From 2549198cfcac9cb38feb616ceb9ecff55ec2ca36 Mon Sep 17 00:00:00 2001 From: AntoinePrv Date: Tue, 7 Nov 2023 10:56:41 +0100 Subject: [PATCH] Apply cmake-format --- CMakeLists.txt | 44 ++-- cmake/Checks.cmake | 3 +- cmake/CompilerWarnings.cmake | 8 +- cmake/LinkTimeOptimization.cmake | 49 ++-- cmake/modules/FindLibsolv.cmake | 58 +++-- libmamba/CMakeLists.txt | 395 ++++++++++++++++--------------- libmamba/tests/CMakeLists.txt | 20 +- libmambapy/CMakeLists.txt | 8 +- mamba_package/CMakeLists.txt | 14 +- micromamba/CMakeLists.txt | 47 ++-- 10 files changed, 349 insertions(+), 297 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c61fe5d6c..5a17533d08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # # The full license is in the file LICENSE, distributed with this software. -cmake_minimum_required (VERSION 3.16) +cmake_minimum_required(VERSION 3.16) cmake_policy(SET CMP0025 NEW) # Introduced in cmake 3.0 cmake_policy(SET CMP0077 NEW) # Introduced in cmake 3.13 @@ -19,25 +19,39 @@ option(BUILD_LIBMAMBA_TESTS "Build libmamba C++ tests" OFF) option(BUILD_MICROMAMBA "Build micromamba" OFF) option(BUILD_MAMBA_PACKAGE "Build mamba package utility" OFF) option(MAMBA_WARNING_AS_ERROR "Treat compiler warnings as errors" OFF) -set(MAMBA_LTO "Default" CACHE STRING "Apply Link Time Optimization to targets") +set( + MAMBA_LTO + "Default" + CACHE STRING "Apply Link Time Optimization to targets" +) include("cmake/CompilerWarnings.cmake") include("cmake/LinkTimeOptimization.cmake") include("cmake/Checks.cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules") -if (MSVC) - # NOMINMAX : prevent tons of code to be included when having to `#include ` - # /EHsc : enable C++ exceptions (otherwise exceptions do not work) - # /Zc:__cplusplus : makes sure `__cplusplus` is set to the current C++ version language. Otherwise it is always set to an incorrect wrong value. - # /MP : enable multi-process build with MSBuild (it should be on by default but CMake generates the project files without the right params). - # /external:I $ENV{CONDA_PREFIX}: consider the conda env prefix libraries headers as "external" to this project. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /DNOMINMAX /EHsc /Zc:__cplusplus /MP /experimental:external /external:I $ENV{CONDA_PREFIX}") +if(MSVC) + # NOMINMAX : prevent tons of code to be included when having to `#include ` /EHsc : + # enable C++ exceptions (otherwise exceptions do not work) /Zc:__cplusplus : makes sure + # `__cplusplus` is set to the current C++ version language. Otherwise it is always set to an + # incorrect wrong value. /MP : enable multi-process build with MSBuild (it should be on by + # default but CMake generates the project files without the right params). /external:I + # $ENV{CONDA_PREFIX}: consider the conda env prefix libraries headers as "external" to this + # project. + set( + CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /DNOMINMAX /EHsc /Zc:__cplusplus /MP /experimental:external /external:I $ENV{CONDA_PREFIX}" + ) # Force release mode to avoid debug libraries to be linked - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The build type") + set( + CMAKE_BUILD_TYPE + "Release" + CACHE STRING "The build type" + ) # add_definitions("-DUNICODE -D_UNICODE") set( - CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL" + CMAKE_MSVC_RUNTIME_LIBRARY + "MultiThreaded$<$:Debug>DLL" CACHE STRING "MSVC runtime library" ) endif() @@ -46,21 +60,21 @@ endif() # ======== # libmamba library and tests -if (BUILD_LIBMAMBA) +if(BUILD_LIBMAMBA) add_subdirectory(libmamba) endif() # Python bindings of libmamba -if (BUILD_LIBMAMBAPY) +if(BUILD_LIBMAMBAPY) add_subdirectory(libmambapy) endif() # micromamba -if (BUILD_MICROMAMBA) +if(BUILD_MICROMAMBA) add_subdirectory(micromamba) endif() # mamba package tarball utility -if (BUILD_MAMBA_PACKAGE) +if(BUILD_MAMBA_PACKAGE) add_subdirectory(mamba_package) endif() diff --git a/cmake/Checks.cmake b/cmake/Checks.cmake index 3e051750df..fb5c064a86 100644 --- a/cmake/Checks.cmake +++ b/cmake/Checks.cmake @@ -2,8 +2,7 @@ # Check that the target has the proper type. # -# This is useful for targets that can be either static or dynamic but have the -# same name. +# This is useful for targets that can be either static or dynamic but have the same name. function(mamba_target_check_type target expected_type log_level) get_target_property(actual_type ${target} TYPE) if(NOT actual_type STREQUAL expected_type) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index e3495bc458..a5637ef7ac 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -15,16 +15,16 @@ function(mamba_target_add_compile_warnings target) # Extra arguments not accounted for if(ARG_UNPARSED_ARGUMENTS) message( - AUTHOR_WARNING - "Unrecoginzed options passed to ${CMAKE_CURRENT_FUNCTION}: " - "${ARG_UNPARSED_ARGUMENTS}" + AUTHOR_WARNING "Unrecoginzed options passed to ${CMAKE_CURRENT_FUNCTION}: " + "${ARG_UNPARSED_ARGUMENTS}" ) endif() set( msvc_warnings # External sever warnings - /experimental:external /external:W1 + /experimental:external + /external:W1 # Baseline reasonable warnings /W4 # "identfier": conversion from "type1" to "type1", possible loss of data diff --git a/cmake/LinkTimeOptimization.cmake b/cmake/LinkTimeOptimization.cmake index 5a9d6ef916..d42d5866ed 100644 --- a/cmake/LinkTimeOptimization.cmake +++ b/cmake/LinkTimeOptimization.cmake @@ -2,7 +2,6 @@ include(CheckIPOSupported) - # Detect is setting Link Time Optimization is recommended. # # Currenlty checks if LTO is supported and if the build is a release. @@ -17,9 +16,8 @@ function(mamba_should_lto) # Extra arguments not accounted for if(arg_UNPARSED_ARGUMENTS) message( - AUTHOR_WARNING - "Unrecoginzed options passed to ${CMAKE_CURRENT_FUNCTION}: " - "${ARG_UNPARSED_ARGUMENTS}" + AUTHOR_WARNING "Unrecoginzed options passed to ${CMAKE_CURRENT_FUNCTION}: " + "${ARG_UNPARSED_ARGUMENTS}" ) endif() @@ -27,28 +25,46 @@ function(mamba_should_lto) string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower) set(valid_release_names "release" "relwithdebinfo") if(NOT ${build_type_lower} IN_LIST valid_release_names) - set(${arg_RESULT} FALSE PARENT_SCOPE) - set(${arg_OUTPUT} "the build type is not a release" PARENT_SCOPE) + set( + ${arg_RESULT} + FALSE + PARENT_SCOPE + ) + set( + ${arg_OUTPUT} + "the build type is not a release" + PARENT_SCOPE + ) return() endif() # Check if LTO is supported by compiler check_ipo_supported(RESULT lto_is_supported OUTPUT lto_not_supported_reason) if(NOT lto_is_supported) - set(${arg_RESULT} FALSE PARENT_SCOPE) - set(${arg_OUTPUT} "${lto_not_supported_reason}" PARENT_SCOPE) + set( + ${arg_RESULT} + FALSE + PARENT_SCOPE + ) + set( + ${arg_OUTPUT} + "${lto_not_supported_reason}" + PARENT_SCOPE + ) endif() - set(${arg_RESULT} TRUE PARENT_SCOPE) + set( + ${arg_RESULT} + TRUE + PARENT_SCOPE + ) endfunction() - # Set Link Time Optimization on a given target. # -# MODE parameter takes the possible values -# - A false constant: deactivate LTO -# - A true constant: activate LTO, fails if this is not supported by the compiler -# - "Default" or "Auto": set LTO if supported and the build type is a release. +# MODE parameter takes the possible values - A false constant: deactivate LTO - A true constant: +# activate LTO, fails if this is not supported by the compiler - "Default" or "Auto": set LTO if +# supported and the build type is a release. function(mamba_target_set_lto target) # Names of option parameters (without arguments) set(options) @@ -60,9 +76,8 @@ function(mamba_target_set_lto target) # Extra arguments not accounted for if(arg_UNPARSED_ARGUMENTS) message( - AUTHOR_WARNING - "Unrecoginzed parameter passed to ${CMAKE_CURRENT_FUNCTION}: " - "'${arg_UNPARSED_ARGUMENTS}'" + AUTHOR_WARNING "Unrecoginzed parameter passed to ${CMAKE_CURRENT_FUNCTION}: " + "'${arg_UNPARSED_ARGUMENTS}'" ) return() endif() diff --git a/cmake/modules/FindLibsolv.cmake b/cmake/modules/FindLibsolv.cmake index 8d79d0f875..79f8e64145 100644 --- a/cmake/modules/FindLibsolv.cmake +++ b/cmake/modules/FindLibsolv.cmake @@ -1,30 +1,36 @@ find_package(PkgConfig) pkg_check_modules(PC_Libsolv QUIET libsolv) -find_path(Libsolv_INCLUDE_DIR +find_path( + Libsolv_INCLUDE_DIR NAMES solv/pool.h solvversion.h PATHS ${PC_Libsolv_INCLUDE_DIRS} ) -find_path(Libsolvext_INCLUDE_DIR +find_path( + Libsolvext_INCLUDE_DIR NAMES solv/repo_conda.h repo_conda.h PATHS ${PC_Libsolv_INCLUDE_DIRS} ) -find_library(Libsolv_LIBRARY +find_library( + Libsolv_LIBRARY NAMES libsolv.so libsolv.dylib solv.lib PATHS ${PC_Libsolv_LIBRARY_DIRS} ) -find_library(Libsolv_static_LIBRARY +find_library( + Libsolv_static_LIBRARY NAMES libsolv.a solv_static PATHS ${PC_Libsolv_LIBRARY_DIRS} ) -find_library(Libsolvext_LIBRARY +find_library( + Libsolvext_LIBRARY NAMES libsolvext.so libsolvext.dylib solvext.lib PATHS ${PC_Libsolv_LIBRARY_DIRS} ) -find_library(Libsolvext_static_LIBRARY +find_library( + Libsolvext_static_LIBRARY NAMES libsolvext.a solvext_static PATHS ${PC_Libsolv_LIBRARY_DIRS} ) @@ -44,10 +50,11 @@ if(Libsolv_FOUND) if(NOT TARGET solv::libsolv_static AND Libsolv_static_LIBRARY) add_library(solv::libsolv_static STATIC IMPORTED) set_target_properties( - solv::libsolv_static PROPERTIES - IMPORTED_LOCATION "${Libsolv_static_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${Libsolv_INCLUDE_DIR}" + solv::libsolv_static + PROPERTIES + IMPORTED_LOCATION "${Libsolv_static_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libsolv_INCLUDE_DIR}" ) endif() if(NOT TARGET solv::libsolv AND Libsolv_LIBRARY) @@ -57,20 +64,22 @@ if(Libsolv_FOUND) add_library(solv::libsolv UNKNOWN IMPORTED) endif() set_target_properties( - solv::libsolv PROPERTIES - IMPORTED_LOCATION "${Libsolv_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${Libsolv_INCLUDE_DIR}" + solv::libsolv + PROPERTIES + IMPORTED_LOCATION "${Libsolv_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libsolv_INCLUDE_DIR}" ) endif() if(NOT TARGET solv::libsolvext_static AND Libsolvext_static_LIBRARY) add_library(solv::libsolvext_static STATIC IMPORTED) set_target_properties( - solv::libsolvext_static PROPERTIES - IMPORTED_LOCATION "${Libsolvext_static_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${Libsolvext_INCLUDE_DIR}" + solv::libsolvext_static + PROPERTIES + IMPORTED_LOCATION "${Libsolvext_static_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libsolvext_INCLUDE_DIR}" ) endif() if(NOT TARGET solv::libsolvext AND Libsolvext_LIBRARY) @@ -80,12 +89,11 @@ if(Libsolv_FOUND) add_library(solv::libsolvext UNKNOWN IMPORTED) endif() set_target_properties( - solv::libsolvext PROPERTIES - IMPORTED_LOCATION "${Libsolvext_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${Libsolvext_INCLUDE_DIR}" + solv::libsolvext + PROPERTIES + IMPORTED_LOCATION "${Libsolvext_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Libsolv_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libsolvext_INCLUDE_DIR}" ) endif() -endif( - - ) +endif() diff --git a/libmamba/CMakeLists.txt b/libmamba/CMakeLists.txt index 2485e835e1..5b1f5496f4 100644 --- a/libmamba/CMakeLists.txt +++ b/libmamba/CMakeLists.txt @@ -4,7 +4,7 @@ # # The full license is in the file LICENSE, distributed with this software. -cmake_minimum_required (VERSION 3.16) +cmake_minimum_required(VERSION 3.16) cmake_policy(SET CMP0025 NEW) # Introduced in cmake 3.0 cmake_policy(SET CMP0077 NEW) # Introduced in cmake 3.13 project(libmamba) @@ -15,81 +15,110 @@ set(LIBMAMBA_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data) # Versioning # =========== -file(STRINGS "${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp" libmamba_version_defines - REGEX "#define LIBMAMBA_VERSION_(MAJOR|MINOR|PATCH)") +file( + STRINGS "${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp" libmamba_version_defines + REGEX "#define LIBMAMBA_VERSION_(MAJOR|MINOR|PATCH)" +) foreach(ver ${libmamba_version_defines}) if(ver MATCHES "#define LIBMAMBA_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$") - set(LIBMAMBA_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") + set( + LIBMAMBA_VERSION_${CMAKE_MATCH_1} + "${CMAKE_MATCH_2}" + CACHE INTERNAL "" + ) endif() endforeach() -set(${PROJECT_NAME}_VERSION - ${LIBMAMBA_VERSION_MAJOR}.${LIBMAMBA_VERSION_MINOR}.${LIBMAMBA_VERSION_PATCH}) +set( + ${PROJECT_NAME}_VERSION + ${LIBMAMBA_VERSION_MAJOR}.${LIBMAMBA_VERSION_MINOR}.${LIBMAMBA_VERSION_PATCH} +) message(STATUS "Building libmamba v${${PROJECT_NAME}_VERSION}") - -# Binary version -# See the following URL for explanations about the binary versionning +# Binary version See the following URL for explanations about the binary versionning # https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info -file(STRINGS "${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp" libmamba_version_defines - REGEX "#define LIBMAMBA_BINARY_(CURRENT|REVISION|AGE)") +file( + STRINGS "${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp" libmamba_version_defines + REGEX "#define LIBMAMBA_BINARY_(CURRENT|REVISION|AGE)" +) foreach(ver ${libmamba_version_defines}) if(ver MATCHES "#define LIBMAMBA_BINARY_(CURRENT|REVISION|AGE) +([^ ]+)$") - set(LIBMAMBA_BINARY_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") + set( + LIBMAMBA_BINARY_${CMAKE_MATCH_1} + "${CMAKE_MATCH_2}" + CACHE INTERNAL "" + ) endif() endforeach() -set(LIBMAMBA_BINARY_VERSION - ${LIBMAMBA_BINARY_CURRENT}.${LIBMAMBA_BINARY_REVISION}.${LIBMAMBA_BINARY_AGE}) +set( + LIBMAMBA_BINARY_VERSION + ${LIBMAMBA_BINARY_CURRENT}.${LIBMAMBA_BINARY_REVISION}.${LIBMAMBA_BINARY_AGE} +) message(STATUS "libmamba binary version: v${LIBMAMBA_BINARY_VERSION}") - # Build options # ============= option(BUILD_TESTS "Build libmamba C++ tests" OFF) option(BUILD_SHARED "Build shared libmamba library" OFF) option(BUILD_STATIC "Build static libmamba library with static linkage to its dependencies" OFF) -set(BUILD_LOG_LEVEL "TRACE" CACHE STRING "Logger active level at compile time") +set( + BUILD_LOG_LEVEL + "TRACE" + CACHE STRING "Logger active level at compile time" +) -if (NOT ${BUILD_LOG_LEVEL} MATCHES "^(TRACE|DEBUG|INFO|WARN|ERROR|CRITICAL|OFF)$") - message(FATAL_ERROR "Invalid log level: ${BUILD_LOG_LEVEL}, should be one of { TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF }") -endif () +if(NOT ${BUILD_LOG_LEVEL} MATCHES "^(TRACE|DEBUG|INFO|WARN|ERROR|CRITICAL|OFF)$") + message( + FATAL_ERROR + "Invalid log level: ${BUILD_LOG_LEVEL}, should be one of { TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF }" + ) +endif() -if (BUILD_STATIC) +if(BUILD_STATIC) add_definitions("-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${BUILD_LOG_LEVEL}") add_definitions(-DLIBMAMBA_STATIC_DEPS) -endif () +endif() -if (WIN32) +if(WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif () +endif() option(ENABLE_ASAN "Enable Address-Sanitizer (currently only supported on GCC and Clang)" OFF) if(ENABLE_ASAN) - message(WARNING "Address-Sanitizer instrumentation will be injected into binaries - do not release these binaries") - add_compile_options(-fno-omit-frame-pointer -fsanitize=address) - add_link_options(-fno-omit-frame-pointer -fsanitize=address) + message( + WARNING + "Address-Sanitizer instrumentation will be injected into binaries - do not release these binaries" + ) + add_compile_options(-fno-omit-frame-pointer -fsanitize=address) + add_link_options(-fno-omit-frame-pointer -fsanitize=address) endif() if(ENABLE_TSAN) - message(WARNING "Thread-Sanitizer instrumentation will be injected into binaries - do not release these binaries") - add_compile_options(-fno-omit-frame-pointer -fsanitize=thread) - add_link_options(-fno-omit-frame-pointer -fsanitize=thread) + message( + WARNING + "Thread-Sanitizer instrumentation will be injected into binaries - do not release these binaries" + ) + add_compile_options(-fno-omit-frame-pointer -fsanitize=thread) + add_link_options(-fno-omit-frame-pointer -fsanitize=thread) endif() if(ENABLE_USAN) - message(WARNING "Undefined-Sanitizer instrumentation will be injected into binaries - do not release these binaries") - add_compile_options(-fno-omit-frame-pointer -fsanitize=undefined) - add_link_options(-fno-omit-frame-pointer -fsanitize=undefined) + message( + WARNING + "Undefined-Sanitizer instrumentation will be injected into binaries - do not release these binaries" + ) + add_compile_options(-fno-omit-frame-pointer -fsanitize=undefined) + add_link_options(-fno-omit-frame-pointer -fsanitize=undefined) endif() - # Source files # ============ -find_package (Python3 COMPONENTS Interpreter) +find_package(Python3 COMPONENTS Interpreter) -set(SHELL_SCRIPTS +set( + SHELL_SCRIPTS micromamba.sh micromamba.csh micromamba.bat @@ -101,21 +130,24 @@ set(SHELL_SCRIPTS mamba.xsh mamba.fish compile_pyc.py - mamba_completion.posix) + mamba_completion.posix +) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/shell_scripts) foreach(script ${SHELL_SCRIPTS}) string(REPLACE "." "_" script_var ${script}) - add_custom_command(OUTPUT shell_scripts/${script}.cpp - DEPENDS data/${script} - COMMAND ${Python3_EXECUTABLE} ${LIBMAMBA_DATA_DIR}/bin2header.py - --extern - -v data_${script_var} - -i ${CMAKE_CURRENT_SOURCE_DIR}/data/${script} - -o ${CMAKE_CURRENT_BINARY_DIR}/shell_scripts/${script}.cpp) + add_custom_command( + OUTPUT shell_scripts/${script}.cpp + DEPENDS data/${script} + COMMAND + ${Python3_EXECUTABLE} ${LIBMAMBA_DATA_DIR}/bin2header.py --extern -v data_${script_var} + -i ${CMAKE_CURRENT_SOURCE_DIR}/data/${script} -o + ${CMAKE_CURRENT_BINARY_DIR}/shell_scripts/${script}.cpp + ) endforeach() -set(LIBMAMBA_SOURCES +set( + LIBMAMBA_SOURCES longpath.manifest ${LIBMAMBA_SOURCE_DIR}/version.cpp # Filesystem library @@ -190,7 +222,6 @@ set(LIBMAMBA_SOURCES ${LIBMAMBA_SOURCE_DIR}/core/env_lockfile.cpp ${LIBMAMBA_SOURCE_DIR}/core/execution.cpp ${LIBMAMBA_SOURCE_DIR}/core/timeref.cpp - # API (high-level) ${LIBMAMBA_SOURCE_DIR}/api/c_api.cpp ${LIBMAMBA_SOURCE_DIR}/api/channel_loader.cpp @@ -211,7 +242,8 @@ foreach(script ${SHELL_SCRIPTS}) list(APPEND LIBMAMBA_SOURCES shell_scripts/${script}.cpp) endforeach() -set(LIBMAMBA_PUBLIC_HEADERS +set( + LIBMAMBA_PUBLIC_HEADERS ${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp # Filesystem library ${LIBMAMBA_INCLUDE_DIR}/mamba/fs/filesystem.hpp @@ -308,7 +340,8 @@ set(LIBMAMBA_PUBLIC_HEADERS ${LIBMAMBA_INCLUDE_DIR}/mamba/api/update.hpp ) -set(LIBMAMBA_PRIVATE_HEADERS +set( + LIBMAMBA_PRIVATE_HEADERS # C++ wrapping of libsolv ${LIBMAMBA_SOURCE_DIR}/solv-cpp/queue.hpp ${LIBMAMBA_SOURCE_DIR}/solv-cpp/ids.hpp @@ -338,34 +371,24 @@ find_package(Libsolv REQUIRED) macro(libmamba_create_target target_name linkage output_name) string(TOUPPER "${linkage}" linkage_upper) - if (NOT ${linkage_upper} MATCHES "^(SHARED|STATIC)$") + if(NOT ${linkage_upper} MATCHES "^(SHARED|STATIC)$") message(FATAL_ERROR "Invalid library linkage: ${linkage}") - endif () + endif() # Output # ====== add_library( - ${target_name} ${linkage_upper} - ${LIBMAMBA_PUBLIC_HEADERS} - ${LIBMAMBA_PRIVATE_HEADERS} - ${LIBMAMBA_SOURCES} + ${target_name} + ${linkage_upper} ${LIBMAMBA_PUBLIC_HEADERS} ${LIBMAMBA_PRIVATE_HEADERS} ${LIBMAMBA_SOURCES} ) # Header only libraries are always linked the same way - target_link_libraries( - ${target_name} - PUBLIC - tl::expected - nlohmann_json::nlohmann_json - ) + target_link_libraries(${target_name} PUBLIC tl::expected nlohmann_json::nlohmann_json) - mamba_target_add_compile_warnings( - ${target_name} - WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR} - ) + mamba_target_add_compile_warnings(${target_name} WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR}) mamba_target_set_lto(${target_name} MODE ${MAMBA_LTO}) - if (${linkage_upper} STREQUAL "STATIC") + if(${linkage_upper} STREQUAL "STATIC") message(" -> Statically linking against libmamba (static) dependencies") target_compile_definitions(${target_name} PUBLIC SPDLOG_FMT_EXTERNAL) @@ -384,65 +407,62 @@ macro(libmamba_create_target target_name linkage output_name) yaml-cpp::yaml-cpp solv::libsolv_static solv::libsolvext_static - PRIVATE - reproc - reproc++ - simdjson::simdjson_static + PRIVATE reproc reproc++ simdjson::simdjson_static ) - if (UNIX) + if(UNIX) - set(REQUIRED_STATIC_DEPS + set( + REQUIRED_STATIC_DEPS libcurl.a libssh2.a - libgssapi_krb5.a libkrb5.a libk5crypto.a libkrb5support.a libcom_err.a - libssl.a libcrypto.a - libarchive.a - libiconv.a libbz2.a liblz4.a libzstd.a libz.a liblzma.a - libnghttp2.a ) - if (APPLE) + if(APPLE) set(REQUIRED_STATIC_DEPS ${REQUIRED_STATIC_DEPS} libc++.a) endif() - if (UNIX AND NOT APPLE) + if(UNIX AND NOT APPLE) list(REMOVE_ITEM REQUIRED_STATIC_DEPS libiconv.a) endif() set(STATIC_DEPS "") foreach(LIB ${REQUIRED_STATIC_DEPS}) set(TMP_LIB "${LIB}-NOTFOUND") - find_library(TMP_LIB - NAMES "${LIB}" - ) - if (NOT ${TMP_LIB} STREQUAL "TMP_LIB-NOTFOUND") + find_library(TMP_LIB NAMES "${LIB}") + if(NOT ${TMP_LIB} STREQUAL "TMP_LIB-NOTFOUND") list(APPEND STATIC_DEPS "${TMP_LIB}") - else () + else() list(APPEND STATIC_DEPS "${LIB}-NOTFOUND") - endif () + endif() endforeach(LIB) - if (APPLE) + if(APPLE) find_library(SECURITY_LIBRARY Security) find_library(SYSTEMCONFIGURATION_LIBRARY SystemConfiguration) find_library(COREFOUNDATION_LIBRARY CoreFoundation) message("Found library: ${SECURITY_LIBRARY}\n${COREFOUNDATION_LIBRARY}") - list(APPEND STATIC_DEPS ${COREFOUNDATION_LIBRARY} ${SECURITY_LIBRARY} ${SYSTEMCONFIGURATION_LIBRARY}) + list( + APPEND + STATIC_DEPS + ${COREFOUNDATION_LIBRARY} + ${SECURITY_LIBRARY} + ${SYSTEMCONFIGURATION_LIBRARY} + ) endif() message(" -> Found static dependencies:") @@ -450,22 +470,17 @@ macro(libmamba_create_target target_name linkage output_name) message(" - ${LIB}") endforeach(LIB) - if (APPLE) - set (MAMBA_FORCE_DYNAMIC_LIBS resolv c++abi) + if(APPLE) + set(MAMBA_FORCE_DYNAMIC_LIBS resolv c++abi) target_link_options(${target_name} PRIVATE -static-libstdc++) - elseif (UNIX) + elseif(UNIX) set(MAMBA_FORCE_DYNAMIC_LIBS rt dl resolv) target_link_options(${target_name} PUBLIC -static-libstdc++ -static-libgcc) endif() - target_link_libraries( - ${target_name} - PUBLIC - ${STATIC_DEPS} - ${MAMBA_FORCE_DYNAMIC_LIBS} - ) + target_link_libraries(${target_name} PUBLIC ${STATIC_DEPS} ${MAMBA_FORCE_DYNAMIC_LIBS}) - elseif (WIN32) + elseif(WIN32) set(CMAKE_PREFIX_PATH "$ENV{VCPKG_ROOT}/installed/x64-windows-static-md/") @@ -484,29 +499,28 @@ macro(libmamba_create_target target_name linkage output_name) find_library(CHARSET_LIBRARY NAMES libcharset charset) message("Found: ${LIBXML2_LIBRARY} ${ICONV_LIBRARY} ${CHARSET_LIBRARY}") - target_link_libraries(${target_name} PUBLIC - ${CRYPTO_LIBRARIES} - ${LibArchive_LIBRARY} - ${LIBXML2_LIBRARY} - ${ICONV_LIBRARY} - ${CHARSET_LIBRARY} - zstd::libzstd_static - ${LZ4_LIBRARY} - ${LZO2_LIBRARY} - ${BZIP2_LIBRARIES} - ${LIBLZMA_LIBRARIES} - CURL::libcurl - ${sodium_LIBRARY_RELEASE} + target_link_libraries( + ${target_name} + PUBLIC + ${CRYPTO_LIBRARIES} + ${LibArchive_LIBRARY} + ${LIBXML2_LIBRARY} + ${ICONV_LIBRARY} + ${CHARSET_LIBRARY} + zstd::libzstd_static + ${LZ4_LIBRARY} + ${LZO2_LIBRARY} + ${BZIP2_LIBRARIES} + ${LIBLZMA_LIBRARIES} + CURL::libcurl + ${sodium_LIBRARY_RELEASE} ) - add_compile_definitions( - LIBARCHIVE_STATIC - CURL_STATICLIB - ) + add_compile_definitions(LIBARCHIVE_STATIC CURL_STATICLIB) include_directories($ENV{CONDA_PREFIX}/Library/include/) include_directories($ENV{VCPKG_ROOT}/installed/x64-windows-static-md/include/) endif() - else () + else() message(" -> Dynamically linking against libmamba (shared) dependencies") mamba_target_check_type(yaml-cpp::yaml-cpp SHARED_LIBRARY WARNING) @@ -532,29 +546,24 @@ macro(libmamba_create_target target_name linkage output_name) 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 + # 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 solv::libsolv solv::libsolvext - PRIVATE - reproc - reproc++ - simdjson::simdjson + PRIVATE reproc reproc++ simdjson::simdjson ) - endif () + endif() target_compile_features(${target_name} PUBLIC cxx_std_17) target_include_directories( ${target_name} - PUBLIC - $ - $ + PUBLIC $ $ ) - if (WIN32) + if(WIN32) find_path( WINREG_INCLUDE_DIR NAMES WinReg.hpp @@ -562,67 +571,62 @@ macro(libmamba_create_target target_name linkage output_name) ) endif() - target_include_directories( - ${target_name} - PRIVATE - ${LIBMAMBA_SOURCE_DIR} - ${WINREG_INCLUDE_DIR} - ) + target_include_directories(${target_name} PRIVATE ${LIBMAMBA_SOURCE_DIR} ${WINREG_INCLUDE_DIR}) - if (UNIX) + if(UNIX) math(EXPR LIBMAMBA_BINARY_COMPATIBLE "${LIBMAMBA_BINARY_CURRENT} - ${LIBMAMBA_BINARY_AGE}") set_target_properties( ${target_name} PROPERTIES - #PUBLIC_HEADER "${LIBMAMBA_PUBLIC_HEADERS}" - COMPILE_DEFINITIONS "LIBMAMBA_EXPORTS" - PREFIX "" - VERSION "${LIBMAMBA_BINARY_COMPATIBLE}.${LIBMAMBA_BINARY_REVISION}.${LIBMAMBA_BINARY_AGE}" - SOVERSION ${LIBMAMBA_BINARY_COMPATIBLE} - OUTPUT_NAME "${output_name}" + # PUBLIC_HEADER "${LIBMAMBA_PUBLIC_HEADERS}" + COMPILE_DEFINITIONS "LIBMAMBA_EXPORTS" + PREFIX "" + VERSION + "${LIBMAMBA_BINARY_COMPATIBLE}.${LIBMAMBA_BINARY_REVISION}.${LIBMAMBA_BINARY_AGE}" + SOVERSION ${LIBMAMBA_BINARY_COMPATIBLE} + OUTPUT_NAME "${output_name}" ) else() set_target_properties( ${target_name} PROPERTIES - #PUBLIC_HEADER "${LIBMAMBA_PUBLIC_HEADERS}" - COMPILE_DEFINITIONS "LIBMAMBA_EXPORTS" - PREFIX "" - VERSION ${LIBMAMBA_BINARY_VERSION} - SOVERSION ${LIBMAMBA_BINARY_CURRENT} - OUTPUT_NAME "${output_name}" + # PUBLIC_HEADER "${LIBMAMBA_PUBLIC_HEADERS}" + COMPILE_DEFINITIONS "LIBMAMBA_EXPORTS" + PREFIX "" + VERSION ${LIBMAMBA_BINARY_VERSION} + SOVERSION ${LIBMAMBA_BINARY_CURRENT} + OUTPUT_NAME "${output_name}" ) target_compile_definitions(${target_name} PUBLIC GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE) endif() - if (${linkage_upper} STREQUAL "STATIC") + if(${linkage_upper} STREQUAL "STATIC") find_package(Threads REQUIRED) target_link_libraries(${target_name} PUBLIC Threads::Threads) - endif () + endif() list(APPEND libmamba_targets ${target_name}) add_library(mamba::${target_name} ALIAS ${target_name}) endmacro() - set(libmamba_targets "") -if (BUILD_SHARED) +if(BUILD_SHARED) message(STATUS "Adding shared libmamba target") libmamba_create_target(libmamba-dyn SHARED libmamba) -endif () +endif() -if (BUILD_STATIC) +if(BUILD_STATIC) message(STATUS "Adding static libmamba target") - # On Windows, a static library should use a different output name - # to avoid the conflict with the import library of a shared one. - if (CMAKE_HOST_WIN32) + # On Windows, a static library should use a different output name to avoid the conflict with the + # import library of a shared one. + if(CMAKE_HOST_WIN32) libmamba_create_target(libmamba-static STATIC libmamba_static) - else () + else() libmamba_create_target(libmamba-static STATIC libmamba) - endif () + endif() endif() if(BUILD_SHARED_LIBS AND BUILD_SHARED) @@ -633,10 +637,10 @@ elseif(BUILD_SHARED) add_library(mamba::libmamba ALIAS libmamba-dyn) else() message(FATAL_ERROR "Select at least a build variant for libmamba") -endif () +endif() # Tests -if (BUILD_LIBMAMBA_TESTS) +if(BUILD_LIBMAMBA_TESTS) add_subdirectory(tests) endif() @@ -646,19 +650,27 @@ endif() include(GNUInstallDirs) include(CMakePackageConfigHelpers) -set(LIBMAMBA_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for libmambaConfig.cmake") +set( + LIBMAMBA_CMAKECONFIG_INSTALL_DIR + "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + CACHE STRING "install path for libmambaConfig.cmake" +) -install(TARGETS ${libmamba_targets} - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install( + TARGETS ${libmamba_targets} + EXPORT ${PROJECT_NAME}-targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) -install(DIRECTORY "${LIBMAMBA_INCLUDE_DIR}/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - FILES_MATCHING - PATTERN "*.hpp" - PATTERN "*.h") +install( + DIRECTORY "${LIBMAMBA_INCLUDE_DIR}/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILES_MATCHING + PATTERN "*.hpp" + PATTERN "*.h" +) # Makes the project importable from the build directory export( @@ -669,25 +681,36 @@ export( # Configure 'mambaConfig.cmake' for a build tree set(MAMBA_CONFIG_CODE "####### Expanded from \@MAMBA_CONFIG_CODE\@ #######\n") -set(MAMBA_CONFIG_CODE "${MAMBA_CONFIG_CODE}set(CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake;\${CMAKE_MODULE_PATH}\")\n") +set( + MAMBA_CONFIG_CODE + "${MAMBA_CONFIG_CODE}set(CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake;\${CMAKE_MODULE_PATH}\")\n" +) set(MAMBA_CONFIG_CODE "${MAMBA_CONFIG_CODE}##################################################") -configure_package_config_file(${PROJECT_NAME}Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${PROJECT_BINARY_DIR}) +configure_package_config_file( + ${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION ${PROJECT_BINARY_DIR} +) # Configure 'mambaConfig.cmake' for an install tree set(MAMBA_CONFIG_CODE "") -configure_package_config_file(${PROJECT_NAME}Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR}) - - -write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - VERSION ${MAMBA_VERSION_MAJOR}.${MAMBA_VERSION_MINOR}.${MAMBA_VERSION_PATCH} - COMPATIBILITY AnyNewerVersion) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR}) -install(EXPORT ${PROJECT_NAME}-targets - FILE ${PROJECT_NAME}Targets.cmake - DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR}) +configure_package_config_file( + ${PROJECT_NAME}Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR} +) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${MAMBA_VERSION_MAJOR}.${MAMBA_VERSION_MINOR}.${MAMBA_VERSION_PATCH} + COMPATIBILITY AnyNewerVersion +) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR} +) +install( + EXPORT ${PROJECT_NAME}-targets + FILE ${PROJECT_NAME}Targets.cmake + DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR} +) diff --git a/libmamba/tests/CMakeLists.txt b/libmamba/tests/CMakeLists.txt index 9442b1dfd9..b476d12008 100644 --- a/libmamba/tests/CMakeLists.txt +++ b/libmamba/tests/CMakeLists.txt @@ -8,8 +8,8 @@ target_compile_features(testing_libmamba_lock PUBLIC cxx_std_17) mamba_target_add_compile_warnings(testing_libmamba_lock WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR}) - -set(LIBMAMBA_TEST_SRCS +set( + LIBMAMBA_TEST_SRCS include/mambatests.hpp src/test_main.cpp # C++ wrapping of libsolv @@ -45,7 +45,6 @@ set(LIBMAMBA_TEST_SRCS src/specs/test_version_spec.cpp src/specs/test_channel_spec.cpp src/specs/test_repo_data.cpp - ../longpath.manifest src/core/test_activation.cpp src/core/test_channel.cpp @@ -90,13 +89,8 @@ find_package(Threads REQUIRED) target_link_libraries( test_libmamba - PUBLIC - mamba::libmamba - reproc - reproc++ - PRIVATE - doctest::doctest - Threads::Threads + PUBLIC mamba::libmamba reproc reproc++ + PRIVATE doctest::doctest Threads::Threads ) # Copy data directory into binary dir to avoid modifications @@ -112,4 +106,8 @@ target_compile_definitions( target_compile_features(test_libmamba PUBLIC cxx_std_17) -add_custom_target(test COMMAND test_libmamba DEPENDS test_libmamba) +add_custom_target( + test + COMMAND test_libmamba + DEPENDS test_libmamba +) diff --git a/libmambapy/CMakeLists.txt b/libmambapy/CMakeLists.txt index cdb641d4b6..8f22a0c830 100644 --- a/libmambapy/CMakeLists.txt +++ b/libmambapy/CMakeLists.txt @@ -18,15 +18,11 @@ endif() find_package(Python COMPONENTS Interpreter Development) find_package(pybind11 REQUIRED) -pybind11_add_module(bindings - src/main.cpp - longpath.manifest -) +pybind11_add_module(bindings src/main.cpp longpath.manifest) mamba_target_add_compile_warnings(bindings WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR}) target_link_libraries(bindings PRIVATE pybind11::pybind11 mamba::libmamba) set_property(TARGET bindings PROPERTY CXX_STANDARD 17) -install(TARGETS bindings - LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/libmambapy/) +install(TARGETS bindings LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/libmambapy/) diff --git a/mamba_package/CMakeLists.txt b/mamba_package/CMakeLists.txt index 9724ebe231..2ad10df6b5 100644 --- a/mamba_package/CMakeLists.txt +++ b/mamba_package/CMakeLists.txt @@ -4,7 +4,7 @@ # # The full license is in the file LICENSE, distributed with this software. -cmake_minimum_required (VERSION 3.16) +cmake_minimum_required(VERSION 3.16) cmake_policy(SET CMP0025 NEW) # Introduced in cmake 3.0 cmake_policy(SET CMP0077 NEW) # Introduced in cmake 3.13 @@ -13,21 +13,19 @@ project(mamba-package) # Source files # ============ -set(MAMBA_PACKAGE_SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/package.cpp +set( + MAMBA_PACKAGE_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/package.cpp ) -set(MAMBA_PACKAGE_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/src/package.hpp -) +set(MAMBA_PACKAGE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/package.hpp) # Dependencies # ============ if(NOT TARGET mamba::libmamba) find_package(libmamba REQUIRED) -endif () +endif() # Build definition # ================ diff --git a/micromamba/CMakeLists.txt b/micromamba/CMakeLists.txt index 5938960411..47d1575707 100644 --- a/micromamba/CMakeLists.txt +++ b/micromamba/CMakeLists.txt @@ -4,7 +4,7 @@ # # The full license is in the file LICENSE, distributed with this software. -cmake_minimum_required (VERSION 3.16) +cmake_minimum_required(VERSION 3.16) cmake_policy(SET CMP0025 NEW) # Introduced in cmake 3.0 cmake_policy(SET CMP0077 NEW) # Introduced in cmake 3.13 project(micromamba) @@ -13,16 +13,25 @@ project(micromamba) # ============= option(BUILD_MICROMAMBA_SERVER "Build the micromamba server" OFF) -if (BUILD_STATIC AND NOT BUILD_SHARED) - set(MICROMAMBA_LINKAGE "STATIC" CACHE STRING "micromamba linkage against libraries") -else () - set(MICROMAMBA_LINKAGE "DYNAMIC" CACHE STRING "micromamba linkage against libraries") -endif () +if(BUILD_STATIC AND NOT BUILD_SHARED) + set( + MICROMAMBA_LINKAGE + "STATIC" + CACHE STRING "micromamba linkage against libraries" + ) +else() + set( + MICROMAMBA_LINKAGE + "DYNAMIC" + CACHE STRING "micromamba linkage against libraries" + ) +endif() # Source files # ============ -set(MICROMAMBA_SRCS +set( + MICROMAMBA_SRCS longpath.manifest ${CMAKE_CURRENT_SOURCE_DIR}/src/activate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/clean.cpp @@ -47,16 +56,15 @@ set(MICROMAMBA_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/version.cpp ) -set(MICROMAMBA_HEADERS +set( + MICROMAMBA_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/common_options.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/umamba.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/version.hpp ) if(UNIX AND BUILD_MICROMAMBA_SERVER) - list(APPEND MICROMAMBA_SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/src/server.cpp - ) + list(APPEND MICROMAMBA_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/server.cpp) add_definitions(-DMICROMAMBA_SERVER) endif() @@ -67,29 +75,22 @@ mamba_target_set_lto(micromamba MODE ${MAMBA_LTO}) if(NOT (TARGET mamba::libmamba-dyn OR TARGET mamba::libmamba-static)) find_package(libmamba REQUIRED) -endif () +endif() string(TOUPPER "${MICROMAMBA_LINKAGE}" linkage_upper) message(STATUS "Micromamba linkage: ${MICROMAMBA_LINKAGE}") -if (${MICROMAMBA_LINKAGE} STREQUAL "STATIC") +if(${MICROMAMBA_LINKAGE} STREQUAL "STATIC") set(libmamba_target mamba::libmamba-static) -else () +else() set(libmamba_target mamba::libmamba-dyn) -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++ -) +target_link_libraries(micromamba PRIVATE ${libmamba_target} Threads::Threads reproc reproc++) set_property(TARGET micromamba PROPERTY CXX_STANDARD 17)