diff --git a/.circleci/config.yml b/.circleci/config.yml index 62034f407b..df07747353 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,7 +85,7 @@ commands: - run: name: "Install Conan" command: | - pip3 install --user --no-warn-script-location conan==1.64.1 + pip3 install --user --no-warn-script-location conan==2.10.2 conan_path="$(python3 -m site --user-base)/bin" echo "export \"PATH=$conan_path:\$PATH\"" >> "$BASH_ENV" "$conan_path/conan" --version @@ -109,7 +109,7 @@ commands: command: | if [[ "<>" == "clang" ]] then - conan_profile=linux_x64_clang_13_release + conan_profile=linux_x64_clang_16_release else conan_profile=linux_x64_gcc_11_release fi @@ -128,7 +128,7 @@ commands: name: "Save Conan cache" key: *conan-cache-key paths: - - ~/.conan + - ~/.conan2 build_fuzzer: steps: @@ -146,7 +146,7 @@ commands: - run: name: "CMake Fuzzer" working_directory: ~/build - command: cmake ../project -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_13_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON + command: cmake ../project -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON - run: name: "Build Fuzzer" command: | diff --git a/.github/actions/fuzzer-common-steps/action.yml b/.github/actions/fuzzer-common-steps/action.yml index 8e4f0c73ab..d524d19e52 100644 --- a/.github/actions/fuzzer-common-steps/action.yml +++ b/.github/actions/fuzzer-common-steps/action.yml @@ -23,17 +23,12 @@ runs: - name: Temporary step - conan cache cleanup - to be executed only once per runner shell: bash - run: conan remove "*" --force - - - name: Preinstall Conan packages - shell: bash - working-directory: ${{runner.workspace}}/silkworm - run: CC=clang-16 CXX=clang++-16 conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/experimental/linux_x64_clang_16_release . + run: /opt/conan2/bin/conan remove --confirm "*" - name: Configure CMake shell: bash working-directory: ${{runner.workspace}}/silkworm/build - run: CC=clang-16 CXX=clang++-16 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=experimental/linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON -DSILKWORM_FUZZER_SANITIZERS=${{inputs.fuzzer_sanitizers}} + run: CC=clang-16 CXX=clang++-16 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON -DSILKWORM_FUZZER_SANITIZERS=${{inputs.fuzzer_sanitizers}} - name: Build Silkworm Fuzzer Test shell: bash diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 736db62b9b..73bd80c16f 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -47,7 +47,7 @@ jobs: - name: Install Prerequisites run: | - pip3 install --user --break-system-packages --no-warn-script-location conan==1.64.1 chardet + pip3 install --user --break-system-packages --no-warn-script-location conan==2.10.2 chardet conan_path="$(python3 -m site --user-base)/bin" echo "$conan_path" >> $GITHUB_PATH "$conan_path/conan" --version diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 94420f50f8..693d05f26d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -47,7 +47,7 @@ jobs: id: conan uses: turtlebrowser/get-conan@main with: - version: 1.64.1 + version: 2.10.2 - name: Create Build Environment # Some projects don't allow in-source building, so create a separate build directory diff --git a/CMakeLists.txt b/CMakeLists.txt index eb8e5c0c14..29f32d64b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ limitations under the License. ]] -cmake_minimum_required(VERSION 3.19.0) +cmake_minimum_required(VERSION 3.24.0) if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/evmone/evmone/evmc/.git) message(FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init --recursive") @@ -22,10 +22,21 @@ endif() get_directory_property(SILKWORM_HAS_PARENT PARENT_DIRECTORY) if(NOT SILKWORM_HAS_PARENT) + # reduce the log verbosity of evmone/cmake/cable + if(NOT CMAKE_MESSAGE_LOG_LEVEL) + set(CMAKE_MESSAGE_LOG_LEVEL_EMPTY YES) + set(CMAKE_MESSAGE_LOG_LEVEL NOTICE) + endif() + include(third_party/evmone/evmone/cmake/cable/bootstrap.cmake) include(CableBuildType) cable_set_build_type(DEFAULT Release CONFIGURATION_TYPES Release Debug) + # restore the log verbosity + if(CMAKE_MESSAGE_LOG_LEVEL_EMPTY) + unset(CMAKE_MESSAGE_LOG_LEVEL) + endif() + if(NOT CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain/cxx20.cmake @@ -33,6 +44,8 @@ if(NOT SILKWORM_HAS_PARENT) ) include("${CMAKE_TOOLCHAIN_FILE}") endif() + + include(cmake/conan.cmake) endif() project(silkworm) @@ -70,10 +83,6 @@ option(SILKWORM_FUZZER_SANITIZERS "CLang sanitizer options for fuzzers" OFF) option(SILKWORM_USE_MIMALLOC "Enable using mimalloc for dynamic memory management" ON) option(SILKWORM_ALLOW_UNUSED_VAR_WARNINGS "Turn unused variable errors into warnings" OFF) -if(NOT SILKWORM_HAS_PARENT) - include(cmake/conan.cmake) -endif() - set_property( DIRECTORY APPEND @@ -125,5 +134,5 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") # avoid fatal error C1002: compiler is out of heap space list(REMOVE_ITEM UNIT_TEST_TARGETS silkworm_rpcdaemon_test) endif() -message(STATUS "UNIT_TEST_TARGETS: ${UNIT_TEST_TARGETS}") +message(VERBOSE "UNIT_TEST_TARGETS: ${UNIT_TEST_TARGETS}") add_custom_target(all_unit_tests DEPENDS ${UNIT_TEST_TARGETS}) diff --git a/README.md b/README.md index 3b5e87b199..50dc3c4efb 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ or AppleClang ([Xcode](https://developer.apple.com/xcode/) >= 15) Conan requires Python, and can be installed using: - pip3 install --user conan==1.64.1 chardet + pip3 install --user conan==2.10.2 chardet On Linux the conan binary gets installed into `$HOME/.local/bin` which is typically in PATH already. On macOS need to add the binary to PATH manually: @@ -122,9 +122,7 @@ will use "debug" configuration builds of dependencies. See available profiles in [cmake/profiles](cmake/profiles). -The conan packages could also be pre-installed using [conan install](https://docs.conan.io/1/reference/commands/consumer/install.html): - - conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/macos_arm64_clang_13_debug . +During the cmake configuration step `conan_provider.cmake` runs a [conan install](https://docs.conan.io/2/reference/commands/install.html) command that downloads packages and builds some of them from source if needed. The exact arguments to this command are printed in the build log. Then run the build itself diff --git a/cmake/compiler_settings.cmake b/cmake/compiler_settings.cmake index c6cf2395b5..6d865906e0 100644 --- a/cmake/compiler_settings.cmake +++ b/cmake/compiler_settings.cmake @@ -89,16 +89,6 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang$") link_libraries(c++abi) endif() - # cmake-format: off - # abseil in conan is prebuilt with clang 13 (see profiles), - # linking absl::log with clang 18+ produces an error due to an ABI change: - # https://github.com/abseil/abseil-cpp/issues/1747 - # https://github.com/llvm/llvm-project/issues/102443 - # cmake-format: on - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18) - add_compile_options(-fclang-abi-compat=17) - endif() - else() message(WARNING "${CMAKE_CXX_COMPILER_ID} is not a supported compiler. Use at your own risk.") endif() diff --git a/cmake/conan.cmake b/cmake/conan.cmake index 356adc5169..7260995941 100644 --- a/cmake/conan.cmake +++ b/cmake/conan.cmake @@ -15,8 +15,18 @@ ]] include(${CMAKE_CURRENT_LIST_DIR}/compiler_settings_sanitize.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/conan_quiet.cmake) function(guess_conan_profile) + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "" AND CMAKE_HOST_UNIX) + execute_process( + COMMAND uname -m + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY + ) + endif() + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "") set(ARCH_NAME "") elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64) @@ -38,7 +48,7 @@ function(guess_conan_profile) elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND ARCH_NAME) set(PROFILE macos_${ARCH_NAME}_clang_13_release) elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - set(PROFILE windows_msvc_16_release) + set(PROFILE windows_msvc_193_release) else() message(FATAL_ERROR "CONAN_PROFILE is not defined for ${CMAKE_HOST_SYSTEM_NAME} on ${CMAKE_HOST_SYSTEM_PROCESSOR}") endif() @@ -49,50 +59,95 @@ function(guess_conan_profile) ) endfunction() -set(CONAN_BINARY_DIR "${CMAKE_BINARY_DIR}/conan") -list(APPEND CMAKE_MODULE_PATH ${CONAN_BINARY_DIR}) -list(APPEND CMAKE_PREFIX_PATH ${CONAN_BINARY_DIR}) +function(get_conan_build_type profile_path var) + file(READ "${profile_path}" CONTENTS) + string(REGEX MATCH "build_type=[A-Za-z0-9]+" VALUE "${CONTENTS}") + string(SUBSTRING "${VALUE}" 11 -1 VALUE) + set(${var} + "${VALUE}" + PARENT_SCOPE + ) +endfunction() -# disable verbose logging from FindXXX.cmake files -set(CONAN_CMAKE_SILENT_OUTPUT ON) +macro(format_list_as_json_array list_var var) + list(JOIN ${list_var} "\",\"" ${var}) + set(${var} "[\"${${var}}\"]") +endmacro() -include("${CMAKE_SOURCE_DIR}/third_party/cmake-conan/conan.cmake") +# unset(CONAN_COMMAND CACHE) +find_program( + CONAN_COMMAND "conan" + PATHS /opt/conan2/bin + NO_DEFAULT_PATH +) +if(NOT CONAN_COMMAND) + find_program(CONAN_COMMAND "conan" PATHS ~/.local/bin REQUIRED) +endif() -# provide a static conanfile.py instead of generating it with conan_cmake_configure() -file(COPY "${CMAKE_SOURCE_DIR}/conanfile.py" DESTINATION "${CONAN_BINARY_DIR}") +# use "verbose" for more detailed conan install logs +set(CONAN_VERBOSITY "error") +set(CONAN_BINARY_DIR "${CMAKE_BINARY_DIR}/conan2") if(NOT DEFINED CONAN_PROFILE) guess_conan_profile() endif() -message(STATUS "CONAN_PROFILE: ${CONAN_PROFILE}") +message(VERBOSE "CONAN_PROFILE: ${CONAN_PROFILE}") +set(CONAN_PROFILE_PATH "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}") +set(CONAN_HOST_PROFILE "${CONAN_PROFILE_PATH}") +set(CONAN_BUILD_PROFILE "${CONAN_PROFILE_PATH}") +get_conan_build_type("${CONAN_PROFILE_PATH}" CONAN_BUILD_TYPE) set(CONAN_BUILD "missing") -set(CONAN_CXXFLAGS_ARG) -set(CONAN_OPTIONS) +set(CONAN_SETTINGS "") +set(CONAN_OPTIONS "") +set(CONAN_CONF "") + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(OS_VERSION_MIN_CXXFLAG "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") +endif() + +if(OS_VERSION_MIN_CXXFLAG AND NOT SILKWORM_SANITIZE_COMPILER_OPTIONS) + list(APPEND CONAN_CONF "libtorrent/*:tools.build:cxxflags=[\"${OS_VERSION_MIN_CXXFLAG}\"]") +endif() if(SILKWORM_SANITIZE_COMPILER_OPTIONS) set(CONAN_CXXFLAGS ${SILKWORM_SANITIZE_COMPILER_OPTIONS}) - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - list(APPEND CONAN_CXXFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + if(OS_VERSION_MIN_CXXFLAG) + list(APPEND CONAN_CXXFLAGS ${OS_VERSION_MIN_CXXFLAG}) endif() - list(JOIN CONAN_CXXFLAGS "\", \"" CONAN_CXXFLAGS_STR) - set(CONAN_CXXFLAGS_STR "[\"${CONAN_CXXFLAGS_STR}\"]") - set(CONAN_CXXFLAGS_ARG "tools.build:cxxflags=${CONAN_CXXFLAGS_STR}") - - list(APPEND CONAN_OPTIONS "boost:zlib=False") + list(APPEND CONAN_OPTIONS "boost/*:zlib=False") + list(APPEND CONAN_OPTIONS "grpc/*:with_libsystemd=False") - # libraries that needs to be rebuilt with sanitize flags + # libraries that must be rebuilt with sanitizer flags # cmake-format: off set(CONAN_BUILD - abseil - boost - grpc - libtorrent - protobuf + "abseil/*" + "boost/*" + "grpc/*" + "libtorrent/*" + "protobuf/*" ) # cmake-format: on + + format_list_as_json_array(CONAN_CXXFLAGS CONAN_CXXFLAGS_STR) + list(APPEND CONAN_CONF "tools.build:cxxflags=${CONAN_CXXFLAGS_STR}") +endif() + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(CONAN_VERBOSITY "verbose") + # make sure to not rebuild anything from source unless required + set(CONAN_BUILD "missing:libtorrent/*") + # HACK: MSVC is "multi config" and conan_provider.cmake runs 2 conan install commands for both Release and Debug + # despite CMAKE_BUILD_TYPE. This adds an extra build_type setting to both commands to override and force the desired + # build type. It still runs 2 commands, but the 2nd one has no effect. + list(APPEND CONAN_SETTINGS "build_type=${CMAKE_BUILD_TYPE}") + # most Windows packages on ConanCenter are built for cppstd=14, but some packages require at least cppstd=17 + # (otherwise report "Invalid" status) + list(APPEND CONAN_SETTINGS "asio-grpc/*:compiler.cppstd=17") + list(APPEND CONAN_SETTINGS "magic_enum/*:compiler.cppstd=17") + list(APPEND CONAN_SETTINGS "tomlplusplus/*:compiler.cppstd=17") endif() if(SILKWORM_USE_MIMALLOC) @@ -100,19 +155,37 @@ if(SILKWORM_USE_MIMALLOC) # should not be used in sanitizer builds or at least its override option must be disabled # (https://github.com/microsoft/mimalloc/issues/317#issuecomment-708506405) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT SILKWORM_SANITIZE) - list(APPEND CONAN_OPTIONS "mimalloc:override=True") + list(APPEND CONAN_OPTIONS "mimalloc/*:override=True") endif() endif() if(SILKWORM_CORE_ONLY) - set(CONAN_CXXFLAGS_ARG "catch2/*:tools.build:cxxflags=[\"-fno-exceptions\"]") + list(APPEND CONAN_CONF "catch2/*:tools.build:cxxflags=[\"-fno-exceptions\"]") endif() -conan_cmake_install( - PATH_OR_REFERENCE "${CONAN_BINARY_DIR}" - INSTALL_FOLDER "${CONAN_BINARY_DIR}" - BUILD ${CONAN_BUILD} - OPTIONS ${CONAN_OPTIONS} - PROFILE "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}" - CONF "${CONAN_CXXFLAGS_ARG}" +# cmake-format: off +set(CONAN_INSTALL_ARGS + -v ${CONAN_VERBOSITY} + --output-folder "${CONAN_BINARY_DIR}" + # https://github.com/conan-io/cmake-conan/issues/607 + --settings:all "&:build_type=${CMAKE_BUILD_TYPE}" ) +# cmake-format: on + +foreach(VALUE IN LISTS CONAN_BUILD) + list(APPEND CONAN_INSTALL_ARGS --build=${VALUE}) +endforeach() + +foreach(VALUE IN LISTS CONAN_SETTINGS) + list(APPEND CONAN_INSTALL_ARGS --settings:all=${VALUE}) +endforeach() + +foreach(VALUE IN LISTS CONAN_OPTIONS) + list(APPEND CONAN_INSTALL_ARGS --options:all=${VALUE}) +endforeach() + +foreach(VALUE IN LISTS CONAN_CONF) + list(APPEND CONAN_INSTALL_ARGS --conf:all=${VALUE}) +endforeach() + +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_SOURCE_DIR}/third_party/cmake-conan/conan_provider.cmake") diff --git a/cmake/conan_quiet.cmake b/cmake/conan_quiet.cmake new file mode 100644 index 0000000000..6a3bacc593 --- /dev/null +++ b/cmake/conan_quiet.cmake @@ -0,0 +1,38 @@ +# Reduce verbosity of CMakeDeps conan generator +# do not edit, regenerate with conan_quiet.sh + +set(ZLIB_FIND_QUIETLY YES) +set(Catch2_FIND_QUIETLY YES) +set(jwt-cpp_FIND_QUIETLY YES) +set(GTest_FIND_QUIETLY YES) +set(LibtorrentRasterbar_FIND_QUIETLY YES) +set(Snappy_FIND_QUIETLY YES) +set(Microsoft.GSL_FIND_QUIETLY YES) +set(OpenSSL_FIND_QUIETLY YES) +set(fmt_FIND_QUIETLY YES) +set(roaring_FIND_QUIETLY YES) +set(BZip2_FIND_QUIETLY YES) +set(c-ares_FIND_QUIETLY YES) +set(magic_enum_FIND_QUIETLY YES) +set(absl_FIND_QUIETLY YES) +set(OpenSSL_FIND_QUIETLY YES) +set(tomlplusplus_FIND_QUIETLY YES) +set(spdlog_FIND_QUIETLY YES) +set(SQLite3_FIND_QUIETLY YES) +set(CLI11_FIND_QUIETLY YES) +set(tl-expected_FIND_QUIETLY YES) +set(asio-grpc_FIND_QUIETLY YES) +set(benchmark_FIND_QUIETLY YES) +set(gmp_FIND_QUIETLY YES) +set(Boost_FIND_QUIETLY YES) +set(SQLite3_FIND_QUIETLY YES) +set(mimalloc_FIND_QUIETLY YES) +set(re2_FIND_QUIETLY YES) +set(gRPC_FIND_QUIETLY YES) +set(protobuf_FIND_QUIETLY YES) +set(ZLIB_FIND_QUIETLY YES) +set(Protobuf_FIND_QUIETLY YES) +set(BZip2_FIND_QUIETLY YES) +set(SQLiteCpp_FIND_QUIETLY YES) +set(GTest_FIND_QUIETLY YES) +set(nlohmann_json_FIND_QUIETLY YES) diff --git a/cmake/conan_quiet.sh b/cmake/conan_quiet.sh new file mode 100755 index 0000000000..78efc3b93c --- /dev/null +++ b/cmake/conan_quiet.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +script_dir=$(dirname "${BASH_SOURCE[0]}") +project_dir="$script_dir/.." +build_dir="$1" + +if [[ -z "$build_dir" ]] +then + build_dir="$project_dir/build" +fi + +cat << EOF > "$script_dir/conan_quiet.cmake" +# Reduce verbosity of CMakeDeps conan generator +# do not edit, regenerate with conan_quiet.sh + +EOF + +grep -R FIND_QUIETLY "$build_dir/conan2" | sed -E 's/.+\((.+)\)/set(\1 YES)/' >> "$script_dir/conan_quiet.cmake" diff --git a/cmake/profiles/experimental/linux_arm64_gcc_12_debug b/cmake/profiles/experimental/linux_arm64_gcc_12_debug index 84715c32d4..8944d831e9 100644 --- a/cmake/profiles/experimental/linux_arm64_gcc_12_debug +++ b/cmake/profiles/experimental/linux_arm64_gcc_12_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=armv8 -arch_build=armv8 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/linux_arm64_gcc_12_release b/cmake/profiles/experimental/linux_arm64_gcc_12_release index 47ea55e61b..a072a98730 100644 --- a/cmake/profiles/experimental/linux_arm64_gcc_12_release +++ b/cmake/profiles/experimental/linux_arm64_gcc_12_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=armv8 -arch_build=armv8 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/linux_x64_clang_16_release b/cmake/profiles/experimental/linux_x64_clang_16_release deleted file mode 100644 index ba21adcbdc..0000000000 --- a/cmake/profiles/experimental/linux_x64_clang_16_release +++ /dev/null @@ -1,17 +0,0 @@ -[settings] -os=Linux -os_build=Linux -arch=x86_64 -arch_build=x86_64 -compiler=clang -compiler.version=16 -compiler.libcxx=libc++ -build_type=Release - -[options] - -[build_requires] - -[env] -CONAN_CXX_FLAGS="-fuse-ld=lld" -CONAN_C_FLAGS="-fuse-ld=lld" diff --git a/cmake/profiles/experimental/linux_x64_gcc_12_debug b/cmake/profiles/experimental/linux_x64_gcc_12_debug index 35372a5f46..c0f4a39e0a 100644 --- a/cmake/profiles/experimental/linux_x64_gcc_12_debug +++ b/cmake/profiles/experimental/linux_x64_gcc_12_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/linux_x64_gcc_12_release b/cmake/profiles/experimental/linux_x64_gcc_12_release index 68dd94e10c..c8aaacd327 100644 --- a/cmake/profiles/experimental/linux_x64_gcc_12_release +++ b/cmake/profiles/experimental/linux_x64_gcc_12_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_arm64_clang_14_debug b/cmake/profiles/experimental/macos_arm64_clang_14_debug index 64ddf4a6c0..5e7e3ec2bd 100644 --- a/cmake/profiles/experimental/macos_arm64_clang_14_debug +++ b/cmake/profiles/experimental/macos_arm64_clang_14_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_arm64_clang_14_release b/cmake/profiles/experimental/macos_arm64_clang_14_release index 8768c4f67f..b944fe3347 100644 --- a/cmake/profiles/experimental/macos_arm64_clang_14_release +++ b/cmake/profiles/experimental/macos_arm64_clang_14_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_x64_clang_14_debug b/cmake/profiles/experimental/macos_x64_clang_14_debug index e2ae677c67..45a838776a 100644 --- a/cmake/profiles/experimental/macos_x64_clang_14_debug +++ b/cmake/profiles/experimental/macos_x64_clang_14_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_x64_clang_14_release b/cmake/profiles/experimental/macos_x64_clang_14_release index d613bc4cdc..caf3d2c890 100644 --- a/cmake/profiles/experimental/macos_x64_clang_14_release +++ b/cmake/profiles/experimental/macos_x64_clang_14_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/readme.txt b/cmake/profiles/experimental/readme.txt index d9f25e44bc..8a322f1e79 100644 --- a/cmake/profiles/experimental/readme.txt +++ b/cmake/profiles/experimental/readme.txt @@ -1,7 +1,10 @@ -There are very few binary packages for gcc 12 and clang 14 on ConanCenter. +There are very few binary packages for gcc 12+ and clang 14+ on ConanCenter. +The supported platforms are listed here: https://github.com/conan-io/conan-center-index/issues/25691#issuecomment-2429167255 -Test using this command: +This command shows which packages are "Missing" and need to be built from sources: -conan install . --profile cmake/profiles/experimental/linux_x64_gcc_12_release + conan graph explain --profile:all cmake/profiles/experimental/linux_x64_gcc_12_release . -It shows which packages need "Download" of binaries or "Build" from sources. +This command shows if binaries are missing for a particular package: + + conan graph explain --profile:all cmake/profiles/experimental/linux_x64_gcc_12_release --requires=grpc/x.y.z diff --git a/cmake/profiles/experimental/windows_msvc_17_debug b/cmake/profiles/experimental/windows_msvc_17_debug deleted file mode 100644 index 685e16b406..0000000000 --- a/cmake/profiles/experimental/windows_msvc_17_debug +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=17 -compiler.runtime=MDd -build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/windows_msvc_17_release b/cmake/profiles/experimental/windows_msvc_17_release deleted file mode 100644 index b753317e04..0000000000 --- a/cmake/profiles/experimental/windows_msvc_17_release +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=17 -compiler.runtime=MD -build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/linux_x64_clang_13_debug b/cmake/profiles/linux_x64_clang_16_debug similarity index 50% rename from cmake/profiles/linux_x64_clang_13_debug rename to cmake/profiles/linux_x64_clang_16_debug index 46160e3509..aadab8042d 100644 --- a/cmake/profiles/linux_x64_clang_13_debug +++ b/cmake/profiles/linux_x64_clang_16_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=clang -compiler.version=13 +compiler.version=16 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/linux_x64_clang_13_release b/cmake/profiles/linux_x64_clang_16_release similarity index 51% rename from cmake/profiles/linux_x64_clang_13_release rename to cmake/profiles/linux_x64_clang_16_release index 250efe7c4a..3164500a5a 100644 --- a/cmake/profiles/linux_x64_clang_13_release +++ b/cmake/profiles/linux_x64_clang_16_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=clang -compiler.version=13 +compiler.version=16 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/linux_x64_gcc_11_debug b/cmake/profiles/linux_x64_gcc_11_debug index 21378fb239..d627ca292d 100644 --- a/cmake/profiles/linux_x64_gcc_11_debug +++ b/cmake/profiles/linux_x64_gcc_11_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=11 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] diff --git a/cmake/profiles/linux_x64_gcc_11_release b/cmake/profiles/linux_x64_gcc_11_release index ee38ba1656..3b7c771b9b 100644 --- a/cmake/profiles/linux_x64_gcc_11_release +++ b/cmake/profiles/linux_x64_gcc_11_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=11 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] diff --git a/cmake/profiles/macos_arm64_clang_13_debug b/cmake/profiles/macos_arm64_clang_13_debug index e34ebb4768..20e6dfa5d4 100644 --- a/cmake/profiles/macos_arm64_clang_13_debug +++ b/cmake/profiles/macos_arm64_clang_13_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/macos_arm64_clang_13_release b/cmake/profiles/macos_arm64_clang_13_release index 0b8b38afc9..d7b3ae5d37 100644 --- a/cmake/profiles/macos_arm64_clang_13_release +++ b/cmake/profiles/macos_arm64_clang_13_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/macos_x64_clang_13_debug b/cmake/profiles/macos_x64_clang_13_debug index 45783f26b3..5c47f39831 100644 --- a/cmake/profiles/macos_x64_clang_13_debug +++ b/cmake/profiles/macos_x64_clang_13_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/macos_x64_clang_13_release b/cmake/profiles/macos_x64_clang_13_release index 7346e17a7f..fa07d48c4a 100644 --- a/cmake/profiles/macos_x64_clang_13_release +++ b/cmake/profiles/macos_x64_clang_13_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/wasi_release b/cmake/profiles/wasi_release index 31ae7ca3b1..e986e45afa 100644 --- a/cmake/profiles/wasi_release +++ b/cmake/profiles/wasi_release @@ -5,8 +5,5 @@ compiler=clang compiler.version=14 compiler.libcxx=libc++ build_type=Release -[options] -[build_requires] -[env] -CC=/opt/wasi-sdk/bin/clang -CXX=/opt/wasi-sdk/bin/clang++ +[conf] +tools.build:compiler_executables={'c': '/opt/wasi-sdk/bin/clang', 'cpp': '/opt/wasi-sdk/bin/clang++'} diff --git a/cmake/profiles/windows_msvc_16_debug b/cmake/profiles/windows_msvc_16_debug deleted file mode 100644 index 99fa4f1b73..0000000000 --- a/cmake/profiles/windows_msvc_16_debug +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=16 -compiler.runtime=MDd -build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/windows_msvc_16_release b/cmake/profiles/windows_msvc_16_release deleted file mode 100644 index e52961d8e8..0000000000 --- a/cmake/profiles/windows_msvc_16_release +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=16 -compiler.runtime=MD -build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/windows_msvc_193_debug b/cmake/profiles/windows_msvc_193_debug new file mode 100644 index 0000000000..86bf46cfe9 --- /dev/null +++ b/cmake/profiles/windows_msvc_193_debug @@ -0,0 +1,9 @@ +[settings] +os=Windows +arch=x86_64 +compiler=msvc +compiler.version=193 +compiler.runtime=dynamic +compiler.runtime_type=Release +compiler.cppstd=14 +build_type=Debug diff --git a/cmake/profiles/windows_msvc_193_release b/cmake/profiles/windows_msvc_193_release new file mode 100644 index 0000000000..14b080f211 --- /dev/null +++ b/cmake/profiles/windows_msvc_193_release @@ -0,0 +1,9 @@ +[settings] +os=Windows +arch=x86_64 +compiler=msvc +compiler.version=193 +compiler.runtime=dynamic +compiler.runtime_type=Release +compiler.cppstd=14 +build_type=Release diff --git a/cmake/setup/compiler_install.sh b/cmake/setup/compiler_install.sh index a0e903f50a..1f3712363c 100755 --- a/cmake/setup/compiler_install.sh +++ b/cmake/setup/compiler_install.sh @@ -6,13 +6,22 @@ set -e set -o pipefail +script_dir=$(dirname "${BASH_SOURCE[0]}") +project_dir="$script_dir/../.." + function install_gcc { GCC_VERSION="$1" echo "Installing GCC $GCC_VERSION..." sudo apt-get update - sudo apt-get install -y gcc-$GCC_VERSION g++-$GCC_VERSION - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 100 --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION + sudo apt-get install -y g++-$GCC_VERSION + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 100 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100 + sudo update-alternatives --set gcc /usr/bin/gcc-$GCC_VERSION + sudo update-alternatives --set cc /usr/bin/gcc + sudo update-alternatives --set c++ /usr/bin/g++ } # libc++ is an alternative standard library needed for coroutines support on Clang @@ -22,22 +31,32 @@ function install_clang { echo "Installing clang $CLANG_VERSION..." sudo apt-get update - package_available=$(apt list llvm-$CLANG_VERSION 2>/dev/null | grep llvm-$CLANG_VERSION) - - if [[ -n "$package_available" ]]; then - echo "The package llvm-$CLANG_VERSION is available in apt repositories" - sudo apt-get install -y llvm-$CLANG_VERSION libc++-$CLANG_VERSION-dev libc++abi-$CLANG_VERSION-dev clang-$CLANG_VERSION lld-$CLANG_VERSION + if apt-cache show clang-$CLANG_VERSION > /dev/null 2>&1 + then + echo "Installing from the default apt repositories" + sudo apt-get install -y clang-$CLANG_VERSION \ + libc++-$CLANG_VERSION-dev libc++abi-$CLANG_VERSION-dev \ + lld-$CLANG_VERSION else - echo "Package llvm-$CLANG_VERSION not available, attempting to install using llvm.sh script" - sudo ../../third_party/llvm/llvm.sh $CLANG_VERSION + echo "Installing from apt.llvm.org using llvm.sh script" + sudo "$project_dir/third_party/llvm/llvm.sh" $CLANG_VERSION fi - sudo ln -sfv /usr/bin/clang-$CLANG_VERSION /usr/bin/clang - sudo ln -sfv /usr/bin/clang++-$CLANG_VERSION /usr/bin/clang++ - sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 - sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-$CLANG_VERSION 100 - sudo update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-$CLANG_VERSION 100 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$CLANG_VERSION 100 \ + --slave /usr/bin/clang++ clang++ /usr/bin/clang++-$CLANG_VERSION \ + --slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-$CLANG_VERSION \ + --slave /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-$CLANG_VERSION + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 + sudo update-alternatives --set clang /usr/bin/clang-$CLANG_VERSION + sudo update-alternatives --set cc /usr/bin/clang + sudo update-alternatives --set c++ /usr/bin/clang++ + + # alias gcc to clang + # this is useful for scripts having gcc hardcoded (such as GMP autotools build) + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/clang 10 \ + --slave /usr/bin/g++ g++ /usr/bin/clang++ + sudo update-alternatives --set gcc /usr/bin/clang } if [[ -n "$1" ]] @@ -64,3 +83,7 @@ case "$compiler_id" in install_clang "$version" ;; esac + +update-alternatives --display cc +update-alternatives --display c++ +update-alternatives --display gcc diff --git a/conanfile.py b/conanfile.py index 87338153df..9a1f8fd352 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,11 +1,11 @@ # Copyright 2023 The Silkworm Authors - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - +# # http://www.apache.org/licenses/LICENSE-2.0 - +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ class SilkwormRecipe(ConanFile): settings = 'os', 'compiler', 'build_type', 'arch' - generators = 'cmake_find_package' + generators = 'CMakeDeps' def requirements(self): self.requires('catch2/3.6.0') @@ -32,10 +32,10 @@ def requirements(self): self.requires('abseil/20240116.2') self.requires('asio-grpc/2.9.2') self.requires('benchmark/1.6.1') - self.requires('boost/1.83.0') + self.requires('boost/1.83.0', override=True) self.requires('cli11/2.2.0') self.requires('gmp/6.2.1') - self.requires('grpc/1.67.1') + self.requires('grpc/1.67.1', override=True) self.requires('gtest/1.12.1') self.requires('jwt-cpp/0.6.0') self.requires('libtorrent/2.0.10') @@ -51,19 +51,23 @@ def requirements(self): def configure(self): self.options['asio-grpc'].local_allocator = 'boost_container' - # Conan Center has Windows binaries built only with msvc16 and mimalloc built only with option override=False. - # In order to build mimalloc with override=True we could switch to msvc17 compiler but this would trigger a full - # rebuild from sources of all dependencies increasing build time a lot, so we prefer to keep mimalloc override - # disabled on Windows. - # The same applies also for boost with option asio_no_deprecated, so we skip configuration entirely on Windows. - if self.settings.os == 'Windows': - return + if (self.settings.os == 'Linux') and (self.settings.compiler == 'clang'): + self.options['grpc'].with_libsystemd = False # Disable Catch2 version 3.x.x signal handling on WASM if self.settings.arch == 'wasm': self.options['catch2'].no_posix_signals = True + self.configure_boost() + + def configure_boost(self): + # on Windows rebuilding boost from sources increases the build time a lot, so we skip configuration + # hoping it doesn't break with asio_no_deprecated = False + if self.settings.os == 'Windows': + return + self.options['boost'].asio_no_deprecated = True + if self.settings.os == 'Macos': cmake_osx_deployment_target = '10.14' os_version_min_flag = f'-mmacosx-version-min={cmake_osx_deployment_target}' diff --git a/docs/fuzzer.md b/docs/fuzzer.md index 06d2206821..8a8553ce65 100644 --- a/docs/fuzzer.md +++ b/docs/fuzzer.md @@ -6,7 +6,7 @@ To build the fuzzer use the following: ```bash mkdir build cd build -cmake ../project -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_13_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON +cmake ../project -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON cmake --build --target rpcdaemon_fuzzer_test cmake –-build --target rpcdaemon_fuzzer_diagnostics ``` diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index aebddddfda..3e6284645c 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -6,7 +6,7 @@ FROM cimg/python:3.12.0 as base # 1 Install dependencies RUN sudo apt-get update RUN sudo apt install -y python3-pip -RUN sudo pip3 install conan==1.64.1 chardet +RUN sudo pip3 install conan==2.10.2 chardet RUN sudo apt-get update # 2 Get repo and submodules @@ -22,7 +22,7 @@ RUN cmake/setup/compiler_install.sh clang 16 # 4 Build all targets WORKDIR /app/build -RUN cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_13_debug +RUN cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake WORKDIR /app/project RUN cmake --build /app/build -j4 @@ -48,7 +48,7 @@ RUN git pull origin ${BRANCH} # Rebuild all targets RUN echo "Rebuilding" WORKDIR /app/build -RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_13_debug +RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake WORKDIR /app/project RUN sudo cmake --build /app/build -j4 @@ -64,7 +64,7 @@ RUN sudo cmake --build /app/build -j4 # RUN for file in ~/artifacts/*; do sed -i 's/^>> //' "$file"; done # # Rebuild fuzzer # WORKDIR /app/build -# RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_13_debug -DSILKWORM_FUZZING=ON +# RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON # WORKDIR /app/project # RUN sudo cmake --build /app/build -j4 --target rpcdaemon_fuzzer_test # # Run fuzzer diff --git a/third_party/cmake-conan/LICENSE b/third_party/cmake-conan/LICENSE new file mode 100644 index 0000000000..541f5a3a6f --- /dev/null +++ b/third_party/cmake-conan/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 JFrog + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/cmake-conan/conan.cmake b/third_party/cmake-conan/conan.cmake deleted file mode 100644 index abfe7db7f3..0000000000 --- a/third_party/cmake-conan/conan.cmake +++ /dev/null @@ -1,1146 +0,0 @@ -# The MIT License (MIT) - -# Copyright (c) 2018 JFrog - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - - - -# This file comes from: https://github.com/conan-io/cmake-conan. Please refer -# to this repository for issues and documentation. - -# Its purpose is to wrap and launch Conan C/C++ Package Manager when cmake is called. -# It will take CMake current settings (os, compiler, compiler version, architecture) -# and translate them to conan settings for installing and retrieving dependencies. - -# It is intended to facilitate developers building projects that have conan dependencies, -# but it is only necessary on the end-user side. It is not necessary to create conan -# packages, in fact it shouldn't be use for that. Check the project documentation. - -# version: 0.19.0-dev - -include(CMakeParseArguments) - -function(_get_msvc_ide_version result) - set(${result} "" PARENT_SCOPE) - if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500) - set(${result} 8 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600) - set(${result} 9 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700) - set(${result} 10 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800) - set(${result} 11 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900) - set(${result} 12 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910) - set(${result} 14 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920) - set(${result} 15 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930) - set(${result} 16 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1950) - set(${result} 17 PARENT_SCOPE) - else() - message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]") - endif() -endfunction() - -macro(_conan_detect_build_type) - conan_parse_arguments(${ARGV}) - - if(ARGUMENTS_BUILD_TYPE) - set(_CONAN_SETTING_BUILD_TYPE ${ARGUMENTS_BUILD_TYPE}) - elseif(CMAKE_BUILD_TYPE) - set(_CONAN_SETTING_BUILD_TYPE ${CMAKE_BUILD_TYPE}) - else() - message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") - endif() - - string(TOUPPER ${_CONAN_SETTING_BUILD_TYPE} _CONAN_SETTING_BUILD_TYPE_UPPER) - if (_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "DEBUG") - set(_CONAN_SETTING_BUILD_TYPE "Debug") - elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELEASE") - set(_CONAN_SETTING_BUILD_TYPE "Release") - elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO") - set(_CONAN_SETTING_BUILD_TYPE "RelWithDebInfo") - elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL") - set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel") - endif() -endmacro() - -macro(_conan_check_system_name) - #handle -s os setting - if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") - #use default conan os setting if CMAKE_SYSTEM_NAME is not defined - set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) - if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(CONAN_SYSTEM_NAME Macos) - endif() - if(${CMAKE_SYSTEM_NAME} STREQUAL "QNX") - set(CONAN_SYSTEM_NAME Neutrino) - endif() - set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD WindowsStore WindowsCE watchOS tvOS FreeBSD SunOS AIX Arduino Emscripten Neutrino) - list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index) - if (${_index} GREATER -1) - #check if the cmake system is a conan supported one - set(_CONAN_SETTING_OS ${CONAN_SYSTEM_NAME}) - else() - message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}") - endif() - endif() -endmacro() - -macro(_conan_check_language) - get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) - if (";${_languages};" MATCHES ";CXX;") - set(LANGUAGE CXX) - set(USING_CXX 1) - elseif (";${_languages};" MATCHES ";C;") - set(LANGUAGE C) - set(USING_CXX 0) - else () - message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.") - endif() -endmacro() - -macro(_conan_detect_compiler) - - conan_parse_arguments(${ARGV}) - - if(ARGUMENTS_ARCH) - set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH}) - endif() - - if(USING_CXX) - set(_CONAN_SETTING_COMPILER_CPPSTD ${CMAKE_CXX_STANDARD}) - endif() - - if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU OR ${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL QCC) - # using GCC or QCC - # TODO: Handle other params - string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) - list(GET VERSION_LIST 0 MAJOR) - list(GET VERSION_LIST 1 MINOR) - - if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) - set(_CONAN_SETTING_COMPILER gcc) - # mimic Conan client autodetection - if (${MAJOR} GREATER_EQUAL 5) - set(COMPILER_VERSION ${MAJOR}) - else() - set(COMPILER_VERSION ${MAJOR}.${MINOR}) - endif() - elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL QCC) - set(_CONAN_SETTING_COMPILER qcc) - set(COMPILER_VERSION ${MAJOR}.${MINOR}) - endif () - - set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) - - if (USING_CXX) - conan_cmake_detect_unix_libcxx(_LIBCXX) - set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) - endif () - elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Intel) - string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) - list(GET VERSION_LIST 0 MAJOR) - list(GET VERSION_LIST 1 MINOR) - set(COMPILER_VERSION ${MAJOR}) - set(_CONAN_SETTING_COMPILER intel) - set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) - if (USING_CXX) - conan_cmake_detect_unix_libcxx(_LIBCXX) - set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) - endif () - elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang) - # using AppleClang - string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) - list(GET VERSION_LIST 0 MAJOR) - list(GET VERSION_LIST 1 MINOR) - - # mimic Conan client autodetection - if (${MAJOR} GREATER_EQUAL 13) - set(COMPILER_VERSION ${MAJOR}) - else() - set(COMPILER_VERSION ${MAJOR}.${MINOR}) - endif() - - set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) - - set(_CONAN_SETTING_COMPILER apple-clang) - if (USING_CXX) - conan_cmake_detect_unix_libcxx(_LIBCXX) - set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) - endif () - elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang - AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" - AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC") - - string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) - list(GET VERSION_LIST 0 MAJOR) - list(GET VERSION_LIST 1 MINOR) - set(_CONAN_SETTING_COMPILER clang) - - # mimic Conan client autodetection - if (${MAJOR} GREATER_EQUAL 8) - set(COMPILER_VERSION ${MAJOR}) - else() - set(COMPILER_VERSION ${MAJOR}.${MINOR}) - endif() - - set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) - - if(APPLE) - cmake_policy(GET CMP0025 APPLE_CLANG_POLICY) - if(NOT APPLE_CLANG_POLICY STREQUAL NEW) - message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it") - set(_CONAN_SETTING_COMPILER apple-clang) - endif() - endif() - if (USING_CXX) - conan_cmake_detect_unix_libcxx(_LIBCXX) - set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) - endif () - elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC - OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang - AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" - AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")) - - set(_VISUAL "Visual Studio") - _get_msvc_ide_version(_VISUAL_VERSION) - if("${_VISUAL_VERSION}" STREQUAL "") - message(FATAL_ERROR "Conan: Visual Studio not recognized") - else() - set(_CONAN_SETTING_COMPILER ${_VISUAL}) - set(_CONAN_SETTING_COMPILER_VERSION ${_VISUAL_VERSION}) - endif() - - if(NOT _CONAN_SETTING_ARCH) - if (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "64") - set(_CONAN_SETTING_ARCH x86_64) - elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "^ARM") - message(STATUS "Conan: Using default ARM architecture from MSVC") - set(_CONAN_SETTING_ARCH armv6) - elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "86") - set(_CONAN_SETTING_ARCH x86) - else () - message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_${LANGUAGE}_ARCHITECTURE_ID}]") - endif() - endif() - - conan_cmake_detect_vs_runtime(_vs_runtime ${ARGV}) - message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}") - set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime}) - - if (CMAKE_GENERATOR_TOOLSET) - set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) - elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja")) - set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) - endif() - else() - message(FATAL_ERROR "Conan: compiler setup not recognized") - endif() - -endmacro() - -function(conan_cmake_settings result) - #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER}) - #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID}) - #message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION}) - #message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS}) - #message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE}) - #message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE}) - #message(STATUS "GENERATOR " ${CMAKE_GENERATOR}) - #message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64}) - - message(STATUS "Conan: Automatic detection of conan settings from cmake") - - conan_parse_arguments(${ARGV}) - - _conan_detect_build_type(${ARGV}) - - _conan_check_system_name() - - _conan_check_language() - - _conan_detect_compiler(${ARGV}) - - # If profile is defined it is used - if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE}) - elseif(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_RELEASE_PROFILE}) - elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND ARGUMENTS_RELWITHDEBINFO_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_RELWITHDEBINFO_PROFILE}) - elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" AND ARGUMENTS_MINSIZEREL_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_MINSIZEREL_PROFILE}) - elseif(ARGUMENTS_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_PROFILE}) - endif() - - foreach(ARG ${_APPLIED_PROFILES}) - set(_SETTINGS ${_SETTINGS} -pr=${ARG}) - endforeach() - foreach(ARG ${ARGUMENTS_PROFILE_BUILD}) - conan_check(VERSION 1.24.0 REQUIRED DETECT_QUIET) - set(_SETTINGS ${_SETTINGS} -pr:b=${ARG}) - endforeach() - - if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL") - set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version - compiler.runtime compiler.libcxx compiler.toolset os) - endif() - - # remove any manually specified settings from the autodetected settings - foreach(ARG ${ARGUMENTS_SETTINGS}) - string(REGEX MATCH "[^=]*" MANUAL_SETTING "${ARG}") - message(STATUS "Conan: ${MANUAL_SETTING} was added as an argument. Not using the autodetected one.") - list(REMOVE_ITEM ARGUMENTS_PROFILE_AUTO "${MANUAL_SETTING}") - endforeach() - - # Automatic from CMake - foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) - string(TOUPPER ${ARG} _arg_name) - string(REPLACE "." "_" _arg_name ${_arg_name}) - if(_CONAN_SETTING_${_arg_name}) - set(_SETTINGS ${_SETTINGS} -s ${ARG}=${_CONAN_SETTING_${_arg_name}}) - endif() - endforeach() - - foreach(ARG ${ARGUMENTS_SETTINGS}) - set(_SETTINGS ${_SETTINGS} -s ${ARG}) - endforeach() - - message(STATUS "Conan: Settings= ${_SETTINGS}") - - set(${result} ${_SETTINGS} PARENT_SCOPE) -endfunction() - - -function(conan_cmake_detect_unix_libcxx result) - # Take into account any -stdlib in compile options - get_directory_property(compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) - string(GENEX_STRIP "${compile_options}" compile_options) - - # Take into account any _GLIBCXX_USE_CXX11_ABI in compile definitions - get_directory_property(defines DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) - string(GENEX_STRIP "${defines}" defines) - - foreach(define ${defines}) - if(define MATCHES "_GLIBCXX_USE_CXX11_ABI") - if(define MATCHES "^-D") - set(compile_options ${compile_options} "${define}") - else() - set(compile_options ${compile_options} "-D${define}") - endif() - endif() - endforeach() - - # add additional compiler options ala cmRulePlaceholderExpander::ExpandRuleVariable - set(EXPAND_CXX_COMPILER ${CMAKE_CXX_COMPILER}) - if(CMAKE_CXX_COMPILER_ARG1) - # CMake splits CXX="foo bar baz" into CMAKE_CXX_COMPILER="foo", CMAKE_CXX_COMPILER_ARG1="bar baz" - # without this, ccache, winegcc, or other wrappers might lose all their arguments - separate_arguments(SPLIT_CXX_COMPILER_ARG1 NATIVE_COMMAND ${CMAKE_CXX_COMPILER_ARG1}) - list(APPEND EXPAND_CXX_COMPILER ${SPLIT_CXX_COMPILER_ARG1}) - endif() - - if(CMAKE_CXX_COMPILE_OPTIONS_TARGET AND CMAKE_CXX_COMPILER_TARGET) - # without --target= we may be calling the wrong underlying GCC - list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_TARGET}${CMAKE_CXX_COMPILER_TARGET}") - endif() - - if(CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN AND CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) - list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") - endif() - - if(CMAKE_CXX_COMPILE_OPTIONS_SYSROOT) - # without --sysroot= we may find the wrong #include - if(CMAKE_SYSROOT_COMPILE) - list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_COMPILE}") - elseif(CMAKE_SYSROOT) - list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}") - endif() - endif() - - separate_arguments(SPLIT_CXX_FLAGS NATIVE_COMMAND ${CMAKE_CXX_FLAGS}) - - if(CMAKE_OSX_SYSROOT) - set(xcode_sysroot_option "--sysroot=${CMAKE_OSX_SYSROOT}") - endif() - - execute_process( - COMMAND ${CMAKE_COMMAND} -E echo "#include " - COMMAND ${EXPAND_CXX_COMPILER} ${SPLIT_CXX_FLAGS} -x c++ ${xcode_sysroot_option} ${compile_options} -E -dM - - OUTPUT_VARIABLE string_defines - ) - - if(string_defines MATCHES "#define __GLIBCXX__") - # Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake - if(DEFINED _GLIBCXX_USE_CXX11_ABI) - if(_GLIBCXX_USE_CXX11_ABI) - set(${result} libstdc++11 PARENT_SCOPE) - return() - else() - set(${result} libstdc++ PARENT_SCOPE) - return() - endif() - endif() - - if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n") - set(${result} libstdc++11 PARENT_SCOPE) - else() - # Either the compiler is missing the define because it is old, and so - # it can't use the new abi, or the compiler was configured to use the - # old abi by the user or distro (e.g. devtoolset on RHEL/CentOS) - set(${result} libstdc++ PARENT_SCOPE) - endif() - else() - set(${result} libc++ PARENT_SCOPE) - endif() -endfunction() - -function(conan_cmake_detect_vs_runtime result) - - conan_parse_arguments(${ARGV}) - if(ARGUMENTS_BUILD_TYPE) - set(build_type "${ARGUMENTS_BUILD_TYPE}") - elseif(CMAKE_BUILD_TYPE) - set(build_type "${CMAKE_BUILD_TYPE}") - else() - message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") - endif() - - if(build_type) - string(TOUPPER "${build_type}" build_type) - endif() - set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) - foreach(variable ${variables}) - if(NOT "${${variable}}" STREQUAL "") - string(REPLACE " " ";" flags "${${variable}}") - foreach (flag ${flags}) - if("${flag}" STREQUAL "/MD" OR "${flag}" STREQUAL "/MDd" OR "${flag}" STREQUAL "/MT" OR "${flag}" STREQUAL "/MTd") - string(SUBSTRING "${flag}" 1 -1 runtime) - set(${result} "${runtime}" PARENT_SCOPE) - return() - endif() - endforeach() - endif() - endforeach() - if("${build_type}" STREQUAL "DEBUG") - set(${result} "MDd" PARENT_SCOPE) - else() - set(${result} "MD" PARENT_SCOPE) - endif() -endfunction() - -function(_collect_settings result) - set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version - compiler.runtime compiler.libcxx compiler.toolset - compiler.cppstd os) - foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) - string(TOUPPER ${ARG} _arg_name) - string(REPLACE "." "_" _arg_name ${_arg_name}) - if(_CONAN_SETTING_${_arg_name}) - set(detected_setings ${detected_setings} ${ARG}=${_CONAN_SETTING_${_arg_name}}) - endif() - endforeach() - set(${result} ${detected_setings} PARENT_SCOPE) -endfunction() - -function(conan_cmake_autodetect detected_settings) - _conan_detect_build_type(${ARGV}) - _conan_check_system_name() - _conan_check_language() - _conan_detect_compiler(${ARGV}) - _collect_settings(collected_settings) - set(${detected_settings} ${collected_settings} PARENT_SCOPE) -endfunction() - -macro(conan_parse_arguments) - set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS - OUTPUT_QUIET NO_IMPORTS SKIP_STD) - set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND) - set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE - PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO - INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD BUILD_REQUIRES) - cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) -endmacro() - -function(old_conan_cmake_install) - # Calls "conan install" - # Argument BUILD is equivalent to --build={missing, PkgName,...} or - # --build when argument is 'BUILD all' (which builds all packages from source) - # Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source - # cmake does not identify conan as command, even if it is +x and it is in the path - conan_parse_arguments(${ARGV}) - - if(CONAN_CMAKE_MULTI) - set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi) - else() - set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake) - endif() - - set(CONAN_BUILD_POLICY "") - foreach(ARG ${ARGUMENTS_BUILD}) - if(${ARG} STREQUAL "all") - set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build) - break() - else() - set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG}) - endif() - endforeach() - if(ARGUMENTS_CONAN_COMMAND) - set(CONAN_CMD ${ARGUMENTS_CONAN_COMMAND}) - else() - conan_check(REQUIRED) - endif() - set(CONAN_OPTIONS "") - if(ARGUMENTS_CONANFILE) - if(IS_ABSOLUTE ${ARGUMENTS_CONANFILE}) - set(CONANFILE ${ARGUMENTS_CONANFILE}) - else() - set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE}) - endif() - else() - set(CONANFILE ".") - endif() - foreach(ARG ${ARGUMENTS_OPTIONS}) - set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG}) - endforeach() - if(ARGUMENTS_UPDATE) - set(CONAN_INSTALL_UPDATE --update) - endif() - if(ARGUMENTS_NO_IMPORTS) - set(CONAN_INSTALL_NO_IMPORTS --no-imports) - endif() - set(CONAN_INSTALL_FOLDER "") - if(ARGUMENTS_INSTALL_FOLDER) - set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER}) - endif() - set(CONAN_OUTPUT_FOLDER "") - if(ARGUMENTS_OUTPUT_FOLDER) - set(CONAN_OUTPUT_FOLDER -of=${ARGUMENTS_OUTPUT_FOLDER}) - endif() - foreach(ARG ${ARGUMENTS_GENERATORS}) - set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG}) - endforeach() - foreach(ARG ${ARGUMENTS_ENV}) - set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG}) - endforeach() - set(conan_args install ${CONANFILE} ${settings} ${CONAN_ENV_VARS} ${CONAN_GENERATORS} ${CONAN_BUILD_POLICY} ${CONAN_INSTALL_UPDATE} ${CONAN_INSTALL_NO_IMPORTS} ${CONAN_OPTIONS} ${CONAN_INSTALL_FOLDER} ${ARGUMENTS_INSTALL_ARGS}) - - string (REPLACE ";" " " _conan_args "${conan_args}") - message(STATUS "Conan executing: ${CONAN_CMD} ${_conan_args}") - - if(ARGUMENTS_OUTPUT_QUIET) - execute_process(COMMAND ${CONAN_CMD} ${conan_args} - RESULT_VARIABLE return_code - OUTPUT_VARIABLE conan_output - ERROR_VARIABLE conan_output - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - else() - execute_process(COMMAND ${CONAN_CMD} ${conan_args} - RESULT_VARIABLE return_code - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - endif() - - if(NOT "${return_code}" STREQUAL "0") - message(FATAL_ERROR "Conan install failed='${return_code}'") - endif() - -endfunction() - -function(conan_cmake_install) - if(DEFINED CONAN_COMMAND) - set(CONAN_CMD ${CONAN_COMMAND}) - else() - conan_check(REQUIRED) - endif() - - set(installOptions UPDATE NO_IMPORTS OUTPUT_QUIET ERROR_QUIET) - set(installOneValueArgs PATH_OR_REFERENCE REFERENCE REMOTE LOCKFILE LOCKFILE_OUT LOCKFILE_NODE_ID INSTALL_FOLDER OUTPUT_FOLDER) - set(installMultiValueArgs GENERATOR BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE - PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD CONF CONF_HOST CONF_BUILD) - cmake_parse_arguments(ARGS "${installOptions}" "${installOneValueArgs}" "${installMultiValueArgs}" ${ARGN}) - foreach(arg ${installOptions}) - if(ARGS_${arg}) - set(${arg} ${${arg}} ${ARGS_${arg}}) - endif() - endforeach() - foreach(arg ${installOneValueArgs}) - if(DEFINED ARGS_${arg}) - if("${arg}" STREQUAL "REMOTE") - set(flag "--remote") - elseif("${arg}" STREQUAL "LOCKFILE") - set(flag "--lockfile") - elseif("${arg}" STREQUAL "LOCKFILE_OUT") - set(flag "--lockfile-out") - elseif("${arg}" STREQUAL "LOCKFILE_NODE_ID") - set(flag "--lockfile-node-id") - elseif("${arg}" STREQUAL "INSTALL_FOLDER") - set(flag "--install-folder") - elseif("${arg}" STREQUAL "OUTPUT_FOLDER") - set(flag "--output-folder") - endif() - set(${arg} ${${arg}} ${flag} ${ARGS_${arg}}) - endif() - endforeach() - foreach(arg ${installMultiValueArgs}) - if(DEFINED ARGS_${arg}) - if("${arg}" STREQUAL "GENERATOR") - set(flag "--generator") - elseif("${arg}" STREQUAL "BUILD") - set(flag "--build") - elseif("${arg}" STREQUAL "ENV") - set(flag "--env") - elseif("${arg}" STREQUAL "ENV_HOST") - set(flag "--env:host") - elseif("${arg}" STREQUAL "ENV_BUILD") - set(flag "--env:build") - elseif("${arg}" STREQUAL "OPTIONS") - set(flag "--options") - elseif("${arg}" STREQUAL "OPTIONS_HOST") - set(flag "--options:host") - elseif("${arg}" STREQUAL "OPTIONS_BUILD") - set(flag "--options:build") - elseif("${arg}" STREQUAL "PROFILE") - set(flag "--profile") - elseif("${arg}" STREQUAL "PROFILE_HOST") - set(flag "--profile:host") - elseif("${arg}" STREQUAL "PROFILE_BUILD") - set(flag "--profile:build") - elseif("${arg}" STREQUAL "SETTINGS") - set(flag "--settings") - elseif("${arg}" STREQUAL "SETTINGS_HOST") - set(flag "--settings:host") - elseif("${arg}" STREQUAL "SETTINGS_BUILD") - set(flag "--settings:build") - elseif("${arg}" STREQUAL "CONF") - set(flag "--conf") - elseif("${arg}" STREQUAL "CONF_HOST") - set(flag "--conf:host") - elseif("${arg}" STREQUAL "CONF_BUILD") - set(flag "--conf:build") - endif() - list(LENGTH ARGS_${arg} numargs) - foreach(item ${ARGS_${arg}}) - if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD") - set(${arg} "--build") - break() - endif() - set(${arg} ${${arg}} ${flag} ${item}) - endforeach() - endif() - endforeach() - if(DEFINED UPDATE) - set(UPDATE --update) - endif() - if(DEFINED NO_IMPORTS) - set(NO_IMPORTS --no-imports) - endif() - set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} - ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} - ${OUTPUT_FOLDER} ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} - ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} ${PROFILE} ${PROFILE_HOST} - ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD} - ${CONF} ${CONF_HOST} ${CONF_BUILD}) - - string(REPLACE ";" " " _install_args "${install_args}") - message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}") - - if(ARGS_OUTPUT_QUIET) - set(OUTPUT_OPT OUTPUT_QUIET) - endif() - if(ARGS_ERROR_QUIET) - set(ERROR_OPT ERROR_QUIET) - endif() - - execute_process(COMMAND ${CONAN_CMD} ${install_args} - RESULT_VARIABLE return_code - ${OUTPUT_OPT} - ${ERROR_OPT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - - if(NOT "${return_code}" STREQUAL "0") - if (ARGS_ERROR_QUIET) - message(WARNING "Conan install failed='${return_code}'") - else() - message(FATAL_ERROR "Conan install failed='${return_code}'") - endif() - endif() - -endfunction() - -function(conan_cmake_lock_create) - if(DEFINED CONAN_COMMAND) - set(CONAN_CMD ${CONAN_COMMAND}) - else() - conan_check(REQUIRED) - endif() - - set(lockCreateOptions UPDATE BASE OUTPUT_QUIET ERROR_QUIET) - set(lockCreateOneValueArgs PATH REFERENCE REMOTE LOCKFILE LOCKFILE_OUT) - set(lockCreateMultiValueArgs BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE - PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD) - cmake_parse_arguments(ARGS "${lockCreateOptions}" "${lockCreateOneValueArgs}" "${lockCreateMultiValueArgs}" ${ARGN}) - foreach(arg ${lockCreateOptions}) - if(ARGS_${arg}) - set(${arg} ${${arg}} ${ARGS_${arg}}) - endif() - endforeach() - foreach(arg ${lockCreateOneValueArgs}) - if(DEFINED ARGS_${arg}) - if("${arg}" STREQUAL "REMOTE") - set(flag "--remote") - elseif("${arg}" STREQUAL "LOCKFILE") - set(flag "--lockfile") - elseif("${arg}" STREQUAL "LOCKFILE_OUT") - set(flag "--lockfile-out") - endif() - set(${arg} ${${arg}} ${flag} ${ARGS_${arg}}) - endif() - endforeach() - foreach(arg ${lockCreateMultiValueArgs}) - if(DEFINED ARGS_${arg}) - if("${arg}" STREQUAL "BUILD") - set(flag "--build") - elseif("${arg}" STREQUAL "ENV") - set(flag "--env") - elseif("${arg}" STREQUAL "ENV_HOST") - set(flag "--env:host") - elseif("${arg}" STREQUAL "ENV_BUILD") - set(flag "--env:build") - elseif("${arg}" STREQUAL "OPTIONS") - set(flag "--options") - elseif("${arg}" STREQUAL "OPTIONS_HOST") - set(flag "--options:host") - elseif("${arg}" STREQUAL "OPTIONS_BUILD") - set(flag "--options:build") - elseif("${arg}" STREQUAL "PROFILE") - set(flag "--profile") - elseif("${arg}" STREQUAL "PROFILE_HOST") - set(flag "--profile:host") - elseif("${arg}" STREQUAL "PROFILE_BUILD") - set(flag "--profile:build") - elseif("${arg}" STREQUAL "SETTINGS") - set(flag "--settings") - elseif("${arg}" STREQUAL "SETTINGS_HOST") - set(flag "--settings:host") - elseif("${arg}" STREQUAL "SETTINGS_BUILD") - set(flag "--settings:build") - endif() - list(LENGTH ARGS_${arg} numargs) - foreach(item ${ARGS_${arg}}) - if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD") - set(${arg} "--build") - break() - endif() - set(${arg} ${${arg}} ${flag} ${item}) - endforeach() - endif() - endforeach() - if(DEFINED UPDATE) - set(UPDATE --update) - endif() - if(DEFINED BASE) - set(BASE --base) - endif() - set(lock_create_Args lock create ${PATH} ${REFERENCE} ${UPDATE} ${BASE} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} - ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} - ${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) - - string(REPLACE ";" " " _lock_create_Args "${lock_create_Args}") - message(STATUS "Conan executing: ${CONAN_CMD} ${_lock_create_Args}") - - if(ARGS_OUTPUT_QUIET) - set(OUTPUT_OPT OUTPUT_QUIET) - endif() - if(ARGS_ERROR_QUIET) - set(ERROR_OPT ERROR_QUIET) - endif() - - execute_process(COMMAND ${CONAN_CMD} ${lock_create_Args} - RESULT_VARIABLE return_code - ${OUTPUT_OPT} - ${ERROR_OPT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - - if(NOT "${return_code}" STREQUAL "0") - if (ARGS_ERROR_QUIET) - message(WARNING "Conan lock create failed='${return_code}'") - else() - message(FATAL_ERROR "Conan lock create failed='${return_code}'") - endif() - endif() -endfunction() - -function(conan_cmake_setup_conanfile) - conan_parse_arguments(${ARGV}) - if(ARGUMENTS_CONANFILE) - get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME) - # configure_file will make sure cmake re-runs when conanfile is updated - configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk COPYONLY) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) - else() - conan_cmake_generate_conanfile(ON ${ARGV}) - endif() -endfunction() - -function(conan_cmake_configure) - conan_cmake_generate_conanfile(OFF ${ARGV}) -endfunction() - -# Generate, writing in disk a conanfile.txt with the requires, options, and imports -# specified as arguments -# This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR) -function(conan_cmake_generate_conanfile DEFAULT_GENERATOR) - - conan_parse_arguments(${ARGV}) - - set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt") - file(WRITE ${_FN} "") - - if(DEFINED ARGUMENTS_REQUIRES) - file(APPEND ${_FN} "[requires]\n") - foreach(REQUIRE ${ARGUMENTS_REQUIRES}) - file(APPEND ${_FN} ${REQUIRE} "\n") - endforeach() - endif() - - if (DEFAULT_GENERATOR OR DEFINED ARGUMENTS_GENERATORS) - file(APPEND ${_FN} "[generators]\n") - if (DEFAULT_GENERATOR) - file(APPEND ${_FN} "cmake\n") - endif() - if (DEFINED ARGUMENTS_GENERATORS) - foreach(GENERATOR ${ARGUMENTS_GENERATORS}) - file(APPEND ${_FN} ${GENERATOR} "\n") - endforeach() - endif() - endif() - - if(DEFINED ARGUMENTS_BUILD_REQUIRES) - file(APPEND ${_FN} "[build_requires]\n") - foreach(BUILD_REQUIRE ${ARGUMENTS_BUILD_REQUIRES}) - file(APPEND ${_FN} ${BUILD_REQUIRE} "\n") - endforeach() - endif() - - if(DEFINED ARGUMENTS_IMPORTS) - file(APPEND ${_FN} "[imports]\n") - foreach(IMPORTS ${ARGUMENTS_IMPORTS}) - file(APPEND ${_FN} ${IMPORTS} "\n") - endforeach() - endif() - - if(DEFINED ARGUMENTS_OPTIONS) - file(APPEND ${_FN} "[options]\n") - foreach(OPTION ${ARGUMENTS_OPTIONS}) - file(APPEND ${_FN} ${OPTION} "\n") - endforeach() - endif() - -endfunction() - - -macro(conan_load_buildinfo) - if(CONAN_CMAKE_MULTI) - set(_CONANBUILDINFO conanbuildinfo_multi.cmake) - else() - set(_CONANBUILDINFO conanbuildinfo.cmake) - endif() - if(ARGUMENTS_INSTALL_FOLDER) - set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER}) - else() - set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR}) - endif() - # Checks for the existence of conanbuildinfo.cmake, and loads it - # important that it is macro, so variables defined at parent scope - if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}") - message(STATUS "Conan: Loading ${_CONANBUILDINFO}") - include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}) - else() - message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}") - endif() -endmacro() - - -macro(conan_cmake_run) - conan_parse_arguments(${ARGV}) - - if(ARGUMENTS_CONFIGURATION_TYPES AND NOT CMAKE_CONFIGURATION_TYPES) - message(WARNING "CONFIGURATION_TYPES should only be specified for multi-configuration generators") - elseif(ARGUMENTS_CONFIGURATION_TYPES AND ARGUMENTS_BUILD_TYPE) - message(WARNING "CONFIGURATION_TYPES and BUILD_TYPE arguments should not be defined at the same time.") - endif() - - if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED - AND NOT ARGUMENTS_BUILD_TYPE) - set(CONAN_CMAKE_MULTI ON) - if (NOT ARGUMENTS_CONFIGURATION_TYPES) - set(ARGUMENTS_CONFIGURATION_TYPES "Release;Debug") - endif() - message(STATUS "Conan: Using cmake-multi generator") - else() - set(CONAN_CMAKE_MULTI OFF) - endif() - - if(NOT CONAN_EXPORTED) - conan_cmake_setup_conanfile(${ARGV}) - if(CONAN_CMAKE_MULTI) - foreach(CMAKE_BUILD_TYPE ${ARGUMENTS_CONFIGURATION_TYPES}) - set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE}) - conan_cmake_settings(settings ${ARGV}) - old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) - endforeach() - set(CMAKE_BUILD_TYPE) - else() - conan_cmake_settings(settings ${ARGV}) - old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) - endif() - endif() - - if (NOT ARGUMENTS_NO_LOAD) - conan_load_buildinfo() - endif() - - if(ARGUMENTS_BASIC_SETUP) - foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS SKIP_STD) - if(ARGUMENTS_${_option}) - if(${_option} STREQUAL "CMAKE_TARGETS") - list(APPEND _setup_options "TARGETS") - else() - list(APPEND _setup_options ${_option}) - endif() - endif() - endforeach() - conan_basic_setup(${_setup_options}) - endif() -endmacro() - -function(conan_version result) - set(${result} "" PARENT_SCOPE) - - if(NOT CONAN_CMD) - find_program(CONAN_CMD conan) - if(NOT CONAN_CMD AND CONAN_REQUIRED) - message(FATAL_ERROR "Conan executable not found! Please install conan.") - endif() - endif() - - execute_process(COMMAND ${CONAN_CMD} --version - RESULT_VARIABLE return_code - OUTPUT_VARIABLE CONAN_VERSION_OUTPUT - ERROR_VARIABLE CONAN_VERSION_OUTPUT) - - if(NOT "${return_code}" STREQUAL "0") - message(FATAL_ERROR "Conan --version failed='${return_code}'") - endif() - - string(REGEX MATCH ".*Conan version ([0-9]+\\.[0-9]+\\.[0-9]+)" FOO "${CONAN_VERSION_OUTPUT}") - - set(${result} ${CMAKE_MATCH_1} PARENT_SCOPE) -endfunction() - -macro(conan_check) - # Checks conan availability in PATH - # Arguments REQUIRED, DETECT_QUIET and VERSION are optional - # Example usage: - # conan_check(VERSION 1.0.0 REQUIRED) - set(options REQUIRED DETECT_QUIET) - set(oneValueArgs VERSION) - cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN}) - if(NOT CONAN_DETECT_QUIET) - message(STATUS "Conan: checking conan executable") - endif() - - find_program(CONAN_CMD conan) - if(NOT CONAN_CMD AND CONAN_REQUIRED) - message(FATAL_ERROR "Conan executable not found! Please install conan.") - endif() - if(NOT CONAN_DETECT_QUIET) - message(STATUS "Conan: Found program ${CONAN_CMD}") - endif() - - conan_version(CONAN_DETECTED_VERSION) - - if(NOT CONAN_DETECT_QUIET) - message(STATUS "Conan: Version found ${CONAN_DETECTED_VERSION}") - endif() - - if(DEFINED CONAN_VERSION) - if(${CONAN_DETECTED_VERSION} VERSION_LESS ${CONAN_VERSION}) - message(FATAL_ERROR "Conan outdated. Installed: ${CONAN_DETECTED_VERSION}, \ - required: ${CONAN_VERSION}. Consider updating via 'pip \ - install conan==${CONAN_VERSION}'.") - endif() - endif() -endmacro() - -function(conan_add_remote) - # Adds a remote - # Arguments URL and NAME are required, INDEX, COMMAND and VERIFY_SSL are optional - # Example usage: - # conan_add_remote(NAME bincrafters INDEX 1 - # URL https://api.bintray.com/conan/bincrafters/public-conan - # VERIFY_SSL True) - set(oneValueArgs URL NAME INDEX COMMAND VERIFY_SSL) - cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN}) - - if(DEFINED CONAN_INDEX) - set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}") - endif() - if(DEFINED CONAN_COMMAND) - set(CONAN_CMD ${CONAN_COMMAND}) - else() - conan_check(REQUIRED DETECT_QUIET) - endif() - set(CONAN_VERIFY_SSL_ARG "True") - if(DEFINED CONAN_VERIFY_SSL) - set(CONAN_VERIFY_SSL_ARG ${CONAN_VERIFY_SSL}) - endif() - message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL}) verify ssl (${CONAN_VERIFY_SSL_ARG})") - execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_INDEX_ARG} -f ${CONAN_URL} ${CONAN_VERIFY_SSL_ARG} - RESULT_VARIABLE return_code) - if(NOT "${return_code}" STREQUAL "0") - message(FATAL_ERROR "Conan remote failed='${return_code}'") - endif() -endfunction() - -macro(conan_config_install) - # install a full configuration from a local or remote zip file - # Argument ITEM is required, arguments TYPE, SOURCE, TARGET and VERIFY_SSL are optional - # Example usage: - # conan_config_install(ITEM https://github.com/conan-io/cmake-conan.git - # TYPE git SOURCE source-folder TARGET target-folder VERIFY_SSL false) - set(oneValueArgs ITEM TYPE SOURCE TARGET VERIFY_SSL) - set(multiValueArgs ARGS) - cmake_parse_arguments(CONAN "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if(DEFINED CONAN_COMMAND) - set(CONAN_CMD ${CONAN_COMMAND}) - else() - conan_check(REQUIRED) - endif() - - if(DEFINED CONAN_VERIFY_SSL) - set(CONAN_VERIFY_SSL_ARG "--verify-ssl=${CONAN_VERIFY_SSL}") - endif() - - if(DEFINED CONAN_TYPE) - set(CONAN_TYPE_ARG "--type=${CONAN_TYPE}") - endif() - - if(DEFINED CONAN_ARGS) - # Convert ; seperated multi arg list into space seperated string - string(REPLACE ";" " " l_CONAN_ARGS "${CONAN_ARGS}") - set(CONAN_ARGS_ARGS "--args=${l_CONAN_ARGS}") - endif() - - if(DEFINED CONAN_SOURCE) - set(CONAN_SOURCE_ARGS "--source-folder=${CONAN_SOURCE}") - endif() - - if(DEFINED CONAN_TARGET) - set(CONAN_TARGET_ARGS "--target-folder=${CONAN_TARGET}") - endif() - - set (CONAN_CONFIG_INSTALL_ARGS ${CONAN_VERIFY_SSL_ARG} - ${CONAN_TYPE_ARG} - ${CONAN_ARGS_ARGS} - ${CONAN_SOURCE_ARGS} - ${CONAN_TARGET_ARGS}) - - message(STATUS "Conan: Installing config from ${CONAN_ITEM}") - execute_process(COMMAND ${CONAN_CMD} config install ${CONAN_ITEM} ${CONAN_CONFIG_INSTALL_ARGS} - RESULT_VARIABLE return_code) - if(NOT "${return_code}" STREQUAL "0") - message(FATAL_ERROR "Conan config failed='${return_code}'") - endif() -endmacro() - - -function(conan_cmake_profile) - set(profileOneValueArgs FILEPATH INCLUDE) - set(profileMultiValueArgs SETTINGS OPTIONS CONF ENV BUILDENV RUNENV TOOL_REQUIRES) - cmake_parse_arguments(ARGS "" "${profileOneValueArgs}" "${profileMultiValueArgs}" ${ARGN}) - - if(DEFINED ARGS_FILEPATH) - set(_FN "${ARGS_FILEPATH}") - else() - set(_FN "${CMAKE_CURRENT_BINARY_DIR}/profile") - endif() - message(STATUS "Conan: Creating profile ${_FN}") - file(WRITE ${_FN} "") - - if(DEFINED ARGS_INCLUDE) - file(APPEND ${_FN} "include(${ARGS_INCLUDE})\n") - endif() - - if(DEFINED ARGS_SETTINGS) - file(APPEND ${_FN} "[settings]\n") - foreach(SETTING ${ARGS_SETTINGS}) - file(APPEND ${_FN} ${SETTING} "\n") - endforeach() - endif() - - if(DEFINED ARGS_OPTIONS) - file(APPEND ${_FN} "[options]\n") - foreach(OPTION ${ARGS_OPTIONS}) - file(APPEND ${_FN} ${OPTION} "\n") - endforeach() - endif() - - if(DEFINED ARGS_CONF) - file(APPEND ${_FN} "[conf]\n") - foreach(CONF ${ARGS_CONF}) - file(APPEND ${_FN} ${CONF} "\n") - endforeach() - endif() - - if(DEFINED ARGS_ENV) - file(APPEND ${_FN} "[env]\n") - foreach(ENV ${ARGS_ENV}) - file(APPEND ${_FN} ${ENV} "\n") - endforeach() - endif() - - if(DEFINED ARGS_BUILDENV) - file(APPEND ${_FN} "[buildenv]\n") - foreach(BUILDENV ${ARGS_BUILDENV}) - file(APPEND ${_FN} ${BUILDENV} "\n") - endforeach() - endif() - - if(DEFINED ARGS_RUNENV) - file(APPEND ${_FN} "[runenv]\n") - foreach(RUNENV ${ARGS_RUNENV}) - file(APPEND ${_FN} ${RUNENV} "\n") - endforeach() - endif() - - if(DEFINED ARGS_TOOL_REQUIRES) - file(APPEND ${_FN} "[tool_requires]\n") - foreach(TOOL_REQUIRE ${ARGS_TOOL_REQUIRES}) - file(APPEND ${_FN} ${TOOL_REQUIRE} "\n") - endforeach() - endif() -endfunction() diff --git a/third_party/cmake-conan/conan_provider.cmake b/third_party/cmake-conan/conan_provider.cmake new file mode 100644 index 0000000000..59a58ed700 --- /dev/null +++ b/third_party/cmake-conan/conan_provider.cmake @@ -0,0 +1,675 @@ +# The MIT License (MIT) +# +# Copyright (c) 2024 JFrog +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set(CONAN_MINIMUM_VERSION 2.0.5) + +# Create a new policy scope and set the minimum required cmake version so the +# features behind a policy setting like if(... IN_LIST ...) behaves as expected +# even if the parent project does not specify a minimum cmake version or a minimum +# version less than this module requires (e.g. 3.0) before the first project() call. +# (see: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.html) +# +# The policy-affecting calls like cmake_policy(SET...) or `cmake_minimum_required` only +# affects the current policy scope, i.e. between the PUSH and POP in this case. +# +# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Policies.html#the-policy-stack +cmake_policy(PUSH) +cmake_minimum_required(VERSION 3.24) + + +function(detect_os os os_api_level os_sdk os_subsystem os_version) + # it could be cross compilation + message(STATUS "CMake-Conan: cmake_system_name=${CMAKE_SYSTEM_NAME}") + if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(${os} Macos PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX") + set(${os} Neutrino PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN") + set(${os} Windows PARENT_SCOPE) + set(${os_subsystem} cygwin PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS") + set(${os} Windows PARENT_SCOPE) + set(${os_subsystem} msys2 PARENT_SCOPE) + else() + set(${os} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + if(DEFINED ANDROID_PLATFORM) + string(REGEX MATCH "[0-9]+" _os_api_level ${ANDROID_PLATFORM}) + elseif(DEFINED CMAKE_SYSTEM_VERSION) + set(_os_api_level ${CMAKE_SYSTEM_VERSION}) + endif() + message(STATUS "CMake-Conan: android api level=${_os_api_level}") + set(${os_api_level} ${_os_api_level} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS") + # CMAKE_OSX_SYSROOT contains the full path to the SDK for MakeFile/Ninja + # generators, but just has the original input string for Xcode. + if(NOT IS_DIRECTORY ${CMAKE_OSX_SYSROOT}) + set(_os_sdk ${CMAKE_OSX_SYSROOT}) + else() + if(CMAKE_OSX_SYSROOT MATCHES Simulator) + set(apple_platform_suffix simulator) + else() + set(apple_platform_suffix os) + endif() + if(CMAKE_OSX_SYSROOT MATCHES AppleTV) + set(_os_sdk "appletv${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES iPhone) + set(_os_sdk "iphone${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES Watch) + set(_os_sdk "watch${apple_platform_suffix}") + endif() + endif() + if(DEFINED os_sdk) + message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}") + set(${os_sdk} ${_os_sdk} PARENT_SCOPE) + endif() + if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET) + message(STATUS "CMake-Conan: cmake_osx_deployment_target=${CMAKE_OSX_DEPLOYMENT_TARGET}") + set(${os_version} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + + +function(detect_arch arch) + # CMAKE_OSX_ARCHITECTURES can contain multiple architectures, but Conan only supports one. + # Therefore this code only finds one. If the recipes support multiple architectures, the + # build will work. Otherwise, there will be a linker error for the missing architecture(s). + if(DEFINED CMAKE_OSX_ARCHITECTURES) + string(REPLACE " " ";" apple_arch_list "${CMAKE_OSX_ARCHITECTURES}") + list(LENGTH apple_arch_list apple_arch_count) + if(apple_arch_count GREATER 1) + message(WARNING "CMake-Conan: Multiple architectures detected, this will only work if Conan recipe(s) produce fat binaries.") + endif() + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "") + set(host_arch ${CMAKE_OSX_ARCHITECTURES}) + elseif(MSVC) + set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}) + else() + set(host_arch ${CMAKE_SYSTEM_PROCESSOR}) + endif() + if(host_arch MATCHES "aarch64|arm64|ARM64") + set(_arch armv8) + elseif(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7") + set(_arch armv7) + elseif(host_arch MATCHES armv7s) + set(_arch armv7s) + elseif(host_arch MATCHES "i686|i386|X86") + set(_arch x86) + elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64") + set(_arch x86_64) + endif() + message(STATUS "CMake-Conan: cmake_system_processor=${_arch}") + set(${arch} ${_arch} PARENT_SCOPE) +endfunction() + + +function(detect_cxx_standard cxx_standard) + set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE) + if(CMAKE_CXX_EXTENSIONS) + set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE) + endif() +endfunction() + + +macro(detect_gnu_libstdcxx) + # _conan_is_gnu_libstdcxx true if GNU libstdc++ + check_cxx_source_compiles(" + #include + #if !defined(__GLIBCXX__) && !defined(__GLIBCPP__) + static_assert(false); + #endif + int main(){}" _conan_is_gnu_libstdcxx) + + # _conan_gnu_libstdcxx_is_cxx11_abi true if C++11 ABI + check_cxx_source_compiles(" + #include + static_assert(sizeof(std::string) != sizeof(void*), \"using libstdc++\"); + int main () {}" _conan_gnu_libstdcxx_is_cxx11_abi) + + set(_conan_gnu_libstdcxx_suffix "") + if(_conan_gnu_libstdcxx_is_cxx11_abi) + set(_conan_gnu_libstdcxx_suffix "11") + endif() + unset (_conan_gnu_libstdcxx_is_cxx11_abi) +endmacro() + + +macro(detect_libcxx) + # _conan_is_libcxx true if LLVM libc++ + check_cxx_source_compiles(" + #include + #if !defined(_LIBCPP_VERSION) + static_assert(false); + #endif + int main(){}" _conan_is_libcxx) +endmacro() + + +function(detect_lib_cxx lib_cxx) + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + message(STATUS "CMake-Conan: android_stl=${CMAKE_ANDROID_STL_TYPE}") + set(${lib_cxx} ${CMAKE_ANDROID_STL_TYPE} PARENT_SCOPE) + return() + endif() + + include(CheckCXXSourceCompiles) + + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + detect_gnu_libstdcxx() + set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + set(${lib_cxx} "libc++" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows") + # Check for libc++ + detect_libcxx() + if(_conan_is_libcxx) + set(${lib_cxx} "libc++" PARENT_SCOPE) + return() + endif() + + # Check for libstdc++ + detect_gnu_libstdcxx() + if(_conan_is_gnu_libstdcxx) + set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE) + return() + endif() + + # TODO: it would be an error if we reach this point + elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + # Do nothing - compiler.runtime and compiler.runtime_type + # should be handled separately: https://github.com/conan-io/cmake-conan/pull/516 + return() + else() + # TODO: unable to determine, ask user to provide a full profile file instead + endif() +endfunction() + + +function(detect_compiler compiler compiler_version compiler_runtime compiler_runtime_type) + if(DEFINED CMAKE_CXX_COMPILER_ID) + set(_compiler ${CMAKE_CXX_COMPILER_ID}) + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) + else() + if(NOT DEFINED CMAKE_C_COMPILER_ID) + message(FATAL_ERROR "C or C++ compiler not defined") + endif() + set(_compiler ${CMAKE_C_COMPILER_ID}) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + endif() + + message(STATUS "CMake-Conan: CMake compiler=${_compiler}") + message(STATUS "CMake-Conan: CMake compiler version=${_compiler_version}") + + if(_compiler MATCHES MSVC) + set(_compiler "msvc") + string(SUBSTRING ${MSVC_VERSION} 0 3 _compiler_version) + # Configure compiler.runtime and compiler.runtime_type settings for MSVC + if(CMAKE_MSVC_RUNTIME_LIBRARY) + set(_msvc_runtime_library ${CMAKE_MSVC_RUNTIME_LIBRARY}) + else() + set(_msvc_runtime_library MultiThreaded$<$:Debug>DLL) # default value documented by CMake + endif() + + set(_KNOWN_MSVC_RUNTIME_VALUES "") + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded MultiThreadedDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreadedDebug MultiThreadedDebugDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded$<$:Debug> MultiThreaded$<$:Debug>DLL) + + # only accept the 6 possible values, otherwise we don't don't know to map this + if(NOT _msvc_runtime_library IN_LIST _KNOWN_MSVC_RUNTIME_VALUES) + message(FATAL_ERROR "CMake-Conan: unable to map MSVC runtime: ${_msvc_runtime_library} to Conan settings") + endif() + + # Runtime is "dynamic" in all cases if it ends in DLL + if(_msvc_runtime_library MATCHES ".*DLL$") + set(_compiler_runtime "dynamic") + else() + set(_compiler_runtime "static") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime=${_compiler_runtime}") + + # Only define compiler.runtime_type when explicitly requested + # If a generator expression is used, let Conan handle it conditional on build_type + if(NOT _msvc_runtime_library MATCHES ":Debug>") + if(_msvc_runtime_library MATCHES "Debug") + set(_compiler_runtime_type "Debug") + else() + set(_compiler_runtime_type "Release") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_compiler_runtime_type}") + endif() + + unset(_KNOWN_MSVC_RUNTIME_VALUES) + + elseif(_compiler MATCHES AppleClang) + set(_compiler "apple-clang") + string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) + list(GET VERSION_LIST 0 _compiler_version) + elseif(_compiler MATCHES Clang) + set(_compiler "clang") + string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) + list(GET VERSION_LIST 0 _compiler_version) + elseif(_compiler MATCHES GNU) + set(_compiler "gcc") + string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) + list(GET VERSION_LIST 0 _compiler_version) + endif() + + message(STATUS "CMake-Conan: [settings] compiler=${_compiler}") + message(STATUS "CMake-Conan: [settings] compiler.version=${_compiler_version}") + if (_compiler_runtime) + message(STATUS "CMake-Conan: [settings] compiler.runtime=${_compiler_runtime}") + endif() + if (_compiler_runtime_type) + message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_compiler_runtime_type}") + endif() + + set(${compiler} ${_compiler} PARENT_SCOPE) + set(${compiler_version} ${_compiler_version} PARENT_SCOPE) + set(${compiler_runtime} ${_compiler_runtime} PARENT_SCOPE) + set(${compiler_runtime_type} ${_compiler_runtime_type} PARENT_SCOPE) +endfunction() + + +function(detect_build_type build_type) + get_property(multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT multiconfig_generator) + # Only set when we know we are in a single-configuration generator + # Note: we may want to fail early if `CMAKE_BUILD_TYPE` is not defined + set(${build_type} ${CMAKE_BUILD_TYPE} PARENT_SCOPE) + endif() +endfunction() + + +macro(set_conan_compiler_if_appleclang lang command output_variable) + if(CMAKE_${lang}_COMPILER_ID STREQUAL "AppleClang") + execute_process(COMMAND xcrun --find ${command} + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE) + cmake_path(GET _xcrun_out PARENT_PATH _xcrun_toolchain_path) + cmake_path(GET CMAKE_${lang}_COMPILER PARENT_PATH _compiler_parent_path) + if ("${_xcrun_toolchain_path}" STREQUAL "${_compiler_parent_path}") + set(${output_variable} "") + endif() + unset(_xcrun_out) + unset(_xcrun_toolchain_path) + unset(_compiler_parent_path) + endif() +endmacro() + + +macro(append_compiler_executables_configuration) + set(_conan_c_compiler "") + set(_conan_cpp_compiler "") + set(_conan_rc_compiler "") + set(_conan_compilers_list "") + if(CMAKE_C_COMPILER) + set(_conan_c_compiler "\"c\":\"${CMAKE_C_COMPILER}\"") + set_conan_compiler_if_appleclang(C cc _conan_c_compiler) + list(APPEND _conan_compilers_list ${_conan_c_compiler}) + else() + message(WARNING "CMake-Conan: The C compiler is not defined. " + "Please define CMAKE_C_COMPILER or enable the C language.") + endif() + if(CMAKE_CXX_COMPILER) + set(_conan_cpp_compiler "\"cpp\":\"${CMAKE_CXX_COMPILER}\"") + set_conan_compiler_if_appleclang(CXX c++ _conan_cpp_compiler) + list(APPEND _conan_compilers_list ${_conan_cpp_compiler}) + else() + message(WARNING "CMake-Conan: The C++ compiler is not defined. " + "Please define CMAKE_CXX_COMPILER or enable the C++ language.") + endif() + if(CMAKE_RC_COMPILER) + set(_conan_rc_compiler "\"rc\":\"${CMAKE_RC_COMPILER}\"") + list(APPEND _conan_compilers_list ${_conan_rc_compiler}) + # Not necessary to warn if RC not defined + endif() + if(NOT "x${_conan_compilers_list}" STREQUAL "x") + string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}") + string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n") + endif() + unset(_conan_c_compiler) + unset(_conan_cpp_compiler) + unset(_conan_rc_compiler) + unset(_conan_compilers_list) +endmacro() + + +function(detect_host_profile output_file) + detect_os(os os_api_level os_sdk os_subsystem os_version) + detect_arch(arch) + detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type) + detect_cxx_standard(compiler_cppstd) + detect_lib_cxx(compiler_libcxx) + detect_build_type(build_type) + + set(profile "") + string(APPEND profile "[settings]\n") + if(arch) + string(APPEND profile arch=${arch} "\n") + endif() + if(os) + string(APPEND profile os=${os} "\n") + endif() + if(os_api_level) + string(APPEND profile os.api_level=${os_api_level} "\n") + endif() + if(os_version) + string(APPEND profile os.version=${os_version} "\n") + endif() + if(os_sdk) + string(APPEND profile os.sdk=${os_sdk} "\n") + endif() + if(os_subsystem) + string(APPEND profile os.subsystem=${os_subsystem} "\n") + endif() + if(compiler) + string(APPEND profile compiler=${compiler} "\n") + endif() + if(compiler_version) + string(APPEND profile compiler.version=${compiler_version} "\n") + endif() + if(compiler_runtime) + string(APPEND profile compiler.runtime=${compiler_runtime} "\n") + endif() + if(compiler_runtime_type) + string(APPEND profile compiler.runtime_type=${compiler_runtime_type} "\n") + endif() + if(compiler_cppstd) + string(APPEND profile compiler.cppstd=${compiler_cppstd} "\n") + endif() + if(compiler_libcxx) + string(APPEND profile compiler.libcxx=${compiler_libcxx} "\n") + endif() + if(build_type) + string(APPEND profile "build_type=${build_type}\n") + endif() + + if(NOT DEFINED output_file) + set(file_name "${CMAKE_BINARY_DIR}/profile") + else() + set(file_name ${output_file}) + endif() + + string(APPEND profile "[conf]\n") + string(APPEND profile "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n") + + # propagate compilers via profile + append_compiler_executables_configuration() + + if(os STREQUAL "Android") + string(APPEND profile "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n") + endif() + + message(STATUS "CMake-Conan: Creating profile ${file_name}") + file(WRITE ${file_name} ${profile}) + message(STATUS "CMake-Conan: Profile: \n${profile}") +endfunction() + + +function(conan_profile_detect_default) + message(STATUS "CMake-Conan: Checking if a default profile exists") + execute_process(COMMAND ${CONAN_COMMAND} profile path default + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if(NOT ${return_code} EQUAL "0") + message(STATUS "CMake-Conan: The default profile doesn't exist, detecting it.") + execute_process(COMMAND ${CONAN_COMMAND} profile detect + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() +endfunction() + + +function(conan_install) + cmake_parse_arguments(ARGS conan_args ${ARGN}) + # SILKWORM-PATCH: set(conan_output_folder ${CMAKE_BINARY_DIR}/conan) + # Invoke "conan install" with the provided arguments + # SILKWORM-PATCH: set(conan_args ${conan_args} -of=${conan_output_folder}) + message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN}") + + + # In case there was not a valid cmake executable in the PATH, we inject the + # same we used to invoke the provider to the PATH + if(DEFINED PATH_TO_CMAKE_BIN) + set(old_path $ENV{PATH}) + set(ENV{PATH} "$ENV{PATH}:${PATH_TO_CMAKE_BIN}") + endif() + + execute_process(COMMAND ${CONAN_COMMAND} install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN} --format=json + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(DEFINED PATH_TO_CMAKE_BIN) + set(ENV{PATH} "${old_path}") + endif() + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + + # the files are generated in a folder that depends on the layout used, if + # one is specified, but we don't know a priori where this is. + # TODO: this can be made more robust if Conan can provide this in the json output + string(JSON conan_generators_folder GET "${conan_stdout}" graph nodes 0 generators_folder) + cmake_path(CONVERT ${conan_generators_folder} TO_CMAKE_PATH_LIST conan_generators_folder) + + message(VERBOSE "CMake-Conan: CONAN_GENERATORS_FOLDER=${conan_generators_folder}") + set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${conan_generators_folder}") + # reconfigure on conanfile changes + string(JSON conanfile GET "${conan_stdout}" graph nodes 0 label) + message(VERBOSE "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/${conanfile}") + set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${conanfile}") + # success + set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE) + +endfunction() + + +function(conan_get_version conan_command conan_current_version) + execute_process( + COMMAND ${conan_command} --version + OUTPUT_VARIABLE conan_output + RESULT_VARIABLE conan_result + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(conan_result) + message(FATAL_ERROR "CMake-Conan: Error when trying to run Conan") + endif() + + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" conan_version ${conan_output}) + set(${conan_current_version} ${conan_version} PARENT_SCOPE) +endfunction() + + +function(conan_version_check) + set(options ) + set(one_value_args MINIMUM CURRENT) + set(multi_value_args ) + cmake_parse_arguments(conan_version_check + "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) + + if(NOT conan_version_check_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Required parameter MINIMUM not set!") + endif() + if(NOT conan_version_check_CURRENT) + message(FATAL_ERROR "CMake-Conan: Required parameter CURRENT not set!") + endif() + + if(conan_version_check_CURRENT VERSION_LESS conan_version_check_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Conan version must be ${conan_version_check_MINIMUM} or later") + endif() +endfunction() + + +macro(construct_profile_argument argument_variable profile_list) + set(${argument_variable} "") + if("${profile_list}" STREQUAL "CONAN_HOST_PROFILE") + set(_arg_flag "--profile:host=") + elseif("${profile_list}" STREQUAL "CONAN_BUILD_PROFILE") + set(_arg_flag "--profile:build=") + endif() + + set(_profile_list "${${profile_list}}") + list(TRANSFORM _profile_list REPLACE "auto-cmake" "${CMAKE_BINARY_DIR}/conan_host_profile") + list(TRANSFORM _profile_list PREPEND ${_arg_flag}) + set(${argument_variable} ${_profile_list}) + + unset(_arg_flag) + unset(_profile_list) +endmacro() + + +macro(conan_provide_dependency method package_name) + set_property(GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED TRUE) + get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS) + if(NOT _conan_install_success) + # SILKWORM-PATCH: find_program(CONAN_COMMAND "conan" REQUIRED) + conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION) + conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION}) + message(VERBOSE "CMake-Conan: first find_package() found. Installing dependencies with Conan") + if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE) + conan_profile_detect_default() + endif() + if("auto-cmake" IN_LIST CONAN_HOST_PROFILE) + detect_host_profile(${CMAKE_BINARY_DIR}/conan_host_profile) + endif() + construct_profile_argument(_host_profile_flags CONAN_HOST_PROFILE) + construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE) + if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") + message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile") + endif() + set(generator "") + elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") + message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile. " + "Please define the generator as it will be mandatory in the future") + endif() + set(generator "-g;CMakeDeps") + endif() + get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT _multiconfig_generator) + message(VERBOSE "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}") + conan_install(${_host_profile_flags} ${_build_profile_flags} ${CONAN_INSTALL_ARGS} ${generator}) + else() + message(VERBOSE "CMake-Conan: Installing both Debug and Release") + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator}) + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Debug ${CONAN_INSTALL_ARGS} ${generator}) + endif() + unset(_host_profile_flags) + unset(_build_profile_flags) + unset(_multiconfig_generator) + unset(_conan_install_success) + else() + unset(_conan_install_success) + endif() + + get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER) + + # Ensure that we consider Conan-provided packages ahead of any other, + # irrespective of other settings that modify the search order or search paths + # This follows the guidelines from the find_package documentation + # (https://cmake.org/cmake/help/latest/command/find_package.html): + # find_package ( PATHS paths... NO_DEFAULT_PATH) + # find_package () + + # Filter out `REQUIRED` from the argument list, as the first call may fail + set(_find_args_${package_name} "${ARGN}") + list(REMOVE_ITEM _find_args_${package_name} "REQUIRED") + if(NOT "MODULE" IN_LIST _find_args_${package_name}) + find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER PATHS "${_conan_generators_folder}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + unset(_find_args_${package_name}) + endif() + + # Invoke find_package a second time - if the first call succeeded, + # this will simply reuse the result. If not, fall back to CMake default search + # behaviour, also allowing modules to be searched. + if(NOT ${package_name}_FOUND) + list(FIND CMAKE_MODULE_PATH "${_conan_generators_folder}" _index) + if(_index EQUAL -1) + list(PREPEND CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() + unset(_index) + find_package(${package_name} ${ARGN} BYPASS_PROVIDER) + list(REMOVE_ITEM CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() +endmacro() + + +cmake_language( + SET_DEPENDENCY_PROVIDER conan_provide_dependency + SUPPORTED_METHODS FIND_PACKAGE +) + + +macro(conan_provide_dependency_check) + set(_conan_provide_dependency_invoked FALSE) + get_property(_conan_provide_dependency_invoked GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED) + if(NOT _conan_provide_dependency_invoked) + message(WARNING "Conan is correctly configured as dependency provider, " + "but Conan has not been invoked. Please add at least one " + "call to `find_package()`.") + if(DEFINED CONAN_COMMAND) + # supress warning in case `CONAN_COMMAND` was specified but unused. + set(_conan_command ${CONAN_COMMAND}) + unset(_conan_command) + endif() + endif() + unset(_conan_provide_dependency_invoked) +endmacro() + + +# Add a deferred call at the end of processing the top-level directory +# to check if the dependency provider was invoked at all. +cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependency_check) + +# Configurable variables for Conan profiles +set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile") +set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile") +set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install") + +find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) +if(NOT _cmake_program) + get_filename_component(PATH_TO_CMAKE_BIN "${CMAKE_COMMAND}" DIRECTORY) + set(PATH_TO_CMAKE_BIN "${PATH_TO_CMAKE_BIN}" CACHE INTERNAL "Path where the CMake executable is") +endif() + +cmake_policy(POP) diff --git a/third_party/cmake-conan/readme.txt b/third_party/cmake-conan/readme.txt new file mode 100644 index 0000000000..c5fe46128e --- /dev/null +++ b/third_party/cmake-conan/readme.txt @@ -0,0 +1,3 @@ +https://github.com/conan-io/cmake-conan +branch: develop2 +commit: c22bbf0 diff --git a/third_party/erigon-mdbx-go/CMakeLists.txt b/third_party/erigon-mdbx-go/CMakeLists.txt index d3cc4d9812..044635037e 100644 --- a/third_party/erigon-mdbx-go/CMakeLists.txt +++ b/third_party/erigon-mdbx-go/CMakeLists.txt @@ -15,9 +15,28 @@ ]] set(MDBX_ENABLE_TESTS OFF) + +# reduce the log verbosity of mdbx-go/mdbxdist/CMakeLists.txt +if(NOT CMAKE_MESSAGE_LOG_LEVEL) + set(CMAKE_MESSAGE_LOG_LEVEL_EMPTY YES) + set(CMAKE_MESSAGE_LOG_LEVEL NOTICE) +endif() + add_subdirectory(mdbx-go/mdbxdist) + +# restore the log verbosity +if(CMAKE_MESSAGE_LOG_LEVEL_EMPTY) + unset(CMAKE_MESSAGE_LOG_LEVEL) +endif() + target_compile_definitions(mdbx-static PUBLIC CONSTEXPR_ASSERT=assert) +# mdbx is not compatible with TSAN and added to the suppressions config file let's suppress the related compilation +# warnings +if(SILKWORM_SANITIZE STREQUAL "thread" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_options(mdbx-static PRIVATE -Wno-tsan) +endif() + if(MDBX_BUILD_TOOLS) foreach( TOOL diff --git a/third_party/gmp/CMakeLists.txt b/third_party/gmp/CMakeLists.txt index 4f8196fb0d..7f7c99ef4a 100644 --- a/third_party/gmp/CMakeLists.txt +++ b/third_party/gmp/CMakeLists.txt @@ -14,6 +14,20 @@ limitations under the License. ]] +function(expand_config_gen_expr expr build_type var) + string(REGEX MATCH ":[^>]+" VALUE "${expr}") + string(REPLACE ":" "" VALUE "${VALUE}") + set(${var} + "${VALUE}" + PARENT_SCOPE + ) +endfunction() + +if(GMP_LIBRARY STREQUAL "GMP_LIBRARY-NOTFOUND") + unset(GMP_LIBRARY CACHE) + unset(GMP_INCLUDE_DIR CACHE) +endif() + if(DEFINED GMP_LIBRARY) add_library(gmplib STATIC IMPORTED) set_target_properties(gmplib PROPERTIES IMPORTED_LOCATION "${GMP_LIBRARY}") @@ -24,15 +38,17 @@ if(DEFINED GMP_LIBRARY) endif() else() find_package(gmp REQUIRED) - add_custom_target(gmplib DEPENDS gmp::GMP) + add_custom_target(gmplib DEPENDS gmp::gmp) # derive the path variables from the package for intx, libff - get_target_property(GMP_INCLUDE_DIR gmp::GMP INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(GMP_INCLUDE_DIR_EXPR gmp::libgmp INTERFACE_INCLUDE_DIRECTORIES) + expand_config_gen_expr("${GMP_INCLUDE_DIR_EXPR}" ${CMAKE_BUILD_TYPE} GMP_INCLUDE_DIR) set(GMP_INCLUDE_DIR "${GMP_INCLUDE_DIR}" CACHE PATH "" ) - get_target_property(GMP_LIBRARY_DIR gmp::GMP INTERFACE_LINK_DIRECTORIES) + get_target_property(GMP_LIBRARY_DIR_EXPR gmp::libgmp INTERFACE_LINK_DIRECTORIES) + expand_config_gen_expr("${GMP_LIBRARY_DIR_EXPR}" ${CMAKE_BUILD_TYPE} GMP_LIBRARY_DIR) find_library( GMP_LIBRARY gmp PATHS "${GMP_LIBRARY_DIR}" REQUIRED diff --git a/third_party/libff/CMakeLists.txt b/third_party/libff/CMakeLists.txt index 33519aaace..ee2088e14d 100644 --- a/third_party/libff/CMakeLists.txt +++ b/third_party/libff/CMakeLists.txt @@ -20,4 +20,16 @@ set(CURVE ) option(WITH_PROCPS "" OFF) option(IS_LIBFF_PARENT "" OFF) + +# reduce the log verbosity of libff/CMakeLists.txt +if(NOT CMAKE_MESSAGE_LOG_LEVEL) + set(CMAKE_MESSAGE_LOG_LEVEL_EMPTY YES) + set(CMAKE_MESSAGE_LOG_LEVEL NOTICE) +endif() + add_subdirectory(libff) + +# restore the log verbosity +if(CMAKE_MESSAGE_LOG_LEVEL_EMPTY) + unset(CMAKE_MESSAGE_LOG_LEVEL) +endif() diff --git a/third_party/llvm/README.md b/third_party/llvm/README.md index 295543f26f..9651564720 100644 --- a/third_party/llvm/README.md +++ b/third_party/llvm/README.md @@ -10,4 +10,8 @@ To re-compile, run the following commands: The problem with the standard build delivered by the `compiler_install.sh` is that the libFuzzer is linked against the libstdc++ library. This is not compatible with the libc++ library used by the Silkworm project. Therefore, we need to re-compile the libFuzzer library. To prevent the lengthy recompliation of the whole LLVM project, we deliver the pre-compiled libFuzzer library in this repository. -The similar issue has been in https://github.com/google/oss-fuzz/issues/2328. \ No newline at end of file +The similar issue has been in https://github.com/google/oss-fuzz/issues/2328. + +Update llvm.sh using: + + curl -O https://apt.llvm.org/llvm.sh