From 0fbb0e4fab2d65a68c1bcd388b377feaa20f5370 Mon Sep 17 00:00:00 2001 From: Antoine Prouvost Date: Mon, 2 Oct 2023 18:01:14 +0200 Subject: [PATCH] Use CMake targets for reproc (#2883) * Use CMake targets for reproc * Use reproc-cpp-static on Windows * Upper pin on Mamba --- .github/workflows/static_build.yml | 1 + libmamba/CMakeLists.txt | 80 +++++++++++++++--------------- libmamba/environment-dev.yml | 2 +- libmamba/tests/CMakeLists.txt | 14 ++++-- libmambapy/environment-dev.yml | 2 +- mamba/environment-dev.yml | 4 +- micromamba/CMakeLists.txt | 20 ++++++-- micromamba/environment-dev.yml | 2 +- vcpkg.json | 1 - 9 files changed, 71 insertions(+), 55 deletions(-) diff --git a/.github/workflows/static_build.yml b/.github/workflows/static_build.yml index 1f00e8b73..ea3f31611 100644 --- a/.github/workflows/static_build.yml +++ b/.github/workflows/static_build.yml @@ -138,6 +138,7 @@ jobs: fmt yaml-cpp-static>=0.8.0 libsolv-static>=0.7.24 + reproc-cpp-static>=14.2.4.post0 - name: build micromamba shell: cmd /C call {0} run: | diff --git a/libmamba/CMakeLists.txt b/libmamba/CMakeLists.txt index a23668df9..372cc8315 100644 --- a/libmamba/CMakeLists.txt +++ b/libmamba/CMakeLists.txt @@ -323,6 +323,8 @@ find_package(spdlog REQUIRED) find_package(tl-expected REQUIRED) find_package(nlohmann_json REQUIRED) find_package(yaml-cpp REQUIRED) +find_package(reproc REQUIRED) +find_package(reproc++ REQUIRED) macro(libmamba_create_target target_name linkage output_name) 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") 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) @@ -386,9 +403,6 @@ macro(libmamba_create_target target_name linkage output_name) liblzma.a libnghttp2.a - - libreproc++.a - libreproc.a ) if (APPLE) 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) endif() - - add_compile_definitions(SPDLOG_FMT_EXTERNAL) target_link_libraries( ${target_name} PUBLIC ${STATIC_DEPS} ${MAMBA_FORCE_DYNAMIC_LIBS} - fmt::fmt-header-only - spdlog::spdlog_header_only - yaml-cpp::yaml-cpp ) 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(LIBSOLVEXT_BUILD_STATICRARIES NAMES solvext_static) - find_package(reproc++ CONFIG REQUIRED) find_library(LIBXML2_LIBRARY NAMES libxml2) find_library(ICONV_LIBRARY NAMES libiconv iconv) @@ -479,21 +487,12 @@ macro(libmamba_create_target target_name linkage output_name) ${BZIP2_LIBRARIES} ${LIBLZMA_LIBRARIES} 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} ${LIBSOLVEXT_BUILD_STATICRARIES} ${sodium_LIBRARY_RELEASE} - reproc++ - reproc ) add_compile_definitions( - SPDLOG_FMT_EXTERNAL LIBARCHIVE_STATIC CURL_STATICLIB SOLV_BUILD_STATIC @@ -513,31 +512,30 @@ macro(libmamba_create_target target_name linkage output_name) find_package(zstd REQUIRED) find_package(BZip2 REQUIRED) find_package(OpenSSL REQUIRED) - find_package(reproc++ CONFIG REQUIRED) - set(LIBMAMBA_LIBRARIES_DEPS - ${LIBSOLV_LIBRARIES} - ${LIBSOLVEXT_LIBRARIES} - ${LibArchive_LIBRARIES} - zstd::libzstd_shared - ${CURL_LIBRARIES} - ${OPENSSL_LIBRARIES} - zstd::libzstd_shared - BZip2::BZip2 - yaml-cpp::yaml-cpp - reproc++ - reproc - fmt::fmt - # 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 + target_compile_definitions(${target_name} PUBLIC SPDLOG_FMT_EXTERNAL) + + target_link_libraries( + ${target_name} + PUBLIC + ${LIBSOLV_LIBRARIES} + ${LIBSOLVEXT_LIBRARIES} + ${LibArchive_LIBRARIES} + zstd::libzstd_shared + ${CURL_LIBRARIES} + ${OPENSSL_LIBRARIES} + zstd::libzstd_shared + BZip2::BZip2 + yaml-cpp::yaml-cpp + fmt::fmt + # 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 + PRIVATE + reproc + reproc++ ) - - add_compile_definitions(SPDLOG_FMT_EXTERNAL) - target_link_libraries(${target_name} PUBLIC - ${LIBMAMBA_LIBRARIES_DEPS} - ${MAMBA_FORCE_DYNAMIC_LIBS}) endif () target_compile_features(${target_name} PUBLIC cxx_std_17) diff --git a/libmamba/environment-dev.yml b/libmamba/environment-dev.yml index 615f10e83..de27fc048 100644 --- a/libmamba/environment-dev.yml +++ b/libmamba/environment-dev.yml @@ -12,7 +12,7 @@ dependencies: - libcurl >=7.86 - doctest - cpp-expected - - reproc-cpp + - reproc-cpp >=14.2.4.post0 - yaml-cpp >=0.8.0 - cli11 >=2.2 - spdlog diff --git a/libmamba/tests/CMakeLists.txt b/libmamba/tests/CMakeLists.txt index aafa28954..3a2a96486 100644 --- a/libmamba/tests/CMakeLists.txt +++ b/libmamba/tests/CMakeLists.txt @@ -82,7 +82,10 @@ mamba_target_add_compile_warnings(test_libmamba WARNING_AS_ERROR ${MAMBA_WARNING target_include_directories( 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) @@ -90,8 +93,13 @@ find_package(Threads REQUIRED) target_link_libraries( test_libmamba - PUBLIC ${libmamba_target} - PRIVATE doctest::doctest Threads::Threads + PUBLIC + ${libmamba_target} + reproc + reproc++ + PRIVATE + doctest::doctest + Threads::Threads ) # Copy data directory into binary dir to avoid modifications diff --git a/libmambapy/environment-dev.yml b/libmambapy/environment-dev.yml index a0e6ae657..f5286b4db 100644 --- a/libmambapy/environment-dev.yml +++ b/libmambapy/environment-dev.yml @@ -13,7 +13,7 @@ dependencies: - gtest - gmock - cpp-expected - - reproc-cpp + - reproc-cpp >=14.2.4.post0 - yaml-cpp >=0.8.0 - cli11 >=2.2 - spdlog diff --git a/mamba/environment-dev.yml b/mamba/environment-dev.yml index e4b395c81..a981e183e 100644 --- a/mamba/environment-dev.yml +++ b/mamba/environment-dev.yml @@ -13,7 +13,7 @@ dependencies: - gtest - gmock - cpp-expected - - reproc-cpp + - reproc-cpp >=14.2.4.post0 - yaml-cpp >= 0.8.0 - cli11 >=2.2 - spdlog @@ -24,7 +24,7 @@ dependencies: - pybind11-stubgen <1.0 - pytest >=7.3 - pyyaml - - conda + - conda <23.9.0 - conda-content-trust - cryptography<40.0 # Or breaks conda-content-trust - pip: diff --git a/micromamba/CMakeLists.txt b/micromamba/CMakeLists.txt index e223ed123..950b98ea0 100644 --- a/micromamba/CMakeLists.txt +++ b/micromamba/CMakeLists.txt @@ -69,18 +69,28 @@ if(NOT (TARGET libmamba OR TARGET libmamba-static)) find_package(libmamba REQUIRED) endif () -find_package(Threads REQUIRED) -target_link_libraries(micromamba PRIVATE Threads::Threads) - string(TOUPPER "${MICROMAMBA_LINKAGE}" linkage_upper) message(STATUS "Micromamba linkage: ${MICROMAMBA_LINKAGE}") if (${MICROMAMBA_LINKAGE} STREQUAL "STATIC") - target_link_libraries(micromamba PRIVATE libmamba-static) + set(libmamba_target "libmamba-static") else () - target_link_libraries(micromamba PRIVATE libmamba) + set(libmamba_target "libmamba") 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) install(TARGETS micromamba) diff --git a/micromamba/environment-dev.yml b/micromamba/environment-dev.yml index d2869336b..eb34181ab 100644 --- a/micromamba/environment-dev.yml +++ b/micromamba/environment-dev.yml @@ -14,7 +14,7 @@ dependencies: - gtest - gmock - cpp-expected - - reproc-cpp + - reproc-cpp >=14.2.4.post0 - yaml-cpp >=0.8.0 - cli11 >=2.2 - pytest >=7.3.0 diff --git a/vcpkg.json b/vcpkg.json index 79386b8d3..6c2b0efca 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,7 +3,6 @@ "dependencies": [ "zstd", "curl", - "reproc", { "name": "winreg", "platform": "windows"