Use CMake targets for reproc (#2883)

* Use CMake targets for reproc

* Use reproc-cpp-static on Windows

* Upper pin on Mamba
This commit is contained in:
Antoine Prouvost 2023-10-02 18:01:14 +02:00 committed by GitHub
parent 474be8b9b0
commit 0fbb0e4fab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 71 additions and 55 deletions

View File

@ -138,6 +138,7 @@ jobs:
fmt fmt
yaml-cpp-static>=0.8.0 yaml-cpp-static>=0.8.0
libsolv-static>=0.7.24 libsolv-static>=0.7.24
reproc-cpp-static>=14.2.4.post0
- name: build micromamba - name: build micromamba
shell: cmd /C call {0} shell: cmd /C call {0}
run: | run: |

View File

@ -323,6 +323,8 @@ find_package(spdlog REQUIRED)
find_package(tl-expected REQUIRED) find_package(tl-expected REQUIRED)
find_package(nlohmann_json REQUIRED) find_package(nlohmann_json REQUIRED)
find_package(yaml-cpp REQUIRED) find_package(yaml-cpp REQUIRED)
find_package(reproc REQUIRED)
find_package(reproc++ REQUIRED)
macro(libmamba_create_target target_name linkage output_name) macro(libmamba_create_target target_name linkage output_name)
string(TOUPPER "${linkage}" linkage_upper) string(TOUPPER "${linkage}" linkage_upper)
@ -357,6 +359,21 @@ macro(libmamba_create_target target_name linkage output_name)
message(" -> Statically linking against libmamba (static) dependencies") message(" -> Statically linking against libmamba (static) dependencies")
mamba_target_check_type(yaml-cpp::yaml-cpp STATIC_LIBRARY FATAL_ERROR) mamba_target_check_type(yaml-cpp::yaml-cpp STATIC_LIBRARY FATAL_ERROR)
mamba_target_check_type(reproc STATIC_LIBRARY FATAL_ERROR)
mamba_target_check_type(reproc++ STATIC_LIBRARY FATAL_ERROR)
target_compile_definitions(${target_name} PUBLIC SPDLOG_FMT_EXTERNAL)
target_link_libraries(
${target_name}
PUBLIC
fmt::fmt-header-only
spdlog::spdlog_header_only
yaml-cpp::yaml-cpp
PRIVATE
reproc
reproc++
)
if (UNIX) if (UNIX)
@ -386,9 +403,6 @@ macro(libmamba_create_target target_name linkage output_name)
liblzma.a liblzma.a
libnghttp2.a libnghttp2.a
libreproc++.a
libreproc.a
) )
if (APPLE) if (APPLE)
set(REQUIRED_STATIC_DEPS ${REQUIRED_STATIC_DEPS} libc++.a) set(REQUIRED_STATIC_DEPS ${REQUIRED_STATIC_DEPS} libc++.a)
@ -432,16 +446,11 @@ macro(libmamba_create_target target_name linkage output_name)
target_link_options(${target_name} PUBLIC -static-libstdc++ -static-libgcc) target_link_options(${target_name} PUBLIC -static-libstdc++ -static-libgcc)
endif() endif()
add_compile_definitions(SPDLOG_FMT_EXTERNAL)
target_link_libraries( target_link_libraries(
${target_name} ${target_name}
PUBLIC PUBLIC
${STATIC_DEPS} ${STATIC_DEPS}
${MAMBA_FORCE_DYNAMIC_LIBS} ${MAMBA_FORCE_DYNAMIC_LIBS}
fmt::fmt-header-only
spdlog::spdlog_header_only
yaml-cpp::yaml-cpp
) )
elseif (WIN32) elseif (WIN32)
@ -460,7 +469,6 @@ macro(libmamba_create_target target_name linkage output_name)
find_library(LIBSOLV_BUILD_STATICRARIES NAMES solv_static) find_library(LIBSOLV_BUILD_STATICRARIES NAMES solv_static)
find_library(LIBSOLVEXT_BUILD_STATICRARIES NAMES solvext_static) find_library(LIBSOLVEXT_BUILD_STATICRARIES NAMES solvext_static)
find_package(reproc++ CONFIG REQUIRED)
find_library(LIBXML2_LIBRARY NAMES libxml2) find_library(LIBXML2_LIBRARY NAMES libxml2)
find_library(ICONV_LIBRARY NAMES libiconv iconv) find_library(ICONV_LIBRARY NAMES libiconv iconv)
@ -479,21 +487,12 @@ macro(libmamba_create_target target_name linkage output_name)
${BZIP2_LIBRARIES} ${BZIP2_LIBRARIES}
${LIBLZMA_LIBRARIES} ${LIBLZMA_LIBRARIES}
CURL::libcurl CURL::libcurl
fmt::fmt-header-only
# Since conda-forge spdlog is built with a bundled version of fmt we use the
# header only version to avoid chasing after the correct fmt version mathching
# the one used in the bundle
spdlog::spdlog_header_only
yaml-cpp::yaml-cpp
${LIBSOLV_BUILD_STATICRARIES} ${LIBSOLV_BUILD_STATICRARIES}
${LIBSOLVEXT_BUILD_STATICRARIES} ${LIBSOLVEXT_BUILD_STATICRARIES}
${sodium_LIBRARY_RELEASE} ${sodium_LIBRARY_RELEASE}
reproc++
reproc
) )
add_compile_definitions( add_compile_definitions(
SPDLOG_FMT_EXTERNAL
LIBARCHIVE_STATIC LIBARCHIVE_STATIC
CURL_STATICLIB CURL_STATICLIB
SOLV_BUILD_STATIC SOLV_BUILD_STATIC
@ -513,31 +512,30 @@ macro(libmamba_create_target target_name linkage output_name)
find_package(zstd REQUIRED) find_package(zstd REQUIRED)
find_package(BZip2 REQUIRED) find_package(BZip2 REQUIRED)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
find_package(reproc++ CONFIG REQUIRED)
set(LIBMAMBA_LIBRARIES_DEPS target_compile_definitions(${target_name} PUBLIC SPDLOG_FMT_EXTERNAL)
${LIBSOLV_LIBRARIES}
${LIBSOLVEXT_LIBRARIES} target_link_libraries(
${LibArchive_LIBRARIES} ${target_name}
zstd::libzstd_shared PUBLIC
${CURL_LIBRARIES} ${LIBSOLV_LIBRARIES}
${OPENSSL_LIBRARIES} ${LIBSOLVEXT_LIBRARIES}
zstd::libzstd_shared ${LibArchive_LIBRARIES}
BZip2::BZip2 zstd::libzstd_shared
yaml-cpp::yaml-cpp ${CURL_LIBRARIES}
reproc++ ${OPENSSL_LIBRARIES}
reproc zstd::libzstd_shared
fmt::fmt BZip2::BZip2
# Since conda-forge spdlog is built with a bundled version of fmt we use the yaml-cpp::yaml-cpp
# header only version to avoid chasing after the correct fmt version mathching fmt::fmt
# the one used in the bundle # Since conda-forge spdlog is built with a bundled version of fmt we use the
spdlog::spdlog_header_only # header only version to avoid chasing after the correct fmt version mathching
# the one used in the bundle
spdlog::spdlog_header_only
PRIVATE
reproc
reproc++
) )
add_compile_definitions(SPDLOG_FMT_EXTERNAL)
target_link_libraries(${target_name} PUBLIC
${LIBMAMBA_LIBRARIES_DEPS}
${MAMBA_FORCE_DYNAMIC_LIBS})
endif () endif ()
target_compile_features(${target_name} PUBLIC cxx_std_17) target_compile_features(${target_name} PUBLIC cxx_std_17)

View File

@ -12,7 +12,7 @@ dependencies:
- libcurl >=7.86 - libcurl >=7.86
- doctest - doctest
- cpp-expected - cpp-expected
- reproc-cpp - reproc-cpp >=14.2.4.post0
- yaml-cpp >=0.8.0 - yaml-cpp >=0.8.0
- cli11 >=2.2 - cli11 >=2.2
- spdlog - spdlog

View File

@ -82,7 +82,10 @@ mamba_target_add_compile_warnings(test_libmamba WARNING_AS_ERROR ${MAMBA_WARNING
target_include_directories( target_include_directories(
test_libmamba test_libmamba
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/libmamba/src" PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/libmamba/src"
) )
find_package(doctest REQUIRED) find_package(doctest REQUIRED)
@ -90,8 +93,13 @@ find_package(Threads REQUIRED)
target_link_libraries( target_link_libraries(
test_libmamba test_libmamba
PUBLIC ${libmamba_target} PUBLIC
PRIVATE doctest::doctest Threads::Threads ${libmamba_target}
reproc
reproc++
PRIVATE
doctest::doctest
Threads::Threads
) )
# Copy data directory into binary dir to avoid modifications # Copy data directory into binary dir to avoid modifications

View File

@ -13,7 +13,7 @@ dependencies:
- gtest - gtest
- gmock - gmock
- cpp-expected - cpp-expected
- reproc-cpp - reproc-cpp >=14.2.4.post0
- yaml-cpp >=0.8.0 - yaml-cpp >=0.8.0
- cli11 >=2.2 - cli11 >=2.2
- spdlog - spdlog

View File

@ -13,7 +13,7 @@ dependencies:
- gtest - gtest
- gmock - gmock
- cpp-expected - cpp-expected
- reproc-cpp - reproc-cpp >=14.2.4.post0
- yaml-cpp >= 0.8.0 - yaml-cpp >= 0.8.0
- cli11 >=2.2 - cli11 >=2.2
- spdlog - spdlog
@ -24,7 +24,7 @@ dependencies:
- pybind11-stubgen <1.0 - pybind11-stubgen <1.0
- pytest >=7.3 - pytest >=7.3
- pyyaml - pyyaml
- conda - conda <23.9.0
- conda-content-trust - conda-content-trust
- cryptography<40.0 # Or breaks conda-content-trust - cryptography<40.0 # Or breaks conda-content-trust
- pip: - pip:

View File

@ -69,18 +69,28 @@ if(NOT (TARGET libmamba OR TARGET libmamba-static))
find_package(libmamba REQUIRED) find_package(libmamba REQUIRED)
endif () endif ()
find_package(Threads REQUIRED)
target_link_libraries(micromamba PRIVATE Threads::Threads)
string(TOUPPER "${MICROMAMBA_LINKAGE}" linkage_upper) string(TOUPPER "${MICROMAMBA_LINKAGE}" linkage_upper)
message(STATUS "Micromamba linkage: ${MICROMAMBA_LINKAGE}") message(STATUS "Micromamba linkage: ${MICROMAMBA_LINKAGE}")
if (${MICROMAMBA_LINKAGE} STREQUAL "STATIC") if (${MICROMAMBA_LINKAGE} STREQUAL "STATIC")
target_link_libraries(micromamba PRIVATE libmamba-static) set(libmamba_target "libmamba-static")
else () else ()
target_link_libraries(micromamba PRIVATE libmamba) set(libmamba_target "libmamba")
endif () endif ()
find_package(Threads REQUIRED)
find_package(reproc REQUIRED)
find_package(reproc++ REQUIRED)
target_link_libraries(
micromamba
PRIVATE
${libmamba_target}
Threads::Threads
reproc
reproc++
)
set_property(TARGET micromamba PROPERTY CXX_STANDARD 17) set_property(TARGET micromamba PROPERTY CXX_STANDARD 17)
install(TARGETS micromamba) install(TARGETS micromamba)

View File

@ -14,7 +14,7 @@ dependencies:
- gtest - gtest
- gmock - gmock
- cpp-expected - cpp-expected
- reproc-cpp - reproc-cpp >=14.2.4.post0
- yaml-cpp >=0.8.0 - yaml-cpp >=0.8.0
- cli11 >=2.2 - cli11 >=2.2
- pytest >=7.3.0 - pytest >=7.3.0

View File

@ -3,7 +3,6 @@
"dependencies": [ "dependencies": [
"zstd", "zstd",
"curl", "curl",
"reproc",
{ {
"name": "winreg", "name": "winreg",
"platform": "windows" "platform": "windows"