diff --git a/CMakeLists.txt b/CMakeLists.txt index a88aabe9ee..f15c6800b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,10 @@ include(WholeArchive) include(MiNiFiOptions) +message("Checking MiNiFi Options Updated by conanfile.py") +message("USE_CONAN_PACKAGER = ${USE_CONAN_PACKAGER}") +message("USE_CMAKE_FETCH_CONTENT = ${USE_CMAKE_FETCH_CONTENT}") + include(DockerConfig) if (DOCKER_BUILD_ONLY) return() @@ -221,6 +225,7 @@ else() message(VERBOSE "No custom malloc implementation") endif() +# rocksdb needed for minifi C++ GTESTs if (ENABLE_BZIP2 AND (ENABLE_LIBARCHIVE OR (ENABLE_ROCKSDB AND NOT WIN32))) include(BundledBZip2) use_bundled_bzip2(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) @@ -230,6 +235,16 @@ endif() if(NOT WIN32) if (ENABLE_JNI) list(APPEND MINIFI_CPP_COMPILE_DEFINITIONS ENABLE_JNI) + # NOTE (JG): Mainly leverage conan to install the prebuilt Java OpenJDK and create custom Maven conan package for + # minifi exposing Maven Executable environment variable, so we can leverage conan to build Apache NiFi JNI Assembly + # and Framework without having to rely on user having Java & Maven installed on their system. Kept backward + # compatibility using find_package for Java and Maven + include(JavaOpenJDK) + include(JavaMaven) + use_javamaven(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) + + include(CheckJavaMaven) + check_javamaven_version() endif() endif() @@ -252,17 +267,18 @@ if (MINIFI_OPENSSL) list(APPEND MINIFI_CPP_COMPILE_DEFINITIONS OPENSSL_SUPPORT) endif() -# libsodium +# libsodium (libminifi C++ core) include(BundledLibSodium) use_bundled_libsodium("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") list(APPEND MINIFI_CPP_COMPILE_DEFINITIONS SODIUM_STATIC=1) -# zlib +# zlib (libminifi C++ core) include(BundledZLIB) use_bundled_zlib(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/zlib/dummy") +# TODO (JG): Add uthash.cmake with condition to use conan package # uthash add_library(ut INTERFACE) target_include_directories(ut SYSTEM INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/ut") @@ -275,18 +291,20 @@ if(ENABLE_CURL) list(APPEND MINIFI_CPP_COMPILE_DEFINITIONS ENABLE_CURL) endif() -# spdlog +# spdlog (libminifi C++ core) include(Spdlog) -# yaml-cpp +# yaml-cpp (libminifi C++ core) include(BundledYamlCpp) use_bundled_yamlcpp(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -# concurrentqueue +# TODO (JG): Add concurrentqueue.cmake with condition to use conan package +# concurrentqueue (libminifi C++ core) add_library(concurrentqueue INTERFACE) target_include_directories(concurrentqueue SYSTEM INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/concurrentqueue") -# RapidJSON +# TODO (JG): Add RapidJSON.cmake with condition to use conan package +# RapidJSON (libminifi C++ core) add_library(RapidJSON INTERFACE) target_include_directories(RapidJSON SYSTEM INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/rapidjson-48fbd8cd202ca54031fe799db2ad44ffa8e77c13/include") target_compile_definitions(RapidJSON INTERFACE RAPIDJSON_HAS_STDSTRING) @@ -294,30 +312,16 @@ target_compile_definitions(RapidJSON INTERFACE RAPIDJSON_HAS_STDSTRING) include(Coroutines) enable_coroutines() -# gsl-lite +# gsl-lite (libminifi C++ core) include(GslLite) -# Add necessary definitions based on the value of STRICT_GSL_CHECKS, see gsl-lite README for more details -list(APPEND GslDefinitions gsl_CONFIG_DEFAULTS_VERSION=1) -list(APPEND GslDefinitionsNonStrict gsl_CONFIG_CONTRACT_VIOLATION_THROWS gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION=1) -if (STRICT_GSL_CHECKS STREQUAL "AUDIT") - list(APPEND GslDefinitions gsl_CONFIG_CONTRACT_CHECKING_AUDIT) -endif() -if (NOT STRICT_GSL_CHECKS) # OFF (or any other falsey string) matches, AUDIT/ON/DEBUG_ONLY don't match - list(APPEND GslDefinitions ${GslDefinitionsNonStrict}) -endif() -if (STRICT_GSL_CHECKS STREQUAL "DEBUG_ONLY") - list(APPEND GslDefinitions $<$>:${GslDefinitionsNonStrict}>) -endif() -target_compile_definitions(gsl-lite INTERFACE ${GslDefinitions}) - -# date +# date (libminifi C++ core) include(Date) -# expected-lite +# expected-lite (libminifi C++ core) include(ExpectedLite) -# magic_enum +# magic_enum (libminifi C++ core) include(MagicEnum) # Setup warning flags @@ -356,12 +360,15 @@ include(Extensions) add_subdirectory(libminifi) if ((ENABLE_OPENWSMAN AND ENABLE_CIVET AND ENABLE_CURL) OR ENABLE_ALL OR ENABLE_AZURE) + message("Enabled OpenWSMAN, Civet, and Curl for MiNiFi C++ Core") + message("Including BundledLibXml2") include(BundledLibXml2) use_bundled_libxml2(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/libxml2/dummy") endif() if (ENABLE_ALL OR ENABLE_PROMETHEUS OR ENABLE_CIVET) + message("Including CivetWeb") include(CivetWeb) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/civetweb/dummy") endif() @@ -629,28 +636,131 @@ if(NOT WIN32) cpack_add_component(conf DISPLAY_NAME "Default configuration files" REQUIRED) endif() +# Speed up MiNIFi C++ builds by just having standard processors being included by default +message("Adding minifi-standard-processors to EXTENSIONS_ENABLED_BY_DEFAULT list") cpack_add_component_group(extensions DISPLAY_NAME "Extensions" EXPANDED) -set(EXTENSIONS_ENABLED_BY_DEFAULT ( - minifi-aws - minifi-azure - minifi-civet-extensions - minifi-elasticsearch - minifi-expression-language-extensions - minifi-gcp - minifi-grafana-loki - minifi-http-curl - minifi-archive-extensions - minifi-mqtt-extensions - minifi-rdkafka-extensions - minifi-pdh - minifi-prometheus - minifi-rocksdb-repos - minifi-smb - minifi-splunk - minifi-sql +set(EXTENSIONS_ENABLED_BY_DEFAULT minifi-standard-processors - minifi-wel -)) +) + +# Only append the remaining extensions that are enabled, so they dont take up time in the build +message("Checking for enabled extensions to append to EXTENSIONS_ENABLED_BY_DEFAULT list") +if(ENABLE_AWS) + message("AWS Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-aws) +endif() + +if(ENABLE_AZURE) + message("Azure Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-azure) +endif() + +if(ENABLE_CIVET) + message("Civet Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-civet-extensions) +endif() + +if(ENABLE_ELASTICSEARCH) + message("Elasticsearch Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-elasticsearch) +endif() + +if(ENABLE_EXPRESSION_LANGUAGE) + message("Expression Language Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-expression-language-extensions) +endif() + +if(ENABLE_GCP) + message("GCP Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-gcp) +endif() + +if(ENABLE_GRAFANA_LOKI) + message("Grafana Loki Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-grafana-loki) +endif() + +if(ENABLE_HTTP_CURL) + message("HTTP CURL Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-http-curl) +endif() + +if(ENABLE_LIBARCHIVE) + message("Libarchive Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-archive-extensions) +endif() + +if(ENABLE_MQTT) + message("MQTT Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-mqtt-extensions) +endif() + +if(ENABLE_LIBRDKAFKA) + message("RDKafka Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-rdkafka-extensions) +endif() + +if(ENABLE_PDH) + message("PDH Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-pdh) +endif() + +if(ENABLE_PROMETHEUS) + message("Prometheus Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-prometheus) +endif() + +if(ENABLE_ROCKSDB) + message("RocksDB Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-rocksdb-repos) +endif() + +if(ENABLE_SMB) + message("SMB Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-smb) +endif() + +if(ENABLE_SPLUNK) + message("Splunk Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-splunk) +endif() + +if(ENABLE_SQL) + message("SQL Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-sql) +endif() + +if(ENABLE_WEL) + message("WEL Enabled appending to EXTENSIONS_ENABLED_BY_DEFAULT") + list(APPEND EXTENSIONS_ENABLED_BY_DEFAULT minifi-wel) +endif() + + +# TODO (JG): Planning to replace below with the above conditional approach, so we save time on building +# MiNiFi C++ Core library and Main binary executable and whats needed for building minifi-standard-processors +# like external libraries Openwsman, Openssl, Civet, Curl and their appropriate extensions. +# cpack_add_component_group(extensions DISPLAY_NAME "Extensions" EXPANDED) +# set(EXTENSIONS_ENABLED_BY_DEFAULT ( +# # minifi-aws +# # minifi-azure +# # minifi-civet-extensions +# # minifi-elasticsearch +# # minifi-expression-language-extensions +# # minifi-gcp +# # minifi-grafana-loki +# # minifi-http-curl +# # minifi-archive-extensions +# # minifi-mqtt-extensions +# # minifi-rdkafka-extensions +# # minifi-pdh +# # minifi-prometheus +# # minifi-rocksdb-repos +# # minifi-smb +# # minifi-splunk +# # minifi-sql +# minifi-standard-processors +# # minifi-wel +# )) foreach(extension ${selected_extensions}) get_component_name(${extension} component-name) list(APPEND CPACK_COMPONENTS_ALL ${component-name}) diff --git a/cmake/Abseil.cmake b/cmake/Abseil.cmake index 9872b41b94..4e739ba7f4 100644 --- a/cmake/Abseil.cmake +++ b/cmake/Abseil.cmake @@ -16,20 +16,32 @@ # specific language governing permissions and limitations # under the License. # -include(FetchContent) -set(ABSL_PROPAGATE_CXX_STD ON CACHE INTERNAL absl-propagate-cxx) -set(ABSL_ENABLE_INSTALL ON CACHE INTERNAL "") -set(BUILD_TESTING OFF CACHE STRING "" FORCE) +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Abseil external lib") + include(${CMAKE_BINARY_DIR}/absl-config.cmake) + set(ABSL_INCLUDE_DIRS "${absl_INCLUDE_DIRS}" CACHE STRING "" FORCE) -set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/abseil/rename-crc32.patch") -set(PC ${Bash_EXECUTABLE} -c "set -x &&\ - (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")") +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building Abseil external lib") + include(FetchContent) + set(ABSL_PROPAGATE_CXX_STD ON CACHE INTERNAL absl-propagate-cxx) + set(ABSL_ENABLE_INSTALL ON CACHE INTERNAL "") + set(BUILD_TESTING OFF CACHE STRING "" FORCE) -FetchContent_Declare( - absl - URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.tar.gz - URL_HASH SHA256=59d2976af9d6ecf001a81a35749a6e551a335b949d34918cfade07737b9d93c5 - PATCH_COMMAND "${PC}" - OVERRIDE_FIND_PACKAGE -) -FetchContent_MakeAvailable(absl) + set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/abseil/rename-crc32.patch") + set(PC ${Bash_EXECUTABLE} -c "set -x &&\ + (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")") + + FetchContent_Declare( + absl + URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.tar.gz + URL_HASH SHA256=59d2976af9d6ecf001a81a35749a6e551a335b949d34918cfade07737b9d93c5 + PATCH_COMMAND "${PC}" + OVERRIDE_FIND_PACKAGE + ) + FetchContent_MakeAvailable(absl) + + add_library(abseil::abseil INTERFACE IMPORTED) + set(ABSL_INCLUDE_DIRS "${absl_SOURCE_DIR}/absl" CACHE STRING "" FORCE) + target_include_directories(abseil::abseil SYSTEM INTERFACE ${ABSL_INCLUDE_DIRS}) +endif() \ No newline at end of file diff --git a/cmake/ArgParse.cmake b/cmake/ArgParse.cmake index 29251ceb9f..8ec0d07681 100644 --- a/cmake/ArgParse.cmake +++ b/cmake/ArgParse.cmake @@ -14,11 +14,17 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. - -include(FetchContent) -FetchContent_Declare( - argparse - URL https://github.com/p-ranav/argparse/archive/refs/tags/v3.0.tar.gz - URL_HASH SHA256=ba7b465759bb01069d57302855eaf4d1f7d677f21ad7b0b00b92939645c30f47 -) -FetchContent_MakeAvailable(argparse) +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt ArgParse external lib") + include(${CMAKE_BINARY_DIR}/argparse-config.cmake) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building ArgParse external lib") + + include(FetchContent) + FetchContent_Declare( + argparse + URL https://github.com/p-ranav/argparse/archive/refs/tags/v3.0.tar.gz + URL_HASH SHA256=ba7b465759bb01069d57302855eaf4d1f7d677f21ad7b0b00b92939645c30f47 + ) + FetchContent_MakeAvailable(argparse) +endif() diff --git a/cmake/Asio.cmake b/cmake/Asio.cmake index 28f4bb928a..697c8ace39 100644 --- a/cmake/Asio.cmake +++ b/cmake/Asio.cmake @@ -14,18 +14,24 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +# under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Asio external lib") + include(${CMAKE_BINARY_DIR}/asio-config.cmake) +elseif(USE_CMAKE_FETCH_CONTENT) + include(FetchContent) + message("Using CMAKE's FetchContent to manage source building Asio external lib") + FetchContent_Declare(asio + URL https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-28-1.tar.gz + URL_HASH SHA256=5ff6111ec8cbe73a168d997c547f562713aa7bd004c5c02326f0e9d579a5f2ce) -include(FetchContent) - -FetchContent_Declare(asio - URL https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-28-1.tar.gz - URL_HASH SHA256=5ff6111ec8cbe73a168d997c547f562713aa7bd004c5c02326f0e9d579a5f2ce) - -FetchContent_GetProperties(asio) -if(NOT asio_POPULATED) - FetchContent_Populate(asio) - add_library(asio INTERFACE) - target_include_directories(asio SYSTEM INTERFACE ${asio_SOURCE_DIR}/asio/include) - find_package(Threads) - target_link_libraries(asio INTERFACE Threads::Threads) + FetchContent_GetProperties(asio) + if(NOT asio_POPULATED) + FetchContent_Populate(asio) + add_library(asio INTERFACE) + add_library(asio::asio ALIAS asio) + target_include_directories(asio SYSTEM INTERFACE ${asio_SOURCE_DIR}/asio/include) + find_package(Threads) + target_link_libraries(asio INTERFACE Threads::Threads) + endif() endif() diff --git a/cmake/BuildTests.cmake b/cmake/BuildTests.cmake index d299d67fbb..eb5cffe610 100644 --- a/cmake/BuildTests.cmake +++ b/cmake/BuildTests.cmake @@ -78,7 +78,7 @@ function(createTests testName) target_link_libraries(${testName} ${CMAKE_DL_LIBS}) target_wholearchive_library(${testName} ${TEST_BASE_LIB}) - target_link_libraries(${testName} core-minifi yaml-cpp spdlog Threads::Threads) + target_link_libraries(${testName} core-minifi yaml-cpp::yaml-cpp spdlog Threads::Threads Catch2::Catch2WithMain) target_compile_definitions(${testName} PRIVATE LOAD_EXTENSIONS) set_target_properties(${testName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") endfunction() @@ -89,7 +89,7 @@ SET(TEST_BASE_LIB test_base) set(TEST_BASE_SOURCES "TestBase.cpp" "StatefulProcessor.cpp" "WriteToFlowFileTestProcessor.cpp" "ReadFromFlowFileTestProcessor.cpp" "DummyProcessor.cpp") list(TRANSFORM TEST_BASE_SOURCES PREPEND "${TEST_DIR}/") add_minifi_library(${TEST_BASE_LIB} STATIC ${TEST_BASE_SOURCES}) -target_link_libraries(${TEST_BASE_LIB} core-minifi) +target_link_libraries(${TEST_BASE_LIB} core-minifi Catch2::Catch2WithMain) target_include_directories(${TEST_BASE_LIB} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include/") if(WIN32) target_include_directories(${TEST_BASE_LIB} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/opsys/win") @@ -115,7 +115,7 @@ FOREACH(testfile ${UNIT_TESTS}) add_minifi_executable("${testfilename}" "${TEST_DIR}/unit/${testfile}") target_compile_definitions("${testfilename}" PRIVATE TZ_DATA_DIR="${CMAKE_BINARY_DIR}/tzdata") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) MATH(EXPR UNIT_TEST_COUNT "${UNIT_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}") ENDFOREACH() @@ -143,7 +143,7 @@ if(NOT WIN32 AND ENABLE_NANOFI) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors/") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") appendIncludes("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain Threads::Threads) + target_link_libraries(${testfilename} Catch2::Catch2WithMain Threads::Threads) target_wholearchive_library(${testfilename} nanofi) @@ -165,7 +165,7 @@ FOREACH(testfile ${INTEGRATION_TESTS}) MATH(EXPR INT_TEST_COUNT "${INT_TEST_COUNT}+1") ENDFOREACH() -target_link_libraries(OnScheduleErrorHandlingTests minifi-test-processors) +target_link_libraries(OnScheduleErrorHandlingTests minifi-test-processors Catch2::Catch2WithMain) target_wholearchive_library(StateTransactionalityTests minifi-standard-processors) add_test(NAME OnScheduleErrorHandlingTests COMMAND OnScheduleErrorHandlingTests "${TEST_RESOURCES}/TestOnScheduleRetry.yml" "${TEST_RESOURCES}/") diff --git a/cmake/BundledAwsSdkCpp.cmake b/cmake/BundledAwsSdkCpp.cmake index 74c90bf6a8..cd38b820c3 100644 --- a/cmake/BundledAwsSdkCpp.cmake +++ b/cmake/BundledAwsSdkCpp.cmake @@ -16,193 +16,202 @@ # under the License. function(use_bundled_libaws SOURCE_DIR BINARY_DIR) - set(PATCH_FILE1 "${SOURCE_DIR}/thirdparty/aws-sdk-cpp/dll-export-injection.patch") - set(PATCH_FILE2 "${SOURCE_DIR}/thirdparty/aws-sdk-cpp/shutdown-fix.patch") - set(PATCH_FILE3 "${SOURCE_DIR}/thirdparty/aws-sdk-cpp/bundle-openssl.patch") - set(AWS_SDK_CPP_PATCH_COMMAND ${Bash_EXECUTABLE} -c "set -x &&\ - (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE1}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE1}\") &&\ - (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE2}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE2}\") &&\ - (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE3}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE3}\") ") - - if (WIN32) - set(LIBDIR "lib") - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt aws-sdk-cpp external lib") + include(${CMAKE_BINARY_DIR}/AWSSDKConfig.cmake) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building aws-sdk-cpp external lib") + + + set(PATCH_FILE1 "${SOURCE_DIR}/thirdparty/aws-sdk-cpp/dll-export-injection.patch") + set(PATCH_FILE2 "${SOURCE_DIR}/thirdparty/aws-sdk-cpp/shutdown-fix.patch") + set(PATCH_FILE3 "${SOURCE_DIR}/thirdparty/aws-sdk-cpp/bundle-openssl.patch") + set(AWS_SDK_CPP_PATCH_COMMAND ${Bash_EXECUTABLE} -c "set -x &&\ + (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE1}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE1}\") &&\ + (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE2}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE2}\") &&\ + (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE3}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE3}\") ") + + if (WIN32) + set(LIBDIR "lib") + else() + include(GNUInstallDirs) + string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) + list(GET LIBDIR_LIST 0 LIBDIR) + endif() + + # Define byproducts + if (WIN32) + set(SUFFIX "lib") + set(PREFIX "") + else() + set(SUFFIX "a") + set(PREFIX "lib") + endif() + + if (NOT WIN32 AND NOT APPLE) + list(APPEND BYPRODUCTS "${LIBDIR}/${PREFIX}s2n.${SUFFIX}") + endif() + list(APPEND BYPRODUCTS + "${LIBDIR}/${PREFIX}aws-checksums.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-event-stream.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-s3.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-crt-cpp.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-common.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-mqtt.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-io.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-http.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-auth.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-cal.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-compression.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-c-sdkutils.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-cpp-sdk-core.${SUFFIX}" + "${LIBDIR}/${PREFIX}aws-cpp-sdk-s3.${SUFFIX}") + + FOREACH(BYPRODUCT ${BYPRODUCTS}) + LIST(APPEND AWSSDK_LIBRARIES_LIST "${BINARY_DIR}/thirdparty/libaws-install/${BYPRODUCT}") + ENDFOREACH(BYPRODUCT) + + set(AWS_SDK_CPP_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + -DCMAKE_PREFIX_PATH=${BINARY_DIR}/thirdparty/libaws-install + -DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libaws-install + -DBUILD_ONLY=s3 + -DENABLE_TESTING=OFF + -DBUILD_SHARED_LIBS=OFF + -DENABLE_UNITY_BUILD=${AWS_ENABLE_UNITY_BUILD}) + + if(WIN32) + list(APPEND AWS_SDK_CPP_CMAKE_ARGS -DFORCE_EXPORT_CORE_API=ON -DFORCE_EXPORT_S3_API=ON) + endif() + + append_third_party_passthrough_args(AWS_SDK_CPP_CMAKE_ARGS "${AWS_SDK_CPP_CMAKE_ARGS}") + + ExternalProject_Add( + aws-sdk-cpp-external + GIT_REPOSITORY "https://github.com/aws/aws-sdk-cpp.git" + GIT_TAG "1.11.219" + UPDATE_COMMAND git submodule update --init --recursive + SOURCE_DIR "${BINARY_DIR}/thirdparty/aws-sdk-cpp-src" + INSTALL_DIR "${BINARY_DIR}/thirdparty/libaws-install" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${AWS_SDK_CPP_CMAKE_ARGS} + PATCH_COMMAND ${AWS_SDK_CPP_PATCH_COMMAND} + BUILD_BYPRODUCTS "${AWSSDK_LIBRARIES_LIST}" + EXCLUDE_FROM_ALL TRUE + ) + + # Set dependencies + add_dependencies(aws-sdk-cpp-external OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB) + if (NOT WIN32) + add_dependencies(aws-sdk-cpp-external CURL::libcurl) + endif() + + # Set variables + set(LIBAWS_FOUND "YES" CACHE STRING "" FORCE) + set(LIBAWS_INCLUDE_DIR "${BINARY_DIR}/thirdparty/libaws-install/include" CACHE STRING "" FORCE) + set(LIBAWS_LIBRARIES + ${AWSSDK_LIBRARIES_LIST} + CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-c-common STATIC IMPORTED) + set_target_properties(AWS::aws-c-common PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-common.${SUFFIX}") + add_dependencies(AWS::aws-c-common aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-common INTERFACE ${LIBAWS_INCLUDE_DIR}) + + if (NOT WIN32 AND NOT APPLE) + add_library(AWS::s2n STATIC IMPORTED) + set_target_properties(AWS::s2n PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}s2n.${SUFFIX}") + add_dependencies(AWS::s2n aws-sdk-cpp-external) + target_include_directories(AWS::s2n INTERFACE ${LIBAWS_INCLUDE_DIR}) + target_link_libraries(AWS::s2n INTERFACE OpenSSL::Crypto) + endif() + + add_library(AWS::aws-c-io STATIC IMPORTED) + set_target_properties(AWS::aws-c-io PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-io.${SUFFIX}") + add_dependencies(AWS::aws-c-io aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-io INTERFACE ${LIBAWS_INCLUDE_DIR}) + target_link_libraries(AWS::aws-c-io INTERFACE AWS::aws-c-common) + if (WIN32) + target_link_libraries(AWS::aws-c-io INTERFACE ncrypt.lib) + endif() + + add_library(AWS::aws-checksums STATIC IMPORTED) + set_target_properties(AWS::aws-checksums PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-checksums.${SUFFIX}") + add_dependencies(AWS::aws-checksums aws-sdk-cpp-external) + target_include_directories(AWS::aws-checksums INTERFACE ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-c-event-stream STATIC IMPORTED) + set_target_properties(AWS::aws-c-event-stream PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-event-stream.${SUFFIX}") + add_dependencies(AWS::aws-c-event-stream aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-event-stream INTERFACE ${LIBAWS_INCLUDE_DIR}) + target_link_libraries(AWS::aws-c-event-stream INTERFACE AWS::aws-checksums AWS::aws-c-io) + + add_library(AWS::aws-c-auth STATIC IMPORTED) + set_target_properties(AWS::aws-c-auth PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-auth.${SUFFIX}") + add_dependencies(AWS::aws-c-auth aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-auth INTERFACE ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-c-s3 STATIC IMPORTED) + set_target_properties(AWS::aws-c-s3 PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-s3.${SUFFIX}") + add_dependencies(AWS::aws-c-s3 aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-s3 INTERFACE ${LIBAWS_INCLUDE_DIR}) + target_link_libraries(AWS::aws-c-s3 INTERFACE AWS::aws-c-auth) + + add_library(AWS::aws-c-mqtt STATIC IMPORTED) + set_target_properties(AWS::aws-c-mqtt PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-mqtt.${SUFFIX}") + add_dependencies(AWS::aws-c-mqtt aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-mqtt INTERFACE ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-c-http STATIC IMPORTED) + set_target_properties(AWS::aws-c-http PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-http.${SUFFIX}") + add_dependencies(AWS::aws-c-http aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-http INTERFACE ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-c-cal STATIC IMPORTED) + set_target_properties(AWS::aws-c-cal PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-cal.${SUFFIX}") + add_dependencies(AWS::aws-c-cal aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-cal INTERFACE ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-c-compression STATIC IMPORTED) + set_target_properties(AWS::aws-c-compression PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-compression.${SUFFIX}") + add_dependencies(AWS::aws-c-compression aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-compression INTERFACE ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-c-sdkutils STATIC IMPORTED) + set_target_properties(AWS::aws-c-sdkutils PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-sdkutils.${SUFFIX}") + add_dependencies(AWS::aws-c-sdkutils aws-sdk-cpp-external) + target_include_directories(AWS::aws-c-sdkutils INTERFACE ${LIBAWS_INCLUDE_DIR}) + + add_library(AWS::aws-crt-cpp STATIC IMPORTED) + set_target_properties(AWS::aws-crt-cpp PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-crt-cpp.${SUFFIX}") + add_dependencies(AWS::aws-crt-cpp aws-sdk-cpp-external) + target_include_directories(AWS::aws-crt-cpp INTERFACE ${LIBAWS_INCLUDE_DIR}) + target_link_libraries(AWS::aws-crt-cpp INTERFACE AWS::aws-c-io AWS::aws-c-s3 AWS::aws-c-mqtt AWS::aws-c-http AWS::aws-c-cal AWS::aws-c-compression AWS::aws-c-sdkutils) + + add_library(AWS::aws-cpp-sdk-core STATIC IMPORTED) + set_target_properties(AWS::aws-cpp-sdk-core PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-cpp-sdk-core.${SUFFIX}") + add_dependencies(AWS::aws-cpp-sdk-core aws-sdk-cpp-external) + target_include_directories(AWS::aws-cpp-sdk-core INTERFACE ${LIBAWS_INCLUDE_DIR}) + target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE AWS::aws-crt-cpp AWS::aws-c-event-stream OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB Threads::Threads) + if (NOT WIN32) + target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE CURL::libcurl) + endif() + + if (APPLE) + target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE "-framework CoreFoundation -framework Security") + elseif (WIN32) + target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE userenv.lib ws2_32.lib Wininet.lib winhttp.lib bcrypt.lib version.lib Secur32 Crypt32 Shlwapi) + else() + target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE AWS::s2n) + endif() + + add_library(AWS::aws-cpp-sdk-s3 STATIC IMPORTED) + set_target_properties(AWS::aws-cpp-sdk-s3 PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-cpp-sdk-s3.${SUFFIX}") + add_dependencies(AWS::aws-cpp-sdk-s3 aws-sdk-cpp-external) + target_include_directories(AWS::aws-cpp-sdk-s3 INTERFACE ${LIBAWS_INCLUDE_DIR}) + target_link_libraries(AWS::aws-cpp-sdk-s3 INTERFACE AWS::aws-cpp-sdk-core) endif() - - # Define byproducts - if (WIN32) - set(SUFFIX "lib") - set(PREFIX "") - else() - set(SUFFIX "a") - set(PREFIX "lib") - endif() - - if (NOT WIN32 AND NOT APPLE) - list(APPEND BYPRODUCTS "${LIBDIR}/${PREFIX}s2n.${SUFFIX}") - endif() - list(APPEND BYPRODUCTS - "${LIBDIR}/${PREFIX}aws-checksums.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-event-stream.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-s3.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-crt-cpp.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-common.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-mqtt.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-io.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-http.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-auth.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-cal.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-compression.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-c-sdkutils.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-cpp-sdk-core.${SUFFIX}" - "${LIBDIR}/${PREFIX}aws-cpp-sdk-s3.${SUFFIX}") - - FOREACH(BYPRODUCT ${BYPRODUCTS}) - LIST(APPEND AWSSDK_LIBRARIES_LIST "${BINARY_DIR}/thirdparty/libaws-install/${BYPRODUCT}") - ENDFOREACH(BYPRODUCT) - - set(AWS_SDK_CPP_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - -DCMAKE_PREFIX_PATH=${BINARY_DIR}/thirdparty/libaws-install - -DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libaws-install - -DBUILD_ONLY=s3 - -DENABLE_TESTING=OFF - -DBUILD_SHARED_LIBS=OFF - -DENABLE_UNITY_BUILD=${AWS_ENABLE_UNITY_BUILD}) - - if(WIN32) - list(APPEND AWS_SDK_CPP_CMAKE_ARGS -DFORCE_EXPORT_CORE_API=ON -DFORCE_EXPORT_S3_API=ON) - endif() - - append_third_party_passthrough_args(AWS_SDK_CPP_CMAKE_ARGS "${AWS_SDK_CPP_CMAKE_ARGS}") - - ExternalProject_Add( - aws-sdk-cpp-external - GIT_REPOSITORY "https://github.com/aws/aws-sdk-cpp.git" - GIT_TAG "1.11.219" - UPDATE_COMMAND git submodule update --init --recursive - SOURCE_DIR "${BINARY_DIR}/thirdparty/aws-sdk-cpp-src" - INSTALL_DIR "${BINARY_DIR}/thirdparty/libaws-install" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${AWS_SDK_CPP_CMAKE_ARGS} - PATCH_COMMAND ${AWS_SDK_CPP_PATCH_COMMAND} - BUILD_BYPRODUCTS "${AWSSDK_LIBRARIES_LIST}" - EXCLUDE_FROM_ALL TRUE - ) - - # Set dependencies - add_dependencies(aws-sdk-cpp-external OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB) - if (NOT WIN32) - add_dependencies(aws-sdk-cpp-external CURL::libcurl) - endif() - - # Set variables - set(LIBAWS_FOUND "YES" CACHE STRING "" FORCE) - set(LIBAWS_INCLUDE_DIR "${BINARY_DIR}/thirdparty/libaws-install/include" CACHE STRING "" FORCE) - set(LIBAWS_LIBRARIES - ${AWSSDK_LIBRARIES_LIST} - CACHE STRING "" FORCE) - - # Create imported targets - file(MAKE_DIRECTORY ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-c-common STATIC IMPORTED) - set_target_properties(AWS::aws-c-common PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-common.${SUFFIX}") - add_dependencies(AWS::aws-c-common aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-common INTERFACE ${LIBAWS_INCLUDE_DIR}) - - if (NOT WIN32 AND NOT APPLE) - add_library(AWS::s2n STATIC IMPORTED) - set_target_properties(AWS::s2n PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}s2n.${SUFFIX}") - add_dependencies(AWS::s2n aws-sdk-cpp-external) - target_include_directories(AWS::s2n INTERFACE ${LIBAWS_INCLUDE_DIR}) - target_link_libraries(AWS::s2n INTERFACE OpenSSL::Crypto) - endif() - - add_library(AWS::aws-c-io STATIC IMPORTED) - set_target_properties(AWS::aws-c-io PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-io.${SUFFIX}") - add_dependencies(AWS::aws-c-io aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-io INTERFACE ${LIBAWS_INCLUDE_DIR}) - target_link_libraries(AWS::aws-c-io INTERFACE AWS::aws-c-common) - if (WIN32) - target_link_libraries(AWS::aws-c-io INTERFACE ncrypt.lib) - endif() - - add_library(AWS::aws-checksums STATIC IMPORTED) - set_target_properties(AWS::aws-checksums PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-checksums.${SUFFIX}") - add_dependencies(AWS::aws-checksums aws-sdk-cpp-external) - target_include_directories(AWS::aws-checksums INTERFACE ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-c-event-stream STATIC IMPORTED) - set_target_properties(AWS::aws-c-event-stream PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-event-stream.${SUFFIX}") - add_dependencies(AWS::aws-c-event-stream aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-event-stream INTERFACE ${LIBAWS_INCLUDE_DIR}) - target_link_libraries(AWS::aws-c-event-stream INTERFACE AWS::aws-checksums AWS::aws-c-io) - - add_library(AWS::aws-c-auth STATIC IMPORTED) - set_target_properties(AWS::aws-c-auth PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-auth.${SUFFIX}") - add_dependencies(AWS::aws-c-auth aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-auth INTERFACE ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-c-s3 STATIC IMPORTED) - set_target_properties(AWS::aws-c-s3 PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-s3.${SUFFIX}") - add_dependencies(AWS::aws-c-s3 aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-s3 INTERFACE ${LIBAWS_INCLUDE_DIR}) - target_link_libraries(AWS::aws-c-s3 INTERFACE AWS::aws-c-auth) - - add_library(AWS::aws-c-mqtt STATIC IMPORTED) - set_target_properties(AWS::aws-c-mqtt PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-mqtt.${SUFFIX}") - add_dependencies(AWS::aws-c-mqtt aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-mqtt INTERFACE ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-c-http STATIC IMPORTED) - set_target_properties(AWS::aws-c-http PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-http.${SUFFIX}") - add_dependencies(AWS::aws-c-http aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-http INTERFACE ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-c-cal STATIC IMPORTED) - set_target_properties(AWS::aws-c-cal PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-cal.${SUFFIX}") - add_dependencies(AWS::aws-c-cal aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-cal INTERFACE ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-c-compression STATIC IMPORTED) - set_target_properties(AWS::aws-c-compression PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-compression.${SUFFIX}") - add_dependencies(AWS::aws-c-compression aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-compression INTERFACE ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-c-sdkutils STATIC IMPORTED) - set_target_properties(AWS::aws-c-sdkutils PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-c-sdkutils.${SUFFIX}") - add_dependencies(AWS::aws-c-sdkutils aws-sdk-cpp-external) - target_include_directories(AWS::aws-c-sdkutils INTERFACE ${LIBAWS_INCLUDE_DIR}) - - add_library(AWS::aws-crt-cpp STATIC IMPORTED) - set_target_properties(AWS::aws-crt-cpp PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-crt-cpp.${SUFFIX}") - add_dependencies(AWS::aws-crt-cpp aws-sdk-cpp-external) - target_include_directories(AWS::aws-crt-cpp INTERFACE ${LIBAWS_INCLUDE_DIR}) - target_link_libraries(AWS::aws-crt-cpp INTERFACE AWS::aws-c-io AWS::aws-c-s3 AWS::aws-c-mqtt AWS::aws-c-http AWS::aws-c-cal AWS::aws-c-compression AWS::aws-c-sdkutils) - - add_library(AWS::aws-cpp-sdk-core STATIC IMPORTED) - set_target_properties(AWS::aws-cpp-sdk-core PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-cpp-sdk-core.${SUFFIX}") - add_dependencies(AWS::aws-cpp-sdk-core aws-sdk-cpp-external) - target_include_directories(AWS::aws-cpp-sdk-core INTERFACE ${LIBAWS_INCLUDE_DIR}) - target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE AWS::aws-crt-cpp AWS::aws-c-event-stream OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB Threads::Threads) - if (NOT WIN32) - target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE CURL::libcurl) - endif() - - if (APPLE) - target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE "-framework CoreFoundation -framework Security") - elseif (WIN32) - target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE userenv.lib ws2_32.lib Wininet.lib winhttp.lib bcrypt.lib version.lib Secur32 Crypt32 Shlwapi) - else() - target_link_libraries(AWS::aws-cpp-sdk-core INTERFACE AWS::s2n) - endif() - - add_library(AWS::aws-cpp-sdk-s3 STATIC IMPORTED) - set_target_properties(AWS::aws-cpp-sdk-s3 PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/libaws-install/${LIBDIR}/${PREFIX}aws-cpp-sdk-s3.${SUFFIX}") - add_dependencies(AWS::aws-cpp-sdk-s3 aws-sdk-cpp-external) - target_include_directories(AWS::aws-cpp-sdk-s3 INTERFACE ${LIBAWS_INCLUDE_DIR}) - target_link_libraries(AWS::aws-cpp-sdk-s3 INTERFACE AWS::aws-cpp-sdk-core) endfunction(use_bundled_libaws) diff --git a/cmake/BundledBZip2.cmake b/cmake/BundledBZip2.cmake index 9c3fb5b806..f0ab3b110a 100644 --- a/cmake/BundledBZip2.cmake +++ b/cmake/BundledBZip2.cmake @@ -20,49 +20,58 @@ function(use_bundled_bzip2 SOURCE_DIR BINARY_DIR) message("Using bundled bzip2") - # Define patch step - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/bzip2/bzip2.patch") + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt BZip2 external lib") + include(${CMAKE_BINARY_DIR}/BZip2Config.cmake) - # Define byproduct - if (WIN32) - set(BYPRODUCT "lib/bz2.lib") - else() - set(BYPRODUCT "lib/libbz2.a") - endif() + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building BZip2 external lib") + + + # Define patch step + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/bzip2/all/patches/bzip2.patch") - # Set build options - set(BZIP2_BIN_DIR "${BINARY_DIR}/thirdparty/bzip2-install" CACHE STRING "" FORCE) + # Define byproduct + if (WIN32) + set(BYPRODUCT "lib/bz2.lib") + else() + set(BYPRODUCT "lib/libbz2.a") + endif() - set(BZIP2_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BZIP2_BIN_DIR}") + # Set build options + set(BZIP2_BIN_DIR "${BINARY_DIR}/thirdparty/bzip2-install" CACHE STRING "" FORCE) - # Build project - ExternalProject_Add( - bzip2-external - URL https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz http://deb.debian.org/debian/pool/main/b/bzip2/bzip2_1.0.8.orig.tar.gz - URL_HASH "SHA256=ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269" - SOURCE_DIR "${BINARY_DIR}/thirdparty/bzip2-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${BZIP2_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BZIP2_BIN_DIR}/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + set(BZIP2_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BZIP2_BIN_DIR}") - # Set variables - set(BZIP2_FOUND "YES" CACHE STRING "" FORCE) - set(BZIP2_INCLUDE_DIRS "${BZIP2_BIN_DIR}/include" CACHE STRING "" FORCE) - set(BZIP2_LIBRARIES "${BZIP2_BIN_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) + # Build project + ExternalProject_Add( + bzip2-external + URL https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz http://deb.debian.org/debian/pool/main/b/bzip2/bzip2_1.0.8.orig.tar.gz + URL_HASH "SHA256=ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269" + SOURCE_DIR "${BINARY_DIR}/thirdparty/bzip2-src" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${BZIP2_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BZIP2_BIN_DIR}/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_BZIP2_INCLUDE_DIRS=${BZIP2_INCLUDE_DIRS}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_BZIP2_LIBRARIES=${BZIP2_LIBRARIES}" CACHE STRING "" FORCE) + # Set variables + set(BZIP2_FOUND "YES" CACHE STRING "" FORCE) + set(BZIP2_INCLUDE_DIRS "${BZIP2_BIN_DIR}/include" CACHE STRING "" FORCE) + set(BZIP2_LIBRARIES "${BZIP2_BIN_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) - # Create imported targets - file(MAKE_DIRECTORY ${BZIP2_INCLUDE_DIRS}) + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_BZIP2_INCLUDE_DIRS=${BZIP2_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_BZIP2_LIBRARIES=${BZIP2_LIBRARIES}" CACHE STRING "" FORCE) - add_library(BZip2::BZip2 STATIC IMPORTED) - set_target_properties(BZip2::BZip2 PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}") - add_dependencies(BZip2::BZip2 bzip2-external) - set_property(TARGET BZip2::BZip2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}") + # Create imported targets + file(MAKE_DIRECTORY ${BZIP2_INCLUDE_DIRS}) + + add_library(BZip2::BZip2 STATIC IMPORTED) + set_target_properties(BZip2::BZip2 PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}") + add_dependencies(BZip2::BZip2 bzip2-external) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}") + endif() endfunction(use_bundled_bzip2) diff --git a/cmake/BundledIODBC.cmake b/cmake/BundledIODBC.cmake new file mode 100644 index 0000000000..1685a3b441 --- /dev/null +++ b/cmake/BundledIODBC.cmake @@ -0,0 +1,77 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +function(use_bundled_iodbc SOURCE_DIR BINARY_DIR) + message("Using bundled iodbc") + + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt iODBC external lib") + include(${CMAKE_BINARY_DIR}/ODBCConfig.cmake) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building iODBC external lib") + + if (WIN32) + find_package(ODBC REQUIRED) + else() + + # Define byproducts + set(IODBC_BYPRODUCT "lib/libiodbc.a") + + set(IODBC_BYPRODUCT_DIR "${BINARY_DIR}/thirdparty/iodbc-install/") + + # Build project + set(IODBC_URL https://github.com/openlink/iODBC/archive/v3.52.14.tar.gz) + set(IODBC_URL_HASH "SHA256=896d7e16b283cf9a6f5b5f46e8e9549aef21a11935726b0170987cd4c59d16db") + + ExternalProject_Add( + iodbc-external + URL ${IODBC_URL} + URL_HASH ${IODBC_URL_HASH} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/iodbc-src" + BUILD_COMMAND make + CMAKE_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND make install + CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${IODBC_BYPRODUCT_DIR} --with-pic + STEP_TARGETS build + BUILD_BYPRODUCTS "${IODBC_BYPRODUCT_DIR}/${IODBC_BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + + # Set variables + set(IODBC_FOUND "YES" CACHE STRING "" FORCE) + set(IODBC_INCLUDE_DIRS "${IODBC_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) + set(IODBC_LIBRARIES "${IODBC_BYPRODUCT_DIR}/${IODBC_BYPRODUCT}" CACHE STRING "" FORCE) + + # Set exported variables for FindPackage.cmake + set(EXPORTED_IODBC_INCLUDE_DIRS "${IODBC_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(EXPORTED_IODBC_LIBRARIES "${IODBC_LIBRARIES}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${IODBC_INCLUDE_DIRS}) + + add_library(ODBC::ODBC STATIC IMPORTED) + set_target_properties(ODBC::ODBC PROPERTIES IMPORTED_LOCATION "${IODBC_LIBRARIES}") + add_dependencies(ODBC::ODBC iodbc-external) + set_property(TARGET ODBC::ODBC APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${IODBC_INCLUDE_DIRS}) + endif() + endif() +endfunction(use_bundled_iodbc) diff --git a/cmake/BundledLibArchive.cmake b/cmake/BundledLibArchive.cmake index 6ab55de11c..1bf0b349d4 100644 --- a/cmake/BundledLibArchive.cmake +++ b/cmake/BundledLibArchive.cmake @@ -16,105 +16,116 @@ # under the License. function(use_bundled_libarchive SOURCE_DIR BINARY_DIR) - # Define patch step - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libarchive/libarchive.patch") + message("Using bundled LibArchive") + + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt LibArchive external lib") + include(${CMAKE_BINARY_DIR}/LibArchiveConfig.cmake) - # Define byproducts - if (WIN32) - set(BYPRODUCT "lib/archive_static.lib") - else() - set(BYPRODUCT "lib/libarchive.a") - endif() + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building LibArchive external lib") - # Set build options - set(LIBARCHIVE_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libarchive-install" - -DLIBARCHIVE_STATIC=1 - -DENABLE_MBEDTLS=OFF - -DENABLE_NETTLE=OFF - -DENABLE_LIBB2=OFF - -DENABLE_LZ4=OFF - -DENABLE_LZO=OFF - -DENABLE_ZSTD=OFF - -DENABLE_ZLIB=ON - -DENABLE_LIBXML2=OFF - -DENABLE_EXPAT=OFF - -DENABLE_PCREPOSIX=OFF - -DENABLE_TAR=OFF # This does not disable the tar format, just the standalone tar command line utility - -DENABLE_CPIO=OFF - -DENABLE_CAT=OFF - -DENABLE_XATTR=ON - -DENABLE_ACL=ON - -DENABLE_ICONV=OFF - -DENABLE_TEST=OFF - -DENABLE_WERROR=OFF) - if (MINIFI_OPENSSL) - list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_OPENSSL=ON) - else() - list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_OPENSSL=OFF) - endif() + # Define patch step + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libarchive/all/patches/libarchive.patch") - if (NOT ENABLE_LZMA) - list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_LZMA=OFF) - else() - list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_LZMA=ON) - endif() + # Define byproducts + if (WIN32) + set(BYPRODUCT "lib/archive_static.lib") + else() + set(BYPRODUCT "lib/libarchive.a") + endif() - if (NOT ENABLE_BZIP2) - list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_BZip2=OFF) - else() - list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_BZip2=ON) - endif() + # Set build options + set(LIBARCHIVE_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libarchive-install" + -DLIBARCHIVE_STATIC=1 + -DENABLE_MBEDTLS=OFF + -DENABLE_NETTLE=OFF + -DENABLE_LIBB2=OFF + -DENABLE_LZ4=OFF + -DENABLE_LZO=OFF + -DENABLE_ZSTD=OFF + -DENABLE_ZLIB=ON + -DENABLE_LIBXML2=OFF + -DENABLE_EXPAT=OFF + -DENABLE_PCREPOSIX=OFF + -DENABLE_TAR=OFF # This does not disable the tar format, just the standalone tar command line utility + -DENABLE_CPIO=OFF + -DENABLE_CAT=OFF + -DENABLE_XATTR=ON + -DENABLE_ACL=ON + -DENABLE_ICONV=OFF + -DENABLE_TEST=OFF + -DENABLE_WERROR=OFF) - append_third_party_passthrough_args(LIBARCHIVE_CMAKE_ARGS "${LIBARCHIVE_CMAKE_ARGS}") + if (MINIFI_OPENSSL) + list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_OPENSSL=ON) + else() + list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_OPENSSL=OFF) + endif() - # Build project - ExternalProject_Add( - libarchive-external - URL "https://github.com/libarchive/libarchive/releases/download/v3.4.2/libarchive-3.4.2.tar.gz" - URL_HASH "SHA256=b60d58d12632ecf1e8fad7316dc82c6b9738a35625746b47ecdcaf4aed176176" - SOURCE_DIR "${BINARY_DIR}/thirdparty/libarchive-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${LIBARCHIVE_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libarchive-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + if (NOT ENABLE_LZMA) + list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_LZMA=OFF) + else() + list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_LZMA=ON) + endif() - # Set dependencies - add_dependencies(libarchive-external ZLIB::ZLIB) - if (MINIFI_OPENSSL) - add_dependencies(libarchive-external OpenSSL::Crypto) - endif() - if (ENABLE_LZMA) - add_dependencies(libarchive-external LibLZMA::LibLZMA) - endif() - if (ENABLE_BZIP2) - add_dependencies(libarchive-external BZip2::BZip2) - endif() + if (NOT ENABLE_BZIP2) + list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_BZip2=OFF) + else() + list(APPEND LIBARCHIVE_CMAKE_ARGS -DENABLE_BZip2=ON) + endif() - # Set variables - set(LIBARCHIVE_FOUND "YES" CACHE STRING "" FORCE) - set(LIBARCHIVE_INCLUDE_DIRS "${BINARY_DIR}/thirdparty/libarchive-install/include" CACHE STRING "" FORCE) - set(LIBARCHIVE_LIBRARY "${BINARY_DIR}/thirdparty/libarchive-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(LIBARCHIVE_LIBRARIES ${LIBARCHIVE_LIBRARY} CACHE STRING "" FORCE) + append_third_party_passthrough_args(LIBARCHIVE_CMAKE_ARGS "${LIBARCHIVE_CMAKE_ARGS}") - # Create imported targets - add_library(LibArchive::LibArchive STATIC IMPORTED) - set_target_properties(LibArchive::LibArchive PROPERTIES IMPORTED_LOCATION "${LIBARCHIVE_LIBRARY}") - add_dependencies(LibArchive::LibArchive libarchive-external) - set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) - if (MINIFI_OPENSSL) - set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) - endif() - if (ENABLE_LZMA) - set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES LibLZMA::LibLZMA) - endif() - if (ENABLE_BZIP2) - set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES BZip2::BZip2) + # Build project + ExternalProject_Add( + libarchive-external + URL "https://github.com/libarchive/libarchive/releases/download/v3.4.2/libarchive-3.4.2.tar.gz" + URL_HASH "SHA256=b60d58d12632ecf1e8fad7316dc82c6b9738a35625746b47ecdcaf4aed176176" + SOURCE_DIR "${BINARY_DIR}/thirdparty/libarchive-src" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${LIBARCHIVE_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libarchive-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + + # Set dependencies + add_dependencies(libarchive-external ZLIB::ZLIB) + if (MINIFI_OPENSSL) + add_dependencies(libarchive-external OpenSSL::Crypto) + endif() + if (ENABLE_LZMA) + add_dependencies(libarchive-external LibLZMA::LibLZMA) + endif() + if (ENABLE_BZIP2) + add_dependencies(libarchive-external BZip2::BZip2) + endif() + + # Set variables + set(LIBARCHIVE_FOUND "YES" CACHE STRING "" FORCE) + set(LIBARCHIVE_INCLUDE_DIRS "${BINARY_DIR}/thirdparty/libarchive-install/include" CACHE STRING "" FORCE) + set(LIBARCHIVE_LIBRARY "${BINARY_DIR}/thirdparty/libarchive-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(LIBARCHIVE_LIBRARIES ${LIBARCHIVE_LIBRARY} CACHE STRING "" FORCE) + + # Create imported targets + add_library(LibArchive::LibArchive STATIC IMPORTED) + set_target_properties(LibArchive::LibArchive PROPERTIES IMPORTED_LOCATION "${LIBARCHIVE_LIBRARY}") + add_dependencies(LibArchive::LibArchive libarchive-external) + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) + if (MINIFI_OPENSSL) + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) + endif() + if (ENABLE_LZMA) + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES LibLZMA::LibLZMA) + endif() + if (ENABLE_BZIP2) + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES BZip2::BZip2) + endif() + file(MAKE_DIRECTORY ${LIBARCHIVE_INCLUDE_DIRS}) + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBARCHIVE_INCLUDE_DIRS}) + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "LIBARCHIVE_STATIC=1") endif() - file(MAKE_DIRECTORY ${LIBARCHIVE_INCLUDE_DIRS}) - set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBARCHIVE_INCLUDE_DIRS}) - set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "LIBARCHIVE_STATIC=1") endfunction(use_bundled_libarchive) diff --git a/cmake/BundledLibCoAP.cmake b/cmake/BundledLibCoAP.cmake index 8c47033900..41d42e90c4 100644 --- a/cmake/BundledLibCoAP.cmake +++ b/cmake/BundledLibCoAP.cmake @@ -20,66 +20,78 @@ function(use_bundled_libcoap SOURCE_DIR BINARY_DIR) message("Using bundled libcoap") - # Define patch step - if (WIN32) - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libcoap/libcoap-windows-cmake.patch") - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt LibCoap external lib") + include(${CMAKE_BINARY_DIR}/libcoap-config.cmake) - # Define byproducts - if (WIN32) - set(BYPRODUCT "lib/coap.lib") - else() - set(BYPRODUCT "lib/libcoap-2.a") - endif() + set(COAP_INCLUDE_DIRS "${libcoap_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(COAP_LIBRARIES "${libcoap_LIBRARIES}" CACHE STRING "" FORCE) - # Build project - set(LIBCOAP_URL https://github.com/obgm/libcoap/archive/v4.2.1.tar.gz) - set(LIBCOAP_URL_HASH "SHA256=29a0394a265d3febee41e5e2dc03d34292a0aede37f5f80334e529ac0dab2321") + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building LibCoap external lib") - if (WIN32) - set(LIBCOAP_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libcoap-install") + # Define patch step + if (WIN32) + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libcoap/all/patches/libcoap-windows-cmake.patch") + endif() - ExternalProject_Add( - coap-external - URL ${LIBCOAP_URL} - URL_HASH ${LIBCOAP_URL_HASH} - CMAKE_ARGS ${LIBCOAP_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libcoap-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) - else() - ExternalProject_Add( - coap-external - URL ${LIBCOAP_URL} - URL_HASH ${LIBCOAP_URL_HASH} - BUILD_IN_SOURCE true - SOURCE_DIR "${BINARY_DIR}/thirdparty/libcoap-src" - BUILD_COMMAND make - CMAKE_COMMAND "" - UPDATE_COMMAND "" - INSTALL_COMMAND make install - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libcoap-install/${BYPRODUCT}" - CONFIGURE_COMMAND "" - PATCH_COMMAND ./autogen.sh && ./configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS} -fPIC" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS} -fPIC" --with-pic --disable-examples --disable-dtls --disable-tests --disable-documentation --prefix=${BINARY_DIR}/thirdparty/libcoap-install - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - ) - endif() + # Define byproducts + if (WIN32) + set(BYPRODUCT "lib/coap.lib") + else() + set(BYPRODUCT "lib/libcoap-2.a") + endif() + + # Build project + set(LIBCOAP_URL https://github.com/obgm/libcoap/archive/v4.2.1.tar.gz) + set(LIBCOAP_URL_HASH "SHA256=29a0394a265d3febee41e5e2dc03d34292a0aede37f5f80334e529ac0dab2321") - # Set variables - set(COAP_FOUND "YES" CACHE STRING "" FORCE) - set(COAP_INCLUDE_DIRS "${BINARY_DIR}/thirdparty/libcoap-install/include" CACHE STRING "" FORCE) - set(COAP_LIBRARY "${BINARY_DIR}/thirdparty/libcoap-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(COAP_LIBRARIES "${COAP_LIBRARY}" CACHE STRING "" FORCE) + if (WIN32) + set(LIBCOAP_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libcoap-install") - # Create imported targets - file(MAKE_DIRECTORY ${COAP_INCLUDE_DIRS}) + ExternalProject_Add( + coap-external + URL ${LIBCOAP_URL} + URL_HASH ${LIBCOAP_URL_HASH} + CMAKE_ARGS ${LIBCOAP_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libcoap-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + else() + ExternalProject_Add( + coap-external + URL ${LIBCOAP_URL} + URL_HASH ${LIBCOAP_URL_HASH} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/libcoap-src" + BUILD_COMMAND make + CMAKE_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND make install + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libcoap-install/${BYPRODUCT}" + CONFIGURE_COMMAND "" + PATCH_COMMAND ./autogen.sh && ./configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS} -fPIC" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS} -fPIC" --with-pic --disable-examples --disable-dtls --disable-tests --disable-documentation --prefix=${BINARY_DIR}/thirdparty/libcoap-install + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + ) + endif() + + # Set variables + set(COAP_FOUND "YES" CACHE STRING "" FORCE) + set(COAP_INCLUDE_DIRS "${BINARY_DIR}/thirdparty/libcoap-install/include" CACHE STRING "" FORCE) + set(COAP_LIBRARY "${BINARY_DIR}/thirdparty/libcoap-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(COAP_LIBRARIES "${COAP_LIBRARY}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${COAP_INCLUDE_DIRS}) + + add_library(COAP::libcoap STATIC IMPORTED) + set_target_properties(COAP::libcoap PROPERTIES IMPORTED_LOCATION "${COAP_LIBRARY}") + add_dependencies(COAP::libcoap coap-external) + set_property(TARGET COAP::libcoap APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${COAP_INCLUDE_DIRS}") + set_property(TARGET COAP::libcoap APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads) + endif() - add_library(COAP::libcoap STATIC IMPORTED) - set_target_properties(COAP::libcoap PROPERTIES IMPORTED_LOCATION "${COAP_LIBRARY}") - add_dependencies(COAP::libcoap coap-external) - set_property(TARGET COAP::libcoap APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${COAP_INCLUDE_DIRS}") - set_property(TARGET COAP::libcoap APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads) endfunction(use_bundled_libcoap) diff --git a/cmake/BundledLibLZMA.cmake b/cmake/BundledLibLZMA.cmake index 4e58c534ff..8e616b6130 100644 --- a/cmake/BundledLibLZMA.cmake +++ b/cmake/BundledLibLZMA.cmake @@ -20,80 +20,88 @@ function(use_bundled_liblzma SOURCE_DIR BINARY_DIR) message("Using bundled liblzma") - # Define patch step - if (WIN32) - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/liblzma/liblzma.patch") - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt LibLZMA external lib") + include(${CMAKE_BINARY_DIR}/LibLZMAConfig.cmake) - # Define byproduct - if (WIN32) - set(BYPRODUCT "lib/lzma.lib") - else() - set(BYPRODUCT "lib/liblzma.a") - endif() + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building LibLZMA external lib") - # Set build options - set(LIBLZMA_BIN_DIR "${BINARY_DIR}/thirdparty/liblzma-install" CACHE STRING "" FORCE) + # Define patch step + if (WIN32) + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/liblzma/xz_utils/all/patches/liblzma.patch") + endif() - if (WIN32) - set(LIBLZMA_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${LIBLZMA_BIN_DIR}") - endif() + # Define byproduct + if (WIN32) + set(BYPRODUCT "lib/lzma.lib") + else() + set(BYPRODUCT "lib/liblzma.a") + endif() - # Build project - set(LIBLZMA_URL https://distfiles.gentoo.org/distfiles/22/xz-5.2.5.tar.gz https://tukaani.org/xz/xz-5.2.5.tar.gz) - set(LIBLZMA_URL_HASH "SHA256=f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10") + # Set build options + set(LIBLZMA_BIN_DIR "${BINARY_DIR}/thirdparty/liblzma-install" CACHE STRING "" FORCE) - if (WIN32) - ExternalProject_Add( - liblzma-external - URL ${LIBLZMA_URL} - URL_HASH ${LIBLZMA_URL_HASH} - SOURCE_DIR "${BINARY_DIR}/thirdparty/liblzma-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${LIBLZMA_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${LIBLZMA_BIN_DIR}/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) - else() - set(CONFIGURE_COMMAND ./configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS} -fPIC" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS} -fPIC" --disable-xz --disable-xzdec --disable-lzmadec --disable-lzmainfo --disable-lzma-links --disable-scripts --disable-doc --enable-shared=no "--prefix=${LIBLZMA_BIN_DIR}") - if(PORTABLE) - list(APPEND CONFIGURE_COMMAND "--disable-assembler") + if (WIN32) + set(LIBLZMA_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${LIBLZMA_BIN_DIR}") endif() - ExternalProject_Add( - liblzma-external - URL ${LIBLZMA_URL} - URL_HASH ${LIBLZMA_URL_HASH} - BUILD_IN_SOURCE true - SOURCE_DIR "${BINARY_DIR}/thirdparty/liblzma-src" - BUILD_COMMAND make - CMAKE_COMMAND "" - UPDATE_COMMAND "" - INSTALL_COMMAND make install - BUILD_BYPRODUCTS "${LIBLZMA_BIN_DIR}/${BYPRODUCT}" - CONFIGURE_COMMAND "" - PATCH_COMMAND ${CONFIGURE_COMMAND} - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - ) - endif() + # Build project + set(LIBLZMA_URL https://distfiles.gentoo.org/distfiles/22/xz-5.2.5.tar.gz https://tukaani.org/xz/xz-5.2.5.tar.gz) + set(LIBLZMA_URL_HASH "SHA256=f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10") + + if (WIN32) + ExternalProject_Add( + liblzma-external + URL ${LIBLZMA_URL} + URL_HASH ${LIBLZMA_URL_HASH} + SOURCE_DIR "${BINARY_DIR}/thirdparty/liblzma-src" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${LIBLZMA_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${LIBLZMA_BIN_DIR}/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + else() + set(CONFIGURE_COMMAND ./configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS} -fPIC" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS} -fPIC" --disable-xz --disable-xzdec --disable-lzmadec --disable-lzmainfo --disable-lzma-links --disable-scripts --disable-doc --enable-shared=no "--prefix=${LIBLZMA_BIN_DIR}") + if(PORTABLE) + list(APPEND CONFIGURE_COMMAND "--disable-assembler") + endif() - # Set variables - set(LIBLZMA_FOUND "YES" CACHE STRING "" FORCE) - set(LIBLZMA_INCLUDE_DIRS "${LIBLZMA_BIN_DIR}/include" CACHE STRING "" FORCE) - set(LIBLZMA_LIBRARIES "${LIBLZMA_BIN_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) + ExternalProject_Add( + liblzma-external + URL ${LIBLZMA_URL} + URL_HASH ${LIBLZMA_URL_HASH} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/liblzma-src" + BUILD_COMMAND make + CMAKE_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND make install + BUILD_BYPRODUCTS "${LIBLZMA_BIN_DIR}/${BYPRODUCT}" + CONFIGURE_COMMAND "" + PATCH_COMMAND ${CONFIGURE_COMMAND} + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + ) + endif() - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBLZMA_INCLUDE_DIRS=${LIBLZMA_INCLUDE_DIRS}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBLZMA_LIBRARIES=${LIBLZMA_LIBRARIES}" CACHE STRING "" FORCE) + # Set variables + set(LIBLZMA_FOUND "YES" CACHE STRING "" FORCE) + set(LIBLZMA_INCLUDE_DIRS "${LIBLZMA_BIN_DIR}/include" CACHE STRING "" FORCE) + set(LIBLZMA_LIBRARIES "${LIBLZMA_BIN_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) - # Create imported targets - file(MAKE_DIRECTORY ${LIBLZMA_INCLUDE_DIRS}) + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBLZMA_INCLUDE_DIRS=${LIBLZMA_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBLZMA_LIBRARIES=${LIBLZMA_LIBRARIES}" CACHE STRING "" FORCE) - add_library(LibLZMA::LibLZMA STATIC IMPORTED) - set_target_properties(LibLZMA::LibLZMA PROPERTIES IMPORTED_LOCATION "${LIBLZMA_LIBRARIES}") - add_dependencies(LibLZMA::LibLZMA liblzma-external) - set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBLZMA_INCLUDE_DIRS}") + # Create imported targets + file(MAKE_DIRECTORY ${LIBLZMA_INCLUDE_DIRS}) + + add_library(LibLZMA::LibLZMA STATIC IMPORTED) + set_target_properties(LibLZMA::LibLZMA PROPERTIES IMPORTED_LOCATION "${LIBLZMA_LIBRARIES}") + add_dependencies(LibLZMA::LibLZMA liblzma-external) + set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBLZMA_INCLUDE_DIRS}") + endif() endfunction(use_bundled_liblzma) diff --git a/cmake/BundledLibPcap.cmake b/cmake/BundledLibPcap.cmake new file mode 100644 index 0000000000..4cdf7fa3a8 --- /dev/null +++ b/cmake/BundledLibPcap.cmake @@ -0,0 +1,83 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +function(use_bundled_libpcap SOURCE_DIR BINARY_DIR) + message("Using bundled libpcap") + + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt libpcap external lib") + include(${CMAKE_BINARY_DIR}/libpcap-config.cmake) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building libpcap external lib") + + # Define byproducts + if(WIN32) + set(LIBPCAP_BYPRODUCT "lib/libpcap.lib") + else() + # set(LIBPCAP_BYPRODUCT "lib/libpcap.a") + set(LIBPCAP_BYPRODUCT "lib/libpcap.so") + endif() + + set(LIBPCAP_BYPRODUCT_DIR "${BINARY_DIR}/thirdparty/libpcap-install") + + # Build project + set(LIBPCAP_URL https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.10.1.tar.gz) + set(LIBPCAP_URL_HASH "SHA256=7b650c9e0ce246aa41ba5463fe8e903efc444c914a3ccb986547350bed077ed6") + + set(LIBPCAP_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${LIBPCAP_BYPRODUCT_DIR}" + "-DBUILD_SHARED_LIBS=ON") + + append_third_party_passthrough_args(LIBPCAP_CMAKE_ARGS "${LIBPCAP_CMAKE_ARGS}") + + ExternalProject_Add( + libpcap-external + URL ${LIBPCAP_URL} + URL_HASH ${LIBPCAP_URL_HASH} + CMAKE_ARGS ${LIBPCAP_CMAKE_ARGS} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/libpcap-src" + STEP_TARGETS build + BUILD_BYPRODUCTS "${LIBPCAP_BYPRODUCT_DIR}/${LIBPCAP_BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + + # Set variables + set(PCAP_FOUND "YES" CACHE STRING "" FORCE) + set(PCAP_ROOT_DIR "${LIBPCAP_BYPRODUCT_DIR}" CACHE STRING "" FORCE) + set(PCAP_INCLUDE_DIR "${LIBPCAP_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) + set(PCAP_LIBRARIES "${LIBPCAP_BYPRODUCT_DIR}/${LIBPCAP_BYPRODUCT}" CACHE STRING "" FORCE) + set(PCAP_LIBRARY "${PCAP_LIBRARIES}" CACHE STRING "" FORCE) + + # Set exported variables for FindPackage.cmake + set(EXPORTED_PCAP_INCLUDE_DIRS "${PCAP_INCLUDE_DIR}" CACHE STRING "" FORCE) + set(EXPORTED_PCAP_LIBRARIES "${PCAP_LIBRARY}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${PCAP_INCLUDE_DIR}) + + add_library(PCAP SHARED IMPORTED) + add_library(PCAP::PCAP ALIAS PCAP) + set_target_properties(PCAP PROPERTIES IMPORTED_LOCATION "${PCAP_LIBRARY}") + add_dependencies(PCAP libpcap-external) + set_property(TARGET PCAP APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PCAP_INCLUDE_DIR}) + + endif() +endfunction(use_bundled_libpcap) diff --git a/cmake/BundledLibRdKafka.cmake b/cmake/BundledLibRdKafka.cmake index bbaaf96f0d..47202ab4fa 100644 --- a/cmake/BundledLibRdKafka.cmake +++ b/cmake/BundledLibRdKafka.cmake @@ -16,57 +16,74 @@ # under the License. function(use_bundled_librdkafka SOURCE_DIR BINARY_DIR) - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/librdkafka/high-cpu.patch") + message("Using bundled librdkafka") - # Define byproducts - if(WIN32) - set(BYPRODUCT "lib/rdkafka.lib") - else() - set(BYPRODUCT "lib/librdkafka.a") - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt LibRdKafka external lib") + include(${CMAKE_BINARY_DIR}/RdKafkaConfig.cmake) + + set(LIBRDKAFKA_INCLUDE_DIR "${RdKafka_INCLUDE_DIRS}/librdkafka" CACHE STRING "" FORCE) + set_property(TARGET RdKafka::rdkafka++ APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBRDKAFKA_INCLUDE_DIR}) + + add_library(librdkafka ALIAS RdKafka::rdkafka++) + + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building LibRdKafka external lib") - # Set build options - set(LIBRDKAFKA_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/librdkafka-install" - "-DWITH_SSL=ON" - "-DWITH_SASL=OFF" - "-DRDKAFKA_BUILD_STATIC=ON" - "-DRDKAFKA_BUILD_EXAMPLES=OFF" - "-DRDKAFKA_BUILD_TESTS=OFF" - "-DENABLE_LZ4_EXT=OFF" - "-DWITH_ZSTD=OFF" - "-DCMAKE_INSTALL_LIBDIR=lib" - "-DLIBRDKAFKA_STATICLIB=1") - append_third_party_passthrough_args(LIBRDKAFKA_CMAKE_ARGS "${LIBRDKAFKA_CMAKE_ARGS}") + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/librdkafka/high-cpu.patch") - # Build project - ExternalProject_Add( - kafka-external - URL "https://github.com/edenhill/librdkafka/archive/v1.6.0.tar.gz" - URL_HASH "SHA256=3130cbd391ef683dc9acf9f83fe82ff93b8730a1a34d0518e93c250929be9f6b" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${LIBRDKAFKA_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/librdkafka-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + # Define byproducts + if(WIN32) + set(BYPRODUCT "lib/rdkafka.lib") + else() + set(BYPRODUCT "lib/librdkafka.a") + endif() - # Set dependencies - add_dependencies(kafka-external OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB) + # Set build options + set(LIBRDKAFKA_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/librdkafka-install" + "-DWITH_SSL=ON" + "-DWITH_SASL=OFF" + "-DRDKAFKA_BUILD_STATIC=ON" + "-DRDKAFKA_BUILD_EXAMPLES=OFF" + "-DRDKAFKA_BUILD_TESTS=OFF" + "-DENABLE_LZ4_EXT=OFF" + "-DWITH_ZSTD=OFF" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DLIBRDKAFKA_STATICLIB=1") - # Set variables - set(LIBRDKAFKA_FOUND "YES" CACHE STRING "" FORCE) - set(LIBRDKAFKA_INCLUDE_DIR "${BINARY_DIR}/thirdparty/librdkafka-install/include/librdkafka" CACHE STRING "" FORCE) - set(LIBRDKAFKA_LIBRARY "${BINARY_DIR}/thirdparty/librdkafka-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(LIBRDKAFKA_LIBRARIES ${LIBRDKAFKA_LIBRARY} CACHE STRING "" FORCE) + append_third_party_passthrough_args(LIBRDKAFKA_CMAKE_ARGS "${LIBRDKAFKA_CMAKE_ARGS}") - # Create imported targets - add_library(librdkafka STATIC IMPORTED) - set_target_properties(librdkafka PROPERTIES IMPORTED_LOCATION "${LIBRDKAFKA_LIBRARY}") - add_dependencies(librdkafka kafka-external) - set_property(TARGET librdkafka APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB Threads::Threads) - file(MAKE_DIRECTORY ${LIBRDKAFKA_INCLUDE_DIR}) - set_property(TARGET librdkafka APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBRDKAFKA_INCLUDE_DIR}) - set_property(TARGET librdkafka APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "LIBRDKAFKA_STATICLIB=1") + # Build project + ExternalProject_Add( + kafka-external + URL "https://github.com/edenhill/librdkafka/archive/v1.6.0.tar.gz" + URL_HASH "SHA256=3130cbd391ef683dc9acf9f83fe82ff93b8730a1a34d0518e93c250929be9f6b" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${LIBRDKAFKA_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/librdkafka-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + + # Set dependencies + add_dependencies(kafka-external OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB) + + # Set variables + set(LIBRDKAFKA_FOUND "YES" CACHE STRING "" FORCE) + set(LIBRDKAFKA_INCLUDE_DIR "${BINARY_DIR}/thirdparty/librdkafka-install/include/librdkafka" CACHE STRING "" FORCE) + set(LIBRDKAFKA_LIBRARY "${BINARY_DIR}/thirdparty/librdkafka-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(LIBRDKAFKA_LIBRARIES ${LIBRDKAFKA_LIBRARY} CACHE STRING "" FORCE) + + # Create imported targets + add_library(librdkafka STATIC IMPORTED) + set_target_properties(librdkafka PROPERTIES IMPORTED_LOCATION "${LIBRDKAFKA_LIBRARY}") + add_dependencies(librdkafka kafka-external) + set_property(TARGET librdkafka APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB Threads::Threads) + file(MAKE_DIRECTORY ${LIBRDKAFKA_INCLUDE_DIR}) + set_property(TARGET librdkafka APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBRDKAFKA_INCLUDE_DIR}) + set_property(TARGET librdkafka APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "LIBRDKAFKA_STATICLIB=1") + endif() endfunction(use_bundled_librdkafka) diff --git a/cmake/BundledLibSSH2.cmake b/cmake/BundledLibSSH2.cmake index bd7c8a2d63..c80c260956 100644 --- a/cmake/BundledLibSSH2.cmake +++ b/cmake/BundledLibSSH2.cmake @@ -18,60 +18,69 @@ function(use_bundled_libssh2 SOURCE_DIR BINARY_DIR) message("Using bundled libssh2") - # Define patch step - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libssh2/libssh2-CMAKE_MODULE_PATH.patch") + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt LibSSH2 external lib") + include(${CMAKE_BINARY_DIR}/Libssh2Config.cmake) - # Define byproducts - if (WIN32) - set(BYPRODUCT "lib/libssh2.lib") - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - set(BYPRODUCT "${LIBDIR}/libssh2.a") - endif() + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building LibSSH2 external lib") + + # Define patch step + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libssh2/libssh2-CMAKE_MODULE_PATH.patch") + + # Define byproducts + if (WIN32) + set(BYPRODUCT "lib/libssh2.lib") + else() + include(GNUInstallDirs) + string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) + list(GET LIBDIR_LIST 0 LIBDIR) + set(BYPRODUCT "${LIBDIR}/libssh2.a") + endif() - # Set build options - set(LIBSSH2_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libssh2-install" - -DENABLE_ZLIB_COMPRESSION=ON - -DCRYPTO_BACKEND=OpenSSL - -DBUILD_TESTING=OFF - -DBUILD_EXAMPLES=OFF) + # Set build options + set(LIBSSH2_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libssh2-install" + -DENABLE_ZLIB_COMPRESSION=ON + -DCRYPTO_BACKEND=OpenSSL + -DBUILD_TESTING=OFF + -DBUILD_EXAMPLES=OFF) - append_third_party_passthrough_args(LIBSSH2_CMAKE_ARGS "${LIBSSH2_CMAKE_ARGS}") + append_third_party_passthrough_args(LIBSSH2_CMAKE_ARGS "${LIBSSH2_CMAKE_ARGS}") - # Build project - ExternalProject_Add( - libssh2-external - URL "https://github.com/libssh2/libssh2/releases/download/libssh2-1.10.0/libssh2-1.10.0.tar.gz" - URL_HASH "SHA256=2d64e90f3ded394b91d3a2e774ca203a4179f69aebee03003e5a6fa621e41d51" - SOURCE_DIR "${BINARY_DIR}/thirdparty/libssh2-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${LIBSSH2_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libssh2-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + # Build project + ExternalProject_Add( + libssh2-external + URL "https://github.com/libssh2/libssh2/releases/download/libssh2-1.10.0/libssh2-1.10.0.tar.gz" + URL_HASH "SHA256=2d64e90f3ded394b91d3a2e774ca203a4179f69aebee03003e5a6fa621e41d51" + SOURCE_DIR "${BINARY_DIR}/thirdparty/libssh2-src" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${LIBSSH2_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libssh2-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) - # Set dependencies - add_dependencies(libssh2-external OpenSSL::Crypto ZLIB::ZLIB) + # Set dependencies + add_dependencies(libssh2-external OpenSSL::Crypto ZLIB::ZLIB) - # Set variables - set(LIBSSH2_FOUND "YES" CACHE STRING "" FORCE) - set(LIBSSH2_INCLUDE_DIR "${BINARY_DIR}/thirdparty/libssh2-install/include" CACHE STRING "" FORCE) - set(LIBSSH2_LIBRARY "${BINARY_DIR}/thirdparty/libssh2-install/${BYPRODUCT}" CACHE STRING "" FORCE) + # Set variables + set(LIBSSH2_FOUND "YES" CACHE STRING "" FORCE) + set(LIBSSH2_INCLUDE_DIR "${BINARY_DIR}/thirdparty/libssh2-install/include" CACHE STRING "" FORCE) + set(LIBSSH2_LIBRARY "${BINARY_DIR}/thirdparty/libssh2-install/${BYPRODUCT}" CACHE STRING "" FORCE) - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSSH2_INCLUDE_DIR=${LIBSSH2_INCLUDE_DIR}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSSH2_LIBRARY=${LIBSSH2_LIBRARY}" CACHE STRING "" FORCE) + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSSH2_INCLUDE_DIR=${LIBSSH2_INCLUDE_DIR}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSSH2_LIBRARY=${LIBSSH2_LIBRARY}" CACHE STRING "" FORCE) - # Create imported targets - file(MAKE_DIRECTORY ${LIBSSH2_INCLUDE_DIR}) + # Create imported targets + file(MAKE_DIRECTORY ${LIBSSH2_INCLUDE_DIR}) - add_library(libssh2 STATIC IMPORTED) - set_target_properties(libssh2 PROPERTIES IMPORTED_LOCATION "${LIBSSH2_LIBRARY}") - add_dependencies(libssh2 libssh2-external) - set_property(TARGET libssh2 APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::Crypto ZLIB::ZLIB) - set_property(TARGET libssh2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBSSH2_INCLUDE_DIR}) + add_library(libssh2 STATIC IMPORTED) + add_library(Libssh2::libssh2 ALIAS libssh2) + set_target_properties(libssh2 PROPERTIES IMPORTED_LOCATION "${LIBSSH2_LIBRARY}") + add_dependencies(libssh2 libssh2-external) + set_property(TARGET libssh2 APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::Crypto ZLIB::ZLIB) + set_property(TARGET libssh2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBSSH2_INCLUDE_DIR}) + endif() endfunction(use_bundled_libssh2) diff --git a/cmake/BundledLibSodium.cmake b/cmake/BundledLibSodium.cmake index 98d05b737b..31686ac121 100644 --- a/cmake/BundledLibSodium.cmake +++ b/cmake/BundledLibSodium.cmake @@ -18,80 +18,93 @@ function(use_bundled_libsodium SOURCE_DIR BINARY_DIR) message("Using bundled libsodium") - # Define patch step - if (WIN32) - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libsodium/libsodium.patch") - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt libsodium external lib") + include(${CMAKE_BINARY_DIR}/libsodium-config.cmake) + # find_package(libsodium REQUIRED CONFIG) + message("Conan libsodium include dir: ${libsodium_INCLUDE_DIRS}") + message("Conan libsodium library: ${libsodium_LIBRARIES}") + message("Conan libsodium library dir: ${libsodium_LIB_DIRS_RELEASE}") - # Define byproduct - if (WIN32) - set(BYPRODUCT "lib/sodium.lib") - else() - set(BYPRODUCT "lib/libsodium.a") - endif() + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building libsodium external lib") - # Set build options - set(LIBSODIUM_BIN_DIR "${BINARY_DIR}/thirdparty/libsodium-install" CACHE STRING "" FORCE) + # Define patch step + if (WIN32) + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libsodium/libsodium.patch") + endif() - if (WIN32) - set(LIBSODIUM_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${LIBSODIUM_BIN_DIR}" - "-DSODIUM_LIBRARY_MINIMAL=1") - endif() + # Define byproduct + if (WIN32) + set(BYPRODUCT "lib/sodium.lib") + else() + set(BYPRODUCT "lib/libsodium.a") + endif() - # Build project - set(LIBSODIUM_OFFICIAL_MIRROR_URL https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz) - set(LIBSODIUM_GITHUB_MIRROR_URL https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz) - set(LIBSODIUM_GENTOO_MIRROR_URL https://gentoo.osuosl.org/distfiles/libsodium-1.0.18.tar.gz) - set(LIBSODIUM_URL_HASH "SHA256=6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1") + # Set build options + set(LIBSODIUM_BIN_DIR "${BINARY_DIR}/thirdparty/libsodium-install" CACHE STRING "" FORCE) - if (WIN32) - ExternalProject_Add( - libsodium-external - URL "${LIBSODIUM_OFFICIAL_MIRROR_URL}" "${LIBSODIUM_GITHUB_MIRROR_URL}" "${LIBSODIUM_GENTOO_MIRROR_URL}" - URL_HASH ${LIBSODIUM_URL_HASH} - SOURCE_DIR "${BINARY_DIR}/thirdparty/libsodium-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${LIBSODIUM_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${LIBSODIUM_BIN_DIR}/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) - else() - set(CONFIGURE_COMMAND ./configure --disable-pie --enable-minimal "--prefix=${LIBSODIUM_BIN_DIR}") + if (WIN32) + set(LIBSODIUM_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${LIBSODIUM_BIN_DIR}" + "-DSODIUM_LIBRARY_MINIMAL=1") + endif() - ExternalProject_Add( - libsodium-external - URL "${LIBSODIUM_OFFICIAL_MIRROR_URL}" "${LIBSODIUM_GITHUB_MIRROR_URL}" "${LIBSODIUM_GENTOO_MIRROR_URL}" - URL_HASH ${LIBSODIUM_URL_HASH} - BUILD_IN_SOURCE true - SOURCE_DIR "${BINARY_DIR}/thirdparty/libsodium-src" - BUILD_COMMAND make - CMAKE_COMMAND "" - UPDATE_COMMAND "" - INSTALL_COMMAND make install - BUILD_BYPRODUCTS "${LIBSODIUM_BIN_DIR}/${BYPRODUCT}" - CONFIGURE_COMMAND "${CONFIGURE_COMMAND}" - PATCH_COMMAND "" - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - ) - endif() + # Build project + set(LIBSODIUM_OFFICIAL_MIRROR_URL https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz) + set(LIBSODIUM_GITHUB_MIRROR_URL https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz) + set(LIBSODIUM_GENTOO_MIRROR_URL https://gentoo.osuosl.org/distfiles/libsodium-1.0.18.tar.gz) + set(LIBSODIUM_URL_HASH "SHA256=6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1") - # Set variables - set(LIBSODIUM_FOUND "YES" CACHE STRING "" FORCE) - set(LIBSODIUM_INCLUDE_DIRS "${LIBSODIUM_BIN_DIR}/include" CACHE STRING "" FORCE) - set(LIBSODIUM_LIBRARIES "${LIBSODIUM_BIN_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) + if (WIN32) + ExternalProject_Add( + libsodium-external + URL "${LIBSODIUM_OFFICIAL_MIRROR_URL}" "${LIBSODIUM_GITHUB_MIRROR_URL}" "${LIBSODIUM_GENTOO_MIRROR_URL}" + URL_HASH ${LIBSODIUM_URL_HASH} + SOURCE_DIR "${BINARY_DIR}/thirdparty/libsodium-src" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${LIBSODIUM_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${LIBSODIUM_BIN_DIR}/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + else() + set(CONFIGURE_COMMAND ./configure --disable-pie --enable-minimal "--prefix=${LIBSODIUM_BIN_DIR}") - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSODIUM_INCLUDE_DIRS=${LIBSODIUM_INCLUDE_DIRS}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSODIUM_LIBRARIES=${LIBSODIUM_LIBRARIES}" CACHE STRING "" FORCE) + ExternalProject_Add( + libsodium-external + URL "${LIBSODIUM_OFFICIAL_MIRROR_URL}" "${LIBSODIUM_GITHUB_MIRROR_URL}" "${LIBSODIUM_GENTOO_MIRROR_URL}" + URL_HASH ${LIBSODIUM_URL_HASH} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/libsodium-src" + BUILD_COMMAND make + CMAKE_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND make install + BUILD_BYPRODUCTS "${LIBSODIUM_BIN_DIR}/${BYPRODUCT}" + CONFIGURE_COMMAND "${CONFIGURE_COMMAND}" + PATCH_COMMAND "" + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + ) + endif() - # Create imported targets - file(MAKE_DIRECTORY ${LIBSODIUM_INCLUDE_DIRS}) + # Set variables + set(LIBSODIUM_FOUND "YES" CACHE STRING "" FORCE) + set(LIBSODIUM_INCLUDE_DIRS "${LIBSODIUM_BIN_DIR}/include" CACHE STRING "" FORCE) + set(LIBSODIUM_LIBRARIES "${LIBSODIUM_BIN_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) - add_library(libsodium STATIC IMPORTED) - set_target_properties(libsodium PROPERTIES IMPORTED_LOCATION "${LIBSODIUM_LIBRARIES}") - add_dependencies(libsodium libsodium-external) - set_property(TARGET libsodium APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBSODIUM_INCLUDE_DIRS}") + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSODIUM_INCLUDE_DIRS=${LIBSODIUM_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBSODIUM_LIBRARIES=${LIBSODIUM_LIBRARIES}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${LIBSODIUM_INCLUDE_DIRS}) + + add_library(libsodium STATIC IMPORTED) + add_library(libsodium::libsodium ALIAS libsodium) + set_target_properties(libsodium PROPERTIES IMPORTED_LOCATION "${LIBSODIUM_LIBRARIES}") + add_dependencies(libsodium libsodium-external) + set_property(TARGET libsodium APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBSODIUM_INCLUDE_DIRS}") + endif() endfunction(use_bundled_libsodium) diff --git a/cmake/BundledLibXml2.cmake b/cmake/BundledLibXml2.cmake index b5de5503bb..3b6b8fc5cb 100644 --- a/cmake/BundledLibXml2.cmake +++ b/cmake/BundledLibXml2.cmake @@ -20,79 +20,88 @@ function(use_bundled_libxml2 SOURCE_DIR BINARY_DIR) message("Using bundled libxml2") - # Define patch step - if (WIN32) - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libxml2/libxml2-win.patch") - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt LibXml2 external lib") + include(${CMAKE_BINARY_DIR}/libxml2-config.cmake) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building LibXml2 external lib") - # Define byproducts - if (WIN32) - set(BYPRODUCT "lib/xml2.lib") - else() - set(BYPRODUCT "lib/libxml2.a") - endif() - # Set build options - if (WIN32) - set(LIBXML2_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libxml2-install") - endif() + # Define patch step + if (WIN32) + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/libxml2/libxml2-win.patch") + endif() - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) - cmake_policy(SET CMP0135 OLD) # Restore the timestamps from the archive https://gitlab.kitware.com/cmake/cmake/-/issues/24003 - endif() + # Define byproducts + if (WIN32) + set(BYPRODUCT "lib/xml2.lib") + else() + set(BYPRODUCT "lib/libxml2.a") + endif() - # Build project - set(LIBXML2_URL ftp://xmlsoft.org/libxml2/libxml2-2.9.10.tar.gz https://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/libxml2-2.9.10.tar.gz) - set(LIBXML2_URL_HASH "SHA256=aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f") + # Set build options + if (WIN32) + set(LIBXML2_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/libxml2-install") + endif() - if (WIN32) - ExternalProject_Add( - libxml2-external - URL ${LIBXML2_URL} - URL_HASH ${LIBXML2_URL_HASH} - SOURCE_DIR "${BINARY_DIR}/thirdparty/libxml2-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${LIBXML2_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) - else() - ExternalProject_Add( - libxml2-external - URL ${LIBXML2_URL} - URL_HASH ${LIBXML2_URL_HASH} - BUILD_IN_SOURCE true - SOURCE_DIR "${BINARY_DIR}/thirdparty/libxml2-src" - BUILD_COMMAND make - CMAKE_COMMAND "" - UPDATE_COMMAND "" - INSTALL_COMMAND make install - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}" - CONFIGURE_COMMAND "" - PATCH_COMMAND ./configure --enable-shared=no --enable-static=yes --with-pic=yes --with-iconv=no --with-zlib=no --with-lzma=no --with-python=no --with-ftp=no --with-http=no --prefix=${BINARY_DIR}/thirdparty/libxml2-install - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - ) - endif() + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + cmake_policy(SET CMP0135 OLD) # Restore the timestamps from the archive https://gitlab.kitware.com/cmake/cmake/-/issues/24003 + endif() + + # Build project + set(LIBXML2_URL ftp://xmlsoft.org/libxml2/libxml2-2.9.10.tar.gz https://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/libxml2-2.9.10.tar.gz) + set(LIBXML2_URL_HASH "SHA256=aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f") - # Set variables - set(LIBXML2_FOUND "YES" CACHE STRING "" FORCE) - set(LIBXML2_INCLUDE_DIR "${BINARY_DIR}/thirdparty/libxml2-install/include/libxml2" CACHE STRING "" FORCE) - set(LIBXML2_INCLUDE_DIRS "${LIBXML2_INCLUDE_DIR}" CACHE STRING "" FORCE) - set(LIBXML2_LIBRARY "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(LIBXML2_LIBRARIES "${LIBXML2_LIBRARY}" CACHE STRING "" FORCE) + if (WIN32) + ExternalProject_Add( + libxml2-external + URL ${LIBXML2_URL} + URL_HASH ${LIBXML2_URL_HASH} + SOURCE_DIR "${BINARY_DIR}/thirdparty/libxml2-src" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${LIBXML2_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) + else() + ExternalProject_Add( + libxml2-external + URL ${LIBXML2_URL} + URL_HASH ${LIBXML2_URL_HASH} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/libxml2-src" + BUILD_COMMAND make + CMAKE_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND make install + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}" + CONFIGURE_COMMAND "" + PATCH_COMMAND ./configure --enable-shared=no --enable-static=yes --with-pic=yes --with-iconv=no --with-zlib=no --with-lzma=no --with-python=no --with-ftp=no --with-http=no --prefix=${BINARY_DIR}/thirdparty/libxml2-install + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + ) + endif() - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_LIBRARY=${LIBXML2_LIBRARY}" CACHE STRING "" FORCE) + # Set variables + set(LIBXML2_FOUND "YES" CACHE STRING "" FORCE) + set(LIBXML2_INCLUDE_DIR "${BINARY_DIR}/thirdparty/libxml2-install/include/libxml2" CACHE STRING "" FORCE) + set(LIBXML2_INCLUDE_DIRS "${LIBXML2_INCLUDE_DIR}" CACHE STRING "" FORCE) + set(LIBXML2_LIBRARY "${BINARY_DIR}/thirdparty/libxml2-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(LIBXML2_LIBRARIES "${LIBXML2_LIBRARY}" CACHE STRING "" FORCE) - # Create imported targets - file(MAKE_DIRECTORY ${LIBXML2_INCLUDE_DIR}) + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBXML2_LIBRARY=${LIBXML2_LIBRARY}" CACHE STRING "" FORCE) - add_library(LibXml2::LibXml2 STATIC IMPORTED) - set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}") - add_dependencies(LibXml2::LibXml2 libxml2-external) - set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIR}") + # Create imported targets + file(MAKE_DIRECTORY ${LIBXML2_INCLUDE_DIR}) + + add_library(LibXml2::LibXml2 STATIC IMPORTED) + set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}") + add_dependencies(LibXml2::LibXml2 libxml2-external) + set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIR}") + endif() endfunction(use_bundled_libxml2) diff --git a/cmake/BundledLibcURL.cmake b/cmake/BundledLibcURL.cmake index 23735457db..f3c4c41830 100644 --- a/cmake/BundledLibcURL.cmake +++ b/cmake/BundledLibcURL.cmake @@ -16,93 +16,103 @@ # under the License. function(use_bundled_curl SOURCE_DIR BINARY_DIR) - # Define patch step - set(PATCH_FILE_1 "${SOURCE_DIR}/thirdparty/curl/module-path.patch") - set(PC ${Bash_EXECUTABLE} -c "set -x && \ - (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_1}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_1}\")") - # Define byproducts - string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type) - if (WIN32) - if (build_type MATCHES relwithdebinfo OR build_type MATCHES release) - set(BYPRODUCT "lib/libcurl.lib") + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt libcurl external lib") + include(${CMAKE_BINARY_DIR}/CURLConfig.cmake) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building libcurl external lib") + + + # Define patch step + set(PATCH_FILE_1 "${SOURCE_DIR}/thirdparty/curl/module-path.patch") + set(PC ${Bash_EXECUTABLE} -c "set -x && \ + (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_1}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_1}\")") + # Define byproducts + string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type) + if (WIN32) + if (build_type MATCHES relwithdebinfo OR build_type MATCHES release) + set(BYPRODUCT "lib/libcurl.lib") + else() + set(BYPRODUCT "lib/libcurl-d.lib") + endif() else() - set(BYPRODUCT "lib/libcurl-d.lib") + include(GNUInstallDirs) + string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) + list(GET LIBDIR_LIST 0 LIBDIR) + if (build_type MATCHES relwithdebinfo OR build_type MATCHES release) + set(BYPRODUCT "${LIBDIR}/libcurl.a") + else() + set(BYPRODUCT "${LIBDIR}/libcurl-d.a") + endif() endif() - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - if (build_type MATCHES relwithdebinfo OR build_type MATCHES release) - set(BYPRODUCT "${LIBDIR}/libcurl.a") + + # Set build options + set(CURL_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/curl-install" + -DBUILD_CURL_EXE=OFF + -DBUILD_TESTING=OFF + -DBUILD_SHARED_LIBS=OFF + -DHTTP_ONLY=ON + -DCURL_CA_PATH=none + -DCURL_USE_LIBSSH2=OFF + -DUSE_LIBIDN2=OFF + -DCURL_USE_LIBPSL=OFF + ) + if (NOT MINIFI_OPENSSL) + list(APPEND CURL_CMAKE_ARGS -DCURL_USE_OPENSSL=OFF) else() - set(BYPRODUCT "${LIBDIR}/libcurl-d.a") + list(APPEND CURL_CMAKE_ARGS -DCURL_USE_OPENSSL=ON) endif() - endif() - # Set build options - set(CURL_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/curl-install" - -DBUILD_CURL_EXE=OFF - -DBUILD_TESTING=OFF - -DBUILD_SHARED_LIBS=OFF - -DHTTP_ONLY=ON - -DCURL_CA_PATH=none - -DCURL_USE_LIBSSH2=OFF - -DUSE_LIBIDN2=OFF - -DCURL_USE_LIBPSL=OFF - ) - if (NOT MINIFI_OPENSSL) - list(APPEND CURL_CMAKE_ARGS -DCURL_USE_OPENSSL=OFF) - else() - list(APPEND CURL_CMAKE_ARGS -DCURL_USE_OPENSSL=ON) - endif() + append_third_party_passthrough_args(CURL_CMAKE_ARGS "${CURL_CMAKE_ARGS}") - append_third_party_passthrough_args(CURL_CMAKE_ARGS "${CURL_CMAKE_ARGS}") + # Build project + ExternalProject_Add( + curl-external + URL "https://github.com/curl/curl/releases/download/curl-8_4_0/curl-8.4.0.tar.gz" + URL_HASH "SHA256=816e41809c043ff285e8c0f06a75a1fa250211bbfb2dc0a037eeef39f1a9e427" + SOURCE_DIR "${BINARY_DIR}/thirdparty/curl-src" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${CURL_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/curl-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) - # Build project - ExternalProject_Add( - curl-external - URL "https://github.com/curl/curl/releases/download/curl-8_4_0/curl-8.4.0.tar.gz" - URL_HASH "SHA256=816e41809c043ff285e8c0f06a75a1fa250211bbfb2dc0a037eeef39f1a9e427" - SOURCE_DIR "${BINARY_DIR}/thirdparty/curl-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${CURL_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/curl-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + # Set dependencies + add_dependencies(curl-external ZLIB::ZLIB) + if (MINIFI_OPENSSL) + add_dependencies(curl-external OpenSSL::SSL OpenSSL::Crypto) + endif() - # Set dependencies - add_dependencies(curl-external ZLIB::ZLIB) - if (MINIFI_OPENSSL) - add_dependencies(curl-external OpenSSL::SSL OpenSSL::Crypto) - endif() + # Set variables + set(CURL_FOUND "YES" CACHE STRING "" FORCE) + set(CURL_INCLUDE_DIR "${BINARY_DIR}/thirdparty/curl-install/include" CACHE STRING "" FORCE) + set(CURL_INCLUDE_DIRS "${CURL_INCLUDE_DIR}" CACHE STRING "" FORCE) + set(CURL_LIBRARY "${BINARY_DIR}/thirdparty/curl-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(CURL_LIBRARIES "${CURL_LIBRARY}" CACHE STRING "" FORCE) - # Set variables - set(CURL_FOUND "YES" CACHE STRING "" FORCE) - set(CURL_INCLUDE_DIR "${BINARY_DIR}/thirdparty/curl-install/include" CACHE STRING "" FORCE) - set(CURL_INCLUDE_DIRS "${CURL_INCLUDE_DIR}" CACHE STRING "" FORCE) - set(CURL_LIBRARY "${BINARY_DIR}/thirdparty/curl-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(CURL_LIBRARIES "${CURL_LIBRARY}" CACHE STRING "" FORCE) + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_CURL_INCLUDE_DIR=${CURL_INCLUDE_DIR}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_CURL_LIBRARY=${CURL_LIBRARY}" CACHE STRING "" FORCE) - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_CURL_INCLUDE_DIR=${CURL_INCLUDE_DIR}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_CURL_LIBRARY=${CURL_LIBRARY}" CACHE STRING "" FORCE) + # Create imported targets + file(MAKE_DIRECTORY ${CURL_INCLUDE_DIRS}) - # Create imported targets - file(MAKE_DIRECTORY ${CURL_INCLUDE_DIRS}) + add_library(CURL::libcurl STATIC IMPORTED) + set_target_properties(CURL::libcurl PROPERTIES IMPORTED_LOCATION "${CURL_LIBRARY}") + add_dependencies(CURL::libcurl curl-external) + target_include_directories(CURL::libcurl INTERFACE ${CURL_INCLUDE_DIRS}) + target_link_libraries(CURL::libcurl INTERFACE ZLIB::ZLIB Threads::Threads) + if (APPLE) + target_link_libraries(CURL::libcurl INTERFACE "-framework CoreFoundation") + target_link_libraries(CURL::libcurl INTERFACE "-framework SystemConfiguration") + target_link_libraries(CURL::libcurl INTERFACE "-framework CoreServices") + endif() + if (MINIFI_OPENSSL) + target_link_libraries(CURL::libcurl INTERFACE OpenSSL::SSL OpenSSL::Crypto) + endif() - add_library(CURL::libcurl STATIC IMPORTED) - set_target_properties(CURL::libcurl PROPERTIES IMPORTED_LOCATION "${CURL_LIBRARY}") - add_dependencies(CURL::libcurl curl-external) - target_include_directories(CURL::libcurl INTERFACE ${CURL_INCLUDE_DIRS}) - target_link_libraries(CURL::libcurl INTERFACE ZLIB::ZLIB Threads::Threads) - if (APPLE) - target_link_libraries(CURL::libcurl INTERFACE "-framework CoreFoundation") - target_link_libraries(CURL::libcurl INTERFACE "-framework SystemConfiguration") - target_link_libraries(CURL::libcurl INTERFACE "-framework CoreServices") - endif() - if (MINIFI_OPENSSL) - target_link_libraries(CURL::libcurl INTERFACE OpenSSL::SSL OpenSSL::Crypto) endif() endfunction(use_bundled_curl SOURCE_DIR BINARY_DIR) diff --git a/cmake/BundledMbedTLS.cmake b/cmake/BundledMbedTLS.cmake index 7d9184cf4a..ece41d0b32 100644 --- a/cmake/BundledMbedTLS.cmake +++ b/cmake/BundledMbedTLS.cmake @@ -18,87 +18,97 @@ function(use_bundled_mbedtls SOURCE_DIR BINARY_DIR) message("Using bundled MbedTLS") - # Define byproducts - if (WIN32) - set(BYPRODUCT_PREFIX "" CACHE STRING "" FORCE) - set(BYPRODUCT_SUFFIX ".lib" CACHE STRING "" FORCE) - else() - set(BYPRODUCT_PREFIX "lib" CACHE STRING "" FORCE) - set(BYPRODUCT_SUFFIX ".a" CACHE STRING "" FORCE) - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt MbedTLS external lib") + include(${CMAKE_BINARY_DIR}/mbedTLSConfig.cmake) + + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building MbedTLS external lib") + + + # Define byproducts + if (WIN32) + set(BYPRODUCT_PREFIX "" CACHE STRING "" FORCE) + set(BYPRODUCT_SUFFIX ".lib" CACHE STRING "" FORCE) + else() + set(BYPRODUCT_PREFIX "lib" CACHE STRING "" FORCE) + set(BYPRODUCT_SUFFIX ".a" CACHE STRING "" FORCE) + endif() + + set(BYPRODUCTS + "lib/${BYPRODUCT_PREFIX}mbedtls${BYPRODUCT_SUFFIX}" + "lib/${BYPRODUCT_PREFIX}mbedx509${BYPRODUCT_SUFFIX}" + "lib/${BYPRODUCT_PREFIX}mbedcrypto${BYPRODUCT_SUFFIX}" + ) + + set(MBEDTLS_BIN_DIR "${BINARY_DIR}/thirdparty/mbedtls-install" CACHE STRING "" FORCE) + + FOREACH(BYPRODUCT ${BYPRODUCTS}) + LIST(APPEND MBEDTLS_LIBRARIES_LIST "${MBEDTLS_BIN_DIR}/${BYPRODUCT}") + ENDFOREACH(BYPRODUCT) + + # Set build options + set(MBEDTLS_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${MBEDTLS_BIN_DIR}" + -DENABLE_PROGRAMS=OFF + -DENABLE_TESTING=OFF + ) - set(BYPRODUCTS - "lib/${BYPRODUCT_PREFIX}mbedtls${BYPRODUCT_SUFFIX}" - "lib/${BYPRODUCT_PREFIX}mbedx509${BYPRODUCT_SUFFIX}" - "lib/${BYPRODUCT_PREFIX}mbedcrypto${BYPRODUCT_SUFFIX}" - ) - - set(MBEDTLS_BIN_DIR "${BINARY_DIR}/thirdparty/mbedtls-install" CACHE STRING "" FORCE) - - FOREACH(BYPRODUCT ${BYPRODUCTS}) - LIST(APPEND MBEDTLS_LIBRARIES_LIST "${MBEDTLS_BIN_DIR}/${BYPRODUCT}") - ENDFOREACH(BYPRODUCT) - - # Set build options - set(MBEDTLS_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${MBEDTLS_BIN_DIR}" - -DENABLE_PROGRAMS=OFF - -DENABLE_TESTING=OFF - ) - - # Build project - ExternalProject_Add( - mbedtls-external - URL "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.3.tar.gz" - URL_HASH "SHA256=ec72ecf39275327f52b5ee9787271313a0d2960e7342b488d223a118ba164caa" - SOURCE_DIR "${BINARY_DIR}/thirdparty/mbedtls-src" - CMAKE_ARGS ${MBEDTLS_CMAKE_ARGS} - BUILD_BYPRODUCTS ${MBEDTLS_LIBRARIES_LIST} - EXCLUDE_FROM_ALL TRUE - ) - - # Set variables - set(MBEDTLS_FOUND "YES" CACHE STRING "" FORCE) - set(MBEDTLS_INCLUDE_DIRS "${MBEDTLS_BIN_DIR}/include" CACHE STRING "" FORCE) - set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARIES_LIST} CACHE STRING "" FORCE) - set(MBEDTLS_LIBRARY "${MBEDTLS_BIN_DIR}/lib/${BYPRODUCT_PREFIX}mbedtls${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) - set(MBEDX509_LIBRARY "${MBEDTLS_BIN_DIR}/lib/${BYPRODUCT_PREFIX}mbedx509${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) - set(MBEDCRYPTO_LIBRARY "${MBEDTLS_BIN_DIR}/lib/${BYPRODUCT_PREFIX}mbedcrypto${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) - - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDTLS_INCLUDE_DIRS=${MBEDTLS_INCLUDE_DIRS}" CACHE STRING "" FORCE) - string(REPLACE ";" "%" MBEDTLS_LIBRARIES_EXPORT "${MBEDTLS_LIBRARIES}") - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDTLS_LIBRARIES=${MBEDTLS_LIBRARIES_EXPORT}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDTLS_LIBRARY=${MBEDTLS_LIBRARY}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDX509_LIBRARY=${MBEDX509_LIBRARY}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDCRYPTO_LIBRARY=${MBEDCRYPTO_LIBRARY}" CACHE STRING "" FORCE) - - # Create imported targets - file(MAKE_DIRECTORY ${MBEDTLS_INCLUDE_DIRS}) - - add_library(mbedTLS::mbedcrypto STATIC IMPORTED) - set_target_properties(mbedTLS::mbedcrypto PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}") - set_target_properties(mbedTLS::mbedcrypto PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}") - add_dependencies(mbedTLS::mbedcrypto mbedtls-external) - - add_library(mbedTLS::mbedx509 STATIC IMPORTED) - set_target_properties(mbedTLS::mbedx509 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}") - set_target_properties(mbedTLS::mbedx509 PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${MBEDX509_LIBRARY}") - add_dependencies(mbedTLS::mbedx509 mbedtls-external) - set_property(TARGET mbedTLS::mbedx509 APPEND PROPERTY INTERFACE_LINK_LIBRARIES mbedTLS::mbedcrypto) - - add_library(mbedTLS::mbedtls STATIC IMPORTED) - set_target_properties(mbedTLS::mbedtls PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}") - set_target_properties(mbedTLS::mbedtls PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${MBEDTLS_LIBRARY}") - add_dependencies(mbedTLS::mbedtls mbedtls-external) - set_property(TARGET mbedTLS::mbedtls APPEND PROPERTY INTERFACE_LINK_LIBRARIES mbedTLS::mbedx509 mbedTLS::mbedcrypto) + # Build project + ExternalProject_Add( + mbedtls-external + URL "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.3.tar.gz" + URL_HASH "SHA256=ec72ecf39275327f52b5ee9787271313a0d2960e7342b488d223a118ba164caa" + SOURCE_DIR "${BINARY_DIR}/thirdparty/mbedtls-src" + CMAKE_ARGS ${MBEDTLS_CMAKE_ARGS} + BUILD_BYPRODUCTS ${MBEDTLS_LIBRARIES_LIST} + EXCLUDE_FROM_ALL TRUE + ) + + # Set variables + set(MBEDTLS_FOUND "YES" CACHE STRING "" FORCE) + set(MBEDTLS_INCLUDE_DIRS "${MBEDTLS_BIN_DIR}/include" CACHE STRING "" FORCE) + set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARIES_LIST} CACHE STRING "" FORCE) + set(MBEDTLS_LIBRARY "${MBEDTLS_BIN_DIR}/lib/${BYPRODUCT_PREFIX}mbedtls${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + set(MBEDX509_LIBRARY "${MBEDTLS_BIN_DIR}/lib/${BYPRODUCT_PREFIX}mbedx509${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + set(MBEDCRYPTO_LIBRARY "${MBEDTLS_BIN_DIR}/lib/${BYPRODUCT_PREFIX}mbedcrypto${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDTLS_INCLUDE_DIRS=${MBEDTLS_INCLUDE_DIRS}" CACHE STRING "" FORCE) + string(REPLACE ";" "%" MBEDTLS_LIBRARIES_EXPORT "${MBEDTLS_LIBRARIES}") + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDTLS_LIBRARIES=${MBEDTLS_LIBRARIES_EXPORT}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDTLS_LIBRARY=${MBEDTLS_LIBRARY}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDX509_LIBRARY=${MBEDX509_LIBRARY}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_MBEDCRYPTO_LIBRARY=${MBEDCRYPTO_LIBRARY}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${MBEDTLS_INCLUDE_DIRS}) + + add_library(mbedTLS::mbedcrypto STATIC IMPORTED) + set_target_properties(mbedTLS::mbedcrypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}") + set_target_properties(mbedTLS::mbedcrypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}") + add_dependencies(mbedTLS::mbedcrypto mbedtls-external) + + add_library(mbedTLS::mbedx509 STATIC IMPORTED) + set_target_properties(mbedTLS::mbedx509 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}") + set_target_properties(mbedTLS::mbedx509 PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${MBEDX509_LIBRARY}") + add_dependencies(mbedTLS::mbedx509 mbedtls-external) + set_property(TARGET mbedTLS::mbedx509 APPEND PROPERTY INTERFACE_LINK_LIBRARIES mbedTLS::mbedcrypto) + + add_library(mbedTLS::mbedtls STATIC IMPORTED) + set_target_properties(mbedTLS::mbedtls PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}") + set_target_properties(mbedTLS::mbedtls PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${MBEDTLS_LIBRARY}") + add_dependencies(mbedTLS::mbedtls mbedtls-external) + set_property(TARGET mbedTLS::mbedtls APPEND PROPERTY INTERFACE_LINK_LIBRARIES mbedTLS::mbedx509 mbedTLS::mbedcrypto) + endif() endfunction(use_bundled_mbedtls) diff --git a/cmake/BundledOpen62541.cmake b/cmake/BundledOpen62541.cmake index 56c75ea988..fa8703efbd 100644 --- a/cmake/BundledOpen62541.cmake +++ b/cmake/BundledOpen62541.cmake @@ -16,59 +16,71 @@ # under the License. function(use_bundled_open62541 SOURCE_DIR BINARY_DIR) - # Define patch step - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/open62541/open62541.patch") + message("Using bundled Open62541") - # Define byproducts - if (WIN32) - set(BYPRODUCT "lib/open62541.lib") - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - set(BYPRODUCT "${LIBDIR}/libopen62541.a") - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Open62541 external lib") + include(${CMAKE_BINARY_DIR}/open62541-config.cmake) + + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building Open62541 external lib") + + # Define patch step + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/open62541/all/patches/open62541.patch") + + # Define byproducts + if (WIN32) + set(BYPRODUCT "lib/open62541.lib") + else() + include(GNUInstallDirs) + string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) + list(GET LIBDIR_LIST 0 LIBDIR) + set(BYPRODUCT "${LIBDIR}/libopen62541.a") + endif() - # Set build options - set(OPEN62541_BYPRODUCT_DIR "${BINARY_DIR}/thirdparty/open62541-install") + # Set build options + set(OPEN62541_BYPRODUCT_DIR "${BINARY_DIR}/thirdparty/open62541-install") - set(OPEN62541_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${OPEN62541_BYPRODUCT_DIR}" - -DOPEN62541_VERSION=v1.3.3 - -DUA_ENABLE_ENCRYPTION=ON - -DUA_FORCE_WERROR=OFF) + set(OPEN62541_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${OPEN62541_BYPRODUCT_DIR}" + -DOPEN62541_VERSION=v1.3.3 + -DUA_ENABLE_ENCRYPTION=ON + -DUA_FORCE_WERROR=OFF) - append_third_party_passthrough_args(OPEN62541_CMAKE_ARGS "${OPEN62541_CMAKE_ARGS}") + append_third_party_passthrough_args(OPEN62541_CMAKE_ARGS "${OPEN62541_CMAKE_ARGS}") - # Build project - ExternalProject_Add( - open62541-external - URL "https://github.com/open62541/open62541/archive/v1.3.3.tar.gz" - URL_HASH "SHA256=52c049c0f107b4cc382c9e480d677a6360cdd96c472f84689af91b423bd108cb" - SOURCE_DIR "${BINARY_DIR}/thirdparty/open62541-src" - PATCH_COMMAND ${PC} - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${OPEN62541_CMAKE_ARGS} - BUILD_BYPRODUCTS "${OPEN62541_BYPRODUCT_DIR}/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + # Build project + ExternalProject_Add( + open62541-external + URL "https://github.com/open62541/open62541/archive/v1.3.3.tar.gz" + URL_HASH "SHA256=52c049c0f107b4cc382c9e480d677a6360cdd96c472f84689af91b423bd108cb" + SOURCE_DIR "${BINARY_DIR}/thirdparty/open62541-src" + PATCH_COMMAND ${PC} + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${OPEN62541_CMAKE_ARGS} + BUILD_BYPRODUCTS "${OPEN62541_BYPRODUCT_DIR}/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) - # Set dependencies - add_dependencies(open62541-external mbedTLS::mbedtls) + # Set dependencies + add_dependencies(open62541-external mbedTLS::mbedtls) - # Set variables - set(OPEN62541_FOUND "YES" CACHE STRING "" FORCE) - set(OPEN62541_INCLUDE_DIR "${OPEN62541_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) - set(OPEN62541_LIBRARY "${OPEN62541_BYPRODUCT_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) + # Set variables + set(OPEN62541_FOUND "YES" CACHE STRING "" FORCE) + set(OPEN62541_INCLUDE_DIR "${OPEN62541_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) + set(OPEN62541_LIBRARY "${OPEN62541_BYPRODUCT_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) - # Create imported targets - add_library(open62541::open62541 STATIC IMPORTED) - set_target_properties(open62541::open62541 PROPERTIES IMPORTED_LOCATION "${OPEN62541_LIBRARY}") - add_dependencies(open62541::open62541 open62541-external) - file(MAKE_DIRECTORY ${OPEN62541_INCLUDE_DIR}) - set_property(TARGET open62541::open62541 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OPEN62541_INCLUDE_DIR}) - set_property(TARGET open62541::open62541 APPEND PROPERTY INTERFACE_LINK_LIBRARIES mbedTLS::mbedtls Threads::Threads) - if(WIN32) - set_property(TARGET open62541::open62541 APPEND PROPERTY INTERFACE_LINK_LIBRARIES Ws2_32.lib Iphlpapi.lib) + # Create imported targets + add_library(open62541::open62541 STATIC IMPORTED) + set_target_properties(open62541::open62541 PROPERTIES IMPORTED_LOCATION "${OPEN62541_LIBRARY}") + add_dependencies(open62541::open62541 open62541-external) + + file(MAKE_DIRECTORY ${OPEN62541_INCLUDE_DIR}) + set_property(TARGET open62541::open62541 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OPEN62541_INCLUDE_DIR}) + set_property(TARGET open62541::open62541 APPEND PROPERTY INTERFACE_LINK_LIBRARIES mbedTLS::mbedtls Threads::Threads) + if(WIN32) + set_property(TARGET open62541::open62541 APPEND PROPERTY INTERFACE_LINK_LIBRARIES Ws2_32.lib Iphlpapi.lib) + endif() endif() endfunction(use_bundled_open62541) diff --git a/cmake/BundledOpenCV.cmake b/cmake/BundledOpenCV.cmake index ee4a7ff94b..ac046afdc8 100644 --- a/cmake/BundledOpenCV.cmake +++ b/cmake/BundledOpenCV.cmake @@ -16,196 +16,207 @@ # under the License. function(use_bundled_opencv SOURCE_DIR BINARY_DIR) - if (WIN32) - set(LIBDIR "lib") - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - endif() - - # Define byproducts - if (WIN32) - set(SUFFIX "410.lib") - set(THIRDPARTY_SUFFIX ".lib") - set(PREFIX "") - set(THIRDPARTY_DIR "") - else() - set(SUFFIX ".a") - set(THIRDPARTY_SUFFIX ".a") - set(PREFIX "lib") - set(THIRDPARTY_DIR "opencv4/3rdparty/") - endif() - - set(OPENCV_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/opencv-install") - set(BYPRODUCTS - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_flann${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_core${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_photo${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_video${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}" - "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}") - - # Set build options - set(OPENCV_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${OPENCV_BYPRODUCT_DIR}" - "-DBUILD_SHARED_LIBS=OFF" - "-DBUILD_WITH_STATIC_CRT=OFF" - "-DBUILD_EXAMPLES=OFF" - "-DBUILD_DOCS=OFF" - "-DBUILD_PACKAGE=OFF" - "-DBUILD_opencv_apps=OFF" - "-DBUILD_PERF_TESTS=OFF" - "-DBUILD_TESTS=OFF" - "-DBUILD_opencv_calib3d=ON" - "-DBUILD_opencv_core=ON" - "-DBUILD_opencv_dnn=OFF" - "-DBUILD_opencv_features2d=ON" - "-DBUILD_opencv_flann=ON" - "-DBUILD_opencv_gapi=ON" - "-DBUILD_opencv_highgui=OFF" - "-DBUILD_opencv_imgcodecs=ON" - "-DBUILD_opencv_imgproc=ON" - "-DBUILD_opencv_ml=OFF" - "-DBUILD_opencv_objdetect=ON" - "-DBUILD_opencv_photo=ON" - "-DBUILD_opencv_stitching=ON" - "-DBUILD_opencv_video=ON" - "-DBUILD_opencv_videoio=ON" - "-DBUILD_JAVA=OFF" - "-DBUILD_FAT_JAVA_LIB=OFF" - "-DBUILD_PNG=ON" - "-DBUILD_JPEG=ON" - "-DBUILD_OPENJPEG=OFF" - "-DWITH_1394=OFF" - "-DWITH_FFMPEG=OFF" - "-DWITH_GSTREAMER=OFF" - "-DWITH_GTK=OFF" - "-DWITH_IPP=OFF" - "-DWITH_JASPER=OFF" - "-DWITH_ITT=OFF" - "-DWITH_OPENEXR=OFF" - "-DWITH_WEBP=OFF" - "-DWITH_OPENJPEG=OFF" - "-DWITH_TIFF=OFF" - "-DWITH_CAROTENE=OFF" - "-DWITH_PROTOBUF=OFF" - ) - - append_third_party_passthrough_args(OPENCV_CMAKE_ARGS "${OPENCV_CMAKE_ARGS}") - - # Build project - ExternalProject_Add( - opencv-external - URL "https://github.com/opencv/opencv/archive/refs/tags/4.7.0.tar.gz" - URL_HASH "SHA256=8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973" - SOURCE_DIR "${BINARY_DIR}/thirdparty/opencv-src" - CMAKE_ARGS ${OPENCV_CMAKE_ARGS} - BUILD_BYPRODUCTS "${BYPRODUCTS}" - EXCLUDE_FROM_ALL TRUE - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - ) - - # Set variables - set(OPENCV_FOUND "YES" CACHE STRING "" FORCE) - if (WIN32) - set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) - else() - set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include/opencv4" CACHE STRING "" FORCE) - endif() - set(OPENCV_LIBRARIES "${BYPRODUCTS}" CACHE STRING "" FORCE) - - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_INCLUDE_DIR=${OPENCV_INCLUDE_DIR}" CACHE STRING "" FORCE) - string(REPLACE ";" "%" OPENCV_LIBRARIES_EXPORT "${OPENCV_LIBRARIES}") - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_LIBRARIES=${OPENCV_LIBRARIES_EXPORT}" CACHE STRING "" FORCE) - - # Create imported targets - file(MAKE_DIRECTORY ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libjpeg-turbo STATIC IMPORTED) - set_target_properties(OPENCV::libjpeg-turbo PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}") - add_dependencies(OPENCV::libjpeg-turbo opencv-external) - - add_library(OPENCV::libpng STATIC IMPORTED) - set_target_properties(OPENCV::libpng PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}") - add_dependencies(OPENCV::libpng opencv-external) - - add_library(OPENCV::libopencv-core STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-core PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_core${SUFFIX}") - add_dependencies(OPENCV::libopencv-core opencv-external ZLIB::ZLIB) - target_include_directories(OPENCV::libopencv-core INTERFACE ${OPENCV_INCLUDE_DIR}) - target_link_libraries(OPENCV::libopencv-core INTERFACE ZLIB::ZLIB) - - add_library(OPENCV::libopencv-flann STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-flann PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_flann${SUFFIX}") - add_dependencies(OPENCV::libopencv-flann opencv-external) - target_include_directories(OPENCV::libopencv-flann INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv-objdetect STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-objdetect PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}") - add_dependencies(OPENCV::libopencv-objdetect opencv-external) - target_include_directories(OPENCV::libopencv-objdetect INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv-gapi STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-gapi PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}") - add_dependencies(OPENCV::libopencv-gapi opencv-external) - target_include_directories(OPENCV::libopencv-gapi INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv-imgcodecs STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-imgcodecs PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}") - add_dependencies(OPENCV::libopencv-imgcodecs opencv-external) - target_include_directories(OPENCV::libopencv-imgcodecs INTERFACE ${OPENCV_INCLUDE_DIR}) - target_link_libraries(OPENCV::libopencv-imgcodecs INTERFACE OPENCV::libopencv-core OPENCV::libjpeg-turbo OPENCV::libpng) - - add_library(OPENCV::libopencv-calib3d STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-calib3d PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}") - add_dependencies(OPENCV::libopencv-calib3d opencv-external) - target_include_directories(OPENCV::libopencv-calib3d INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv-imgproc STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-imgproc PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}") - add_dependencies(OPENCV::libopencv-imgproc opencv-external) - target_include_directories(OPENCV::libopencv-imgproc INTERFACE ${OPENCV_INCLUDE_DIR}) - target_link_libraries(OPENCV::libopencv-imgproc INTERFACE OPENCV::libopencv-core) - - add_library(OPENCV::libopencv-photo STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-photo PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_photo${SUFFIX}") - add_dependencies(OPENCV::libopencv-photo opencv-external) - target_include_directories(OPENCV::libopencv-photo INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv-videoio STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-videoio PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}") - add_dependencies(OPENCV::libopencv-videoio opencv-external) - target_include_directories(OPENCV::libopencv-videoio INTERFACE ${OPENCV_INCLUDE_DIR}) - target_link_libraries(OPENCV::libopencv-videoio INTERFACE OPENCV::libopencv-core) - - add_library(OPENCV::libopencv-video STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-video PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_video${SUFFIX}") - add_dependencies(OPENCV::libopencv-video opencv-external) - target_include_directories(OPENCV::libopencv-video INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv-stitching STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-stitching PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}") - add_dependencies(OPENCV::libopencv-stitching opencv-external) - target_include_directories(OPENCV::libopencv-stitching INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv-features2d STATIC IMPORTED) - set_target_properties(OPENCV::libopencv-features2d PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}") - add_dependencies(OPENCV::libopencv-features2d opencv-external) - target_include_directories(OPENCV::libopencv-features2d INTERFACE ${OPENCV_INCLUDE_DIR}) - - add_library(OPENCV::libopencv INTERFACE IMPORTED) - target_link_libraries(OPENCV::libopencv INTERFACE OPENCV::libopencv-flann OPENCV::libopencv-objdetect OPENCV::libopencv-core OPENCV::libopencv-gapi OPENCV::libopencv-imgcodecs OPENCV::libopencv-calib3d OPENCV::libopencv-imgproc OPENCV::libopencv-photo OPENCV::libopencv-videoio OPENCV::libopencv-video OPENCV::libopencv-stitching OPENCV::libopencv-features2d) - if (APPLE) - target_link_libraries(OPENCV::libopencv INTERFACE "-framework AVFoundation" "-framework CoreFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo" "-framework Foundation" "-framework OpenCL" "-framework Accelerate") + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt OpenCV external lib") + include(${CMAKE_BINARY_DIR}/OpenCVConfig.cmake) + + add_library(OPENCV::libopencv ALIAS opencv::opencv) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building OpenCV external lib") + + + if (WIN32) + set(LIBDIR "lib") + else() + include(GNUInstallDirs) + string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) + list(GET LIBDIR_LIST 0 LIBDIR) + endif() + + # Define byproducts + if (WIN32) + set(SUFFIX "410.lib") + set(THIRDPARTY_SUFFIX ".lib") + set(PREFIX "") + set(THIRDPARTY_DIR "") + else() + set(SUFFIX ".a") + set(THIRDPARTY_SUFFIX ".a") + set(PREFIX "lib") + set(THIRDPARTY_DIR "opencv4/3rdparty/") + endif() + + set(OPENCV_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/opencv-install") + set(BYPRODUCTS + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_flann${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_core${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_photo${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_video${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}" + "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}") + + # Set build options + set(OPENCV_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${OPENCV_BYPRODUCT_DIR}" + "-DBUILD_SHARED_LIBS=OFF" + "-DBUILD_WITH_STATIC_CRT=OFF" + "-DBUILD_EXAMPLES=OFF" + "-DBUILD_DOCS=OFF" + "-DBUILD_PACKAGE=OFF" + "-DBUILD_opencv_apps=OFF" + "-DBUILD_PERF_TESTS=OFF" + "-DBUILD_TESTS=OFF" + "-DBUILD_opencv_calib3d=ON" + "-DBUILD_opencv_core=ON" + "-DBUILD_opencv_dnn=OFF" + "-DBUILD_opencv_features2d=ON" + "-DBUILD_opencv_flann=ON" + "-DBUILD_opencv_gapi=ON" + "-DBUILD_opencv_highgui=OFF" + "-DBUILD_opencv_imgcodecs=ON" + "-DBUILD_opencv_imgproc=ON" + "-DBUILD_opencv_ml=OFF" + "-DBUILD_opencv_objdetect=ON" + "-DBUILD_opencv_photo=ON" + "-DBUILD_opencv_stitching=ON" + "-DBUILD_opencv_video=ON" + "-DBUILD_opencv_videoio=ON" + "-DBUILD_JAVA=OFF" + "-DBUILD_FAT_JAVA_LIB=OFF" + "-DBUILD_PNG=ON" + "-DBUILD_JPEG=ON" + "-DBUILD_OPENJPEG=OFF" + "-DWITH_1394=OFF" + "-DWITH_FFMPEG=OFF" + "-DWITH_GSTREAMER=OFF" + "-DWITH_GTK=OFF" + "-DWITH_IPP=OFF" + "-DWITH_JASPER=OFF" + "-DWITH_ITT=OFF" + "-DWITH_OPENEXR=OFF" + "-DWITH_WEBP=OFF" + "-DWITH_OPENJPEG=OFF" + "-DWITH_TIFF=OFF" + "-DWITH_CAROTENE=OFF" + "-DWITH_PROTOBUF=OFF" + ) + + append_third_party_passthrough_args(OPENCV_CMAKE_ARGS "${OPENCV_CMAKE_ARGS}") + + # Build project + ExternalProject_Add( + opencv-external + URL "https://github.com/opencv/opencv/archive/refs/tags/4.7.0.tar.gz" + URL_HASH "SHA256=8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973" + SOURCE_DIR "${BINARY_DIR}/thirdparty/opencv-src" + CMAKE_ARGS ${OPENCV_CMAKE_ARGS} + BUILD_BYPRODUCTS "${BYPRODUCTS}" + EXCLUDE_FROM_ALL TRUE + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + ) + + # Set variables + set(OPENCV_FOUND "YES" CACHE STRING "" FORCE) + if (WIN32) + set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) + else() + set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include/opencv4" CACHE STRING "" FORCE) + endif() + set(OPENCV_LIBRARIES "${BYPRODUCTS}" CACHE STRING "" FORCE) + + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_INCLUDE_DIR=${OPENCV_INCLUDE_DIR}" CACHE STRING "" FORCE) + string(REPLACE ";" "%" OPENCV_LIBRARIES_EXPORT "${OPENCV_LIBRARIES}") + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_LIBRARIES=${OPENCV_LIBRARIES_EXPORT}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libjpeg-turbo STATIC IMPORTED) + set_target_properties(OPENCV::libjpeg-turbo PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}") + add_dependencies(OPENCV::libjpeg-turbo opencv-external) + + add_library(OPENCV::libpng STATIC IMPORTED) + set_target_properties(OPENCV::libpng PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}") + add_dependencies(OPENCV::libpng opencv-external) + + add_library(OPENCV::libopencv-core STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-core PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_core${SUFFIX}") + add_dependencies(OPENCV::libopencv-core opencv-external ZLIB::ZLIB) + target_include_directories(OPENCV::libopencv-core INTERFACE ${OPENCV_INCLUDE_DIR}) + target_link_libraries(OPENCV::libopencv-core INTERFACE ZLIB::ZLIB) + + add_library(OPENCV::libopencv-flann STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-flann PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_flann${SUFFIX}") + add_dependencies(OPENCV::libopencv-flann opencv-external) + target_include_directories(OPENCV::libopencv-flann INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv-objdetect STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-objdetect PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}") + add_dependencies(OPENCV::libopencv-objdetect opencv-external) + target_include_directories(OPENCV::libopencv-objdetect INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv-gapi STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-gapi PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}") + add_dependencies(OPENCV::libopencv-gapi opencv-external) + target_include_directories(OPENCV::libopencv-gapi INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv-imgcodecs STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-imgcodecs PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}") + add_dependencies(OPENCV::libopencv-imgcodecs opencv-external) + target_include_directories(OPENCV::libopencv-imgcodecs INTERFACE ${OPENCV_INCLUDE_DIR}) + target_link_libraries(OPENCV::libopencv-imgcodecs INTERFACE OPENCV::libopencv-core OPENCV::libjpeg-turbo OPENCV::libpng) + + add_library(OPENCV::libopencv-calib3d STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-calib3d PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}") + add_dependencies(OPENCV::libopencv-calib3d opencv-external) + target_include_directories(OPENCV::libopencv-calib3d INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv-imgproc STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-imgproc PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}") + add_dependencies(OPENCV::libopencv-imgproc opencv-external) + target_include_directories(OPENCV::libopencv-imgproc INTERFACE ${OPENCV_INCLUDE_DIR}) + target_link_libraries(OPENCV::libopencv-imgproc INTERFACE OPENCV::libopencv-core) + + add_library(OPENCV::libopencv-photo STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-photo PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_photo${SUFFIX}") + add_dependencies(OPENCV::libopencv-photo opencv-external) + target_include_directories(OPENCV::libopencv-photo INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv-videoio STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-videoio PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}") + add_dependencies(OPENCV::libopencv-videoio opencv-external) + target_include_directories(OPENCV::libopencv-videoio INTERFACE ${OPENCV_INCLUDE_DIR}) + target_link_libraries(OPENCV::libopencv-videoio INTERFACE OPENCV::libopencv-core) + + add_library(OPENCV::libopencv-video STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-video PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_video${SUFFIX}") + add_dependencies(OPENCV::libopencv-video opencv-external) + target_include_directories(OPENCV::libopencv-video INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv-stitching STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-stitching PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}") + add_dependencies(OPENCV::libopencv-stitching opencv-external) + target_include_directories(OPENCV::libopencv-stitching INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv-features2d STATIC IMPORTED) + set_target_properties(OPENCV::libopencv-features2d PROPERTIES IMPORTED_LOCATION "${OPENCV_BYPRODUCT_DIR}/${LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}") + add_dependencies(OPENCV::libopencv-features2d opencv-external) + target_include_directories(OPENCV::libopencv-features2d INTERFACE ${OPENCV_INCLUDE_DIR}) + + add_library(OPENCV::libopencv INTERFACE IMPORTED) + target_link_libraries(OPENCV::libopencv INTERFACE OPENCV::libopencv-flann OPENCV::libopencv-objdetect OPENCV::libopencv-core OPENCV::libopencv-gapi OPENCV::libopencv-imgcodecs OPENCV::libopencv-calib3d OPENCV::libopencv-imgproc OPENCV::libopencv-photo OPENCV::libopencv-videoio OPENCV::libopencv-video OPENCV::libopencv-stitching OPENCV::libopencv-features2d) + if (APPLE) + target_link_libraries(OPENCV::libopencv INTERFACE "-framework AVFoundation" "-framework CoreFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo" "-framework Foundation" "-framework OpenCL" "-framework Accelerate") + endif() endif() endfunction(use_bundled_opencv) diff --git a/cmake/BundledOpenSSL.cmake b/cmake/BundledOpenSSL.cmake index 7a429a9f54..6aecd4dd7d 100644 --- a/cmake/BundledOpenSSL.cmake +++ b/cmake/BundledOpenSSL.cmake @@ -18,120 +18,128 @@ function(use_openssl SOURCE_DIR BINARY_DIR) message("Using bundled OpenSSL") - if(APPLE OR WIN32 OR CMAKE_SIZEOF_VOID_P EQUAL 4 OR CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)|(aarch64)|(armv8)") - set(LIBDIR "lib") - else() - set(LIBDIR "lib64") - endif() - - # Define byproducts - set(BYPRODUCT_PREFIX "lib" CACHE STRING "" FORCE) - set(OPENSSL_BUILD_SHARED "NO" CACHE STRING "" FORCE) - - if (WIN32) - set(BYPRODUCT_SUFFIX ".lib" CACHE STRING "" FORCE) - # Due to OpenSSL 3's static linking issue on x86 MacOS platform we make an exception to build a shared library instead - elseif (APPLE AND (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")) - set(BYPRODUCT_SUFFIX ".dylib" CACHE STRING "" FORCE) - set(OPENSSL_BUILD_SHARED "YES" CACHE STRING "" FORCE) - else() - set(BYPRODUCT_SUFFIX ".a" CACHE STRING "" FORCE) - endif() - - set(BYPRODUCTS - "${LIBDIR}/${BYPRODUCT_PREFIX}ssl${BYPRODUCT_SUFFIX}" - "${LIBDIR}/${BYPRODUCT_PREFIX}crypto${BYPRODUCT_SUFFIX}" - ) - - if (OPENSSL_BUILD_SHARED) - set(OPENSSL_SHARED_FLAG "" CACHE STRING "" FORCE) - else() - set(OPENSSL_SHARED_FLAG "no-shared" CACHE STRING "" FORCE) - endif() - - set(OPENSSL_BIN_DIR "${BINARY_DIR}/thirdparty/openssl-install" CACHE STRING "" FORCE) - - FOREACH(BYPRODUCT ${BYPRODUCTS}) - LIST(APPEND OPENSSL_LIBRARIES_LIST "${OPENSSL_BIN_DIR}/${BYPRODUCT}") - ENDFOREACH(BYPRODUCT) - - if (OPENSSL_BUILD_SHARED) - install(FILES ${OPENSSL_LIBRARIES_LIST} DESTINATION bin COMPONENT bin) - endif() - - # Set build options - set(OPENSSL_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${OPENSSL_BIN_DIR}" - "-DCMAKE_POLICY_DEFAULT_CMP0063=NEW" - # avoid polluting the global namespace, otherwise could interfere with the system openssl (e.g. python script extension using numpy) - "-DCMAKE_C_VISIBILITY_PRESET=hidden" - "-DCMAKE_CXX_VISIBILITY_PRESET=hidden" - "-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON" + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt OpenSSL external lib") + include(${CMAKE_BINARY_DIR}/OpenSSLConfig.cmake) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building OpenSSL external lib") + + + if(APPLE OR WIN32 OR CMAKE_SIZEOF_VOID_P EQUAL 4 OR CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)|(aarch64)|(armv8)") + set(LIBDIR "lib") + else() + set(LIBDIR "lib64") + endif() + + # Define byproducts + set(BYPRODUCT_PREFIX "lib" CACHE STRING "" FORCE) + set(OPENSSL_BUILD_SHARED "NO" CACHE STRING "" FORCE) + + if (WIN32) + set(BYPRODUCT_SUFFIX ".lib" CACHE STRING "" FORCE) + # Due to OpenSSL 3's static linking issue on x86 MacOS platform we make an exception to build a shared library instead + elseif (APPLE AND (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")) + set(BYPRODUCT_SUFFIX ".dylib" CACHE STRING "" FORCE) + set(OPENSSL_BUILD_SHARED "YES" CACHE STRING "" FORCE) + else() + set(BYPRODUCT_SUFFIX ".a" CACHE STRING "" FORCE) + endif() + + set(BYPRODUCTS + "${LIBDIR}/${BYPRODUCT_PREFIX}ssl${BYPRODUCT_SUFFIX}" + "${LIBDIR}/${BYPRODUCT_PREFIX}crypto${BYPRODUCT_SUFFIX}" + ) + + if (OPENSSL_BUILD_SHARED) + set(OPENSSL_SHARED_FLAG "" CACHE STRING "" FORCE) + else() + set(OPENSSL_SHARED_FLAG "no-shared" CACHE STRING "" FORCE) + endif() + + set(OPENSSL_BIN_DIR "${BINARY_DIR}/thirdparty/openssl-install" CACHE STRING "" FORCE) + + FOREACH(BYPRODUCT ${BYPRODUCTS}) + LIST(APPEND OPENSSL_LIBRARIES_LIST "${OPENSSL_BIN_DIR}/${BYPRODUCT}") + ENDFOREACH(BYPRODUCT) + + if (OPENSSL_BUILD_SHARED) + install(FILES ${OPENSSL_LIBRARIES_LIST} DESTINATION bin COMPONENT bin) + endif() + + # Set build options + set(OPENSSL_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${OPENSSL_BIN_DIR}" + "-DCMAKE_POLICY_DEFAULT_CMP0063=NEW" + # avoid polluting the global namespace, otherwise could interfere with the system openssl (e.g. python script extension using numpy) + "-DCMAKE_C_VISIBILITY_PRESET=hidden" + "-DCMAKE_CXX_VISIBILITY_PRESET=hidden" + "-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON" + ) + + if (WIN32) + ExternalProject_Add( + openssl-external + URL https://github.com/openssl/openssl/releases/download/openssl-3.3.0/openssl-3.3.0.tar.gz + URL_HASH "SHA256=53e66b043322a606abf0087e7699a0e033a37fa13feb9742df35c3a33b18fb02" + SOURCE_DIR "${BINARY_DIR}/thirdparty/openssl-src" + BUILD_IN_SOURCE true + CONFIGURE_COMMAND perl Configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS}" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS}" ${OPENSSL_SHARED_FLAG} no-tests "--prefix=${OPENSSL_BIN_DIR}" "--openssldir=${OPENSSL_BIN_DIR}" + BUILD_BYPRODUCTS ${OPENSSL_LIBRARIES_LIST} + EXCLUDE_FROM_ALL TRUE + BUILD_COMMAND nmake + INSTALL_COMMAND nmake install + ) + else() + ExternalProject_Add( + openssl-external + URL https://github.com/openssl/openssl/releases/download/openssl-3.3.0/openssl-3.3.0.tar.gz + URL_HASH "SHA256=53e66b043322a606abf0087e7699a0e033a37fa13feb9742df35c3a33b18fb02" + SOURCE_DIR "${BINARY_DIR}/thirdparty/openssl-src" + BUILD_IN_SOURCE true + CONFIGURE_COMMAND ./Configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS} -fPIC" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS} -fPIC" ${OPENSSL_SHARED_FLAG} no-tests "--prefix=${OPENSSL_BIN_DIR}" "--openssldir=${OPENSSL_BIN_DIR}" + BUILD_BYPRODUCTS ${OPENSSL_LIBRARIES_LIST} + EXCLUDE_FROM_ALL TRUE ) - - # Note: when upgrading to a later release than 3.1.1 the --no-apps could be used instead of --no-tests to minimize the build size - if (WIN32) - ExternalProject_Add( - openssl-external - URL https://github.com/openssl/openssl/releases/download/openssl-3.3.0/openssl-3.3.0.tar.gz - URL_HASH "SHA256=53e66b043322a606abf0087e7699a0e033a37fa13feb9742df35c3a33b18fb02" - SOURCE_DIR "${BINARY_DIR}/thirdparty/openssl-src" - BUILD_IN_SOURCE true - CONFIGURE_COMMAND perl Configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS}" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS}" ${OPENSSL_SHARED_FLAG} no-tests "--prefix=${OPENSSL_BIN_DIR}" "--openssldir=${OPENSSL_BIN_DIR}" - BUILD_BYPRODUCTS ${OPENSSL_LIBRARIES_LIST} - EXCLUDE_FROM_ALL TRUE - BUILD_COMMAND nmake - INSTALL_COMMAND nmake install - ) - else() - ExternalProject_Add( - openssl-external - URL https://github.com/openssl/openssl/releases/download/openssl-3.3.0/openssl-3.3.0.tar.gz - URL_HASH "SHA256=53e66b043322a606abf0087e7699a0e033a37fa13feb9742df35c3a33b18fb02" - SOURCE_DIR "${BINARY_DIR}/thirdparty/openssl-src" - BUILD_IN_SOURCE true - CONFIGURE_COMMAND ./Configure "CFLAGS=${PASSTHROUGH_CMAKE_C_FLAGS} -fPIC" "CXXFLAGS=${PASSTHROUGH_CMAKE_CXX_FLAGS} -fPIC" ${OPENSSL_SHARED_FLAG} no-tests "--prefix=${OPENSSL_BIN_DIR}" "--openssldir=${OPENSSL_BIN_DIR}" - BUILD_BYPRODUCTS ${OPENSSL_LIBRARIES_LIST} - EXCLUDE_FROM_ALL TRUE - ) - endif() - - # Set variables - set(OPENSSL_FOUND "YES" CACHE STRING "" FORCE) - set(OPENSSL_INCLUDE_DIR "${OPENSSL_BIN_DIR}/include" CACHE STRING "" FORCE) - set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES_LIST};${CMAKE_DL_LIBS}" CACHE STRING "" FORCE) - set(OPENSSL_CRYPTO_LIBRARY "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}crypto${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) - set(OPENSSL_SSL_LIBRARY "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}ssl${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) - - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}" CACHE STRING "" FORCE) - string(REPLACE ";" "%" OPENSSL_LIBRARIES_EXPORT "${OPENSSL_LIBRARIES}") - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_EXPORT}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY}" CACHE STRING "" FORCE) - - # Create imported targets - file(MAKE_DIRECTORY ${OPENSSL_INCLUDE_DIR}) - - add_library(OpenSSL::Crypto STATIC IMPORTED) - set_target_properties(OpenSSL::Crypto PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") - set_target_properties(OpenSSL::Crypto PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}crypto${BYPRODUCT_SUFFIX}") - add_dependencies(OpenSSL::Crypto openssl-external) - - add_library(OpenSSL::SSL STATIC IMPORTED) - set_target_properties(OpenSSL::SSL PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") - set_target_properties(OpenSSL::SSL PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}ssl${BYPRODUCT_SUFFIX}") - add_dependencies(OpenSSL::SSL openssl-external) - set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) - - if(WIN32) - set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32.lib ) - set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32.lib) + endif() + + # Set variables + set(OPENSSL_FOUND "YES" CACHE STRING "" FORCE) + set(OPENSSL_INCLUDE_DIR "${OPENSSL_BIN_DIR}/include" CACHE STRING "" FORCE) + set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES_LIST};${CMAKE_DL_LIBS}" CACHE STRING "" FORCE) + set(OPENSSL_CRYPTO_LIBRARY "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}crypto${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + set(OPENSSL_SSL_LIBRARY "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}ssl${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}" CACHE STRING "" FORCE) + string(REPLACE ";" "%" OPENSSL_LIBRARIES_EXPORT "${OPENSSL_LIBRARIES}") + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_EXPORT}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${OPENSSL_INCLUDE_DIR}) + + add_library(OpenSSL::Crypto STATIC IMPORTED) + set_target_properties(OpenSSL::Crypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}crypto${BYPRODUCT_SUFFIX}") + add_dependencies(OpenSSL::Crypto openssl-external) + + add_library(OpenSSL::SSL STATIC IMPORTED) + set_target_properties(OpenSSL::SSL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${OPENSSL_BIN_DIR}/${LIBDIR}/${BYPRODUCT_PREFIX}ssl${BYPRODUCT_SUFFIX}") + add_dependencies(OpenSSL::SSL openssl-external) + set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) + + if(WIN32) + set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32.lib ) + set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32.lib) + endif() endif() endfunction(use_openssl) diff --git a/cmake/BundledPcapPlusPlus.cmake b/cmake/BundledPcapPlusPlus.cmake new file mode 100644 index 0000000000..4b08ac1178 --- /dev/null +++ b/cmake/BundledPcapPlusPlus.cmake @@ -0,0 +1,158 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. See the License for the +# specific language governing permissions and limitations +# under the License. +function(use_bundled_pcapplusplus SOURCE_DIR BINARY_DIR) + message("Using bundled pcapplusplus") + + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt PcapPlusPlus external lib") + include(${CMAKE_BINARY_DIR}/pcapplusplus-config.cmake) + + set(PCAPPLUSPLUS_LIBRARIES "${pcapplusplus_LIBRARIES}") + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building PcapPlusPlus external lib") + + find_package(PCAP REQUIRED) + + # Define byproducts + if (WIN32) + set(BYPRODUCT1 "lib/Pcap++.lib") + set(BYPRODUCT2 "lib/Packet++.lib") + set(BYPRODUCT3 "lib/Common++.lib") + elseif (APPLE) + set(BYPRODUCT1 "lib/Plibcap++.a") + set(BYPRODUCT2 "lib/libPacket++.a") + set(BYPRODUCT3 "lib/libCommon++.a") + else () + set(BYPRODUCT1 "lib/libPcap++.a") + set(BYPRODUCT2 "lib/libPacket++.a") + set(BYPRODUCT3 "lib/libCommon++.a") + endif () + + list(APPEND PCAPPLUSPLUS_BYPRODUCTS "${BINARY_DIR}/thirdparty/pcapplusplus-install/${BYPRODUCT1}" "${BINARY_DIR}/thirdparty/pcapplusplus-install/${BYPRODUCT2}" "${BINARY_DIR}/thirdparty/pcapplusplus-install/${BYPRODUCT3}") + + set(PCAPPLUSPLUS_URL https://github.com/seladb/PcapPlusPlus/archive/v22.05.tar.gz) + set(PCAPPLUSPLUS_URL_HASH "SHA256=5f299c4503bf5d3c29f82b8d876a19be7dea29c2aadcb52f2f3b394846c21da9") + + # Set build options + set(PCAPPLUSPLUS_BIN_DIR "${BINARY_DIR}/thirdparty/pcapplusplus-install" CACHE STRING "" FORCE) + + append_third_party_passthrough_args(PCAPPLUSPLUS_CMAKE_ARGS "${PCAPPLUSPLUS_CMAKE_ARGS}") + + if(TARGET PCAP::PCAP) + message("Adding PCAP::PCAP as dependency to pcapplusplus-external") + else() + message("PCAP::PCAP target not found, so cant add as dependency to pcapplusplus-external") + endif() + + # Create install directory before ExternalProject_Add + file(MAKE_DIRECTORY ${PCAPPLUSPLUS_BIN_DIR}) + + + if (WIN32) + # NOTE (JG): Originally, while we could run windows configure bat script, we still compiled libs for Linux or Mac + # However, with the conan package approach for building pcapplusplus, we can add support for windows much easier + ExternalProject_Add( + pcapplusplus-external + URL ${PCAPPLUSPLUS_URL} + URL_HASH ${PCAPPLUSPLUS_URL_HASH} + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${PCAPPLUSPLUS_CMAKE_ARGS} + CONFIGURE_COMMAND "" + PATCH_COMMAND configure-windows-visual-studio.bat --install-dir=${BINARY_DIR}/thirdparty/pcapplusplus-install --libpcap-include-dir=${PCAP_INCLUDE_DIR} --libpcap-lib-dir=${PCAP_LIBRARY} + BUILD_BYPRODUCTS ${PCAPPLUSPLUS_BYPRODUCTS} + EXCLUDE_FROM_ALL TRUE + ) + elseif (APPLE) + ExternalProject_Add( + pcapplusplus-external + URL ${PCAPPLUSPLUS_URL} + URL_HASH ${PCAPPLUSPLUS_URL_HASH} + CMAKE_ARGS ${PCAPPLUSPLUS_CMAKE_ARGS} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/pcapplusplus-src" + INSTALL_DIR "${BINARY_DIR}/thirdparty/pcapplusplus-install" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + BUILD_COMMAND make + CMAKE_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND make install + BUILD_BYPRODUCTS ${PCAPPLUSPLUS_BYPRODUCTS} + CONFIGURE_COMMAND "" + PATCH_COMMAND ./configure-mac_os_x.sh --install-dir=${BINARY_DIR}/thirdparty/pcapplusplus-install --libpcap-include-dir=${PCAP_INCLUDE_DIR} --libpcap-lib-dir=${PCAP_LIBRARY} + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + ) + else() + ExternalProject_Add( + pcapplusplus-external + URL ${PCAPPLUSPLUS_URL} + URL_HASH ${PCAPPLUSPLUS_URL_HASH} + CMAKE_ARGS ${PCAPPLUSPLUS_CMAKE_ARGS} + BUILD_IN_SOURCE true + SOURCE_DIR "${BINARY_DIR}/thirdparty/pcapplusplus-src" + INSTALL_DIR "${BINARY_DIR}/thirdparty/pcapplusplus-install" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + BUILD_COMMAND make + CMAKE_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND make install + BUILD_BYPRODUCTS ${PCAPPLUSPLUS_BYPRODUCTS} + CONFIGURE_COMMAND "" + PATCH_COMMAND ./configure-linux.sh --install-dir=${BINARY_DIR}/thirdparty/pcapplusplus-install --libpcap-include-dir=${PCAP_INCLUDE_DIR} --libpcap-lib-dir=${PCAP_LIBRARY} + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + ) + endif() + + add_dependencies(pcapplusplus-external libpcap-external) + + + # Set variables + set(PCAPPLUSPLUS_FOUND "YES" CACHE STRING "" FORCE) + set(PCAPPLUSPLUS_INCLUDE_DIRS + "${BINARY_DIR}/thirdparty/pcapplusplus-install/include" + "${BINARY_DIR}/thirdparty/pcapplusplus-install/include/pcapplusplus" CACHE STRING "" FORCE) + set(PCAPPLUSPLUS_LIBRARY ${PCAPPLUSPLUS_BYPRODUCTS} CACHE STRING "" FORCE) + set(PCAPPLUSPLUS_LIBRARIES "${PCAPPLUSPLUS_LIBRARY}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${PCAPPLUSPLUS_INCLUDE_DIRS}) + + add_library(pcapplusplus::Pcap++ STATIC IMPORTED) + set_target_properties(pcapplusplus::Pcap++ PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/pcapplusplus-install/${BYPRODUCT1}") + add_dependencies(pcapplusplus::Pcap++ pcapplusplus-external libpcap-external) + + add_library(pcapplusplus::Packet++ STATIC IMPORTED) + set_target_properties(pcapplusplus::Packet++ PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/pcapplusplus-install/${BYPRODUCT2}") + add_dependencies(pcapplusplus::Packet++ pcapplusplus-external libpcap-external) + + add_library(pcapplusplus::Common++ STATIC IMPORTED) + set_target_properties(pcapplusplus::Common++ PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/thirdparty/pcapplusplus-install/${BYPRODUCT3}") + add_dependencies(pcapplusplus::Common++ pcapplusplus-external libpcap-external) + + add_library(pcapplusplus::pcapplusplus INTERFACE IMPORTED) + target_link_libraries(pcapplusplus::pcapplusplus INTERFACE pcapplusplus::Pcap++ pcapplusplus::Packet++ pcapplusplus::Common++ PCAP::PCAP) + target_include_directories(pcapplusplus::pcapplusplus INTERFACE "${PCAPPLUSPLUS_INCLUDE_DIRS}") + + if (APPLE) + target_link_libraries(pcapplusplus::pcapplusplus INTERFACE "-framework CoreFoundation" "-framework SystemConfiguration") + set_target_properties(pcapplusplus::pcapplusplus PROPERTIES LINK_FLAGS "-Wl,-F/Library/Frameworks") + endif () + endif() + +endfunction(use_bundled_pcapplusplus) \ No newline at end of file diff --git a/cmake/BundledRocksDB.cmake b/cmake/BundledRocksDB.cmake index 2d4211e944..de95b080da 100644 --- a/cmake/BundledRocksDB.cmake +++ b/cmake/BundledRocksDB.cmake @@ -18,93 +18,107 @@ function(use_bundled_rocksdb SOURCE_DIR BINARY_DIR) message("Using bundled RocksDB") - if (NOT WIN32) - include(Zstd) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/zstd/dummy") + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt RocksDB external lib") + include(${CMAKE_BINARY_DIR}/RocksDBConfig.cmake) - include(LZ4) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/lz4/dummy") - endif() + add_library(RocksDB::RocksDB ALIAS RocksDB::rocksdb) - # Patch to fix build issue on ARM7 architecture: https://github.com/facebook/rocksdb/issues/8609#issuecomment-1009572506 - set(PATCH_FILE_1 "${SOURCE_DIR}/thirdparty/rocksdb/arm7.patch") - set(PATCH_FILE_2 "${SOURCE_DIR}/thirdparty/rocksdb/dboptions_equality_operator.patch") - set(PATCH_FILE_3 "${SOURCE_DIR}/thirdparty/rocksdb/cstdint.patch") - set(PC ${Bash_EXECUTABLE} -c "set -x &&\ - (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_1}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_1}\") &&\ - (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_2}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_2}\") &&\ - (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_3}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_3}\") ") + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building RocksDB external lib") - # Define byproducts - if (WIN32) - set(BYPRODUCT "lib/rocksdb.lib") - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - set(BYPRODUCT "${LIBDIR}/librocksdb.a") - endif() - # Set build options - set(ROCKSDB_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/rocksdb-install" - -DWITH_TESTS=OFF - -DWITH_TOOLS=ON - -DWITH_GFLAGS=OFF - -DUSE_RTTI=1 - -DROCKSDB_BUILD_SHARED=OFF - -DFAIL_ON_WARNINGS=OFF - ) - if(PORTABLE) - list(APPEND ROCKSDB_CMAKE_ARGS -DPORTABLE=ON) - endif() - if(WIN32) - list(APPEND ROCKSDB_CMAKE_ARGS - -DROCKSDB_INSTALL_ON_WINDOWS=ON - -DWITH_XPRESS=ON) - else() - list(APPEND ROCKSDB_CMAKE_ARGS - -DWITH_ZLIB=ON - -DWITH_BZ2=ON - -DWITH_ZSTD=ON - -DWITH_LZ4=ON) - endif() + if (NOT WIN32) + include(Zstd) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/zstd/dummy") - append_third_party_passthrough_args(ROCKSDB_CMAKE_ARGS "${ROCKSDB_CMAKE_ARGS}") + include(LZ4) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/lz4/dummy") + endif() - # Build project - ExternalProject_Add( - rocksdb-external - URL "https://github.com/facebook/rocksdb/archive/refs/tags/v8.10.2.tar.gz" - URL_HASH "SHA256=44b6ec2f4723a0d495762da245d4a59d38704e0d9d3d31c45af4014bee853256" - SOURCE_DIR "${BINARY_DIR}/thirdparty/rocksdb-src" - CMAKE_ARGS ${ROCKSDB_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/rocksdb-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - ) + # /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/rocksdb/all/patches/arm7.patch + # Patch to fix build issue on ARM7 architecture: https://github.com/facebook/rocksdb/issues/8609#issuecomment-1009572506 + set(PATCH_FILE_1 "${SOURCE_DIR}/thirdparty/rocksdb/all/patches/arm7.patch") + set(PATCH_FILE_2 "${SOURCE_DIR}/thirdparty/rocksdb/all/patches/dboptions_equality_operator.patch") + set(PATCH_FILE_3 "${SOURCE_DIR}/thirdparty/rocksdb/all/patches/cstdint.patch") + set(PC ${Bash_EXECUTABLE} -c "set -x &&\ + (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_1}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_1}\") &&\ + (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_2}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_2}\") &&\ + (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i \"${PATCH_FILE_3}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE_3}\") ") - # Set variables - set(ROCKSDB_FOUND "YES" CACHE STRING "" FORCE) - set(ROCKSDB_INCLUDE_DIR "${BINARY_DIR}/thirdparty/rocksdb-install/include" CACHE STRING "" FORCE) - set(ROCKSDB_LIBRARY "${BINARY_DIR}/thirdparty/rocksdb-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(ROCKSDB_LIBRARIES ${ROCKSDB_LIBRARY} CACHE STRING "" FORCE) + # Define byproducts + if (WIN32) + set(BYPRODUCT "lib/rocksdb.lib") + else() + include(GNUInstallDirs) + string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) + list(GET LIBDIR_LIST 0 LIBDIR) + set(BYPRODUCT "${LIBDIR}/librocksdb.a") + endif() + + # Set build options + set(ROCKSDB_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/rocksdb-install" + -DWITH_TESTS=OFF + -DWITH_TOOLS=ON + -DWITH_GFLAGS=OFF + -DUSE_RTTI=1 + -DROCKSDB_BUILD_SHARED=OFF + -DFAIL_ON_WARNINGS=OFF + ) + if(PORTABLE) + list(APPEND ROCKSDB_CMAKE_ARGS -DPORTABLE=ON) + endif() + if(WIN32) + list(APPEND ROCKSDB_CMAKE_ARGS + -DROCKSDB_INSTALL_ON_WINDOWS=ON + -DWITH_XPRESS=ON) + else() + list(APPEND ROCKSDB_CMAKE_ARGS + -DWITH_ZLIB=ON + -DWITH_BZ2=ON + -DWITH_ZSTD=ON + -DWITH_LZ4=ON) + endif() + + append_third_party_passthrough_args(ROCKSDB_CMAKE_ARGS "${ROCKSDB_CMAKE_ARGS}") + + # Build project + ExternalProject_Add( + rocksdb-external + URL "https://github.com/facebook/rocksdb/archive/refs/tags/v8.10.2.tar.gz" + URL_HASH "SHA256=44b6ec2f4723a0d495762da245d4a59d38704e0d9d3d31c45af4014bee853256" + SOURCE_DIR "${BINARY_DIR}/thirdparty/rocksdb-src" + CMAKE_ARGS ${ROCKSDB_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/rocksdb-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + ) + + # Set variables + set(ROCKSDB_FOUND "YES" CACHE STRING "" FORCE) + set(ROCKSDB_INCLUDE_DIR "${BINARY_DIR}/thirdparty/rocksdb-install/include" CACHE STRING "" FORCE) + set(ROCKSDB_LIBRARY "${BINARY_DIR}/thirdparty/rocksdb-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(ROCKSDB_LIBRARIES ${ROCKSDB_LIBRARY} CACHE STRING "" FORCE) + + # Create imported targets + add_library(RocksDB::RocksDB STATIC IMPORTED) + set_target_properties(RocksDB::RocksDB PROPERTIES IMPORTED_LOCATION "${ROCKSDB_LIBRARY}") + if (NOT WIN32) + add_dependencies(rocksdb-external ZLIB::ZLIB BZip2::BZip2 zstd::zstd lz4::lz4) + endif() + add_dependencies(RocksDB::RocksDB rocksdb-external) + file(MAKE_DIRECTORY ${ROCKSDB_INCLUDE_DIR}) + target_include_directories(RocksDB::RocksDB INTERFACE ${ROCKSDB_INCLUDE_DIR}) + set_property(TARGET RocksDB::RocksDB APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads) + target_link_libraries(RocksDB::RocksDB INTERFACE Threads::Threads) + if(WIN32) + target_link_libraries(RocksDB::RocksDB INTERFACE Rpcrt4.lib Cabinet.lib) + else() + target_link_libraries(RocksDB::RocksDB INTERFACE ZLIB::ZLIB BZip2::BZip2 zstd::zstd lz4::lz4) + endif() + - # Create imported targets - add_library(RocksDB::RocksDB STATIC IMPORTED) - set_target_properties(RocksDB::RocksDB PROPERTIES IMPORTED_LOCATION "${ROCKSDB_LIBRARY}") - if (NOT WIN32) - add_dependencies(rocksdb-external ZLIB::ZLIB BZip2::BZip2 zstd::zstd lz4::lz4) - endif() - add_dependencies(RocksDB::RocksDB rocksdb-external) - file(MAKE_DIRECTORY ${ROCKSDB_INCLUDE_DIR}) - target_include_directories(RocksDB::RocksDB INTERFACE ${ROCKSDB_INCLUDE_DIR}) - set_property(TARGET RocksDB::RocksDB APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads) - target_link_libraries(RocksDB::RocksDB INTERFACE Threads::Threads) - if(WIN32) - target_link_libraries(RocksDB::RocksDB INTERFACE Rpcrt4.lib Cabinet.lib) - else() - target_link_libraries(RocksDB::RocksDB INTERFACE ZLIB::ZLIB BZip2::BZip2 zstd::zstd lz4::lz4) endif() endfunction(use_bundled_rocksdb) diff --git a/cmake/BundledSOCI.cmake b/cmake/BundledSOCI.cmake new file mode 100644 index 0000000000..8042cec7b5 --- /dev/null +++ b/cmake/BundledSOCI.cmake @@ -0,0 +1,137 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +function(use_bundled_soci SOURCE_DIR BINARY_DIR) + message("Using bundled soci") + + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt SOCI external lib") + include(${CMAKE_BINARY_DIR}/SOCIConfig.cmake) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building SOCI external lib") + + # Build SOCI + + # Define byproducts + # This should be based on GNUInstallDirs, but it's done wrong in Soci: + # https://github.com/SOCI/soci/blob/release/4.0/CMakeLists.txt#L140 + if(APPLE OR CMAKE_SIZEOF_VOID_P EQUAL 4) + set(LIBDIR "lib") + else() + set(LIBDIR "lib64") + endif() + + # Define byproducts + + if (WIN32) + set(BYPRODUCT_SUFFIX "_4_0.lib") + else() + set(BYPRODUCT_SUFFIX ".a") + endif() + + set(SOCI_BYPRODUCTS + "${LIBDIR}/libsoci_core${BYPRODUCT_SUFFIX}" + "${LIBDIR}/libsoci_odbc${BYPRODUCT_SUFFIX}" + ) + + set(SOCI_BYPRODUCT_DIR "${BINARY_DIR}/thirdparty/soci-install") + + foreach(SOCI_BYPRODUCT ${SOCI_BYPRODUCTS}) + list(APPEND SOCI_LIBRARIES_LIST "${SOCI_BYPRODUCT_DIR}/${SOCI_BYPRODUCT}") + endforeach(SOCI_BYPRODUCT) + + + # Build project + if(WIN32) + # Set build options + set(SOCI_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${SOCI_BYPRODUCT_DIR}" + "-DSOCI_TESTS=OFF" + "-DSOCI_SHARED=OFF" + "-DSOCI_CXX_C11=ON" + "-DWITH_ODBC=ON" + "-DWITH_BOOST=OFF") + else() + # SOCI has its own FindODBC.cmake file + # Set build options + set(SOCI_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${SOCI_BYPRODUCT_DIR}" + "-DSOCI_TESTS=OFF" + "-DSOCI_SHARED=OFF" + "-DSOCI_CXX_C11=ON" + "-DSOCI_ODBC=ON" + "-DODBC_INCLUDE_DIR=${IODBC_INCLUDE_DIRS}" + "-DODBC_LIBRARY=${IODBC_LIBRARIES}" + "-DWITH_BOOST=OFF") + endif() + + if(NOT WIN32) + list(APPEND SOCI_CMAKE_ARGS "-DCMAKE_MODULE_PATH=${SOURCE_DIR}/cmake/" + "-DEXPORTED_IODBC_INCLUDE_DIRS=${EXPORTED_IODBC_INCLUDE_DIRS}" + "-DEXPORTED_IODBC_LIBRARIES=${EXPORTED_IODBC_LIBRARIES}") + endif() + + set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/soci/all/patches/sqlite3-path.patch") + + + + set(SOCI_URL https://github.com/SOCI/soci/archive/4.0.1.tar.gz) + set(SOCI_URL_HASH "SHA256=fa69347b1a1ef74450c0382b665a67bd6777cc7005bbe09726479625bcf1e29c") + + ExternalProject_Add( + soci-external + URL ${SOCI_URL} + URL_HASH ${SOCI_URL_HASH} + SOURCE_DIR "${BINARY_DIR}/thirdparty/soci-src" + CMAKE_ARGS ${SOCI_CMAKE_ARGS} + PATCH_COMMAND ${PC} + BUILD_BYPRODUCTS ${SOCI_LIBRARIES_LIST} + EXCLUDE_FROM_ALL TRUE + ) + + # Set dependencies + if(NOT WIN32) + add_dependencies(soci-external ODBC::ODBC) + endif() + + + # Set variables + set(SOCI_FOUND "YES" CACHE STRING "" FORCE) + set(SOCI_INCLUDE_DIR "${SOCI_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) + set(SOCI_LIBRARIES "${SOCI_LIBRARIES_LIST}" CACHE STRING "" FORCE) + + # Create imported targets + file(MAKE_DIRECTORY ${SOCI_INCLUDE_DIR}) + + add_library(SOCI::libsoci_core STATIC IMPORTED) + set_target_properties(SOCI::libsoci_core PROPERTIES IMPORTED_LOCATION "${SOCI_BYPRODUCT_DIR}/${LIBDIR}/libsoci_core${BYPRODUCT_SUFFIX}") + set_target_properties(SOCI::libsoci_core PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIR}") + add_dependencies(SOCI::libsoci_core soci-external) + target_compile_features(SOCI::libsoci_core INTERFACE cxx_std_14) + + add_library(SOCI::libsoci_odbc STATIC IMPORTED) + set_target_properties(SOCI::libsoci_odbc PROPERTIES IMPORTED_LOCATION "${SOCI_BYPRODUCT_DIR}/${LIBDIR}/libsoci_odbc${BYPRODUCT_SUFFIX}") + set_target_properties(SOCI::libsoci_odbc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIR}") + add_dependencies(SOCI::libsoci_odbc soci-external) + set_property(TARGET SOCI::libsoci_odbc APPEND PROPERTY INTERFACE_LINK_LIBRARIES SOCI::libsoci_core) + set_property(TARGET SOCI::libsoci_odbc APPEND PROPERTY INTERFACE_LINK_LIBRARIES ODBC::ODBC) + target_compile_features(SOCI::libsoci_odbc INTERFACE cxx_std_14) + endif() +endfunction(use_bundled_soci) diff --git a/cmake/BundledYamlCpp.cmake b/cmake/BundledYamlCpp.cmake index d88663a04b..0835fa821e 100644 --- a/cmake/BundledYamlCpp.cmake +++ b/cmake/BundledYamlCpp.cmake @@ -16,53 +16,62 @@ # under the License. function(use_bundled_yamlcpp SOURCE_DIR BINARY_DIR) - if (WIN32) - set(LIBDIR "lib") - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - endif() + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt yaml-cpp external lib") + include(${CMAKE_BINARY_DIR}/yaml-cpp-config.cmake) + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building yaml-cpp external lib") - # Define byproducts - if (WIN32) - set(BYPRODUCT "${LIBDIR}/yaml-cpp.lib") - else() - set(BYPRODUCT "${LIBDIR}/libyaml-cpp.a") - endif() - # Set build options - set(YAMLCPP_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/yaml-cpp-install" - "-DCMAKE_DEBUG_POSTFIX=" - "-DBUILD_SHARED_LIBS=OFF" - "-DYAML_CPP_BUILD_TESTS=OFF" - "-DYAML_CPP_BUILD_TOOLS=OFF") + if (WIN32) + set(LIBDIR "lib") + else() + include(GNUInstallDirs) + string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) + list(GET LIBDIR_LIST 0 LIBDIR) + endif() + + # Define byproducts + if (WIN32) + set(BYPRODUCT "${LIBDIR}/yaml-cpp.lib") + else() + set(BYPRODUCT "${LIBDIR}/libyaml-cpp.a") + endif() - # Build project - ExternalProject_Add( - yaml-cpp-external - URL "https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.7.0.tar.gz" - URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3" - SOURCE_DIR "${BINARY_DIR}/thirdparty/yaml-cpp-src" - INSTALL_DIR "${BINARY_DIR}/thirdparty/yaml-cpp-install" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${YAMLCPP_CMAKE_ARGS} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/yaml-cpp-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + # Set build options + set(YAMLCPP_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/yaml-cpp-install" + "-DCMAKE_DEBUG_POSTFIX=" + "-DBUILD_SHARED_LIBS=OFF" + "-DYAML_CPP_BUILD_TESTS=OFF" + "-DYAML_CPP_BUILD_TOOLS=OFF") - # Set variables - set(YAMLCPP_FOUND "YES" CACHE STRING "" FORCE) - set(YAMLCPP_INCLUDE_DIR "${BINARY_DIR}/thirdparty/yaml-cpp-install/include" CACHE STRING "" FORCE) - set(YAMLCPP_LIBRARY "${BINARY_DIR}/thirdparty/yaml-cpp-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(YAMLCPP_LIBRARIES ${YAMLCPP_LIBRARY} CACHE STRING "" FORCE) + # Build project + ExternalProject_Add( + yaml-cpp-external + URL "https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.7.0.tar.gz" + URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3" + SOURCE_DIR "${BINARY_DIR}/thirdparty/yaml-cpp-src" + INSTALL_DIR "${BINARY_DIR}/thirdparty/yaml-cpp-install" + LIST_SEPARATOR % # This is needed for passing semicolon-separated lists + CMAKE_ARGS ${YAMLCPP_CMAKE_ARGS} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/yaml-cpp-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) - # Create imported targets - file(MAKE_DIRECTORY ${YAMLCPP_INCLUDE_DIR}) + # Set variables + set(YAMLCPP_FOUND "YES" CACHE STRING "" FORCE) + set(YAMLCPP_INCLUDE_DIR "${BINARY_DIR}/thirdparty/yaml-cpp-install/include" CACHE STRING "" FORCE) + set(YAMLCPP_LIBRARY "${BINARY_DIR}/thirdparty/yaml-cpp-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(YAMLCPP_LIBRARIES ${YAMLCPP_LIBRARY} CACHE STRING "" FORCE) - add_library(yaml-cpp STATIC IMPORTED) - set_target_properties(yaml-cpp PROPERTIES IMPORTED_LOCATION "${YAMLCPP_LIBRARY}") - add_dependencies(yaml-cpp yaml-cpp-external) - target_include_directories(yaml-cpp INTERFACE ${YAMLCPP_INCLUDE_DIR}) + # Create imported targets + file(MAKE_DIRECTORY ${YAMLCPP_INCLUDE_DIR}) + + add_library(yaml-cpp STATIC IMPORTED) + add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp) + set_target_properties(yaml-cpp PROPERTIES IMPORTED_LOCATION "${YAMLCPP_LIBRARY}") + add_dependencies(yaml-cpp yaml-cpp-external) + target_include_directories(yaml-cpp INTERFACE ${YAMLCPP_INCLUDE_DIR}) + endif() endfunction(use_bundled_yamlcpp) diff --git a/cmake/BundledZLIB.cmake b/cmake/BundledZLIB.cmake index 16b77c9077..a460b82443 100644 --- a/cmake/BundledZLIB.cmake +++ b/cmake/BundledZLIB.cmake @@ -18,56 +18,63 @@ function(use_bundled_zlib SOURCE_DIR BINARY_DIR) message("Using bundled zlib") - # Define byproducts - if (WIN32) - string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type) - if (build_type MATCHES relwithdebinfo OR build_type MATCHES release) - set(BYPRODUCT "lib/zlibstatic.lib") + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt zlib external lib") + include(${CMAKE_BINARY_DIR}/ZLIBConfig.cmake) + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building zlib external lib") + + # Define byproducts + if (WIN32) + string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type) + if (build_type MATCHES relwithdebinfo OR build_type MATCHES release) + set(BYPRODUCT "lib/zlibstatic.lib") + else() + set(BYPRODUCT "lib/zlibstaticd.lib") + endif() else() - set(BYPRODUCT "lib/zlibstaticd.lib") + set(BYPRODUCT "lib/libz.a") endif() - else() - set(BYPRODUCT "lib/libz.a") - endif() - # Set build options - set(ZLIB_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/zlib-install" - ) + # Set build options + set(ZLIB_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + "-DCMAKE_INSTALL_PREFIX=${BINARY_DIR}/thirdparty/zlib-install" + ) - # Build project - ExternalProject_Add( - zlib-external - URL "https://github.com/madler/zlib/archive/v1.2.11.tar.gz" - URL_HASH "SHA256=629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" - SOURCE_DIR "${BINARY_DIR}/thirdparty/zlib-src" - CMAKE_ARGS ${ZLIB_CMAKE_ARGS} - BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/zlib-install/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) + # Build project + ExternalProject_Add( + zlib-external + URL "https://github.com/madler/zlib/archive/v1.2.11.tar.gz" + URL_HASH "SHA256=629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" + SOURCE_DIR "${BINARY_DIR}/thirdparty/zlib-src" + CMAKE_ARGS ${ZLIB_CMAKE_ARGS} + BUILD_BYPRODUCTS "${BINARY_DIR}/thirdparty/zlib-install/${BYPRODUCT}" + EXCLUDE_FROM_ALL TRUE + ) - # Set variables - set(ZLIB_FOUND "YES" CACHE STRING "" FORCE) - set(ZLIB_INCLUDE_DIRS "${BINARY_DIR}/thirdparty/zlib-install/include" CACHE STRING "" FORCE) - set(ZLIB_LIBRARIES "${BINARY_DIR}/thirdparty/zlib-install/${BYPRODUCT}" CACHE STRING "" FORCE) - set(ZLIB_VERSION_STRING "1.2.11" CACHE STRING "" FORCE) - set(ZLIB_VERSION_MAJOR 1 CACHE STRING "" FORCE) - set(ZLIB_VERSION_MINOR 2 CACHE STRING "" FORCE) - set(ZLIB_VERSION_PATCH 11 CACHE STRING "" FORCE) + # Set variables + set(ZLIB_FOUND "YES" CACHE STRING "" FORCE) + set(ZLIB_INCLUDE_DIRS "${BINARY_DIR}/thirdparty/zlib-install/include" CACHE STRING "" FORCE) + set(ZLIB_LIBRARIES "${BINARY_DIR}/thirdparty/zlib-install/${BYPRODUCT}" CACHE STRING "" FORCE) + set(ZLIB_VERSION_STRING "1.2.11" CACHE STRING "" FORCE) + set(ZLIB_VERSION_MAJOR 1 CACHE STRING "" FORCE) + set(ZLIB_VERSION_MINOR 2 CACHE STRING "" FORCE) + set(ZLIB_VERSION_PATCH 11 CACHE STRING "" FORCE) - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_INCLUDE_DIRS=${ZLIB_INCLUDE_DIRS}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_LIBRARIES=${ZLIB_LIBRARIES}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_STRING=${ZLIB_VERSION_STRING}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_MAJOR=${ZLIB_VERSION_MAJOR}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_MINOR=${ZLIB_VERSION_MINOR}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_PATCH=${ZLIB_VERSION_PATCH}" CACHE STRING "" FORCE) + # Set exported variables for FindPackage.cmake + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_INCLUDE_DIRS=${ZLIB_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_LIBRARIES=${ZLIB_LIBRARIES}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_STRING=${ZLIB_VERSION_STRING}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_MAJOR=${ZLIB_VERSION_MAJOR}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_MINOR=${ZLIB_VERSION_MINOR}" CACHE STRING "" FORCE) + set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_ZLIB_VERSION_PATCH=${ZLIB_VERSION_PATCH}" CACHE STRING "" FORCE) - # Create imported targets - file(MAKE_DIRECTORY ${ZLIB_INCLUDE_DIRS}) + # Create imported targets + file(MAKE_DIRECTORY ${ZLIB_INCLUDE_DIRS}) - add_library(ZLIB::ZLIB STATIC IMPORTED) - set_target_properties(ZLIB::ZLIB PROPERTIES IMPORTED_LOCATION "${ZLIB_LIBRARIES}") - add_dependencies(ZLIB::ZLIB zlib-external) - set_property(TARGET ZLIB::ZLIB APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRS}) + add_library(ZLIB::ZLIB STATIC IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES IMPORTED_LOCATION "${ZLIB_LIBRARIES}") + add_dependencies(ZLIB::ZLIB zlib-external) + set_property(TARGET ZLIB::ZLIB APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRS}) + endif() endfunction(use_bundled_zlib) diff --git a/cmake/Catch2.cmake b/cmake/Catch2.cmake index d4c257af2d..e90c27a69c 100644 --- a/cmake/Catch2.cmake +++ b/cmake/Catch2.cmake @@ -16,11 +16,17 @@ # specific language governing permissions and limitations # under the License. # +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Catch2 external lib") + include(${CMAKE_BINARY_DIR}/Catch2Config.cmake) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building Catch2 external lib") include(FetchContent) -FetchContent_Declare( - Catch2 - URL https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.tar.gz - URL_HASH SHA256=122928b814b75717316c71af69bd2b43387643ba076a6ec16e7882bfb2dfacbb -) -FetchContent_MakeAvailable(Catch2) + FetchContent_Declare( + Catch2 + URL https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.tar.gz + URL_HASH SHA256=122928b814b75717316c71af69bd2b43387643ba076a6ec16e7882bfb2dfacbb + ) + FetchContent_MakeAvailable(Catch2) +endif() \ No newline at end of file diff --git a/cmake/CheckJavaMaven.cmake b/cmake/CheckJavaMaven.cmake new file mode 100644 index 0000000000..75cb95e977 --- /dev/null +++ b/cmake/CheckJavaMaven.cmake @@ -0,0 +1,68 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. See the License for the +# specific language governing permissions and limitations +# under the License. +# +function(check_javamaven_version) + if(TARGET openjdk::openjdk AND TARGET maven::maven) + execute_process(COMMAND ${PY_MAVEN_EXECUTABLE} + --maven_executable=$ENV{MAVEN_EXECUTABLE} + --maven_arg1="--version" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error + ) + else() + if (WIN32) + execute_process(COMMAND cmd /c "${MAVEN_EXECUTABLE}" "--version" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + else() + execute_process(COMMAND "${MAVEN_EXECUTABLE}" "--version" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + endif() + endif() + + if("${mvn_result}" STREQUAL "0") + message("....Successfully Ran Maven Version....") + message("${mvn_output}") + + if(DEFINED ENV{MAVEN_EXECUTABLE}) + message("MAVEN_EXECUTABLE = $ENV{MAVEN_EXECUTABLE}") + set(MAVEN_FOUND TRUE CACHE STRING "" FORCE) + else() + message("MAVEN_EXECUTABLE not set") + set(MAVEN_FOUND FALSE CACHE STRING "" FORCE) + endif() + + if(DEFINED ENV{JAVA_HOME}) + message("JAVA_HOME = $ENV{JAVA_HOME}") + set(JAVA_FOUND TRUE CACHE STRING "" FORCE) + else() + message("JAVA_HOME not set") + set(JAVA_FOUND FALSE CACHE STRING "" FORCE) + endif() + else() + message("Maven failed ${mvn_result} ${mvn_output} ${mvn_error}") + endif() + + message("JAVA_FOUND = ${JAVA_FOUND}") + message("MAVEN_FOUND = ${MAVEN_FOUND}") + +endfunction(check_javamaven_version) diff --git a/cmake/CivetWeb.cmake b/cmake/CivetWeb.cmake index 7ab39e9a89..9862223686 100644 --- a/cmake/CivetWeb.cmake +++ b/cmake/CivetWeb.cmake @@ -14,32 +14,39 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Civetweb external lib") + include(${CMAKE_BINARY_DIR}/civetweb-config.cmake) + +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building Civetweb external lib") -include(FetchContent) + include(FetchContent) -set(CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING "OFF" CACHE STRING "" FORCE) -set(CIVETWEB_BUILD_TESTING "OFF" CACHE STRING "" FORCE) -set(CIVETWEB_ENABLE_DUKTAPE "OFF" CACHE STRING "" FORCE) -set(CIVETWEB_ENABLE_LUA "OFF" CACHE STRING "" FORCE) -set(CIVETWEB_ENABLE_CXX "ON" CACHE STRING "" FORCE) -set(CIVETWEB_ALLOW_WARNINGS "ON" CACHE STRING "" FORCE) -set(CIVETWEB_ENABLE_ASAN "OFF" CACHE STRING "" FORCE) -set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/civetweb/openssl3.patch") -set(PC ${Bash_EXECUTABLE} -c "set -x &&\ - (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")") + set(CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING "OFF" CACHE STRING "" FORCE) + set(CIVETWEB_BUILD_TESTING "OFF" CACHE STRING "" FORCE) + set(CIVETWEB_ENABLE_DUKTAPE "OFF" CACHE STRING "" FORCE) + set(CIVETWEB_ENABLE_LUA "OFF" CACHE STRING "" FORCE) + set(CIVETWEB_ENABLE_CXX "ON" CACHE STRING "" FORCE) + set(CIVETWEB_ALLOW_WARNINGS "ON" CACHE STRING "" FORCE) + set(CIVETWEB_ENABLE_ASAN "OFF" CACHE STRING "" FORCE) + set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/civetweb/openssl3.patch") + set(PC ${Bash_EXECUTABLE} -c "set -x &&\ + (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")") -FetchContent_Declare(civetweb - URL https://github.com/civetweb/civetweb/archive/refs/tags/v1.16.tar.gz - URL_HASH SHA256=f0e471c1bf4e7804a6cfb41ea9d13e7d623b2bcc7bc1e2a4dd54951a24d60285 - PATCH_COMMAND "${PC}" -) + FetchContent_Declare(civetweb + URL https://github.com/civetweb/civetweb/archive/refs/tags/v1.16.tar.gz + URL_HASH SHA256=f0e471c1bf4e7804a6cfb41ea9d13e7d623b2bcc7bc1e2a4dd54951a24d60285 + PATCH_COMMAND "${PC}" + ) -FetchContent_MakeAvailable(civetweb) + FetchContent_MakeAvailable(civetweb) -add_dependencies(civetweb-c-library OpenSSL::Crypto OpenSSL::SSL) -add_dependencies(civetweb-cpp OpenSSL::Crypto OpenSSL::SSL) - -target_compile_definitions(civetweb-c-library PRIVATE SOCKET_TIMEOUT_QUANTUM=200) - -add_library(civetweb::c-library ALIAS civetweb-c-library) -add_library(civetweb::civetweb-cpp ALIAS civetweb-cpp) + add_dependencies(civetweb-c-library OpenSSL::Crypto OpenSSL::SSL) + add_dependencies(civetweb-cpp OpenSSL::Crypto OpenSSL::SSL) + + target_compile_definitions(civetweb-c-library PRIVATE SOCKET_TIMEOUT_QUANTUM=200) + + add_library(civetweb::c-library ALIAS civetweb-c-library) + add_library(civetweb::civetweb-cpp ALIAS civetweb-cpp) +endif() diff --git a/cmake/Date.cmake b/cmake/Date.cmake index 3224e4187f..0af7d4d003 100644 --- a/cmake/Date.cmake +++ b/cmake/Date.cmake @@ -14,70 +14,82 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt date external lib") + include(${CMAKE_BINARY_DIR}/date-config.cmake) -include(FetchContent) + message("Using Conan Packager to manage installing prebuilt tz data external lib") + include(${CMAKE_BINARY_DIR}/tz-config.cmake) -if (WIN32) - # tzdata and windowsZones.xml from unicode cldr-common are required to be installed for date-tz operation on Windows - FetchContent_Declare(tzdata - URL https://data.iana.org/time-zones/releases/tzdata2020e.tar.gz - URL_HASH SHA256=0be1ba329eae29ae1b54057c3547b3e672f73b3ae7643aa87dac85122bec037e - ) - FetchContent_GetProperties(tzdata) - if (NOT tzdata_POPULATED) - FetchContent_Populate(tzdata) - endif() +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building tzdata external lib") + message("Using CMAKE's FetchContent to manage source building date external lib") - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tzdata) + include(FetchContent) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cldr-common-38.1/common/supplemental/windowsZones.xml - DESTINATION ${CMAKE_BINARY_DIR}/tzdata) + if (WIN32) + # tzdata and windowsZones.xml from unicode cldr-common are required to be installed for date-tz operation on Windows + FetchContent_Declare(tzdata + URL https://data.iana.org/time-zones/releases/tzdata2020e.tar.gz + URL_HASH SHA256=0be1ba329eae29ae1b54057c3547b3e672f73b3ae7643aa87dac85122bec037e + ) + FetchContent_GetProperties(tzdata) + if (NOT tzdata_POPULATED) + FetchContent_Populate(tzdata) + endif() - file(COPY ${tzdata_SOURCE_DIR}/ - DESTINATION ${CMAKE_BINARY_DIR}/tzdata) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tzdata) - install(DIRECTORY ${tzdata_SOURCE_DIR}/ - DESTINATION tzdata - COMPONENT bin) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cldr-common-38.1/common/supplemental/windowsZones.xml + DESTINATION ${CMAKE_BINARY_DIR}/tzdata) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cldr-common-38.1/common/supplemental/windowsZones.xml - DESTINATION tzdata - COMPONENT bin) -endif() + file(COPY ${tzdata_SOURCE_DIR}/ + DESTINATION ${CMAKE_BINARY_DIR}/tzdata) -set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/date/826_libcpp_17_build_fix.patch") -set(PC ${Bash_EXECUTABLE} -c "set -x &&\ - (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")") + install(DIRECTORY ${tzdata_SOURCE_DIR}/ + DESTINATION tzdata + COMPONENT bin) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cldr-common-38.1/common/supplemental/windowsZones.xml + DESTINATION tzdata + COMPONENT bin) + endif() -FetchContent_Declare(date_src - URL https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.tar.gz - URL_HASH SHA256=7a390f200f0ccd207e8cff6757e04817c1a0aec3e327b006b7eb451c57ee3538 - PATCH_COMMAND "${PC}" -) -FetchContent_GetProperties(date_src) -if (NOT date_src_POPULATED) - FetchContent_Populate(date_src) - set(DATE_INCLUDE_DIR "${date_src_SOURCE_DIR}/include" CACHE STRING "" FORCE) - add_library(date INTERFACE) - add_library(date::date ALIAS date) - target_sources(date INTERFACE ${DATE_INCLUDE_DIR}/date/date.h) - target_include_directories(date SYSTEM INTERFACE ${DATE_INCLUDE_DIR}) - target_compile_features(date INTERFACE cxx_std_11) + set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/date/826_libcpp_17_build_fix.patch") + set(PC ${Bash_EXECUTABLE} -c "set -x &&\ + (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")") + + + FetchContent_Declare(date_src + URL https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.tar.gz + URL_HASH SHA256=7a390f200f0ccd207e8cff6757e04817c1a0aec3e327b006b7eb451c57ee3538 + PATCH_COMMAND "${PC}" + ) + FetchContent_GetProperties(date_src) + if (NOT date_src_POPULATED) + FetchContent_Populate(date_src) + set(DATE_INCLUDE_DIR "${date_src_SOURCE_DIR}/include" CACHE STRING "" FORCE) + add_library(date INTERFACE) + add_library(date::date ALIAS date) + target_sources(date INTERFACE ${DATE_INCLUDE_DIR}/date/date.h) + target_include_directories(date SYSTEM INTERFACE ${DATE_INCLUDE_DIR}) + target_compile_features(date INTERFACE cxx_std_11) - add_library(date-tz STATIC ${date_src_SOURCE_DIR}/src/tz.cpp) - add_library(date::tz ALIAS date-tz) - target_include_directories(date-tz SYSTEM PUBLIC ${DATE_INCLUDE_DIR}) - target_compile_features(date-tz PUBLIC cxx_std_11) - target_compile_options(date-tz PRIVATE $,/w,-w>) - target_compile_definitions(date-tz PRIVATE AUTO_DOWNLOAD=0 HAS_REMOTE_API=0) - if (WIN32) - target_compile_definitions(date-tz PRIVATE INSTALL=. PUBLIC USE_OS_TZDB=0) - else() - target_compile_definitions(date-tz PUBLIC USE_OS_TZDB=1) - endif() - if (NOT MSVC) - find_package(Threads) - target_link_libraries(date-tz PUBLIC Threads::Threads) + add_library(date-tz STATIC ${date_src_SOURCE_DIR}/src/tz.cpp) + add_library(date::date-tz ALIAS date-tz) + target_include_directories(date-tz SYSTEM PUBLIC ${DATE_INCLUDE_DIR}) + target_compile_features(date-tz PUBLIC cxx_std_11) + target_compile_options(date-tz PRIVATE $,/w,-w>) + target_compile_definitions(date-tz PRIVATE AUTO_DOWNLOAD=0 HAS_REMOTE_API=0) + if (WIN32) + target_compile_definitions(date-tz PRIVATE INSTALL=. PUBLIC USE_OS_TZDB=0) + else() + target_compile_definitions(date-tz PUBLIC USE_OS_TZDB=1) + endif() + if (NOT MSVC) + find_package(Threads) + target_link_libraries(date-tz PUBLIC Threads::Threads) + endif() endif() + endif() diff --git a/cmake/ExpectedLite.cmake b/cmake/ExpectedLite.cmake index 2a41fc2260..333500ecef 100644 --- a/cmake/ExpectedLite.cmake +++ b/cmake/ExpectedLite.cmake @@ -14,11 +14,17 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt expected-lite external lib") + include(${CMAKE_BINARY_DIR}/expected-lite-config.cmake) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building expected-lite external lib") -include(FetchContent) + include(FetchContent) -FetchContent_Declare(expected-lite - URL https://github.com/martinmoene/expected-lite/archive/refs/tags/v0.6.0.tar.gz - URL_HASH SHA256=90478ff7345100bf7539b12ea2c5ff04a7b6290bc5c280f02b473d5c65165342 -) -FetchContent_MakeAvailable(expected-lite) + FetchContent_Declare(expected-lite + URL https://github.com/martinmoene/expected-lite/archive/refs/tags/v0.6.0.tar.gz + URL_HASH SHA256=90478ff7345100bf7539b12ea2c5ff04a7b6290bc5c280f02b473d5c65165342 + ) + FetchContent_MakeAvailable(expected-lite) +endif() diff --git a/cmake/FetchUvc.cmake b/cmake/FetchUvc.cmake index 7d2000ae37..ed4ad5a207 100644 --- a/cmake/FetchUvc.cmake +++ b/cmake/FetchUvc.cmake @@ -16,10 +16,21 @@ # specific language governing permissions and limitations # under the License. # -include(FetchContent) -FetchContent_Declare(Uvc - URL https://github.com/libuvc/libuvc/archive/refs/tags/v0.0.7.tar.gz - URL_HASH SHA256=7c6ba79723ad5d0ccdfbe6cadcfbd03f9f75b701d7ba96631eb1fd929a86ee72 - OVERRIDE_FIND_PACKAGE -) -FetchContent_MakeAvailable(Uvc) +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt libuvc external lib") + include(${CMAKE_BINARY_DIR}/libuvc-config.cmake) + + add_library(LibUVC::UVC ALIAS LibUVC::UVCStatic) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building libuvc external lib") + + include(FetchContent) + FetchContent_Declare(Uvc + URL https://github.com/libuvc/libuvc/archive/refs/tags/v0.0.7.tar.gz + URL_HASH SHA256=7c6ba79723ad5d0ccdfbe6cadcfbd03f9f75b701d7ba96631eb1fd929a86ee72 + OVERRIDE_FIND_PACKAGE + ) + FetchContent_MakeAvailable(Uvc) + + find_package(UVC REQUIRED) +endif() diff --git a/cmake/GenericPython.cmake b/cmake/GenericPython.cmake index a815919030..708de1d26d 100644 --- a/cmake/GenericPython.cmake +++ b/cmake/GenericPython.cmake @@ -14,15 +14,28 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + # Verified can build minifi C++ with cpython 3.9.19 + message("Using Conan Packager to manage installing prebuilt Python3 external lib") + include(${CMAKE_BINARY_DIR}/cpython-config.cmake) -find_package(Python 3.6 REQUIRED COMPONENTS Development Interpreter) + set(Python_LIBRARIES ${cpython_LIBRARIES}) + set(Python_INCLUDE_DIRS ${cpython_INCLUDE_DIRS}) + add_library(Python::Python ALIAS cpython::cpython) -if(WIN32) - set(Python_LIBRARIES ${Python_LIBRARY_DIRS}/python3.lib) -else() - find_library(generic_lib_python NAMES libpython3.so) - if (NOT generic_lib_python STREQUAL generic_lib_python-NOTFOUND) - message(VERBOSE "Using generic python library at " ${generic_lib_python}) - set(Python_LIBRARIES ${generic_lib_python}) - endif() -endif() +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE to try to find system Python3 library") + + find_package(Python 3.6 REQUIRED COMPONENTS Development Interpreter) + + if(WIN32) + set(Python_LIBRARIES ${Python_LIBRARY_DIRS}/python3.lib) + else() + find_library(generic_lib_python NAMES libpython3.so) + if (NOT generic_lib_python STREQUAL generic_lib_python-NOTFOUND) + message(VERBOSE "Using generic python library at " ${generic_lib_python}) + set(Python_LIBRARIES ${generic_lib_python}) + endif() + endif() + +endif() \ No newline at end of file diff --git a/cmake/Grpc.cmake b/cmake/Grpc.cmake index 7c881bae7e..9b9265767a 100644 --- a/cmake/Grpc.cmake +++ b/cmake/Grpc.cmake @@ -14,33 +14,51 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -include(FetchContent) - -set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF CACHE BOOL "" FORCE) -set(gRPC_BUILD_GRPC_NODE_PLUGIN OFF CACHE BOOL "" FORCE) -set(gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN OFF CACHE BOOL "" FORCE) -set(gRPC_BUILD_GRPC_PHP_PLUGIN OFF CACHE BOOL "" FORCE) -set(gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF CACHE BOOL "" FORCE) -set(gRPC_BUILD_GRPC_RUBY_PLUGIN OFF CACHE BOOL "" FORCE) -set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE) -set(gRPC_ABSL_PROVIDER "package" CACHE STRING "" FORCE) -set(gRPC_ZLIB_PROVIDER "package" CACHE STRING "" FORCE) -set(gRPC_SSL_PROVIDER "package" CACHE STRING "" FORCE) -set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE) -set(protobuf_ABSL_PROVIDER "package" CACHE STRING "" FORCE) - -FetchContent_Declare( - grpc - GIT_REPOSITORY https://github.com/grpc/grpc - GIT_TAG v1.59.2 - GIT_SUBMODULES "third_party/cares/cares third_party/protobuf third_party/re2" -) -set(FETCHCONTENT_QUIET OFF) -FetchContent_MakeAvailable(grpc) - -add_dependencies(grpc++ OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB) - -set(GRPC_INCLUDE_DIR "${grpc_SOURCE_DIR}/include" CACHE STRING "" FORCE) -set(PROTOBUF_INCLUDE_DIR "${protobuf_SOURCE_DIR}/src" CACHE STRING "" FORCE) -set(PROTOBUF_COMPILER "$" CACHE STRING "" FORCE) -set(GRPC_CPP_PLUGIN "$" CACHE STRING "" FORCE) +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt GRPC external lib") + include(${CMAKE_BINARY_DIR}/gRPCConfig.cmake) + + include(${CMAKE_BINARY_DIR}/protobuf-config.cmake) + + set(GRPC_CPP_PLUGIN "$" CACHE STRING "" FORCE) + set(GRPC_INCLUDE_DIR "${gRPC_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(PROTOBUF_INCLUDE_DIR "${protobuf_INCLUDE_DIRS}" CACHE STRING "" FORCE) + set(PROTOBUF_COMPILER "${Protobuf_PROTOC_EXECUTABLE}" CACHE STRING "" FORCE) + +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's ExternalProject_Add to manage source building GRPC external lib") + + + include(FetchContent) + + set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF CACHE BOOL "" FORCE) + set(gRPC_BUILD_GRPC_NODE_PLUGIN OFF CACHE BOOL "" FORCE) + set(gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN OFF CACHE BOOL "" FORCE) + set(gRPC_BUILD_GRPC_PHP_PLUGIN OFF CACHE BOOL "" FORCE) + set(gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF CACHE BOOL "" FORCE) + set(gRPC_BUILD_GRPC_RUBY_PLUGIN OFF CACHE BOOL "" FORCE) + set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE) + set(gRPC_ABSL_PROVIDER "package" CACHE STRING "" FORCE) + set(gRPC_ZLIB_PROVIDER "package" CACHE STRING "" FORCE) + set(gRPC_SSL_PROVIDER "package" CACHE STRING "" FORCE) + set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE) + set(protobuf_ABSL_PROVIDER "package" CACHE STRING "" FORCE) + + FetchContent_Declare( + grpc + GIT_REPOSITORY https://github.com/grpc/grpc + GIT_TAG v1.59.2 + GIT_SUBMODULES "third_party/cares/cares third_party/protobuf third_party/re2" + ) + set(FETCHCONTENT_QUIET OFF) + FetchContent_MakeAvailable(grpc) + + add_dependencies(grpc++ OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB) + + set(GRPC_INCLUDE_DIR "${grpc_SOURCE_DIR}/include" CACHE STRING "" FORCE) + set(PROTOBUF_INCLUDE_DIR "${protobuf_SOURCE_DIR}/src" CACHE STRING "" FORCE) + set(PROTOBUF_COMPILER "$" CACHE STRING "" FORCE) + set(GRPC_CPP_PLUGIN "$" CACHE STRING "" FORCE) + + add_library(gRPC::grpc++ ALIAS grpc++) +endif() diff --git a/cmake/GslLite.cmake b/cmake/GslLite.cmake index 4262f9cbe6..6e67a40bae 100644 --- a/cmake/GslLite.cmake +++ b/cmake/GslLite.cmake @@ -14,11 +14,38 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt gsl-lite external lib") + include(${CMAKE_BINARY_DIR}/gsl-lite-config.cmake) -include(FetchContent) + # Add necessary definitions based on the value of STRICT_GSL_CHECKS, see gsl-lite README for more details + list(APPEND gsl-lite_DEFINITIONS_RELEASE gsl_CONFIG_DEFAULTS_VERSION=1) -FetchContent_Declare(gsl-lite - URL https://github.com/gsl-lite/gsl-lite/archive/refs/tags/v0.39.0.tar.gz - URL_HASH SHA256=f80ec07d9f4946097a1e2554e19cee4b55b70b45d59e03a7d2b7f80d71e467e9 -) -FetchContent_MakeAvailable(gsl-lite) + target_compile_definitions(gsl::gsl-lite INTERFACE ${gsl-lite_DEFINITIONS_RELEASE}) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building gsl-lite external lib") + + include(FetchContent) + + FetchContent_Declare(gsl-lite + URL https://github.com/gsl-lite/gsl-lite/archive/refs/tags/v0.39.0.tar.gz + URL_HASH SHA256=f80ec07d9f4946097a1e2554e19cee4b55b70b45d59e03a7d2b7f80d71e467e9 + ) + FetchContent_MakeAvailable(gsl-lite) + + # Add necessary definitions based on the value of STRICT_GSL_CHECKS, see gsl-lite README for more details + list(APPEND GslDefinitions gsl_CONFIG_DEFAULTS_VERSION=1) + list(APPEND GslDefinitionsNonStrict gsl_CONFIG_CONTRACT_VIOLATION_THROWS gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION=1) + if (STRICT_GSL_CHECKS STREQUAL "AUDIT") + list(APPEND GslDefinitions gsl_CONFIG_CONTRACT_CHECKING_AUDIT) + endif() + if (NOT STRICT_GSL_CHECKS) # OFF (or any other falsey string) matches, AUDIT/ON/DEBUG_ONLY don't match + list(APPEND GslDefinitions ${GslDefinitionsNonStrict}) + endif() + if (STRICT_GSL_CHECKS STREQUAL "DEBUG_ONLY") + list(APPEND GslDefinitions $<$>:${GslDefinitionsNonStrict}>) + endif() + target_compile_definitions(gsl-lite INTERFACE ${GslDefinitions}) + + +endif() diff --git a/cmake/JavaMaven.cmake b/cmake/JavaMaven.cmake new file mode 100644 index 0000000000..44123b6e1d --- /dev/null +++ b/cmake/JavaMaven.cmake @@ -0,0 +1,37 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +function(use_javamaven SOURCE_DIR BINARY_DIR) + if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Java Maven external lib") + include(${CMAKE_BINARY_DIR}/mavenTargets.cmake) + + # TODO (JG): Later we could integrate this run_maven.py script directly into maven conan package + # and set an environment variable for RUN_MAVEN_EXECUTABLE in the conanfile.py + find_package(Python3 COMPONENTS Interpreter) + message("MAVEN_EXECUTABLE = $ENV{MAVEN_EXECUTABLE}") + message("Path to run_maven.py: ${SOURCE_DIR}/cmake/maven/python/run_maven.py") + set(PY_MAVEN_EXECUTABLE ${Python3_EXECUTABLE} "${SOURCE_DIR}/cmake/maven/python/run_maven.py" PARENT_SCOPE) + + elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's to integrate system Java Maven external lib") + + find_package(Maven) + endif() +endfunction(use_javamaven) diff --git a/cmake/JavaOpenJDK.cmake b/cmake/JavaOpenJDK.cmake new file mode 100644 index 0000000000..d78d3c6f3a --- /dev/null +++ b/cmake/JavaOpenJDK.cmake @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. See the License for the +# specific language governing permissions and limitations +# under the License. +# +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Java OpenJDK external lib") + include(${CMAKE_BINARY_DIR}/openjdk-config.cmake) + +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's find_package to integrate system Java OpenJDK external lib") + find_package(Java) +endif() diff --git a/cmake/Lua.cmake b/cmake/Lua.cmake index 2d38cbcb26..40b77a9167 100644 --- a/cmake/Lua.cmake +++ b/cmake/Lua.cmake @@ -14,24 +14,34 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Lua external lib") + include(${CMAKE_BINARY_DIR}/lua-config.cmake) -include(FetchContent) + set(LUA_INCLUDE_DIR ${lua_INCLUDE_DIRS}) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building Lua external lib") + + include(FetchContent) -FetchContent_Declare(lua - URL "https://www.lua.org/ftp/lua-5.4.6.tar.gz" - URL_HASH "SHA256=7d5ea1b9cb6aa0b59ca3dde1c6adcb57ef83a1ba8e5432c0ecd06bf439b3ad88" -) + FetchContent_Declare(lua + URL "https://www.lua.org/ftp/lua-5.4.6.tar.gz" + URL_HASH "SHA256=7d5ea1b9cb6aa0b59ca3dde1c6adcb57ef83a1ba8e5432c0ecd06bf439b3ad88" + ) -FetchContent_GetProperties(lua) -if(NOT lua_POPULATED) - FetchContent_Populate(lua) + FetchContent_GetProperties(lua) + if(NOT lua_POPULATED) + FetchContent_Populate(lua) - file(GLOB LUA_SOURCES "${lua_SOURCE_DIR}/src/*.c") - add_library(lua STATIC ${LUA_SOURCES}) + file(GLOB LUA_SOURCES "${lua_SOURCE_DIR}/src/*.c") + add_library(lua STATIC ${LUA_SOURCES}) - file(MAKE_DIRECTORY "${lua_BINARY_DIR}/include") - foreach(HEADER lua.h luaconf.h lualib.h lauxlib.h lua.hpp) - file(COPY "${lua_SOURCE_DIR}/src/${HEADER}" DESTINATION "${lua_BINARY_DIR}/include") - endforeach() - set(LUA_INCLUDE_DIR "${lua_BINARY_DIR}/include" CACHE STRING "" FORCE) -endif() + file(MAKE_DIRECTORY "${lua_BINARY_DIR}/include") + foreach(HEADER lua.h luaconf.h lualib.h lauxlib.h lua.hpp) + file(COPY "${lua_SOURCE_DIR}/src/${HEADER}" DESTINATION "${lua_BINARY_DIR}/include") + endforeach() + set(LUA_INCLUDE_DIR "${lua_BINARY_DIR}/include" CACHE STRING "" FORCE) + endif() + add_library(lua::lua ALIAS lua) + +endif() \ No newline at end of file diff --git a/cmake/MagicEnum.cmake b/cmake/MagicEnum.cmake index 266d3b8492..9b36db484c 100644 --- a/cmake/MagicEnum.cmake +++ b/cmake/MagicEnum.cmake @@ -14,11 +14,19 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt magic_enum external lib") + include(${CMAKE_BINARY_DIR}/magic_enum-config.cmake) + target_include_directories(magic_enum::magic_enum INTERFACE ${magic_enum_INCLUDE_DIRS} ${magic_enum_INCLUDE_DIRS}/magic_enum) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building magic_enum external lib") -include(FetchContent) + include(FetchContent) -FetchContent_Declare(magic_enum - URL https://github.com/Neargye/magic_enum/archive/refs/tags/v0.9.3.tar.gz - URL_HASH SHA256=3cadd6a05f1bffc5141e5e731c46b2b73c2dbff025e723c8abaa659e0a24f072) + FetchContent_Declare(magic_enum + URL https://github.com/Neargye/magic_enum/archive/refs/tags/v0.9.3.tar.gz + URL_HASH SHA256=3cadd6a05f1bffc5141e5e731c46b2b73c2dbff025e723c8abaa659e0a24f072) + + FetchContent_MakeAvailable(magic_enum) -FetchContent_MakeAvailable(magic_enum) +endif() diff --git a/cmake/MiNiFiOptions.cmake b/cmake/MiNiFiOptions.cmake index de2b264ed5..cd05d07b92 100644 --- a/cmake/MiNiFiOptions.cmake +++ b/cmake/MiNiFiOptions.cmake @@ -42,6 +42,8 @@ add_minifi_option(DOCKER_SKIP_TESTS "Skip building tests in docker image targets add_minifi_option(DOCKER_PUSH "Push created images to the specified tags" OFF) add_minifi_option(PORTABLE "Instructs the compiler to remove architecture specific optimizations" ON) +add_minifi_option(USE_CONAN_PACKAGER "Instructs cmake to include C++ typically prebuilt external lib dependencies installed with conan packager" OFF) +add_minifi_option(USE_CMAKE_FETCH_CONTENT "Instructs cmake to include C++ source build external lib dependencies installed with cmake's FetchContent" ON) add_minifi_option(USE_SHARED_LIBS "Builds using shared libraries" ON) add_minifi_dependent_option(STATIC_BUILD "Attempts to statically link as many dependencies as possible." ON "NOT USE_SHARED_LIBS" OFF) add_minifi_option(LIBC_STATIC "Instructs the build system to statically link libstdc++ and glibc into minifiexe. Experiemental" OFF) diff --git a/cmake/RangeV3.cmake b/cmake/RangeV3.cmake index ff26be3a18..f49cedb0ff 100644 --- a/cmake/RangeV3.cmake +++ b/cmake/RangeV3.cmake @@ -14,11 +14,22 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt range-v3 external lib") + include(${CMAKE_BINARY_DIR}/range-v3-config.cmake) -include(FetchContent) + # set(RANGE_V3_INCLUDE_DIRS "${range-v3_INCLUDE_DIRS}" CACHE STRING "" FORCE) + # set(RANGE_V3_LIBRARIES "${range-v3_LIB_DIRS_RELEASE}" CACHE STRING "" FORCE) -FetchContent_Declare(range-v3_src - URL https://github.com/ericniebler/range-v3/archive/refs/tags/0.12.0.tar.gz - URL_HASH SHA256=015adb2300a98edfceaf0725beec3337f542af4915cec4d0b89fa0886f4ba9cb -) -FetchContent_MakeAvailable(range-v3_src) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building range-v3 external lib") + + include(FetchContent) + + FetchContent_Declare(range-v3_src + URL https://github.com/ericniebler/range-v3/archive/refs/tags/0.12.0.tar.gz + URL_HASH SHA256=015adb2300a98edfceaf0725beec3337f542af4915cec4d0b89fa0886f4ba9cb + ) + FetchContent_MakeAvailable(range-v3_src) + +endif() diff --git a/cmake/Sol2.cmake b/cmake/Sol2.cmake index e5989a3ace..37d3e6e62e 100644 --- a/cmake/Sol2.cmake +++ b/cmake/Sol2.cmake @@ -14,34 +14,42 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt Sol2 external lib") + include(${CMAKE_BINARY_DIR}/sol2-config.cmake) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's file DOWNLOAD to manage integrating Sol2 external lib") + + # Using file(DOWNLOAD) instead of FetchContent due to this issue in cmake versions older than 3.18 https://gitlab.kitware.com/cmake/cmake/-/issues/20526 -# Using file(DOWNLOAD) instead of FetchContent due to this issue in cmake versions older than 3.18 https://gitlab.kitware.com/cmake/cmake/-/issues/20526 + set(SOL2_INCLUDE_DIR "${CMAKE_BINARY_DIR}/_deps/sol2/" CACHE STRING "" FORCE) + if(NOT EXISTS "${SOL2_INCLUDE_DIR}/sol.hpp") + file(DOWNLOAD "https://github.com/ThePhD/sol2/releases/download/v3.3.0/sol.hpp" "${SOL2_INCLUDE_DIR}/sol/sol.hpp" + EXPECTED_HASH SHA256=e095a961a5189863745e6c101124fce944af991f3d4726a1e82c5b4a885a187f) + configure_file("${SOL2_INCLUDE_DIR}/sol/sol.hpp" "${SOL2_INCLUDE_DIR}/sol/sol.hpp" NEWLINE_STYLE LF) -set(SOL2_INCLUDE_DIR "${CMAKE_BINARY_DIR}/_deps/sol2/" CACHE STRING "" FORCE) -if(NOT EXISTS "${SOL2_INCLUDE_DIR}/sol.hpp") - file(DOWNLOAD "https://github.com/ThePhD/sol2/releases/download/v3.3.0/sol.hpp" "${SOL2_INCLUDE_DIR}/sol/sol.hpp" - EXPECTED_HASH SHA256=e095a961a5189863745e6c101124fce944af991f3d4726a1e82c5b4a885a187f) - configure_file("${SOL2_INCLUDE_DIR}/sol/sol.hpp" "${SOL2_INCLUDE_DIR}/sol/sol.hpp" NEWLINE_STYLE LF) + file(DOWNLOAD "https://github.com/ThePhD/sol2/releases/download/v3.3.0/config.hpp" "${SOL2_INCLUDE_DIR}/sol/config.hpp" + EXPECTED_HASH SHA256=6c283673a16f0eeb3c56f8b8d72ccf7ed3f048816dbd2584ac58564c61315f02) + configure_file("${SOL2_INCLUDE_DIR}/sol/config.hpp" "${SOL2_INCLUDE_DIR}/sol/config.hpp" NEWLINE_STYLE LF) - file(DOWNLOAD "https://github.com/ThePhD/sol2/releases/download/v3.3.0/config.hpp" "${SOL2_INCLUDE_DIR}/sol/config.hpp" - EXPECTED_HASH SHA256=6c283673a16f0eeb3c56f8b8d72ccf7ed3f048816dbd2584ac58564c61315f02) - configure_file("${SOL2_INCLUDE_DIR}/sol/config.hpp" "${SOL2_INCLUDE_DIR}/sol/config.hpp" NEWLINE_STYLE LF) + file(DOWNLOAD "https://github.com/ThePhD/sol2/releases/download/v3.3.0/forward.hpp" "${SOL2_INCLUDE_DIR}/sol/forward.hpp" + EXPECTED_HASH SHA256=8fc34d74e9b4b8baa381f5e6ab7b6f6b44114cd355c718505495943ff6b85740) + configure_file("${SOL2_INCLUDE_DIR}/sol/forward.hpp" "${SOL2_INCLUDE_DIR}/sol/forward.hpp" NEWLINE_STYLE LF) - file(DOWNLOAD "https://github.com/ThePhD/sol2/releases/download/v3.3.0/forward.hpp" "${SOL2_INCLUDE_DIR}/sol/forward.hpp" - EXPECTED_HASH SHA256=8fc34d74e9b4b8baa381f5e6ab7b6f6b44114cd355c718505495943ff6b85740) - configure_file("${SOL2_INCLUDE_DIR}/sol/forward.hpp" "${SOL2_INCLUDE_DIR}/sol/forward.hpp" NEWLINE_STYLE LF) + # Some platform simply define LUA_COMPAT_BITLIB or LUA_COMPAT_5_2 without setting them to explicitly 1 + set(PC "${Patch_EXECUTABLE}" -p1 -i "${CMAKE_SOURCE_DIR}/thirdparty/sol2/fix_bitlib_compatibility.patch" "${SOL2_INCLUDE_DIR}/sol/sol.hpp") - # Some platform simply define LUA_COMPAT_BITLIB or LUA_COMPAT_5_2 without setting them to explicitly 1 - set(PC "${Patch_EXECUTABLE}" -p1 -i "${CMAKE_SOURCE_DIR}/thirdparty/sol2/fix_bitlib_compatibility.patch" "${SOL2_INCLUDE_DIR}/sol/sol.hpp") + execute_process(COMMAND ${PC} RESULT_VARIABLE patch_result_code) + if(NOT patch_result_code EQUAL "0") + message(FATAL_ERROR "Failed to patch sol.hpp") + endif() - execute_process(COMMAND ${PC} RESULT_VARIABLE patch_result_code) - if(NOT patch_result_code EQUAL "0") - message(FATAL_ERROR "Failed to patch sol.hpp") - endif() + add_library(sol2 INTERFACE IMPORTED) + target_sources(sol2 INTERFACE ${SOL2_INCLUDE_DIR}/sol/sol.hpp) + target_sources(sol2 INTERFACE ${SOL2_INCLUDE_DIR}/sol/config.hpp) + target_sources(sol2 INTERFACE ${SOL2_INCLUDE_DIR}/sol/forward.hpp) + target_include_directories(sol2 SYSTEM INTERFACE ${SOL2_INCLUDE_DIR}) + endif() + add_library(sol2::sol2 ALIAS sol2) - add_library(sol2 INTERFACE IMPORTED) - target_sources(sol2 INTERFACE ${SOL2_INCLUDE_DIR}/sol/sol.hpp) - target_sources(sol2 INTERFACE ${SOL2_INCLUDE_DIR}/sol/config.hpp) - target_sources(sol2 INTERFACE ${SOL2_INCLUDE_DIR}/sol/forward.hpp) - target_include_directories(sol2 SYSTEM INTERFACE ${SOL2_INCLUDE_DIR}) -endif() +endif() \ No newline at end of file diff --git a/cmake/Spdlog.cmake b/cmake/Spdlog.cmake index 07eb0f103a..c2d4bc834a 100644 --- a/cmake/Spdlog.cmake +++ b/cmake/Spdlog.cmake @@ -16,12 +16,20 @@ # specific language governing permissions and limitations # under the License. # -include(FetchContent) -include(fmt) -set(SPDLOG_FMT_EXTERNAL ON CACHE STRING "" FORCE) -FetchContent_Declare(Spdlog - URL https://github.com/gabime/spdlog/archive/refs/tags/v1.12.0.tar.gz - URL_HASH SHA256=4dccf2d10f410c1e2feaff89966bfc49a1abb29ef6f08246335b110e001e09a9 - OVERRIDE_FIND_PACKAGE - ) -FetchContent_MakeAvailable(Spdlog) +if(USE_CONAN_PACKAGER) + message("Using Conan Packager to manage installing prebuilt spdlog external lib") + include(${CMAKE_BINARY_DIR}/spdlog-config.cmake) +elseif(USE_CMAKE_FETCH_CONTENT) + message("Using CMAKE's FetchContent to manage source building spdlog external lib") + + include(FetchContent) + include(fmt) + set(SPDLOG_FMT_EXTERNAL ON CACHE STRING "" FORCE) + FetchContent_Declare(Spdlog + URL https://github.com/gabime/spdlog/archive/refs/tags/v1.12.0.tar.gz + URL_HASH SHA256=4dccf2d10f410c1e2feaff89966bfc49a1abb29ef6f08246335b110e001e09a9 + OVERRIDE_FIND_PACKAGE + ) + FetchContent_MakeAvailable(Spdlog) + +endif() \ No newline at end of file diff --git a/cmake/maven/python/run_maven.py b/cmake/maven/python/run_maven.py new file mode 100644 index 0000000000..718a7f9f8b --- /dev/null +++ b/cmake/maven/python/run_maven.py @@ -0,0 +1,57 @@ +import os +import argparse +import subprocess + +SCRIPT_PATH = os.path.realpath(__file__) +SCRIPT_DIR = os.path.dirname(SCRIPT_PATH) + +def run_maven(maven_executable, maven_arg1): + print(f"Running Maven version command") + output = subprocess.check_output([maven_executable, maven_arg1], universal_newlines=True) + + print(output) + +def run_maven_from_wk_dir(maven_executable, maven_nargs=None, working_dir=None): + if maven_nargs is not None and working_dir is not None: + print(f"Running Maven to build Java SFTP Test Server") + orig_dir = os.getcwd() + + os.chdir(working_dir) + + maven_command = [maven_executable, *maven_nargs] + output = subprocess.check_output(maven_command, universal_newlines=True) + + print(output) + + os.chdir(orig_dir) + +if __name__ == "__main__": + print("Running Python to Run Conan Maven") + parser = argparse.ArgumentParser(description="Generate include_dirs.cmake file") + parser.add_argument("--maven_executable_path", dest="maven_executable_path", help="Path to the maven executable") + parser.add_argument("--maven_arg1", dest="maven_arg1", nargs="?", help="Maven 1st argument") + parser.add_argument("--maven_arg2", dest="maven_arg2", nargs="?", help="Maven 2nd argument") + parser.add_argument("--maven_arg3", dest="maven_arg3", nargs="?", help="Maven 3rd argument") + parser.add_argument("--working_directory", dest="working_directory", nargs="?", help="Working directory to run maven from") + args = parser.parse_args() + + maven_executable = args.maven_executable_path + + if args.maven_arg1 and args.maven_arg2 and args.maven_arg3 and args.working_directory: + print(f"-----maven_nargs: {args.maven_arg1}; {args.maven_arg2}; {args.maven_arg3}") + print(f"-----working_directory: {args.working_directory}") + + # run_maven(maven_executable, "--version") + run_maven_from_wk_dir(maven_executable, maven_nargs=[args.maven_arg1, args.maven_arg2, args.maven_arg3], working_dir=args.working_directory) + elif args.maven_arg1 and args.maven_arg2 and args.working_directory: + print(f"-----maven_nargs: {args.maven_arg1}; {args.maven_arg2}") + print(f"-----working_directory: {args.working_directory}") + + # run_maven(maven_executable, "--version") + run_maven_from_wk_dir(maven_executable, maven_nargs=[args.maven_arg1, args.maven_arg2], working_dir=args.working_directory) + elif args.maven_arg1: + print(f"-----maven_arg1: {args.maven_arg1}") + # run_maven(maven_executable, "--version") + run_maven(maven_executable, args.maven_arg1) + else: + run_maven(maven_executable, "--version") diff --git a/cmake/rocksdb/sys/FindRocksDB.cmake b/cmake/rocksdb/sys/FindRocksDB.cmake index abe8a1d3dd..05ac69440c 100644 --- a/cmake/rocksdb/sys/FindRocksDB.cmake +++ b/cmake/rocksdb/sys/FindRocksDB.cmake @@ -50,11 +50,11 @@ if(ROCKSDB_INCLUDE_DIR AND ROCKSDB_LIBRARIES) message(STATUS "Found RocksDB...${ROCKSDB_LIBRARIES}") endif() -if(NOT TARGET RocksDB::RocksDB) - add_library(RocksDB::RocksDB UNKNOWN IMPORTED) - set_target_properties(RocksDB::RocksDB PROPERTIES +if(NOT TARGET RocksDB::rocksdb) + add_library(RocksDB::rocksdb UNKNOWN IMPORTED) + set_target_properties(RocksDB::rocksdb PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ROCKSDB_INCLUDE_DIR}") - set_target_properties(RocksDB::RocksDB PROPERTIES + set_target_properties(RocksDB::rocksdb PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION "${ROCKSDB_LIBRARIES}") endif() diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000000..1d0f1088d1 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,239 @@ +from conan import ConanFile, tools +from conan.tools.cmake import CMake +import os, subprocess, shutil +from glob import glob + +import shlex +import subprocess +from conan.internal import check_duplicated_generator +from conan.tools.env import Environment +from conan.tools.env.virtualrunenv import runenv_from_cpp_info +from conan.tools.cmake import CMakeToolchain, CMake + +required_conan_version = ">=1.54 <2.0 || >=2.1.0" + +# conan prebuilt binary conan packages for minifi core, mainexe, standard processors +minifi_core_external_libraries = ( + 'libsodium/cci.20220430', + 'zlib/1.3.1', + 'spdlog/1.14.0', + 'yaml-cpp/0.8.0', + 'gsl-lite/0.41.0', + 'date/3.0.1', + 'tz/2023c', + 'expected-lite/0.6.3', + 'magic_enum/0.9.5', + 'abseil/20230125.3', + 'civetweb/1.16', + 'libcurl/8.6.0', + 'asio/1.30.2', + 'range-v3/0.12.0', + 'libxml2/2.12.6', + # 'uthash/2.3.0', + # 'concurrentqueue/1.0.4', + # 'rapidjson/cci.20230929', +) + +# conan non prebuilt binary conan packages for minifi core, so we have source list +minifi_core_external_source_libraries = ( + 'catch2/3.5.4', # for conan 2.2.3, catch2 is not available as prebuilt binary package, so we built source downloaded by conan=center-index recipe + 'openssl/3.3.0@minifi/dev', # conan-center-index didnt have 3.3.0, so built from source by local conan recipe, needed by core-minifi, optional for libarchive +) + +shared_requires = minifi_core_external_libraries +shared_requires += minifi_core_external_source_libraries + +# packages not available on conancenter or need to be prebuilt with MiNiFi C++ specific patches, etc + # TODO (JG): Add conan recipes for building these packages from source, + # later upload to github packages, so we can maintain our own prebuilt packages + # format: '{conan_package}/{version}@{user}/{channel}' + # version: commit hash or official tag version + # user: minifi, channels: stable, testing or dev, etc +github_pcks_minifi_core_gtests_ext_libs = ( + 'rocksdb/8.10.2@minifi/dev', # nifi-minifi-cpp/thirdparty/rocksdb/all + # 'bzip2/1.0.8@minifi/dev', # create bzip2 conan package with patches for minifi +# 'bustache/1a6d442@minifi/dev', # - bustache: https://github.com/jamboree/bustache +# 'ossp-uuid/1.6.2@minifi/dev', +# 'openwsman/2.7.2@minifi/dev', + +) + +# conan packages for minifi core & standard-processor gtests +minifi_core_gtests_external_libraries = github_pcks_minifi_core_gtests_ext_libs + +shared_requires += minifi_core_gtests_external_libraries + +minifi_extension_external_libraries = ( + 'odbc/2.3.11', # soci conan package uses unixodbc, might try openlink's iodbc if needed to build minifi + 'argparse/3.0', # needed for minifi controller + 'lua/5.4.6', + 'sol2/3.3.0', # applied minifi patch to sol2, is a C++ library binding to Lua for advanced featuers & top performance + 'bzip2/1.0.8', + 'libuvc/0.0.7', + 'openjdk/21.0.2', + 'libpcap/1.10.1', +) + +# packages not available on conancenter or need to be prebuilt with MiNiFi C++ specific patches, etc +github_pcks_minifi_extension_ext_libs = ( + 'mbedtls/2.16.3@minifi/dev', # needed to fix mbedtls packaging issue to allow for open62541 to integrate with it + 'open62541/1.3.3@minifi/dev', # open62541 expects version 1.3.3 with patches for minifi + 'xz_utils/5.2.5@minifi/dev', # xz_utils (liblzma) expects version 5.2.5 with patches and configure args for minifi + 'libarchive/3.4.2@minifi/dev', # libarchive with patches and configure args for minifi; need to add support for openssl enabled integration + 'libcoap/4.2.1@minifi/dev', # updated libcoap 4.3.x conanfile.py to build for libcoap 4.2.1 needed by minifi + 'soci/4.0.1@minifi/dev', # updated soci conanfile.py to build soci 4.0.1 with sqlite patch needed by minifi + 'pcapplusplus/22.05@minifi/dev', # updated pcapplusplus conanfile.py to build pcapplusplus 22.05 needed by minifi + # 'cpython/3.9.19@minifi/dev' # use python3.9+ conan package to match nifi custom python extensibility recommended python version + # 'cpython/3.12.2@minifi/dev' # use python3.12.2 conan package to meet nifi custom python extensibility python version requirement + # 'aws-sdk-cpp/1.9.234', + 'ffmpeg/4.4.4@minifi/dev', # opencv requires ffempg, ffempeg requires xz_utils + 'libtiff/4.6.0@minifi/dev', # opencv requires libtiff, libtiff requires xz_utils + 'opencv/4.8.1@minifi/dev', + 'libssh2/1.10.0@minifi/dev', # requires openssl and mbedtls, so use minifi ones + 'maven/3.9.6@minifi/dev', # updated maven conan package with MAVEN_EXECUTABLE env variable + 'librdkafka/1.9.2@minifi/dev', # updated librdkafka conan package CMake definition args similar to ExternalProject_Add + 'libsystemd/255@minifi/dev', # updated libsystemd to use minifi's xz_utils + 'grpc/1.54.3@minifi/dev', # updated grpc conan package to use minifi's openssl, libsystemd +) + +shared_requires += minifi_extension_external_libraries + +shared_requires += github_pcks_minifi_extension_ext_libs + +linux_requires = ( + +) + +window_requires = ( + +) + +shared_options = { + "shared": [True, False], + "fPIC": [True, False], +} + +shared_default_options = { + "shared": False, + "fPIC": True, +} + +class MiNiFiCppMain(ConanFile): + name = "minifi-cpp-main" + version = "0.99.0" + license = "Apache-2.0" + requires = shared_requires + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_libarchive": [True, False], + "minifi_extension_openssl": [True, False], + "enable_lzma": [True, False], + "enable_bzip2": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_libarchive": True, + "minifi_extension_openssl": False, # NOTE: libarchive integration with openssl is not working; filed a bug with conan-center-index + "enable_lzma": True, + "enable_bzip2": True, + } + url = "https://nifi.apache.org/projects/minifi/" + + def configure_libarchive(self): + self.options["libarchive"].with_openssl = self.options.minifi_extension_openssl + self.options["libarchive"].with_lzma = self.options.enable_lzma + self.options["libarchive"].with_bzip2 = self.options.enable_bzip2 + + def configure(self): + if self.options.enable_libarchive: + self.configure_libarchive() + + def requirements(self): + if self.settings.os == "Windows": + for require in window_requires: + self.requires.add(require) + elif self.settings.os == "Linux": + for require in linux_requires: + self.requires.add(require) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["USE_CONAN_PACKAGER"] = "ON" + tc.cache_variables["USE_CMAKE_FETCH_CONTENT"] = "OFF" + + ## + # NEEDED for MiNiFi C++ Core, MainExe, Standard Processors + ## + tc.cache_variables["ENABLE_OPENWSMAN"] = "ON" + tc.cache_variables["MINIFI_OPENSSL"] = "ON" + tc.cache_variables["ENABLE_CIVET"] = "ON" + tc.cache_variables["ENABLE_CURL"] = "ON" + + ## + # NEEDED for MiNiFi C++ GTESTS + ## + tc.cache_variables["SKIP_TESTS"] = "OFF" + tc.cache_variables["ENABLE_EXPRESSION_LANGUAGE"] = "ON" + # NOTE: Realized Rocksdb depends on ZLib, BZip2, Zstd, Lz4 on standalone CMake and need to be explicitly ON + # whereas for rocksdb conan package, these lib deps are already handled by conan package + tc.cache_variables["ENABLE_BZIP2"] = "ON" + tc.cache_variables["ENABLE_ROCKSDB"] = "ON" + tc.cache_variables["BUILD_ROCKSDB"] = "ON" + + ## + # NEEDED for MiNiFi C++ Extensions + ## + tc.cache_variables["ENABLE_ALL"] = "OFF" + + tc.cache_variables["ENABLE_OPS"] = "ON" + tc.cache_variables["ENABLE_JNI"] = "ON" # for JNI extension, I saw for conan approach, it needs to be updated to use Py Maven Executable + tc.cache_variables["ENABLE_OPC"] = "ON" + tc.cache_variables["ENABLE_NANOFI"] = "ON" + + if self.settings.os == "Windows": + tc.cache_variables["ENABLE_WEL"] = "OFF" + tc.cache_variables["ENABLE_PDH"] = "OFF" + tc.cache_variables["ENABLE_SMB"] = "OFF" + elif self.settings.os == "Linux": + tc.cache_variables["ENABLE_SYSTEMD"] = "ON" + tc.cache_variables["ENABLE_PROCFS"] = "ON" + + tc.cache_variables["ENABLE_LIBARCHIVE"] = "ON" if self.options.enable_libarchive else "OFF" + tc.cache_variables["ENABLE_LZMA"] = "ON" if self.options.enable_lzma else "OFF" + + tc.cache_variables["ENABLE_GPS"] = "ON" + tc.cache_variables["ENABLE_COAP"] = "ON" + tc.cache_variables["ENABLE_SQL"] = "ON" + tc.cache_variables["ENABLE_MQTT"] = "ON" + tc.cache_variables["ENABLE_PCAP"] = "ON" + tc.cache_variables["ENABLE_LIBRDKAFKA"] = "ON" + tc.cache_variables["ENABLE_LUA_SCRIPTING"] = "ON" + tc.cache_variables["ENABLE_PYTHON_SCRIPTING"] = "OFF" + tc.cache_variables["ENABLE_SENSORS"] = "ON" + tc.cache_variables["ENABLE_USB_CAMERA"] = "ON" + tc.cache_variables["ENABLE_AWS"] = "OFF" + tc.cache_variables["ENABLE_OPENCV"] = "ON" + tc.cache_variables["ENABLE_BUSTACHE"] = "OFF" + tc.cache_variables["ENABLE_SFTP"] = "ON" + tc.cache_variables["ENABLE_AZURE"] = "OFF" + tc.cache_variables["ENABLE_ENCRYPT_CONFIG"] = "ON" + tc.cache_variables["ENABLE_SPLUNK"] = "ON" + tc.cache_variables["ENABLE_ELASTICSEARCH"] = "ON" + tc.cache_variables["ENABLE_GCP"] = "OFF" + tc.cache_variables["ENABLE_KUBERNETES"] = "OFF" + tc.cache_variables["ENABLE_TEST_PROCESSORS"] = "ON" + tc.cache_variables["ENABLE_PROMETHEUS"] = "OFF" + tc.cache_variables["ENABLE_GRAFANA_LOKI"] = "ON" + tc.cache_variables["ENABLE_GRPC_FOR_LOKI"] = "ON" + tc.cache_variables["ENABLE_CONTROLLER"] = "ON" + + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() diff --git a/controller/CMakeLists.txt b/controller/CMakeLists.txt index bea1c7eea3..596761a659 100644 --- a/controller/CMakeLists.txt +++ b/controller/CMakeLists.txt @@ -41,7 +41,7 @@ endif() add_minifi_executable(minificontroller ${MINIFI_CONTROLLER_SOURCES}) include(ArgParse) -target_link_libraries(minificontroller ${LIBMINIFI} argparse Threads::Threads) +target_link_libraries(minificontroller ${LIBMINIFI} argparse::argparse Threads::Threads) set_target_properties(minificontroller PROPERTIES OUTPUT_NAME minificontroller diff --git a/controller/tests/CMakeLists.txt b/controller/tests/CMakeLists.txt index b00d3aa8bd..8b4b540e35 100644 --- a/controller/tests/CMakeLists.txt +++ b/controller/tests/CMakeLists.txt @@ -37,7 +37,7 @@ foreach(testfile ${CONTROLLER_TESTS}) createTests(${testfilename}) - target_link_libraries(${testfilename} Catch2WithMain ${LIBMINIFI} ${TEST_BASE_LIB}) + target_link_libraries(${testfilename} Catch2::Catch2WithMain ${LIBMINIFI} ${TEST_BASE_LIB}) add_test(NAME ${testfilename} COMMAND ${testfilename} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") math(EXPR CONTROLLER_TEST_COUNT "${CONTROLLER_TEST_COUNT}+1") diff --git a/docs/devops/README.md b/docs/devops/README.md new file mode 100644 index 0000000000..9f791c9f9f --- /dev/null +++ b/docs/devops/README.md @@ -0,0 +1,300 @@ +# Build MiNiFi C++ + +- Build MiNiFi C++ with Conan & CMake +- Build MiNiFi C++ with CMake +- Appendix: Create Conan Packages for MiNiFi C++ Dependencies + +We show 2 examples of building MiNiFi C++ with the first one being the quick way with conan install and conan build while the second one being the previous way with standalone cmake. The first approach is faster because we use conan 2.2.3 to manage installing the external library dependencies for MiNiFi C++ and these external libraries are represented as prebuilt C++ binary conan packages and thus no need to download source and build source external library dependencies prior to actually building the MiNiFi C++ code. The prevoius approach was building MiNiFi C++ using CMake to first download the external source libraries and build those libraries and then build MiNiFi C++. + +For this particular case, we will build MiNiFi C++'s **core-minifi, minifiexe and minifi-standard-processors** and the external library dependencies and extensions these 3 core assets depend on using conan and then do it using standalone CMake. For conan, we +already configured with tc.cache_variables["{MINIFI_BUILD_ARG0}"] in MiNiFi's conanfile.py to have just these core libraries and binary executables to be built. Similarly, in the case of CMake, we pass definitions to CMake generate, so the similar effect happens. You'll see the MiNiFi C++ conan build approach is faster than the MiNiFi C++ standalone CMake build approach. + + + +## Build MiNiFi C++ with Conan & CMake + +### Install MiNiFi C++ External Lib Deps with Conan + +~~~bash +# conanfile.py is in root dir of MiNiFi C++ project +cd nifi-minifi-cpp + +# In case need to delete all conan packages +conan remove "*" -c + +# 1st: 10:52PM - 10:52PM: + +# install conan packages for MiNiFi C++ from dir conanfile.py is located and any missing prebuilt binary conan packages, build them +# only catch2's prebuilt binary conan package is missing, so it'll be built during install; we'll later upload it to our conan repo +conan install . --build=missing --output-folder=build_conan -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Build MiNiFi C++ Project with Conan CMake + +~~~bash +# 1st SUCCESS: 10:52PM - 10:53PM: + +# install conan packages and build C++ in jam repo using Conan & CMake +conan build . --output-folder=build_conan -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +## Build MiNiFi C++ with CMake + +### Build MiNiFi C++ Project with CMake & Make + +I do want to mention if we build MiNiFi C++ this way using cmake generate and make, the conan cached variables we configured for the MiNiFi C++ options +will not go through when MiNiFi C++ generates the build OS files and then compiles the code. Thus, I recommend we use the conan build approach. + +~~~bash +cd nifi-minifi-cpp + +mkdir build_cmake2 +cd build_cmake2 + +# NOTE: libminifi-http-curl fails without CMAKE_BUILD_TYPE=Debug else cant find libcurl-d.a + +#1st: 9:29PM - 9:29PM; +#2nd: 9:33PM - 9:33PM; +#3rd: 9:35PM - 9:35PM; +#4th: 9:40PM - 9:40PM: +#5th: 9:54PM - 9:55PM: +#6th: 10:01PM - 10:02PM: +# 7th: 10:59PM - 10:59PM: + +# building with gtests too +# 1st: 8:34PM - 8:35PM; 9:10PM - 9:10PM +# The definition args that are ON are for following: + # NEEDED for MiNiFi C++ Core, MainExe, Standard Processors + # NEEDED for MiNiFi C++ GTESTS (SKIP_TESTS=False, ENABLE_EXPRESSION_LANGUAGE, ENABLE_ROCKSDB, BUILD_ROCKSDB) + +# NOTE: To build minifi with JNI and SFTP and its tests requires system java and maven installed + # and the environment variables for java and maven must be set on the system + # However, the conan approach is less reliant on system since conan installs java and maven + # and establishes the necessary environment variables for easier integration with minifi C++ +cmake .. -DUSE_CONAN_PACKAGER=OFF \ + -DUSE_CMAKE_FETCH_CONTENT=ON \ + -DCMAKE_BUILD_TYPE=Debug \ + -DENABLE_OPENWSMAN=ON \ + -DMINIFI_OPENSSL=ON \ + -DENABLE_CIVET=ON \ + -DENABLE_CURL=ON \ + -DSKIP_TESTS=OFF \ + -DENABLE_EXPRESSION_LANGUAGE=ON \ + -DENABLE_BZIP2=ON \ + -DENABLE_ROCKSDB=ON \ + -DBUILD_ROCKSDB=ON \ + -DENABLE_OPS=ON \ + -DENABLE_JNI=ON \ + -DENABLE_OPC=ON \ + -DENABLE_NANOFI=ON \ + -DENABLE_SYSTEMD=ON \ + -DENABLE_PROCFS=ON \ + -DENABLE_ALL=OFF \ + -DENABLE_LIBARCHIVE=ON \ + -DENABLE_LZMA=ON \ + -DENABLE_GPS=ON \ + -DENABLE_COAP=ON \ + -DENABLE_SQL=ON \ + -DENABLE_MQTT=ON \ + -DENABLE_PCAP=ON \ + -DENABLE_LIBRDKAFKA=ON \ + -DENABLE_LUA_SCRIPTING=ON \ + -DENABLE_PYTHON_SCRIPTING=ON \ + -DENABLE_SENSORS=ON \ + -DENABLE_USB_CAMERA=ON \ + -DENABLE_AWS=OFF \ + -DENABLE_OPENCV=ON \ + -DENABLE_BUSTACHE=OFF \ + -DENABLE_SFTP=ON \ + -DENABLE_AZURE=OFF \ + -DENABLE_ENCRYPT_CONFIG=ON \ + -DENABLE_SPLUNK=ON \ + -DENABLE_ELASTICSEARCH=ON \ + -DENABLE_GCP=OFF \ + -DENABLE_KUBERNETES=OFF \ + -DENABLE_TEST_PROCESSORS=ON \ + -DENABLE_PROMETHEUS=OFF \ + -DENABLE_GRAFANA_LOKI=ON \ + -DENABLE_GRPC_FOR_LOKI=ON \ + -DENABLE_CONTROLLER=ON + +#Built MiNiFi C++ Core, MainExe, Standard-Processors & Needed Deps wout GTESTs: +# 1st FAILED: 9:29PM -9:32PM; +# 2nd FAILED: 9:33PM - 9:35PM; +# 3rd FAILED: 9:35PM - 9:37PM: + +make -j $(nproc) + +# 4th FAILED: 9:42PM -9:46PM + +make + +# 5th FAILED: 9:55PM - 10PM: +# 6th SUCCESS: 10:02PM - 10:04PM: +# 7th SUCCESS: 11PM - 11PM: + +make -j $(nproc) + +# Built with GTESTs too +# 1st SUCCESS +make -j $(nproc) +~~~ + +### Tracking MiNiFi C++ Standalone CMake Build Fails + +For reference, while building MiNiFi C++ because we also build the external lib dependencies for building the core-minifi, minifiexe and minifi-standard-processors, we ran into these issues from the extensios on waiting for unfinished jobs and the build failed (we'll rerun MiNiFi C++ to resolve this issue): + +~~~bash +[ 95%] Linking CXX shared library ../../bin/libminifi-civet-extensions.so +[ 95%] Built target minifi-civet-extensions +[ 95%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/PutFile.cpp.o +[ 95%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/PutTCP.cpp.o +[ 96%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/PutUDP.cpp.o +make[1]: *** [CMakeFiles/Makefile2:2878: extensions/openwsman/CMakeFiles/minifi-openwsman.dir/all] Error 2 +make[1]: *** Waiting for unfinished jobs.... +[ 96%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/ReplaceText.cpp.o +[ 96%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/RetryFlowFile.cpp.o +[ 96%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/RouteOnAttribute.cpp.o +[ 97%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/RouteText.cpp.o +make[1]: *** [CMakeFiles/Makefile2:2785: extensions/http-curl/CMakeFiles/minifi-http-curl.dir/all] Error 2 +[ 97%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/SplitText.cpp.o +[ 97%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/TailFile.cpp.o +[ 98%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/processors/UpdateAttribute.cpp.o +[ 98%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/utils/JoltUtils.cpp.o +[ 98%] Building CXX object extensions/standard-processors/CMakeFiles/minifi-standard-processors.dir/__/__/ExtensionBuildInfo.cpp.o +[ 99%] Linking CXX executable ../bin/minifi +[ 99%] Built target minifiexe +[100%] Linking CXX shared library ../../bin/libminifi-standard-processors.so +[100%] Built target minifi-standard-processors +make: *** [Makefile:156: all] Error 2 +~~~ + +We look further into this failure, we see the problem comes from libcurl: + +~~~bash +ubuntu@ezedgepipeline ~/src/james/pipeline/nifi-minifi-cpp/build_cmake (MINIFICPP-2346)$ make -j $(nproc) +[ 4%] Built target ossp-uuid-external-build +[ 4%] Built target openssl-external +[ 6%] Built target libsodium-external-build +[ 9%] Built target zlib-external +[ 10%] Built target date-tz +[ 11%] Built target fmt +[ 14%] Built target yaml-cpp-external +[ 16%] Built target libxml2-external-build +[ 16%] Built target ossp-uuid-external +[ 17%] Built target libsodium-external +[ 19%] Built target curl-external +[ 20%] Built target civetweb-c-library +[ 20%] Built target libxml2-external +[ 22%] Built target spdlog +[ 25%] Built target openwsman-external +[ 25%] Built target civetweb-c-executable +[ 25%] Built target civetweb-cpp +[ 82%] Built target core-minifi +Consolidate compiler generated dependencies of target minifi-openwsman +[ 83%] Built target minifi-civet-extensions +make[2]: *** No rule to make target 'thirdparty/curl-install/lib/libcurl-d.a', needed by 'bin/libminifi-openwsman.so'. Stop. +make[1]: *** [CMakeFiles/Makefile2:2878: extensions/openwsman/CMakeFiles/minifi-openwsman.dir/all] Error 2 +make[1]: *** Waiting for unfinished jobs.... +make[2]: *** No rule to make target 'thirdparty/curl-install/lib/libcurl-d.a', needed by 'bin/libminifi-http-curl.so'. Stop. +make[1]: *** [CMakeFiles/Makefile2:2785: extensions/http-curl/CMakeFiles/minifi-http-curl.dir/all] Error 2 +[ 85%] Built target minifiexe +[ 96%] Built target minifi-standard-processors +make: *** [Makefile:156: all] Error 2 +~~~ + +My guess is libcurl failed to download using ExternalProject_Add(curl-external ...). Thus, openwsman complains about not having that dependency. + +Now after building on single core, it shows the issue was coming from libminifi-http-curl.so depending on libcurl-d.a: + +~~~bash +[100%] Built target libcurl_static +[ 78%] Performing install step for 'curl-external' +Consolidate compiler generated dependencies of target libcurl_static +[100%] Built target libcurl_static +Install the project... +-- Install configuration: "" +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/lib/libcurl.a +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/bin/curl-config +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/lib/pkgconfig/libcurl.pc +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/options.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/stdcheaders.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/curlver.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/easy.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/urlapi.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/multi.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/websockets.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/mprintf.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/header.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/system.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/curl.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/include/curl/typecheck-gcc.h +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/lib/cmake/CURL/CURLTargets.cmake +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/lib/cmake/CURL/CURLTargets-noconfig.cmake +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/lib/cmake/CURL/CURLConfigVersion.cmake +-- Installing: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/thirdparty/curl-install/lib/cmake/CURL/CURLConfig.cmake +[ 78%] Completed 'curl-external' +[ 78%] Built target curl-external +[ 79%] Building CXX object extensions/http-curl/CMakeFiles/minifi-http-curl.dir/HTTPCurlLoader.cpp.o +[ 79%] Building CXX object extensions/http-curl/CMakeFiles/minifi-http-curl.dir/client/HTTPClient.cpp.o +[ 79%] Building CXX object extensions/http-curl/CMakeFiles/minifi-http-curl.dir/client/HTTPStream.cpp.o +[ 80%] Building CXX object extensions/http-curl/CMakeFiles/minifi-http-curl.dir/processors/InvokeHTTP.cpp.o +[ 80%] Building CXX object extensions/http-curl/CMakeFiles/minifi-http-curl.dir/protocols/RESTSender.cpp.o +[ 80%] Building CXX object extensions/http-curl/CMakeFiles/minifi-http-curl.dir/sitetosite/HTTPProtocol.cpp.o +[ 81%] Building CXX object extensions/http-curl/CMakeFiles/minifi-http-curl.dir/__/__/ExtensionBuildInfo.cpp.o +make[2]: *** No rule to make target 'thirdparty/curl-install/lib/libcurl-d.a', needed by 'bin/libminifi-http-curl.so'. Stop. +make[1]: *** [CMakeFiles/Makefile2:2785: extensions/http-curl/CMakeFiles/minifi-http-curl.dir/all] Error 2 +make: *** [Makefile:156: all] Error 2 +~~~ + +NOTE: I found the issue about why we get libminifi-http-curl.so failing and expecting libcurl-d.a is because we dont build minifi cpp in debug mode. However, if we want to build minifi cpp in release mode, libminifi-http-curl should be able to take either build type and succeed. For now, I will build minifi cpp in debug mode + + +Heres another problem that comes up from downloading the zlib external lib: + +~~~bash +[ 17%] Completed 'libsodium-external' +[ 17%] Built target libsodium-external + +CMake Error at /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/build_cmake/zlib-external-prefix/src/zlib-external-stamp/download-zlib-external.cmake:170 (message): + Each download failed! + + error: downloading 'https://github.com/madler/zlib/archive/v1.2.11.tar.gz' failed + status_code: 28 + status_string: "Timeout was reached" + log: + --- LOG BEGIN --- + Trying 140.82.116.3:443... + + Connected to github.com (140.82.116.3) port 443 (#0) + + ALPN: offers h2 + + ALPN: offers http/1.1 + + TLSv1.0 (OUT), TLS header, Certificate Status (22): + + [5 bytes data] + + TLSv1.3 (OUT), TLS handshake, Client hello (1): + + [512 bytes data] + + SSL connection timeout + + Closing connection 0 + + + + --- LOG END --- +~~~ + +## Appendix: Create Conan Packages for MiNiFi C++ Dependencies + +~~~bash +pushd nifi-minifi-cpp/thirdparty/rocksdb/all +conan create . --version=8.10.2 --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +More information on our conan packages: **`nifi-minifi-cpp/thirdparty/README.md`** diff --git a/encrypt-config/CMakeLists.txt b/encrypt-config/CMakeLists.txt index cfa4365642..25816a30ef 100644 --- a/encrypt-config/CMakeLists.txt +++ b/encrypt-config/CMakeLists.txt @@ -26,7 +26,7 @@ endif() add_minifi_executable(encrypt-config "${ENCRYPT_CONFIG_FILES}") target_include_directories(encrypt-config PRIVATE ../libminifi/include) include(ArgParse) -target_link_libraries(encrypt-config libsodium argparse ${LIBMINIFI}) +target_link_libraries(encrypt-config libsodium::libsodium argparse::argparse ${LIBMINIFI}) set_target_properties(encrypt-config PROPERTIES OUTPUT_NAME encrypt-config) set_target_properties(encrypt-config PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") diff --git a/encrypt-config/tests/CMakeLists.txt b/encrypt-config/tests/CMakeLists.txt index a394a3c97d..f03555bbcf 100644 --- a/encrypt-config/tests/CMakeLists.txt +++ b/encrypt-config/tests/CMakeLists.txt @@ -32,7 +32,7 @@ foreach(testfile ${ENCRYPT_CONFIG_TESTS}) createTests(${testfilename}) - target_link_libraries(${testfilename} Catch2WithMain ${LIBMINIFI} ${TEST_BASE_LIB}) + target_link_libraries(${testfilename} Catch2::Catch2WithMain ${LIBMINIFI} ${TEST_BASE_LIB}) add_test(NAME ${testfilename} COMMAND ${testfilename} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") math(EXPR ENCRYPT_CONFIG_TEST_COUNT "${ENCRYPT_CONFIG_TEST_COUNT}+1") diff --git a/extensions/aws/tests/CMakeLists.txt b/extensions/aws/tests/CMakeLists.txt index 6d99060abc..481888bcc8 100644 --- a/extensions/aws/tests/CMakeLists.txt +++ b/extensions/aws/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${AWS_INTEGRATION_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/expression-language") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-aws) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-expression-language-extensions) diff --git a/extensions/azure/tests/CMakeLists.txt b/extensions/azure/tests/CMakeLists.txt index 195cea6f8f..fadd46dffe 100644 --- a/extensions/azure/tests/CMakeLists.txt +++ b/extensions/azure/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${AZURE_INTEGRATION_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") target_compile_features(${testfilename} PRIVATE cxx_std_14) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-azure) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-expression-language-extensions) diff --git a/extensions/bustache/tests/CMakeLists.txt b/extensions/bustache/tests/CMakeLists.txt index 9b03bc98aa..6e5b417a1b 100644 --- a/extensions/bustache/tests/CMakeLists.txt +++ b/extensions/bustache/tests/CMakeLists.txt @@ -31,7 +31,7 @@ FOREACH(testfile ${BUSTACHE_INTEGRATION_TESTS}) target_link_libraries(${testfilename} minifi-standard-processors) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) MATH(EXPR BUSTACHE-EXTENSIONS_TEST_COUNT "${BUSTACHE-EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/extensions/civetweb/CMakeLists.txt b/extensions/civetweb/CMakeLists.txt index 0eab2b98cd..b0cf95e2ea 100644 --- a/extensions/civetweb/CMakeLists.txt +++ b/extensions/civetweb/CMakeLists.txt @@ -32,7 +32,13 @@ target_include_directories(minifi-civet-extensions BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/thirdparty/ ${civetweb_SOURCE_DIR}/include ./include) -target_link_libraries(minifi-civet-extensions ${LIBMINIFI} Threads::Threads civetweb::civetweb-cpp civetweb::c-library) + +if(USE_CONAN_PACKAGER) + message("Using Conan ignoring linknig civetweb::civetweb") + target_link_libraries(minifi-civet-extensions ${LIBMINIFI} Threads::Threads civetweb::civetweb-cpp) +elseif(USE_CMAKE_FETCH_CONTENT) + target_link_libraries(minifi-civet-extensions ${LIBMINIFI} Threads::Threads civetweb::civetweb-cpp civetweb::c-library) +endif() register_extension(minifi-civet-extensions CIVETWEB CIVETWEB "This enables ListenHTTP" "extensions/civetweb/tests") register_extension_linter(minifi-civet-extensions-linter) diff --git a/extensions/civetweb/tests/CMakeLists.txt b/extensions/civetweb/tests/CMakeLists.txt index 180617872a..9ad6a85ee8 100644 --- a/extensions/civetweb/tests/CMakeLists.txt +++ b/extensions/civetweb/tests/CMakeLists.txt @@ -34,7 +34,7 @@ if(ENABLE_CURL) target_link_libraries(${testfilename} minifi-standard-processors) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) MATH(EXPR CIVETWEB-EXTENSIONS_TEST_COUNT "${CIVETWEB-EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) # Copy test resources diff --git a/extensions/elasticsearch/tests/CMakeLists.txt b/extensions/elasticsearch/tests/CMakeLists.txt index 516b606e91..c244cfccf1 100644 --- a/extensions/elasticsearch/tests/CMakeLists.txt +++ b/extensions/elasticsearch/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${ELASTICSEARCH_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/http-curl/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-elasticsearch) target_link_libraries(${testfilename} minifi-civet-extensions) target_link_libraries(${testfilename} minifi-http-curl) diff --git a/extensions/expression-language/tests/CMakeLists.txt b/extensions/expression-language/tests/CMakeLists.txt index c427efa289..91b0e95034 100644 --- a/extensions/expression-language/tests/CMakeLists.txt +++ b/extensions/expression-language/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${EXPRESSION_LANGUAGE_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/expression-language") createTests(${testfilename}) - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) if(ENABLE_CURL) target_link_libraries(${testfilename} CURL::libcurl) endif() diff --git a/extensions/gps/tests/CMakeLists.txt b/extensions/gps/tests/CMakeLists.txt index 02e831b210..b98a815baa 100644 --- a/extensions/gps/tests/CMakeLists.txt +++ b/extensions/gps/tests/CMakeLists.txt @@ -28,7 +28,7 @@ FOREACH(testfile ${GPS_INTEGRATION_TESTS}) createTests("${testfilename}") target_link_libraries(${testfilename} minifi-gps) target_link_libraries(${testfilename} minifi-standard-processors) - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) MATH(EXPR GPS_TEST_COUNT "${GPS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/extensions/grafana-loki/CMakeLists.txt b/extensions/grafana-loki/CMakeLists.txt index 79e4af7738..2b9e287317 100644 --- a/extensions/grafana-loki/CMakeLists.txt +++ b/extensions/grafana-loki/CMakeLists.txt @@ -32,11 +32,12 @@ if (ENABLE_GRPC_FOR_LOKI) add_custom_command( OUTPUT ${LOKI_PROTOBUF_GENERATED_DIR}/grafana-loki-push.grpc.pb.cc ${LOKI_PROTOBUF_GENERATED_DIR}/grafana-loki-push.grpc.pb.h ${LOKI_PROTOBUF_GENERATED_DIR}/grafana-loki-push.pb.h ${LOKI_PROTOBUF_GENERATED_DIR}/grafana-loki-push.pb.cc COMMAND ${PROTOBUF_COMPILER} --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} -I=${CMAKE_CURRENT_SOURCE_DIR}/protos/ -I=${protobuf_SOURCE_DIR}/src --grpc_out=${LOKI_PROTOBUF_GENERATED_DIR} --cpp_out=${LOKI_PROTOBUF_GENERATED_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/protos/grafana-loki-push.proto - DEPENDS protobuf::protoc grpc_cpp_plugin) + DEPENDS protobuf::protoc ${GRPC_CPP_PLUGIN}) + message("ABSL_INCLUDE_DIRS = ${ABSL_INCLUDE_DIRS}") add_library(grafana-loki-protos ${LOKI_PROTOBUF_GENERATED_DIR}/grafana-loki-push.grpc.pb.cc ${LOKI_PROTOBUF_GENERATED_DIR}/grafana-loki-push.pb.cc) - target_include_directories(grafana-loki-protos SYSTEM PRIVATE BEFORE "${LOKI_PROTOBUF_GENERATED_DIR}" "${GRPC_INCLUDE_DIR}" "${PROTOBUF_INCLUDE_DIR}") - target_link_libraries(grafana-loki-protos grpc++ protobuf::libprotobuf) + target_include_directories(grafana-loki-protos SYSTEM PRIVATE BEFORE "${LOKI_PROTOBUF_GENERATED_DIR}" "${GRPC_INCLUDE_DIR}" "${PROTOBUF_INCLUDE_DIR}" "${ABSL_INCLUDE_DIRS}") + target_link_libraries(grafana-loki-protos gRPC::grpc++ protobuf::libprotobuf) file(GLOB SOURCES "*.cpp") @@ -52,12 +53,12 @@ else() endif() add_minifi_library(minifi-grafana-loki SHARED ${SOURCES}) -target_include_directories(minifi-grafana-loki PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/http-curl") +target_include_directories(minifi-grafana-loki PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/http-curl" "${ABSL_INCLUDE_DIRS}") target_link_libraries(minifi-grafana-loki ${LIBMINIFI} minifi-http-curl) add_dependencies(minifi-grafana-loki minifi-http-curl) if (ENABLE_GRPC_FOR_LOKI) - target_include_directories(minifi-grafana-loki SYSTEM PRIVATE BEFORE "${LOKI_PROTOBUF_GENERATED_DIR}" "${GRPC_INCLUDE_DIR}" "${PROTOBUF_INCLUDE_DIR}") + target_include_directories(minifi-grafana-loki SYSTEM PRIVATE BEFORE "${LOKI_PROTOBUF_GENERATED_DIR}" "${GRPC_INCLUDE_DIR}" "${PROTOBUF_INCLUDE_DIR}" "${ABSL_INCLUDE_DIRS}") target_link_libraries(minifi-grafana-loki grafana-loki-protos) add_dependencies(minifi-grafana-loki grafana-loki-protos) endif() diff --git a/extensions/grafana-loki/tests/CMakeLists.txt b/extensions/grafana-loki/tests/CMakeLists.txt index a98a0e4240..0f37dff1f3 100644 --- a/extensions/grafana-loki/tests/CMakeLists.txt +++ b/extensions/grafana-loki/tests/CMakeLists.txt @@ -36,7 +36,7 @@ FOREACH(testfile ${GRAFANA_LOKI_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/http-curl/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-grafana-loki) target_link_libraries(${testfilename} minifi-civet-extensions) target_link_libraries(${testfilename} minifi-http-curl) diff --git a/extensions/http-curl/tests/CMakeLists.txt b/extensions/http-curl/tests/CMakeLists.txt index 250b82ca53..edebf8277d 100644 --- a/extensions/http-curl/tests/CMakeLists.txt +++ b/extensions/http-curl/tests/CMakeLists.txt @@ -35,7 +35,7 @@ FOREACH(testfile ${CURL_UNIT_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/civetweb/") target_include_directories(${testfilename} BEFORE PRIVATE ./include) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-http-curl) target_link_libraries(${testfilename} minifi-civet-extensions) target_link_libraries(${testfilename} minifi-standard-processors) diff --git a/extensions/jni/CMakeLists.txt b/extensions/jni/CMakeLists.txt index 833675fa15..6c22a3d9ab 100644 --- a/extensions/jni/CMakeLists.txt +++ b/extensions/jni/CMakeLists.txt @@ -25,9 +25,11 @@ include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) message(STATUS "JAVA_HOME: '$ENV{JAVA_HOME}'") find_package(JNI REQUIRED) -find_package(Java REQUIRED) -find_package(Maven REQUIRED) -message(STATUS "MAVEN: ${MAVEN_EXECUTABLE}") + +include(JavaOpenJDK) +include(JavaMaven) + +message(STATUS "MAVEN: $ENV{MAVEN_EXECUTABLE}") include_directories(${JNI_INCLUDE_DIRS}) file(GLOB SOURCES "jvm/*.cpp" "*.cpp") @@ -45,27 +47,69 @@ set(JNI_ASSEMBLY_JAR_BIN "${CMAKE_CURRENT_BINARY_DIR}/" ) file(COPY ${JNI_FRAMEWORK_JAR_SOURCE} DESTINATION ${JNI_FRAMEWORK_JAR_BIN}) file(COPY ${JNI_ASSEMBLY_JAR_SOURCE} DESTINATION ${JNI_ASSEMBLY_JAR_BIN}) -message("Building NiFi assembly for packaging ....") +message(STATUS "Building NiFi assembly for packaging ....") # duplicating the execute_process because a version of cmake tested exhibited failures # with an empty cmd before ${MAVEN_EXECUTABLE}. Until this is resolved ( or proven to be a non cmake issue on all versions) # we should stick with the the minor duplication -if (WIN32) - execute_process(COMMAND cmd /c "${MAVEN_EXECUTABLE}" "-q" "package" "-Denforcer.skip=true" - WORKING_DIRECTORY "${JNI_ASSEMBLY_JAR_BIN}/nifi-minifi-jni-assembly" - RESULT_VARIABLE mvn_result - OUTPUT_VARIABLE mvn_output - ERROR_VARIABLE mvn_error) +if(USE_CONAN_PACKAGER) + set(MAVEN_ARG1 "-q") + set(MAVEN_ARG2 "package") + set(MAVEN_ARG3 "-Denforcer.skip=true") + set(JNI_ASSEMBLY_WORKING_DIR "${JNI_ASSEMBLY_JAR_BIN}/nifi-minifi-jni-assembly") + + message("-----Prep Conan Py Maven Command: ${PY_MAVEN_EXECUTABLE}") + message("-----Passed Maven Args to Py Script: ${MAVEN_ARG1} ${MAVEN_ARG2} ${MAVEN_ARG3}") + message("-----Passed Working Dir to Py Script: ${JNI_ASSEMBLY_WORKING_DIR}") + message("-----Execute Py Maven Script to build Apache NiFi JNI Assembly") + if (WIN32) + execute_process(COMMAND cmd /c "${PY_MAVEN_EXECUTABLE}" + --maven_executable=$ENV{MAVEN_EXECUTABLE} + --working_directory=${JNI_ASSEMBLY_WORKING_DIR} + --maven_arg1=${MAVEN_ARG1} + --maven_arg2=${MAVEN_ARG2} + --maven_arg3=${MAVEN_ARG3} + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error + ) + else() + execute_process(COMMAND ${PY_MAVEN_EXECUTABLE} + --maven_executable=$ENV{MAVEN_EXECUTABLE} + --working_directory=${JNI_ASSEMBLY_WORKING_DIR} + --maven_arg1=${MAVEN_ARG1} + --maven_arg2=${MAVEN_ARG2} + --maven_arg3=${MAVEN_ARG3} + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error + ) + endif() + else() - execute_process(COMMAND "${MAVEN_EXECUTABLE}" "-q" "package" "-Denforcer.skip=true" - WORKING_DIRECTORY "${JNI_ASSEMBLY_JAR_BIN}/nifi-minifi-jni-assembly" - RESULT_VARIABLE mvn_result - OUTPUT_VARIABLE mvn_output - ERROR_VARIABLE mvn_error) + + if (WIN32) + execute_process(COMMAND cmd /c "${MAVEN_EXECUTABLE}" "-q" "package" "-Denforcer.skip=true" + WORKING_DIRECTORY "${JNI_ASSEMBLY_JAR_BIN}/nifi-minifi-jni-assembly" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + else() + execute_process(COMMAND "${MAVEN_EXECUTABLE}" "-q" "package" "-Denforcer.skip=true" + WORKING_DIRECTORY "${JNI_ASSEMBLY_JAR_BIN}/nifi-minifi-jni-assembly" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + endif() + endif() + if("${mvn_result}" STREQUAL "0") message("${mvn_output}") - install(DIRECTORY "${JNI_ASSEMBLY_JAR_BIN}/nifi-minifi-jni-assembly/target/nifi-minifi-jni-minifi-jni/nifi-minifi-jni-1.9.0/minifi-jni" + SET (JNI-ASSEMBLY-JAR-DIR "${JNI_ASSEMBLY_JAR_BIN}/nifi-minifi-jni-assembly/target/nifi-minifi-jni-minifi-jni/nifi-minifi-jni-1.9.0/minifi-jni") + message("....Successfully Produced ${JNI-ASSEMBLY-JAR-DIR}....") + + install(DIRECTORY "${JNI-ASSEMBLY-JAR-DIR}" DESTINATION . COMPONENT bin) @@ -73,26 +117,60 @@ else() message("Maven failed ${mvn_result} ${mvn_output} ${mvn_error}") endif() -message("Building NiFi JNI Jar for packaging ....") +message(STATUS "Building NiFi JNI Jar for packaging ....") + +if(USE_CONAN_PACKAGER) + set(MAVEN_ARG1 "-q") + set(MAVEN_ARG2 "package") + set(JNI_FRAMEWORK_WORKING_DIR "${JNI_FRAMEWORK_JAR_BIN}/nifi-framework-jni") + + message("-----Prep Conan Py Maven Command: ${PY_MAVEN_EXECUTABLE}") + message("-----Passed Maven Args to Py Script: ${MAVEN_ARG1} ${MAVEN_ARG2} ${MAVEN_ARG3}") + message("-----Passed Working Dir to Py Script: ${JNI_FRAMEWORK_WORKING_DIR}") + message("-----Execute Py Maven Script to build Apache NiFi JNI Framework") + if (WIN32) + execute_process(COMMAND cmd /c "${PY_MAVEN_EXECUTABLE}" + --maven_executable=$ENV{MAVEN_EXECUTABLE} + --working_directory=${JNI_FRAMEWORK_WORKING_DIR} + --maven_arg1=${MAVEN_ARG1} + --maven_arg2=${MAVEN_ARG2} + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error + ) + else() + execute_process(COMMAND ${PY_MAVEN_EXECUTABLE} + --maven_executable=$ENV{MAVEN_EXECUTABLE} + --working_directory=${JNI_FRAMEWORK_WORKING_DIR} + --maven_arg1=${MAVEN_ARG1} + --maven_arg2=${MAVEN_ARG2} + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error + ) + endif() -if (WIN32) - execute_process(COMMAND cmd /c "${MAVEN_EXECUTABLE}" "-q" "package" - WORKING_DIRECTORY "${JNI_FRAMEWORK_JAR_BIN}/nifi-framework-jni" - RESULT_VARIABLE mvn_result - OUTPUT_VARIABLE mvn_output - ERROR_VARIABLE mvn_error) else() - execute_process(COMMAND "${MAVEN_EXECUTABLE}" "-q" "package" - WORKING_DIRECTORY "${JNI_FRAMEWORK_JAR_BIN}/nifi-framework-jni" - RESULT_VARIABLE mvn_result - OUTPUT_VARIABLE mvn_output - ERROR_VARIABLE mvn_error) + + if (WIN32) + execute_process(COMMAND cmd /c "${MAVEN_EXECUTABLE}" "-q" "package" + WORKING_DIRECTORY "${JNI_FRAMEWORK_JAR_BIN}/nifi-framework-jni" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + else() + execute_process(COMMAND "${MAVEN_EXECUTABLE}" "-q" "package" + WORKING_DIRECTORY "${JNI_FRAMEWORK_JAR_BIN}/nifi-framework-jni" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + endif() + endif() if("${mvn_result}" STREQUAL "0") message("${mvn_output}") SET (JNI-FRAMEWORK-JAR "${JNI_FRAMEWORK_JAR_BIN}/nifi-framework-jni/target/nifi-framework-jni-1.9.0.jar") - message("Produced ${JNI-FRAMEWORK-JAR}") - message("${mvn_output}") + message("....Successfully Produced ${JNI-FRAMEWORK-JAR}....") install(FILES ${JNI-FRAMEWORK-JAR} DESTINATION minifi-jni/lib COMPONENT bin) diff --git a/extensions/kubernetes/tests/CMakeLists.txt b/extensions/kubernetes/tests/CMakeLists.txt index 09d982d581..8dd9cb8eed 100644 --- a/extensions/kubernetes/tests/CMakeLists.txt +++ b/extensions/kubernetes/tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(TEST_FILE ${KUBERNETES_UNIT_TESTS}) target_include_directories(${TEST_TARGET} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test") target_include_directories(${TEST_TARGET} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/kubernetes") target_link_libraries(${TEST_TARGET} minifi-kubernetes-extensions) - target_link_libraries(${TEST_TARGET} Catch2WithMain) + target_link_libraries(${TEST_TARGET} Catch2::Catch2WithMain) createTests("${TEST_TARGET}") add_test(NAME ${TEST_TARGET} COMMAND "${TEST_TARGET}" WORKING_DIRECTORY "${TEST_DIR}") MATH(EXPR KUBERNETES_UNIT_TEST_COUNT "${KUBERNETES_UNIT_TEST_COUNT}+1") diff --git a/extensions/libarchive/tests/CMakeLists.txt b/extensions/libarchive/tests/CMakeLists.txt index 10bd7d5580..7c2ee59a52 100644 --- a/extensions/libarchive/tests/CMakeLists.txt +++ b/extensions/libarchive/tests/CMakeLists.txt @@ -29,7 +29,7 @@ FOREACH(testfile ${ARCHIVE_INTEGRATION_TESTS}) target_link_libraries(${testfilename} minifi-archive-extensions) target_link_libraries(${testfilename} minifi-standard-processors) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/extensions/librdkafka/tests/CMakeLists.txt b/extensions/librdkafka/tests/CMakeLists.txt index aaec9c4969..ac3b48c47e 100644 --- a/extensions/librdkafka/tests/CMakeLists.txt +++ b/extensions/librdkafka/tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(testfile ${KAFKA_INTEGRATION_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/librdkafka") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-rdkafka-extensions) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") diff --git a/extensions/lua/CMakeLists.txt b/extensions/lua/CMakeLists.txt index ed0766e9bc..79b911f583 100644 --- a/extensions/lua/CMakeLists.txt +++ b/extensions/lua/CMakeLists.txt @@ -35,10 +35,10 @@ target_link_libraries(minifi-lua-script-extension PRIVATE ${LIBMINIFI} Threads:: SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC) -target_include_directories(minifi-lua-script-extension PRIVATE lua) +# target_include_directories(minifi-lua-script-extension PRIVATE lua::lua) target_include_directories(minifi-lua-script-extension PUBLIC ${LUA_INCLUDE_DIR}) -target_link_libraries(minifi-lua-script-extension PUBLIC lua sol2) +target_link_libraries(minifi-lua-script-extension PUBLIC lua::lua sol2::sol2) target_compile_features(minifi-lua-script-extension PUBLIC cxx_std_14) register_extension(minifi-lua-script-extension "LUA SCRIPTING EXTENSIONS" LUA-SCRIPTING-EXTENSIONS "This enables LUA scripting" "extensions/lua/tests") diff --git a/extensions/lua/tests/CMakeLists.txt b/extensions/lua/tests/CMakeLists.txt index a64bbcaef6..31af2c6fd7 100644 --- a/extensions/lua/tests/CMakeLists.txt +++ b/extensions/lua/tests/CMakeLists.txt @@ -28,7 +28,7 @@ FOREACH(testfile ${EXECUTESCRIPT_LUA_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") target_include_directories(${testfilename} SYSTEM PRIVATE BEFORE "${SOL2_INCLUDE_DIR}") target_link_libraries(${testfilename} minifi-lua-script-extension minifi-script-extension) - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) createTests("${testfilename}") MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/extensions/mqtt/tests/CMakeLists.txt b/extensions/mqtt/tests/CMakeLists.txt index d5b408a64a..913eb1ef77 100644 --- a/extensions/mqtt/tests/CMakeLists.txt +++ b/extensions/mqtt/tests/CMakeLists.txt @@ -25,7 +25,7 @@ FOREACH(testfile ${MQTT_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../../extensions/standard-processors") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../../../libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-mqtt-extensions) target_link_libraries(${testfilename} minifi-standard-processors) add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/extensions/opc/CMakeLists.txt b/extensions/opc/CMakeLists.txt index 9f1267cf92..0d120de83d 100644 --- a/extensions/opc/CMakeLists.txt +++ b/extensions/opc/CMakeLists.txt @@ -38,7 +38,7 @@ file(GLOB SOURCES "src/*.cpp") add_minifi_library(minifi-opc-extensions SHARED ${SOURCES}) target_link_libraries(minifi-opc-extensions ${LIBMINIFI} Threads::Threads) -target_link_libraries(minifi-opc-extensions ${CMAKE_DL_LIBS} spdlog open62541::open62541) +target_link_libraries(minifi-opc-extensions ${CMAKE_DL_LIBS} spdlog::spdlog open62541::open62541) register_extension(minifi-opc-extensions "OPC EXTENSIONS" OPC-EXTENSIONS "This enables OPC-UA support") register_extension_linter(minifi-opc-extensions-linter) diff --git a/extensions/opencv/tests/CMakeLists.txt b/extensions/opencv/tests/CMakeLists.txt index d095c7e9a2..cc34d8550f 100644 --- a/extensions/opencv/tests/CMakeLists.txt +++ b/extensions/opencv/tests/CMakeLists.txt @@ -31,6 +31,6 @@ FOREACH(testfile ${OPENCV_TESTS}) createTests("${testfilename}") MATH(EXPR OPENCV_TEST_COUNT "${OPENCV_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) ENDFOREACH() message("-- Finished building ${OPENCV_TEST_COUNT} OpenCV related test file(s)...") diff --git a/extensions/openwsman/CMakeLists.txt b/extensions/openwsman/CMakeLists.txt index f7152cad9b..a9a14a3a95 100644 --- a/extensions/openwsman/CMakeLists.txt +++ b/extensions/openwsman/CMakeLists.txt @@ -31,7 +31,12 @@ file(GLOB SOURCES "processors/*.cpp") add_minifi_library(minifi-openwsman SHARED ${SOURCES}) target_link_libraries(minifi-openwsman ${LIBMINIFI} Threads::Threads) -target_link_libraries(minifi-openwsman OpenWSMAN::libwsman civetweb::civetweb-cpp civetweb::c-library LibXml2::LibXml2) + +if(USE_CONAN_PACKAGER) + target_link_libraries(minifi-openwsman OpenWSMAN::libwsman civetweb::civetweb LibXml2::LibXml2) +elseif(USE_CMAKE_FETCH_CONTENT) + target_link_libraries(minifi-openwsman OpenWSMAN::libwsman civetweb::civetweb-cpp civetweb::c-library LibXml2::LibXml2) +endif() register_extension(minifi-openwsman "OPENWSMAN EXTENSIONS" OPENWSMAN-EXTENSIONS "This enables Openwsman support") register_extension_linter(minifi-openwsman-linter) diff --git a/extensions/pcap/CMakeLists.txt b/extensions/pcap/CMakeLists.txt index bb71aa3082..726af27d82 100644 --- a/extensions/pcap/CMakeLists.txt +++ b/extensions/pcap/CMakeLists.txt @@ -21,56 +21,19 @@ if(NOT (ENABLE_ALL OR ENABLE_PCAP)) return() endif() -find_package(PCAP REQUIRED) +include(BundledLibPcap) +use_bundled_libpcap(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) -include(FetchContent) - -FetchContent_Declare(pcapplusplus - URL https://github.com/seladb/PcapPlusPlus/archive/refs/tags/v22.05.tar.gz - URL_HASH SHA256=5f299c4503bf5d3c29f82b8d876a19be7dea29c2aadcb52f2f3b394846c21da9 - ) -FetchContent_MakeAvailable(pcapplusplus) +include(BundledPcapPlusPlus) +use_bundled_pcapplusplus(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) -set(PCAPPLUSPLUS_TP_BASE_DIR "${pcapplusplus_SOURCE_DIR}/") -set(PCAPPLUSPLUS_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pcap++" ) -set(PCAPPLUSPLUS_BASE_DIR PCAPPLUSPLUS_BASE_DIR PARENT_SCOPE) -set(PCAPPLUSPLUS_HEADER_DIR "${PCAPPLUSPLUS_BASE_DIR}/Dist/header" ) -set(PCAPPLUSPLUS_HEADER_DIR PCAPPLUSPLUS_HEADER_DIR PARENT_SCOPE) - -file(COPY ${PCAPPLUSPLUS_TP_BASE_DIR} DESTINATION ${PCAPPLUSPLUS_BASE_DIR}) - -if (WIN32) - execute_process(COMMAND ${PCAPPLUSPLUS_BASE_DIR}/configure-windows-visual-studio.bat WORKING_DIRECTORY ${PCAPPLUSPLUS_BASE_DIR}) -elseif (APPLE) - execute_process(COMMAND ${PCAPPLUSPLUS_BASE_DIR}/configure-mac_os_x.sh WORKING_DIRECTORY ${PCAPPLUSPLUS_BASE_DIR}) -else () - execute_process(COMMAND ${PCAPPLUSPLUS_BASE_DIR}/configure-linux.sh --default WORKING_DIRECTORY ${PCAPPLUSPLUS_BASE_DIR}) -endif () - -set(PCAPPLUSPLUS_LIB_DIR "${PCAPPLUSPLUS_BASE_DIR}/Dist") - -add_custom_target( - pcappp - COMMAND make libs - BYPRODUCTS ${PCAPPLUSPLUS_LIB_DIR}/libPcap++.a ${PCAPPLUSPLUS_LIB_DIR}/libPacket++.a ${PCAPPLUSPLUS_LIB_DIR}/libCommon++.a - WORKING_DIRECTORY ${PCAPPLUSPLUS_BASE_DIR} -) - file(GLOB SOURCES "*.cpp") add_minifi_library(minifi-pcap SHARED ${SOURCES}) -target_include_directories(minifi-pcap PRIVATE ${PCAPPLUSPLUS_HEADER_DIR}) - -add_dependencies(minifi-pcap pcappp) -target_link_libraries (minifi-pcap ${PCAPPLUSPLUS_LIB_DIR}/libPcap++.a ${PCAPPLUSPLUS_LIB_DIR}/libPacket++.a ${PCAPPLUSPLUS_LIB_DIR}/libCommon++.a ${PCAP_LIBRARIES}) -if (APPLE) - target_link_libraries(minifi-pcap "-framework CoreFoundation") - target_link_libraries(minifi-pcap "-framework SystemConfiguration") - set_target_properties(minifi-pcap PROPERTIES LINK_FLAGS "-Wl,-F/Library/Frameworks") -endif () +target_link_libraries(minifi-pcap pcapplusplus::pcapplusplus) target_link_libraries(minifi-pcap ${LIBMINIFI} Threads::Threads) diff --git a/extensions/pdh/tests/CMakeLists.txt b/extensions/pdh/tests/CMakeLists.txt index d50549f337..28b8cf7335 100644 --- a/extensions/pdh/tests/CMakeLists.txt +++ b/extensions/pdh/tests/CMakeLists.txt @@ -27,7 +27,7 @@ FOREACH(testfile ${PDH_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/pdh") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-pdh) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR PDH_TEST_COUNT "${PDH_TEST_COUNT}+1") diff --git a/extensions/procfs/tests/CMakeLists.txt b/extensions/procfs/tests/CMakeLists.txt index ec0a8e8e86..a53765a873 100644 --- a/extensions/procfs/tests/CMakeLists.txt +++ b/extensions/procfs/tests/CMakeLists.txt @@ -28,7 +28,7 @@ FOREACH(testfile ${PROCFS_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-procfs) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR PROCFS_TEST_COUNT "${PROCFS_TEST_COUNT}+1") diff --git a/extensions/prometheus/tests/CMakeLists.txt b/extensions/prometheus/tests/CMakeLists.txt index 6f0e72c3e3..d1a73df222 100644 --- a/extensions/prometheus/tests/CMakeLists.txt +++ b/extensions/prometheus/tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(testfile ${PROMETHEUS_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/prometheus") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-prometheus) MATH(EXPR PROMETHEUS_TEST_COUNT "${PROMETHEUS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}") diff --git a/extensions/python/tests/CMakeLists.txt b/extensions/python/tests/CMakeLists.txt index 93ac1c8d24..a0fc168256 100644 --- a/extensions/python/tests/CMakeLists.txt +++ b/extensions/python/tests/CMakeLists.txt @@ -29,7 +29,7 @@ FOREACH(testfile ${EXECUTESCRIPT_PYTHON_TESTS}) add_minifi_executable("${testfilename}" "${testfile}") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/python") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") - target_link_libraries(${testfilename} minifi-python-script-extension minifi-script-extension Catch2WithMain Python::Python) + target_link_libraries(${testfilename} minifi-python-script-extension minifi-script-extension Catch2::Catch2WithMain Python::Python) createTests("${testfilename}") MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -46,7 +46,7 @@ FOREACH(testfile ${EXECUTEPYTHONPROCESSOR_UNIT_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") - target_link_libraries(${testfilename} minifi-python-script-extension minifi-script-extension minifi-standard-processors Catch2WithMain Python::Python) + target_link_libraries(${testfilename} minifi-python-script-extension minifi-script-extension minifi-standard-processors Catch2::Catch2WithMain Python::Python) createTests("${testfilename}") MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") diff --git a/extensions/rocksdb-repos/CMakeLists.txt b/extensions/rocksdb-repos/CMakeLists.txt index e9d0a7af8d..afaee99c32 100644 --- a/extensions/rocksdb-repos/CMakeLists.txt +++ b/extensions/rocksdb-repos/CMakeLists.txt @@ -21,13 +21,13 @@ if (NOT ENABLE_ROCKSDB) return() endif() -if (BUILD_ROCKSDB) - include(BundledRocksDB) - use_bundled_rocksdb(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) -else() - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/rocksdb/sys") - find_package(RocksDB REQUIRED) -endif() +# if (BUILD_ROCKSDB) +include(BundledRocksDB) +use_bundled_rocksdb(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) +# else() +# list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/rocksdb/sys") +# find_package(RocksDB REQUIRED) +# endif() include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) diff --git a/extensions/rocksdb-repos/tests/CMakeLists.txt b/extensions/rocksdb-repos/tests/CMakeLists.txt index 9f4754c120..2625e3150a 100644 --- a/extensions/rocksdb-repos/tests/CMakeLists.txt +++ b/extensions/rocksdb-repos/tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(testfile ${ROCKSDB_UNIT_TESTS}) target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${ROCKSDB_THIRDPARTY_ROOT}/include") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-rocksdb-repos) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR ROCKSDB_TEST_COUNT "${ROCKSDB_TEST_COUNT}+1") diff --git a/extensions/script/tests/CMakeLists.txt b/extensions/script/tests/CMakeLists.txt index 121428ec5e..85acb7b29e 100644 --- a/extensions/script/tests/CMakeLists.txt +++ b/extensions/script/tests/CMakeLists.txt @@ -27,7 +27,7 @@ FOREACH(testfile ${EXECUTE_SCRIPT_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-script-extension) MATH(EXPR EXECUTE_SCRIPT_TEST_COUNT "${EXECUTE_SCRIPT_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) diff --git a/extensions/sftp/CMakeLists.txt b/extensions/sftp/CMakeLists.txt index 169c7f8ccc..9eecf7fb9d 100644 --- a/extensions/sftp/CMakeLists.txt +++ b/extensions/sftp/CMakeLists.txt @@ -33,7 +33,7 @@ file(GLOB SOURCES "*.cpp" "client/*.cpp" "processors/*.cpp") add_minifi_library(minifi-sftp SHARED ${SOURCES}) target_link_libraries(minifi-sftp ${LIBMINIFI} Threads::Threads) -target_link_libraries(minifi-sftp CURL::libcurl libssh2 RapidJSON) +target_link_libraries(minifi-sftp CURL::libcurl Libssh2::libssh2 RapidJSON) register_extension(minifi-sftp "SFTP EXTENSIONS" SFTP "This enables SFTP support" "extensions/sftp/tests") register_extension_linter(minifi-sftp-linter) diff --git a/extensions/sftp/tests/CMakeLists.txt b/extensions/sftp/tests/CMakeLists.txt index 5dd84b3486..c329e77ad5 100644 --- a/extensions/sftp/tests/CMakeLists.txt +++ b/extensions/sftp/tests/CMakeLists.txt @@ -18,12 +18,9 @@ # # Java is required for SFTPTestServer, we will disable tests if we can't find it -find_package(Java) -find_package(Maven) -message(STATUS "JAVA_HOME: '$ENV{JAVA_HOME}'") -message(STATUS "MAVEN: ${MAVEN_EXECUTABLE}") - -if (NOT SKIP_TESTS AND Java_FOUND AND Maven_FOUND AND ENABLE_EXPRESSION_LANGUAGE) +# TODO (JG): Why is Java required for SFTPTestServer? Cant this be an alternative + # for SFTPTestServer? Like we could create a C++ SFTPTestServer, even Python one, etc. +function(build_sftp_extension_test) file(GLOB SFTP_INTEGRATION_TESTS "*.cpp") SET(SFTP-EXTENSIONS_TEST_COUNT 0) FOREACH(testfile ${SFTP_INTEGRATION_TESTS}) @@ -42,7 +39,7 @@ if (NOT SKIP_TESTS AND Java_FOUND AND Maven_FOUND AND ENABLE_EXPRESSION_LANGUAGE target_include_directories(${testfilename} BEFORE PRIVATE ./tools) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain core-minifi sftp-test-tools) + target_link_libraries(${testfilename} Catch2::Catch2WithMain core-minifi sftp-test-tools) target_link_libraries(${testfilename} minifi-sftp) target_link_libraries(${testfilename} minifi-expression-language-extensions) target_link_libraries(${testfilename} minifi-standard-processors) @@ -59,6 +56,14 @@ if (NOT SKIP_TESTS AND Java_FOUND AND Maven_FOUND AND ENABLE_EXPRESSION_LANGUAGE file(COPY "${CMAKE_SOURCE_DIR}/extensions/sftp/tests/resources" DESTINATION "${CMAKE_BINARY_DIR}/bin/sftp-test/") add_subdirectory(tools) -else() - message("Could find Java and Maven to build SFTPTestServer, disabling SFTP tests") +endfunction(build_sftp_extension_test) + +if (NOT SKIP_TESTS AND ENABLE_EXPRESSION_LANGUAGE) + if(Java_FOUND AND Maven_FOUND) + build_sftp_extension_test() + elseif (TARGET openjdk::openjdk AND TARGET maven::maven) + build_sftp_extension_test() + else() + message("Could find Java and Maven to build SFTPTestServer, disabling SFTP tests") + endif() endif() diff --git a/extensions/sftp/tests/tools/CMakeLists.txt b/extensions/sftp/tests/tools/CMakeLists.txt index b8cec70338..205afacf10 100644 --- a/extensions/sftp/tests/tools/CMakeLists.txt +++ b/extensions/sftp/tests/tools/CMakeLists.txt @@ -34,25 +34,64 @@ set(SFTP_TEST_SERVER_JAR_BIN "${CMAKE_BINARY_DIR}/bin/sftp-test/tools" ) file(COPY ${SFTP_TEST_SERVER_JAR_SOURCE} DESTINATION ${SFTP_TEST_SERVER_JAR_BIN}) -message("Building SFTPTestServer ....") +message(STATUS "Building Java SFTPTestServer ....") # duplicating the execute_process because a version of cmake tested exhibited failures # with an empty cmd before ${MAVEN_EXECUTABLE}. Until this is resolved ( or proven to be a non cmake issue on all versions) # we should stick with the the minor duplication -if (WIN32) - execute_process(COMMAND cmd /c "${MAVEN_EXECUTABLE}" "-q" "package" "-Denforcer.skip=true" - WORKING_DIRECTORY "${SFTP_TEST_SERVER_JAR_BIN}/sftp-test-server" +if(USE_CONAN_PACKAGER) + set(MAVEN_ARG1 "-q") + set(MAVEN_ARG2 "package") + set(MAVEN_ARG3 "-Denforcer.skip=true") + set(WORKING_DIR "${SFTP_TEST_SERVER_JAR_BIN}/sftp-test-server") + + message("-----Prep Conan Py Maven Command: ${PY_MAVEN_EXECUTABLE}") + message("-----Passed Maven Args to Py Script: ${MAVEN_ARG1} ${MAVEN_ARG2} ${MAVEN_ARG3}") + message("-----Passed Working Dir to Py Script: ${WORKING_DIR}") + message("-----Execute Py Maven Script to build Java SFTP Test Server") + if (WIN32) + execute_process(COMMAND cmd /c "${PY_MAVEN_EXECUTABLE}" + --maven_executable=$ENV{MAVEN_EXECUTABLE} + --working_directory=${WORKING_DIR} + --maven_arg1=${MAVEN_ARG1} + --maven_arg2=${MAVEN_ARG2} + --maven_arg3=${MAVEN_ARG3} RESULT_VARIABLE mvn_result OUTPUT_VARIABLE mvn_output - ERROR_VARIABLE mvn_error) -else() - execute_process(COMMAND "${MAVEN_EXECUTABLE}" "-q" "package" "-Denforcer.skip=true" - WORKING_DIRECTORY "${SFTP_TEST_SERVER_JAR_BIN}/sftp-test-server" + ERROR_VARIABLE mvn_error + ) + else() + execute_process(COMMAND ${PY_MAVEN_EXECUTABLE} + --maven_executable=$ENV{MAVEN_EXECUTABLE} + --working_directory=${WORKING_DIR} + --maven_arg1=${MAVEN_ARG1} + --maven_arg2=${MAVEN_ARG2} + --maven_arg3=${MAVEN_ARG3} RESULT_VARIABLE mvn_result OUTPUT_VARIABLE mvn_output - ERROR_VARIABLE mvn_error) + ERROR_VARIABLE mvn_error + ) + endif() + +else() + set(RUN_MAVEN_COMMAND "${MAVEN_EXECUTABLE}" "-q" "package" "-Denforcer.skip=true") + + if (WIN32) + execute_process(COMMAND cmd /c "${RUN_MAVEN_COMMAND}" + WORKING_DIRECTORY "${SFTP_TEST_SERVER_JAR_BIN}/sftp-test-server" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + else() + execute_process(COMMAND "${RUN_MAVEN_COMMAND}" + WORKING_DIRECTORY "${SFTP_TEST_SERVER_JAR_BIN}/sftp-test-server" + RESULT_VARIABLE mvn_result + OUTPUT_VARIABLE mvn_output + ERROR_VARIABLE mvn_error) + endif() endif() + if("${mvn_result}" STREQUAL "0") - message("Successfully built SFTPTestServer") + message("....Successfully Built Java SFTPTestServer....") message("${mvn_output}") else() message("Maven failed ${mvn_result} ${mvn_output} ${mvn_error}") diff --git a/extensions/smb/tests/CMakeLists.txt b/extensions/smb/tests/CMakeLists.txt index 79ee9471b8..a33c4c5798 100644 --- a/extensions/smb/tests/CMakeLists.txt +++ b/extensions/smb/tests/CMakeLists.txt @@ -27,7 +27,7 @@ FOREACH(testfile ${SMB_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/smb") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-smb) target_link_libraries(${testfilename} minifi-standard-processors Netapi32) MATH(EXPR SMB_TEST_COUNT "${SMB_TEST_COUNT}+1") diff --git a/extensions/splunk/tests/CMakeLists.txt b/extensions/splunk/tests/CMakeLists.txt index 945c18ea30..641603a63f 100644 --- a/extensions/splunk/tests/CMakeLists.txt +++ b/extensions/splunk/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${SPLUNK_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/http-curl/") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-splunk) target_link_libraries(${testfilename} minifi-civet-extensions) target_link_libraries(${testfilename} minifi-http-curl) diff --git a/extensions/sql/CMakeLists.txt b/extensions/sql/CMakeLists.txt index 75c4d9afe6..b54b98b2c0 100644 --- a/extensions/sql/CMakeLists.txt +++ b/extensions/sql/CMakeLists.txt @@ -28,149 +28,14 @@ include_directories(".") file(GLOB SOURCES "*.cpp" "services/*.cpp" "processors/*.cpp" "data/*.cpp") -add_minifi_library(minifi-sql SHARED ${SOURCES}) +# NOTE (JG): When building minifi-sql ODBC & SOCI deps with conan if SHARED, undefined reference issues, STATIC succeeds +add_minifi_library(minifi-sql STATIC ${SOURCES}) -if(WIN32) - find_package(ODBC REQUIRED) -else() - # Build iODBC +include(BundledIODBC) +use_bundled_iodbc(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) - # Define byproducts - set(IODBC_BYPRODUCT "lib/libiodbc.a") - - set(IODBC_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/iodbc-install/") - - # Build project - ExternalProject_Add( - iodbc-external - URL "https://github.com/openlink/iODBC/archive/v3.52.14.tar.gz" - URL_HASH "SHA256=896d7e16b283cf9a6f5b5f46e8e9549aef21a11935726b0170987cd4c59d16db" - BUILD_IN_SOURCE true - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/iodbc-src" - BUILD_COMMAND make - CMAKE_COMMAND "" - UPDATE_COMMAND "" - INSTALL_COMMAND make install - CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${IODBC_BYPRODUCT_DIR} --with-pic - STEP_TARGETS build - BUILD_BYPRODUCTS "${IODBC_BYPRODUCT_DIR}/${IODBC_BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - ) - - # Set variables - set(IODBC_FOUND "YES" CACHE STRING "" FORCE) - set(IODBC_INCLUDE_DIRS "${IODBC_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) - set(IODBC_LIBRARIES "${IODBC_BYPRODUCT_DIR}/${IODBC_BYPRODUCT}" CACHE STRING "" FORCE) - - # Set exported variables for FindPackage.cmake - set(EXPORTED_IODBC_INCLUDE_DIRS "${IODBC_INCLUDE_DIRS}" CACHE STRING "" FORCE) - set(EXPORTED_IODBC_LIBRARIES "${IODBC_LIBRARIES}" CACHE STRING "" FORCE) - - # Create imported targets - add_library(ODBC::ODBC STATIC IMPORTED) - set_target_properties(ODBC::ODBC PROPERTIES IMPORTED_LOCATION "${IODBC_LIBRARIES}") - add_dependencies(ODBC::ODBC iodbc-external) - file(MAKE_DIRECTORY ${IODBC_INCLUDE_DIRS}) - set_property(TARGET ODBC::ODBC APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${IODBC_INCLUDE_DIRS}) -endif() - -# Build SOCI - -# Define byproducts -# This should be based on GNUInstallDirs, but it's done wrong in Soci: -# https://github.com/SOCI/soci/blob/release/4.0/CMakeLists.txt#L140 -if(APPLE OR CMAKE_SIZEOF_VOID_P EQUAL 4) - set(LIBDIR "lib") -else() - set(LIBDIR "lib64") -endif() - -if (WIN32) - set(BYPRODUCT_SUFFIX "_4_0.lib") -else() - set(BYPRODUCT_SUFFIX ".a") -endif() - -set(SOCI_BYPRODUCTS - "${LIBDIR}/libsoci_core${BYPRODUCT_SUFFIX}" - "${LIBDIR}/libsoci_odbc${BYPRODUCT_SUFFIX}" - ) - -set(SOCI_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/soci-install") - -foreach(SOCI_BYPRODUCT ${SOCI_BYPRODUCTS}) - list(APPEND SOCI_LIBRARIES_LIST "${SOCI_BYPRODUCT_DIR}/${SOCI_BYPRODUCT}") -endforeach(SOCI_BYPRODUCT) - -if(WIN32) - # Set build options - set(SOCI_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${SOCI_BYPRODUCT_DIR}" - "-DSOCI_TESTS=OFF" - "-DSOCI_SHARED=OFF" - "-DSOCI_CXX_C11=ON" - "-DWITH_ODBC=ON" - "-DWITH_BOOST=OFF") -else() - # SOCI has its own FindODBC.cmake file - # Set build options - set(SOCI_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${SOCI_BYPRODUCT_DIR}" - "-DSOCI_TESTS=OFF" - "-DSOCI_SHARED=OFF" - "-DSOCI_CXX_C11=ON" - "-DSOCI_ODBC=ON" - "-DODBC_INCLUDE_DIR=${IODBC_INCLUDE_DIRS}" - "-DODBC_LIBRARY=${IODBC_LIBRARIES}" - "-DWITH_BOOST=OFF") -endif() - -if(NOT WIN32) - list(APPEND SOCI_CMAKE_ARGS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/cmake/" - "-DEXPORTED_IODBC_INCLUDE_DIRS=${EXPORTED_IODBC_INCLUDE_DIRS}" - "-DEXPORTED_IODBC_LIBRARIES=${EXPORTED_IODBC_LIBRARIES}") -endif() - -set(PC "${Patch_EXECUTABLE}" -p1 -i "${CMAKE_SOURCE_DIR}/thirdparty/soci/sqlite3-path.patch") - -# Build project -ExternalProject_Add( - soci-external - URL "https://github.com/SOCI/soci/archive/4.0.1.tar.gz" - URL_HASH "SHA256=fa69347b1a1ef74450c0382b665a67bd6777cc7005bbe09726479625bcf1e29c" - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/soci-src" - CMAKE_ARGS ${SOCI_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS ${SOCI_LIBRARIES_LIST} - EXCLUDE_FROM_ALL TRUE -) - -# Set dependencies -if(NOT WIN32) - add_dependencies(soci-external ODBC::ODBC) -endif() - -# Set variables -set(SOCI_FOUND "YES" CACHE STRING "" FORCE) -set(SOCI_INCLUDE_DIR "${SOCI_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) -set(SOCI_LIBRARIES "${SOCI_LIBRARIES_LIST}" CACHE STRING "" FORCE) - -# Create imported targets -file(MAKE_DIRECTORY ${SOCI_INCLUDE_DIR}) - -add_library(SOCI::libsoci_core STATIC IMPORTED) -set_target_properties(SOCI::libsoci_core PROPERTIES IMPORTED_LOCATION "${SOCI_BYPRODUCT_DIR}/${LIBDIR}/libsoci_core${BYPRODUCT_SUFFIX}") -set_target_properties(SOCI::libsoci_core PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIR}") -add_dependencies(SOCI::libsoci_core soci-external) -target_compile_features(SOCI::libsoci_core INTERFACE cxx_std_14) - -add_library(SOCI::libsoci_odbc STATIC IMPORTED) -set_target_properties(SOCI::libsoci_odbc PROPERTIES IMPORTED_LOCATION "${SOCI_BYPRODUCT_DIR}/${LIBDIR}/libsoci_odbc${BYPRODUCT_SUFFIX}") -set_target_properties(SOCI::libsoci_odbc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOCI_INCLUDE_DIR}") -add_dependencies(SOCI::libsoci_odbc soci-external) -set_property(TARGET SOCI::libsoci_odbc APPEND PROPERTY INTERFACE_LINK_LIBRARIES SOCI::libsoci_core) -set_property(TARGET SOCI::libsoci_odbc APPEND PROPERTY INTERFACE_LINK_LIBRARIES ODBC::ODBC) -target_compile_features(SOCI::libsoci_odbc INTERFACE cxx_std_14) +include(BundledSOCI) +use_bundled_soci(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) target_link_libraries(minifi-sql SOCI::libsoci_odbc SOCI::libsoci_core) diff --git a/extensions/sql/tests/CMakeLists.txt b/extensions/sql/tests/CMakeLists.txt index 15b22d8566..c61cd1fe22 100644 --- a/extensions/sql/tests/CMakeLists.txt +++ b/extensions/sql/tests/CMakeLists.txt @@ -35,7 +35,7 @@ foreach(testfile ${SQL_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-sql-mocks) target_link_libraries(${testfilename} minifi-sql) target_link_libraries(${testfilename} minifi-standard-processors) diff --git a/extensions/standard-processors/CMakeLists.txt b/extensions/standard-processors/CMakeLists.txt index 630fb3cab7..e8b3a7d099 100644 --- a/extensions/standard-processors/CMakeLists.txt +++ b/extensions/standard-processors/CMakeLists.txt @@ -27,7 +27,7 @@ target_include_directories(minifi-standard-processors PUBLIC "${CMAKE_SOURCE_DIR include(RangeV3) include(Asio) -target_link_libraries(minifi-standard-processors ${LIBMINIFI} Threads::Threads range-v3 asio) +target_link_libraries(minifi-standard-processors ${LIBMINIFI} Threads::Threads range-v3::range-v3 asio::asio) include(Coroutines) enable_coroutines() diff --git a/extensions/standard-processors/tests/CMakeLists.txt b/extensions/standard-processors/tests/CMakeLists.txt index 6defa1a982..7616a50ca5 100644 --- a/extensions/standard-processors/tests/CMakeLists.txt +++ b/extensions/standard-processors/tests/CMakeLists.txt @@ -39,7 +39,7 @@ FOREACH(testfile ${PROCESSOR_UNIT_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "../processors") target_include_directories(${testfilename} BEFORE PRIVATE ./include) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-expression-language-extensions) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-civet-extensions) diff --git a/extensions/systemd/tests/CMakeLists.txt b/extensions/systemd/tests/CMakeLists.txt index ec689d9e32..7ad80d2a23 100644 --- a/extensions/systemd/tests/CMakeLists.txt +++ b/extensions/systemd/tests/CMakeLists.txt @@ -27,7 +27,7 @@ function(add_systemd_test testfile) target_link_libraries(${TEST_TARGET} minifi-standard-processors) createTests("${TEST_TARGET}") add_test(NAME ${TEST_TARGET} COMMAND "${TEST_TARGET}" WORKING_DIRECTORY "${TEST_DIR}") - target_link_libraries(${TEST_TARGET} Catch2WithMain) + target_link_libraries(${TEST_TARGET} Catch2::Catch2WithMain) endfunction() add_systemd_test("ConsumeJournaldTest.cpp") diff --git a/extensions/usb-camera/CMakeLists.txt b/extensions/usb-camera/CMakeLists.txt index 13d0275188..b408f8a21f 100644 --- a/extensions/usb-camera/CMakeLists.txt +++ b/extensions/usb-camera/CMakeLists.txt @@ -52,7 +52,6 @@ if(NOT TARGET PNG::PNG) endif() include(FetchUvc) -find_package(UVC REQUIRED) file(GLOB SOURCES "*.cpp") diff --git a/extensions/windows-event-log/tests/CMakeLists.txt b/extensions/windows-event-log/tests/CMakeLists.txt index 68487dcf33..9a946b6ac4 100644 --- a/extensions/windows-event-log/tests/CMakeLists.txt +++ b/extensions/windows-event-log/tests/CMakeLists.txt @@ -37,7 +37,7 @@ FOREACH(testfile ${WEL_TESTS}) createTests("${testfilename}") target_link_libraries(${testfilename} minifi-wel) target_link_libraries(${testfilename} minifi-standard-processors) - target_link_libraries (${testfilename} ${LIBMINIFI} Catch2WithMain) + target_link_libraries (${testfilename} ${LIBMINIFI} Catch2::Catch2WithMain) MATH(EXPR WEL_TEST_COUNT "${WEL_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/libminifi/CMakeLists.txt b/libminifi/CMakeLists.txt index f2817790ae..2589069158 100644 --- a/libminifi/CMakeLists.txt +++ b/libminifi/CMakeLists.txt @@ -75,10 +75,25 @@ else() set_target_properties(core-minifi PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") endif() +# Recursively get all LIBMINIFI header directories, store into generated include_dirs.cmake using python +find_package(Python3 COMPONENTS Interpreter) +execute_process(COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/python/get_include_dirs.py" + "${CMAKE_CURRENT_SOURCE_DIR}/include" # LIBMINIFI include directory + "${CMAKE_CURRENT_BINARY_DIR}/include_dirs.cmake" # generated LIBMINIFI include_dirs.cmake file + "LIBMINIFI_INCLUDE_DIRS" # CMake variable name for LIBMINIFI INCLUDE_DIRS + ) + +# Include the generated cmake file to set the LIBMINIFI_INCLUDE_DIRS variable +include("${CMAKE_CURRENT_BINARY_DIR}/include_dirs.cmake") + +message("LIBMINIFI_INCLUDE_DIRS = ${LIBMINIFI_INCLUDE_DIRS}") +target_include_directories(core-minifi PUBLIC ${LIBMINIFI_INCLUDE_DIRS}) + +# TODO (JG): Analyze the 3rd party lib dependencies (thirdparty, extensions, etc) on libminifi and replace them with the appropriate conan packages include(RangeV3) include(Asio) include(MagicEnum) -list(APPEND LIBMINIFI_LIBRARIES yaml-cpp ZLIB::ZLIB concurrentqueue RapidJSON spdlog Threads::Threads gsl-lite libsodium range-v3 expected-lite date::date date::tz asio magic_enum) +list(APPEND LIBMINIFI_LIBRARIES yaml-cpp::yaml-cpp ZLIB::ZLIB concurrentqueue RapidJSON spdlog::spdlog Threads::Threads gsl::gsl-lite libsodium::libsodium range-v3::range-v3 nonstd::expected-lite date::date date::date-tz asio::asio magic_enum::magic_enum) if(NOT WIN32) list(APPEND LIBMINIFI_LIBRARIES OSSP::libuuid++) endif() diff --git a/libminifi/cmake/python/get_include_dirs.py b/libminifi/cmake/python/get_include_dirs.py new file mode 100644 index 0000000000..1d31f34e12 --- /dev/null +++ b/libminifi/cmake/python/get_include_dirs.py @@ -0,0 +1,28 @@ +import os +import argparse + +SCRIPT_PATH = os.path.realpath(__file__) +SCRIPT_DIR = os.path.dirname(SCRIPT_PATH) + +def get_include_dirs(project_root_dir): + include_dirs = [] + for root, dirs, files in os.walk(project_root_dir): + include_dirs.append(root) + return include_dirs + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Generate include_dirs.cmake file") + parser.add_argument("project_root_dir", help="Path to the project root directory") + parser.add_argument("include_dirs_cmake_file", help="Path to the output include_dirs.cmake file") + parser.add_argument("include_dirs_variable_name", help="Name of the CMake variable to store include directories") + args = parser.parse_args() + + root_dir = args.project_root_dir + include_dirs = get_include_dirs(root_dir) + + gen_include_dirs_cmake = args.include_dirs_cmake_file + with open(gen_include_dirs_cmake, "w") as f: + f.write(f"set({args.include_dirs_variable_name}\n") + for dir in include_dirs: + f.write(f" \"{dir}\"\n") + f.write(")\n") diff --git a/libminifi/test/flow-tests/CMakeLists.txt b/libminifi/test/flow-tests/CMakeLists.txt index 092f0e8df0..029e911d63 100644 --- a/libminifi/test/flow-tests/CMakeLists.txt +++ b/libminifi/test/flow-tests/CMakeLists.txt @@ -32,7 +32,7 @@ FOREACH(testfile ${FLOW_TESTS}) target_link_libraries(${testfilename} minifi-rocksdb-repos) endif() - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) MATH(EXPR FLOW_TEST_COUNT "${FLOW_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}") ENDFOREACH() diff --git a/libminifi/test/persistence-tests/CMakeLists.txt b/libminifi/test/persistence-tests/CMakeLists.txt index c2913bd6d6..c2b51a2afe 100644 --- a/libminifi/test/persistence-tests/CMakeLists.txt +++ b/libminifi/test/persistence-tests/CMakeLists.txt @@ -32,7 +32,7 @@ FOREACH(testfile ${PERSISTENCE_TESTS}) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-rocksdb-repos) createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) MATH(EXPR PERSISTENCE_TEST_COUNT "${PERSISTENCE_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/libminifi/test/schema-tests/CMakeLists.txt b/libminifi/test/schema-tests/CMakeLists.txt index a5befa0829..0a53ed1f10 100644 --- a/libminifi/test/schema-tests/CMakeLists.txt +++ b/libminifi/test/schema-tests/CMakeLists.txt @@ -25,7 +25,7 @@ FOREACH(testfile ${SCHEMA_TESTS}) get_filename_component(testfilename "${testfile}" NAME_WE) add_minifi_executable("${testfilename}" "${testfile}") createTests("${testfilename}") - target_link_libraries(${testfilename} Catch2WithMain) + target_link_libraries(${testfilename} Catch2::Catch2WithMain) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} nlohmann_json_schema_validator) MATH(EXPR SCHEMA_TEST_COUNT "${SCHEMA_TEST_COUNT}+1") diff --git a/minifi_main/CMakeLists.txt b/minifi_main/CMakeLists.txt index 62eb234f6e..3c9397885d 100644 --- a/minifi_main/CMakeLists.txt +++ b/minifi_main/CMakeLists.txt @@ -52,7 +52,7 @@ if (NOT USE_SHARED_LIBS) endif(NOT USE_SHARED_LIBS) target_link_libraries(minifiexe Threads::Threads) -target_link_libraries(minifiexe yaml-cpp) +target_link_libraries(minifiexe yaml-cpp::yaml-cpp) if(CUSTOM_MALLOC_LIB) message(VERBOSE "Using custom malloc lib ${CUSTOM_MALLOC_LIB} for minifiexe") target_link_libraries(minifiexe ${CUSTOM_MALLOC_LIB}) @@ -65,7 +65,7 @@ endif() get_property(extensions GLOBAL PROPERTY EXTENSION-OPTIONS) include(ArgParse) -target_link_libraries(minifiexe spdlog libsodium gsl-lite argparse ${LIBMINIFI}) +target_link_libraries(minifiexe spdlog::spdlog libsodium::libsodium gsl::gsl-lite argparse::argparse ${LIBMINIFI}) set_target_properties(minifiexe PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set_target_properties(minifiexe PROPERTIES OUTPUT_NAME minifi) diff --git a/minifi_main/tests/CMakeLists.txt b/minifi_main/tests/CMakeLists.txt index 2549c349b0..73a9d6ade7 100644 --- a/minifi_main/tests/CMakeLists.txt +++ b/minifi_main/tests/CMakeLists.txt @@ -25,7 +25,7 @@ FOREACH(TEST_FILE ${MINIFI_MAIN_UNIT_TESTS}) target_include_directories(${TEST_TARGET} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test" "${CMAKE_SOURCE_DIR}/minifi_main") - target_link_libraries(${TEST_TARGET} core-minifi Catch2WithMain) + target_link_libraries(${TEST_TARGET} core-minifi Catch2::Catch2WithMain) createTests("${TEST_TARGET}") add_test(NAME ${TEST_TARGET} COMMAND "${TEST_TARGET}" WORKING_DIRECTORY "${TEST_DIR}") MATH(EXPR MINIFI_MAIN_UNIT_TEST_COUNT "${MINIFI_MAIN_UNIT_TEST_COUNT}+1") diff --git a/nanofi/CMakeLists.txt b/nanofi/CMakeLists.txt index d8fe2c99a7..0286826e51 100644 --- a/nanofi/CMakeLists.txt +++ b/nanofi/CMakeLists.txt @@ -42,7 +42,7 @@ set_cpp_version() add_minifi_library(nanofi STATIC ${NANOFI_SOURCES}) -target_link_libraries(nanofi spdlog ut core-minifi minifi-standard-processors) +target_link_libraries(nanofi spdlog::spdlog ut core-minifi minifi-standard-processors) if (ENABLE_CURL) add_subdirectory(examples) diff --git a/thirdparty/README.md b/thirdparty/README.md new file mode 100644 index 0000000000..bf72a0cc4d --- /dev/null +++ b/thirdparty/README.md @@ -0,0 +1,193 @@ +# Managing 3rd Party Deps for MiNiFi C++ + +For MiNiFi C++, we've built all the external library dependencies using standalone CMake with FetchContent(...) and ExternalProject_Add(...) approach in the .cmake files. With some of those .cmake files, we have some of them pulling in the header files, source code, patch files, etc from the thirdparty folder. + +Now that we are also adding support for building MiNiFi C++ with conan, we're adding conan recipes to the thirdparty folder, so in cases where we need to build our own third party libraries for MiNiFi C++, we can do it using **conan create**. + +We have included an example for creating the **rocksdb** conan package using **conan create** while accounting for how we added and applied the **arm7.patch** and **dboptions_equality_operator.patch** updates to that conan package. Once you try out creating this **rocksdb** conan package, you'll be familiar with how to create other conan packages for the MiNiFi C++ dependencies. + +We'll also integrate conan into the MiNiFi C++ **bootstrap.py** file to install MiNiFi C++ external library dependencies and/or build them if needed as well as then build MiNiFi C++. + +## Create Conan Packages for MiNiFi C++ Dependencies + +### Create BZip2 Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/bzip2/all +conan create . --version=1.0.8 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create Rocksdb Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/rocksdb/all +conan create . --version=8.10.2 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +Heres an example of the **rocksdb** conan package successfully being created with the **arm7.patch** and **dboptions_equality_operator.patch** files being applied like we did in the previous standalone CMake approach for building the rocksdb library. + +~~~bash +-- Using Conan toolchain: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/rocksdb/all/test_package/build/gcc-11-x86_64-gnu20-release/generators/conan_toolchain.cmake +-- Conan toolchain: C++ Standard 20 with extensions ON +-- The CXX compiler identification is GNU 11.4.0 +-- Detecting CXX compiler ABI info +-- Detecting CXX compiler ABI info - done +-- Check for working CXX compiler: /usr/lib/ccache/c++ - skipped +-- Detecting CXX compile features +-- Detecting CXX compile features - done +-- Conan: Component target declared 'RocksDB::rocksdb' +-- Configuring done +-- Generating done +-- Build files have been written to: /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/rocksdb/all/test_package/build/gcc-11-x86_64-gnu20-release + +rocksdb/8.10.2@minifi/dev (test package): Running CMake.build() +rocksdb/8.10.2@minifi/dev (test package): RUN: cmake --build "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/rocksdb/all/test_package/build/gcc-11-x86_64-gnu20-release" -- -j20 +[ 25%] Building CXX object CMakeFiles/test_package_stable_abi.dir/test_package_stable_abi.cpp.o +[ 50%] Building CXX object CMakeFiles/test_package_cpp.dir/test_package.cpp.o +[ 75%] Linking CXX executable test_package_stable_abi +[ 75%] Built target test_package_stable_abi +[100%] Linking CXX executable test_package_cpp +[100%] Built target test_package_cpp + + +======== Testing the package: Executing test ======== +rocksdb/8.10.2@minifi/dev (test package): Running test() +rocksdb/8.10.2@minifi/dev (test package): RUN: ctest --output-on-failure -C Release +Test project /home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/rocksdb/all/test_package/build/gcc-11-x86_64-gnu20-release + Start 1: test_package_stable_abi +1/2 Test #1: test_package_stable_abi .......... Passed 0.08 sec + Start 2: test_package_cpp +2/2 Test #2: test_package_cpp ................. Passed 0.08 sec + +100% tests passed, 0 tests failed out of 2 + +Total Test time (real) = 0.16 sec +~~~ + +### Create MBedTLS Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/mbedtls/all +conan create . --version=2.16.3 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + + +### Create Open62541 Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/open62541/all +conan create . --version=1.3.3 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create LibLZMA XZ_Utils Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/liblzma/xz_utils/all +conan create . --version=5.2.5 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + + +### Create OpenSSL Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/openssl/3.x.x +conan create . --version=3.3.0 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create LibArchive Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/libarchive/all +conan create . --version=3.4.2 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create LibCoap Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/libcoap/all +conan create . --version=4.2.1 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +NOTE: SOCI depends on ODBC. Our SOCI uses iODBC from openlink while conan's SOCI uses ODBC from unixodbc. Lets see if I can just use SOCI's default ODBC integration for conan approach. + +### Create SOCI Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/soci/all +conan create . --version=4.0.1 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create PcapPlusPlus Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/pcapplusplus/all +conan create . --version=22.05 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create CPython Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/cpython/all +conan create . --version=3.9.19 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create LibTiff Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/libtiff/all +conan create . --version=4.6.0 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create FFMPEG Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/ffmpeg/all +conan create . --version=4.4.4 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create OpenCV Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/opencv/4.x +conan create . --version=4.8.1 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create LibSSH2 Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/libssh2/all +conan create . --version=1.10.0 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create Maven Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/maven/all +conan create . --version=3.9.6 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create LibRdKafka Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/librdkafka/all +conan create . --version=1.9.2 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create LibSystemd Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/libsystemd/all +conan create . --version=255 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +### Create GRPC Conan Package + +~~~bash +pushd nifi-minifi-cpp/thirdparty/grpc/all +conan create . --version=1.54.3 --user=minifi --channel=dev --build=missing -pr=$HOME/src/james/pipeline/nifi-minifi-cpp/etc/build/conan/profiles/release-linux +~~~ + +## References + +- [Conan 2 - Devops Guide](https://docs.conan.io/2/devops.html): Designing and implementing conan in production. Shows information on using ConanCenter packages, local recipes index repository, backing up third-party sources, managing package metadata files, versioning, saving and restoring packages from/to cache +- [Conan 2 - Commands](https://docs.conan.io/2/reference/commands.html): Shows conan commands, common commands we'll use in scripts and directly in terminal include `conan create`, `conan install`, `conan build`, `conan remove`, etc diff --git a/thirdparty/bzip2/all/CMakeLists.txt b/thirdparty/bzip2/all/CMakeLists.txt new file mode 100644 index 0000000000..cce959a4a4 --- /dev/null +++ b/thirdparty/bzip2/all/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.4) +project(bzip2 LANGUAGES C) + +include(GNUInstallDirs) + +option(BZ2_BUILD_EXE "Build bzip2 command-line utility" ON) + +add_library( + bz2 + ${BZ2_SRC_DIR}/blocksort.c + ${BZ2_SRC_DIR}/bzlib.c + ${BZ2_SRC_DIR}/compress.c + ${BZ2_SRC_DIR}/crctable.c + ${BZ2_SRC_DIR}/decompress.c + ${BZ2_SRC_DIR}/huffman.c + ${BZ2_SRC_DIR}/randtable.c +) + +target_include_directories(bz2 PUBLIC ${BZ2_SRC_DIR}) +set_target_properties( + bz2 + PROPERTIES + PUBLIC_HEADER "${BZ2_SRC_DIR}/bzlib.h" + SOVERSION ${BZ2_VERSION_MAJOR} + VERSION ${BZ2_VERSION_STRING} + WINDOWS_EXPORT_ALL_SYMBOLS ON +) + +install( + TARGETS bz2 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +if(BZ2_BUILD_EXE) + add_executable(bzip2 ${BZ2_SRC_DIR}/bzip2.c) + target_link_libraries(bzip2 PRIVATE bz2) + install(TARGETS bzip2 DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/thirdparty/bzip2/all/conandata.yml b/thirdparty/bzip2/all/conandata.yml new file mode 100644 index 0000000000..71ec779efb --- /dev/null +++ b/thirdparty/bzip2/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.0.8": + url: "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz" + sha256: "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269" +patches: + "1.0.8": + - patch_file: "patches/bzip2.patch" diff --git a/thirdparty/bzip2/all/conanfile.py b/thirdparty/bzip2/all/conanfile.py new file mode 100644 index 0000000000..2a39045a82 --- /dev/null +++ b/thirdparty/bzip2/all/conanfile.py @@ -0,0 +1,106 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, save +from conan.tools.scm import Version +import os +import textwrap + +required_conan_version = ">=1.53.0" + + +class Bzip2Conan(ConanFile): + name = "bzip2" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://sourceware.org/bzip2" + license = "bzip2-1.0.8" + description = "bzip2 is a free and open-source file compression program that uses the Burrows Wheeler algorithm." + topics = ("data-compressor", "file-compression") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "build_executable": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "build_executable": True, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + self.license = f"bzip2-{self.version}" + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.compiler.rm_safe("libcxx") + self.settings.compiler.rm_safe("cppstd") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BZ2_BUILD_EXE"] = self.options.build_executable + tc.variables["BZ2_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["BZ2_VERSION_MAJOR"] = Version(self.version).major + tc.variables["BZ2_VERSION_STRING"] = self.version + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path) + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent(f"""\ + set(BZIP2_NEED_PREFIX TRUE) + set(BZIP2_FOUND TRUE) + if(NOT DEFINED BZIP2_INCLUDE_DIRS AND DEFINED BZip2_INCLUDE_DIRS) + set(BZIP2_INCLUDE_DIRS ${{BZip2_INCLUDE_DIRS}}) + endif() + if(NOT DEFINED BZIP2_INCLUDE_DIR AND DEFINED BZip2_INCLUDE_DIR) + set(BZIP2_INCLUDE_DIR ${{BZip2_INCLUDE_DIR}}) + endif() + if(NOT DEFINED BZIP2_LIBRARIES AND DEFINED BZip2_LIBRARIES) + set(BZIP2_LIBRARIES ${{BZip2_LIBRARIES}}) + endif() + set(BZIP2_VERSION_STRING "{self.version}") + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "BZip2") + self.cpp_info.set_property("cmake_target_name", "BZip2::BZip2") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.libs = ["bz2"] + + self.cpp_info.names["cmake_find_package"] = "BZip2" + self.cpp_info.names["cmake_find_package_multi"] = "BZip2" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + if self.options.build_executable: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/thirdparty/bzip2/bzip2.patch b/thirdparty/bzip2/all/patches/bzip2.patch similarity index 100% rename from thirdparty/bzip2/bzip2.patch rename to thirdparty/bzip2/all/patches/bzip2.patch diff --git a/thirdparty/bzip2/all/test_package/CMakeLists.txt b/thirdparty/bzip2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..364bed2972 --- /dev/null +++ b/thirdparty/bzip2/all/test_package/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(BZip2 REQUIRED) + +add_executable(test_package test_package.c) +target_link_libraries(test_package PRIVATE BZip2::BZip2) + +# Test whether variables from https://cmake.org/cmake/help/latest/module/FindBZip2.html are properly defined +set(_custom_vars + BZIP2_FOUND + BZIP2_NEED_PREFIX + BZIP2_INCLUDE_DIRS + BZIP2_INCLUDE_DIR + BZIP2_LIBRARIES + BZIP2_VERSION_STRING +) +foreach(_custom_var ${_custom_vars}) + if(DEFINED ${_custom_var}) + message(STATUS "${_custom_var}: ${${_custom_var}}") + else() + message(FATAL_ERROR "${_custom_var} not defined") + endif() +endforeach() diff --git a/thirdparty/bzip2/all/test_package/conanfile.py b/thirdparty/bzip2/all/test_package/conanfile.py new file mode 100644 index 0000000000..8a5bb47f50 --- /dev/null +++ b/thirdparty/bzip2/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/bzip2/all/test_package/test_package.c b/thirdparty/bzip2/all/test_package/test_package.c new file mode 100644 index 0000000000..fb91334dfa --- /dev/null +++ b/thirdparty/bzip2/all/test_package/test_package.c @@ -0,0 +1,14 @@ +#include +#include +#include "bzlib.h" + + +int main(void) { + char buffer [256] = {0}; + unsigned int size = 256; + const char* version = BZ2_bzlibVersion(); + printf("Bzip2 version: %s\n", version); + BZ2_bzBuffToBuffCompress(buffer, &size, "conan-package-manager", 21, 1, 0, 1); + printf("Bzip2 compressed: %s\n", buffer); + return EXIT_SUCCESS; +} diff --git a/thirdparty/bzip2/config.yml b/thirdparty/bzip2/config.yml new file mode 100644 index 0000000000..28e3ee22ca --- /dev/null +++ b/thirdparty/bzip2/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.8": + folder: all diff --git a/thirdparty/ffmpeg/all/conandata.yml b/thirdparty/ffmpeg/all/conandata.yml new file mode 100644 index 0000000000..b51138c1bc --- /dev/null +++ b/thirdparty/ffmpeg/all/conandata.yml @@ -0,0 +1,107 @@ +sources: + "6.1": + url: "http://ffmpeg.org/releases/ffmpeg-6.1.tar.bz2" + sha256: "eb7da3de7dd3ce48a9946ab447a7346bd11a3a85e6efb8f2c2ce637e7f547611" + "6.0.1": + url: "http://ffmpeg.org/releases/ffmpeg-6.0.1.tar.bz2" + sha256: "2c6e294569d1ba8e99cbf1acbe49e060a23454228a540a0f45d679d72ec69a06" + "6.0": + url: "https://ffmpeg.org/releases/ffmpeg-6.0.tar.bz2" + sha256: "47d062731c9f66a78380e35a19aac77cebceccd1c7cc309b9c82343ffc430c3d" + "5.1.3": + url: "https://ffmpeg.org/releases/ffmpeg-5.1.3.tar.bz2" + sha256: "5d5bef6a11f0c500588f9870ec965a30acc0d54d8b1e535da6554a32902d236d" + "5.1": + url: "https://ffmpeg.org/releases/ffmpeg-5.1.tar.bz2" + sha256: "32b56fb01ce90d452958ae25e91c9564abf49ed5453c127bec23c63e530aa8fa" + "5.0.3": + url: "https://ffmpeg.org/releases/ffmpeg-5.0.3.tar.bz2" + sha256: "664e8fa8ac4cc5dce03277f022798461998d9bb8d96b9e1859b24e74511229fd" + "5.0": + url: "https://ffmpeg.org/releases/ffmpeg-5.0.tar.bz2" + sha256: "c0130b8db2c763430fd1c6905288d61bc44ee0548ad5fcd2dfd650b88432bed9" + "4.4.4": + url: "https://ffmpeg.org/releases/ffmpeg-4.4.4.tar.bz2" + sha256: "47b1fbf70a2c090d9c0fae5910da11c6406ca92408bb69d8c935cd46c622c7ce" + "4.4.3": + url: "https://ffmpeg.org/releases/ffmpeg-4.4.3.tar.bz2" + sha256: "33b8c2dbcd530fe1db5710415345609b4ca227bd0da1e3a9332dbb0f11fd273a" + "4.4": + url: "https://ffmpeg.org/releases/ffmpeg-4.4.tar.bz2" + sha256: "42093549751b582cf0f338a21a3664f52e0a9fbe0d238d3c992005e493607d0e" + "4.3.2": + url: "https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2" + sha256: "ab3a6d6a70358ba0a5f67f37f91f6656b7302b02e98e5b8c846c16763c99913a" + "4.2.1": + url: "https://ffmpeg.org/releases/ffmpeg-4.2.1.tar.bz2" + sha256: "682a9fa3f6864d7f0dbf224f86b129e337bc60286e0d00dffcd710998d521624" +patches: + "5.1.3": + - patch_file: "patches/5.1-0001-fix-libsvtav1-compressed_ten_bit_format.patch" + patch_description: "Compatibility with libsvtav1 > 1.2.0" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/031f1561cd286596cdb374da32f8aa816ce3b135" + - patch_file: "patches/5.1-0002-fix-libsvtav1-vbv_bufsize-1.patch" + patch_description: "Compatibility with libsvtav1 > 1.2.0" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/1c6fd7d756afe0f8b7df14dbf7a95df275f8f5ee" + - patch_file: "patches/5.1-0003-fix-libsvtav1-vbv_bufsize-2.patch" + patch_description: "Compatibility with libsvtav1 > 1.2.0" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/96748ac54f998ba6fe22802799c16b4eba8d4ccc" + - patch_file: "patches/5.0-0001-fix-hwcontext_vulkan.patch" + patch_description: "Compatibility with vulkan >= 1.3.239" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/eb0455d64690eed0068e5cb202f72ecdf899837c" + "5.1": + - patch_file: "patches/5.1-0001-fix-libsvtav1-compressed_ten_bit_format.patch" + patch_description: "Compatibility with libsvtav1 > 1.2.0" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/031f1561cd286596cdb374da32f8aa816ce3b135" + - patch_file: "patches/5.1-0002-fix-libsvtav1-vbv_bufsize-1.patch" + patch_description: "Compatibility with libsvtav1 > 1.2.0" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/1c6fd7d756afe0f8b7df14dbf7a95df275f8f5ee" + - patch_file: "patches/5.1-0003-fix-libsvtav1-vbv_bufsize-2.patch" + patch_description: "Compatibility with libsvtav1 > 1.2.0" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/96748ac54f998ba6fe22802799c16b4eba8d4ccc" + - patch_file: "patches/5.0-0001-fix-hwcontext_vulkan.patch" + patch_description: "Compatibility with vulkan >= 1.3.239" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/eb0455d64690eed0068e5cb202f72ecdf899837c" + "5.0.3": + - patch_file: "patches/5.0-0001-fix-hwcontext_vulkan.patch" + patch_description: "Compatibility with vulkan >= 1.3.239" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/eb0455d64690eed0068e5cb202f72ecdf899837c" + "5.0": + - patch_file: "patches/5.0-0001-fix-hwcontext_vulkan.patch" + patch_description: "Compatibility with vulkan >= 1.3.239" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/eb0455d64690eed0068e5cb202f72ecdf899837c" + "4.4.4": + - patch_file: "patches/4.4-0001-fix-aom_codec_av1_dx_algo.patch" + patch_description: "Compatibility with shared libaom" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d92fdc714496d43234733c315894abe0beeb3529" + "4.4.3": + - patch_file: "patches/4.4-0001-fix-aom_codec_av1_dx_algo.patch" + patch_description: "Compatibility with shared libaom" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d92fdc714496d43234733c315894abe0beeb3529" + "4.4": + - patch_file: "patches/4.4-0001-fix-aom_codec_av1_dx_algo.patch" + patch_description: "Compatibility with shared libaom" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d92fdc714496d43234733c315894abe0beeb3529" + "4.3.2": + - patch_file: "patches/4.2-0001-fix-aom_codec_av1_dx_algo.patch" + patch_description: "Compatibility with shared libaom" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d92fdc714496d43234733c315894abe0beeb3529" + "4.2.1": + - patch_file: "patches/4.2-0001-fix-aom_codec_av1_dx_algo.patch" + patch_description: "Compatibility with shared libaom" + patch_type: "portability" + patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d92fdc714496d43234733c315894abe0beeb3529" diff --git a/thirdparty/ffmpeg/all/conanfile.py b/thirdparty/ffmpeg/all/conanfile.py new file mode 100644 index 0000000000..be0e77dee8 --- /dev/null +++ b/thirdparty/ffmpeg/all/conanfile.py @@ -0,0 +1,1026 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import ( + apply_conandata_patches, chdir, copy, export_conandata_patches, get, rename, + replace_in_file, rm, rmdir +) +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import check_min_vs, is_msvc, unix_path +from conan.tools.scm import Version +import os +import glob +import shutil +import re + +required_conan_version = ">=1.57.0" + + +class FFMpegConan(ConanFile): + name = "ffmpeg" + url = "https://github.com/conan-io/conan-center-index" + description = "A complete, cross-platform solution to record, convert and stream audio and video" + # https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md + license = ("LGPL-2.1-or-later", "GPL-2.0-or-later") + homepage = "https://ffmpeg.org" + topics = ("multimedia", "audio", "video", "encoder", "decoder", "encoding", "decoding", + "transcoding", "multiplexer", "demultiplexer", "streaming") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "avdevice": [True, False], + "avcodec": [True, False], + "avformat": [True, False], + "swresample": [True, False], + "swscale": [True, False], + "postproc": [True, False], + "avfilter": [True, False], + "with_asm": [True, False], + "with_zlib": [True, False], + "with_bzip2": [True, False], + "with_lzma": [True, False], + "with_libiconv": [True, False], + "with_freetype": [True, False], + "with_openjpeg": [True, False], + "with_openh264": [True, False], + "with_opus": [True, False], + "with_vorbis": [True, False], + "with_zeromq": [True, False], + "with_sdl": [True, False], + "with_libx264": [True, False], + "with_libx265": [True, False], + "with_libvpx": [True, False], + "with_libmp3lame": [True, False], + "with_libfdk_aac": [True, False], + "with_libwebp": [True, False], + "with_ssl": [False, "openssl", "securetransport"], + "with_libalsa": [True, False], + "with_pulse": [True, False], + "with_vaapi": [True, False], + "with_vdpau": [True, False], + "with_vulkan": [True, False], + "with_xcb": [True, False], + "with_appkit": [True, False], + "with_avfoundation": [True, False], + "with_coreimage": [True, False], + "with_audiotoolbox": [True, False], + "with_videotoolbox": [True, False], + "with_programs": [True, False], + "with_libsvtav1": [True, False], + "with_libaom": [True, False], + "with_libdav1d": [True, False], + "disable_everything": [True, False], + "disable_all_encoders": [True, False], + "disable_encoders": [None, "ANY"], + "enable_encoders": [None, "ANY"], + "disable_all_decoders": [True, False], + "disable_decoders": [None, "ANY"], + "enable_decoders": [None, "ANY"], + "disable_all_hardware_accelerators": [True, False], + "disable_hardware_accelerators": [None, "ANY"], + "enable_hardware_accelerators": [None, "ANY"], + "disable_all_muxers": [True, False], + "disable_muxers": [None, "ANY"], + "enable_muxers": [None, "ANY"], + "disable_all_demuxers": [True, False], + "disable_demuxers": [None, "ANY"], + "enable_demuxers": [None, "ANY"], + "disable_all_parsers": [True, False], + "disable_parsers": [None, "ANY"], + "enable_parsers": [None, "ANY"], + "disable_all_bitstream_filters": [True, False], + "disable_bitstream_filters": [None, "ANY"], + "enable_bitstream_filters": [None, "ANY"], + "disable_all_protocols": [True, False], + "disable_protocols": [None, "ANY"], + "enable_protocols": [None, "ANY"], + "disable_all_devices": [True, False], + "disable_all_input_devices": [True, False], + "disable_input_devices": [None, "ANY"], + "enable_input_devices": [None, "ANY"], + "disable_all_output_devices": [True, False], + "disable_output_devices": [None, "ANY"], + "enable_output_devices": [None, "ANY"], + "disable_all_filters": [True, False], + "disable_filters": [None, "ANY"], + "enable_filters": [None, "ANY"], + } + default_options = { + "shared": False, + "fPIC": True, + "avdevice": True, + "avcodec": True, + "avformat": True, + "swresample": True, + "swscale": True, + "postproc": True, + "avfilter": True, + "with_asm": True, + "with_zlib": True, + "with_bzip2": True, + "with_lzma": True, + "with_libiconv": True, + "with_freetype": True, + "with_openjpeg": True, + "with_openh264": True, + "with_opus": True, + "with_vorbis": True, + "with_zeromq": False, + "with_sdl": False, + "with_libx264": True, + "with_libx265": True, + "with_libvpx": True, + "with_libmp3lame": True, + "with_libfdk_aac": True, + "with_libwebp": True, + "with_ssl": "openssl", + "with_libalsa": True, + "with_pulse": True, + "with_vaapi": True, + "with_vdpau": True, + "with_vulkan": False, + "with_xcb": True, + "with_appkit": True, + "with_avfoundation": True, + "with_coreimage": True, + "with_audiotoolbox": True, + "with_videotoolbox": True, + "with_programs": True, + "with_libsvtav1": True, + "with_libaom": True, + "with_libdav1d": True, + "disable_everything": False, + "disable_all_encoders": False, + "disable_encoders": None, + "enable_encoders": None, + "disable_all_decoders": False, + "disable_decoders": None, + "enable_decoders": None, + "disable_all_hardware_accelerators": False, + "disable_hardware_accelerators": None, + "enable_hardware_accelerators": None, + "disable_all_muxers": False, + "disable_muxers": None, + "enable_muxers": None, + "disable_all_demuxers": False, + "disable_demuxers": None, + "enable_demuxers": None, + "disable_all_parsers": False, + "disable_parsers": None, + "enable_parsers": None, + "disable_all_bitstream_filters": False, + "disable_bitstream_filters": None, + "enable_bitstream_filters": None, + "disable_all_protocols": False, + "disable_protocols": None, + "enable_protocols": None, + "disable_all_devices": False, + "disable_all_input_devices": False, + "disable_input_devices": None, + "enable_input_devices": None, + "disable_all_output_devices": False, + "disable_output_devices": None, + "enable_output_devices": None, + "disable_all_filters": False, + "disable_filters": None, + "enable_filters": None, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _dependencies(self): + return { + "avformat": ["avcodec"], + "avdevice": ["avcodec", "avformat"], + "avfilter": ["avformat"], + "with_bzip2": ["avformat"], + "with_ssl": ["avformat"], + "with_zlib": ["avcodec"], + "with_lzma": ["avcodec"], + "with_libiconv": ["avcodec"], + "with_openjpeg": ["avcodec"], + "with_openh264": ["avcodec"], + "with_vorbis": ["avcodec"], + "with_opus": ["avcodec"], + "with_libx264": ["avcodec"], + "with_libx265": ["avcodec"], + "with_libvpx": ["avcodec"], + "with_libmp3lame": ["avcodec"], + "with_libfdk_aac": ["avcodec"], + "with_libwebp": ["avcodec"], + "with_freetype": ["avfilter"], + "with_zeromq": ["avfilter", "avformat"], + "with_libalsa": ["avdevice"], + "with_xcb": ["avdevice"], + "with_pulse": ["avdevice"], + "with_sdl": ["with_programs"], + "with_libsvtav1": ["avcodec"], + "with_libaom": ["avcodec"], + "with_libdav1d": ["avcodec"], + } + + @property + def _version_supports_vulkan(self): + return Version(self.version) >= "4.3.0" + + @property + def _version_supports_libsvtav1(self): + return Version(self.version) >= "5.1.0" + + @property + def _version_supports_libdav1d(self): + return Version(self.version) >= "4.3.0" + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if not self.settings.os in ["Linux", "FreeBSD"]: + del self.options.with_vaapi + del self.options.with_vdpau + del self.options.with_vulkan + del self.options.with_xcb + del self.options.with_libalsa + del self.options.with_pulse + if self.settings.os != "Macos": + del self.options.with_appkit + if self.settings.os not in ["Macos", "iOS", "tvOS"]: + del self.options.with_coreimage + del self.options.with_audiotoolbox + del self.options.with_videotoolbox + if not is_apple_os(self): + del self.options.with_avfoundation + if not self._version_supports_vulkan: + self.options.rm_safe("with_vulkan") + if not self._version_supports_libsvtav1: + self.options.rm_safe("with_libsvtav1") + if not self._version_supports_libdav1d: + self.options.rm_safe("with_libdav1d") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.with_bzip2: + self.requires("bzip2/1.0.8") + if self.options.with_lzma: + # self.requires("xz_utils/5.4.5") + self.requires("xz_utils/5.2.5@minifi/dev") + if self.options.with_libiconv: + self.requires("libiconv/1.17") + if self.options.with_freetype: + self.requires("freetype/2.13.2") + if self.options.with_openjpeg: + self.requires("openjpeg/2.5.0") + if self.options.with_openh264: + self.requires("openh264/2.3.1") + if self.options.with_vorbis: + self.requires("vorbis/1.3.7") + if self.options.with_opus: + self.requires("opus/1.4") + if self.options.with_zeromq: + self.requires("zeromq/4.3.5") + if self.options.with_sdl: + self.requires("sdl/2.28.5") + if self.options.with_libx264: + self.requires("libx264/cci.20220602") + if self.options.with_libx265: + self.requires("libx265/3.4") + if self.options.with_libvpx: + self.requires("libvpx/1.13.1") + if self.options.with_libmp3lame: + self.requires("libmp3lame/3.100") + if self.options.with_libfdk_aac: + self.requires("libfdk_aac/2.0.3") + if self.options.with_libwebp: + self.requires("libwebp/1.3.2") + if self.options.with_ssl == "openssl": + # self.requires("openssl/[>=1.1 <4]") + self.requires("openssl/3.3.0@minifi/dev") + if self.options.get_safe("with_libalsa"): + self.requires("libalsa/1.2.10") + if self.options.get_safe("with_xcb") or self.options.get_safe("with_vaapi"): + self.requires("xorg/system") + if self.options.get_safe("with_pulse"): + self.requires("pulseaudio/14.2") + if self.options.get_safe("with_vaapi"): + self.requires("vaapi/system") + if self.options.get_safe("with_vdpau"): + self.requires("vdpau/system") + if self._version_supports_vulkan and self.options.get_safe("with_vulkan"): + self.requires("vulkan-loader/1.3.243.0") + if self.options.get_safe("with_libsvtav1"): + self.requires("libsvtav1/1.6.0") + if self.options.with_libaom: + self.requires("libaom-av1/3.6.1") + if self.options.get_safe("with_libdav1d"): + self.requires("dav1d/1.2.1") + + def validate(self): + if self.options.with_ssl == "securetransport" and not is_apple_os(self): + raise ConanInvalidConfiguration( + "securetransport is only available on Apple") + + for dependency, features in self._dependencies.items(): + if not self.options.get_safe(dependency): + continue + used = False + for feature in features: + used = used or self.options.get_safe(feature) + if not used: + raise ConanInvalidConfiguration("FFmpeg '{}' option requires '{}' option to be enabled".format( + dependency, "' or '".join(features))) + + def build_requirements(self): + if self.settings.arch in ("x86", "x86_64"): + self.tool_requires("yasm/1.3.0") + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/2.1.0") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + @property + def _target_arch(self): + # Taken from acceptable values https://github.com/FFmpeg/FFmpeg/blob/0684e58886881a998f1a7b510d73600ff1df2b90/configure#L5010 + if str(self.settings.arch).startswith("armv8"): + return "aarch64" + elif self.settings.arch == "x86": + return "i686" + return str(self.settings.arch) + + @property + def _target_os(self): + if self.settings.os == "Windows": + return "mingw32" if self.settings.compiler == "gcc" else "win32" + elif is_apple_os(self): + return "darwin" + + # Taken from https://github.com/FFmpeg/FFmpeg/blob/0684e58886881a998f1a7b510d73600ff1df2b90/configure#L5485 + # This is the map of Conan OS settings to FFmpeg acceptable values + return { + "AIX": "aix", + "Android": "android", + "FreeBSD": "freebsd", + "Linux": "linux", + "Neutrino": "qnx", + "SunOS": "sunos", + }.get(str(self.settings.os), "none") + + def _patch_sources(self): + apply_conandata_patches(self) + if Version(self.version) < "5.1": + # suppress MSVC linker warnings: https://trac.ffmpeg.org/ticket/7396 + # warning LNK4049: locally defined symbol x264_levels imported + # warning LNK4049: locally defined symbol x264_bit_depth imported + replace_in_file(self, os.path.join(self.source_folder, "libavcodec", "libx264.c"), + "#define X264_API_IMPORTS 1", "") + if self.options.with_ssl == "openssl": + # https://trac.ffmpeg.org/ticket/5675 + openssl_libraries = " ".join( + [f"-l{lib}" for lib in self.dependencies["openssl"].cpp_info.aggregated_components().libs]) + replace_in_file(self, os.path.join(self.source_folder, "configure"), + "check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||", + f"check_lib openssl openssl/ssl.h OPENSSL_init_ssl {openssl_libraries} || ") + + replace_in_file(self, os.path.join(self.source_folder, "configure"), "echo libx264.lib", "echo x264.lib") + + @property + def _default_compilers(self): + if self.settings.compiler == "gcc": + return {"cc": "gcc", "cxx": "g++"} + elif self.settings.compiler in ["clang", "apple-clang"]: + return {"cc": "clang", "cxx": "clang++"} + elif is_msvc(self): + return {"cc": "cl.exe", "cxx": "cl.exe"} + return {} + + def _create_toolchain(self): + tc = AutotoolsToolchain(self) + # Custom configure script of ffmpeg understands: + # --prefix, --bindir, --datadir, --docdir, --incdir, --libdir, --mandir + # Options --datadir, --docdir, --incdir, and --mandir are not injected by AutotoolsToolchain but their default value + # in ffmpeg script matches expected conan install layout. + # Several options injected by AutotoolsToolchain are unknown from this configure script and must be pruned. + # This must be done before modifying tc.configure_args, because update_configre_args currently removes + # duplicate configuration keys, even when they have different values, such as list of encoder flags. + # See https://github.com/conan-io/conan-center-index/issues/17140 for further information. + tc.update_configure_args({ + "--sbindir": None, + "--includedir": None, + "--oldincludedir": None, + "--datarootdir": None, + "--build": None, + "--host": None, + "--target": None, + }) + return tc + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + + def opt_enable_disable(what, v): + return "--{}-{}".format("enable" if v else "disable", what) + + def opt_append_disable_if_set(args, what, v): + if v: + args.append(f"--disable-{what}") + + tc = self._create_toolchain() + + args = [ + "--pkg-config-flags=--static", + "--disable-doc", + opt_enable_disable("cross-compile", cross_building(self)), + opt_enable_disable("asm", self.options.with_asm), + # Libraries + opt_enable_disable("shared", self.options.shared), + opt_enable_disable("static", not self.options.shared), + opt_enable_disable("pic", self.options.get_safe("fPIC", True)), + # Components + opt_enable_disable("avdevice", self.options.avdevice), + opt_enable_disable("avcodec", self.options.avcodec), + opt_enable_disable("avformat", self.options.avformat), + opt_enable_disable("swresample", self.options.swresample), + opt_enable_disable("swscale", self.options.swscale), + opt_enable_disable("postproc", self.options.postproc), + opt_enable_disable("avfilter", self.options.avfilter), + + # Dependencies + opt_enable_disable("bzlib", self.options.with_bzip2), + opt_enable_disable("zlib", self.options.with_zlib), + opt_enable_disable("lzma", self.options.with_lzma), + opt_enable_disable("iconv", self.options.with_libiconv), + opt_enable_disable("libopenjpeg", self.options.with_openjpeg), + opt_enable_disable("libopenh264", self.options.with_openh264), + opt_enable_disable("libvorbis", self.options.with_vorbis), + opt_enable_disable("libopus", self.options.with_opus), + opt_enable_disable("libzmq", self.options.with_zeromq), + opt_enable_disable("sdl2", self.options.with_sdl), + opt_enable_disable("libx264", self.options.with_libx264), + opt_enable_disable("libx265", self.options.with_libx265), + opt_enable_disable("libvpx", self.options.with_libvpx), + opt_enable_disable("libmp3lame", self.options.with_libmp3lame), + opt_enable_disable("libfdk-aac", self.options.with_libfdk_aac), + opt_enable_disable("libwebp", self.options.with_libwebp), + opt_enable_disable("libaom", self.options.with_libaom), + opt_enable_disable("openssl", self.options.with_ssl == "openssl"), + opt_enable_disable("alsa", self.options.get_safe("with_libalsa")), + opt_enable_disable( + "libpulse", self.options.get_safe("with_pulse")), + opt_enable_disable("vaapi", self.options.get_safe("with_vaapi")), + opt_enable_disable("vdpau", self.options.get_safe("with_vdpau")), + opt_enable_disable("libxcb", self.options.get_safe("with_xcb")), + opt_enable_disable( + "libxcb-shm", self.options.get_safe("with_xcb")), + opt_enable_disable( + "libxcb-shape", self.options.get_safe("with_xcb")), + opt_enable_disable( + "libxcb-xfixes", self.options.get_safe("with_xcb")), + opt_enable_disable("appkit", self.options.get_safe("with_appkit")), + opt_enable_disable( + "avfoundation", self.options.get_safe("with_avfoundation")), + opt_enable_disable( + "coreimage", self.options.get_safe("with_coreimage")), + opt_enable_disable( + "audiotoolbox", self.options.get_safe("with_audiotoolbox")), + opt_enable_disable( + "videotoolbox", self.options.get_safe("with_videotoolbox")), + opt_enable_disable("securetransport", + self.options.with_ssl == "securetransport"), + "--disable-cuda", # FIXME: CUDA support + "--disable-cuvid", # FIXME: CUVID support + # Licenses + opt_enable_disable("nonfree", self.options.with_libfdk_aac or (self.options.with_ssl and ( + self.options.with_libx264 or self.options.with_libx265 or self.options.postproc))), + opt_enable_disable( + "gpl", self.options.with_libx264 or self.options.with_libx265 or self.options.postproc) + ] + + # Individual Component Options + opt_append_disable_if_set(args, "everything", self.options.disable_everything) + opt_append_disable_if_set(args, "encoders", self.options.disable_all_encoders) + opt_append_disable_if_set(args, "decoders", self.options.disable_all_decoders) + opt_append_disable_if_set(args, "hwaccels", self.options.disable_all_hardware_accelerators) + opt_append_disable_if_set(args, "muxers", self.options.disable_all_muxers) + opt_append_disable_if_set(args, "demuxers", self.options.disable_all_demuxers) + opt_append_disable_if_set(args, "parsers", self.options.disable_all_parsers) + opt_append_disable_if_set(args, "bsfs", self.options.disable_all_bitstream_filters) + opt_append_disable_if_set(args, "protocols", self.options.disable_all_protocols) + opt_append_disable_if_set(args, "devices", self.options.disable_all_devices) + opt_append_disable_if_set(args, "indevs", self.options.disable_all_input_devices) + opt_append_disable_if_set(args, "outdevs", self.options.disable_all_output_devices) + opt_append_disable_if_set(args, "filters", self.options.disable_all_filters) + + args.extend(self._split_and_format_options_string( + "enable-encoder", self.options.enable_encoders)) + args.extend(self._split_and_format_options_string( + "disable-encoder", self.options.disable_encoders)) + args.extend(self._split_and_format_options_string( + "enable-decoder", self.options.enable_decoders)) + args.extend(self._split_and_format_options_string( + "disable-decoder", self.options.disable_decoders)) + args.extend(self._split_and_format_options_string( + "enable-hwaccel", self.options.enable_hardware_accelerators)) + args.extend(self._split_and_format_options_string( + "disable-hwaccel", self.options.disable_hardware_accelerators)) + args.extend(self._split_and_format_options_string( + "enable-muxer", self.options.enable_muxers)) + args.extend(self._split_and_format_options_string( + "disable-muxer", self.options.disable_muxers)) + args.extend(self._split_and_format_options_string( + "enable-demuxer", self.options.enable_demuxers)) + args.extend(self._split_and_format_options_string( + "disable-demuxer", self.options.disable_demuxers)) + args.extend(self._split_and_format_options_string( + "enable-parser", self.options.enable_parsers)) + args.extend(self._split_and_format_options_string( + "disable-parser", self.options.disable_parsers)) + args.extend(self._split_and_format_options_string( + "enable-bsf", self.options.enable_bitstream_filters)) + args.extend(self._split_and_format_options_string( + "disable-bsf", self.options.disable_bitstream_filters)) + args.extend(self._split_and_format_options_string( + "enable-protocol", self.options.enable_protocols)) + args.extend(self._split_and_format_options_string( + "disable-protocol", self.options.disable_protocols)) + args.extend(self._split_and_format_options_string( + "enable-indev", self.options.enable_input_devices)) + args.extend(self._split_and_format_options_string( + "disable-indev", self.options.disable_input_devices)) + args.extend(self._split_and_format_options_string( + "enable-outdev", self.options.enable_output_devices)) + args.extend(self._split_and_format_options_string( + "disable-outdev", self.options.disable_output_devices)) + args.extend(self._split_and_format_options_string( + "enable-filter", self.options.enable_filters)) + args.extend(self._split_and_format_options_string( + "disable-filter", self.options.disable_filters)) + + if self._version_supports_vulkan: + args.append(opt_enable_disable("vulkan", self.options.get_safe("with_vulkan"))) + if self._version_supports_libsvtav1: + args.append(opt_enable_disable("libsvtav1", self.options.get_safe("with_libsvtav1"))) + if self._version_supports_libsvtav1: + args.append(opt_enable_disable("libdav1d", self.options.get_safe("with_libdav1d"))) + if is_apple_os(self): + # relocatable shared libs + args.append("--install-name-dir=@rpath") + args.append(f"--arch={self._target_arch}") + if self.settings.build_type == "Debug": + args.extend([ + "--disable-optimizations", + "--disable-mmx", + "--disable-stripping", + "--enable-debug", + ]) + if not self.options.with_programs: + args.append("--disable-programs") + # since ffmpeg"s build system ignores CC and CXX + compilers_from_conf = self.conf.get("tools.build:compiler_executables", default={}, check_type=dict) + buildenv_vars = VirtualBuildEnv(self).vars() + nm = buildenv_vars.get("NM") + if nm: + args.append(f"--nm={unix_path(self, nm)}") + ar = buildenv_vars.get("AR") + if ar: + args.append(f"--ar={unix_path(self, ar)}") + if self.options.with_asm: + asm = compilers_from_conf.get("asm", buildenv_vars.get("AS")) + if asm: + args.append(f"--as={unix_path(self, asm)}") + strip = buildenv_vars.get("STRIP") + if strip: + args.append(f"--strip={unix_path(self, strip)}") + cc = compilers_from_conf.get("c", buildenv_vars.get("CC", self._default_compilers.get("cc"))) + if cc: + args.append(f"--cc={unix_path(self, cc)}") + cxx = compilers_from_conf.get("cpp", buildenv_vars.get("CXX", self._default_compilers.get("cxx"))) + if cxx: + args.append(f"--cxx={unix_path(self, cxx)}") + ld = buildenv_vars.get("LD") + if ld: + args.append(f"--ld={unix_path(self, ld)}") + ranlib = buildenv_vars.get("RANLIB") + if ranlib: + args.append(f"--ranlib={unix_path(self, ranlib)}") + # for some reason pkgconf from conan can't find .pc files on Linux in the context of ffmpeg configure... + if self._settings_build.os != "Linux": + pkg_config = self.conf.get("tools.gnu:pkg_config", default=buildenv_vars.get("PKG_CONFIG"), check_type=str) + if pkg_config: + args.append(f"--pkg-config={unix_path(self, pkg_config)}") + if is_msvc(self): + args.append("--toolchain=msvc") + if not check_min_vs(self, "190", raise_invalid=False): + # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++) + tc.extra_defines.append("inline=__inline") + if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) >= "15": + # Workaround for link error "ld: building exports trie: duplicate symbol '_av_ac3_parse_header'" + tc.extra_ldflags.append("-Wl,-ld_classic") + if cross_building(self): + args.append(f"--target-os={self._target_os}") + if is_apple_os(self) and self.options.with_audiotoolbox: + args.append("--disable-outdev=audiotoolbox") + + if tc.cflags: + args.append("--extra-cflags={}".format(" ".join(tc.cflags))) + if tc.ldflags: + args.append("--extra-ldflags={}".format(" ".join(tc.ldflags))) + tc.configure_args.extend(args) + tc.generate() + + if is_msvc(self): + # Custom AutotoolsDeps for cl like compilers + # workaround for https://github.com/conan-io/conan/issues/12784 + includedirs = [] + defines = [] + libs = [] + libdirs = [] + linkflags = [] + cxxflags = [] + cflags = [] + for dependency in self.dependencies.values(): + deps_cpp_info = dependency.cpp_info.aggregated_components() + includedirs.extend(deps_cpp_info.includedirs) + defines.extend(deps_cpp_info.defines) + libs.extend(deps_cpp_info.libs + deps_cpp_info.system_libs) + libdirs.extend(deps_cpp_info.libdirs) + linkflags.extend(deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags) + cxxflags.extend(deps_cpp_info.cxxflags) + cflags.extend(deps_cpp_info.cflags) + + env = Environment() + env.append("CPPFLAGS", [f"-I{unix_path(self, p)}" for p in includedirs] + [f"-D{d}" for d in defines]) + env.append("_LINK_", [lib if lib.endswith(".lib") else f"{lib}.lib" for lib in libs]) + env.append("LDFLAGS", [f"-LIBPATH:{unix_path(self, p)}" for p in libdirs] + linkflags) + env.append("CXXFLAGS", cxxflags) + env.append("CFLAGS", cflags) + env.vars(self).save_script("conanautotoolsdeps_cl_workaround") + else: + deps = AutotoolsDeps(self) + deps.generate() + + deps = PkgConfigDeps(self) + deps.generate() + + def _split_and_format_options_string(self, flag_name, options_list): + if not options_list: + return [] + + def _format_options_list_item(flag_name, options_item): + return f"--{flag_name}={options_item}" + + def _split_options_string(options_string): + return list(filter(None, "".join(options_string.split()).split(","))) + + options_string = str(options_list) + return [_format_options_list_item(flag_name, item) for item in _split_options_string(options_string)] + + def build(self): + self._patch_sources() + if self.options.with_libx264: + # ffmepg expects libx264.pc instead of x264.pc + with chdir(self, self.generators_folder): + shutil.copy("x264.pc", "libx264.pc") + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + if is_msvc(self): + if self.options.shared: + # ffmpeg created `.lib` files in the `/bin` folder + for fn in os.listdir(os.path.join(self.package_folder, "bin")): + if fn.endswith(".lib"): + rename(self, os.path.join(self.package_folder, "bin", fn), + os.path.join(self.package_folder, "lib", fn)) + rm(self, "*.def", os.path.join(self.package_folder, "lib")) + else: + # ffmpeg produces `.a` files that are actually `.lib` files + with chdir(self, os.path.join(self.package_folder, "lib")): + for lib in glob.glob("*.a"): + rename(self, lib, lib[3:-2] + ".lib") + + def _read_component_version(self, component_name): + # since 5.1, major version may be defined in version_major.h instead of version.h + component_folder = os.path.join(self.package_folder, "include", f"lib{component_name}") + version_file_name = os.path.join(component_folder, "version.h") + version_major_file_name = os.path.join(component_folder, "version_major.h") + pattern = f"define LIB{component_name.upper()}_VERSION_(MAJOR|MINOR|MICRO)[ \t]+(\\d+)" + version = dict() + for file in (version_file_name, version_major_file_name): + if os.path.isfile(file): + with open(file, "r", encoding="utf-8") as f: + for line in f: + match = re.search(pattern, line) + if match: + version[match[1]] = match[2] + if "MAJOR" in version and "MINOR" in version and "MICRO" in version: + return f"{version['MAJOR']}.{version['MINOR']}.{version['MICRO']}" + return None + + def _set_component_version(self, component_name): + version = self._read_component_version(component_name) + if version is not None: + self.cpp_info.components[component_name].set_property("component_version", version) + # TODO: to remove once support of conan v1 dropped + self.cpp_info.components[component_name].version = version + else: + self.output.warning(f"cannot determine version of lib{component_name} packaged with ffmpeg!") + + def package_info(self): + if self.options.with_programs: + if self.options.with_sdl: + self.cpp_info.components["programs"].requires = [ + "sdl::libsdl2"] + + if self.options.avdevice: + self.cpp_info.components["avdevice"].set_property( + "pkg_config_name", "libavdevice") + self.cpp_info.components["avdevice"].libs = ["avdevice"] + self.cpp_info.components["avdevice"].requires = ["avutil"] + if self.options.avfilter: + self.cpp_info.components["avdevice"].requires.append( + "avfilter") + if self.options.swscale: + self.cpp_info.components["avdevice"].requires.append("swscale") + if self.options.avformat: + self.cpp_info.components["avdevice"].requires.append( + "avformat") + if self.options.avcodec: + self.cpp_info.components["avdevice"].requires.append("avcodec") + if self.options.swresample: + self.cpp_info.components["avdevice"].requires.append( + "swresample") + if self.options.postproc: + self.cpp_info.components["avdevice"].requires.append( + "postproc") + self._set_component_version("avdevice") + + if self.options.avfilter: + self.cpp_info.components["avfilter"].set_property( + "pkg_config_name", "libavfilter") + self.cpp_info.components["avfilter"].libs = ["avfilter"] + self.cpp_info.components["avfilter"].requires = ["avutil"] + if self.options.swscale: + self.cpp_info.components["avfilter"].requires.append("swscale") + if self.options.avformat: + self.cpp_info.components["avfilter"].requires.append( + "avformat") + if self.options.avcodec: + self.cpp_info.components["avfilter"].requires.append("avcodec") + if self.options.swresample: + self.cpp_info.components["avfilter"].requires.append( + "swresample") + if self.options.postproc: + self.cpp_info.components["avfilter"].requires.append( + "postproc") + self._set_component_version("avfilter") + + if self.options.avformat: + self.cpp_info.components["avformat"].set_property( + "pkg_config_name", "libavformat") + self.cpp_info.components["avformat"].libs = ["avformat"] + self.cpp_info.components["avformat"].requires = ["avutil"] + if self.options.avcodec: + self.cpp_info.components["avformat"].requires.append("avcodec") + if self.options.swresample: + self.cpp_info.components["avformat"].requires.append( + "swresample") + self._set_component_version("avformat") + + if self.options.avcodec: + self.cpp_info.components["avcodec"].set_property( + "pkg_config_name", "libavcodec") + self.cpp_info.components["avcodec"].libs = ["avcodec"] + self.cpp_info.components["avcodec"].requires = ["avutil"] + if self.options.swresample: + self.cpp_info.components["avcodec"].requires.append( + "swresample") + self._set_component_version("avcodec") + + if self.options.swscale: + self.cpp_info.components["swscale"].set_property( + "pkg_config_name", "libswscale") + self.cpp_info.components["swscale"].libs = ["swscale"] + self.cpp_info.components["swscale"].requires = ["avutil"] + self._set_component_version("swscale") + + if self.options.swresample: + self.cpp_info.components["swresample"].set_property( + "pkg_config_name", "libswresample") + self.cpp_info.components["swresample"].libs = ["swresample"] + self.cpp_info.components["swresample"].requires = ["avutil"] + self._set_component_version("swresample") + + if self.options.postproc: + self.cpp_info.components["postproc"].set_property( + "pkg_config_name", "libpostproc") + self.cpp_info.components["postproc"].libs = ["postproc"] + self.cpp_info.components["postproc"].requires = ["avutil"] + self._set_component_version("postproc") + + self.cpp_info.components["avutil"].set_property( + "pkg_config_name", "libavutil") + self.cpp_info.components["avutil"].libs = ["avutil"] + self._set_component_version("avutil") + + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["avutil"].system_libs = [ + "pthread", "m", "dl"] + if self.options.swresample: + self.cpp_info.components["swresample"].system_libs = ["m"] + if self.options.swscale: + self.cpp_info.components["swscale"].system_libs = ["m"] + if self.options.postproc: + self.cpp_info.components["postproc"].system_libs = ["m"] + if self.options.get_safe("fPIC"): + if self.settings.compiler in ("gcc", "clang"): + # https://trac.ffmpeg.org/ticket/1713 + # https://ffmpeg.org/platform.html#Advanced-linking-configuration + # https://ffmpeg.org/pipermail/libav-user/2014-December/007719.html + self.cpp_info.components["avcodec"].exelinkflags.append( + "-Wl,-Bsymbolic") + self.cpp_info.components["avcodec"].sharedlinkflags.append( + "-Wl,-Bsymbolic") + if self.options.avformat: + self.cpp_info.components["avformat"].system_libs = ["m"] + if self.options.avfilter: + self.cpp_info.components["avfilter"].system_libs = [ + "m", "pthread"] + if self.options.avdevice: + self.cpp_info.components["avdevice"].system_libs = ["m"] + elif self.settings.os == "Windows": + if self.options.avcodec: + self.cpp_info.components["avcodec"].system_libs = ["mfplat", "mfuuid", "strmiids"] + if self.options.avdevice: + self.cpp_info.components["avdevice"].system_libs = [ + "ole32", "psapi", "strmiids", "uuid", "oleaut32", "shlwapi", "gdi32", "vfw32"] + self.cpp_info.components["avutil"].system_libs = [ + "user32", "bcrypt"] + self.cpp_info.components["avformat"].system_libs = ["secur32"] + elif is_apple_os(self): + if self.options.avdevice: + self.cpp_info.components["avdevice"].frameworks = [ + "CoreFoundation", "Foundation", "CoreGraphics"] + if self.options.avfilter: + self.cpp_info.components["avfilter"].frameworks = [ + "CoreGraphics"] + if self.options.avcodec: + self.cpp_info.components["avcodec"].frameworks = [ + "CoreFoundation", "CoreVideo", "CoreMedia"] + if self.settings.os == "Macos": + if self.options.avdevice: + self.cpp_info.components["avdevice"].frameworks.append( + "OpenGL") + if self.options.avfilter: + self.cpp_info.components["avfilter"].frameworks.append( + "OpenGL") + + if self.options.avdevice: + if self.options.get_safe("with_libalsa"): + self.cpp_info.components["avdevice"].requires.append( + "libalsa::libalsa") + if self.options.get_safe("with_xcb"): + self.cpp_info.components["avdevice"].requires.append( + "xorg::xcb") + if self.options.get_safe("with_pulse"): + self.cpp_info.components["avdevice"].requires.append( + "pulseaudio::pulseaudio") + if self.options.get_safe("with_appkit"): + self.cpp_info.components["avdevice"].frameworks.append( + "AppKit") + if self.options.get_safe("with_avfoundation"): + self.cpp_info.components["avdevice"].frameworks.append( + "AVFoundation") + if self.options.get_safe("with_audiotoolbox"): + self.cpp_info.components["avdevice"].frameworks.append( + "CoreAudio") + + if self.options.avcodec: + if self.options.with_zlib: + self.cpp_info.components["avcodec"].requires.append( + "zlib::zlib") + if self.options.with_lzma: + self.cpp_info.components["avcodec"].requires.append( + "xz_utils::xz_utils") + if self.options.with_libiconv: + self.cpp_info.components["avcodec"].requires.append( + "libiconv::libiconv") + if self.options.with_openjpeg: + self.cpp_info.components["avcodec"].requires.append( + "openjpeg::openjpeg") + if self.options.with_openh264: + self.cpp_info.components["avcodec"].requires.append( + "openh264::openh264") + if self.options.with_vorbis: + self.cpp_info.components["avcodec"].requires.append( + "vorbis::vorbis") + if self.options.with_opus: + self.cpp_info.components["avcodec"].requires.append( + "opus::opus") + if self.options.with_libx264: + self.cpp_info.components["avcodec"].requires.append( + "libx264::libx264") + if self.options.with_libx265: + self.cpp_info.components["avcodec"].requires.append( + "libx265::libx265") + if self.options.with_libvpx: + self.cpp_info.components["avcodec"].requires.append( + "libvpx::libvpx") + if self.options.with_libmp3lame: + self.cpp_info.components["avcodec"].requires.append( + "libmp3lame::libmp3lame") + if self.options.with_libfdk_aac: + self.cpp_info.components["avcodec"].requires.append( + "libfdk_aac::libfdk_aac") + if self.options.with_libwebp: + self.cpp_info.components["avcodec"].requires.append( + "libwebp::libwebp") + if self.options.get_safe("with_audiotoolbox"): + self.cpp_info.components["avcodec"].frameworks.append( + "AudioToolbox") + if self.options.get_safe("with_videotoolbox"): + self.cpp_info.components["avcodec"].frameworks.append( + "VideoToolbox") + if self.options.get_safe("with_libsvtav1"): + self.cpp_info.components["avcodec"].requires.extend( + ["libsvtav1::decoder", "libsvtav1::encoder"]) + if self.options.get_safe("with_libaom"): + self.cpp_info.components["avcodec"].requires.append( + "libaom-av1::libaom-av1") + if self.options.get_safe("with_libdav1d"): + self.cpp_info.components["avcodec"].requires.append( + "dav1d::dav1d") + + if self.options.avformat: + if self.options.with_bzip2: + self.cpp_info.components["avformat"].requires.append( + "bzip2::bzip2") + if self.options.with_zeromq: + self.cpp_info.components["avformat"].requires.append( + "zeromq::libzmq") + if self.options.with_ssl == "openssl": + self.cpp_info.components["avformat"].requires.append( + "openssl::ssl") + elif self.options.with_ssl == "securetransport": + self.cpp_info.components["avformat"].frameworks.append( + "Security") + + if self.options.avfilter: + if self.options.with_freetype: + self.cpp_info.components["avfilter"].requires.append( + "freetype::freetype") + if self.options.with_zeromq: + self.cpp_info.components["avfilter"].requires.append( + "zeromq::libzmq") + if self.options.get_safe("with_appkit"): + self.cpp_info.components["avfilter"].frameworks.append( + "AppKit") + if self.options.get_safe("with_coreimage"): + self.cpp_info.components["avfilter"].frameworks.append( + "CoreImage") + if Version(self.version) >= "5.0" and is_apple_os(self): + self.cpp_info.components["avfilter"].frameworks.append("Metal") + + if self.options.get_safe("with_vaapi"): + self.cpp_info.components["avutil"].requires.extend( + ["vaapi::vaapi", "xorg::x11"]) + + if self.options.get_safe("with_vdpau"): + self.cpp_info.components["avutil"].requires.append("vdpau::vdpau") + + if self._version_supports_vulkan and self.options.get_safe("with_vulkan"): + self.cpp_info.components["avutil"].requires.append( + "vulkan-loader::vulkan-loader") diff --git a/thirdparty/ffmpeg/all/patches/4.2-0001-fix-aom_codec_av1_dx_algo.patch b/thirdparty/ffmpeg/all/patches/4.2-0001-fix-aom_codec_av1_dx_algo.patch new file mode 100644 index 0000000000..7ed8995ec2 --- /dev/null +++ b/thirdparty/ffmpeg/all/patches/4.2-0001-fix-aom_codec_av1_dx_algo.patch @@ -0,0 +1,11 @@ +--- a/libavcodec/libaomdec.c ++++ b/libavcodec/libaomdec.c +@@ -216,7 +216,7 @@ static av_cold int aom_free(AVCodecContext *avctx) + + static av_cold int av1_init(AVCodecContext *avctx) + { +- return aom_init(avctx, &aom_codec_av1_dx_algo); ++ return aom_init(avctx, aom_codec_av1_dx()); + } + + AVCodec ff_libaom_av1_decoder = { diff --git a/thirdparty/ffmpeg/all/patches/4.4-0001-fix-aom_codec_av1_dx_algo.patch b/thirdparty/ffmpeg/all/patches/4.4-0001-fix-aom_codec_av1_dx_algo.patch new file mode 100644 index 0000000000..5855404e33 --- /dev/null +++ b/thirdparty/ffmpeg/all/patches/4.4-0001-fix-aom_codec_av1_dx_algo.patch @@ -0,0 +1,11 @@ +--- a/libavcodec/libaomdec.c ++++ b/libavcodec/libaomdec.c +@@ -224,7 +224,7 @@ static av_cold int aom_free(AVCodecContext *avctx) + + static av_cold int av1_init(AVCodecContext *avctx) + { +- return aom_init(avctx, &aom_codec_av1_dx_algo); ++ return aom_init(avctx, aom_codec_av1_dx()); + } + + AVCodec ff_libaom_av1_decoder = { diff --git a/thirdparty/ffmpeg/all/patches/5.0-0001-fix-hwcontext_vulkan.patch b/thirdparty/ffmpeg/all/patches/5.0-0001-fix-hwcontext_vulkan.patch new file mode 100644 index 0000000000..344b5c89fc --- /dev/null +++ b/thirdparty/ffmpeg/all/patches/5.0-0001-fix-hwcontext_vulkan.patch @@ -0,0 +1,17 @@ +--- a/libavutil/hwcontext_vulkan.c ++++ b/libavutil/hwcontext_vulkan.c +@@ -354,14 +354,6 @@ static const VulkanOptExtension optional_device_exts[] = { + { VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_MEMORY }, + { VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_SEM }, + #endif +- +- /* Video encoding/decoding */ +- { VK_KHR_VIDEO_QUEUE_EXTENSION_NAME, FF_VK_EXT_NO_FLAG }, +- { VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME, FF_VK_EXT_NO_FLAG }, +- { VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME, FF_VK_EXT_NO_FLAG }, +- { VK_EXT_VIDEO_ENCODE_H264_EXTENSION_NAME, FF_VK_EXT_NO_FLAG }, +- { VK_EXT_VIDEO_DECODE_H264_EXTENSION_NAME, FF_VK_EXT_NO_FLAG }, +- { VK_EXT_VIDEO_DECODE_H265_EXTENSION_NAME, FF_VK_EXT_NO_FLAG }, + }; + + /* Converts return values to strings */ diff --git a/thirdparty/ffmpeg/all/patches/5.1-0001-fix-libsvtav1-compressed_ten_bit_format.patch b/thirdparty/ffmpeg/all/patches/5.1-0001-fix-libsvtav1-compressed_ten_bit_format.patch new file mode 100644 index 0000000000..f60f6d44f6 --- /dev/null +++ b/thirdparty/ffmpeg/all/patches/5.1-0001-fix-libsvtav1-compressed_ten_bit_format.patch @@ -0,0 +1,22 @@ +--- a/libavcodec/libsvtav1.c ++++ b/libavcodec/libsvtav1.c +@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err, + + static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc) + { +- const int pack_mode_10bit = +- (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0; +- const size_t luma_size_8bit = +- config->source_width * config->source_height * (1 << pack_mode_10bit); +- const size_t luma_size_10bit = +- (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0; ++ const size_t luma_size = config->source_width * config->source_height * ++ (config->encoder_bit_depth > 8 ? 2 : 1); + + EbSvtIOFormat *in_data; + +- svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2; ++ svt_enc->raw_size = luma_size * 3 / 2; + + // allocate buffer for in and out + svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf)); diff --git a/thirdparty/ffmpeg/all/patches/5.1-0002-fix-libsvtav1-vbv_bufsize-1.patch b/thirdparty/ffmpeg/all/patches/5.1-0002-fix-libsvtav1-vbv_bufsize-1.patch new file mode 100644 index 0000000000..9df9fbb5d6 --- /dev/null +++ b/thirdparty/ffmpeg/all/patches/5.1-0002-fix-libsvtav1-vbv_bufsize-1.patch @@ -0,0 +1,20 @@ +--- a/libavcodec/libsvtav1.c ++++ b/libavcodec/libsvtav1.c +@@ -179,7 +179,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, + param->min_qp_allowed = avctx->qmin; + } + param->max_bit_rate = avctx->rc_max_rate; +- param->vbv_bufsize = avctx->rc_buffer_size; ++ param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / avctx->bit_rate; + + if (svt_enc->crf > 0) { + param->qp = svt_enc->crf; +@@ -296,7 +296,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, + avctx->bit_rate = param->rate_control_mode > 0 ? + param->target_bit_rate : 0; + avctx->rc_max_rate = param->max_bit_rate; +- avctx->rc_buffer_size = param->vbv_bufsize; ++ avctx->rc_buffer_size = param->maximum_buffer_size_ms * avctx->bit_rate / 1000LL; + + if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) { + AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx); diff --git a/thirdparty/ffmpeg/all/patches/5.1-0003-fix-libsvtav1-vbv_bufsize-2.patch b/thirdparty/ffmpeg/all/patches/5.1-0003-fix-libsvtav1-vbv_bufsize-2.patch new file mode 100644 index 0000000000..6bf5219325 --- /dev/null +++ b/thirdparty/ffmpeg/all/patches/5.1-0003-fix-libsvtav1-vbv_bufsize-2.patch @@ -0,0 +1,12 @@ +--- a/libavcodec/libsvtav1.c ++++ b/libavcodec/libsvtav1.c +@@ -179,7 +179,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, + param->min_qp_allowed = avctx->qmin; + } + param->max_bit_rate = avctx->rc_max_rate; +- param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / avctx->bit_rate; ++ if (avctx->bit_rate && avctx->rc_buffer_size) ++ param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / avctx->bit_rate; + + if (svt_enc->crf > 0) { + param->qp = svt_enc->crf; diff --git a/thirdparty/ffmpeg/all/test_package/CMakeLists.txt b/thirdparty/ffmpeg/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..e8b19851e2 --- /dev/null +++ b/thirdparty/ffmpeg/all/test_package/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(ffmpeg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avutil) +if (TARGET ffmpeg::avdevice) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVDEVICE) + target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avdevice) +endif () +if (TARGET ffmpeg::avfilter) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVFILTER) + target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avfilter) +endif () +if (TARGET ffmpeg::avformat) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVFORMAT) + target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avformat) +endif () +if (TARGET ffmpeg::avcodec) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVCODEC) + target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avcodec) +endif () +if (TARGET ffmpeg::swscale) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_SWSCALE) + target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::swscale) +endif () +if (TARGET ffmpeg::swresample) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_SWRESAMPLE) + target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::swresample) +endif () +if (TARGET ffmpeg::postproc) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_POSTPROC) + target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::postproc) +endif () diff --git a/thirdparty/ffmpeg/all/test_package/conanfile.py b/thirdparty/ffmpeg/all/test_package/conanfile.py new file mode 100644 index 0000000000..98ab55852a --- /dev/null +++ b/thirdparty/ffmpeg/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/ffmpeg/all/test_package/test_package.c b/thirdparty/ffmpeg/all/test_package/test_package.c new file mode 100644 index 0000000000..a868a90f9d --- /dev/null +++ b/thirdparty/ffmpeg/all/test_package/test_package.c @@ -0,0 +1,55 @@ +#ifdef HAVE_FFMPEG_AVCODEC +# include +#endif +#ifdef HAVE_FFMPEG_AVFORMAT +# include +#endif +#ifdef HAVE_FFMPEG_AVFILTER +# include +#endif +#ifdef HAVE_FFMPEG_AVDEVICE +# include +#endif +#ifdef HAVE_FFMPEG_SWRESAMPLE +# include +#endif +#ifdef HAVE_FFMPEG_SWSCALE +# include +#endif +#include + +#include +#include + +int main() +{ + #ifdef HAVE_FFMPEG_AVCODEC + printf("configuration: %s\n", avcodec_configuration()); + printf("avcodec version: %d.%d.%d\n", AV_VERSION_MAJOR(avcodec_version()), AV_VERSION_MINOR(avcodec_version()), AV_VERSION_MICRO(avcodec_version())); + #else + printf("avcodec is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_AVFILTER + printf("avfilter version: %d.%d.%d\n", AV_VERSION_MAJOR(avfilter_version()), AV_VERSION_MINOR(avfilter_version()), AV_VERSION_MICRO(avfilter_version())); + #else + printf("avfilter is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_AVDEVICE + avdevice_register_all(); + printf("avdevice version: %d.%d.%d\n", AV_VERSION_MAJOR(avdevice_version()), AV_VERSION_MINOR(avdevice_version()), AV_VERSION_MICRO(avdevice_version())); + #else + printf("avdevice is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_SWRESAMPLE + printf("swresample version: %d.%d.%d\n", AV_VERSION_MAJOR(swresample_version()), AV_VERSION_MINOR(swresample_version()), AV_VERSION_MICRO(swresample_version())); + #else + printf("swresample is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_SWSCALE + printf("swscale version: %d.%d.%d\n", AV_VERSION_MAJOR(swscale_version()), AV_VERSION_MINOR(swscale_version()), AV_VERSION_MICRO(swscale_version())); + #else + printf("swscale is disabled!\n"); + #endif + + return EXIT_SUCCESS; +} diff --git a/thirdparty/ffmpeg/all/test_v1_package/CMakeLists.txt b/thirdparty/ffmpeg/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..0d20897301 --- /dev/null +++ b/thirdparty/ffmpeg/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/thirdparty/ffmpeg/all/test_v1_package/conanfile.py b/thirdparty/ffmpeg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..eab3ab98cc --- /dev/null +++ b/thirdparty/ffmpeg/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + if self.options["ffmpeg"].with_programs: + self.run("ffmpeg --help", run_environment=True) + + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/ffmpeg/config.yml b/thirdparty/ffmpeg/config.yml new file mode 100644 index 0000000000..0ea4ae6cca --- /dev/null +++ b/thirdparty/ffmpeg/config.yml @@ -0,0 +1,25 @@ +versions: + "6.1": + folder: "all" + "6.0.1": + folder: "all" + "6.0": + folder: "all" + "5.1.3": + folder: "all" + "5.1": + folder: "all" + "5.0.3": + folder: "all" + "5.0": + folder: "all" + "4.4.4": + folder: "all" + "4.4.3": + folder: "all" + "4.4": + folder: "all" + "4.3.2": + folder: "all" + "4.2.1": + folder: "all" diff --git a/thirdparty/grpc/all/cmake/grpc_plugin_template.cmake.in b/thirdparty/grpc/all/cmake/grpc_plugin_template.cmake.in new file mode 100644 index 0000000000..5ab1d94fab --- /dev/null +++ b/thirdparty/grpc/all/cmake/grpc_plugin_template.cmake.in @@ -0,0 +1,31 @@ +if(NOT TARGET @target_name@) + # Find @executable_name@ + ## Workaround for legacy "cmake" generator in case of cross-build + if(CMAKE_CROSSCOMPILING) + find_program(@find_program_variable@ + NAMES @executable_name@ + PATHS ENV PATH + NO_DEFAULT_PATH + ) + endif() + ## And here this will work fine with "CMakeToolchain" (for native & cross-build) + ## and legacy "cmake" generator in case of native build + if(NOT @find_program_variable@) + find_program(@find_program_variable@ NAMES @executable_name@) + endif() + ## Last resort: we search in package folder directly + if(NOT @find_program_variable@) + find_program(@find_program_variable@ + NAMES @executable_name@ + PATHS "${CMAKE_CURRENT_LIST_DIR}/@relative_path@bin/" + NO_DEFAULT_PATH + ) + endif() + + # Define @target_name@ imported target + if(@find_program_variable@) + get_filename_component(@find_program_variable@ "${@find_program_variable@}" ABSOLUTE) + add_executable(@target_name@ IMPORTED) + set_property(TARGET @target_name@ PROPERTY IMPORTED_LOCATION ${@find_program_variable@}) + endif() +endif() diff --git a/thirdparty/grpc/all/conan_cmake_project_include.cmake b/thirdparty/grpc/all/conan_cmake_project_include.cmake new file mode 100644 index 0000000000..0d23c71e31 --- /dev/null +++ b/thirdparty/grpc/all/conan_cmake_project_include.cmake @@ -0,0 +1,4 @@ +# TODO: move to a patch? It avoids link errors while resolving abseil symbols with gcc +if (TARGET check_epollexclusive) + set_target_properties(check_epollexclusive PROPERTIES LINKER_LANGUAGE CXX) +endif() diff --git a/thirdparty/grpc/all/conandata.yml b/thirdparty/grpc/all/conandata.yml new file mode 100644 index 0000000000..02c1ca609e --- /dev/null +++ b/thirdparty/grpc/all/conandata.yml @@ -0,0 +1,22 @@ +sources: + "1.54.3": + url: "https://github.com/grpc/grpc/archive/v1.54.3.tar.gz" + sha256: "17e4e1b100657b88027721220cbfb694d86c4b807e9257eaf2fb2d273b41b1b1" + "1.50.1": + url: "https://github.com/grpc/grpc/archive/v1.50.1.tar.gz" + sha256: "fb1ed98eb3555877d55eb2b948caca44bc8601c6704896594de81558639709ef" + "1.50.0": + url: "https://github.com/grpc/grpc/archive/v1.50.0.tar.gz" + sha256: "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a" + "1.48.4": + url: "https://github.com/grpc/grpc/archive/v1.48.4.tar.gz" + sha256: "0c3faa83e39d4f1ab55fe1476362b9ac3b81632a46dce7fd4d50271bce816b53" +patches: + "1.50.1": + - patch_file: "patches/v1.50.x/001-disable-cppstd-override.patch" + "1.50.0": + - patch_file: "patches/v1.50.x/001-disable-cppstd-override.patch" + "1.48.4": + - patch_file: "patches/v1.48.x/001-disable-cppstd-override.patch" + patch_description: "disable cpp std override" + patch_type: "portability" diff --git a/thirdparty/grpc/all/conanfile.py b/thirdparty/grpc/all/conanfile.py new file mode 100644 index 0000000000..88969628a8 --- /dev/null +++ b/thirdparty/grpc/all/conanfile.py @@ -0,0 +1,441 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building, valid_min_cppstd, check_min_cppstd +from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain, CMakeDeps +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file, rmdir +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version + +required_conan_version = ">=1.60.0 <2 || >=2.0.5" + + +class GrpcConan(ConanFile): + name = "grpc" + package_type = "library" + description = "Google's RPC (remote procedure call) library and framework." + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/grpc/grpc" + topics = ("rpc",) + + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "codegen": [True, False], + "csharp_ext": [True, False], + "cpp_plugin": [True, False], + "csharp_plugin": [True, False], + "node_plugin": [True, False], + "objective_c_plugin": [True, False], + "php_plugin": [True, False], + "python_plugin": [True, False], + "ruby_plugin": [True, False], + "secure": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "codegen": True, + "csharp_ext": False, + "cpp_plugin": True, + "csharp_plugin": True, + "node_plugin": True, + "objective_c_plugin": True, + "php_plugin": True, + "python_plugin": True, + "ruby_plugin": True, + "secure": False, + } + + short_paths = True + + @property + def _grpc_plugin_template(self): + return "grpc_plugin_template.cmake.in" + + @property + def _cxxstd_required(self): + return 14 if Version(self.version) >= "1.47" else 11 + + @property + def _is_legacy_one_profile(self): + return not hasattr(self, "settings_build") + + def export_sources(self): + copy(self, "conan_cmake_project_include.cmake", self.recipe_folder, os.path.join(self.export_sources_folder, "src")) + copy(self, f"cmake/{self._grpc_plugin_template}", self.recipe_folder, os.path.join(self.export_sources_folder, "src")) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.options["protobuf"].shared = True + + if cross_building(self): + self.options["grpc"].shared = True + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # abseil is public. See https://github.com/conan-io/conan-center-index/pull/17284#issuecomment-1526082638 + if Version(self.version) < "1.47": + if is_msvc(self): + self.requires("abseil/20211102.0", transitive_headers=True, transitive_libs=True) + else: + self.requires("abseil/20220623.1", transitive_headers=True, transitive_libs=True) + else: + self.requires("abseil/20230125.3", transitive_headers=True, transitive_libs=True) + self.requires("c-ares/1.19.1") + # self.requires("openssl/[>=1.1 <4]") + self.requires("openssl/3.3.0@minifi/dev") + self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True) + self.requires("re2/20230301") + self.requires("zlib/[>=1.2.11 <2]") + if self.settings.os in ["Linux", "FreeBSD"] and Version(self.version) >= "1.52": + # self.requires("libsystemd/255") + self.requires("libsystemd/255@minifi/dev") + + def package_id(self): + del self.info.options.secure + + def validate(self): + check_min_vs(self, "190") + if is_msvc(self) and self.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} shared not supported by Visual Studio") + + if Version(self.version) >= "1.47" and self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "6": + raise ConanInvalidConfiguration("GCC older than 6 is not supported") + + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._cxxstd_required) + + if self.options.shared and not self.dependencies.host["protobuf"].options.shared: + raise ConanInvalidConfiguration( + "If built as shared protobuf must be shared as well. " + "Please, use `protobuf:shared=True`.", + ) + + def build_requirements(self): + if not self._is_legacy_one_profile: + self.tool_requires("protobuf/") + if cross_building(self): + # when cross compiling we need pre compiled grpc plugins for protoc + self.tool_requires(f"grpc/{self.version}") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + # Set up environment so that we can run grpc-cpp-plugin at build time + VirtualBuildEnv(self).generate() + if self._is_legacy_one_profile: + VirtualRunEnv(self).generate(scope="build") + + # This doesn't work yet as one would expect, because the install target builds everything + # and we need the install target because of the generated CMake files + # + # enable_mobile=False # Enables iOS and Android support + # + # cmake.definitions["CONAN_ENABLE_MOBILE"] = "ON" if self.options.csharp_ext else "OFF" + tc = CMakeToolchain(self) + + tc.cache_variables["CMAKE_PROJECT_grpc_INCLUDE"] = os.path.join(self.source_folder, "conan_cmake_project_include.cmake") + + tc.cache_variables["gRPC_BUILD_CODEGEN"] = self.options.codegen + tc.cache_variables["gRPC_BUILD_CSHARP_EXT"] = self.options.csharp_ext + tc.cache_variables["gRPC_BUILD_TESTS"] = "OFF" + + # We need the generated cmake/ files (bc they depend on the list of targets, which is dynamic) + tc.cache_variables["gRPC_INSTALL"] = True + tc.cache_variables["gRPC_INSTALL_SHAREDIR"] = "res/grpc" + + # tell grpc to use the find_package versions + tc.cache_variables["gRPC_ZLIB_PROVIDER"] = "package" + tc.cache_variables["gRPC_CARES_PROVIDER"] = "package" + tc.cache_variables["gRPC_RE2_PROVIDER"] = "package" + tc.cache_variables["gRPC_SSL_PROVIDER"] = "package" + tc.cache_variables["gRPC_PROTOBUF_PROVIDER"] = "package" + tc.cache_variables["gRPC_ABSL_PROVIDER"] = "package" + + tc.cache_variables["gRPC_BUILD_GRPC_CPP_PLUGIN"] = self.options.cpp_plugin + tc.cache_variables["gRPC_BUILD_GRPC_CSHARP_PLUGIN"] = self.options.csharp_plugin + tc.cache_variables["gRPC_BUILD_GRPC_NODE_PLUGIN"] = self.options.node_plugin + tc.cache_variables["gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN"] = self.options.objective_c_plugin + tc.cache_variables["gRPC_BUILD_GRPC_PHP_PLUGIN"] = self.options.php_plugin + tc.cache_variables["gRPC_BUILD_GRPC_PYTHON_PLUGIN"] = self.options.python_plugin + tc.cache_variables["gRPC_BUILD_GRPC_RUBY_PLUGIN"] = self.options.ruby_plugin + + # Consumed targets (abseil) via interface target_compiler_feature can propagate newer standards + if not valid_min_cppstd(self, self._cxxstd_required): + tc.cache_variables["CMAKE_CXX_STANDARD"] = self._cxxstd_required + + if is_apple_os(self): + # workaround for: install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable + tc.cache_variables["CMAKE_MACOSX_BUNDLE"] = False + + if is_msvc(self) and Version(self.version) >= "1.48": + tc.cache_variables["CMAKE_SYSTEM_VERSION"] = "10.0.18362.0" + + tc.generate() + + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + # On macOS if all the following are true: + # - protoc from protobuf has shared library dependencies + # - grpc_cpp_plugin has shared library deps (when crossbuilding) + # - using `make` as the cmake generator + # Make will run commands via `/bin/sh` which will strip all env vars that start with `DYLD*` + # This workaround wraps the protoc command to be invoked by CMake with a modified environment + settings_build = getattr(self, "settings_build", self.settings) + if settings_build.os == "Macos": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}", + 'COMMAND ${CMAKE_COMMAND} -E env "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}" ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}') + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + # Create one custom module file per executable in order to emulate + # CMake executables imported targets of grpc + for plugin_option, values in self._grpc_plugins.items(): + if self.options.get_safe(plugin_option): + target = values["target"] + executable = values["executable"] + self._create_executable_module_file(target, executable) + + @property + def _grpc_plugins(self): + return { + "cpp_plugin": { + "target": "gRPC::grpc_cpp_plugin", + "executable": "grpc_cpp_plugin", + }, + "csharp_plugin": { + "target": "gRPC::grpc_csharp_plugin", + "executable": "grpc_csharp_plugin", + }, + "node_plugin": { + "target": "gRPC::grpc_node_plugin", + "executable": "grpc_node_plugin", + }, + "objective_c_plugin": { + "target": "gRPC::grpc_objective_c_plugin", + "executable": "grpc_objective_c_plugin", + }, + "php_plugin": { + "target": "gRPC::grpc_php_plugin", + "executable": "grpc_php_plugin", + }, + "python_plugin": { + "target": "gRPC::grpc_python_plugin", + "executable": "grpc_python_plugin", + }, + "ruby_plugin": { + "target": "gRPC::grpc_ruby_plugin", + "executable": "grpc_ruby_plugin", + }, + } + + def _create_executable_module_file(self, target, executable): + module_abs_path = os.path.join(self.package_folder, self._module_path) + + # Copy our CMake module template file to package folder + copy(self, self._grpc_plugin_template, src=os.path.join(self.source_folder, "cmake"), dst=module_abs_path) + + # Rename it + dst_file = os.path.join(module_abs_path, f"{executable}.cmake") + rename(self, os.path.join(module_abs_path, self._grpc_plugin_template), dst_file) + + # Replace placeholders + replace_in_file(self, dst_file, "@target_name@", target) + replace_in_file(self, dst_file, "@executable_name@", executable) + + find_program_var = "{}_PROGRAM".format(executable.upper()) + replace_in_file(self, dst_file, "@find_program_variable@", find_program_var) + + module_folder_depth = len(os.path.normpath(self._module_path).split(os.path.sep)) + rel_path = "".join(["../"] * module_folder_depth) + replace_in_file(self, dst_file, "@relative_path@", rel_path) + + @property + def _module_path(self): + return os.path.join("lib", "cmake", "conan_trick") + + @property + def _grpc_components(self): + + def libsystemd(): + return ["libsystemd::libsystemd"] if self.settings.os in ["Linux", "FreeBSD"] and Version(self.version) >= "1.52" else [] + + def libm(): + return ["m"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + def pthread(): + return ["pthread"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + def crypt32(): + return ["crypt32"] if self.settings.os == "Windows" else [] + + def ws2_32(): + return ["ws2_32"] if self.settings.os == "Windows" else [] + + def wsock32(): + return ["wsock32"] if self.settings.os == "Windows" else [] + + def corefoundation(): + return ["CoreFoundation"] if is_apple_os(self) else [] + + components = { + "address_sorting": { + "lib": "address_sorting", + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "gpr": { + "lib": "gpr", + "requires": [ + "upb", "abseil::absl_base", "abseil::absl_memory", + "abseil::absl_status", "abseil::absl_str_format", + "abseil::absl_strings", "abseil::absl_synchronization", + "abseil::absl_time", "abseil::absl_optional", + "abseil::absl_flags" + ] + libsystemd(), + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "_grpc": { + "lib": "grpc", + "requires": [ + "address_sorting", "gpr", "upb", "abseil::absl_bind_front", + "abseil::absl_flat_hash_map", "abseil::absl_inlined_vector", + "abseil::absl_statusor", "abseil::absl_random_random", + "c-ares::cares", "openssl::crypto", + "openssl::ssl", "re2::re2", "zlib::zlib", + ], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + "frameworks": corefoundation(), + }, + "grpc++": { + "lib": "grpc++", + "requires": ["_grpc", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpc++_alts": { + "lib": "grpc++_alts", + "requires": ["grpc++", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpc++_error_details": { + "lib": "grpc++_error_details", + "requires": ["grpc++", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "upb": { + "lib": "upb", + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpc_plugin_support": { + "lib": "grpc_plugin_support", + "requires": ["protobuf::libprotoc", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + } + + if not self.options.secure: + components.update({ + "grpc_unsecure": { + "lib": "grpc_unsecure", + "requires": [ + "address_sorting", "gpr", "upb", "abseil::absl_flat_hash_map", + "abseil::absl_inlined_vector", "abseil::absl_statusor", + "c-ares::cares", "re2::re2", "zlib::zlib", + "abseil::absl_random_random", + ], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + "frameworks": corefoundation(), + }, + "grpc++_unsecure": { + "lib": "grpc++_unsecure", + "requires": ["grpc_unsecure", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + }) + + if self.options.codegen: + components.update({ + "grpc++_reflection": { + "lib": "grpc++_reflection", + "requires": ["grpc++", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpcpp_channelz": { + "lib": "grpcpp_channelz", + "requires": ["grpc++", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + }) + + return components + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "gRPC") + self.cpp_info.resdirs = ["res"] + ssl_roots_file_path = os.path.join(self.package_folder, "res", "grpc", "roots.pem") + self.runenv_info.define_path("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", ssl_roots_file_path) + + for component, values in self._grpc_components.items(): + target = values.get("lib") + lib = values.get("lib") + self.cpp_info.components[component].set_property("cmake_target_name", "gRPC::{}".format(target)) + # actually only gpr, grpc, grpc_unsecure, grpc++ and grpc++_unsecure should have a .pc file + self.cpp_info.components[component].set_property("pkg_config_name", target) + self.cpp_info.components[component].libs = [lib] + self.cpp_info.components[component].requires = values.get("requires", []) + self.cpp_info.components[component].system_libs = values.get("system_libs", []) + self.cpp_info.components[component].frameworks = values.get("frameworks", []) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components[component].names["cmake_find_package"] = target + self.cpp_info.components[component].names["cmake_find_package_multi"] = target + + # Executable imported targets are added through custom CMake module files, + # since conan generators don't know how to emulate these kind of targets. + grpc_modules = [] + for plugin_option, values in self._grpc_plugins.items(): + if self.options.get_safe(plugin_option): + grpc_module_filename = "{}.cmake".format(values["executable"]) + grpc_modules.append(os.path.join(self._module_path, grpc_module_filename)) + self.cpp_info.set_property("cmake_build_modules", grpc_modules) + + # TODO: to remove once conan v1 not supported anymore + self.cpp_info.names["cmake_find_package"] = "gRPC" + self.cpp_info.names["cmake_find_package_multi"] = "gRPC" + self.env_info.GRPC_DEFAULT_SSL_ROOTS_FILE_PATH = ssl_roots_file_path + if grpc_modules: + self.cpp_info.components["grpc_execs"].build_modules["cmake_find_package"] = grpc_modules + self.cpp_info.components["grpc_execs"].build_modules["cmake_find_package_multi"] = grpc_modules + if any(self.options.get_safe(plugin_option) for plugin_option in self._grpc_plugins.keys()): + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/thirdparty/grpc/all/patches/v1.48.x/001-disable-cppstd-override.patch b/thirdparty/grpc/all/patches/v1.48.x/001-disable-cppstd-override.patch new file mode 100644 index 0000000000..dee7836ac5 --- /dev/null +++ b/thirdparty/grpc/all/patches/v1.48.x/001-disable-cppstd-override.patch @@ -0,0 +1,39 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1ecaea8eb7..0788b88177 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -226,21 +226,6 @@ if (NOT DEFINED CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 11) + endif() + +-# Add c++14 flags +-if (NOT DEFINED CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 14) +-else() +- if (CMAKE_CXX_STANDARD LESS 14) +- message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 14, please specify at least SET(CMAKE_CXX_STANDARD 14)") +- endif() +-endif() +-if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) +- set(CMAKE_CXX_STANDARD_REQUIRED ON) +-endif() +-if (NOT DEFINED CMAKE_CXX_EXTENSIONS) +- set(CMAKE_CXX_EXTENSIONS OFF) +-endif() +- + if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + endif() +diff --git a/src/core/ext/xds/xds_http_fault_filter.cc b/src/core/ext/xds/xds_http_fault_filter.cc +index 2a10d2fd27..0900fedf61 100644 +--- a/src/core/ext/xds/xds_http_fault_filter.cc ++++ b/src/core/ext/xds/xds_http_fault_filter.cc +@@ -109,7 +109,7 @@ absl::StatusOr ParseHttpFaultIntoJson( + int abort_http_status_code = + envoy_extensions_filters_http_fault_v3_FaultAbort_http_status( + fault_abort); +- if (abort_http_status_code != 0 and abort_http_status_code != 200) { ++ if (abort_http_status_code != 0 && abort_http_status_code != 200) { + abort_grpc_status_code = + grpc_http2_status_to_grpc_status(abort_http_status_code); + } diff --git a/thirdparty/grpc/all/patches/v1.50.x/001-disable-cppstd-override.patch b/thirdparty/grpc/all/patches/v1.50.x/001-disable-cppstd-override.patch new file mode 100644 index 0000000000..fb952330fd --- /dev/null +++ b/thirdparty/grpc/all/patches/v1.50.x/001-disable-cppstd-override.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7052846..259fa93 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -227,21 +227,6 @@ if (NOT DEFINED CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 11) + endif() + +-# Add c++14 flags +-if (NOT DEFINED CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 14) +-else() +- if (CMAKE_CXX_STANDARD LESS 14) +- message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 14, please specify at least SET(CMAKE_CXX_STANDARD 14)") +- endif() +-endif() +-if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) +- set(CMAKE_CXX_STANDARD_REQUIRED ON) +-endif() +-if (NOT DEFINED CMAKE_CXX_EXTENSIONS) +- set(CMAKE_CXX_EXTENSIONS OFF) +-endif() +- + if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + endif() diff --git a/thirdparty/grpc/all/test_package/CMakeLists.txt b/thirdparty/grpc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..15a54da82c --- /dev/null +++ b/thirdparty/grpc/all/test_package/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + + +find_package(protobuf CONFIG REQUIRED) +find_package(gRPC CONFIG REQUIRED) + +message("DYLD_LIBRARY_PATH from CMake: $ENV{DYLD_LIBRARY_PATH}") + +add_executable(${PROJECT_NAME} test_package.cpp helloworld.proto) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) # grpc 1.47.0 requires c++14 +target_link_libraries(${PROJECT_NAME} + PRIVATE + protobuf::libprotobuf + $,gRPC::grpc++_unsecure,gRPC::grpc++> +) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +if(TEST_ACTUAL_SERVER) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DTEST_ACTUAL_SERVER) +endif() +protobuf_generate( + TARGET ${PROJECT_NAME} + LANGUAGE cpp +) +protobuf_generate( + TARGET ${PROJECT_NAME} + LANGUAGE grpc + GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc + PLUGIN protoc-gen-grpc=$ +) diff --git a/thirdparty/grpc/all/test_package/conanfile.py b/thirdparty/grpc/all/test_package/conanfile.py new file mode 100644 index 0000000000..cb18d0a94b --- /dev/null +++ b/thirdparty/grpc/all/test_package/conanfile.py @@ -0,0 +1,63 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.microsoft import is_msvc +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + @property + def _is_legacy_one_profile(self): + return not hasattr(self, "settings_build") + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + self.requires("protobuf/3.21.12") + + def build_requirements(self): + if not self._is_legacy_one_profile: + # For the grpc-cpp-plugin executable at build time + self.tool_requires(self.tested_reference_str) + self.tool_requires("protobuf/") + + def generate(self): + # Set up environment so that we can run protoc & grpc-cpp-plugin at build time + if self._is_legacy_one_profile: + VirtualRunEnv(self).generate(scope="build") + else: + VirtualBuildEnv(self).generate() + + # Environment so that the compiled test executable can load shared libraries + runenv = VirtualRunEnv(self) + runenv.generate() + + tc = CMakeToolchain(self) + tc.cache_variables["TEST_ACTUAL_SERVER"] = not (is_msvc(self) + and str(self.settings.compiler.version) in ("15", "191") + and self.settings.build_type == "Release") + + # Additional logic to override the make program on MacOS if /usr/bin/make is found by CMake + # which otherwise prevents the propagation of DYLD_LIBRARY_PATH as set by the VirtualBuildEnv + project_include = os.path.join(self.source_folder, "macos_make_override.cmake") + tc.cache_variables["CMAKE_PROJECT_test_package_INCLUDE"] = project_include + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/grpc/all/test_package/helloworld.proto b/thirdparty/grpc/all/test_package/helloworld.proto new file mode 100644 index 0000000000..be878ce25f --- /dev/null +++ b/thirdparty/grpc/all/test_package/helloworld.proto @@ -0,0 +1,38 @@ +// Copyright 2015 gRPC 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. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "io.grpc.examples.helloworld"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings +message HelloReply { + string message = 1; +} diff --git a/thirdparty/grpc/all/test_package/macos_make_override.cmake b/thirdparty/grpc/all/test_package/macos_make_override.cmake new file mode 100644 index 0000000000..e7078c1b51 --- /dev/null +++ b/thirdparty/grpc/all/test_package/macos_make_override.cmake @@ -0,0 +1,13 @@ +if (CMAKE_GENERATOR MATCHES "Unix Makefiles" AND CMAKE_HOST_APPLE AND CMAKE_MAKE_PROGRAM MATCHES "/usr/bin/make") + execute_process( + COMMAND xcrun --find make + OUTPUT_VARIABLE xcode_make OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE xcrun_error) + if(xcode_make) + #Override the value of `CMAKE_MAKE_PROGRAM` + set_property(CACHE CMAKE_MAKE_PROGRAM PROPERTY VALUE "${xcode_make}") + else() + message(WARNING "Using /usr/bin/make may prevent execution of Conan tool_requires that require DYLD_LIBRARY_PATH" + " to be set at build time.") + endif() +endif() diff --git a/thirdparty/grpc/all/test_package/test_package.cpp b/thirdparty/grpc/all/test_package/test_package.cpp new file mode 100644 index 0000000000..18a37cf906 --- /dev/null +++ b/thirdparty/grpc/all/test_package/test_package.cpp @@ -0,0 +1,122 @@ +/* + * + * Copyright 2015 gRPC 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include + +#include +#include "helloworld.grpc.pb.h" + +using grpc::Channel; +using grpc::ClientContext; +using grpc::Server; +using grpc::ServerBuilder; +using grpc::ServerContext; +using grpc::Status; +using helloworld::HelloRequest; +using helloworld::HelloReply; +using helloworld::Greeter; + +class GreeterClient { + public: + GreeterClient(std::shared_ptr channel) + : stub_(Greeter::NewStub(channel)) {} + + // Assembles the client's payload, sends it and presents the response back + // from the server. + std::string SayHello(const std::string& user) { + // Data we are sending to the server. + HelloRequest request; + request.set_name(user); + + // Container for the data we expect from the server. + HelloReply reply; + + // Context for the client. It could be used to convey extra information to + // the server and/or tweak certain RPC behaviors. + ClientContext context; + + // The actual RPC. + Status status = stub_->SayHello(&context, request, &reply); + + // Act upon its status. + if (status.ok()) { + return reply.message(); + } else { + std::cout << status.error_code() << ": " << status.error_message() + << std::endl; + return "RPC failed"; + } + } + + private: + std::unique_ptr stub_; +}; + +// Logic and data behind the server's behavior. +class GreeterServiceImpl final : public Greeter::Service { + Status SayHello(ServerContext* context, const HelloRequest* request, + HelloReply* reply) override { + std::string prefix("Hello "); + reply->set_message(prefix + request->name()); + return Status::OK; + } +}; + +int main(int argc, char** argv) { + std::string server_address("127.0.0.1:0"); + GreeterServiceImpl service; + + ServerBuilder builder; + int selected_port = 0; + // Listen on the given address without any authentication mechanism. + builder.AddListeningPort(server_address, grpc::InsecureServerCredentials(), &selected_port); + // Register "service" as the instance through which we'll communicate with + // clients. In this case it corresponds to an *synchronous* service. + builder.RegisterService(&service); + + // Finally assemble the server. +#ifdef TEST_ACTUAL_SERVER + std::unique_ptr server(builder.BuildAndStart()); + std::thread serverThread([&](){ + std::cout << "Server listening on 127.0.0.1:" << selected_port << std::endl; + server->Wait(); + std::cout << "Server closed" << std::endl; + }); +#endif + + // Instantiate the client. It requires a channel, out of which the actual RPCs + // are created. This channel models a connection to an endpoint (in this case, + // localhost at the selected port). We indicate that the channel isn't + // authenticated (use of InsecureChannelCredentials()). + std::ostringstream addr; + addr << "localhost:" << selected_port; + GreeterClient greeter(grpc::CreateChannel(addr.str(), grpc::InsecureChannelCredentials())); + std::string user("world"); + std::string reply = greeter.SayHello(user); + std::cout << "Greeter received: " << reply << std::endl; + +#ifdef TEST_ACTUAL_SERVER + server->Shutdown(); + serverThread.join(); +#endif + return 0; +} diff --git a/thirdparty/grpc/all/test_v1_package/CMakeLists.txt b/thirdparty/grpc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..f16bc97992 --- /dev/null +++ b/thirdparty/grpc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_v1_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/thirdparty/grpc/all/test_v1_package/conanfile.py b/thirdparty/grpc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..5fbf37e412 --- /dev/null +++ b/thirdparty/grpc/all/test_v1_package/conanfile.py @@ -0,0 +1,55 @@ +from conans import ConanFile, CMake, tools +import contextlib +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if hasattr(self, "settings_build"): + self.build_requires(str(self.requires["grpc"])) + + @contextlib.contextmanager + def _buildenv(self): + # TODO: conan v2: replace by VirtualBuildEnv and always add grpc to build requirements + if tools.cross_building(self): + yield + else: + with tools.run_environment(self): + yield + + @property + def macos_grpc_shared(self): + # Due to SIP limitations on newer macOS, `DYLD_LIBRARY_PATH`, which is set + # by `tools.run_environment`, will not be propagated properly, see + # https://stackoverflow.com/questions/35568122/why-isnt-dyld-library-path-being-propagated-here + return self.settings.os == "Macos" and self.options["grpc"].shared + + def build(self): + # TODO: always build in conan v2 + # this is a limitation of conan v1: + # at build time we want to inject PATH/LD_LIBRARY/DYLD_LIBRARY_PATH + # of build requirements so that gprc_cpp_plugin can find its + # shared dependencies (in build context as well) + # should be fixed by using: CMakeToolchain + VirtualBuildEnv + if (tools.cross_building(self) and self.options["grpc"].shared) or self.macos_grpc_shared: + self.output.warning("Skipping build of test_package due to limitation propagating " + "runtime environment when invoking protoc and grpc_cpp_plugin. " + "For a working example, please see the newer Conan 2.0 compatible " + "test package.") + return + with self._buildenv(): + cmake = CMake(self) + # FIXME: This combination of settings randomly fails in CI + cmake.definitions["TEST_ACTUAL_SERVER"] = not (self.settings.compiler == "Visual Studio" + and self.settings.compiler.version == "15" + and self.settings.build_type == "Release") + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self) and not self.macos_grpc_shared: + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/grpc/config.yml b/thirdparty/grpc/config.yml new file mode 100644 index 0000000000..0e75e17263 --- /dev/null +++ b/thirdparty/grpc/config.yml @@ -0,0 +1,9 @@ +versions: + "1.54.3": + folder: "all" + "1.50.1": + folder: "all" + "1.50.0": + folder: "all" + "1.48.4": + folder: "all" diff --git a/thirdparty/libarchive/all/conandata.yml b/thirdparty/libarchive/all/conandata.yml new file mode 100644 index 0000000000..11f354164f --- /dev/null +++ b/thirdparty/libarchive/all/conandata.yml @@ -0,0 +1,78 @@ +sources: + "3.7.4": + url: "https://github.com/libarchive/libarchive/releases/download/v3.7.4/libarchive-3.7.4.tar.xz" + sha256: "f887755c434a736a609cbd28d87ddbfbe9d6a3bb5b703c22c02f6af80a802735" + "3.7.3": + url: "https://github.com/libarchive/libarchive/releases/download/v3.7.3/libarchive-3.7.3.tar.xz" + sha256: "63e7a7174638fc7d6b79b4c8b0ad954e0f4f45abe7239c1ecb200232aa9a43d2" + "3.7.2": + url: "https://github.com/libarchive/libarchive/releases/download/v3.7.2/libarchive-3.7.2.tar.xz" + sha256: "04357661e6717b6941682cde02ad741ae4819c67a260593dfb2431861b251acb" + "3.7.1": + url: "https://github.com/libarchive/libarchive/releases/download/v3.7.1/libarchive-3.7.1.tar.xz" + sha256: "b17403ce670ff18d8e06fea05a9ea9accf70678c88f1b9392a2e29b51127895f" + "3.4.2": + url: "https://github.com/libarchive/libarchive/releases/download/v3.4.2/libarchive-3.4.2.tar.gz" + sha256: "b60d58d12632ecf1e8fad7316dc82c6b9738a35625746b47ecdcaf4aed176176" +patches: + "3.7.4": + - patch_file: "patches/0001-3.7.4-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.7.4-cmake.patch" + patch_description: "Make CMake build-system compatible with Conan" + patch_type: "conan" + - patch_file: "patches/0005-3.7.4-try-compile-cmakedeps.patch" + patch_description: "Patch try_compile check to work with imported CMake targets from Conan packages" + patch_type: "conan" + - patch_file: "patches/0006-3.7.4-fix-msvc-build.patch" + patch_description: "Fix MSVC build" + patch_type: "conan" + "3.7.3": + - patch_file: "patches/0001-3.7.3-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.7.3-cmake.patch" + patch_description: "Make CMake build-system compatible with Conan" + patch_type: "conan" + - patch_file: "patches/0005-3.7.3-try-compile-cmakedeps.patch" + patch_description: "Patch try_compile check to work with imported CMake targets from Conan packages" + patch_type: "conan" + - patch_file: "patches/0006-3.7.3-fix-msvc-build.patch" + patch_description: "Fix MSVC build" + patch_type: "conan" + "3.7.2": + - patch_file: "patches/0001-3.7.2-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.7.1-cmake.patch" + patch_description: "Make CMake build-system compatible with Conan" + patch_type: "conan" + - patch_file: "patches/0005-3.7.1-try-compile-cmakedeps.patch" + patch_description: "Patch try_compile check to work with imported CMake targets from Conan packages" + patch_type: "conan" + - patch_file: "patches/0006-3.7.1-fix-msvc-build.patch" + patch_description: "Fix MSVC build" + patch_type: "conan" + "3.7.1": + - patch_file: "patches/0007-3.7.1-include-getopt.patch" + patch_description: "include getopt.h if HAVE_GETOPT_OPTRESET is defined" + patch_type: "portability" + patch_source: "https://github.com/libarchive/libarchive/pull/2007" + - patch_file: "patches/0001-3.7.1-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.7.1-cmake.patch" + patch_description: "Make CMake build-system compatible with Conan" + patch_type: "conan" + - patch_file: "patches/0005-3.7.1-try-compile-cmakedeps.patch" + patch_description: "Patch try_compile check to work with imported CMake targets from Conan packages" + patch_type: "conan" + - patch_file: "patches/0006-3.7.1-fix-msvc-build.patch" + patch_description: "Fix MSVC build" + patch_type: "conan" + "3.4.2": + - patch_file: "patches/libarchive.patch" + patch_description: "Patch LibArchive CMakeLists.txt for MiNiFi C++" + patch_type: "conan" + \ No newline at end of file diff --git a/thirdparty/libarchive/all/conanfile.py b/thirdparty/libarchive/all/conanfile.py new file mode 100644 index 0000000000..670d4a58bb --- /dev/null +++ b/thirdparty/libarchive/all/conanfile.py @@ -0,0 +1,202 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout, CMakeDeps, CMakeToolchain +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.53.0" + + +class LibarchiveConan(ConanFile): + name = "libarchive" + description = "Multi-format archive and compression library" + topics = "archive", "compression", "tar", "data-compressor", "file-compression" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://libarchive.org" + license = "BSD-2-Clause" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_acl": [True, False], + "with_zlib": [True, False], + "with_bzip2": [True, False], + "with_libxml2": [True, False], + "with_expat": [True, False], + "with_iconv": [True, False], + "with_pcreposix": [True, False], + "with_cng": [True, False], + "with_nettle": [True, False], + "with_openssl": [True, False], + "with_libb2": [True, False], + "with_lz4": [True, False], + "with_lzo": [True, False], + "with_lzma": [True, False], + "with_zstd": [True, False], + "with_mbedtls": [True, False], + "with_xattr": [True, False], + "with_pcre2": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_acl": True, + "with_zlib": True, + "with_bzip2": True, + "with_libxml2": False, + "with_expat": False, + "with_iconv": False, + "with_pcreposix": False, + "with_cng": False, + "with_nettle": False, + "with_openssl": False, + "with_libb2": False, + "with_lz4": False, + "with_lzo": False, + "with_lzma": True, + "with_zstd": False, + "with_mbedtls": False, + "with_xattr": True, + "with_pcre2": False, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if Version(self.version) < "3.7.3": + del self.options.with_pcre2 + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.with_bzip2: + self.requires("bzip2/1.0.8") + # self.requires("bzip2/1.0.8@minifi/dev") + if self.options.with_libxml2: + self.requires("libxml2/[>=2.12.5 <3]") + if self.options.with_expat: + self.requires("expat/[>=2.6.2 <3]") + if self.options.with_iconv: + self.requires("libiconv/1.17") + if self.options.with_pcreposix: + self.requires("pcre2/10.42") + if self.options.with_nettle: + self.requires("nettle/3.9.1") + if self.options.with_openssl: + # self.requires("openssl/[>=1.1 <4]") + self.requires("openssl/3.3.0@minifi/dev") # note: need to figure how to integrate openssl conan with libarchive; think libarchive needs a patch + if self.options.with_libb2: + self.requires("libb2/20190723") + if self.options.with_lz4: + self.requires("lz4/1.9.4") + if self.options.with_lzo: + self.requires("lzo/2.10") + if self.options.with_lzma: + # self.requires("xz_utils/5.4.5") + self.requires("xz_utils/5.2.5@minifi/dev") + if self.options.with_zstd: + self.requires("zstd/1.5.5") + if self.options.get_safe("with_mbedtls"): + self.requires("mbedtls/3.5.1") + if self.options.get_safe("with_pcre2"): + self.requires("pcre2/10.43") + + def validate(self): + if self.settings.os != "Windows" and self.options.with_cng: + # TODO: add cng when available in CCI + raise ConanInvalidConfiguration("cng recipe not yet available in CCI.") + if self.options.with_expat and self.options.with_libxml2: + raise ConanInvalidConfiguration("libxml2 and expat options are exclusive. They cannot be used together as XML engine") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + tc = CMakeToolchain(self) + # turn off deps to avoid picking up them accidentally + if not self.options.shared: + tc.variables["LIBARCHIVE_STATIC"] = "1" + tc.variables["ENABLE_NETTLE"] = self.options.with_nettle + tc.variables["ENABLE_OPENSSL"] = self.options.with_openssl + tc.variables["ENABLE_LIBB2"] = self.options.with_libb2 + tc.variables["ENABLE_LZ4"] = self.options.with_lz4 + tc.variables["ENABLE_LZO"] = self.options.with_lzo + tc.variables["ENABLE_LZMA"] = self.options.with_lzma + tc.variables["ENABLE_ZSTD"] = self.options.with_zstd + tc.variables["ENABLE_ZLIB"] = self.options.with_zlib + tc.variables["ENABLE_BZip2"] = self.options.with_bzip2 + # requires LibXml2 cmake name + tc.variables["ENABLE_LIBXML2"] = self.options.with_libxml2 + tc.variables["ENABLE_ICONV"] = self.options.with_iconv + tc.variables["ENABLE_EXPAT"] = self.options.with_expat + tc.variables["ENABLE_PCREPOSIX"] = self.options.with_pcreposix + if self.options.with_pcreposix: + tc.variables["POSIX_REGEX_LIB"] = "LIBPCREPOSIX" + tc.variables["ENABLE_LibGCC"] = False + tc.variables["ENABLE_CNG"] = self.options.with_cng + # turn off features + tc.variables["ENABLE_ACL"] = self.options.with_acl + # turn off components + tc.variables["ENABLE_TAR"] = False + tc.variables["ENABLE_CPIO"] = False + tc.variables["ENABLE_CAT"] = False + tc.variables["ENABLE_TEST"] = False + tc.variables["ENABLE_UNZIP"] = False + # too strict check + tc.variables["ENABLE_WERROR"] = False + tc.variables["ENABLE_MBEDTLS"] = self.options.with_mbedtls + if Version(self.version) >= "3.7.3": + tc.variables["ENABLE_PCRE2POSIX"] = self.options.with_pcre2 + tc.variables["ENABLE_XATTR"] = self.options.with_xattr + # TODO: Remove after fixing https://github.com/conan-io/conan/issues/12012 + if is_msvc(self): + tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "LibArchive") + + self.cpp_info.set_property("cmake_target_name", "LibArchive::LibArchive") + self.cpp_info.set_property("pkg_config_name", "libarchive") + + self.cpp_info.names["cmake_find_package"] = "LibArchive" + self.cpp_info.names["cmake_find_package_multi"] = "LibArchive" + + self.cpp_info.libs = collect_libs(self) + if self.settings.os == "Windows" and self.options.with_cng: + self.cpp_info.system_libs.append("bcrypt") + if is_msvc(self) and not self.options.shared: + self.cpp_info.defines = ["LIBARCHIVE_STATIC"] + elif not self.options.shared: + self.cpp_info.defines = ["LIBARCHIVE_STATIC=1"] diff --git a/thirdparty/libarchive/all/patches/0001-3.7.1-zlib-winapi.patch b/thirdparty/libarchive/all/patches/0001-3.7.1-zlib-winapi.patch new file mode 100644 index 0000000000..beb5f743fa --- /dev/null +++ b/thirdparty/libarchive/all/patches/0001-3.7.1-zlib-winapi.patch @@ -0,0 +1,27 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6849ce40..57cf7f8f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -444,14 +444,14 @@ IF(ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) + IF(WIN32 AND NOT CYGWIN) +- # +- # Test if ZLIB_WINAPI macro is needed to use. +- # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) ++ ++ ++ ++ ++ ++ ++ ++ SET(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) diff --git a/thirdparty/libarchive/all/patches/0001-3.7.2-zlib-winapi.patch b/thirdparty/libarchive/all/patches/0001-3.7.2-zlib-winapi.patch new file mode 100644 index 0000000000..9c5a48b11c --- /dev/null +++ b/thirdparty/libarchive/all/patches/0001-3.7.2-zlib-winapi.patch @@ -0,0 +1,35 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ff1b025..53ecd0e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,7 +13,6 @@ SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +-# + # Set the Build type for make based generators. + # You can choose following types: + # Debug : Debug build +@@ -445,14 +444,14 @@ IF(ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) + IF(WIN32 AND NOT CYGWIN) +- # +- # Test if ZLIB_WINAPI macro is needed to use. +- # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) ++ ++ ++ ++ ++ ++ ++ ++ SET(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) diff --git a/thirdparty/libarchive/all/patches/0001-3.7.3-zlib-winapi.patch b/thirdparty/libarchive/all/patches/0001-3.7.3-zlib-winapi.patch new file mode 100644 index 0000000000..ca141ca403 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0001-3.7.3-zlib-winapi.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c0fbd70..44ca23d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -454,12 +454,12 @@ IF(ZLIB_FOUND) + # + # Test if ZLIB_WINAPI macro is needed to use. + # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) +- IF(ZLIB_WINAPI) ++ # TRY_MACRO_FOR_LIBRARY( ++ # "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" ++ # RUNS ++ # "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" ++ # ZLIB_WINAPI) ++ IF(TRUE) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) + # Test if a macro is needed for the library. diff --git a/thirdparty/libarchive/all/patches/0001-3.7.4-zlib-winapi.patch b/thirdparty/libarchive/all/patches/0001-3.7.4-zlib-winapi.patch new file mode 100644 index 0000000000..11d72518d4 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0001-3.7.4-zlib-winapi.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ec97e4c..7e87e07 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -456,12 +456,12 @@ IF(ZLIB_FOUND) + # + # Test if ZLIB_WINAPI macro is needed to use. + # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) +- IF(ZLIB_WINAPI) ++ # TRY_MACRO_FOR_LIBRARY( ++ # "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" ++ # RUNS ++ # "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" ++ # ZLIB_WINAPI) ++ IF(TRUE) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) + # Test if a macro is needed for the library. diff --git a/thirdparty/libarchive/all/patches/0003-3.7.1-cmake.patch b/thirdparty/libarchive/all/patches/0003-3.7.1-cmake.patch new file mode 100644 index 0000000000..67a75a07b0 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0003-3.7.1-cmake.patch @@ -0,0 +1,91 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6849ce40..8d5b6018 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -9,7 +9,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +@@ -442,7 +442,7 @@ IF(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ LIST(APPEND ADDITIONAL_LIBS ZLIB::ZLIB) + IF(WIN32 AND NOT CYGWIN) + + +@@ -511,7 +511,7 @@ IF(LIBLZMA_FOUND) + SET(HAVE_LIBLZMA 1) + SET(HAVE_LZMA_H 1) + CMAKE_PUSH_CHECK_STATE() +- SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) ++ SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) +@@ -532,7 +532,7 @@ ELSE(LIBLZMA_FOUND) + # LZMA not found and will not be used. + SET(HAVE_LZMA_STREAM_ENCODER_MT 0) + ENDIF(LIBLZMA_FOUND) +-MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIRS) + MARK_AS_ADVANCED(CLEAR LIBLZMA_LIBRARY) + + # +@@ -603,7 +603,7 @@ IF(ENABLE_LZ4) + ENDIF (LZ4_INCLUDE_DIR) + + FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +- FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) ++ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) + ELSE(ENABLE_LZ4) +@@ -827,7 +827,7 @@ ENDIF(ENABLE_NETTLE) + # Find OpenSSL + # (Except on Mac, where OpenSSL is deprecated.) + # +-IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") ++IF(ENABLE_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index f7fdfb68..9d2915ac 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -251,6 +251,7 @@ IF(BUILD_SHARED_LIBS) + ENDIF(BUILD_SHARED_LIBS) + + # archive_static is a static library ++if(NOT BUILD_SHARED_LIBS) + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) + SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS +@@ -259,6 +260,7 @@ SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS + IF(NOT WIN32 OR CYGWIN OR NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN OR NOT BUILD_SHARED_LIBS) ++endif() + + IF(ENABLE_INSTALL) + # How to install the libraries +@@ -268,10 +270,12 @@ IF(ENABLE_INSTALL) + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + ENDIF(BUILD_SHARED_LIBS) ++ if(NOT BUILD_SHARED_LIBS) + INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ endif() + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/thirdparty/libarchive/all/patches/0003-3.7.3-cmake.patch b/thirdparty/libarchive/all/patches/0003-3.7.3-cmake.patch new file mode 100644 index 0000000000..a4c5151beb --- /dev/null +++ b/thirdparty/libarchive/all/patches/0003-3.7.3-cmake.patch @@ -0,0 +1,92 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 44ca23d..40439ca 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -12,7 +12,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +@@ -449,7 +449,7 @@ IF(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ LIST(APPEND ADDITIONAL_LIBS ZLIB::ZLIB) + IF(WIN32 AND NOT CYGWIN) + # + # Test if ZLIB_WINAPI macro is needed to use. +@@ -518,7 +518,7 @@ IF(LIBLZMA_FOUND) + SET(HAVE_LIBLZMA 1) + SET(HAVE_LZMA_H 1) + CMAKE_PUSH_CHECK_STATE() +- SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) ++ SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) +@@ -539,7 +539,7 @@ ELSE(LIBLZMA_FOUND) + # LZMA not found and will not be used. + SET(HAVE_LZMA_STREAM_ENCODER_MT 0) + ENDIF(LIBLZMA_FOUND) +-MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIRS) + MARK_AS_ADVANCED(CLEAR LIBLZMA_LIBRARY) + + # +@@ -610,7 +610,7 @@ IF(ENABLE_LZ4) + ENDIF (LZ4_INCLUDE_DIR) + + FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +- FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) ++ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) + ELSE(ENABLE_LZ4) +@@ -834,7 +834,7 @@ ENDIF(ENABLE_NETTLE) + # Find OpenSSL + # (Except on Mac, where OpenSSL is deprecated.) + # +-IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") ++IF(ENABLE_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index b79091c..bd9e980 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -251,6 +251,7 @@ IF(BUILD_SHARED_LIBS) + ENDIF(BUILD_SHARED_LIBS) + + # archive_static is a static library ++if(NOT BUILD_SHARED_LIBS) + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_INCLUDE_DIRECTORIES(archive_static PUBLIC .) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) +@@ -260,7 +261,7 @@ SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS + IF(NOT WIN32 OR CYGWIN OR NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN OR NOT BUILD_SHARED_LIBS) +- ++endif() + IF(ENABLE_INSTALL) + # How to install the libraries + IF(BUILD_SHARED_LIBS) +@@ -269,10 +270,12 @@ IF(ENABLE_INSTALL) + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + ENDIF(BUILD_SHARED_LIBS) ++ if(NOT BUILD_SHARED_LIBS) + INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ endif() + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/thirdparty/libarchive/all/patches/0003-3.7.4-cmake.patch b/thirdparty/libarchive/all/patches/0003-3.7.4-cmake.patch new file mode 100644 index 0000000000..1cd38344e5 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0003-3.7.4-cmake.patch @@ -0,0 +1,83 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7e87e07..2c9a5f8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -12,7 +12,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +@@ -451,7 +451,7 @@ IF(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ LIST(APPEND ADDITIONAL_LIBS ZLIB::ZLIB) + IF(WIN32 AND NOT CYGWIN) + # + # Test if ZLIB_WINAPI macro is needed to use. +@@ -541,7 +541,7 @@ ELSE(LIBLZMA_FOUND) + # LZMA not found and will not be used. + SET(HAVE_LZMA_STREAM_ENCODER_MT 0) + ENDIF(LIBLZMA_FOUND) +-MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIRS) + MARK_AS_ADVANCED(CLEAR LIBLZMA_LIBRARY) + + # +@@ -612,7 +612,7 @@ IF(ENABLE_LZ4) + ENDIF (LZ4_INCLUDE_DIR) + + FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +- FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) ++ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) + ELSE(ENABLE_LZ4) +@@ -836,7 +836,7 @@ ENDIF(ENABLE_NETTLE) + # Find OpenSSL + # (Except on Mac, where OpenSSL is deprecated.) + # +-IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") ++IF(ENABLE_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index b79091c..bd9e980 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -251,6 +251,7 @@ IF(BUILD_SHARED_LIBS) + ENDIF(BUILD_SHARED_LIBS) + + # archive_static is a static library ++if(NOT BUILD_SHARED_LIBS) + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_INCLUDE_DIRECTORIES(archive_static PUBLIC .) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) +@@ -260,7 +261,7 @@ SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS + IF(NOT WIN32 OR CYGWIN OR NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN OR NOT BUILD_SHARED_LIBS) +- ++endif() + IF(ENABLE_INSTALL) + # How to install the libraries + IF(BUILD_SHARED_LIBS) +@@ -269,10 +270,12 @@ IF(ENABLE_INSTALL) + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + ENDIF(BUILD_SHARED_LIBS) ++ if(NOT BUILD_SHARED_LIBS) + INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ endif() + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/thirdparty/libarchive/all/patches/0005-3.4.2-try-compile-cmakedeps.patch b/thirdparty/libarchive/all/patches/0005-3.4.2-try-compile-cmakedeps.patch new file mode 100644 index 0000000000..a6c90a0205 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0005-3.4.2-try-compile-cmakedeps.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2c9a5f8..91d0f49 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -869,8 +869,10 @@ ENDIF(NOT OPENSSL_FOUND) + # required libraries. + # + MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) ++ include(CMakePushCheckState) + FOREACH(ALGORITHM ${ALGORITHMS}) + IF(NOT ARCHIVE_CRYPTO_${ALGORITHM}) ++ cmake_push_check_state() + STRING(TOLOWER "${ALGORITHM}" lower_algorithm) + STRING(TOUPPER "${ALGORITHM}" algorithm) + IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND NOT OPENSSL_FOUND) +@@ -903,8 +905,7 @@ MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) + SET(TRY_CRYPTO_REQUIRED_LIBS + "-DLINK_LIBRARIES:STRING=${NETTLE_LIBRARY}") + ELSEIF("${IMPLEMENTATION}" MATCHES "^LIBMD$" AND LIBMD_FOUND) +- SET(TRY_CRYPTO_REQUIRED_LIBS +- "-DLINK_LIBRARIES:STRING=${LIBMD_LIBRARY}") ++ SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + ENDIF("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) + + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in diff --git a/thirdparty/libarchive/all/patches/0005-3.7.1-try-compile-cmakedeps.patch b/thirdparty/libarchive/all/patches/0005-3.7.1-try-compile-cmakedeps.patch new file mode 100644 index 0000000000..c71291d029 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0005-3.7.1-try-compile-cmakedeps.patch @@ -0,0 +1,32 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6849ce40..e7c9fbee 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -854,14 +854,14 @@ IF(NOT OPENSSL_FOUND) + ENDIF(LIBMD_FOUND) + ENDIF(NOT OPENSSL_FOUND) + +-# + # How to prove that CRYPTO functions, which have several names on various + # platforms, just see if archive_digest.c can compile and link against + # required libraries. +-# + MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) ++ include(CMakePushCheckState) + FOREACH(ALGORITHM ${ALGORITHMS}) + IF(NOT ARCHIVE_CRYPTO_${ALGORITHM}) ++ cmake_push_check_state() + STRING(TOLOWER "${ALGORITHM}" lower_algorithm) + STRING(TOUPPER "${ALGORITHM}" algorithm) + IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND NOT OPENSSL_FOUND) +@@ -881,8 +881,8 @@ MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) + IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) + SET(TRY_CRYPTO_REQUIRED_INCLUDES + "${TRY_CRYPTO_REQUIRED_INCLUDES};${OPENSSL_INCLUDE_DIR}") +- SET(TRY_CRYPTO_REQUIRED_LIBS +- "-DLINK_LIBRARIES:STRING=${OPENSSL_LIBRARIES}") ++ SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) ++ + ELSEIF("${IMPLEMENTATION}" MATCHES "^MBEDTLS$" AND MBEDTLS_FOUND) + SET(TRY_CRYPTO_REQUIRED_INCLUDES + "${TRY_CRYPTO_REQUIRED_INCLUDES};${MBEDTLS_INCLUDE_DIRS}") diff --git a/thirdparty/libarchive/all/patches/0005-3.7.3-try-compile-cmakedeps.patch b/thirdparty/libarchive/all/patches/0005-3.7.3-try-compile-cmakedeps.patch new file mode 100644 index 0000000000..a55e8c8709 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0005-3.7.3-try-compile-cmakedeps.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 40439ca..6845238 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -867,8 +867,10 @@ ENDIF(NOT OPENSSL_FOUND) + # required libraries. + # + MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) ++ include(CMakePushCheckState) + FOREACH(ALGORITHM ${ALGORITHMS}) + IF(NOT ARCHIVE_CRYPTO_${ALGORITHM}) ++ cmake_push_check_state() + STRING(TOLOWER "${ALGORITHM}" lower_algorithm) + STRING(TOUPPER "${ALGORITHM}" algorithm) + IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND NOT OPENSSL_FOUND) +@@ -901,8 +903,7 @@ MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) + SET(TRY_CRYPTO_REQUIRED_LIBS + "-DLINK_LIBRARIES:STRING=${NETTLE_LIBRARY}") + ELSEIF("${IMPLEMENTATION}" MATCHES "^LIBMD$" AND LIBMD_FOUND) +- SET(TRY_CRYPTO_REQUIRED_LIBS +- "-DLINK_LIBRARIES:STRING=${LIBMD_LIBRARY}") ++ SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + ENDIF("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) + + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in diff --git a/thirdparty/libarchive/all/patches/0005-3.7.4-try-compile-cmakedeps.patch b/thirdparty/libarchive/all/patches/0005-3.7.4-try-compile-cmakedeps.patch new file mode 100644 index 0000000000..a6c90a0205 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0005-3.7.4-try-compile-cmakedeps.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2c9a5f8..91d0f49 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -869,8 +869,10 @@ ENDIF(NOT OPENSSL_FOUND) + # required libraries. + # + MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) ++ include(CMakePushCheckState) + FOREACH(ALGORITHM ${ALGORITHMS}) + IF(NOT ARCHIVE_CRYPTO_${ALGORITHM}) ++ cmake_push_check_state() + STRING(TOLOWER "${ALGORITHM}" lower_algorithm) + STRING(TOUPPER "${ALGORITHM}" algorithm) + IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND NOT OPENSSL_FOUND) +@@ -903,8 +905,7 @@ MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION) + SET(TRY_CRYPTO_REQUIRED_LIBS + "-DLINK_LIBRARIES:STRING=${NETTLE_LIBRARY}") + ELSEIF("${IMPLEMENTATION}" MATCHES "^LIBMD$" AND LIBMD_FOUND) +- SET(TRY_CRYPTO_REQUIRED_LIBS +- "-DLINK_LIBRARIES:STRING=${LIBMD_LIBRARY}") ++ SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + ENDIF("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) + + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in diff --git a/thirdparty/libarchive/all/patches/0006-3.7.1-fix-msvc-build.patch b/thirdparty/libarchive/all/patches/0006-3.7.1-fix-msvc-build.patch new file mode 100644 index 0000000000..04ec53a2e2 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0006-3.7.1-fix-msvc-build.patch @@ -0,0 +1,45 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6849ce40..d5dac48b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1401,7 +1401,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(localtime_r HAVE_LOCALTIME_R) + CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT) + CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(mbrtowc HAVE_MBRTOWC) +-CHECK_FUNCTION_EXISTS_GLIBC(memmove HAVE_MEMMOVE) ++SET(HAVE_MEMMOVE 1) + CHECK_FUNCTION_EXISTS_GLIBC(mkdir HAVE_MKDIR) + CHECK_FUNCTION_EXISTS_GLIBC(mkfifo HAVE_MKFIFO) + CHECK_FUNCTION_EXISTS_GLIBC(mknod HAVE_MKNOD) +@@ -1434,11 +1434,11 @@ CHECK_FUNCTION_EXISTS_GLIBC(utime HAVE_UTIME) + CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT) + CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK) +-CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) +-CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) +-CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) ++SET(HAVE_WCRTOMB 1) ++SET(HAVE_WCSCMP 1) ++SET(HAVE_WCSCPY 1) ++SET(HAVE_WCSLEN 1) ++SET(HAVE_WCTOMB 1) + CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64) + CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE) + CHECK_SYMBOL_EXISTS(ctime_s "time.h" HAVE_CTIME_S) +@@ -1451,10 +1451,10 @@ CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH) + CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) + CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) + CHECK_FUNCTION_EXISTS(strftime HAVE_STRFTIME) +-CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF) +-CHECK_FUNCTION_EXISTS(wmemcmp HAVE_WMEMCMP) +-CHECK_FUNCTION_EXISTS(wmemcpy HAVE_WMEMCPY) +-CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE) ++SET(HAVE_VPRINTF 1) ++SET(HAVE_WMEMCMP 1) ++SET(HAVE_WMEMCPY 1) ++SET(HAVE_WMEMMOVE 1) + + CMAKE_POP_CHECK_STATE() # Restore the state of the variables + diff --git a/thirdparty/libarchive/all/patches/0006-3.7.3-fix-msvc-build.patch b/thirdparty/libarchive/all/patches/0006-3.7.3-fix-msvc-build.patch new file mode 100644 index 0000000000..d25d36378b --- /dev/null +++ b/thirdparty/libarchive/all/patches/0006-3.7.3-fix-msvc-build.patch @@ -0,0 +1,45 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6845238..489936a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1471,7 +1471,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(localtime_r HAVE_LOCALTIME_R) + CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT) + CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(mbrtowc HAVE_MBRTOWC) +-CHECK_FUNCTION_EXISTS_GLIBC(memmove HAVE_MEMMOVE) ++SET(HAVE_MEMMOVE 1) + CHECK_FUNCTION_EXISTS_GLIBC(mkdir HAVE_MKDIR) + CHECK_FUNCTION_EXISTS_GLIBC(mkfifo HAVE_MKFIFO) + CHECK_FUNCTION_EXISTS_GLIBC(mknod HAVE_MKNOD) +@@ -1504,11 +1504,11 @@ CHECK_FUNCTION_EXISTS_GLIBC(utime HAVE_UTIME) + CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT) + CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK) +-CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) +-CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) +-CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) ++SET(HAVE_WCRTOMB 1) ++SET(HAVE_WCSCMP 1) ++SET(HAVE_WCSCPY 1) ++SET(HAVE_WCSLEN 1) ++SET(HAVE_WCTOMB 1) + CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64) + CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE) + CHECK_SYMBOL_EXISTS(ctime_s "time.h" HAVE_CTIME_S) +@@ -1521,10 +1521,10 @@ CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH) + CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) + CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) + CHECK_FUNCTION_EXISTS(strftime HAVE_STRFTIME) +-CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF) +-CHECK_FUNCTION_EXISTS(wmemcmp HAVE_WMEMCMP) +-CHECK_FUNCTION_EXISTS(wmemcpy HAVE_WMEMCPY) +-CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE) ++SET(HAVE_VPRINTF 1) ++SET(HAVE_WMEMCMP 1) ++SET(HAVE_WMEMCPY 1) ++SET(HAVE_WMEMMOVE 1) + + CMAKE_POP_CHECK_STATE() # Restore the state of the variables + diff --git a/thirdparty/libarchive/all/patches/0006-3.7.4-fix-msvc-build.patch b/thirdparty/libarchive/all/patches/0006-3.7.4-fix-msvc-build.patch new file mode 100644 index 0000000000..754faa44c1 --- /dev/null +++ b/thirdparty/libarchive/all/patches/0006-3.7.4-fix-msvc-build.patch @@ -0,0 +1,45 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 91d0f49..4041b9b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1473,7 +1473,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(localtime_r HAVE_LOCALTIME_R) + CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT) + CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(mbrtowc HAVE_MBRTOWC) +-CHECK_FUNCTION_EXISTS_GLIBC(memmove HAVE_MEMMOVE) ++SET(HAVE_MEMMOVE 1) + CHECK_FUNCTION_EXISTS_GLIBC(mkdir HAVE_MKDIR) + CHECK_FUNCTION_EXISTS_GLIBC(mkfifo HAVE_MKFIFO) + CHECK_FUNCTION_EXISTS_GLIBC(mknod HAVE_MKNOD) +@@ -1507,11 +1507,11 @@ CHECK_FUNCTION_EXISTS_GLIBC(utime HAVE_UTIME) + CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES) + CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT) + CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK) +-CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP) +-CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) +-CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) +-CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) ++SET(HAVE_WCRTOMB 1) ++SET(HAVE_WCSCMP 1) ++SET(HAVE_WCSCPY 1) ++SET(HAVE_WCSLEN 1) ++SET(HAVE_WCTOMB 1) + CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64) + CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE) + CHECK_SYMBOL_EXISTS(ctime_s "time.h" HAVE_CTIME_S) +@@ -1524,10 +1524,10 @@ CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH) + CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) + CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) + CHECK_FUNCTION_EXISTS(strftime HAVE_STRFTIME) +-CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF) +-CHECK_FUNCTION_EXISTS(wmemcmp HAVE_WMEMCMP) +-CHECK_FUNCTION_EXISTS(wmemcpy HAVE_WMEMCPY) +-CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE) ++SET(HAVE_VPRINTF 1) ++SET(HAVE_WMEMCMP 1) ++SET(HAVE_WMEMCPY 1) ++SET(HAVE_WMEMMOVE 1) + + CMAKE_POP_CHECK_STATE() # Restore the state of the variables + diff --git a/thirdparty/libarchive/all/patches/0007-3.7.1-include-getopt.patch b/thirdparty/libarchive/all/patches/0007-3.7.1-include-getopt.patch new file mode 100644 index 0000000000..6db790a6cd --- /dev/null +++ b/thirdparty/libarchive/all/patches/0007-3.7.1-include-getopt.patch @@ -0,0 +1,13 @@ +--- unzip/bsdunzip.c 2023-07-29 19:27:43.000000000 +0200 ++++ unzip/bsdunzip.c 2023-10-28 13:19:27.181106700 +0200 +@@ -78,6 +78,10 @@ + #include + #endif + #endif ++#ifdef HAVE_GETOPT_OPTRESET ++#include ++#endif ++ + + #include + #include diff --git a/thirdparty/libarchive/all/patches/libarchive.patch b/thirdparty/libarchive/all/patches/libarchive.patch new file mode 100644 index 0000000000..457789fc83 --- /dev/null +++ b/thirdparty/libarchive/all/patches/libarchive.patch @@ -0,0 +1,116 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,7 +6,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -166,51 +166,6 @@ SET(libarchive_SOURCES + xxhash.c + ) + +-# Man pages +-SET(libarchive_MANS +- archive_entry.3 +- archive_entry_acl.3 +- archive_entry_linkify.3 +- archive_entry_misc.3 +- archive_entry_paths.3 +- archive_entry_perms.3 +- archive_entry_stat.3 +- archive_entry_time.3 +- archive_read.3 +- archive_read_add_passphrase.3 +- archive_read_data.3 +- archive_read_disk.3 +- archive_read_extract.3 +- archive_read_filter.3 +- archive_read_format.3 +- archive_read_free.3 +- archive_read_header.3 +- archive_read_new.3 +- archive_read_open.3 +- archive_read_set_options.3 +- archive_util.3 +- archive_write.3 +- archive_write_blocksize.3 +- archive_write_data.3 +- archive_write_disk.3 +- archive_write_filter.3 +- archive_write_finish_entry.3 +- archive_write_format.3 +- archive_write_free.3 +- archive_write_header.3 +- archive_write_new.3 +- archive_write_open.3 +- archive_write_set_options.3 +- archive_write_set_passphrase.3 +- cpio.5 +- libarchive.3 +- libarchive_changes.3 +- libarchive_internals.3 +- libarchive-formats.5 +- mtree.5 +- tar.5 +-) +- + IF(WIN32 AND NOT CYGWIN) + LIST(APPEND libarchive_SOURCES archive_entry_copy_bhfi.c) + LIST(APPEND libarchive_SOURCES archive_read_disk_windows.c) +@@ -235,12 +190,6 @@ ELSEIF(ARCHIVE_ACL_SUNOS) + LIST(APPEND libarchive_SOURCES archive_disk_acl_sunos.c) + ENDIF() + +-# Libarchive is a shared library +-ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS}) +-TARGET_INCLUDE_DIRECTORIES(archive PUBLIC .) +-TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS}) +-SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION}) +- + # archive_static is a static library + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) +@@ -253,12 +202,9 @@ ENDIF(NOT WIN32 OR CYGWIN) + + IF(ENABLE_INSTALL) + # How to install the libraries +- INSTALL(TARGETS archive archive_static ++ INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +- INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() +- +-add_subdirectory(test) +diff --git a/libarchive/archive_read_support_format_rar5.c b/libarchive/archive_read_support_format_rar5.c +--- a/libarchive/archive_read_support_format_rar5.c ++++ b/libarchive/archive_read_support_format_rar5.c +@@ -3084,12 +3084,17 @@ static int do_uncompress_block(struct ar + + continue; + } +- ++#ifndef _MSC_VER ++/* ++ * This is unreachable code (seemingly by design), and compilation on MSVC fails because of that, ++ * so we remove it when compiling with MSVC. ++ */ + /* The program counter shouldn't reach here. */ + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Unsupported block code: 0x%x", num); + + return ARCHIVE_FATAL; ++#endif + } + + return ARCHIVE_OK; diff --git a/thirdparty/libarchive/all/test_package/CMakeLists.txt b/thirdparty/libarchive/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..925a2be085 --- /dev/null +++ b/thirdparty/libarchive/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(LibArchive REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE LibArchive::LibArchive) diff --git a/thirdparty/libarchive/all/test_package/conanfile.py b/thirdparty/libarchive/all/test_package/conanfile.py new file mode 100644 index 0000000000..a9fb96656f --- /dev/null +++ b/thirdparty/libarchive/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/libarchive/all/test_package/test_package.c b/thirdparty/libarchive/all/test_package/test_package.c new file mode 100644 index 0000000000..42ef77c45f --- /dev/null +++ b/thirdparty/libarchive/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char *argv[]) { + printf("libarchive version: %s\n", archive_version_string()); + printf("libarchive details: %s\n", archive_version_details()); + return 0; +} diff --git a/thirdparty/libarchive/all/test_v1_package/CMakeLists.txt b/thirdparty/libarchive/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..925ecbe19e --- /dev/null +++ b/thirdparty/libarchive/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/thirdparty/libarchive/all/test_v1_package/conanfile.py b/thirdparty/libarchive/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..19e6a0c06e --- /dev/null +++ b/thirdparty/libarchive/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/libarchive/config.yml b/thirdparty/libarchive/config.yml new file mode 100644 index 0000000000..c060674e19 --- /dev/null +++ b/thirdparty/libarchive/config.yml @@ -0,0 +1,12 @@ +versions: + "3.7.4": + folder: all + "3.7.3": + folder: all + "3.7.2": + folder: all + "3.7.1": + folder: all + "3.4.2": + folder: all + \ No newline at end of file diff --git a/thirdparty/libcoap/all/conandata.yml b/thirdparty/libcoap/all/conandata.yml new file mode 100644 index 0000000000..540d0223b7 --- /dev/null +++ b/thirdparty/libcoap/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "4.3.3": + url: "https://github.com/obgm/libcoap/archive/v4.3.3.tar.gz" + sha256: "3df6e1a51e42ef8fd45f16276505a47ed32aef150d348d60f251a0b470dda379" + "4.2.1": + url: "https://github.com/obgm/libcoap/archive/v4.2.1.tar.gz" + sha256: "29a0394a265d3febee41e5e2dc03d34292a0aede37f5f80334e529ac0dab2321" +patches: + "4.2.1": + - patch_file: "patches/libcoap-windows-cmake.patch" + patch_description: "Creates a CMakeLists.txt for building MiNiFi C++ Dependency on Windows" + patch_type: "portability" + patch_source: "https://github.com/apache/nifi-minifi-cpp/commit/6b99991ba7ffb3dae471fda1f2e9649ff33ca14e" diff --git a/thirdparty/libcoap/all/conanfile.py b/thirdparty/libcoap/all/conanfile.py new file mode 100644 index 0000000000..c88b29ec8d --- /dev/null +++ b/thirdparty/libcoap/all/conanfile.py @@ -0,0 +1,161 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, chdir, export_conandata_patches, get, rm, rmdir, save +from conan.tools.scm import Version +import os +import textwrap + +required_conan_version = ">=1.53.0" + +# TODO (JG): Add support for creating LibCoap 4.2.1 conan package for windows using minifi's libcoap-windows-cmake.patch +class LibCoapConan(ConanFile): + name = "libcoap" + description = "A CoAP (RFC 7252) implementation in C" + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/obgm/libcoap" + topics = "coap" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_epoll": [True, False], + "dtls_backend": [None, "openssl", "gnutls", "tinydtls", "mbedtls"], + } + default_options = { + "shared": False, + "fPIC": True, + "with_epoll": False, + "dtls_backend": "openssl", + } + + # def export_sources(self): + # if self.settings.os == "Windows": + # export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.options.dtls_backend == "openssl": + # self.requires("openssl/[>=1.1 <4]") + self.requires("openssl/3.3.0@minifi/dev") + elif self.options.dtls_backend == "mbedtls": + # self.requires("mbedtls/3.2.1") + self.requires("mbedtls/2.16.3@minifi/dev") + + def validate(self): + if self.settings.os == "Windows" or is_apple_os(self): + raise ConanInvalidConfiguration("Platform is currently not supported") + + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.options.dtls_backend in ["gnutls", "tinydtls"]: + raise ConanInvalidConfiguration(f"{self.options.dtls_backend} not available yet") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + if self.settings.os == "Linux": + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.append("--with-pic") + tc.configure_args.append("--disable-examples") + tc.configure_args.append("--disable-dtls") + tc.configure_args.append("--disable-tests") + tc.configure_args.append("--disable-documentation") + tc.generate() + + def build(self): + # if self.settings.os == "Windows": + # apply_conandata_patches(self) + with chdir(self, self.source_folder): + self.run("./autogen.sh") + + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path), + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent(f"""\ + set(COAP_FOUND TRUE) + if(DEFINED libcoap_INCLUDE_DIRS) + set(COAP_INCLUDE_DIRS ${{libcoap_INCLUDE_DIRS}}) + endif() + if(DEFINED libcoap_LIBRARIES) + set(COAP_LIBRARIES ${{libcoap_LIBRARIES}}) + endif() + set(COAP_VERSION_MAJOR {Version(self.version).major}) + set(COAP_VERSION_MINOR {Version(self.version).minor}) + set(COAP_VERSION_PATCH {Version(self.version).patch}) + set(COAP_VERSION_STRING "{self.version}") + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + def package_info(self): + library_name = "coap-2" + pkgconfig_filename = "libcoap-2" + cmake_target_name = "libcoap" + + if self.options.dtls_backend: + pkgconfig_filename += f"-{self.options.dtls_backend}" + + self.cpp_info.set_property("cmake_file_name", "libcoap") + self.cpp_info.set_property("cmake_target_name", f"COAP::{cmake_target_name}") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + + self.cpp_info.set_property("pkg_config_name", pkgconfig_filename) + + # TODO: back to global scope once legacy generators support removed + self.cpp_info.components["coap"].libs = [library_name] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["coap"].system_libs = ["pthread"] + if self.options.dtls_backend == "openssl": + self.cpp_info.components["coap"].requires = ["openssl::openssl"] + elif self.options.dtls_backend == "mbedtls": + self.cpp_info.components["coap"].requires = ["mbedtls::mbedtls"] + + # TODO: to remove once legacy generators support removed + self.cpp_info.components["coap"].names["cmake_find_package"] = cmake_target_name + self.cpp_info.components["coap"].names["cmake_find_package_multi"] = cmake_target_name + self.cpp_info.components["coap"].set_property("cmake_target_name", f"COAP::{cmake_target_name}") + self.cpp_info.components["coap"].set_property("pkg_config_name", pkgconfig_filename) + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] diff --git a/thirdparty/libcoap/libcoap-windows-cmake.patch b/thirdparty/libcoap/all/patches/libcoap-windows-cmake.patch similarity index 88% rename from thirdparty/libcoap/libcoap-windows-cmake.patch rename to thirdparty/libcoap/all/patches/libcoap-windows-cmake.patch index 9150cd0eeb..be1f221efe 100644 --- a/thirdparty/libcoap/libcoap-windows-cmake.patch +++ b/thirdparty/libcoap/all/patches/libcoap-windows-cmake.patch @@ -1,6 +1,6 @@ -diff -rupN orig/CMakeLists.txt patched/CMakeLists.txt ---- orig/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 -+++ patched/CMakeLists.txt 2019-11-21 17:42:30.000000000 +0100 +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt @@ -0,0 +1,77 @@ +cmake_minimum_required(VERSION 3.10) + @@ -79,9 +79,9 @@ diff -rupN orig/CMakeLists.txt patched/CMakeLists.txt +) + +install(FILES ${PUBLIC_HEADERS} DESTINATION include/coap2) -diff -rupN orig/coap_config.h.windows patched/coap_config.h.windows ---- orig/coap_config.h.windows 2019-11-21 17:42:00.000000000 +0100 -+++ patched/coap_config.h.windows 2019-11-22 09:11:43.000000000 +0100 +diff --git a/coap_config.h.windows b/coap_config.h.windows +--- a/coap_config.h.windows ++++ b/coap_config.h.windows @@ -67,7 +67,7 @@ #define snprintf _snprintf #endif diff --git a/thirdparty/libcoap/all/test_package/CMakeLists.txt b/thirdparty/libcoap/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..e6fd2149ef --- /dev/null +++ b/thirdparty/libcoap/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(libcoap REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) + +target_link_libraries(${PROJECT_NAME} COAP::libcoap) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/thirdparty/libcoap/all/test_package/CMakeUserPresets.json b/thirdparty/libcoap/all/test_package/CMakeUserPresets.json new file mode 100644 index 0000000000..89a3169902 --- /dev/null +++ b/thirdparty/libcoap/all/test_package/CMakeUserPresets.json @@ -0,0 +1,9 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/libcoap/all/test_package/build/gcc-11-x86_64-gnu20-release/generators/CMakePresets.json" + ] +} \ No newline at end of file diff --git a/thirdparty/libcoap/all/test_package/conanfile.py b/thirdparty/libcoap/all/test_package/conanfile.py new file mode 100644 index 0000000000..a804618d0f --- /dev/null +++ b/thirdparty/libcoap/all/test_package/conanfile.py @@ -0,0 +1,30 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/libcoap/all/test_package/test_package.cpp b/thirdparty/libcoap/all/test_package/test_package.cpp new file mode 100644 index 0000000000..b089d84453 --- /dev/null +++ b/thirdparty/libcoap/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include "coap2/coap.h" + +#include + +int main() { + std::cout << "starting" << std::endl; + coap_startup(); + + // create CoAP context and a client session + coap_context_t *ctx = coap_new_context(nullptr); + + coap_free_context(ctx); + coap_cleanup(); + std::cout << "stopping" << std::endl; + return 0; +} diff --git a/thirdparty/libcoap/config.yml b/thirdparty/libcoap/config.yml new file mode 100644 index 0000000000..3b95f4168c --- /dev/null +++ b/thirdparty/libcoap/config.yml @@ -0,0 +1,5 @@ +versions: + "4.3.3": + folder: all + "4.2.1": + folder: all diff --git a/thirdparty/liblzma/xz_utils/all/conandata.yml b/thirdparty/liblzma/xz_utils/all/conandata.yml new file mode 100644 index 0000000000..c1753d2157 --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/conandata.yml @@ -0,0 +1,45 @@ +sources: + "5.4.5": + url: + - "https://tukaani.org/xz/xz-5.4.5.tar.xz" + - "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/da9dec6c12cf2ecf269c31ab65b5de18e8e52b96f35d5bcd08c12b43e6878803" + sha256: "da9dec6c12cf2ecf269c31ab65b5de18e8e52b96f35d5bcd08c12b43e6878803" + "5.4.4": + url: + - "https://tukaani.org/xz/xz-5.4.4.tar.gz" + - "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/aae39544e254cfd27e942d35a048d592959bd7a79f9a624afb0498bb5613bdf8" + sha256: "aae39544e254cfd27e942d35a048d592959bd7a79f9a624afb0498bb5613bdf8" + "5.4.2": + url: + - "https://tukaani.org/xz/xz-5.4.2.tar.gz" + - "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/87947679abcf77cc509d8d1b474218fd16b72281e2797360e909deaee1ac9d05" + sha256: "87947679abcf77cc509d8d1b474218fd16b72281e2797360e909deaee1ac9d05" + "5.4.0": + url: + - "https://tukaani.org/xz/xz-5.4.0.tar.gz" + - "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/7471ef5991f690268a8f2be019acec2e0564b7b233ca40035f339fe9a07f830b" + sha256: "7471ef5991f690268a8f2be019acec2e0564b7b233ca40035f339fe9a07f830b" + "5.2.10": + url: + - "https://tukaani.org/xz/xz-5.2.10.tar.gz" + - "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/eb7a3b2623c9d0135da70ca12808a214be9c019132baaa61c9e1d198d1d9ded3" + sha256: "eb7a3b2623c9d0135da70ca12808a214be9c019132baaa61c9e1d198d1d9ded3" + "5.2.5": + url: + - "https://tukaani.org/xz/xz-5.2.5.tar.gz" + - "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10" + sha256: "f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10" + "5.2.4": + url: + - "https://tukaani.org/xz/xz-5.2.4.tar.gz" + - "https://c3i.jfrog.io/artifactory/conan-center-backup-sources/b512f3b726d3b37b6dc4c8570e137b9311e7552e8ccbab4d39d47ce5f4177145" + sha256: "b512f3b726d3b37b6dc4c8570e137b9311e7552e8ccbab4d39d47ce5f4177145" +patches: + "5.2.5": + - patch_file: "patches/liblzma.patch" + patch_description: "Create a Windows-specific CMakeLists.txt for the project to integrate with MiNiFi CMake build system" + patch_type: "portability" + "5.2.4": + - patch_file: "patches/0001-relax_windows-sdk-restriction.patch" + patch_description: "Relax Windows SDK restriction" + patch_type: "conan" diff --git a/thirdparty/liblzma/xz_utils/all/conanfile.py b/thirdparty/liblzma/xz_utils/all/conanfile.py new file mode 100644 index 0000000000..478d52e7a1 --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/conanfile.py @@ -0,0 +1,212 @@ +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file, rm, rmdir, save +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, MSBuild, MSBuildToolchain +from conan.tools.scm import Version +import os +import textwrap + +required_conan_version = ">=1.54.0" + + +class XZUtilsConan(ConanFile): + name = "xz_utils" + description = ( + "XZ Utils is free general-purpose data compression software with a high " + "compression ratio. XZ Utils were written for POSIX-like systems, but also " + "work on some not-so-POSIX systems. XZ Utils are the successor to LZMA Utils." + ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://tukaani.org/xz" + topics = ("lzma", "xz", "compression") + license = "Unlicense", "LGPL-2.1-or-later", "GPL-2.0-or-later", "GPL-3.0-or-later" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "portable": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "portable": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _effective_msbuild_type(self): + # treat "RelWithDebInfo" and "MinSizeRel" as "Release" + # there is no DebugMT configuration in upstream vcxproj, we patch Debug configuration afterwards + return "{}{}".format( + "Debug" if self.settings.build_type == "Debug" else "Release", + "MT" if is_msvc_static_runtime(self) and self.settings.build_type != "Debug" else "", + ) + + @property + def _msbuild_target(self): + return "liblzma_dll" if self.options.shared else "liblzma" + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not is_msvc(self): + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + if is_msvc(self): + tc = MSBuildToolchain(self) + tc.configuration = self._effective_msbuild_type + tc.generate() + else: + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-doc") + tc.configure_args.append("--disable-xz") + tc.configure_args.append("--disable-xzdec") + tc.configure_args.append("--disable-lzmadec") + tc.configure_args.append("--disable-lzmainfo") + tc.configure_args.append("--disable-lzma-links") + tc.configure_args.append("--disable-scripts") + tc.configure_args.append("--enable-shared=no") + if self.options.portable: + tc.configure_args.append("--disable-assembler") + if self.settings.build_type == "Debug": + tc.configure_args.append("--enable-debug") + tc.generate() + + @property + def _msvc_sln_folder(self): + if (str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler) >= "15") or \ + (str(self.settings.compiler) == "msvc" and Version(self.settings.compiler) >= "191"): + return "vs2017" + return "vs2013" + + def _build_msvc(self): + build_script_folder = os.path.join(self.source_folder, "windows", self._msvc_sln_folder) + + #============================== + # TODO: to remove once https://github.com/conan-io/conan/pull/12817 available in conan client. + vcxproj_files = [ + os.path.join(build_script_folder, "liblzma.vcxproj"), + os.path.join(build_script_folder, "liblzma_dll.vcxproj"), + ] + if (str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler) >= "15") or \ + (str(self.settings.compiler) == "msvc" and Version(self.settings.compiler) >= "191"): + old_toolset = "v141" + else: + old_toolset = "v120" + new_toolset = MSBuildToolchain(self).toolset + conantoolchain_props = os.path.join(self.generators_folder, MSBuildToolchain.filename) + for vcxproj_file in vcxproj_files: + replace_in_file( + self, vcxproj_file, + f"{old_toolset}", + f"{new_toolset}", + ) + replace_in_file( + self, vcxproj_file, + "", + f"", + ) + #============================== + + msbuild = MSBuild(self) + msbuild.build_type = self._effective_msbuild_type + msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform + msbuild.build(os.path.join(build_script_folder, "xz_win.sln"), targets=[self._msbuild_target]) + + def build(self): + apply_conandata_patches(self) + if is_msvc(self): + self._build_msvc() + else: + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if is_msvc(self): + inc_dir = os.path.join(self.source_folder, "src", "liblzma", "api") + copy(self, "*.h", src=inc_dir, dst=os.path.join(self.package_folder, "include")) + output_dir = os.path.join(self.source_folder, "windows") + copy(self, "*.lib", src=output_dir, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.dll", src=output_dir, dst=os.path.join(self.package_folder, "bin"), keep_path=False) + rename(self, os.path.join(self.package_folder, "lib", "liblzma.lib"), + os.path.join(self.package_folder, "lib", "lzma.lib")) + else: + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) + + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path), + ) + + def _create_cmake_module_variables(self, module_file): + # TODO: also add LIBLZMA_HAS_AUTO_DECODER, LIBLZMA_HAS_EASY_ENCODER & LIBLZMA_HAS_LZMA_PRESET + content = textwrap.dedent(f"""\ + set(LIBLZMA_FOUND TRUE) + if(DEFINED LibLZMA_INCLUDE_DIRS) + set(LIBLZMA_INCLUDE_DIRS ${{LibLZMA_INCLUDE_DIRS}}) + endif() + if(DEFINED LibLZMA_LIBRARIES) + set(LIBLZMA_LIBRARIES ${{LibLZMA_LIBRARIES}}) + endif() + set(LIBLZMA_VERSION_MAJOR {Version(self.version).major}) + set(LIBLZMA_VERSION_MINOR {Version(self.version).minor}) + set(LIBLZMA_VERSION_PATCH {Version(self.version).patch}) + set(LIBLZMA_VERSION_STRING "{self.version}") + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "LibLZMA") + self.cpp_info.set_property("cmake_target_name", "LibLZMA::LibLZMA") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.set_property("pkg_config_name", "liblzma") + self.cpp_info.libs = ["lzma"] + if not self.options.shared: + self.cpp_info.defines.append("LZMA_API_STATIC") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "LibLZMA" + self.cpp_info.names["cmake_find_package_multi"] = "LibLZMA" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] diff --git a/thirdparty/liblzma/xz_utils/all/patches/0001-relax_windows-sdk-restriction.patch b/thirdparty/liblzma/xz_utils/all/patches/0001-relax_windows-sdk-restriction.patch new file mode 100644 index 0000000000..d9680984de --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/patches/0001-relax_windows-sdk-restriction.patch @@ -0,0 +1,20 @@ +--- a/windows/vs2017/liblzma.vcxproj ++++ b/windows/vs2017/liblzma.vcxproj +@@ -29,7 +29,6 @@ + + {12728250-16EC-4DC6-94D7-E21DD88947F8} + Win32Proj +- 10.0.15063.0 + + + +--- a/windows/vs2017/liblzma_dll.vcxproj ++++ b/windows/vs2017/liblzma_dll.vcxproj +@@ -29,7 +29,6 @@ + + {E0F247DB-EF12-4755-8DF9-F74BCD1348F7} + Win32Proj +- 10.0.15063.0 + + + diff --git a/thirdparty/liblzma/liblzma.patch b/thirdparty/liblzma/xz_utils/all/patches/liblzma.patch similarity index 100% rename from thirdparty/liblzma/liblzma.patch rename to thirdparty/liblzma/xz_utils/all/patches/liblzma.patch diff --git a/thirdparty/liblzma/xz_utils/all/test_package/CMakeLists.txt b/thirdparty/liblzma/xz_utils/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..cd4e960a3f --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/test_package/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(LibLZMA REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE LibLZMA::LibLZMA) + +# Test whether variables from https://cmake.org/cmake/help/latest/module/FindLibLZMA.html +# are properly defined in conan generators +set(_custom_vars + LIBLZMA_FOUND + LIBLZMA_INCLUDE_DIRS + LIBLZMA_LIBRARIES + LIBLZMA_VERSION_MAJOR + LIBLZMA_VERSION_MINOR + LIBLZMA_VERSION_PATCH + LIBLZMA_VERSION_STRING +) +foreach(_custom_var ${_custom_vars}) + if(DEFINED ${_custom_var}) + message(STATUS "${_custom_var}: ${${_custom_var}}") + else() + message(FATAL_ERROR "${_custom_var} not defined") + endif() +endforeach() diff --git a/thirdparty/liblzma/xz_utils/all/test_package/CMakeUserPresets.json b/thirdparty/liblzma/xz_utils/all/test_package/CMakeUserPresets.json new file mode 100644 index 0000000000..b028da2957 --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/test_package/CMakeUserPresets.json @@ -0,0 +1,9 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/liblzma/xz_utils/all/test_package/build/gcc-11-x86_64-gnu20-release/generators/CMakePresets.json" + ] +} \ No newline at end of file diff --git a/thirdparty/liblzma/xz_utils/all/test_package/conanfile.py b/thirdparty/liblzma/xz_utils/all/test_package/conanfile.py new file mode 100644 index 0000000000..0a6bc68712 --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/liblzma/xz_utils/all/test_package/test_package.c b/thirdparty/liblzma/xz_utils/all/test_package/test_package.c new file mode 100644 index 0000000000..a1f55ac414 --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include +#include +#include + +int main() { + printf("LZMA version %s\n", lzma_version_string()); + return EXIT_SUCCESS; +} diff --git a/thirdparty/liblzma/xz_utils/all/test_v1_package/CMakeLists.txt b/thirdparty/liblzma/xz_utils/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..0d20897301 --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/thirdparty/liblzma/xz_utils/all/test_v1_package/conanfile.py b/thirdparty/liblzma/xz_utils/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..19e6a0c06e --- /dev/null +++ b/thirdparty/liblzma/xz_utils/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/liblzma/xz_utils/config.yml b/thirdparty/liblzma/xz_utils/config.yml new file mode 100644 index 0000000000..d950dab72f --- /dev/null +++ b/thirdparty/liblzma/xz_utils/config.yml @@ -0,0 +1,15 @@ +versions: + "5.4.5": + folder: all + "5.4.4": + folder: all + "5.4.2": + folder: all + "5.4.0": + folder: all + "5.2.10": + folder: all + "5.2.5": + folder: all + "5.2.4": + folder: all diff --git a/thirdparty/librdkafka/all/conandata.yml b/thirdparty/librdkafka/all/conandata.yml new file mode 100644 index 0000000000..5b70b2f07d --- /dev/null +++ b/thirdparty/librdkafka/all/conandata.yml @@ -0,0 +1,52 @@ +sources: + "2.4.0": + url: "https://github.com/edenhill/librdkafka/archive/v2.4.0.tar.gz" + sha256: "d645e47d961db47f1ead29652606a502bdd2a880c85c1e060e94eea040f1a19a" + "2.3.0": + url: "https://github.com/edenhill/librdkafka/archive/v2.3.0.tar.gz" + sha256: "2d49c35c77eeb3d42fa61c43757fcbb6a206daa560247154e60642bcdcc14d12" + "2.2.0": + url: "https://github.com/edenhill/librdkafka/archive/v2.2.0.tar.gz" + sha256: "af9a820cbecbc64115629471df7c7cecd40403b6c34bfdbb9223152677a47226" + "2.0.2": + url: "https://github.com/edenhill/librdkafka/archive/v2.0.2.tar.gz" + sha256: "f321bcb1e015a34114c83cf1aa7b99ee260236aab096b85c003170c90a47ca9d" + "1.9.2": + url: "https://github.com/edenhill/librdkafka/archive/v1.9.2.tar.gz" + sha256: "3fba157a9f80a0889c982acdd44608be8a46142270a389008b22d921be1198ad" +patches: + "2.4.0": + - patch_file: patches/0001-Change-library-names-1-9-1.patch + patch_description: "find_package conan packages" + patch_type: "conan" + - patch_file: patches/0002-Change-library-targets-and-result-variables-2-3-0.patch + patch_description: "refer conan package names" + patch_type: "conan" + "2.3.0": + - patch_file: patches/0001-Change-library-names-1-9-1.patch + patch_description: "find_package conan packages" + patch_type: "conan" + - patch_file: patches/0002-Change-library-targets-and-result-variables-2-3-0.patch + patch_description: "refer conan package names" + patch_type: "conan" + "2.2.0": + - patch_file: patches/0001-Change-library-names-1-9-1.patch + patch_description: "find_package conan packages" + patch_type: "conan" + - patch_file: patches/0002-Change-library-targets-and-result-variables-2-0-2.patch + patch_description: "refer conan package names" + patch_type: "conan" + "2.0.2": + - patch_file: patches/0001-Change-library-names-1-9-1.patch + patch_description: "find_package conan packages" + patch_type: "conan" + - patch_file: patches/0002-Change-library-targets-and-result-variables-2-0-2.patch + patch_description: "refer conan package names" + patch_type: "conan" + "1.9.2": + - patch_file: patches/0001-Change-library-names-1-9-1.patch + patch_description: "find_package conan packages" + patch_type: "conan" + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-9-1.patch + patch_description: "refer conan package names" + patch_type: "conan" diff --git a/thirdparty/librdkafka/all/conanfile.py b/thirdparty/librdkafka/all/conanfile.py new file mode 100644 index 0000000000..31a4d85a04 --- /dev/null +++ b/thirdparty/librdkafka/all/conanfile.py @@ -0,0 +1,170 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, replace_in_file +from conan.tools.microsoft import is_msvc +from conan.tools.gnu import PkgConfigDeps +import os + +required_conan_version = ">=1.55.0" + + +class LibrdkafkaConan(ConanFile): + name = "librdkafka" + description = ( + "Librdkafka is an Apache Kafka C/C++ library designed with message " + "delivery reliability and high performance in mind." + ) + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/edenhill/librdkafka" + topics = ("kafka", "consumer", "producer") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "zlib": [True, False], + "zstd": [True, False], + "plugins": [True, False], + "ssl": [True, False], + "sasl": [True, False], + "curl": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "zlib": False, + "zstd": False, + "plugins": False, + "ssl": True, + "sasl": False, + "curl": False, + } + + @property + def _depends_on_cyrus_sasl(self): + return self.options.sasl and self.settings.os != "Windows" + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("lz4/1.9.4") + if self.options.zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.zstd: + self.requires("zstd/1.5.5") + if self.options.ssl: + # self.requires("openssl/[>=1.1 <4]") + self.requires("openssl/3.3.0@minifi/dev") + if self._depends_on_cyrus_sasl: + self.requires("cyrus-sasl/2.1.28") + if self.options.curl: + self.requires("libcurl/[>=7.78.0 <9]") + + def build_requirements(self): + if self._depends_on_cyrus_sasl: + self.tool_requires("pkgconf/2.1.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = CMakeToolchain(self) + tc.variables["WITHOUT_OPTIMIZATION"] = self.settings.build_type == "Debug" + tc.variables["ENABLE_DEVEL"] = self.settings.build_type == "Debug" + tc.variables["RDKAFKA_BUILD_STATIC"] = not self.options.shared + tc.variables["RDKAFKA_BUILD_EXAMPLES"] = False + tc.variables["RDKAFKA_BUILD_TESTS"] = False + tc.variables["WITHOUT_WIN32_CONFIG"] = True + tc.variables["WITH_BUNDLED_SSL"] = False + tc.variables["WITH_ZLIB"] = self.options.zlib + tc.variables["WITH_ZSTD"] = self.options.zstd + tc.variables["WITH_PLUGINS"] = self.options.plugins + tc.variables["WITH_SSL"] = self.options.ssl + tc.variables["WITH_SASL"] = self.options.sasl + tc.variables["ENABLE_LZ4_EXT"] = False + tc.variables["WITH_CURL"] = self.options.curl + tc.generate() + + cd = CMakeDeps(self) + cd.generate() + + if self._depends_on_cyrus_sasl: + pc = PkgConfigDeps(self) + pc.generate() + + def build(self): + apply_conandata_patches(self) + # There are references to libcrypto.lib and libssl.lib in rdkafka_ssl.c for versions >= 1.8.0 + if is_msvc(self) and self.settings.build_type == "Debug" and self.options.get_safe("ssl", False): + rdkafka_ssl_path = os.path.join(self.source_folder, "src", "rdkafka_ssl.c") + replace_in_file(self, rdkafka_ssl_path, "libcrypto.lib", "libcryptod.lib") + replace_in_file(self, rdkafka_ssl_path, "libssl.lib", "libssld.lib") + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSES.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "RdKafka") + # Avoid to create undesirables librdkafka::librdkafka target and librdkafka.pc + # it's fine since rdkafka++ component depends on all components + self.cpp_info.set_property("cmake_target_name", "RdKafka::rdkafka++") + self.cpp_info.set_property("pkg_config_name", "rdkafka++") + + # rdkafka + self.cpp_info.components["rdkafka"].set_property("cmake_target_name", "RdKafka::rdkafka") + self.cpp_info.components["rdkafka"].set_property("pkg_config_name", "rdkafka") + self.cpp_info.components["rdkafka"].libs = ["rdkafka"] + self.cpp_info.components["rdkafka"].requires = ["lz4::lz4"] + if self.options.zlib: + self.cpp_info.components["rdkafka"].requires.append("zlib::zlib") + if self.options.zstd: + self.cpp_info.components["rdkafka"].requires.append("zstd::zstd") + if self.options.ssl: + self.cpp_info.components["rdkafka"].requires.append("openssl::openssl") + if self._depends_on_cyrus_sasl: + self.cpp_info.components["rdkafka"].requires.append("cyrus-sasl::cyrus-sasl") + if self.options.get_safe("curl", False): + self.cpp_info.components["rdkafka"].requires.append("libcurl::libcurl") + if self.settings.os == "Windows": + self.cpp_info.components["rdkafka"].system_libs = ["ws2_32", "secur32"] + if self.options.ssl: + self.cpp_info.components["rdkafka"].system_libs.append("crypt32") + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["rdkafka"].system_libs.extend(["pthread", "rt", "dl", "m"]) + if not self.options.shared: + self.cpp_info.components["rdkafka"].defines.append("LIBRDKAFKA_STATICLIB") + + # rdkafka++ + self.cpp_info.components["rdkafka++"].set_property("cmake_target_name", "RdKafka::rdkafka++") + self.cpp_info.components["rdkafka++"].set_property("pkg_config_name", "rdkafka++") + self.cpp_info.components["rdkafka++"].libs = ["rdkafka++"] + self.cpp_info.components["rdkafka++"].requires = ["rdkafka"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "RdKafka" + self.cpp_info.names["cmake_find_package_multi"] = "RdKafka" diff --git a/thirdparty/librdkafka/all/patches/0001-Change-library-names-1-9-1.patch b/thirdparty/librdkafka/all/patches/0001-Change-library-names-1-9-1.patch new file mode 100644 index 0000000000..93de57a4d1 --- /dev/null +++ b/thirdparty/librdkafka/all/patches/0001-Change-library-names-1-9-1.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7f3dd0f..89a21e7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -67,7 +67,7 @@ endif() + # } + + # ZSTD { +-find_package(ZSTD QUIET) ++find_package(zstd QUIET CONFIG) + if(ZSTD_FOUND) + set(with_zstd_default ON) + else() +@@ -169,7 +169,8 @@ endif() + option(ENABLE_LZ4_EXT "Enable external LZ4 library support" ON) + set(WITH_LZ4_EXT OFF) + if(ENABLE_LZ4_EXT) +- find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) ++ set(LZ4_FOUND ON) + if(LZ4_FOUND) + set(WITH_LZ4_EXT ON) + list(APPEND BUILT_WITH "LZ4_EXT") diff --git a/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-9-1.patch b/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-9-1.patch new file mode 100644 index 0000000000..c3347279b9 --- /dev/null +++ b/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-9-1.patch @@ -0,0 +1,25 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 33b3ced..93f49b1 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -207,9 +207,7 @@ if(WITH_ZLIB) + endif() + + if(WITH_ZSTD) +- target_link_libraries(rdkafka PRIVATE ${ZSTD_LIBRARY}) +- target_include_directories(rdkafka PRIVATE ${ZSTD_INCLUDE_DIR}) +- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") ++ target_link_libraries(rdkafka PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + + if(WITH_SSL) +@@ -248,8 +246,7 @@ if(WITH_LIBDL) + endif() + + if(WITH_LZ4_EXT) +- target_include_directories(rdkafka PRIVATE ${LZ4_INCLUDE_DIRS}) +- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) + endif() + + if(WIN32) diff --git a/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-2-0-2.patch b/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-2-0-2.patch new file mode 100644 index 0000000000..740fe7f025 --- /dev/null +++ b/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-2-0-2.patch @@ -0,0 +1,24 @@ +diff --git a/a/src/CMakeLists.txt b/b/src/CMakeLists.txt +index 37b43c4..78745a7 100644 +--- a/a/src/CMakeLists.txt ++++ b/b/src/CMakeLists.txt +@@ -214,9 +214,7 @@ if(WITH_ZLIB) + endif() + + if(WITH_ZSTD) +- target_link_libraries(rdkafka PRIVATE ${ZSTD_LIBRARY}) +- target_include_directories(rdkafka PRIVATE ${ZSTD_INCLUDE_DIR}) +- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") ++ target_link_libraries(rdkafka PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + + if(WITH_SSL) +@@ -256,7 +254,7 @@ endif() + + if(WITH_LZ4_EXT) + target_include_directories(rdkafka PRIVATE ${LZ4_INCLUDE_DIRS}) +- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) + endif() + + if(WIN32) diff --git a/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-2-3-0.patch b/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-2-3-0.patch new file mode 100644 index 0000000000..169e5bb94d --- /dev/null +++ b/thirdparty/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-2-3-0.patch @@ -0,0 +1,24 @@ +iff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index cbcff50..38ad38e 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -215,9 +215,7 @@ if(WITH_ZLIB) + endif() + + if(WITH_ZSTD) +- target_link_libraries(rdkafka PRIVATE ${ZSTD_LIBRARY}) +- target_include_directories(rdkafka PRIVATE ${ZSTD_INCLUDE_DIR}) +- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") ++ target_link_libraries(rdkafka PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + + if(WITH_SSL) +@@ -257,7 +255,7 @@ endif() + + if(WITH_LZ4_EXT) + target_include_directories(rdkafka PRIVATE ${LZ4_INCLUDE_DIRS}) +- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) + endif() + + if(WIN32) diff --git a/thirdparty/librdkafka/all/test_package/CMakeLists.txt b/thirdparty/librdkafka/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..636b897b6b --- /dev/null +++ b/thirdparty/librdkafka/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C CXX) + +find_package(RdKafka REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE RdKafka::rdkafka) + +add_executable(${PROJECT_NAME}_cpp test_package.cpp) +target_link_libraries(${PROJECT_NAME}_cpp PRIVATE RdKafka::rdkafka++) diff --git a/thirdparty/librdkafka/all/test_package/conanfile.py b/thirdparty/librdkafka/all/test_package/conanfile.py new file mode 100644 index 0000000000..6b68cbd742 --- /dev/null +++ b/thirdparty/librdkafka/all/test_package/conanfile.py @@ -0,0 +1,28 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/librdkafka/all/test_package/test_package.c b/thirdparty/librdkafka/all/test_package/test_package.c new file mode 100644 index 0000000000..9670aa9ff8 --- /dev/null +++ b/thirdparty/librdkafka/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const *argv[]) { + rd_kafka_conf_t *conf = rd_kafka_conf_new(); + + printf("\n"); + printf("----------------->Tests are done.<---------------------\n"); + printf("Using version (from C lib) %s\n", rd_kafka_version_str()); + printf("///////////////////////////////////////////////////////\n"); + return 0; +} diff --git a/thirdparty/librdkafka/all/test_package/test_package.cpp b/thirdparty/librdkafka/all/test_package/test_package.cpp new file mode 100644 index 0000000000..d1ea076285 --- /dev/null +++ b/thirdparty/librdkafka/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const *argv[]) { + RdKafka::Conf* confpp = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL); + + std::cout << std::endl + << "----------------->Tests are done.<---------------------" << std::endl + << "Using version (from C++ lib) " << RdKafka::version() << std::endl + << "///////////////////////////////////////////////////////" << std::endl; + return 0; +} diff --git a/thirdparty/librdkafka/all/test_v1_package/CMakeLists.txt b/thirdparty/librdkafka/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..0d20897301 --- /dev/null +++ b/thirdparty/librdkafka/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/thirdparty/librdkafka/all/test_v1_package/conanfile.py b/thirdparty/librdkafka/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..2be697c561 --- /dev/null +++ b/thirdparty/librdkafka/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + bin_path = os.path.join("bin", "test_package_cpp") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/librdkafka/config.yml b/thirdparty/librdkafka/config.yml new file mode 100644 index 0000000000..d9d5e85da2 --- /dev/null +++ b/thirdparty/librdkafka/config.yml @@ -0,0 +1,11 @@ +versions: + "2.4.0": + folder: all + "2.3.0": + folder: all + "2.2.0": + folder: all + "2.0.2": + folder: all + "1.9.2": + folder: all diff --git a/thirdparty/libssh2/all/conandata.yml b/thirdparty/libssh2/all/conandata.yml new file mode 100644 index 0000000000..46c0ee9468 --- /dev/null +++ b/thirdparty/libssh2/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "1.11.0": + sha256: a488a22625296342ddae862de1d59633e6d446eff8417398e06674a49be3d7c2 + url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz + "1.10.0": + sha256: 2d64e90f3ded394b91d3a2e774ca203a4179f69aebee03003e5a6fa621e41d51 + url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.10.0/libssh2-1.10.0.tar.gz + "1.9.0": + sha256: d5fb8bd563305fd1074dda90bd053fb2d29fc4bce048d182f96eaa466dfadafd + url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.9.0/libssh2-1.9.0.tar.gz + "1.8.2": + sha256: 088307d9f6b6c4b8c13f34602e8ff65d21c2dc4d55284dfe15d502c4ee190d67 + url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.8.2/libssh2-1.8.2.tar.gz + "1.8.0": + sha256: 39f34e2f6835f4b992cafe8625073a88e5a28ba78f83e8099610a7b3af4676d4 + url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.8.0/libssh2-1.8.0.tar.gz diff --git a/thirdparty/libssh2/all/conanfile.py b/thirdparty/libssh2/all/conanfile.py new file mode 100644 index 0000000000..eda3962810 --- /dev/null +++ b/thirdparty/libssh2/all/conanfile.py @@ -0,0 +1,136 @@ +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir, collect_libs +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.53.0" + + +class Libssh2Conan(ConanFile): + name = "libssh2" + description = "libssh2 is a client-side C library implementing the SSH2 protocol" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://libssh2.org" + topics = ("libssh", "ssh", "shell", "ssh2", "connection") + license = "BSD-3-Clause" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_zlib": [True, False], + "enable_crypt_none": [True, False], + "enable_mac_none": [True, False], + "crypto_backend": ["openssl", "mbedtls"], + "enable_debug_logging": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_zlib": True, + "enable_crypt_none": False, + "enable_mac_none": False, + "crypto_backend": "openssl", + "enable_debug_logging": False, + } + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="src") + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["ENABLE_ZLIB_COMPRESSION"] = self.options.with_zlib + tc.cache_variables["ENABLE_CRYPT_NONE"] = self.options.enable_crypt_none + tc.cache_variables["ENABLE_MAC_NONE"] = self.options.enable_mac_none + tc.cache_variables["ENABLE_DEBUG_LOGGING"] = self.options.enable_debug_logging + if self.options.crypto_backend == "openssl": + tc.cache_variables["CRYPTO_BACKEND"] = "OpenSSL" + tc.cache_variables["OPENSSL_ROOT_DIR"] = self.dependencies["openssl"].package_folder.replace("\\", "/") + elif self.options.crypto_backend == "mbedtls": + tc.cache_variables["CRYPTO_BACKEND"] = "mbedTLS" + tc.cache_variables["BUILD_EXAMPLES"] = False + tc.cache_variables['BUILD_TESTING'] = not self.conf.get("tools.build:skip_test", default=True, check_type=bool) + tc.cache_variables["BUILD_STATIC_LIBS"] = not self.options.shared + tc.cache_variables["BUILD_SHARED_LIBS"] = self.options.shared + # To install relocatable shared lib on Macos by default + tc.variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Workaround until github.com/conan-io/conan/pull/12600 is merged + if is_msvc(self): + tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + # This is a pure C library + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def requirements(self): + if self.options.with_zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.crypto_backend == "openssl": + # self.requires("openssl/[>=1.1 <4]") + self.requires("openssl/3.3.0@minifi/dev") + elif self.options.crypto_backend == "mbedtls": + if Version(self.version) >= "1.11": + self.requires("mbedtls/3.5.0") + else: + # self.requires("mbedtls/2.28.4") + self.requires("mbedtls/2.16.3@minifi/dev") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "share")) # only docs and manpages + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Libssh2") + self.cpp_info.set_property("cmake_target_name", "Libssh2::libssh2") + self.cpp_info.set_property("pkg_config_name", "libssh2") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["_libssh2"].libs = collect_libs(self) + if self.settings.os == "Windows": + self.cpp_info.components["_libssh2"].system_libs.append("ws2_32") + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["_libssh2"].system_libs.extend(["pthread", "dl"]) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "Libssh2" + self.cpp_info.names["cmake_find_package_multi"] = "Libssh2" + self.cpp_info.components["_libssh2"].names["cmake_find_package"] = "libssh2" + self.cpp_info.components["_libssh2"].names["cmake_find_package_multi"] = "libssh2" + self.cpp_info.components["_libssh2"].set_property("cmake_target_name", "Libssh2::libssh2") + self.cpp_info.components["_libssh2"].set_property("pkg_config_name", "libssh2") + if self.options.with_zlib: + self.cpp_info.components["_libssh2"].requires.append("zlib::zlib") + if self.options.crypto_backend == "openssl": + self.cpp_info.components["_libssh2"].requires.append("openssl::openssl") + elif self.options.crypto_backend == "mbedtls": + self.cpp_info.components["_libssh2"].requires.append("mbedtls::mbedtls") diff --git a/thirdparty/libssh2/all/test_package/CMakeLists.txt b/thirdparty/libssh2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..92f94a3640 --- /dev/null +++ b/thirdparty/libssh2/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +find_package(Libssh2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE Libssh2::libssh2) diff --git a/thirdparty/libssh2/all/test_package/conanfile.py b/thirdparty/libssh2/all/test_package/conanfile.py new file mode 100644 index 0000000000..a9bc449b52 --- /dev/null +++ b/thirdparty/libssh2/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/libssh2/all/test_package/test_package.c b/thirdparty/libssh2/all/test_package/test_package.c new file mode 100644 index 0000000000..3996348f02 --- /dev/null +++ b/thirdparty/libssh2/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include + +int main(int argc, char *argv[]) +{ + LIBSSH2_SESSION* session = libssh2_session_init(); + libssh2_session_disconnect(session, "Normal Shutdown"); + libssh2_session_free(session); + + return 0; +} diff --git a/thirdparty/libssh2/config.yml b/thirdparty/libssh2/config.yml new file mode 100644 index 0000000000..3cada2e5e3 --- /dev/null +++ b/thirdparty/libssh2/config.yml @@ -0,0 +1,11 @@ +versions: + "1.11.0": + folder: all + "1.10.0": + folder: all + "1.9.0": + folder: all + "1.8.2": + folder: all + "1.8.0": + folder: all diff --git a/thirdparty/libsystemd/all/conandata.yml b/thirdparty/libsystemd/all/conandata.yml new file mode 100644 index 0000000000..e7dd740091 --- /dev/null +++ b/thirdparty/libsystemd/all/conandata.yml @@ -0,0 +1,120 @@ +sources: + "255.2": + url: "https://github.com/systemd/systemd-stable/archive/v255.2.tar.gz" + sha256: "ba7354a742dc9a8bb7dbeaa40cbf7cf2ca84f506d5b7ae5ab8d14c8eecb7aca0" + "255": + url: "https://github.com/systemd/systemd-stable/archive/v255.tar.gz" + sha256: "a3eb766ee96eb9f4cc25c2a6c933f3299e1b7ae22e72507dade0a5c86d92534f" + "253.14": + url: "https://github.com/systemd/systemd-stable/archive/v253.14.tar.gz" + sha256: "9c83ac26f691ff2c482659884f01f1155ef5e1bd202204f9e3076a31e54ab155" + "253.10": + url: "https://github.com/systemd/systemd-stable/archive/v253.10.tar.gz" + sha256: "7c869513b2ad015568e8e35304942f84378b0c59972cb44de5ac905b8eea08d4" + "253.6": + url: "https://github.com/systemd/systemd-stable/archive/v253.6.tar.gz" + sha256: "a0aebcfaa2e001a4d846691631d1722c4cfa1a175e4ea62db6edca0ea3cf1e3e" + "252.12": + url: "https://github.com/systemd/systemd-stable/archive/v252.12.tar.gz" + sha256: "c6c249d65b3aff0a2b99410f430f404068c74a7cd96b63f482c933afd7288112" + "251.18": + url: "https://github.com/systemd/systemd-stable/archive/v251.18.tar.gz" + sha256: "aaa5eca2dcf3fda242ed6816a00a83c91762b44ef3c76ee4eb8476a592c38f7f" + "249.16": + url: "https://github.com/systemd/systemd-stable/archive/v249.16.tar.gz" + sha256: "e6c8a686023ef0ce402f4abde42245e3ada661e000c4811dc16c8cd9b4c6d885" + "248.12": + url: "https://github.com/systemd/systemd-stable/archive/v248.12.tar.gz" + sha256: "d0826453439363b57a4f092ae078b128a95e87047281a79e8b136116ab83abc9" + "247.13": + url: "https://github.com/systemd/systemd-stable/archive/v247.13.tar.gz" + sha256: "0958bfcebf3ed4e451f6cc49802f338fcc80eb4fe4f0cf5cb5b1b90fa62e5f47" + "246.16": + url: "https://github.com/systemd/systemd-stable/archive/v246.16.tar.gz" + sha256: "b69f9940d65870f090269a28f1047a633d4b80d0001e091d53a031dd40a822d2" +patches: + "255.2": + - patch_file: "patches/251.18/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "255": + - patch_file: "patches/251.18/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "253.14": + - patch_file: "patches/253.6/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/251.18/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + - patch_file: "patches/253.3/0002-meson-use-c_args-in-generator-scripts.patch" + patch_source: "https://patch-diff.githubusercontent.com/raw/systemd/systemd/pull/29538" + patch_description: "fixes cross-compilation by passing necessary compiler arguments to generator scripts" + patch_type: "portability" + "253.10": + - patch_file: "patches/253.6/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/251.18/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + - patch_file: "patches/253.3/0002-meson-use-c_args-in-generator-scripts.patch" + patch_source: "https://patch-diff.githubusercontent.com/raw/systemd/systemd/pull/29538" + patch_description: "fixes cross-compilation by passing necessary compiler arguments to generator scripts" + patch_type: "portability" + "253.6": + - patch_file: "patches/253.6/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/251.18/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + - patch_file: "patches/253.3/0002-meson-use-c_args-in-generator-scripts.patch" + patch_source: "https://patch-diff.githubusercontent.com/raw/systemd/systemd/pull/29538" + patch_description: "fixes cross-compilation by passing necessary compiler arguments to generator scripts" + patch_type: "portability" + "252.12": + - patch_file: "patches/248.12/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/251.18/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "251.18": + - patch_file: "patches/248.12/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/251.18/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "249.16": + - patch_file: "patches/248.12/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/249.16/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "248.12": + - patch_file: "patches/248.12/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/247.13/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "247.13": + - patch_file: "patches/247.13/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "246.16": + - patch_file: "patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch" + patch_description: "fix build error with Linux headers >= 5.14 by removing a bundled copy of it" + patch_type: "portability" + patch_source: "https://github.com/systemd/systemd-stable/commit/06dea04b38ce506c1436cd4fef9bf9919a34f441" + - patch_file: "patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch" + patch_description: "allow to build with meson >= 0.60.0 by fixing syntax error" + patch_type: "bugfix" + patch_source: "https://github.com/systemd/systemd-stable/commit/3d0666d9091dd097022f02fae79890b5746285c1" + - patch_file: "patches/246.16/0003-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" diff --git a/thirdparty/libsystemd/all/conanfile.py b/thirdparty/libsystemd/all/conanfile.py new file mode 100644 index 0000000000..c5fe263559 --- /dev/null +++ b/thirdparty/libsystemd/all/conanfile.py @@ -0,0 +1,210 @@ +import os +import re +import tarfile + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, replace_in_file, download, move_folder_contents +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.scm import Version + +required_conan_version = ">=1.60.0" + + +class LibsystemdConan(ConanFile): + name = "libsystemd" + license = "LGPL-2.1-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.freedesktop.org/wiki/Software/systemd/" + description = "System and Service Manager API library" + topics = ("systemd", "service", "manager") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_selinux": [True, False], + "with_lz4": [True, False], + "with_xz": [True, False], + "with_zstd": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_selinux": True, + "with_lz4": True, + "with_xz": True, + "with_zstd": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("libcap/2.69") + self.requires("libmount/2.39.2") + if Version(self.version) >= "251.18": + self.requires("libxcrypt/4.4.36") + if self.options.with_selinux: + self.requires("libselinux/3.5") + if self.options.with_lz4: + self.requires("lz4/1.9.4") + if self.options.with_xz: + # self.requires("xz_utils/5.4.5") + self.requires("xz_utils/5.2.5@minifi/dev") + if self.options.with_zstd: + self.requires("zstd/1.5.5") + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("Only Linux supported") + + def build_requirements(self): + self.tool_requires("meson/1.3.0") + self.tool_requires("m4/1.4.19") + self.tool_requires("gperf/3.1") + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/2.1.0") + + def source(self): + # Extract using standard Python tools due to Conan's unzip() not handling backslashes in + # 'units/system-systemd\x2dcryptsetup.slice', etc. correctly. + download(self, **self.conan_data["sources"][self.version], filename="sources.tar.gz") + with tarfile.open("sources.tar.gz", "r:gz") as tar: + tar.extractall() + move_folder_contents(self, os.path.join(self.source_folder, f"systemd-stable-{self.version}"), self.source_folder) + + @property + def _so_version(self): + meson_build = os.path.join(self.source_folder, "meson.build") + with open(meson_build, "r", encoding="utf-8") as build_file: + for line in build_file: + match = re.match(r"^libsystemd_version = '(.*)'$", line) + if match: + return match.group(1) + return "" + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = MesonToolchain(self) + tc.project_options["selinux"] = ("true" if self.options.with_selinux + else "false") + tc.project_options["lz4"] = ("true" if self.options.with_lz4 + else "false") + tc.project_options["xz"] = "true" if self.options.with_xz else "false" + tc.project_options["zstd"] = ("true" if self.options.with_zstd + else "false") + + if self.options.shared: + tc.project_options["static-libsystemd"] = "false" + elif self.options.fPIC: + tc.project_options["static-libsystemd"] = "pic" + else: + tc.project_options["static-libsystemd"] = "no-pic" + + # options unrelated to libsystemd + unrelated = [ + "fdisk", "seccomp", "pwquality", "apparmor", "polkit", "audit", + "kmod", "microhttpd", "libcryptsetup", "libcurl", "libidn", + "libidn2", "qrencode", "openssl", "libfido2", "zlib", "xkbcommon", + "pcre2", "glib", "dbus", "blkid", "gcrypt", "p11kit", "ima", + "smack", "bzip2", "gnutls", "idn", "initrd", "binfmt", "vconsole", + "quotacheck", "tmpfiles", "environment-d", "sysusers", "firstboot", + "randomseed", "backlight", "rfkill", "xdg-autostart", "logind", + "hibernate", "machined", "portabled", "userdb", "hostnamed", + "timedated", "timesyncd", "localed", "networkd", "resolve", + "coredump", "pstore", "efi", "nss-myhostname", "nss-mymachines", + "nss-resolve", "nss-systemd", "hwdb", "tpm", "man", "html", "utmp", + "ldconfig", "adm-group", "wheel-group", "gshadow", "install-tests", + "link-udev-shared", "link-systemctl-shared", "analyze", "pam", + "link-networkd-shared", "link-timesyncd-shared", "kernel-install", + "libiptc", "elfutils", "repart", "homed", "importd", "acl", + "dns-over-tls", "log-trace"] + + if Version(self.version) >= "247.1": + unrelated.append("oomd") + if Version(self.version) >= "248.1": + unrelated.extend(["sysext", "nscd"]) + if Version(self.version) >= "251.1": + unrelated.append("link-boot-shared") + if Version(self.version) >= "252.1": + unrelated.append("link-journalctl-shared") + if Version(self.version) < "254.7": + unrelated.extend(["gnu-efi", "valgrind"]) + else: + unrelated.extend(["passwdqc", "bootloader", "link-portabled-shared"]) + + for opt in unrelated: + tc.project_options[opt] = "false" + + # 'rootprefix' is unused during libsystemd packaging but systemd > v247 + # build files require 'prefix' to be a subdirectory of 'rootprefix'. + tc.project_options["rootprefix"] = self.package_folder + + # There are a few places in libsystemd where pkgconfig dependencies are + # not used in compile time and only used in link time. And because of + # that it is not enough to use the 'PkgConfigDeps' generator here. It + # is also required to provide a path to the header files directly to + # the compiler. + for dependency in self.dependencies.values(): + for includedir in dependency.cpp_info.aggregated_components().includedirs: + tc.c_args.append(f"-I{includedir}") + + tc.generate() + + deps = PkgConfigDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + meson_build = os.path.join(self.source_folder, "meson.build") + replace_in_file(self, meson_build, "@CONAN_SRC_REL_PATH@", f"'../{self.source_path.name}'") + + def build(self): + self._patch_sources() + + meson = Meson(self) + meson.configure() + target = ("systemd:shared_library" if self.options.shared + else "systemd:static_library") + meson.build(target=f"version.h {target}") + + def package(self): + copy(self, "LICENSE.LGPL2.1", self.source_folder, + os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", os.path.join(self.source_folder, "src", "systemd"), + os.path.join(self.package_folder, "include", "systemd")) + + if self.options.shared: + copy(self, "libsystemd.so", self.build_folder, + os.path.join(self.package_folder, "lib")) + copy(self, "libsystemd.so.{}".format(self._so_version.split('.')), + self.build_folder, os.path.join(self.package_folder, "lib")) + copy(self, "libsystemd.so.{}".format(self._so_version), + self.build_folder, os.path.join(self.package_folder, "lib")) + else: + copy(self, "libsystemd.a", self.build_folder, + os.path.join(self.package_folder, "lib")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libsystemd") + self.cpp_info.set_property("component_version", str(Version(self.version).major)) + self.cpp_info.libs = ["systemd"] + self.cpp_info.system_libs = ["rt", "pthread", "dl"] + + # TODO: to remove in conan v2 + self.cpp_info.version = str(Version(self.version).major) diff --git a/thirdparty/libsystemd/all/patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch b/thirdparty/libsystemd/all/patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch new file mode 100644 index 0000000000..cb77bf0883 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch @@ -0,0 +1,223 @@ +From 00ff923c28498dad77c1705c3699a21bcc941329 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Wed, 15 Sep 2021 16:33:05 +0200 +Subject: [PATCH 1/2] Drop bundled copy of linux/if_arp.h +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +As far as I can see, we use this to get a list of ARPHRD_* defines (used in +particular for Type= in .link files). If we drop our copy, and build against +old kernel headers, the user will have a shorter list of types available. This +seems OK, and I don't think it's worth carrying our own version of this file +just to have newest possible entries. + +7c5b9952c4f6e2b72f90edbe439982528b7cf223 recently updated this file, but we'd +have to update it every time the kernel adds new entries. But if we look at +the failure carefully: + +src/basic/arphrd-from-name.gperf:65:16: error: ‘ARPHRD_MCTP’ undeclared (first use in this function); did you mean ‘ARPHRD_FCPP’? + 65 | MCTP, ARPHRD_MCTP + | ^~ + | ARPHRD_FCPP + +we see that the list we were generating was from the system headers, so it was +only as good as the system headers anyway, without the newer entries in our +bundled copy, if there were any. So let's make things simpler by always using +system headers. + +And if somebody wants to fix things so that we always have the newest list, +then we should just generate and store the converted list, not the full header. + +(cherry picked from commit e7f46ee3ae1cc66a94b293957721d68dc09d7449) +--- + src/basic/linux/if_arp.h | 164 --------------------------------------- + src/basic/meson.build | 1 - + 2 files changed, 165 deletions(-) + delete mode 100644 src/basic/linux/if_arp.h + +diff --git a/src/basic/linux/if_arp.h b/src/basic/linux/if_arp.h +deleted file mode 100644 +index c3cc5a9e5e..0000000000 +--- a/src/basic/linux/if_arp.h ++++ /dev/null +@@ -1,164 +0,0 @@ +-/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +-/* +- * INET An implementation of the TCP/IP protocol suite for the LINUX +- * operating system. INET is implemented using the BSD Socket +- * interface as the means of communication with the user level. +- * +- * Global definitions for the ARP (RFC 826) protocol. +- * +- * Version: @(#)if_arp.h 1.0.1 04/16/93 +- * +- * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988 +- * Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source. +- * Ross Biro +- * Fred N. van Kempen, +- * Florian La Roche, +- * Jonathan Layes +- * Arnaldo Carvalho de Melo ARPHRD_HWX25 +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU General Public License +- * as published by the Free Software Foundation; either version +- * 2 of the License, or (at your option) any later version. +- */ +-#ifndef _UAPI_LINUX_IF_ARP_H +-#define _UAPI_LINUX_IF_ARP_H +- +-#include +- +-/* ARP protocol HARDWARE identifiers. */ +-#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */ +-#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ +-#define ARPHRD_EETHER 2 /* Experimental Ethernet */ +-#define ARPHRD_AX25 3 /* AX.25 Level 2 */ +-#define ARPHRD_PRONET 4 /* PROnet token ring */ +-#define ARPHRD_CHAOS 5 /* Chaosnet */ +-#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */ +-#define ARPHRD_ARCNET 7 /* ARCnet */ +-#define ARPHRD_APPLETLK 8 /* APPLEtalk */ +-#define ARPHRD_DLCI 15 /* Frame Relay DLCI */ +-#define ARPHRD_ATM 19 /* ATM */ +-#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */ +-#define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734 */ +-#define ARPHRD_EUI64 27 /* EUI-64 */ +-#define ARPHRD_INFINIBAND 32 /* InfiniBand */ +- +-/* Dummy types for non ARP hardware */ +-#define ARPHRD_SLIP 256 +-#define ARPHRD_CSLIP 257 +-#define ARPHRD_SLIP6 258 +-#define ARPHRD_CSLIP6 259 +-#define ARPHRD_RSRVD 260 /* Notional KISS type */ +-#define ARPHRD_ADAPT 264 +-#define ARPHRD_ROSE 270 +-#define ARPHRD_X25 271 /* CCITT X.25 */ +-#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */ +-#define ARPHRD_CAN 280 /* Controller Area Network */ +-#define ARPHRD_PPP 512 +-#define ARPHRD_CISCO 513 /* Cisco HDLC */ +-#define ARPHRD_HDLC ARPHRD_CISCO +-#define ARPHRD_LAPB 516 /* LAPB */ +-#define ARPHRD_DDCMP 517 /* Digital's DDCMP protocol */ +-#define ARPHRD_RAWHDLC 518 /* Raw HDLC */ +-#define ARPHRD_RAWIP 519 /* Raw IP */ +- +-#define ARPHRD_TUNNEL 768 /* IPIP tunnel */ +-#define ARPHRD_TUNNEL6 769 /* IP6IP6 tunnel */ +-#define ARPHRD_FRAD 770 /* Frame Relay Access Device */ +-#define ARPHRD_SKIP 771 /* SKIP vif */ +-#define ARPHRD_LOOPBACK 772 /* Loopback device */ +-#define ARPHRD_LOCALTLK 773 /* Localtalk device */ +-#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface */ +-#define ARPHRD_BIF 775 /* AP1000 BIF */ +-#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4 */ +-#define ARPHRD_IPDDP 777 /* IP over DDP tunneller */ +-#define ARPHRD_IPGRE 778 /* GRE over IP */ +-#define ARPHRD_PIMREG 779 /* PIMSM register interface */ +-#define ARPHRD_HIPPI 780 /* High Performance Parallel Interface */ +-#define ARPHRD_ASH 781 /* Nexus 64Mbps Ash */ +-#define ARPHRD_ECONET 782 /* Acorn Econet */ +-#define ARPHRD_IRDA 783 /* Linux-IrDA */ +-/* ARP works differently on different FC media .. so */ +-#define ARPHRD_FCPP 784 /* Point to point fibrechannel */ +-#define ARPHRD_FCAL 785 /* Fibrechannel arbitrated loop */ +-#define ARPHRD_FCPL 786 /* Fibrechannel public loop */ +-#define ARPHRD_FCFABRIC 787 /* Fibrechannel fabric */ +- /* 787->799 reserved for fibrechannel media types */ +-#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR */ +-#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */ +-#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header */ +-#define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header */ +-#define ARPHRD_IEEE802154 804 +-#define ARPHRD_IEEE802154_MONITOR 805 /* IEEE 802.15.4 network monitor */ +- +-#define ARPHRD_PHONET 820 /* PhoNet media type */ +-#define ARPHRD_PHONET_PIPE 821 /* PhoNet pipe header */ +-#define ARPHRD_CAIF 822 /* CAIF media type */ +-#define ARPHRD_IP6GRE 823 /* GRE over IPv6 */ +-#define ARPHRD_NETLINK 824 /* Netlink header */ +-#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */ +-#define ARPHRD_VSOCKMON 826 /* Vsock monitor header */ +- +-#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known */ +-#define ARPHRD_NONE 0xFFFE /* zero header length */ +- +-/* ARP protocol opcodes. */ +-#define ARPOP_REQUEST 1 /* ARP request */ +-#define ARPOP_REPLY 2 /* ARP reply */ +-#define ARPOP_RREQUEST 3 /* RARP request */ +-#define ARPOP_RREPLY 4 /* RARP reply */ +-#define ARPOP_InREQUEST 8 /* InARP request */ +-#define ARPOP_InREPLY 9 /* InARP reply */ +-#define ARPOP_NAK 10 /* (ATM)ARP NAK */ +- +- +-/* ARP ioctl request. */ +-struct arpreq { +- struct sockaddr arp_pa; /* protocol address */ +- struct sockaddr arp_ha; /* hardware address */ +- int arp_flags; /* flags */ +- struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ +- char arp_dev[IFNAMSIZ]; +-}; +- +-struct arpreq_old { +- struct sockaddr arp_pa; /* protocol address */ +- struct sockaddr arp_ha; /* hardware address */ +- int arp_flags; /* flags */ +- struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ +-}; +- +-/* ARP Flag values. */ +-#define ATF_COM 0x02 /* completed entry (ha valid) */ +-#define ATF_PERM 0x04 /* permanent entry */ +-#define ATF_PUBL 0x08 /* publish entry */ +-#define ATF_USETRAILERS 0x10 /* has requested trailers */ +-#define ATF_NETMASK 0x20 /* want to use a netmask (only +- for proxy entries) */ +-#define ATF_DONTPUB 0x40 /* don't answer this addresses */ +- +-/* +- * This structure defines an ethernet arp header. +- */ +- +-struct arphdr { +- __be16 ar_hrd; /* format of hardware address */ +- __be16 ar_pro; /* format of protocol address */ +- unsigned char ar_hln; /* length of hardware address */ +- unsigned char ar_pln; /* length of protocol address */ +- __be16 ar_op; /* ARP opcode (command) */ +- +-#if 0 +- /* +- * Ethernet looks like this : This bit is variable sized however... +- */ +- unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ +- unsigned char ar_sip[4]; /* sender IP address */ +- unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ +- unsigned char ar_tip[4]; /* target IP address */ +-#endif +- +-}; +- +- +-#endif /* _UAPI_LINUX_IF_ARP_H */ +diff --git a/src/basic/meson.build b/src/basic/meson.build +index ae01beaeaa..feb4e75b74 100644 +--- a/src/basic/meson.build ++++ b/src/basic/meson.build +@@ -95,7 +95,6 @@ basic_sources = files(''' + linux/fou.h + linux/if.h + linux/if_addr.h +- linux/if_arp.h + linux/if_bonding.h + linux/if_bridge.h + linux/if_ether.h +-- +2.37.2 + diff --git a/thirdparty/libsystemd/all/patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch b/thirdparty/libsystemd/all/patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch new file mode 100644 index 0000000000..8ad824a082 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch @@ -0,0 +1,34 @@ +From eda62b3f67ce3ae5d1ddf281034a66bcf6c74933 Mon Sep 17 00:00:00 2001 +From: Dan Streetman +Date: Fri, 3 Sep 2021 12:43:33 -0400 +Subject: [PATCH 2/2] meson.build: change operator combining bools from + to + and + +upstream meson stopped allowing combining boolean with the plus +operator, and now requires using the logical and operator + +reference: +https://github.com/mesonbuild/meson/commit/43302d3296baff6aeaf8e03f5d701b0402e37a6c + +Fixes: #20632 +(cherry picked from commit c29537f39e4f413a6cbfe9669fa121bdd6d8b36f) +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 77da8a4504..3754e89c24 100644 +--- a/meson.build ++++ b/meson.build +@@ -40,7 +40,7 @@ conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + want_ossfuzz = get_option('oss-fuzz') + want_libfuzzer = get_option('llvm-fuzz') +-if want_ossfuzz + want_libfuzzer > 1 ++if want_ossfuzz and want_libfuzzer + error('only one of oss-fuzz or llvm-fuzz can be specified') + endif + +-- +2.37.2 + diff --git a/thirdparty/libsystemd/all/patches/246.16/0003-Remove-dependency-from-coreutils.patch b/thirdparty/libsystemd/all/patches/246.16/0003-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000..9aa5388102 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/246.16/0003-Remove-dependency-from-coreutils.patch @@ -0,0 +1,29 @@ +From 39d419d89e069213ec3bce9390df26de68f41135 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index 77da8a4504..08560292a1 100644 +--- a/meson.build ++++ b/meson.build +@@ -33,9 +33,7 @@ substs.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + want_ossfuzz = get_option('oss-fuzz') +-- +2.37.2 + diff --git a/thirdparty/libsystemd/all/patches/247.13/0001-Remove-dependency-from-coreutils.patch b/thirdparty/libsystemd/all/patches/247.13/0001-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000..4114c12481 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/247.13/0001-Remove-dependency-from-coreutils.patch @@ -0,0 +1,31 @@ +From 2dbb0fe320ca75e7e2be6eba8b5fe6fe07a1ece1 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index 177cd4fb66..869c2352f6 100644 +--- a/meson.build ++++ b/meson.build +@@ -33,9 +33,7 @@ substs.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + conf.set('BUILD_MODE', 'BUILD_MODE_' + get_option('mode').to_upper(), + +base-commit: bb47600aeb38c68c857fbf0ee5f66c3144dd81ce +-- +2.40.1 + diff --git a/thirdparty/libsystemd/all/patches/248.12/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch b/thirdparty/libsystemd/all/patches/248.12/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch new file mode 100644 index 0000000000..b040e39278 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/248.12/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch @@ -0,0 +1,32 @@ +From e8ff65fb110f1a1118ab709fe41e1c3dff0b3c40 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Wed, 17 Aug 2022 22:31:13 +0300 +Subject: [PATCH] missing_syscalls.py: Replace unicode with ascii + +In some system configurations 'find_program('missing_syscalls.py')' may +fail with error: + 'ascii' codec can't decode byte 0xe2 in position 615: ordinal not in range(128) + Unusable script 'src/basic/missing_syscalls.py' + Program missing_syscalls.py found: NO +--- + src/basic/missing_syscalls.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basic/missing_syscalls.py b/src/basic/missing_syscalls.py +index 1bfa31ba37..cc353fe723 100644 +--- a/src/basic/missing_syscalls.py ++++ b/src/basic/missing_syscalls.py +@@ -32,7 +32,7 @@ def dictify(f): + + @dictify + def parse_syscall_table(filename): +- print(f'Reading {filename}…') ++ print(f'Reading {filename}...') + for line in open(filename): + items = line.split() + if len(items) >= 2: + +base-commit: 786df410b1cb3a2294c9a5d118c958525e7439e6 +-- +2.40.1 + diff --git a/thirdparty/libsystemd/all/patches/249.16/0001-Remove-dependency-from-coreutils.patch b/thirdparty/libsystemd/all/patches/249.16/0001-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000..1df9689ea3 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/249.16/0001-Remove-dependency-from-coreutils.patch @@ -0,0 +1,31 @@ +From 08ad698a1b3f7c1caf9dac54c68c2878c664ceec Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index ece21fbd10..aefc82513e 100644 +--- a/meson.build ++++ b/meson.build +@@ -25,9 +25,7 @@ conf.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer', + +base-commit: 358552f75f0ef03af2d6d0ba0f5423f17eab7f84 +-- +2.40.1 + diff --git a/thirdparty/libsystemd/all/patches/251.18/0001-Remove-dependency-from-coreutils.patch b/thirdparty/libsystemd/all/patches/251.18/0001-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000..d186a13d30 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/251.18/0001-Remove-dependency-from-coreutils.patch @@ -0,0 +1,32 @@ +From 0cd72ba5fc1e0b7927522e91d4a1b5172bbc818e Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/meson.build b/meson.build +index d27796e85e..1a31824c8c 100644 +--- a/meson.build ++++ b/meson.build +@@ -25,10 +25,7 @@ conf.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root, +- check : true).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer', + +base-commit: a6422b7bd7001dc38d658f3197073a3e22ca9f1b +-- +2.40.1 + diff --git a/thirdparty/libsystemd/all/patches/253.3/0002-meson-use-c_args-in-generator-scripts.patch b/thirdparty/libsystemd/all/patches/253.3/0002-meson-use-c_args-in-generator-scripts.patch new file mode 100644 index 0000000000..478910e9a3 --- /dev/null +++ b/thirdparty/libsystemd/all/patches/253.3/0002-meson-use-c_args-in-generator-scripts.patch @@ -0,0 +1,33 @@ +From 7b110183b2607d57d399e977a96cb453aed37265 Mon Sep 17 00:00:00 2001 +From: Jordan Williams +Date: Fri, 13 Oct 2023 09:41:00 -0500 +Subject: [PATCH] Revert "Revert "meson: use c_args in generator scripts + (#10289)"" + +This reverts commit 0e3cc902faec4f18d5fa606396f602b08bc94e27. + +Fixes #10288. +I have confirmed that this does now fix cross-compilation. +It appears that changes upstream in Meson, probably mesonbuild/meson#5263, have made the original MR, #10289, work now. + +This needs to be tested to ensure that it doesn't break Travis CI like when it was reverted in #10361. +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index d79263ea8b..87b5a76082 100644 +--- a/meson.build ++++ b/meson.build +@@ -498,7 +498,7 @@ if cxx_cmd != '' + add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp') + endif + +-cpp = ' '.join(cc.cmd_array()) + ' -E' ++cpp = ' '.join(cc.cmd_array() + get_option('c_args')) + ' -E' + + has_wstringop_truncation = cc.has_argument('-Wstringop-truncation') + +-- +2.41.0 + diff --git a/thirdparty/libsystemd/all/patches/253.6/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch b/thirdparty/libsystemd/all/patches/253.6/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch new file mode 100644 index 0000000000..c6abf3d61d --- /dev/null +++ b/thirdparty/libsystemd/all/patches/253.6/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch @@ -0,0 +1,32 @@ +From da3472d677dd30065f8745a124d580e5c24d3868 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Wed, 17 Aug 2022 22:31:13 +0300 +Subject: [PATCH] missing_syscalls.py: Replace unicode with ascii + +In some system configurations 'find_program('missing_syscalls.py')' may +fail with error: + 'ascii' codec can't decode byte 0xe2 in position 615: ordinal not in range(128) + Unusable script 'src/basic/missing_syscalls.py' + Program missing_syscalls.py found: NO +--- + src/basic/missing_syscalls.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basic/missing_syscalls.py b/src/basic/missing_syscalls.py +index 5ccf02adec..14169e67f3 100644 +--- a/src/basic/missing_syscalls.py ++++ b/src/basic/missing_syscalls.py +@@ -31,7 +31,7 @@ def dictify(f): + + @dictify + def parse_syscall_table(filename): +- print(f'Reading {filename}…') ++ print(f'Reading {filename}...') + for line in open(filename): + items = line.split() + if len(items) >= 2: + +base-commit: ed18c2ab79e8b94182d5dcf31d58457763f3e3e1 +-- +2.40.1 + diff --git a/thirdparty/libsystemd/all/test_package/CMakeLists.txt b/thirdparty/libsystemd/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..63d72a88f1 --- /dev/null +++ b/thirdparty/libsystemd/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.6) +project(test_package LANGUAGES C) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::SYSTEMD) diff --git a/thirdparty/libsystemd/all/test_package/conanfile.py b/thirdparty/libsystemd/all/test_package/conanfile.py new file mode 100644 index 0000000000..0e275799b5 --- /dev/null +++ b/thirdparty/libsystemd/all/test_package/conanfile.py @@ -0,0 +1,31 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "PkgConfigDeps", "VirtualBuildEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/2.0.3") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/libsystemd/all/test_package/test_package.c b/thirdparty/libsystemd/all/test_package/test_package.c new file mode 100644 index 0000000000..97e8b8389e --- /dev/null +++ b/thirdparty/libsystemd/all/test_package/test_package.c @@ -0,0 +1,14 @@ +#include +#include + +#include + +int main(void) { + puts("check object path"); + if (sd_bus_object_path_is_valid("/valid/path")) { + puts("ok"); + return EXIT_SUCCESS; + } + puts("failed"); + return EXIT_FAILURE; +} diff --git a/thirdparty/libsystemd/all/test_v1_package/CMakeLists.txt b/thirdparty/libsystemd/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..0d20897301 --- /dev/null +++ b/thirdparty/libsystemd/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/thirdparty/libsystemd/all/test_v1_package/conanfile.py b/thirdparty/libsystemd/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..b3607270e2 --- /dev/null +++ b/thirdparty/libsystemd/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "pkg_config" + + def build_requirements(self): + self.build_requires("pkgconf/2.0.3") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/libsystemd/config.yml b/thirdparty/libsystemd/config.yml new file mode 100644 index 0000000000..84d8505540 --- /dev/null +++ b/thirdparty/libsystemd/config.yml @@ -0,0 +1,23 @@ +versions: + "255.2": + folder: all + "255": + folder: all + "253.14": + folder: all + "253.10": + folder: all + "253.6": + folder: all + "252.12": + folder: all + "251.18": + folder: all + "249.16": + folder: all + "248.12": + folder: all + "247.13": + folder: all + "246.16": + folder: all diff --git a/thirdparty/libtiff/all/conandata.yml b/thirdparty/libtiff/all/conandata.yml new file mode 100644 index 0000000000..e73e0da632 --- /dev/null +++ b/thirdparty/libtiff/all/conandata.yml @@ -0,0 +1,37 @@ +sources: + "4.6.0": + url: "https://download.osgeo.org/libtiff/tiff-4.6.0.tar.gz" + sha256: "88b3979e6d5c7e32b50d7ec72fb15af724f6ab2cbf7e10880c360a77e4b5d99a" + "4.5.1": + url: "https://download.osgeo.org/libtiff/tiff-4.5.1.tar.gz" + sha256: "d7f38b6788e4a8f5da7940c5ac9424f494d8a79eba53d555f4a507167dca5e2b" + "4.5.0": + url: "https://download.osgeo.org/libtiff/tiff-4.5.0.tar.gz" + sha256: "c7a1d9296649233979fa3eacffef3fa024d73d05d589cb622727b5b08c423464" + "4.4.0": + url: "https://download.osgeo.org/libtiff/tiff-4.4.0.tar.gz" + sha256: "917223b37538959aca3b790d2d73aa6e626b688e02dcda272aec24c2f498abed" + "4.3.0": + url: "https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" + sha256: "0e46e5acb087ce7d1ac53cf4f56a09b221537fc86dfc5daaad1c2e89e1b37ac8" +patches: + "4.6.0": + - patch_file: "patches/4.5.1-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + "4.5.1": + - patch_file: "patches/4.5.1-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + "4.5.0": + - patch_file: "patches/4.5.0-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + "4.4.0": + - patch_file: "patches/4.4.0-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + "4.3.0": + - patch_file: "patches/4.3.0-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" diff --git a/thirdparty/libtiff/all/conanfile.py b/thirdparty/libtiff/all/conanfile.py new file mode 100644 index 0000000000..ad7f219314 --- /dev/null +++ b/thirdparty/libtiff/all/conanfile.py @@ -0,0 +1,193 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.53.0" + + +class LibtiffConan(ConanFile): + name = "libtiff" + description = "Library for Tag Image File Format (TIFF)" + url = "https://github.com/conan-io/conan-center-index" + license = "libtiff" + homepage = "http://www.simplesystems.org/libtiff" + topics = ("tiff", "image", "bigtiff", "tagged-image-file-format") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "lzma": [True, False], + "jpeg": [False, "libjpeg", "libjpeg-turbo", "mozjpeg"], + "zlib": [True, False], + "libdeflate": [True, False], + "zstd": [True, False], + "jbig": [True, False], + "webp": [True, False], + "cxx": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "lzma": True, + "jpeg": "libjpeg", + "zlib": True, + "libdeflate": True, + "zstd": True, + "jbig": True, + "webp": True, + "cxx": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + if not self.options.cxx: + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.libdeflate: + self.requires("libdeflate/1.19") + if self.options.lzma: + # self.requires("xz_utils/5.4.5") + self.requires("xz_utils/5.2.5@minifi/dev") + if self.options.jpeg == "libjpeg": + self.requires("libjpeg/9e") + elif self.options.jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/3.0.2") + elif self.options.jpeg == "mozjpeg": + self.requires("mozjpeg/4.1.5") + if self.options.jbig: + self.requires("jbig/20160605") + if self.options.zstd: + self.requires("zstd/1.5.5") + if self.options.webp: + self.requires("libwebp/1.3.2") + + def validate(self): + if self.options.libdeflate and not self.options.zlib: + raise ConanInvalidConfiguration("libtiff:libdeflate=True requires libtiff:zlib=True") + + def build_requirements(self): + if Version(self.version) >= "4.5.1": + # https://github.com/conan-io/conan/issues/3482#issuecomment-662284561 + self.tool_requires("cmake/[>=3.18 <4]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["lzma"] = self.options.lzma + tc.variables["jpeg"] = bool(self.options.jpeg) + tc.variables["jpeg12"] = False + tc.variables["jbig"] = self.options.jbig + tc.variables["zlib"] = self.options.zlib + tc.variables["libdeflate"] = self.options.libdeflate + tc.variables["zstd"] = self.options.zstd + tc.variables["webp"] = self.options.webp + tc.variables["lerc"] = False # TODO: add lerc support for libtiff versions >= 4.3.0 + if Version(self.version) >= "4.5.0": + # Disable tools, test, contrib, man & html generation + tc.variables["tiff-tools"] = False + tc.variables["tiff-tests"] = False + tc.variables["tiff-contrib"] = False + tc.variables["tiff-docs"] = False + tc.variables["cxx"] = self.options.cxx + # BUILD_SHARED_LIBS must be set in command line because defined upstream before project() + tc.cache_variables["BUILD_SHARED_LIBS"] = bool(self.options.shared) + tc.cache_variables["CMAKE_FIND_PACKAGE_PREFER_CONFIG"] = True + tc.generate() + deps = CMakeDeps(self) + if Version(self.version) >= "4.5.1": + deps.set_property("jbig", "cmake_target_name", "JBIG::JBIG") + deps.set_property("xz_utils", "cmake_target_name", "liblzma::liblzma") + deps.set_property("libdeflate", "cmake_file_name", "Deflate") + deps.set_property("libdeflate", "cmake_target_name", "Deflate::Deflate") + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + # remove FindXXXX for conan dependencies + for module in ["Deflate", "JBIG", "JPEG", "LERC", "WebP", "ZSTD", "liblzma", "LibLZMA"]: + rm(self, f"Find{module}.cmake", os.path.join(self.source_folder, "cmake")) + + # Export symbols of tiffxx for msvc shared + replace_in_file(self, os.path.join(self.source_folder, "libtiff", "CMakeLists.txt"), + "set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION})", + "set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION} WINDOWS_EXPORT_ALL_SYMBOLS ON)") + + # Disable tools, test, contrib, man & html generation + if Version(self.version) < "4.5.0": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "add_subdirectory(tools)\nadd_subdirectory(test)\nadd_subdirectory(contrib)\nadd_subdirectory(build)\n" + "add_subdirectory(man)\nadd_subdirectory(html)", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + license_file = "COPYRIGHT" if Version(self.version) < "4.5.0" else "LICENSE.md" + copy(self, license_file, src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), ignore_case=True, keep_path=False) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "TIFF") + self.cpp_info.set_property("cmake_target_name", "TIFF::TIFF") + self.cpp_info.set_property("pkg_config_name", f"libtiff-{Version(self.version).major}") + suffix = "d" if is_msvc(self) and self.settings.build_type == "Debug" else "" + if self.options.cxx: + self.cpp_info.libs.append(f"tiffxx{suffix}") + self.cpp_info.libs.append(f"tiff{suffix}") + if self.settings.os in ["Linux", "Android", "FreeBSD", "SunOS", "AIX"]: + self.cpp_info.system_libs.append("m") + + self.cpp_info.requires = [] + if self.options.zlib: + self.cpp_info.requires.append("zlib::zlib") + if self.options.libdeflate: + self.cpp_info.requires.append("libdeflate::libdeflate") + if self.options.lzma: + self.cpp_info.requires.append("xz_utils::xz_utils") + if self.options.jpeg == "libjpeg": + self.cpp_info.requires.append("libjpeg::libjpeg") + elif self.options.jpeg == "libjpeg-turbo": + self.cpp_info.requires.append("libjpeg-turbo::jpeg") + elif self.options.jpeg == "mozjpeg": + self.cpp_info.requires.append("mozjpeg::libjpeg") + if self.options.jbig: + self.cpp_info.requires.append("jbig::jbig") + if self.options.zstd: + self.cpp_info.requires.append("zstd::zstd") + if self.options.webp: + self.cpp_info.requires.append("libwebp::libwebp") + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "TIFF" + self.cpp_info.names["cmake_find_package_multi"] = "TIFF" diff --git a/thirdparty/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch b/thirdparty/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000000..497c6171bb --- /dev/null +++ b/thirdparty/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch @@ -0,0 +1,91 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,14 +28,17 @@ + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH) ++ set(ZSTD_RECENT_ENOUGH TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -110,7 +110,7 @@ if(ZIP_SUPPORT) + target_link_libraries(tiff PRIVATE ZLIB::ZLIB) + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE $,libdeflate::libdeflate,libdeflate::libdeflate_static>) + endif() + if(JPEG_SUPPORT) + target_link_libraries(tiff PRIVATE JPEG::JPEG) +@@ -120,7 +120,7 @@ if(JPEG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + endif() + if(LERC_SUPPORT) + target_link_libraries(tiff PRIVATE LERC::LERC) +@@ -129,10 +129,10 @@ if(LZMA_SUPPORT) + target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA) + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + endif() + target_link_libraries(tiff PRIVATE CMath::CMath) + diff --git a/thirdparty/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch b/thirdparty/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000000..e2a9148325 --- /dev/null +++ b/thirdparty/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch @@ -0,0 +1,92 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,14 +28,17 @@ + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH) ++ set(ZSTD_RECENT_ENOUGH TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -114,7 +114,7 @@ if(ZIP_SUPPORT) + string(APPEND tiff_requires_private " zlib") + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE $,libdeflate::libdeflate,libdeflate::libdeflate_static>) + list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}") + endif() + if(JPEG_SUPPORT) +@@ -126,7 +126,7 @@ if(JPEG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + list(APPEND tiff_libs_private_list "${JBIG_LIBRARY}") + endif() + if(LERC_SUPPORT) +@@ -141,11 +141,11 @@ if(LZMA_SUPPORT) + string(APPEND tiff_requires_private " liblzma") + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + string(APPEND tiff_requires_private " libzstd") + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + string(APPEND tiff_requires_private " libwebp") + endif() + target_link_libraries(tiff PRIVATE CMath::CMath) diff --git a/thirdparty/libtiff/all/patches/4.5.0-0001-cmake-dependencies.patch b/thirdparty/libtiff/all/patches/4.5.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000000..7780017230 --- /dev/null +++ b/thirdparty/libtiff/all/patches/4.5.0-0001-cmake-dependencies.patch @@ -0,0 +1,116 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(LIBDEFLATE_SUPPORT FALSE) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ set(JBIG_SUPPORT FALSE) + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/JPEGCodec.cmake ++++ b/cmake/JPEGCodec.cmake +@@ -47,19 +47,7 @@ + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}") +- check_c_source_compiles( +- " +- #include +- #include +- #include \"jpeglib.h\" +- int main() +- { +- jpeg_read_scanlines(0,0,0); +- jpeg12_read_scanlines(0,0,0); +- return 0; +- } +- " +- HAVE_JPEGTURBO_DUAL_MODE_8_12) ++ set(HAVE_JPEGTURBO_DUAL_MODE_8_12 FALSE) + cmake_pop_check_state() + endif() + +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,7 +28,10 @@ set(ZSTD_USABLE FALSE) + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + if(NOT DEFINED ZSTD_HAVE_DECOMPRESS_STREAM) +@@ -36,7 +39,7 @@ if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_HAVE_DECOMPRESS_STREAM) ++ set(ZSTD_HAVE_DECOMPRESS_STREAM TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -116,7 +116,7 @@ if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) + string(APPEND tiff_requires_private " zlib") + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE $,libdeflate::libdeflate,libdeflate::libdeflate_static>) + list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}") + endif() + if(JPEG_SUPPORT) +@@ -130,7 +130,7 @@ if(JBIG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + list(APPEND tiff_libs_private_list "${JBIG_LIBRARY}") + endif() + if(LERC_SUPPORT) +@@ -145,11 +145,11 @@ if(ZSTD_SUPPORT) + string(APPEND tiff_requires_private " liblzma") + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + string(APPEND tiff_requires_private " libzstd") + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + string(APPEND tiff_requires_private " libwebp") + endif() + if(CMath_LIBRARY) diff --git a/thirdparty/libtiff/all/patches/4.5.1-0001-cmake-dependencies.patch b/thirdparty/libtiff/all/patches/4.5.1-0001-cmake-dependencies.patch new file mode 100644 index 0000000000..761950e496 --- /dev/null +++ b/thirdparty/libtiff/all/patches/4.5.1-0001-cmake-dependencies.patch @@ -0,0 +1,31 @@ +diff --git a/cmake/JPEGCodec.cmake b/cmake/JPEGCodec.cmake +index 8455a3ec..09fe975a 100644 +--- a/cmake/JPEGCodec.cmake ++++ b/cmake/JPEGCodec.cmake +@@ -42,25 +42,7 @@ endif() + if (JPEG_SUPPORT) + # Check for jpeg12_read_scanlines() which has been added in libjpeg-turbo 2.2 + # for dual 8/12 bit mode. +- include(CheckCSourceCompiles) +- include(CMakePushCheckState) +- cmake_push_check_state(RESET) +- set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}") +- set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}") +- check_c_source_compiles( +- " +- #include +- #include +- #include \"jpeglib.h\" +- int main() +- { +- jpeg_read_scanlines(0,0,0); +- jpeg12_read_scanlines(0,0,0); +- return 0; +- } +- " +- HAVE_JPEGTURBO_DUAL_MODE_8_12) +- cmake_pop_check_state() ++ set(HAVE_JPEGTURBO_DUAL_MODE_8_12 FALSE) + endif() + + if (NOT HAVE_JPEGTURBO_DUAL_MODE_8_12) diff --git a/thirdparty/libtiff/all/test_package/CMakeLists.txt b/thirdparty/libtiff/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..cd389da928 --- /dev/null +++ b/thirdparty/libtiff/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(TIFF REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE TIFF::TIFF) diff --git a/thirdparty/libtiff/all/test_package/CMakeUserPresets.json b/thirdparty/libtiff/all/test_package/CMakeUserPresets.json new file mode 100644 index 0000000000..e30386e923 --- /dev/null +++ b/thirdparty/libtiff/all/test_package/CMakeUserPresets.json @@ -0,0 +1,9 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/libtiff/all/test_package/build/gcc-11-x86_64-gnu20-release/generators/CMakePresets.json" + ] +} \ No newline at end of file diff --git a/thirdparty/libtiff/all/test_package/conanfile.py b/thirdparty/libtiff/all/test_package/conanfile.py new file mode 100644 index 0000000000..0a6bc68712 --- /dev/null +++ b/thirdparty/libtiff/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/libtiff/all/test_package/test_package.c b/thirdparty/libtiff/all/test_package/test_package.c new file mode 100644 index 0000000000..0b73b99d43 --- /dev/null +++ b/thirdparty/libtiff/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + TIFF* tif = TIFFOpen("foo.tif", "w"); + TIFFClose(tif); + return 0; +} diff --git a/thirdparty/libtiff/all/test_v1_package/CMakeLists.txt b/thirdparty/libtiff/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..0d20897301 --- /dev/null +++ b/thirdparty/libtiff/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/thirdparty/libtiff/all/test_v1_package/conanfile.py b/thirdparty/libtiff/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..19e6a0c06e --- /dev/null +++ b/thirdparty/libtiff/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/libtiff/config.yml b/thirdparty/libtiff/config.yml new file mode 100644 index 0000000000..d9523166c1 --- /dev/null +++ b/thirdparty/libtiff/config.yml @@ -0,0 +1,11 @@ +versions: + "4.6.0": + folder: all + "4.5.1": + folder: all + "4.5.0": + folder: all + "4.4.0": + folder: all + "4.3.0": + folder: all diff --git a/thirdparty/maven/all/conandata.yml b/thirdparty/maven/all/conandata.yml new file mode 100644 index 0000000000..f03488696f --- /dev/null +++ b/thirdparty/maven/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "3.9.6": + url: + - "https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" + - "https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" + sha256: "6eedd2cae3626d6ad3a5c9ee324bd265853d64297f07f033430755bd0e0c3a4b" + "3.9.4": + url: + - "https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz" + - "https://archive.apache.org/dist/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz" + sha256: "ff66b70c830a38d331d44f6c25a37b582471def9a161c93902bac7bea3098319" + "3.9.2": + url: "https://archive.apache.org/dist/maven/maven-3/3.9.2/binaries/apache-maven-3.9.2-bin.tar.gz" + sha256: "809ef3220c6d179195c06c324cb9a6d34d8ecba566c5cfd8eb83167bc034117d" diff --git a/thirdparty/maven/all/conanfile.py b/thirdparty/maven/all/conanfile.py new file mode 100644 index 0000000000..38fe23066b --- /dev/null +++ b/thirdparty/maven/all/conanfile.py @@ -0,0 +1,63 @@ +from conan import ConanFile +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.47.0" + +class MavenConan(ConanFile): + name = "maven" + description = "Apache Maven is a software project management and comprehension tool." + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://maven.apache.org/" + topics = ("build", "project management") + package_type = "application" + settings = "os", "arch", "compiler", "build_type" + + def layout(self): + pass + + def requirements(self): + self.requires("zulu-openjdk/21.0.1") + + def package_id(self): + del self.info.settings.arch + del self.info.settings.compiler + del self.info.settings.build_type + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + for target in ("bin", "boot", "conf", "lib"): + copy(self, pattern="*", dst=os.path.join(self.package_folder, target), src=os.path.join(self.source_folder, target)) + + def package_info(self): + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.includedirs = [] + + self.output.info(f"Creating MAVEN_HOME environment variable with : {self.package_folder}") + + self.runenv_info.define_path("MAVEN_HOME", self.package_folder) + self.buildenv_info.define_path("MAVEN_HOME", self.package_folder) + + # TODO: remove `env_info` once the recipe is only compatible with Conan >= 2.0 + self.env_info.MAVEN_HOME = self.package_folder + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) + + + for target in ("bin", "boot", "conf", "lib"): + if target == "bin": + self.env_info.PATH.append(os.path.join(self.package_folder, target)) + + self.runenv_info.define_path("MAVEN_EXECUTABLE", os.path.join(self.package_folder, target, "mvn")) + self.buildenv_info.define_path("MAVEN_EXECUTABLE", os.path.join(self.package_folder, target, "mvn")) + + # TODO: remove `env_info` once the recipe is only compatible with Conan >= 2.0 + self.env_info.MAVEN_EXECUTABLE = os.path.join(self.package_folder, target, "mvn") + self.env_info.PATH.append(os.path.join(self.package_folder, target, "mvn")) + + self.output.info(f"Creating MAVEN_EXECUTABLE environment variable with : {self.env_info.MAVEN_EXECUTABLE}") diff --git a/thirdparty/maven/all/test_package/conanbuild.sh b/thirdparty/maven/all/test_package/conanbuild.sh new file mode 100644 index 0000000000..da8543df6e --- /dev/null +++ b/thirdparty/maven/all/test_package/conanbuild.sh @@ -0,0 +1 @@ +. "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/maven/all/test_package/conanbuildenv-release-x86_64.sh" \ No newline at end of file diff --git a/thirdparty/maven/all/test_package/conanbuildenv-release-x86_64.sh b/thirdparty/maven/all/test_package/conanbuildenv-release-x86_64.sh new file mode 100644 index 0000000000..d3f9c6e6f2 --- /dev/null +++ b/thirdparty/maven/all/test_package/conanbuildenv-release-x86_64.sh @@ -0,0 +1,19 @@ +script_folder="/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/maven/all/test_package" +echo "echo Restoring environment" > "$script_folder/deactivate_conanbuildenv-release-x86_64.sh" +for v in MAVEN_HOME MAVEN_EXECUTABLE PATH JAVA_HOME +do + is_defined="true" + value=$(printenv $v) || is_defined="" || true + if [ -n "$value" ] || [ -n "$is_defined" ] + then + echo export "$v='$value'" >> "$script_folder/deactivate_conanbuildenv-release-x86_64.sh" + else + echo unset $v >> "$script_folder/deactivate_conanbuildenv-release-x86_64.sh" + fi +done + + +export MAVEN_HOME="/home/ubuntu/.conan2/p/b/maven7207cfc89c6f4/p" +export MAVEN_EXECUTABLE="/home/ubuntu/.conan2/p/b/maven7207cfc89c6f4/p/bin/mvn" +export PATH="/home/ubuntu/.conan2/p/b/maven7207cfc89c6f4/p/bin:/home/ubuntu/.conan2/p/zulu-68f60a2c42691/p/bin:$PATH" +export JAVA_HOME="/home/ubuntu/.conan2/p/zulu-68f60a2c42691/p" \ No newline at end of file diff --git a/thirdparty/maven/all/test_package/conanfile.py b/thirdparty/maven/all/test_package/conanfile.py new file mode 100644 index 0000000000..8a44299cfa --- /dev/null +++ b/thirdparty/maven/all/test_package/conanfile.py @@ -0,0 +1,15 @@ +from conan import ConanFile +from conan.tools.build import can_run + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def test(self): + if can_run(self): + self.run("mvn --version") diff --git a/thirdparty/maven/all/test_package/conanrun.sh b/thirdparty/maven/all/test_package/conanrun.sh new file mode 100644 index 0000000000..ef5d1f7721 --- /dev/null +++ b/thirdparty/maven/all/test_package/conanrun.sh @@ -0,0 +1 @@ +. "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/maven/all/test_package/conanrunenv-release-x86_64.sh" \ No newline at end of file diff --git a/thirdparty/maven/all/test_package/conanrunenv-release-x86_64.sh b/thirdparty/maven/all/test_package/conanrunenv-release-x86_64.sh new file mode 100644 index 0000000000..4f328b92a4 --- /dev/null +++ b/thirdparty/maven/all/test_package/conanrunenv-release-x86_64.sh @@ -0,0 +1,14 @@ +script_folder="/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/maven/all/test_package" +echo "echo Restoring environment" > "$script_folder/deactivate_conanrunenv-release-x86_64.sh" +for v in +do + is_defined="true" + value=$(printenv $v) || is_defined="" || true + if [ -n "$value" ] || [ -n "$is_defined" ] + then + echo export "$v='$value'" >> "$script_folder/deactivate_conanrunenv-release-x86_64.sh" + else + echo unset $v >> "$script_folder/deactivate_conanrunenv-release-x86_64.sh" + fi +done + diff --git a/thirdparty/maven/all/test_package/deactivate_conanbuild.sh b/thirdparty/maven/all/test_package/deactivate_conanbuild.sh new file mode 100644 index 0000000000..6763e6a9e6 --- /dev/null +++ b/thirdparty/maven/all/test_package/deactivate_conanbuild.sh @@ -0,0 +1 @@ +. "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/maven/all/test_package/deactivate_conanbuildenv-release-x86_64.sh" \ No newline at end of file diff --git a/thirdparty/maven/all/test_package/deactivate_conanbuildenv-release-x86_64.sh b/thirdparty/maven/all/test_package/deactivate_conanbuildenv-release-x86_64.sh new file mode 100644 index 0000000000..ebffbd0837 --- /dev/null +++ b/thirdparty/maven/all/test_package/deactivate_conanbuildenv-release-x86_64.sh @@ -0,0 +1,5 @@ +echo Restoring environment +unset MAVEN_HOME +unset MAVEN_EXECUTABLE +export PATH='/usr/lib/ccache:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/ubuntu/src/devops/script:/home/ubuntu/src/james/jam-repo/devops/script:/usr/local/cuda/bin' +unset JAVA_HOME diff --git a/thirdparty/maven/all/test_package/deactivate_conanrun.sh b/thirdparty/maven/all/test_package/deactivate_conanrun.sh new file mode 100644 index 0000000000..9c155a41e3 --- /dev/null +++ b/thirdparty/maven/all/test_package/deactivate_conanrun.sh @@ -0,0 +1 @@ +. "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/maven/all/test_package/deactivate_conanrunenv-release-x86_64.sh" \ No newline at end of file diff --git a/thirdparty/maven/config.yml b/thirdparty/maven/config.yml new file mode 100644 index 0000000000..8e2950a3cb --- /dev/null +++ b/thirdparty/maven/config.yml @@ -0,0 +1,7 @@ +versions: + "3.9.6": + folder: all + "3.9.4": + folder: all + "3.9.2": + folder: all diff --git a/thirdparty/mbedtls/all/conandata.yml b/thirdparty/mbedtls/all/conandata.yml new file mode 100644 index 0000000000..f4bba6916f --- /dev/null +++ b/thirdparty/mbedtls/all/conandata.yml @@ -0,0 +1,46 @@ +sources: + "3.6.0": + url: "https://github.com/Mbed-TLS/mbedtls/releases/download/v3.6.0/mbedtls-3.6.0.tar.bz2" + sha256: "3ecf94fcfdaacafb757786a01b7538a61750ebd85c4b024f56ff8ba1490fcd38" + "3.5.2": + url: "https://github.com/Mbed-TLS/mbedtls/archive/mbedtls-3.5.2.tar.gz" + sha256: "eedecc468b3f8d052ef05a9d42bf63f04c8a1c50d1c5a94c251c681365a2c723" + "3.5.1": + url: "https://github.com/Mbed-TLS/mbedtls/archive/mbedtls-3.5.1.tar.gz" + sha256: "0da345cda55ec6f6d71afa84cfae55632a16ba0b8b4644f4d0e8a32c9d1117b0" + "3.5.0": + url: "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.5.0.tar.gz" + sha256: "bdee0e3e45bbf360541306cac0cc27e00402c7a46b9bdf2d24787d5107f008f2" + "3.4.1": + url: "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.4.1.tar.gz" + sha256: "a420fcf7103e54e775c383e3751729b8fb2dcd087f6165befd13f28315f754f5" + "3.2.1": + url: "https://github.com/Mbed-TLS/mbedtls/archive/mbedtls-3.2.1.tar.gz" + sha256: "5850089672560eeaca03dc36678ee8573bb48ef6e38c94f5ce349af60c16da33" + "3.1.0": + url: "https://github.com/Mbed-TLS/mbedtls/archive/mbedtls-3.1.0.tar.gz" + sha256: "64d01a3b22b91cf3a25630257f268f11bc7bfa37981ae6d397802dd4ccec4690" + "3.0.0": + url: "https://github.com/Mbed-TLS/mbedtls/archive/mbedtls-3.0.0.tar.gz" + sha256: "377d376919be19f07c7e7adeeded088a525be40353f6d938a78e4f986bce2ae0" + "2.28.8": + url: "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v2.28.8.tar.gz" + sha256: "4fef7de0d8d542510d726d643350acb3cdb9dc76ad45611b59c9aa08372b4213" + "2.28.4": + url: "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v2.28.4.tar.gz" + sha256: "578c4dcd15bbff3f5cd56aa07cd4f850fc733634e3d5947be4f7157d5bfd81ac" + "2.25.0": + url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.25.0.tar.gz" + sha256: "ea2049c2dd4868693998d5a9780e198194be5aea1706ff4a9d4f882f18c0a101" + "2.24.0": + url: "https://github.com/Mbed-TLS/mbedtls/archive/mbedtls-2.24.0.tar.gz" + sha256: "b5a779b5f36d5fc4cba55faa410685f89128702423ad07b36c5665441a06a5f3" + "2.23.0": + url: "https://github.com/Mbed-TLS/mbedtls/archive/mbedtls-2.23.0.tar.gz" + sha256: "5c8998217402aa1fc734f4afaeac38fad2421470fac4b3abc112bd46391054fe" + "2.16.12": + url: "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.12.tar.gz" + sha256: "0afb4a4ce5b771f2fb86daee786362fbe48285f05b73cd205f46a224ec031783" + "2.16.3": + url: "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.3.tar.gz" + sha256: "ec72ecf39275327f52b5ee9787271313a0d2960e7342b488d223a118ba164caa" diff --git a/thirdparty/mbedtls/all/conanfile.py b/thirdparty/mbedtls/all/conanfile.py new file mode 100644 index 0000000000..86ea879d52 --- /dev/null +++ b/thirdparty/mbedtls/all/conanfile.py @@ -0,0 +1,153 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.microsoft import is_msvc, check_min_vs +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.53.0" + + +class MBedTLSConan(ConanFile): + name = "mbedtls" + description = ( + "mbed TLS makes it trivially easy for developers to include " + "cryptographic and SSL/TLS capabilities in their (embedded) products" + ) + topics = ("polarssl", "tls", "security") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://tls.mbed.org" + license = "Apache-2.0" + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_zlib": [True, False], + "enable_threading": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_zlib": True, + "enable_threading": False, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if Version(self.version) >= "3.0.0": + # ZLIB support has been ditched on version 3.0.0 + del self.options.with_zlib + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.get_safe("with_zlib"): + self.requires("zlib/[>=1.2.11 <2]") + + def validate(self): + if self.settings.os == "Windows": + if self.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} does not support shared build on Windows") + if self.options.enable_threading: + # INFO: Planned: https://github.com/Mbed-TLS/mbedtls/issues/8455 + raise ConanInvalidConfiguration(f"{self.ref} does not support the option enable_threading on Windows") + + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "5": + # The command line flags set are not supported on older versions of gcc + raise ConanInvalidConfiguration( + f"{self.ref} does not support {self.settings.compiler}-{self.settings.compiler.version}" + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if self.options.shared: + tc.preprocessor_definitions["X509_BUILD_SHARED"] = "1" + tc.cache_variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.variables["USE_SHARED_MBEDTLS_LIBRARY"] = self.options.shared + tc.variables["USE_STATIC_MBEDTLS_LIBRARY"] = not self.options.shared + if Version(self.version) < "3.0.0": + tc.variables["ENABLE_ZLIB_SUPPORT"] = self.options.with_zlib + tc.variables["ENABLE_PROGRAMS"] = False + tc.variables["MBEDTLS_FATAL_WARNINGS"] = False + tc.variables["ENABLE_TESTING"] = False + if Version(self.version) < "3.0.0": + # relocatable shared libs on macOS + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + if is_msvc(self): + if check_min_vs(self, 190, raise_invalid=False): + tc.preprocessor_definitions["MBEDTLS_PLATFORM_SNPRINTF_MACRO"] = "snprintf" + else: + tc.preprocessor_definitions["MBEDTLS_PLATFORM_SNPRINTF_MACRO"] = "MBEDTLS_PLATFORM_STD_SNPRINTF" + if self.options.enable_threading: + tc.preprocessor_definitions["MBEDTLS_THREADING_C"] = True + tc.preprocessor_definitions["MBEDTLS_THREADING_PTHREAD"] = True + + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "mbedTLS") + self.cpp_info.set_property("cmake_target_name", "mbedTLS::mbedtls") + + self.cpp_info.components["mbedcrypto"].set_property("cmake_target_name", "mbedTLS::mbedcrypto") + self.cpp_info.components["mbedcrypto"].libs = ["mbedcrypto"] + if self.settings.os == "Windows": + self.cpp_info.components["mbedcrypto"].system_libs = ["bcrypt"] + if Version(self.version) >= "3.6.0": + self.cpp_info.components["mbedcrypto"].set_property("pkg_config_name", "mbedcrypto") + if self.options.enable_threading: + self.cpp_info.components["mbedcrypto"].defines.extend(["MBEDTLS_THREADING_C=1", "MBEDTLS_THREADING_PTHREAD=1"]) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["mbedcrypto"].system_libs.append("pthread") + + self.cpp_info.components["mbedx509"].set_property("cmake_target_name", "mbedTLS::mbedx509") + self.cpp_info.components["mbedx509"].libs = ["mbedx509"] + if self.settings.os == "Windows": + self.cpp_info.components["mbedx509"].system_libs = ["ws2_32"] + self.cpp_info.components["mbedx509"].requires = ["mbedcrypto"] + if Version(self.version) >= "3.6.0": + self.cpp_info.components["mbedx509"].set_property("pkg_config_name", "mbedx509") + + self.cpp_info.components["libmbedtls"].set_property("cmake_target_name", "mbedTLS::mbedtls") + self.cpp_info.components["libmbedtls"].libs = ["mbedtls"] + self.cpp_info.components["libmbedtls"].requires = ["mbedx509"] + if Version(self.version) >= "3.6.0": + self.cpp_info.components["libmbedtls"].set_property("pkg_config_name", "mbedtls") + + if self.options.get_safe("with_zlib"): + for component in self.cpp_info.components: + self.cpp_info.components[component].requires.append("zlib::zlib") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "mbedTLS" + self.cpp_info.names["cmake_find_package_multi"] = "mbedTLS" + self.cpp_info.components["libmbedtls"].names["cmake_find_package"] = "mbedtls" + self.cpp_info.components["libmbedtls"].names["cmake_find_package_multi"] = "mbedtls" diff --git a/thirdparty/mbedtls/all/test_package/CMakeLists.txt b/thirdparty/mbedtls/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..40be1590e6 --- /dev/null +++ b/thirdparty/mbedtls/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +find_package(mbedTLS REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE mbedTLS::mbedtls) diff --git a/thirdparty/mbedtls/all/test_package/conanfile.py b/thirdparty/mbedtls/all/test_package/conanfile.py new file mode 100644 index 0000000000..0a6bc68712 --- /dev/null +++ b/thirdparty/mbedtls/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/mbedtls/all/test_package/test_package.c b/thirdparty/mbedtls/all/test_package/test_package.c new file mode 100644 index 0000000000..a0acf231ee --- /dev/null +++ b/thirdparty/mbedtls/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include "mbedtls/version.h" + +#include + +int main() +{ + char mbedtls_version[18]; + mbedtls_version_get_string_full(mbedtls_version); + printf("version: %s\n", mbedtls_version); + + return 0; +} diff --git a/thirdparty/mbedtls/all/test_v1_package/CMakeLists.txt b/thirdparty/mbedtls/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..b21cc49efd --- /dev/null +++ b/thirdparty/mbedtls/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/thirdparty/mbedtls/all/test_v1_package/conanfile.py b/thirdparty/mbedtls/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..38f4483872 --- /dev/null +++ b/thirdparty/mbedtls/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/mbedtls/config.yml b/thirdparty/mbedtls/config.yml new file mode 100644 index 0000000000..04380df269 --- /dev/null +++ b/thirdparty/mbedtls/config.yml @@ -0,0 +1,31 @@ +versions: + "3.6.0": + folder: all + "3.5.2": + folder: all + "3.5.1": + folder: all + "3.5.0": + folder: all + "3.4.1": + folder: all + "3.2.1": + folder: all + "3.1.0": + folder: all + "3.0.0": + folder: all + "2.28.8": + folder: all + "2.28.4": + folder: all + "2.25.0": + folder: all + "2.24.0": + folder: all + "2.23.0": + folder: all + "2.16.12": + folder: all + "2.16.3": + folder: all diff --git a/thirdparty/open62541/all/CMakeLists.txt b/thirdparty/open62541/all/CMakeLists.txt new file mode 100644 index 0000000000..6a26d2a68b --- /dev/null +++ b/thirdparty/open62541/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.12) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/thirdparty/open62541/all/conandata.yml b/thirdparty/open62541/all/conandata.yml new file mode 100644 index 0000000000..9cecbedaa6 --- /dev/null +++ b/thirdparty/open62541/all/conandata.yml @@ -0,0 +1,23 @@ +sources: + "1.3.3": + url: "https://github.com/open62541/open62541/archive/v1.3.3.tar.gz" + sha256: "52c049c0f107b4cc382c9e480d677a6360cdd96c472f84689af91b423bd108cb" + "1.3.8": + url: "https://github.com/open62541/open62541/archive/v1.3.8.tar.gz" + sha256: "b6943b564787c4953b77ca8d7f987c4b896b3f3e91f45d9f13e9056b6148bc1d" + "1.3.9": + url: "https://github.com/open62541/open62541/archive/v1.3.9.tar.gz" + sha256: "71764d4a060cfa07eae7aaabd176da38b155ef01c63103513339699fd8026e2f" +patches: + "1.3.3": + - patch_file: "patches/open62541.patch" + patch_description: "MINIFICPP-1941: Upgrade OPC UA library to version 1.3.3" + patch_type: "portability" + "1.3.8": + - patch_file: "patches/0001-disable-sanitizers-1_3_x.patch" + patch_description: "Disable static code analysis" + patch_type: "conan" + "1.3.9": + - patch_file: "patches/0001-disable-sanitizers-1_3_x.patch" + patch_description: "Disable static code analysis" + patch_type: "conan" diff --git a/thirdparty/open62541/all/conanfile.py b/thirdparty/open62541/all/conanfile.py new file mode 100644 index 0000000000..7723136cf7 --- /dev/null +++ b/thirdparty/open62541/all/conanfile.py @@ -0,0 +1,455 @@ +from conan import ConanFile +from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain, CMakeDeps +from conan.tools.scm import Version +from conan.tools.files import apply_conandata_patches, collect_libs, export_conandata_patches, copy, rm, rmdir, get +from conan.errors import ConanInvalidConfiguration +import glob +import os +import yaml + +required_conan_version = ">=1.53.0" + + +class Open62541Conan(ConanFile): + name = "open62541" + license = ("MPL-2.0", "CC0-1.0") + homepage = "https://open62541.org/" + url = "https://github.com/conan-io/conan-center-index" + description = "open62541 is an open source and free implementation of OPC UA " \ + "(OPC Unified Architecture) written in the common subset of the " \ + "C99 and C++98 languages. The library is usable with all major " \ + "compilers and provides the necessary tools to implement dedicated " \ + "OPC UA clients and servers, or to integrate OPC UA-based communication " \ + "into existing applications. open62541 library is platform independent. " \ + "All platform-specific functionality is implemented via exchangeable " \ + "plugins. Plugin implementations are provided for the major operating systems." + topics = ( + "opc ua", "sdk", "server/client", "c", "iec-62541", + "industrial automation", "tsn", "time sensitive networks", "publish-subscirbe", "pubsub" + ) + + package_type = "library" + settings = "os", "compiler", "build_type", "arch" + options = { + "fPIC": [True, False], + "shared": [True, False], + # False: UA_ENABLE_HISTORIZING=Off + # True: UA_ENABLE_HISTORIZING=On + # Experimental: UA_ENABLE_HISTORIZING=On and UA_ENABLE_EXPERIMENTAL_HISTORIZING=On + "historize": [True, False, "Experimental"], + "logging_level": ["Fatal", "Error", "Warning", "Info", "Debug", "Trace"], + # False: UA_ENABLE_SUBSCRIPTIONS=Off + # True: UA_ENABLE_SUBSCRIPTIONS=On + # With Events: deprecated. Use 'events' instead + # events: UA_ENABLE_SUBSCRIPTIONS_EVENTS=On + # alarms,conditions,events: UA_ENABLE_SUBSCRIPTIONS_EVENTS=On and UA_ENABLE_SUBSCRIPTIONS_ALARMS_CONDITIONS=On + "subscription": [True, False, "With Events", "events", "alarms,conditions,events"], + # False: UA_ENABLE_METHODCALLS=Off + # True: UA_ENABLE_METHODCALLS=Onn + "methods": [True, False], + # False: UA_ENABLE_NODEMANAGEMENT=Off + # True: UA_ENABLE_NODEMANAGEMENT=On + "dynamic_nodes": [True, False], + # False: UA_ENABLE_AMALGAMATION=Off + # True: UA_ENABLE_AMALGAMATION=On + "single_header": [True, False], + # None: UA_MULTITHREADING=0 + # Threadsafe: UA_MULTITHREADING=100 + # Internal threads: UA_MULTITHREADING=200 + "multithreading": ["None", "Threadsafe", "Internal threads"], + # False: UA_ENABLE_IMMUTABLE_NODES=Off + # True: UA_ENABLE_IMMUTABLE_NODES=On + "imutable_nodes": [True, False], + # False: UA_ENABLE_WEBSOCKET_SERVER=Off + # True: UA_ENABLE_WEBSOCKET_SERVER=On + "web_socket": [True, False], + # False: UA_ENABLE_DISCOVERY=Off + # True: UA_ENABLE_DISCOVERY=On + # With Multicast: Deprecated. Use 'multicast' instead + # multicast: UA_ENABLE_DISCOVERY_MULTICAST=On + # semaphore: UA_ENABLE_DISCOVERY_SEMAPHORE=On + # multicast,semaphore: UA_ENABLE_DISCOVERY_MULTICAST=On and UA_ENABLE_DISCOVERY_SEMAPHORE=On + "discovery": [True, False, "With Multicast", "multicast", "semaphore", "multicast,semaphore"], + # Deprecated. Use discovery=semaphore instead + "discovery_semaphore": [True, False], + # False: UA_ENABLE_QUERY=Off + # True: UA_ENABLE_QUERY=On + "query": [True, False], + # False: UA_ENABLE_ENCRYPTION=Off + # openssl: UA_ENABLE_ENCRYPTION=On and UA_ENABLE_ENCRYPTION_OPENSSL=On + # mbedtls: UA_ENABLE_ENCRYPTION=On + # changed in 1.3.1 - UA_ENABLE_ENCRYPTION can be OFF, OPENSSL, MBEDTLS + "encryption": [False, "openssl", "mbedtls"], + # False: UA_ENABLE_JSON_ENCODING=Off + # True: UA_ENABLE_JSON_ENCODING=On + "json_support": [True, False], + # False: UA_ENABLE_PUBSUB=Off + # Simple: UA_ENABLE_PUBSUB=On + # Ethernet: UA_ENABLE_PUBSUB=On and UA_ENABLE_PUBSUB_ETH_UADP=On + # Ethernet_XDP: UA_ENABLE_PUBSUB=On and UA_ENABLE_PUBSUB_ETH_UADP_XDP=On + "pub_sub": [False, "Simple", "Ethernet", "Ethernet_XDP"], + # False: UA_ENABLE_PUBSUB_ENCRYPTION=Off + # True: UA_ENABLE_PUBSUB_ENCRYPTION=On + "pub_sub_encryption": [True, False], + # False: UA_ENABLE_DA=Off + # True: UA_ENABLE_DA=On + "data_access": [True, False], + # False: UA_ENABLE_NODESET_COMPILER_DESCRIPTIONS=Off and UA_NAMESPACE_ZERO=options.namespace_zero + # True: UA_ENABLE_NODESET_COMPILER_DESCRIPTIONS=On and UA_NAMESPACE_ZERO=Full + "compiled_nodeset_descriptions": [True, False], + # UA_NAMESPACE_ZERO=option.namespace_zero (only if compiled_nodeset_descriptions=False) + "namespace_zero": ["MINIMAL", "REDUCED", "FULL"], + # UA_ENABLE_MICRO_EMB_DEV_PROFILE=embedded_profile + "embedded_profile": [True, False], + # UA_ENABLE_TYPENAMES=typenames + "typenames": [True, False], + # UA_ENABLE_HARDENING=hardening + "hardening": [True, False], + # UA_COMPILE_AS_CXX=cpp_compatible + "cpp_compatible": [True, False], + # UA_ENABLE_STATUSCODE_DESCRIPTIONS=readable_statuscodes + "readable_statuscodes": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + "historize": False, + "logging_level": "Info", + "subscription": True, + "methods": True, + "dynamic_nodes": True, + "single_header": False, + "multithreading": "None", + "imutable_nodes": False, + "web_socket": False, + "discovery": "semaphore", + "discovery_semaphore": True, + "query": False, + "encryption": "mbedtls", + "json_support": False, + "pub_sub": False, + "pub_sub_encryption": False, + "data_access": True, + "compiled_nodeset_descriptions": True, + "namespace_zero": "FULL", + "embedded_profile": False, + "typenames": True, + "hardening": True, + "cpp_compatible": False, + "readable_statuscodes": True, + } + + exports = "submoduledata.yml" + + short_paths = True + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + if Version(self.version) >= "1.3.1": + del self.options.embedded_profile + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + if not self.options.cpp_compatible: + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + # Due to https://github.com/open62541/open62541/issues/4687 we cannot build with 1.2.2 + Windows + shared + if Version(self.version) >= "1.2.2" and self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration( + f"{self.ref} doesn't properly support shared lib on Windows") + + if self.options.subscription == "With Events": + # Deprecated in 1.2.2 + self.output.warning( + f"`{self.ref}:subscription=With Events` is deprecated. Use `{self.ref}:subscription=events` instead") + self.options.subscription = "events" + + if self.options.web_socket: + self.options["libwebsockets"].with_ssl = self.options.encryption + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.encryption == "mbedtls": + # self.requires("mbedtls/2.25.0") + self.requires("mbedtls/2.16.3@minifi/dev") + elif self.options.encryption == "openssl": + self.requires("openssl/[>=1.1 <4]") + if self.options.web_socket: + self.requires("libwebsockets/4.3.2") + if self.options.discovery == "With Multicast" or "multicast" in str(self.options.discovery): + self.requires("pro-mdnsd/0.8.4") + + def validate(self): + if not self.options.subscription: + raise ConanInvalidConfiguration( + "Open62541 requires subscription option") + + if not self.options.discovery: + if self.options.discovery_semaphore: + raise ConanInvalidConfiguration( + "Open62541 discovery sempahore option requires discovery option to be enabled") + + if Version(self.version) < "1.1.0": + if self.options.encryption == "openssl": + raise ConanInvalidConfiguration( + "Lower Open62541 versions than 1.1.0 do not support openssl") + + if self.options.multithreading != "None": + raise ConanInvalidConfiguration( + "Lower Open62541 versions than 1.1.0 do not fully support multithreading") + + if self.options.web_socket: + raise ConanInvalidConfiguration( + "Lower Open62541 versions than 1.1.0 do not fully support websockets") + + if self.options.cpp_compatible: + raise ConanInvalidConfiguration( + "Lower Open62541 versions than 1.1.0 are not cpp compatible due to -fpermisive flags") + + unsupported_clang_version = "8" if Version(self.version) < "1.1.0" else "9" + if self.settings.compiler == "clang" and Version(self.settings.compiler.version) == unsupported_clang_version: + raise ConanInvalidConfiguration( + f"{self.ref} does not support Clang version {self.settings.compiler.version}") + + if self.settings.compiler == "clang": + if Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration( + "Older clang compiler version than 5.0 are not supported") + + if self.options.pub_sub != False and self.settings.os != "Linux": + raise ConanInvalidConfiguration( + "PubSub over Ethernet is not supported for your OS!") + + if self.options.web_socket: + if self.options["libwebsockets"].with_ssl != self.options.encryption: + raise ConanInvalidConfiguration( + "When web_socket is enabled, libwebsockets:with_ssl must have the value of open62541:encryption") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + submodule_filename = os.path.join( + self.recipe_folder, 'submoduledata.yml') + with open(submodule_filename, 'r') as submodule_stream: + submodules_data = yaml.safe_load(submodule_stream) + for path, submodule in submodules_data["submodules"][self.version].items(): + archive_name = os.path.splitext( + os.path.basename(submodule["url"]))[0] + get(self, url=submodule["url"], + sha256=submodule["sha256"], + destination=path, + filename=archive_name, + strip_root=True) + + def _get_log_level(self): + return { + "Fatal": "600", + "Error": "500", + "Warning": "400", + "Info": "300", + "Debug": "200", + "Trace": "100", + "PackageOption": "300" + }.get(str(self.options.logging_level), "300") + + def _get_multithreading_option(self): + return { + "None": "0", + "Threadsafe": "100", + "Internal threads": "200" + }.get(str(self.options.multithreading), "0") + + def generate(self): + tc = CMakeToolchain(self) + + version = Version(self.version) + tc.variables["OPEN62541_VER_MAJOR"] = version.major + tc.variables["OPEN62541_VER_MINOR"] = version.minor + tc.variables["OPEN62541_VER_PATCH"] = version.patch + + tc.variables["UA_LOGLEVEL"] = self._get_log_level() + tc.variables["UA_ENABLE_SUBSCRIPTIONS"] = self.options.subscription != False + + if self.options.subscription != False: + if "events" in str(self.options.subscription): + tc.variables["UA_ENABLE_SUBSCRIPTIONS_EVENTS"] = True + if "alarms" in str(self.options.subscription) and "conditions" in str(self.options.subscription): + tc.variables["UA_ENABLE_SUBSCRIPTIONS_ALARMS_CONDITIONS"] = True + + tc.variables["UA_ENABLE_METHODCALLS"] = self.options.methods + tc.variables["UA_ENABLE_NODEMANAGEMENT"] = self.options.dynamic_nodes + tc.variables["UA_ENABLE_AMALGAMATION"] = self.options.single_header + + if version >= "1.1.3": + tc.variables["UA_MULTITHREADING"] = self._get_multithreading_option() + + tc.variables["UA_ENABLE_IMMUTABLE_NODES"] = self.options.imutable_nodes + tc.variables["UA_ENABLE_WEBSOCKET_SERVER"] = self.options.web_socket + tc.variables["UA_ENABLE_HISTORIZING"] = self.options.historize != False + + if self.options.historize != False: + if self.options.historize == "Experimental": + tc.variables["UA_ENABLE_EXPERIMENTAL_HISTORIZING"] = True + + tc.variables["UA_ENABLE_DISCOVERY"] = self.options.discovery != False + + if self.options.discovery != False: + tc.variables["UA_ENABLE_DISCOVERY_MULTICAST"] = \ + self.options.discovery == "With Multicast" or "multicast" in str( + self.options.discovery) + tc.variables["UA_ENABLE_DISCOVERY_SEMAPHORE"] = \ + self.options.discovery_semaphore or "semaphore" in str( + self.options.discovery) + + tc.variables["UA_ENABLE_QUERY"] = self.options.query + + if Version(self.version) >= "1.3.1": + if self.options.encryption == "openssl": + tc.variables["UA_ENABLE_ENCRYPTION"] = "OPENSSL" + elif self.options.encryption == "mbedtls": + tc.variables["UA_ENABLE_ENCRYPTION"] = "MBEDTLS" + tc.variables["UA_FORCE_WERROR"] = "OFF" + else: + tc.variables["UA_ENABLE_ENCRYPTION"] = "OFF" + else: + tc.variables["UA_ENABLE_ENCRYPTION"] = self.options.encryption != False + if self.options.encryption != False: + if self.options.encryption == "openssl": + tc.variables["UA_ENABLE_ENCRYPTION_OPENSSL"] = True + + tc.variables["UA_ENABLE_JSON_ENCODING"] = self.options.json_support + tc.variables["UA_ENABLE_PUBSUB"] = self.options.pub_sub != False + tc.variables["UA_ENABLE_PUBSUB_ENCRYPTION"] = self.options.pub_sub_encryption != False + + if self.options.pub_sub != False: + if self.settings.os == "Linux" and self.options.pub_sub == "Ethernet": + tc.variables["UA_ENABLE_PUBSUB_ETH_UADP"] = True + elif self.settings.os == "Linux" and self.options.pub_sub == "Ethernet_XDP": + tc.variables["UA_ENABLE_PUBSUB_ETH_UADP_XDP"] = True + tc.variables["UA_ENABLE_DA"] = self.options.data_access + + if self.options.compiled_nodeset_descriptions == True: + tc.variables["UA_ENABLE_NODESET_COMPILER_DESCRIPTIONS"] = self.options.compiled_nodeset_descriptions + tc.variables["UA_NAMESPACE_ZERO"] = "FULL" + else: + tc.variables["UA_NAMESPACE_ZERO"] = self.options.namespace_zero + if Version(self.version) < "1.3.1": + tc.variables["UA_ENABLE_MICRO_EMB_DEV_PROFILE"] = self.options.embedded_profile + + tc.variables["UA_ENABLE_TYPENAMES"] = self.options.typenames + tc.variables["UA_ENABLE_STATUSCODE_DESCRIPTIONS"] = self.options.readable_statuscodes + tc.variables["UA_ENABLE_HARDENING"] = self.options.hardening + + if self.settings.compiler == "msvc" and self.options.shared == True: + tc.variables["UA_MSVC_FORCE_STATIC_CRT"] = True + + tc.variables["UA_COMPILE_AS_CXX"] = self.options.cpp_compatible + + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + if Version(self.version) >= "1.3.1": + os.unlink(os.path.join(self.source_folder, "tools", "cmake", "FindPython3.cmake")) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + @property + def _tools_subfolder(self): + return os.path.join(self.source_folder, "tools") + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake", "open62541") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, "open62541Macros.cmake") + + def package(self): + licenses_dir = os.path.join(self.package_folder, "licenses") + copy(self, "LICENSE", src=self.source_folder, dst=licenses_dir) + copy(self, "LICENSE-CC0", src=self.source_folder, dst=licenses_dir) + cmake = CMake(self) + cmake.install() + + rm(self, '*.pdb', os.path.join(self.package_folder, "bin")) + rm(self, '*.pdb', os.path.join(self.package_folder, "lib")) + + for cmake_file in glob.glob(os.path.join(self.package_folder, self._module_subfolder, "*")): + if not cmake_file.endswith(self._module_file_rel_path): + os.remove(cmake_file) + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + tools_dir = os.path.join(self.package_folder, "res", "tools") + copy(self, "generate_*.py", src=self._tools_subfolder, dst=tools_dir) + copy(self, "nodeset_compiler/*", src=self._tools_subfolder, dst=tools_dir) + + @staticmethod + def _chmod_plus_x(filename): + if os.name == 'posix': + os.chmod(filename, os.stat(filename).st_mode | 0o111) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "open62541" + self.cpp_info.names["cmake_find_package_multi"] = "open62541" + self.cpp_info.names["pkg_config"] = "open62541" + self.cpp_info.libs = collect_libs(self) + self.cpp_info.includedirs = ["include"] + + # required for creating custom servers from ua-nodeset + self.conf_info.define("user.open62541:tools_dir", os.path.join( + self.package_folder, "res", "tools").replace("\\", "/")) + # v1 legacy support for tools_dir definition + self.user_info.tools_dir = os.path.join( + self.package_folder, "res", "tools").replace("\\", "/") + self._chmod_plus_x(os.path.join(self.package_folder, + "res", "tools", "generate_nodeid_header.py")) + + if self.options.single_header: + self.cpp_info.defines.append("UA_ENABLE_AMALGAMATION") + else: + self.cpp_info.includedirs.append( + os.path.join("include", "open62541", "plugin")) + if self.settings.os == "Windows": + self.cpp_info.includedirs.append( + os.path.join("include", "open62541", "win32")) + else: + self.cpp_info.includedirs.append( + os.path.join("include", "open62541", "posix")) + + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") + elif self.settings.os in ("Linux", "FreeBSD"): + self.cpp_info.system_libs.extend(["pthread", "m", "rt"]) + + self.cpp_info.builddirs.append(self._module_subfolder) + # v1 legacy support for open62541Macros.cmake auto-include + self.cpp_info.build_modules["cmake_find_package"] = [ + self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [ + self._module_file_rel_path] + self.cpp_info.set_property("cmake_build_modules", [ + self._module_file_rel_path]) diff --git a/thirdparty/open62541/all/patches/0001-disable-sanitizers-1_3_x.patch b/thirdparty/open62541/all/patches/0001-disable-sanitizers-1_3_x.patch new file mode 100644 index 0000000000..a2c9d60322 --- /dev/null +++ b/thirdparty/open62541/all/patches/0001-disable-sanitizers-1_3_x.patch @@ -0,0 +1,24 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5300b12f6..9a80321da 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -749,19 +749,6 @@ if(NOT UA_FORCE_CPP AND (CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" ST + # Linker + set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default + +- # Debug +- if(BUILD_TYPE_LOWER_CASE STREQUAL "debug" AND UNIX AND NOT UA_BUILD_OSS_FUZZ AND +- "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang" AND NOT UA_ENABLE_UNIT_TESTS_MEMCHECK) +- # Add default sanitizer settings when using clang and Debug build. +- # This allows e.g. CLion to find memory locations for SegFaults +- message(STATUS "Sanitizer enabled") +- set(SANITIZER_FLAGS "-g -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=leak -fsanitize=undefined") +- if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) +- set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize-coverage=trace-pc-guard") +- endif() +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") +- endif() + + if(NOT MINGW AND UA_ENABLE_HARDENING AND ((CMAKE_BUILD_TYPE STREQUAL "Release") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))) + check_add_cc_flag("-D_FORTIFY_SOURCE=2") # run-time buffer overflow detection (needs at least -O1) diff --git a/thirdparty/open62541/open62541.patch b/thirdparty/open62541/all/patches/open62541.patch similarity index 100% rename from thirdparty/open62541/open62541.patch rename to thirdparty/open62541/all/patches/open62541.patch diff --git a/thirdparty/open62541/all/submoduledata.yml b/thirdparty/open62541/all/submoduledata.yml new file mode 100644 index 0000000000..625e1bcaf8 --- /dev/null +++ b/thirdparty/open62541/all/submoduledata.yml @@ -0,0 +1,16 @@ +submodules: + "1.3.3": + deps/ua-nodeset: + sha256: 032c93e3f7c335bbb2d2d699804a804c9cdce2a2ecc3fe7cde552f2130982c26 + url: https://github.com/OPCFoundation/UA-Nodeset/archive/Glass=1.0.0-2022-01-01.zip + archive_pattern: "UA-Nodeset-{version}" + "1.3.8": + deps/ua-nodeset: + sha256: 032c93e3f7c335bbb2d2d699804a804c9cdce2a2ecc3fe7cde552f2130982c26 + url: https://github.com/OPCFoundation/UA-Nodeset/archive/Glass=1.0.0-2022-01-01.zip + archive_pattern: "UA-Nodeset-{version}" + "1.3.9": + deps/ua-nodeset: + sha256: 032c93e3f7c335bbb2d2d699804a804c9cdce2a2ecc3fe7cde552f2130982c26 + url: https://github.com/OPCFoundation/UA-Nodeset/archive/Glass=1.0.0-2022-01-01.zip + archive_pattern: "UA-Nodeset-{version}" diff --git a/thirdparty/open62541/all/test_package/CMakeLists.txt b/thirdparty/open62541/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..099ba922c1 --- /dev/null +++ b/thirdparty/open62541/all/test_package/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +find_package(open62541 REQUIRED CONFIG) +find_package(Threads REQUIRED) + +find_package(Python3 REQUIRED) +set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + +# Output directory for Nodeset Compiler +set(GENERATE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/src_generated/") +file(MAKE_DIRECTORY "${GENERATE_OUTPUT_DIR}") +include_directories("${GENERATE_OUTPUT_DIR}") +ua_generate_nodeset_and_datatypes( + NAME "foo_flt" + TARGET_PREFIX "${PROJECT_NAME}" + FILE_CSV "${PROJECT_SOURCE_DIR}/FooFltModel.csv" + FILE_BSD "${PROJECT_SOURCE_DIR}/FooFlt.Types.bsd" + OUTPUT_DIR "${GENERATE_OUTPUT_DIR}" + NAMESPACE_IDX 2 # This namespace index must match the order in which you are adding the nodeset in the source code + NAMESPACE_MAP "2:https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/" + FILE_NS "${PROJECT_SOURCE_DIR}/FooFlt.NodeSet2.xml" + INTERNAL +) +# Previous macro automatically sets some variables which hold the generated source code files using the provided NAME +add_executable(${PROJECT_NAME} + ${UA_NODESET_FOO_FLT_SOURCES} + ${UA_TYPES_FOO_FLT_SOURCES} + test_package.c +) + +# Make sure the nodeset compiler is executed before compiling the main file +add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-ns-foo_flt) +target_link_libraries(${PROJECT_NAME} PRIVATE open62541::open62541) diff --git a/thirdparty/open62541/all/test_package/FooFlt.NodeSet2.xml b/thirdparty/open62541/all/test_package/FooFlt.NodeSet2.xml new file mode 100644 index 0000000000..59b67944e9 --- /dev/null +++ b/thirdparty/open62541/all/test_package/FooFlt.NodeSet2.xml @@ -0,0 +1,282 @@ + + + + https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/ + + + + + + + + i=1 + i=2 + i=3 + i=4 + i=5 + i=6 + i=7 + i=8 + i=9 + i=10 + i=11 + i=13 + i=12 + i=15 + i=14 + i=16 + i=17 + i=18 + i=20 + i=21 + i=19 + i=22 + i=26 + i=27 + i=28 + i=47 + i=46 + i=35 + i=36 + i=48 + i=45 + i=40 + i=37 + i=38 + i=39 + + + ApeType + The Automatic Surface Tabulator. It represents a single hardware unit. + + ns=1;i=2 + ns=1;i=3 + ns=1;i=4 + i=58 + + + + Name + + i=68 + i=78 + ns=1;i=1 + + + + Number + + i=68 + i=78 + ns=1;i=1 + + + + MyVariable + + ns=1;i=8 + i=2368 + i=78 + ns=1;i=1 + + + + EURange + + i=68 + i=78 + ns=1;i=4 + + + + FooAnalogItemType + + i=2368 + + + + TestDataType + + i=22 + + + + + + + Ape + Instance of the APE. + + ns=1;i=18 + ns=1;i=19 + ns=1;i=20 + i=85 + ns=1;i=1 + + + + Name + + i=68 + ns=1;i=17 + + + + Number + + i=68 + ns=1;i=17 + + + + MyVariable + + ns=1;i=24 + i=2368 + ns=1;i=17 + + + + EURange + + i=68 + ns=1;i=20 + + + + Default Binary + + ns=1;i=16 + ns=1;i=31 + i=76 + + + + FooFlt + + ns=1;i=29 + ns=1;i=30 + ns=1;i=31 + i=93 + i=72 + + + PG9wYzpUeXBlRGljdGlvbmFyeQ0KICB4bWxuczpvcGM9Imh0dHA6Ly9vcGNmb3VuZGF0aW9uLm9y +Zy9CaW5hcnlTY2hlbWEvIg0KICB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1M +U2NoZW1hLWluc3RhbmNlIg0KICB4bWxuczp1YT0iaHR0cDovL29wY2ZvdW5kYXRpb24ub3JnL1VB +LyINCiAgeG1sbnM6dG5zPSJodHRwczovL25ldy5mb28uY29tL3plYnJhLWNvbXByZXNzaW9uL2Zs +YXR0ZW5pbmctYW5kLXN1YnNwYWNlZm9sZGluZy9VQS8iDQogIERlZmF1bHRCeXRlT3JkZXI9Ikxp +dHRsZUVuZGlhbiINCiAgVGFyZ2V0TmFtZXNwYWNlPSJodHRwczovL25ldy5mb28uY29tL3plYnJh +LWNvbXByZXNzaW9uL2ZsYXR0ZW5pbmctYW5kLXN1YnNwYWNlZm9sZGluZy9VQS8iDQo+DQogIDxv +cGM6SW1wb3J0IE5hbWVzcGFjZT0iaHR0cDovL29wY2ZvdW5kYXRpb24ub3JnL1VBLyIgTG9jYXRp +b249Ii5CaW5hcnlTY2hlbWEuYnNkIi8+DQoNCiAgPG9wYzpTdHJ1Y3R1cmVkVHlwZSBOYW1lPSJU +ZXN0RGF0YVR5cGUiIEJhc2VUeXBlPSJ1YTpFeHRlbnNpb25PYmplY3QiPg0KICAgIDxvcGM6Rmll +bGQgTmFtZT0idGVzdEludCIgVHlwZU5hbWU9Im9wYzpJbnQzMiIgLz4NCiAgPC9vcGM6U3RydWN0 +dXJlZFR5cGU+DQoNCjwvb3BjOlR5cGVEaWN0aW9uYXJ5Pg== + + + + NamespaceUri + + i=68 + ns=1;i=27 + + + https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/ + + + + Deprecated + + i=68 + ns=1;i=27 + + + true + + + + TestDataType + + i=69 + ns=1;i=27 + + + TestDataType + + + + Default XML + + ns=1;i=16 + ns=1;i=39 + i=76 + + + + FooFlt + + ns=1;i=37 + ns=1;i=38 + ns=1;i=39 + i=92 + i=72 + + + PHhzOnNjaGVtYQ0KICB4bWxuczp4cz0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEi +DQogIHhtbG5zOnVhPSJodHRwOi8vb3BjZm91bmRhdGlvbi5vcmcvVUEvMjAwOC8wMi9UeXBlcy54 +c2QiDQogIHhtbG5zOnRucz0iaHR0cHM6Ly9uZXcuZm9vLmNvbS96ZWJyYS1jb21wcmVzc2lvbi9m +bGF0dGVuaW5nLWFuZC1zdWJzcGFjZWZvbGRpbmcvVUEvIg0KICB0YXJnZXROYW1lc3BhY2U9Imh0 +dHBzOi8vbmV3LmZvby5jb20vemVicmEtY29tcHJlc3Npb24vZmxhdHRlbmluZy1hbmQtc3Vic3Bh +Y2Vmb2xkaW5nL1VBLyINCiAgZWxlbWVudEZvcm1EZWZhdWx0PSJxdWFsaWZpZWQiDQo+DQogIDx4 +czppbXBvcnQgbmFtZXNwYWNlPSJodHRwOi8vb3BjZm91bmRhdGlvbi5vcmcvVUEvIiAvPg0KDQog +IDx4czpjb21wbGV4VHlwZSBuYW1lPSJUZXN0RGF0YVR5cGUiPg0KICAgIDx4czpzZXF1ZW5jZT4N +CiAgICAgIDx4czplbGVtZW50IG5hbWU9InRlc3RJbnQiIHR5cGU9InhzOmludCIgbWluT2NjdXJz +PSIwIiAvPg0KICAgIDwveHM6c2VxdWVuY2U+DQogIDwveHM6Y29tcGxleFR5cGU+DQogIDx4czpl +bGVtZW50IG5hbWU9IlRlc3REYXRhVHlwZSIgdHlwZT0idG5zOlRlc3REYXRhVHlwZSIgLz4NCg0K +ICA8eHM6Y29tcGxleFR5cGUgbmFtZT0iTGlzdE9mVGVzdERhdGFUeXBlIj4NCiAgICA8eHM6c2Vx +dWVuY2U+DQogICAgICA8eHM6ZWxlbWVudCBuYW1lPSJUZXN0RGF0YVR5cGUiIHR5cGU9InRuczpU +ZXN0RGF0YVR5cGUiIG1pbk9jY3Vycz0iMCIgbWF4T2NjdXJzPSJ1bmJvdW5kZWQiIG5pbGxhYmxl +PSJ0cnVlIiAvPg0KICAgIDwveHM6c2VxdWVuY2U+DQogIDwveHM6Y29tcGxleFR5cGU+DQogIDx4 +czplbGVtZW50IG5hbWU9Ikxpc3RPZlRlc3REYXRhVHlwZSIgdHlwZT0idG5zOkxpc3RPZlRlc3RE +YXRhVHlwZSIgbmlsbGFibGU9InRydWUiPjwveHM6ZWxlbWVudD4NCg0KPC94czpzY2hlbWE+ + + + + NamespaceUri + + i=68 + ns=1;i=35 + + + https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/ + + + + Deprecated + + i=68 + ns=1;i=35 + + + true + + + + TestDataType + + i=69 + ns=1;i=35 + + + //xs:element[@name='TestDataType'] + + + + Default JSON + + ns=1;i=16 + i=76 + + + diff --git a/thirdparty/open62541/all/test_package/FooFlt.Types.bsd b/thirdparty/open62541/all/test_package/FooFlt.Types.bsd new file mode 100644 index 0000000000..ffd89ccecc --- /dev/null +++ b/thirdparty/open62541/all/test_package/FooFlt.Types.bsd @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/thirdparty/open62541/all/test_package/FooFltModel.csv b/thirdparty/open62541/all/test_package/FooFltModel.csv new file mode 100644 index 0000000000..e39f643bed --- /dev/null +++ b/thirdparty/open62541/all/test_package/FooFltModel.csv @@ -0,0 +1,42 @@ +ApeType,1,ObjectType +ApeType_Name,2,Variable +ApeType_Number,3,Variable +ApeType_MyVariable,4,Variable +ApeType_MyVariable_Definition,5,Variable +ApeType_MyVariable_ValuePrecision,6,Variable +ApeType_MyVariable_InstrumentRange,7,Variable +ApeType_MyVariable_EURange,8,Variable +ApeType_MyVariable_EngineeringUnits,9,Variable +FooAnalogItemType,10,VariableType +FooAnalogItemType_Definition,11,Variable +FooAnalogItemType_ValuePrecision,12,Variable +FooAnalogItemType_InstrumentRange,13,Variable +FooAnalogItemType_EURange,14,Variable +FooAnalogItemType_EngineeringUnits,15,Variable +TestDataType,16,DataType +Ape,17,Object +Ape_Name,18,Variable +Ape_Number,19,Variable +Ape_MyVariable,20,Variable +Ape_MyVariable_Definition,21,Variable +Ape_MyVariable_ValuePrecision,22,Variable +Ape_MyVariable_InstrumentRange,23,Variable +Ape_MyVariable_EURange,24,Variable +Ape_MyVariable_EngineeringUnits,25,Variable +TestDataType_Encoding_DefaultBinary,26,Object +FooZbrFlt_BinarySchema,27,Variable +FooZbrFlt_BinarySchema_DataTypeVersion,28,Variable +FooZbrFlt_BinarySchema_NamespaceUri,29,Variable +FooZbrFlt_BinarySchema_Deprecated,30,Variable +FooZbrFlt_BinarySchema_TestDataType,31,Variable +FooZbrFlt_BinarySchema_TestDataType_DataTypeVersion,32,Variable +FooZbrFlt_BinarySchema_TestDataType_DictionaryFragment,33,Variable +TestDataType_Encoding_DefaultXml,34,Object +FooZbrFlt_XmlSchema,35,Variable +FooZbrFlt_XmlSchema_DataTypeVersion,36,Variable +FooZbrFlt_XmlSchema_NamespaceUri,37,Variable +FooZbrFlt_XmlSchema_Deprecated,38,Variable +FooZbrFlt_XmlSchema_TestDataType,39,Variable +FooZbrFlt_XmlSchema_TestDataType_DataTypeVersion,40,Variable +FooZbrFlt_XmlSchema_TestDataType_DictionaryFragment,41,Variable +TestDataType_Encoding_DefaultJson,42,Object diff --git a/thirdparty/open62541/all/test_package/conanfile.py b/thirdparty/open62541/all/test_package/conanfile.py new file mode 100644 index 0000000000..c1fe645c77 --- /dev/null +++ b/thirdparty/open62541/all/test_package/conanfile.py @@ -0,0 +1,36 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + self.requires("ua-nodeset/padim-1.02-2021-07-21") + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["open62541_NODESET_DIR"] = self.dependencies["ua-nodeset"].conf_info.get( + "user.ua-nodeset:nodeset_dir").replace("\\", "/") # sanitize path for windows systems + tc.variables["open62541_TOOLS_DIR"] = self.dependencies["open62541"].conf_info.get( + "user.open62541:tools_dir") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/open62541/all/test_package/test_package.c b/thirdparty/open62541/all/test_package/test_package.c new file mode 100644 index 0000000000..31232fcb70 --- /dev/null +++ b/thirdparty/open62541/all/test_package/test_package.c @@ -0,0 +1,75 @@ +#ifdef UA_ENABLE_AMALGAMATION +#include +#else +#include +#include +#include +#include +#endif + +/* Files namespace_foo_flt_generated.h and namespace_foo_flt_generated.c are created from FooFlt.NodeSet2.xml in the + * /src_generated directory by CMake */ +#include "foo_flt_nodeids.h" +#include "namespace_foo_flt_generated.h" +#include +#include +#include + +UA_Boolean running = false; + +static void server_stop_callback(UA_Server *server, void *data) { + UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "stopping server due to timer"); + running = false; +} + +int main(void) { + UA_Server *server = UA_Server_new(); + running = true; + UA_StatusCode return_code; + UA_UInt16 portNumber = 4840; + UA_ServerConfig_setMinimal(UA_Server_getConfig(server), portNumber, NULL); + UA_Server_addRepeatedCallback(server, server_stop_callback, NULL, 500., NULL); + + /* create nodes from nodeset */ + if(namespace_foo_flt_generated(server) != UA_STATUSCODE_GOOD) + { + UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Could not add the Foo FLT nodeset. " + "Check previous output for any error."); + return_code = UA_STATUSCODE_BADUNEXPECTEDERROR; + } + else + { + // Do some additional stuff with the nodes + // this will just get the namespace index, since it is already added to the server + UA_UInt16 nsIdx = UA_Server_addNamespace(server, "https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/"); + UA_NodeId testInstanceId = UA_NODEID_NUMERIC(nsIdx, UA_FOO_FLTID_APE); + UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "The Ape has ns=%d;id=%d", + testInstanceId.namespaceIndex, testInstanceId.identifier.numeric); + + return_code = UA_Server_run(server, &running); + + while(return_code == UA_STATUSCODE_BADCOMMUNICATIONERROR) + { + running = false; + portNumber = portNumber + 1; + UA_Server_getConfig(server)->networkLayersSize = 0; + UA_ServerConfig_addNetworkLayerTCP(UA_Server_getConfig(server), portNumber, 0, 0); + running = true; + return_code = UA_Server_run(server, &running); + + if(return_code == UA_STATUSCODE_GOOD) + { + printf("free port found"); + break; + } + else if(portNumber>4850) + { + printf("ports from 4840 to 4850 are not avilable"); + break; + } + } + } + running = false; + UA_Server_delete(server); + return return_code == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/thirdparty/open62541/config.yml b/thirdparty/open62541/config.yml new file mode 100644 index 0000000000..d22a18eb7f --- /dev/null +++ b/thirdparty/open62541/config.yml @@ -0,0 +1,7 @@ +versions: + "1.3.3": + folder: all + "1.3.8": + folder: all + "1.3.9": + folder: all diff --git a/thirdparty/opencv/4.x/conandata.yml b/thirdparty/opencv/4.x/conandata.yml new file mode 100644 index 0000000000..d536778d0c --- /dev/null +++ b/thirdparty/opencv/4.x/conandata.yml @@ -0,0 +1,180 @@ +sources: + "4.9.0": + - url: "https://github.com/opencv/opencv/archive/refs/tags/4.9.0.tar.gz" + sha256: "ddf76f9dffd322c7c3cb1f721d0887f62d747b82059342213138dc190f28bc6c" + - url: "https://github.com/opencv/opencv_contrib/archive/refs/tags/4.9.0.tar.gz" + sha256: "8952c45a73b75676c522dd574229f563e43c271ae1d5bbbd26f8e2b6bc1a4dae" + "4.8.1": + - url: "https://github.com/opencv/opencv/archive/refs/tags/4.8.1.tar.gz" + sha256: "62f650467a60a38794d681ae7e66e3e8cfba38f445e0bf87867e2f2cdc8be9d5" + - url: "https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.tar.gz" + sha256: "0c082a0b29b3118f2a0a1856b403bb098643af7b994a0080f402a12159a99c6e" + "4.5.5": + - url: "https://github.com/opencv/opencv/archive/refs/tags/4.5.5.tar.gz" + sha256: "a1cfdcf6619387ca9e232687504da996aaa9f7b5689986b8331ec02cb61d28ad" + - url: "https://github.com/opencv/opencv_contrib/archive/refs/tags/4.5.5.tar.gz" + sha256: "a97c2eaecf7a23c6dbd119a609c6d7fae903e5f9ff5f1fe678933e01c67a6c11" + "4.5.3": + - url: "https://github.com/opencv/opencv/archive/refs/tags/4.5.3.tar.gz" + sha256: "77f616ae4bea416674d8c373984b20c8bd55e7db887fd38c6df73463a0647bab" + - url: "https://github.com/opencv/opencv_contrib/archive/refs/tags/4.5.3.tar.gz" + sha256: "73da052fd10e73aaba2560eaff10cc5177e2dcc58b27f8aedf7c649e24c233bc" + "4.1.2": + - url: "https://github.com/opencv/opencv/archive/refs/tags/4.1.2.tar.gz" + sha256: "385dd0a9c25e67ef0dd60e022d2a2d7b17e2f36819cf3cb46aa8cdff5c5282c9" + - url: "https://github.com/opencv/opencv_contrib/archive/refs/tags/4.1.2.tar.gz" + sha256: "0f6c3d30baa39e3e7611afb481ee86dea45dafb182cac87d570c95dccd83eb8b" +patches: + "4.9.0": + - patch_file: "patches/4.5.5-0001-find-openexr.patch" + patch_description: "Robust discovery & injection of OpenEXR" + patch_type: "conan" + - patch_file: "patches/4.5.5-0003-find-quirc.patch" + patch_description: "Robust discovery & injection of quirc" + patch_type: "conan" + - patch_file: "patches/4.8.1-0001-find-ade.patch" + patch_description: "Robust discovery & injection of ade" + patch_type: "conan" + - patch_file: "patches/4.5.1-0001-tracking-no-plot-deps.patch" + patch_description: "Fix requirements of tracking module" + patch_type: "conan" + - patch_file: "patches/4.1.2-0006-hdf.patch" + patch_description: "Robust discovery of hdf" + patch_type: "conan" + - patch_file: "patches/4.5.2-0001-fix-zlib-static-android.patch" + patch_description: "Fix discovery of zlib static if Android" + patch_type: "conan" + - patch_file: "patches/4.1.2-0007-android-install-layout.patch" + patch_description: "Honor install layout from conan if Android" + patch_type: "conan" + "4.8.1": + - patch_file: "patches/4.5.5-0001-find-openexr.patch" + patch_description: "Robust discovery & injection of OpenEXR" + patch_type: "conan" + - patch_file: "patches/4.5.5-0003-find-quirc.patch" + patch_description: "Robust discovery & injection of quirc" + patch_type: "conan" + - patch_file: "patches/4.8.1-0004-link-qt-targets.patch" + patch_description: "Link to Qt through CMake targets" + patch_type: "conan" + - patch_file: "patches/4.8.1-0001-find-ade.patch" + patch_description: "Robust discovery & injection of ade" + patch_type: "conan" + - patch_file: "patches/4.5.1-0001-tracking-no-plot-deps.patch" + patch_description: "Fix requirements of tracking module" + patch_type: "conan" + - patch_file: "patches/4.1.2-0006-hdf.patch" + patch_description: "Robust discovery of hdf" + patch_type: "conan" + - patch_file: "patches/4.5.2-0001-fix-zlib-static-android.patch" + patch_description: "Fix discovery of zlib static if Android" + patch_type: "conan" + - patch_file: "patches/4.1.2-0007-android-install-layout.patch" + patch_description: "Honor install layout from conan if Android" + patch_type: "conan" + - patch_file: "patches/4.8.1-0002-mingw-disable-obsensor.patch" + patch_description: "MinGW: disable obsensor to avoid build issue" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv/pull/24478" + "4.5.5": + - patch_file: "patches/4.5.5-0001-find-openexr.patch" + patch_description: "Robust discovery & injection of OpenEXR" + patch_type: "conan" + - patch_file: "patches/4.5.5-0002-objdetect-without-dnn.patch" + patch_description: "Allow to build objdetect module without dnn" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv/pull/21369" + - patch_file: "patches/4.5.5-0003-find-quirc.patch" + patch_description: "Robust discovery & injection of quirc" + patch_type: "conan" + - patch_file: "patches/4.5.5-0004-link-qt-targets.patch" + patch_description: "Link to Qt through CMake targets" + patch_type: "conan" + - patch_file: "patches/4.5.0-0002-find-ade.patch" + patch_description: "Robust discovery & injection of ade" + patch_type: "conan" + - patch_file: "patches/4.5.1-0001-tracking-no-plot-deps.patch" + patch_description: "Fix requirements of tracking module" + patch_type: "conan" + - patch_file: "patches/4.5.1-0002-alphamat-header.patch" + patch_description: "Add missing header in alphamat.hpp" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv_contrib/pull/3422" + - patch_file: "patches/4.1.2-0006-hdf.patch" + patch_description: "Robust discovery of hdf" + patch_type: "conan" + - patch_file: "patches/4.5.2-0001-fix-zlib-static-android.patch" + patch_description: "Fix discovery of zlib static if Android" + patch_type: "conan" + - patch_file: "patches/4.1.2-0007-android-install-layout.patch" + patch_description: "Honor install layout from conan if Android" + patch_type: "conan" + "4.5.3": + - patch_file: "patches/4.5.3-0001-find-openexr.patch" + patch_description: "Robust discovery & injection of OpenEXR" + patch_type: "conan" + - patch_file: "patches/4.5.3-0002-link-qt-targets.patch" + patch_description: "Link to Qt through CMake targets" + patch_type: "conan" + - patch_file: "patches/4.5.0-0002-find-ade.patch" + patch_description: "Robust discovery & injection of ade" + patch_type: "conan" + - patch_file: "patches/4.1.2-0003-find-quirc.patch" + patch_description: "Robust discovery & injection of quirc" + patch_type: "conan" + - patch_file: "patches/4.5.1-0001-tracking-no-plot-deps.patch" + patch_description: "Fix requirements of tracking module" + patch_type: "conan" + - patch_file: "patches/4.5.1-0002-alphamat-header.patch" + patch_description: "Add missing header in alphamat.hpp" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv_contrib/pull/3422" + - patch_file: "patches/4.1.2-0006-hdf.patch" + patch_description: "Robust discovery of hdf" + patch_type: "conan" + - patch_file: "patches/4.5.2-0001-fix-zlib-static-android.patch" + patch_description: "Fix discovery of zlib static if Android" + patch_type: "conan" + - patch_file: "patches/4.1.2-0007-android-install-layout.patch" + patch_description: "Honor install layout from conan if Android" + patch_type: "conan" + - patch_file: "patches/4.1.2-0010-compat-protobuf-ge-3.18.patch" + patch_description: "Compatibility with protobuf >= 3.18" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv/pull/20386" + "4.1.2": + - patch_file: "patches/4.1.2-0001-find-openexr.patch" + patch_description: "Robust discovery & injection of OpenEXR" + patch_type: "conan" + - patch_file: "patches/4.1.2-0002-find-ade.patch" + patch_description: "Robust discovery & injection of ade" + patch_type: "conan" + - patch_file: "patches/4.1.2-0003-find-quirc.patch" + patch_description: "Robust discovery & injection of quirc" + patch_type: "conan" + - patch_file: "patches/4.1.2-0004-jasper.patch" + patch_description: "Compatibility with recent jasper versions" + patch_type: "portability" + - patch_file: "patches/4.1.2-0005-tracking-no-plot-deps.patch" + patch_description: "Fix requirements of tracking module" + patch_type: "conan" + - patch_file: "patches/4.1.2-0006-hdf.patch" + patch_description: "Robust discovery of hdf" + patch_type: "conan" + - patch_file: "patches/4.1.2-0007-android-install-layout.patch" + patch_description: "Honor install layout from conan if Android" + patch_type: "conan" + - patch_file: "patches/4.1.2-0008-link-qt-targets.patch" + patch_description: "Link to Qt through CMake targets" + patch_type: "conan" + - patch_file: "patches/4.1.2-0009-sfm-deps.patch" + patch_description: "Fix link to dependencies of sfm module" + patch_type: "conan" + - patch_file: "patches/4.1.2-0010-compat-protobuf-ge-3.18.patch" + patch_description: "Compatibility with protobuf >= 3.18" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv/pull/20386" + - patch_file: "patches/4.1.2-0011-compat-openexr3.patch" + patch_description: "Compatibility with OpenEXR 3.x" + patch_type: "portability" + patch_source: "https://github.com/opencv/opencv/pull/19970" diff --git a/thirdparty/opencv/4.x/conanfile.py b/thirdparty/opencv/4.x/conanfile.py new file mode 100644 index 0000000000..25e2e591de --- /dev/null +++ b/thirdparty/opencv/4.x/conanfile.py @@ -0,0 +1,1738 @@ +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rename, replace_in_file, rmdir, save +from conan.tools.gnu import PkgConfigDeps +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version +import os +import re +import textwrap + +required_conan_version = ">=1.60.0 <2.0 || >=2.0.5" + + +OPENCV_MAIN_MODULES_OPTIONS = ( + "calib3d", + "dnn", + "features2d", + "flann", + "gapi", + "highgui", + "imgcodecs", + "imgproc", + "ml", + "objdetect", + "photo", + "stitching", + "video", + "videoio", +) + +OPENCV_EXTRA_MODULES_OPTIONS = ( + "alphamat", + "aruco", + "barcode", + "bgsegm", + "bioinspired", + "ccalib", + "cudaarithm", + "cudabgsegm", + "cudacodec", + "cudafeatures2d", + "cudafilters", + "cudaimgproc", + "cudalegacy", + "cudaobjdetect", + "cudaoptflow", + "cudastereo", + "cudawarping", + "cvv", + "datasets", + "dnn_objdetect", + "dnn_superres", + "dpm", + "face", + "freetype", + "fuzzy", + "hdf", + "hfs", + "img_hash", + "intensity_transform", + "line_descriptor", + "mcc", + "optflow", + "ovis", + "phase_unwrapping", + "plot", + "quality", + "rapid", + "reg", + "rgbd", + "saliency", + "sfm", + "shape", + "stereo", + "structured_light", + "superres", + "surface_matching", + "text", + "tracking", + "videostab", + "viz", + "wechat_qrcode", + "xfeatures2d", + "ximgproc", + "xobjdetect", + "xphoto", +) + +class OpenCVConan(ConanFile): + name = "opencv" + license = "Apache-2.0" + homepage = "https://opencv.org" + description = "OpenCV (Open Source Computer Vision Library)" + url = "https://github.com/conan-io/conan-center-index" + topics = ("computer-vision", "deep-learning", "image-processing") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + # global options + "parallel": [False, "tbb", "openmp"], + "with_ipp": [False, "intel-ipp", "opencv-icv"], + "with_eigen": [True, False], + "neon": [True, False], + "with_opencl": [True, False], + "with_cuda": [True, False], + "with_cublas": [True, False], + "with_cufft": [True, False], + "with_cudnn": [True, False], + "cuda_arch_bin": [None, "ANY"], + "cpu_baseline": [None, "ANY"], + "cpu_dispatch": [None, "ANY"], + "world": [True, False], + "nonfree": [True, False], + # dnn module options + "with_flatbuffers": [True, False], + "with_protobuf": [True, False], + "with_vulkan": [True, False], + "dnn_cuda": [True, False], + # highgui module options + "with_gtk": [True, False], + "with_qt": [True, False], + "with_wayland": [True, False], + # imgcodecs module options + "with_avif": [True, False], + "with_jpeg": [False, "libjpeg", "libjpeg-turbo", "mozjpeg"], + "with_png": [True, False], + "with_tiff": [True, False], + "with_jpeg2000": [False, "jasper", "openjpeg"], + "with_openexr": [True, False], + "with_webp": [True, False], + "with_gdal": [True, False], + "with_gdcm": [True, False], + "with_imgcodec_hdr": [True, False], + "with_imgcodec_pfm": [True, False], + "with_imgcodec_pxm": [True, False], + "with_imgcodec_sunraster": [True, False], + "with_msmf": [True, False], + "with_msmf_dxva": [True, False], + # objdetect module options + "with_quirc": [True, False], + # videoio module options + "with_ffmpeg": [True, False], + "with_v4l": [True, False], + # text module options + "with_tesseract": [True, False], + # TODO: deprecated options to remove in few months + "contrib": [True, False, "deprecated"], + "contrib_freetype": [True, False, "deprecated"], + "contrib_sfm": [True, False, "deprecated"], + "with_ade": [True, False, "deprecated"], + } + options.update({_name: [True, False] for _name in OPENCV_MAIN_MODULES_OPTIONS}) + options.update({_name: [True, False] for _name in OPENCV_EXTRA_MODULES_OPTIONS}) + + default_options = { + "shared": False, + "fPIC": True, + # global options + "parallel": False, + "with_ipp": False, + "with_eigen": True, + "neon": True, + "with_opencl": False, + "with_cuda": False, + "with_cublas": False, + "with_cufft": False, + "with_cudnn": False, + "cuda_arch_bin": None, + "cpu_baseline": None, + "cpu_dispatch": None, + "world": False, + "nonfree": False, + # dnn module options + "with_flatbuffers": True, + "with_protobuf": True, + "with_vulkan": False, + "dnn_cuda": False, + # highgui module options + "with_gtk": False, + "with_qt": False, + "with_wayland": True, + # imgcodecs module options + "with_avif": False, + "with_jpeg": "libjpeg", + "with_png": True, + "with_tiff": True, + "with_jpeg2000": "jasper", + "with_openexr": True, + "with_webp": True, + "with_gdal": False, + "with_gdcm": False, + "with_imgcodec_hdr": False, + "with_imgcodec_pfm": False, + "with_imgcodec_pxm": False, + "with_imgcodec_sunraster": False, + "with_msmf": True, + "with_msmf_dxva": True, + # objdetect module options + "with_quirc": True, + # videoio module options + "with_ffmpeg": True, + "with_v4l": False, + # text module options + "with_tesseract": True, + # TODO: deprecated options to remove in few months + "contrib": "deprecated", + "contrib_freetype": "deprecated", + "contrib_sfm": "deprecated", + "with_ade": "deprecated", + } + default_options.update({_name: True for _name in OPENCV_MAIN_MODULES_OPTIONS}) + default_options.update({_name: False for _name in OPENCV_EXTRA_MODULES_OPTIONS}) + + short_paths = True + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" + + @property + def _is_legacy_one_profile(self): + return not hasattr(self, "settings_build") + + @property + def _contrib_folder(self): + return os.path.join(self.source_folder, "contrib") + + @property + def _extra_modules_folder(self): + return os.path.join(self._contrib_folder, "modules") + + @property + def _has_with_jpeg2000_option(self): + return self.settings.os != "iOS" + + @property + def _has_with_tiff_option(self): + return self.settings.os != "iOS" + + @property + def _has_with_ffmpeg_option(self): + return self.settings.os != "iOS" and self.settings.os != "WindowsStore" + + @property + def _has_superres_option(self): + return self.settings.os != "iOS" + + @property + def _has_alphamat_option(self): + return Version(self.version) >= "4.3.0" + + @property + def _has_intensity_transform_option(self): + return Version(self.version) >= "4.3.0" + + @property + def _has_rapid_option(self): + return Version(self.version) >= "4.3.0" + + @property + def _has_mcc_option(self): + return Version(self.version) >= "4.5.0" + + @property + def _has_wechat_qrcode_option(self): + return Version(self.version) >= "4.5.2" + + @property + def _has_barcode_option(self): + return Version(self.version) >= "4.5.3" and Version(self.version) < "4.8.0" + + @property + def _has_with_wayland_option(self): + return Version(self.version) >= "4.7.0" and self.settings.os in ["Linux", "FreeBSD"] + + @property + def _has_with_avif_option(self): + return Version(self.version) >= "4.8.0" + + @property + def _has_with_flatbuffers_option(self): + return Version(self.version) >= "4.8.0" + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os != "Linux": + del self.options.with_gtk + del self.options.with_v4l + if self.settings.os in ["iOS", "Android"]: + del self.options.with_opencl + if self.settings.os != "Windows": + del self.options.with_msmf + del self.options.with_msmf_dxva + + if self._has_with_ffmpeg_option: + # Following the packager choice, ffmpeg is enabled by default when + # supported, except on Android. See + # https://github.com/opencv/opencv/blob/39c3334147ec02761b117f180c9c4518be18d1fa/CMakeLists.txt#L266-L268 + self.options.with_ffmpeg = self.settings.os != "Android" + else: + del self.options.with_ffmpeg + + if "arm" not in self.settings.arch: + del self.options.neon + if not self._has_with_jpeg2000_option: + del self.options.with_jpeg2000 + if not self._has_with_tiff_option: + del self.options.with_tiff + if not self._has_superres_option: + del self.options.superres + if not self._has_alphamat_option: + del self.options.alphamat + if not self._has_intensity_transform_option: + del self.options.intensity_transform + if not self._has_rapid_option: + del self.options.rapid + if not self._has_mcc_option: + del self.options.mcc + if not self._has_wechat_qrcode_option: + del self.options.wechat_qrcode + if not self._has_barcode_option: + del self.options.barcode + if not self._has_with_wayland_option: + del self.options.with_wayland + if not self._has_with_avif_option: + del self.options.with_avif + if not self._has_with_flatbuffers_option: + del self.options.with_flatbuffers + + # Conditional default options + if self._is_mingw: + # These options are visible for Windows, but upstream disables them + # by default for MinGW (actually it would fail otherwise) + self.options.with_msmf = False + self.options.with_msmf_dxva = False + if self.settings.os == "Linux": + # Use Wayland by default, but fallback to GTK for old OpenCV versions. + # gtk/system is problematic for this recpe, there might be side effects + # in a big dependency graph + if not self._has_with_wayland_option: + self.options.with_gtk = True + + @property + def _opencv_modules(self): + def imageformats_deps(): + components = [] + if self.options.get_safe("with_avif"): + components.append("libavif::libavif") + if self.options.get_safe("with_jpeg2000"): + components.append("{0}::{0}".format(self.options.with_jpeg2000)) + if self.options.get_safe("with_png"): + components.append("libpng::libpng") + if self.options.get_safe("with_jpeg") == "libjpeg": + components.append("libjpeg::libjpeg") + elif self.options.get_safe("with_jpeg") == "libjpeg-turbo": + components.append("libjpeg-turbo::jpeg") + elif self.options.get_safe("with_jpeg") == "mozjpeg": + components.append("mozjpeg::libjpeg") + if self.options.get_safe("with_tiff"): + components.append("libtiff::libtiff") + if self.options.get_safe("with_openexr"): + components.append("openexr::openexr") + if self.options.get_safe("with_webp"): + components.append("libwebp::libwebp") + if self.options.get_safe("with_gdal"): + components.append("gdal::gdal") + if self.options.get_safe("with_gdcm"): + components.append("gdcm::gdcm") + return components + + def eigen(): + return ["eigen::eigen"] if self.options.with_eigen else [] + + def ffmpeg(): + components = [] + if self.options.get_safe("with_ffmpeg"): + components = ["ffmpeg::avcodec", "ffmpeg::avformat", "ffmpeg::avutil", "ffmpeg::swscale"] + return components + + def gtk(): + return ["gtk::gtk"] if self.options.get_safe("with_gtk") else [] + + def ipp(): + if self.options.with_ipp == "intel-ipp": + return ["intel-ipp::intel-ipp"] + elif self.options.with_ipp == "opencv-icv" and not self.options.shared: + return ["ippiw"] + return [] + + def parallel(): + return ["onetbb::onetbb"] if self.options.parallel == "tbb" else [] + + def protobuf(): + return ["protobuf::protobuf"] if self.options.get_safe("with_protobuf") else [] + + def qt(): + return ["qt::qt"] if self.options.get_safe("with_qt") else [] + + def quirc(): + return ["quirc::quirc"] if self.options.get_safe("with_quirc") else [] + + def tesseract(): + return ["tesseract::tesseract"] if self.options.get_safe("with_tesseract") else [] + + def vulkan(): + return ["vulkan-headers::vulkan-headers"] if self.options.get_safe("with_vulkan") else [] + + def wayland(): + return ["wayland::wayland-client", "wayland::wayland-cursor"] if self.options.get_safe("with_wayland") else [] + + def xkbcommon(): + return ["xkbcommon::libxkbcommon"] if self.options.get_safe("with_wayland") else [] + + def opencv_calib3d(): + return ["opencv_calib3d"] if self.options.calib3d else [] + + def opencv_cudaarithm(): + return ["opencv_cudaarithm"] if self.options.cudaarithm else [] + + def opencv_cudacodec(): + return ["opencv_cudacodec"] if self.options.cudacodec else [] + + def opencv_cudafeatures2d(): + return ["opencv_cudafeatures2d"] if self.options.cudafeatures2d else [] + + def opencv_cudafilters(): + return ["opencv_cudafilters"] if self.options.cudafilters else [] + + def opencv_cudaimgproc(): + return ["opencv_cudaimgproc"] if self.options.cudaimgproc else [] + + def opencv_cudalegacy(): + return ["opencv_cudalegacy"] if self.options.cudalegacy else [] + + def opencv_cudaoptflow(): + return ["opencv_cudaoptflow"] if self.options.cudaoptflow else [] + + def opencv_cudawarping(): + return ["opencv_cudawarping"] if self.options.cudawarping else [] + + def opencv_dnn(): + return ["opencv_dnn"] if self.options.dnn else [] + + def opencv_flann(): + return ["opencv_flann"] if self.options.flann else [] + + def opencv_imgcodecs(): + return ["opencv_imgcodecs"] if self.options.imgcodecs else [] + + def opencv_imgproc(): + return ["opencv_imgproc"] if self.options.imgproc else [] + + def opencv_objdetect(): + return ["opencv_objdetect"] if self.options.objdetect else [] + + def opencv_video(): + return ["opencv_video"] if self.options.video else [] + + def opencv_videoio(): + return ["opencv_videoio"] if self.options.videoio else [] + + def opencv_xfeatures2d(): + return ["opencv_xfeatures2d"] if self.options.xfeatures2d else [] + + opencv_modules = { + # Main modules + "calib3d": { + "is_built": self.options.calib3d, + "mandatory_options": ["features2d", "flann", "imgproc"], + "requires": ["opencv_core", "opencv_features2d", "opencv_flann", "opencv_imgproc"] + eigen() + ipp(), + }, + "core": { + "is_built": True, + "no_option": True, + "requires": ["zlib::zlib"] + parallel() + eigen() + ipp(), + "system_libs": [ + (self.settings.os == "Android", ["dl", "m", "log"]), + (self.settings.os == "FreeBSD", ["m", "pthread"]), + (self.settings.os == "Linux", ["dl", "m", "pthread", "rt"]), + ], + "frameworks": [ + (self.settings.os == "Macos" and self.options.get_safe("with_opencl"), ["OpenCL"]), + ], + }, + "dnn": { + "is_built": self.options.dnn, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + protobuf() + vulkan() + ipp(), + }, + "features2d": { + "is_built": self.options.features2d, + "mandatory_options": ["imgproc"], + "requires": ["opencv_imgproc"] + opencv_flann() + eigen() + ipp(), + }, + "flann": { + "is_built": self.options.flann, + "requires": ["opencv_core"] + ipp(), + }, + "gapi": { + "is_built": self.options.gapi, + "mandatory_options": ["imgproc"], + "requires": ["opencv_imgproc", "ade::ade"], + "system_libs": [ + (self.settings.os == "Windows", ["ws2_32", "wsock32"]), + ], + }, + "highgui": { + "is_built": self.options.highgui, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + opencv_imgcodecs() + + opencv_videoio() + gtk() + qt() + xkbcommon() + wayland() + ipp(), + "system_libs": [ + (self.settings.os == "Windows", ["comctl32", "gdi32", "ole32", "setupapi", "ws2_32", "vfw32"]), + ], + "frameworks": [ + (self.settings.os == "Macos", ["Cocoa"]), + ], + }, + "imgcodecs": { + "is_built": self.options.imgcodecs, + "mandatory_options": ["imgproc"], + "requires": ["opencv_imgproc", "zlib::zlib"] + imageformats_deps() + ipp(), + "frameworks": [ + (is_apple_os(self), ["CoreFoundation", "CoreGraphics"]), + (self.settings.os == "iOS", ["UIKit"]), + (self.settings.os == "Macos", ["AppKit"]), + ], + }, + "imgproc": { + "is_built": self.options.imgproc, + "requires": ["opencv_core"] + ipp(), + }, + "ml": { + "is_built": self.options.ml, + "requires": ["opencv_core"] + ipp(), + }, + "objdetect": { + "is_built": self.options.objdetect, + "mandatory_options": ["calib3d", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + quirc() + ipp(), + }, + "photo": { + "is_built": self.options.photo, + "mandatory_options": ["imgproc"], + "requires": ["opencv_imgproc"] + opencv_cudaarithm() + opencv_cudaimgproc() + ipp(), + }, + "stitching": { + "is_built": self.options.stitching, + "mandatory_options": ["calib3d", "features2d", "flann", "imgproc"], + "requires": ["opencv_calib3d", "opencv_features2d", "opencv_flann", "opencv_imgproc"] + + opencv_xfeatures2d() + opencv_cudaarithm() + opencv_cudawarping() + + opencv_cudafeatures2d() + opencv_cudalegacy() + opencv_cudaimgproc() + eigen() + ipp(), + }, + "video": { + "is_built": self.options.video, + "mandatory_options": ["imgproc"], + "requires": ["opencv_imgproc"] + opencv_calib3d() + ipp(), + }, + "videoio": { + "is_built": self.options.videoio, + "mandatory_options": ["imgcodecs", "imgproc"], + "requires": ["opencv_imgcodecs", "opencv_imgproc"] + ffmpeg() + ipp(), + "system_libs": [ + (self.settings.os == "Android" and int(str(self.settings.os.api_level)) > 20, ["mediandk"]), + ], + "frameworks": [ + (is_apple_os(self), ["Accelerate", "AVFoundation", "CoreGraphics", "CoreMedia", "CoreVideo", "QuartzCore"]), + (self.settings.os == "iOS", ["CoreImage", "UIKit"]), + (self.settings.os == "Macos", ["Cocoa"]), + ], + }, + # Extra modules + "alphamat": { + "is_built": self.options.get_safe("alphamat"), + "mandatory_options": ["with_eigen", "imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + ipp(), + }, + "aruco": { + "is_built": self.options.aruco, + "mandatory_options": ["calib3d", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + ipp(), + }, + "barcode": { + "is_built": self.options.get_safe("barcode"), + "mandatory_options": ["dnn", "imgproc"], + "requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(), + }, + "bgsegm": { + "is_built": self.options.bgsegm, + "mandatory_options": ["calib3d", "imgproc", "video"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "opencv_video"] + ipp(), + }, + "bioinspired": { + "is_built": self.options.bioinspired, + "requires": ["opencv_core"] + ipp(), + }, + "ccalib": { + "is_built": self.options.ccalib, + "mandatory_options": ["calib3d", "features2d", "highgui", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_features2d", "opencv_highgui", "opencv_imgproc"] + ipp(), + }, + "cudaarithm": { + "is_built": self.options.cudaarithm, + "mandatory_options": ["with_cuda"], + "requires": ["opencv_core", "opencv_cudev"] + ipp(), + }, + "cudabgsegm": { + "is_built": self.options.cudabgsegm, + "mandatory_options": ["with_cuda", "video"], + "requires": ["opencv_video"] + ipp(), + }, + "cudacodec": { + "is_built": self.options.cudacodec, + "mandatory_options": ["with_cuda", "videoio"], + "requires": ["opencv_core", "opencv_videoio"] + ipp(), + }, + "cudafeatures2d": { + "is_built": self.options.cudafeatures2d, + "mandatory_options": ["with_cuda", "features2d", "cudafilters", "cudawarping"], + "requires": ["opencv_features2d", "opencv_cudafilters", "opencv_cudawarping"] + ipp(), + }, + "cudafilters": { + "is_built": self.options.cudafilters, + "mandatory_options": ["with_cuda", "imgproc", "cudaarithm"], + "requires": ["opencv_imgproc", "opencv_cudaarithm"] + ipp(), + }, + "cudaimgproc": { + "is_built": self.options.cudaimgproc, + "mandatory_options": ["with_cuda", "imgproc"], + "requires": ["opencv_imgproc", "opencv_cudev"] + opencv_cudaarithm() + opencv_cudafilters() + ipp(), + }, + "cudalegacy": { + "is_built": self.options.cudalegacy, + "mandatory_options": ["with_cuda", "video"], + "requires": ["opencv_core", "opencv_video"] + opencv_calib3d() + opencv_imgproc() + opencv_objdetect() + + opencv_cudaarithm() + opencv_cudafilters() + opencv_cudaimgproc() + ipp(), + }, + "cudaobjdetect": { + "is_built": self.options.cudaobjdetect, + "mandatory_options": ["with_cuda", "objdetect", "cudaarithm", "cudawarping"], + "requires": ["opencv_objdetect", "opencv_cudaarithm", "opencv_cudawarping"] + opencv_cudalegacy() + ipp(), + }, + "cudaoptflow": { + "is_built": self.options.cudaoptflow, + "mandatory_options": ["with_cuda", "video", "cudaarithm", "cudaimgproc", "cudawarping", "optflow"], + "requires": ["opencv_video", "opencv_cudaarithm", "cudaimgproc", "opencv_cudawarping", + "opencv_optflow"] + opencv_cudalegacy() + ipp(), + }, + "cudastereo": { + "is_built": self.options.cudastereo, + "mandatory_options": ["with_cuda", "calib3d"], + "requires": ["opencv_calib3d", "opencv_cudev"] + ipp(), + }, + "cudawarping": { + "is_built": self.options.cudawarping, + "mandatory_options": ["with_cuda", "imgproc"], + "requires": ["opencv_core", "opencv_imgproc", "opencv_cudev"] + ipp(), + }, + "cudev": { + "is_built": self.options.with_cuda, + "no_option": True, + "requires": ipp(), + }, + "cvv": { + "is_built": self.options.cvv, + "mandatory_options": ["with_qt", "features2d", "imgproc"], + "requires": ["opencv_core", "opencv_features2d", "opencv_imgproc", "qt::qt"] + ipp(), + }, + "datasets": { + "is_built": self.options.datasets, + "mandatory_options": ["flann", "imgcodecs", "ml"], + "requires": ["opencv_core", "opencv_flann", "opencv_imgcodecs", "opencv_ml"] + ipp(), + }, + "dnn_objdetect": { + "is_built": self.options.dnn_objdetect, + "mandatory_options": ["dnn", "imgproc"], + "requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(), + }, + "dnn_superres": { + "is_built": self.options.dnn_superres, + "mandatory_options": ["dnn", "imgproc"], + "requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(), + }, + "dpm": { + "is_built": self.options.dpm, + "mandatory_options": ["imgproc", "objdetect"], + "requires": ["opencv_core", "opencv_imgproc", "opencv_objdetect"] + ipp(), + }, + "face": { + "is_built": self.options.face, + "mandatory_options": ["calib3d", "imgproc", "objdetect", "photo"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "opencv_objdetect", "opencv_photo"] + ipp(), + }, + "freetype": { + "is_built": self.options.freetype, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc", "freetype::freetype", "harfbuzz::harfbuzz"] + ipp(), + }, + "fuzzy": { + "is_built": self.options.fuzzy, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + ipp(), + }, + "hdf": { + "is_built": self.options.hdf, + "requires": ["opencv_core", "hdf5::hdf5"] + ipp(), + }, + "hfs": { + "is_built": self.options.hfs, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + ipp(), + }, + "img_hash": { + "is_built": self.options.img_hash, + "is_part_of_world": False, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + ipp(), + }, + "intensity_transform": { + "is_built": self.options.get_safe("intensity_transform"), + "requires": ["opencv_core"] + ipp(), + }, + "line_descriptor": { + "is_built": self.options.line_descriptor, + "mandatory_options": ["imgproc"], + "requires": ["opencv_imgproc"] + ipp(), + }, + "mcc": { + "is_built": self.options.get_safe("mcc"), + "mandatory_options": ["calib3d", "dnn", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_dnn", "opencv_imgproc"] + ipp(), + }, + "optflow": { + "is_built": self.options.optflow, + "mandatory_options": ["calib3d", "flann", "imgcodecs", "imgproc", "video", "ximgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_flann", "opencv_imgcodecs", "opencv_imgproc", + "opencv_video", "opencv_ximgproc"] + ipp(), + }, + "ovis": { + "is_built": self.options.ovis, + "mandatory_options": ["calib3d", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "ogre::ogre"] + ipp(), + }, + "phase_unwrapping": { + "is_built": self.options.phase_unwrapping, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + ipp(), + }, + "plot": { + "is_built": self.options.plot, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + ipp(), + }, + "quality": { + "is_built": self.options.quality, + "mandatory_options": ["imgproc", "ml"], + "requires": ["opencv_core", "opencv_imgproc", "opencv_ml"] + ipp(), + }, + "rapid": { + "is_built": self.options.get_safe("rapid"), + "mandatory_options": ["calib3d", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + ipp(), + }, + "reg": { + "is_built": self.options.reg, + "mandatory_options": ["imgproc"], + "requires": ["opencv_core", "opencv_imgproc"] + ipp(), + }, + "rgbd": { + "is_built": self.options.rgbd, + "mandatory_options": ["calib3d", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + eigen() + ipp(), + }, + "saliency": { + "is_built": self.options.saliency, + "mandatory_options": ["features2d", "imgproc"], + "requires": ["opencv_features2d", "opencv_imgproc"] + ipp(), + }, + "sfm": { + "is_built": self.options.sfm, + "is_part_of_world": False, + "mandatory_options": ["with_eigen", "calib3d", "features2d", "imgcodecs", "xfeatures2d"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_features2d", "opencv_imgcodecs", "opencv_xfeatures2d", + "correspondence", "multiview", "numeric", "glog::glog", "gflags::gflags"] + eigen() + ipp(), + }, + "shape": { + "is_built": self.options.shape, + "mandatory_options": ["calib3d", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + ipp(), + }, + "stereo": { + "is_built": self.options.stereo, + "mandatory_options": ["features2d", "imgproc", "tracking"], + "requires": ["opencv_core", "opencv_features2d", "opencv_imgproc", "opencv_tracking"] + ipp(), + }, + "structured_light": { + "is_built": self.options.structured_light, + "mandatory_options": ["calib3d", "imgproc", "phase_unwrapping"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "opencv_phase_unwrapping"] + ipp(), + }, + "superres": { + "is_built": self.options.get_safe("superres"), + "mandatory_options": ["imgproc", "video", "optflow"], + "requires": ["opencv_imgproc", "opencv_video", "opencv_optflow"] + opencv_videoio() + ipp() + + opencv_cudaarithm() + opencv_cudafilters() + opencv_cudawarping() + opencv_cudaimgproc() + + opencv_cudaoptflow() + opencv_cudacodec(), + }, + "surface_matching": { + "is_built": self.options.surface_matching, + "mandatory_options": ["flann"], + "requires": ["opencv_core", "opencv_flann"] + ipp(), + }, + "text": { + "is_built": self.options.text, + "mandatory_options": ["dnn", "features2d", "imgproc", "ml"], + "requires": ["opencv_core", "opencv_dnn", "opencv_features2d", "opencv_imgproc", "opencv_ml"] + + tesseract() + ipp(), + }, + "tracking": { + "is_built": self.options.tracking, + "mandatory_options": ["imgproc", "video"], + "requires": ["opencv_core", "opencv_imgproc", "opencv_video"] + opencv_dnn() + ipp(), + }, + "videostab": { + "is_built": self.options.videostab, + "mandatory_options": ["calib3d", "features2d", "imgproc", "photo", "video"], + "requires": ["opencv_calib3d", "opencv_features2d", "opencv_imgproc", "opencv_photo", "opencv_video"] + + opencv_videoio() + ipp() + opencv_cudawarping() + opencv_cudaoptflow(), + }, + "viz": { + "is_built": self.options.viz, + "requires": ["opencv_core", "vtk::vtk"] + ipp(), + }, + "wechat_qrcode": { + "is_built": self.options.get_safe("wechat_qrcode"), + "mandatory_options": ["dnn", "imgproc"], + "requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(), + }, + "xfeatures2d": { + "is_built": self.options.xfeatures2d, + "mandatory_options": ["calib3d", "features2d", "imgproc"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_features2d", "opencv_imgproc"] + ipp() + opencv_cudaarithm(), + }, + "ximgproc": { + "is_built": self.options.ximgproc, + "mandatory_options": ["calib3d", "imgcodecs", "imgproc", "video"], + "requires": ["opencv_core", "opencv_calib3d", "opencv_imgcodecs", "opencv_imgproc", "opencv_video"] + + eigen() + ipp(), + }, + "xobjdetect": { + "is_built": self.options.xobjdetect, + "mandatory_options": ["imgcodecs", "imgproc", "objdetect"], + "requires": ["opencv_core", "opencv_imgcodecs", "opencv_imgproc", "opencv_objdetect"] + ipp(), + }, + "xphoto": { + "is_built": self.options.xphoto, + "mandatory_options": ["imgproc", "photo"], + "requires": ["opencv_core", "opencv_imgproc", "opencv_photo"] + ipp(), + }, + # Extra targets (without prefix in their target & lib name) + "ippiw": { + "is_built": self.options.with_ipp == "opencv-icv" and not self.options.shared, + "is_part_of_world": False, + "no_option": True, + }, + "numeric": { + "is_built": self.options.sfm, + "is_part_of_world": False, + "no_option": True, + "requires": eigen() + ipp(), + }, + "correspondence": { + "is_built": self.options.sfm, + "is_part_of_world": False, + "no_option": True, + "requires": ["opencv_imgcodecs", "multiview", "glog::glog"] + eigen() + ipp(), + }, + "multiview": { + "is_built": self.options.sfm, + "is_part_of_world": False, + "no_option": True, + "requires": ["numeric", "glog::glog"] + eigen() + ipp(), + }, + } + + if Version(self.version) >= "4.3.0": + opencv_modules["gapi"].setdefault("requires", []).extend(opencv_video()) + if Version(self.version) >= "4.5.2": + opencv_modules["gapi"].setdefault("requires", []).extend(opencv_calib3d()) + if Version(self.version) >= "4.5.4": + opencv_modules["objdetect"].setdefault("requires", []).extend(opencv_dnn()) + if Version(self.version) >= "4.5.1": + opencv_modules["video"].setdefault("requires", []).extend(opencv_dnn()) + if Version(self.version) >= "4.4.0": + opencv_modules["intensity_transform"].setdefault("mandatory_options", []).append("imgproc") + opencv_modules["intensity_transform"].setdefault("requires", []).append("opencv_imgproc") + if Version(self.version) < "4.3.0": + opencv_modules["stereo"].setdefault("mandatory_options", []).extend(["calib3d", "video"]) + opencv_modules["stereo"].setdefault("requires", []).extend(["opencv_calib3d", "opencv_video"]) + if Version(self.version) >= "4.7.0": + opencv_modules["aruco"].setdefault("mandatory_options", []).append("objdetect") + opencv_modules["aruco"].setdefault("requires", []).append("opencv_objdetect") + opencv_modules["cudacodec"].setdefault("mandatory_options", []).extend(["cudaarithm", "cudawarping"]) + opencv_modules["cudacodec"].setdefault("requires", []).extend(["opencv_cudaarithm", "opencv_cudawarping"]) + opencv_modules["wechat_qrcode"].setdefault("mandatory_options", []).append("objdetect") + opencv_modules["wechat_qrcode"].setdefault("requires", []).append("opencv_objdetect") + else: + opencv_modules["cudacodec"].setdefault("requires", []).append("opencv_cudev") + if Version(self.version) < "4.8.0": + opencv_modules["dnn"].setdefault("mandatory_options", []).append("with_protobuf") + + return opencv_modules + + def _get_mandatory_disabled_options(self, opencv_modules): + direct_options_to_enable = {} + transitive_options_to_enable = {} + + # Check which direct options have to be enabled + base_options = [option for option, values in opencv_modules.items() + if not values.get("no_option") and self.options.get_safe(option)] + for base_option in base_options: + for mandatory_option in opencv_modules.get(base_option, {}).get("mandatory_options", []): + if not self.options.get_safe(mandatory_option): + direct_options_to_enable.setdefault(mandatory_option, set()).add(base_option) + + # Now traverse the graph to check which transitive options have to be enabled + def collect_transitive_options(base_option, option): + for mandatory_option in opencv_modules.get(option, {}).get("mandatory_options", []): + if not self.options.get_safe(mandatory_option): + if mandatory_option not in transitive_options_to_enable: + transitive_options_to_enable[mandatory_option] = set() + collect_transitive_options(base_option, mandatory_option) + if base_option not in direct_options_to_enable.get(mandatory_option, set()): + transitive_options_to_enable[mandatory_option].add(base_option) + + for base_option in base_options: + collect_transitive_options(base_option, base_option) + + return { + "direct": direct_options_to_enable, + "transitive": transitive_options_to_enable, + } + + def _solve_internal_dependency_graph(self, opencv_modules): + disabled_options = self._get_mandatory_disabled_options(opencv_modules) + direct_options_to_enable = disabled_options["direct"] + transitive_options_to_enable = disabled_options["transitive"] + + # Enable mandatory options + all_options_to_enable = set(direct_options_to_enable.keys()) + all_options_to_enable.update(transitive_options_to_enable.keys()) + if all_options_to_enable: + message = ("Several opencv options which were disabled will be enabled because " + "they are required by modules you have explicitly requested:\n") + + for option_to_enable in all_options_to_enable: + try: + setattr(self.options, option_to_enable, True) + except ConanException: + # It may not work in conan v2 and raise ConanException "Incorrect attempt to modify option" + continue + + direct_and_transitive = [] + direct = ", ".join(direct_options_to_enable.get(option_to_enable, [])) + if direct: + direct_and_transitive.append(f"direct dependency of {direct}") + transitive = ", ".join(transitive_options_to_enable.get(option_to_enable, [])) + if transitive: + direct_and_transitive.append(f"transitive dependency of {transitive}") + message += f" - {option_to_enable}: {' / '.join(direct_and_transitive)}\n" + + self.output.warning(message) + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + # TODO: remove contrib option in few months + if self.options.contrib != "deprecated": + self.output.warning("contrib option is deprecated") + if self.options.contrib: + # During deprecation period, keep old behavior of contrib=True, which was to enable + # all available contribs. + ## Filter main module options + filtered_options = list(OPENCV_MAIN_MODULES_OPTIONS) + ## Filter extra modules not built previously with contrib=True + filtered_options.extend(["cvv", "freetype", "hdf", "ovis", "sfm", "viz"]) + ## Filter extra modules not built previously when some option was disabled + if not self.options.with_eigen: + filtered_options.append("alphamat") + if not self.options.with_cuda: + filtered_options.extend([ + "cudaarithm", "cudabgsegm", "cudacodec", "cudafeatures2d", "cudafilters", "cudaimgproc", + "cudalegacy", "cudaobjdetect", "cudaoptflow", "cudastereo", "cudawarping", + ]) + for option, values in self._opencv_modules.items(): + if option not in filtered_options and not values.get("no_option"): + try: + if hasattr(self.options, option): + setattr(self.options, option, True) + except ConanException: + continue + + # TODO: remove contrib_freetype option in few months + if self.options.contrib_freetype != "deprecated": + self.output.warning("contrib_freetype option is deprecated, use freetype option instead") + self.options.freetype = self.options.contrib_freetype + + # TODO: remove contrib_sfm option in few months + if self.options.contrib_sfm != "deprecated": + self.output.warning("contrib_sfm option is deprecated, use sfm option instead") + self.options.sfm = self.options.contrib_sfm + + # TODO: remove with_ade option in few months + if self.options.with_ade != "deprecated": + self.output.warning("with_ade option is deprecated, use gapi option instead") + self.options.gapi = self.options.with_ade + + # Call this first before any further manipulation of options based on other options + self._solve_internal_dependency_graph(self._opencv_modules) + + if not self.options.dnn: + self.options.rm_safe("dnn_cuda") + self.options.rm_safe("with_flatbuffers") + self.options.rm_safe("with_protobuf") + self.options.rm_safe("with_vulkan") + if not self.options.highgui: + self.options.rm_safe("with_gtk") + self.options.rm_safe("with_wayland") + if not (self.options.highgui or self.options.cvv): + self.options.rm_safe("with_qt") + if not self.options.imgcodecs: + self.options.rm_safe("with_avif") + self.options.rm_safe("with_jpeg") + self.options.rm_safe("with_jpeg2000") + self.options.rm_safe("with_openexr") + self.options.rm_safe("with_png") + self.options.rm_safe("with_tiff") + self.options.rm_safe("with_webp") + self.options.rm_safe("with_gdal") + self.options.rm_safe("with_gdcm") + self.options.rm_safe("with_imgcodec_hdr") + self.options.rm_safe("with_imgcodec_pfm") + self.options.rm_safe("with_imgcodec_pxm") + self.options.rm_safe("with_imgcodec_sunraster") + self.options.rm_safe("with_msmf") + self.options.rm_safe("with_msmf_dxva") + if not self.options.objdetect: + self.options.rm_safe("with_quirc") + if not self.options.videoio: + self.options.rm_safe("with_ffmpeg") + self.options.rm_safe("with_v4l") + if not self.options.with_cuda: + self.options.rm_safe("with_cublas") + self.options.rm_safe("with_cudnn") + self.options.rm_safe("with_cufft") + self.options.rm_safe("dnn_cuda") + self.options.rm_safe("cuda_arch_bin") + if not self.options.text: + self.options.rm_safe("with_tesseract") + + if bool(self.options.get_safe("with_jpeg", False)): + if self.options.get_safe("with_jpeg2000") == "jasper": + self.options["jasper"].with_libjpeg = self.options.with_jpeg + if self.options.get_safe("with_tiff"): + self.options["libtiff"].jpeg = self.options.with_jpeg + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # core module dependencies + self.requires("zlib/[>=1.2.11 <2]") + if self.options.with_eigen: + self.requires("eigen/3.4.0") + if self.options.parallel == "tbb": + self.requires("onetbb/2021.10.0") + if self.options.with_ipp == "intel-ipp": + self.requires("intel-ipp/2020") + # dnn module dependencies + if self.options.get_safe("with_protobuf"): + # Symbols are exposed https://github.com/conan-io/conan-center-index/pull/16678#issuecomment-1507811867 + self.requires("protobuf/3.21.12", transitive_libs=True) + if self.options.get_safe("with_vulkan"): + self.requires("vulkan-headers/1.3.268.0") + # gapi module dependencies + if self.options.gapi: + self.requires("ade/0.1.2d") + # highgui module dependencies + if self.options.get_safe("with_gtk"): + self.requires("gtk/system") + if self.options.get_safe("with_qt"): + self.requires("qt/5.15.12") + if self.options.get_safe("with_wayland"): + self.requires("xkbcommon/1.6.0") + self.requires("wayland/1.22.0") + # imgcodecs module dependencies + if self.options.get_safe("with_avif"): + self.requires("libavif/1.0.4") + if self.options.get_safe("with_jpeg") == "libjpeg": + self.requires("libjpeg/9e") + elif self.options.get_safe("with_jpeg") == "libjpeg-turbo": + self.requires("libjpeg-turbo/3.0.2") + elif self.options.get_safe("with_jpeg") == "mozjpeg": + self.requires("mozjpeg/4.1.5") + if self.options.get_safe("with_jpeg2000") == "jasper": + self.requires("jasper/4.2.0") + elif self.options.get_safe("with_jpeg2000") == "openjpeg": + self.requires("openjpeg/2.5.2") + if self.options.get_safe("with_png"): + self.requires("libpng/[>=1.6 <2]") + if self.options.get_safe("with_openexr"): + self.requires("openexr/3.2.3") + if self.options.get_safe("with_tiff"): + # self.requires("libtiff/4.6.0") + self.requires("libtiff/4.6.0@minifi/dev") # libtiff requires xz_utils, so use minifi one + if self.options.get_safe("with_webp"): + self.requires("libwebp/1.3.2") + if self.options.get_safe("with_gdal"): + self.requires("gdal/3.8.3") + if self.options.get_safe("with_gdcm"): + self.requires("gdcm/3.0.23") + # objdetect module dependencies + if self.options.get_safe("with_quirc"): + self.requires("quirc/1.2") + # videoio module dependencies + if self.options.get_safe("with_ffmpeg"): + # opencv doesn't support ffmpeg >= 5.0.0 for the moment (until 4.5.5 at least) + self.requires("ffmpeg/4.4.4@minifi/dev") # ffmpeg requires xz_utils, so use minifi one + # freetype module dependencies + if self.options.freetype: + self.requires("freetype/2.13.2") + self.requires("harfbuzz/8.3.0") + # hdf module dependencies + if self.options.hdf: + self.requires("hdf5/1.14.3") + # ovis module dependencies + if self.options.ovis: + self.requires("ogre/1.10.2") + # sfm module dependencies + if self.options.sfm: + self.requires("gflags/2.2.2") + self.requires("glog/0.7.0") + # text module dependencies + if self.options.get_safe("with_tesseract"): + self.requires("tesseract/5.3.3") + + def package_id(self): + # deprecated options + del self.info.options.contrib + del self.info.options.contrib_freetype + del self.info.options.contrib_sfm + del self.info.options.with_ade + + def _check_mandatory_options(self, opencv_modules): + disabled_options = self._get_mandatory_disabled_options(opencv_modules) + direct_disabled_mandatory_options = disabled_options["direct"] + transitive_disabled_mandatory_options = disabled_options["transitive"] + + # check mandatory options + all_disabled_mandatory_options = set(direct_disabled_mandatory_options.keys()) + all_disabled_mandatory_options.update(transitive_disabled_mandatory_options.keys()) + if all_disabled_mandatory_options: + message = ("Several opencv options are disabled but are required by modules " + "you have explicitly requested:\n") + + for disabled_option in all_disabled_mandatory_options: + direct_and_transitive = [] + direct = ", ".join(direct_disabled_mandatory_options.get(disabled_option, [])) + if direct: + direct_and_transitive.append(f"direct dependency of {direct}") + transitive = ", ".join(transitive_disabled_mandatory_options.get(disabled_option, [])) + if transitive: + direct_and_transitive.append(f"transitive dependency of {transitive}") + message += f" - {disabled_option}: {' / '.join(direct_and_transitive)}\n" + + raise ConanInvalidConfiguration(message) + + def validate(self): + self._check_mandatory_options(self._opencv_modules) + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration("Visual Studio with static runtime is not supported for shared library.") + if self.settings.compiler == "clang" and Version(self.settings.compiler.version) < "4": + raise ConanInvalidConfiguration("Clang 3.x can't build OpenCV 4.x due to an internal bug.") + if self.options.get_safe("dnn_cuda") and \ + (not self.options.with_cuda or not self.options.with_cublas or not self.options.with_cudnn): + raise ConanInvalidConfiguration("with_cublas and with_cudnn must be enabled for dnn_cuda") + if self.options.with_ipp == "opencv-icv" and \ + not (self.settings.arch in ["x86", "x86_64"] and self.settings.os in ["Linux", "Macos", "Windows"]): + raise ConanInvalidConfiguration(f"opencv-icv is not available for {self.settings.os}/{self.settings.arch}") + if self.options.viz: + raise ConanInvalidConfiguration( + "viz module can't be enabled yet. It requires VTK which is not available in conan-center." + ) + + def build_requirements(self): + if self.options.get_safe("with_protobuf"): + if not self._is_legacy_one_profile: + self.tool_requires("protobuf/") + if self.options.get_safe("with_wayland"): + self.tool_requires("wayland-protocols/1.33") + if not self._is_legacy_one_profile: + self.tool_requires("wayland/") + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/2.1.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version][0], strip_root=True) + + get(self, **self.conan_data["sources"][self.version][1], + destination=self._contrib_folder, strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + # Patches in opencv + # ----------------- + + ## Remove 3rd party libs + for directory in [ + "libjasper", "libjpeg", "libjpeg-turbo", "libpng", "libspng", "libtiff", + "libwebp", "openexr", "openjpeg", "protobuf", "quirc", "tbb", "zlib", + ]: + rmdir(self, os.path.join(self.source_folder, "3rdparty", directory)) + + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "ANDROID OR NOT UNIX", "FALSE") + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "elseif(EMSCRIPTEN)", "elseif(QNXNTO)\nelseif(EMSCRIPTEN)") + + ## Upstream CMakeLists vendors quirc in CMakeLists of 3rdparty/quirc. + ## Instead we rely on find-quirc.patch in order to link external quirc. + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "add_subdirectory(3rdparty/quirc)", "") + + ## Fix link to several dependencies + replace_in_file(self, os.path.join(self.source_folder, "modules", "imgcodecs", "CMakeLists.txt"), "JASPER_", "Jasper_") + replace_in_file(self, os.path.join(self.source_folder, "modules", "imgcodecs", "CMakeLists.txt"), "${GDAL_LIBRARY}", "GDAL::GDAL") + if Version(self.version) >= "4.8.0": + replace_in_file(self, os.path.join(self.source_folder, "modules", "imgcodecs", "CMakeLists.txt"), "${AVIF_LIBRARY}", "avif") + + ## Fix detection of ffmpeg + replace_in_file(self, os.path.join(self.source_folder, "modules", "videoio", "cmake", "detect_ffmpeg.cmake"), + "FFMPEG_FOUND", "ffmpeg_FOUND") + + ## Robust handling of wayland + if self.options.get_safe("with_wayland"): + detect_wayland = os.path.join(self.source_folder, "modules", "highgui", "cmake", "detect_wayland.cmake") + + # We have to override *_LINK_LIBRARIES variables linked to highui because they are just link fkags, not cflags + # so include dirs are missing (OpenCV seems to assume system libs for wayland) + replace_in_file( + self, + detect_wayland, + "ocv_check_modules(WAYLAND_CLIENT wayland-client)", + "ocv_check_modules(WAYLAND_CLIENT wayland-client)\nfind_package(wayland REQUIRED CONFIG)\nset(WAYLAND_CLIENT_LINK_LIBRARIES wayland::wayland-client)", + ) + replace_in_file( + self, + detect_wayland, + "ocv_check_modules(WAYLAND_CURSOR wayland-cursor)", + "ocv_check_modules(WAYLAND_CURSOR wayland-cursor)\nset(WAYLAND_CURSOR_LINK_LIBRARIES wayland::wayland-cursor)", + ) + replace_in_file( + self, + detect_wayland, + "ocv_check_modules(XKBCOMMON xkbcommon)", + "ocv_check_modules(XKBCOMMON xkbcommon)\nfind_package(xkbcommon REQUIRED CONFIG)\nset(XKBCOMMON_LINK_LIBRARIES xkbcommon::libxkbcommon)", + ) + + ## Cleanup RPATH + install_layout_file = os.path.join(self.source_folder, "cmake", "OpenCVInstallLayout.cmake") + replace_in_file(self, install_layout_file, + "ocv_update(CMAKE_INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}\")", + "") + replace_in_file(self, install_layout_file, "set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)", "") + + ## Fix discovery & link of protobuf + if self.options.get_safe("with_protobuf"): + find_protobuf = os.path.join(self.source_folder, "cmake", "OpenCVFindProtobuf.cmake") + # OpenCV expects to find FindProtobuf.cmake, not the config file + replace_in_file(self, find_protobuf, + "find_package(Protobuf QUIET)", + "find_package(Protobuf REQUIRED MODULE)") + # in 'if' block, get_target_property() produces an error + if Version(self.version) >= "4.4.0": + replace_in_file(self, find_protobuf, + 'if(TARGET "${Protobuf_LIBRARIES}")', + 'if(FALSE) # patch: disable if(TARGET "${Protobuf_LIBRARIES}")') + + # Patches in opencv_contrib + # ------------------------- + + ## Remove unused extra modules to avoid side effects + if not self.options.with_cuda: + rmdir(self, os.path.join(self._extra_modules_folder, "cudev")) + for module in OPENCV_EXTRA_MODULES_OPTIONS: + if not self.options.get_safe(module): + rmdir(self, os.path.join(self._extra_modules_folder, module)) + for module in ["cnn_3dobj", "julia", "matlab"]: + rmdir(self, os.path.join(self._extra_modules_folder, module)) + + ## Fix Freetype discovery logic in freetype extra module + if self.options.freetype: + freetype_cmake = os.path.join(self._extra_modules_folder, "freetype", "CMakeLists.txt") + replace_in_file(self, freetype_cmake, "ocv_check_modules(FREETYPE freetype2)", "find_package(Freetype REQUIRED MODULE)") + replace_in_file(self, freetype_cmake, "FREETYPE_", "Freetype_") + + replace_in_file(self, freetype_cmake, "ocv_check_modules(HARFBUZZ harfbuzz)", "find_package(harfbuzz REQUIRED CONFIG)") + replace_in_file(self, freetype_cmake, "HARFBUZZ_", "harfbuzz_") + + def generate(self): + VirtualBuildEnv(self).generate() + if self._is_legacy_one_profile: + if self.options.get_safe("with_protobuf") or self.options.get_safe("with_wayland"): + VirtualRunEnv(self).generate(scope="build") + + tc = CMakeToolchain(self) + tc.variables["OPENCV_CONFIG_INSTALL_PATH"] = "cmake" + tc.variables["OPENCV_BIN_INSTALL_PATH"] = "bin" + tc.variables["OPENCV_LIB_INSTALL_PATH"] = "lib" + tc.variables["OPENCV_3P_LIB_INSTALL_PATH"] = "lib" + tc.variables["OPENCV_OTHER_INSTALL_PATH"] = "res" + tc.variables["OPENCV_LICENSES_INSTALL_PATH"] = "licenses" + + tc.variables["OPENCV_SKIP_CMAKE_CXX_STANDARD"] = valid_min_cppstd(self, 11) + + tc.variables["BUILD_CUDA_STUBS"] = False + tc.variables["BUILD_DOCS"] = False + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_FAT_JAVA_LIB"] = False + tc.variables["BUILD_IPP_IW"] = self.options.with_ipp == "opencv-icv" + tc.variables["BUILD_ITT"] = False + tc.variables["BUILD_JASPER"] = False + tc.variables["BUILD_JAVA"] = False + tc.variables["BUILD_JPEG"] = False + tc.variables["BUILD_OPENEXR"] = False + tc.variables["BUILD_OPENJPEG"] = False + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_PROTOBUF"] = False + tc.variables["BUILD_PACKAGE"] = False + tc.variables["BUILD_PERF_TESTS"] = False + tc.variables["BUILD_USE_SYMLINKS"] = False + tc.variables["BUILD_opencv_apps"] = False + tc.variables["BUILD_opencv_java"] = False + tc.variables["BUILD_opencv_java_bindings_gen"] = False + tc.variables["BUILD_opencv_js"] = False + tc.variables["BUILD_ZLIB"] = False + tc.variables["BUILD_PNG"] = False + tc.variables["BUILD_TIFF"] = False + tc.variables["BUILD_WEBP"] = False + tc.variables["BUILD_TBB"] = False + tc.variables["OPENCV_FORCE_3RDPARTY_BUILD"] = False + tc.variables["OPENCV_PYTHON_SKIP_DETECTION"] = True + tc.variables["BUILD_opencv_python2"] = False + tc.variables["BUILD_opencv_python3"] = False + tc.variables["BUILD_opencv_python_bindings_g"] = False + tc.variables["BUILD_opencv_python_tests"] = False + tc.variables["BUILD_opencv_ts"] = False + + tc.variables["WITH_1394"] = False + tc.variables["WITH_ARAVIS"] = False + tc.variables["WITH_CLP"] = False + tc.variables["WITH_NVCUVID"] = False + + tc.variables["WITH_FFMPEG"] = self.options.get_safe("with_ffmpeg", False) + if self.options.get_safe("with_ffmpeg"): + tc.variables["OPENCV_FFMPEG_SKIP_BUILD_CHECK"] = True + tc.variables["OPENCV_FFMPEG_SKIP_DOWNLOAD"] = True + # opencv will not search for ffmpeg package, but for + # libavcodec;libavformat;libavutil;libswscale modules + tc.variables["OPENCV_FFMPEG_USE_FIND_PACKAGE"] = "ffmpeg" + tc.variables["OPENCV_INSTALL_FFMPEG_DOWNLOAD_SCRIPT"] = False + if Version(self.version) >= "4.7.0": + tc.variables["OPENCV_FFMPEG_ENABLE_LIBAVDEVICE"] = False + ffmpeg_libraries = [] + for component in ["avcodec", "avformat", "avutil", "swscale", "avresample"]: + if component == "avutil" or self.dependencies["ffmpeg"].options.get_safe(component): + ffmpeg_libraries.append(f"ffmpeg::{component}") + ffmpeg_component_version = self.dependencies["ffmpeg"].cpp_info.components[component].get_property("component_version") + tc.variables[f"FFMPEG_lib{component}_VERSION"] = ffmpeg_component_version + tc.variables["FFMPEG_LIBRARIES"] = ";".join(ffmpeg_libraries) + + tc.variables["WITH_GSTREAMER"] = False + tc.variables["WITH_HALIDE"] = False + tc.variables["WITH_HPX"] = False + tc.variables["WITH_IMGCODEC_HDR"] = self.options.get_safe("with_imgcodec_hdr", False) + tc.variables["WITH_IMGCODEC_PFM"] = self.options.get_safe("with_imgcodec_pfm", False) + tc.variables["WITH_IMGCODEC_PXM"] = self.options.get_safe("with_imgcodec_pxm", False) + tc.variables["WITH_IMGCODEC_SUNRASTER"] = self.options.get_safe("with_imgcodec_sunraster", False) + tc.variables["WITH_IPP"] = bool(self.options.with_ipp) + if self.options.with_ipp == "intel-ipp": + ipp_root = self.dependencies["intel-ipp"].package_folder.replace("\\", "/") + tc.variables["IPPROOT"] = ipp_root + tc.variables["IPPIWROOT"] = ipp_root + tc.variables["WITH_ITT"] = False + tc.variables["WITH_LIBREALSENSE"] = False + tc.variables["WITH_MFX"] = False + tc.variables["WITH_OPENCL"] = self.options.get_safe("with_opencl", False) + tc.variables["WITH_OPENCLAMDBLAS"] = False + tc.variables["WITH_OPENCLAMDFFT"] = False + tc.variables["WITH_OPENCL_SVM"] = False + tc.variables["WITH_OPENGL"] = False + tc.variables["WITH_TBB"] = self.options.parallel == "tbb" + tc.variables["WITH_OPENMP"] = self.options.parallel == "openmp" + tc.variables["WITH_OPENNI"] = False + tc.variables["WITH_OPENNI2"] = False + tc.variables["WITH_OPENVX"] = False + tc.variables["WITH_CAROTENE"] = False + tc.variables["WITH_PLAIDML"] = False + tc.variables["WITH_PVAPI"] = False + tc.variables["WITH_QT"] = self.options.get_safe("with_qt", False) + tc.variables["WITH_QUIRC"] = self.options.get_safe("with_quirc", False) + tc.variables["WITH_V4L"] = self.options.get_safe("with_v4l", False) + tc.variables["WITH_VA"] = False + tc.variables["WITH_VA_INTEL"] = False + tc.variables["WITH_VTK"] = self.options.viz + tc.variables["WITH_VULKAN"] = self.options.get_safe("with_vulkan", False) + if self.options.get_safe("with_vulkan"): + tc.variables["VULKAN_INCLUDE_DIRS"] = os.path.join(self.dependencies["vulkan-headers"].package_folder, "include").replace("\\", "/") + tc.variables["WITH_XIMEA"] = False + tc.variables["WITH_XINE"] = False + tc.variables["WITH_LAPACK"] = False + + tc.variables["WITH_GTK"] = self.options.get_safe("with_gtk", False) + tc.variables["WITH_GTK_2_X"] = self._is_gtk_version2 + tc.variables["WITH_WEBP"] = self.options.get_safe("with_webp", False) + tc.variables["WITH_JPEG"] = bool(self.options.get_safe("with_jpeg", False)) + tc.variables["WITH_PNG"] = self.options.get_safe("with_png", False) + if self._has_with_tiff_option: + tc.variables["WITH_TIFF"] = self.options.get_safe("with_tiff", False) + if self._has_with_jpeg2000_option: + tc.variables["WITH_JASPER"] = self.options.get_safe("with_jpeg2000") == "jasper" + tc.variables["WITH_OPENJPEG"] = self.options.get_safe("with_jpeg2000") == "openjpeg" + tc.variables["WITH_OPENEXR"] = self.options.get_safe("with_openexr", False) + tc.variables["WITH_GDAL"] = self.options.get_safe("with_gdal", False) + tc.variables["WITH_GDCM"] = self.options.get_safe("with_gdcm", False) + tc.variables["WITH_EIGEN"] = self.options.with_eigen + tc.variables["WITH_DSHOW"] = is_msvc(self) + tc.variables["WITH_MSMF"] = self.options.get_safe("with_msmf", False) + tc.variables["WITH_MSMF_DXVA"] = self.options.get_safe("with_msmf_dxva", False) + tc.variables["OPENCV_MODULES_PUBLIC"] = "opencv" + tc.variables["OPENCV_ENABLE_NONFREE"] = self.options.nonfree + + if self.options.cpu_baseline or self.options.cpu_baseline == "": + tc.variables["CPU_BASELINE"] = self.options.cpu_baseline + + if self.options.cpu_dispatch or self.options.cpu_dispatch == "": + tc.variables["CPU_DISPATCH"] = self.options.cpu_dispatch + + tc.variables["ENABLE_NEON"] = self.options.get_safe("neon", False) + + tc.variables["OPENCV_DNN_CUDA"] = self.options.get_safe("dnn_cuda", False) + + if Version(self.version) >= "4.6.0": + tc.variables["WITH_OPENVINO"] = False + tc.variables["WITH_TIMVX"] = False + else: + tc.variables["WITH_INF_ENGINE"] = False + tc.variables["WITH_NGRAPH"] = False + + if Version(self.version) >= "4.7.0": + tc.variables["ENABLE_DELAYLOAD"] = False + tc.variables["WITH_CANN"] = False + tc.variables["WITH_SPNG"] = False # TODO: change with_png recipe option in order to use either libpng or libspng + tc.variables["WITH_WAYLAND"] = self.options.get_safe("with_wayland", False) + + if Version(self.version) >= "4.8.0": + tc.variables["WITH_AVIF"] = self.options.get_safe("with_avif", False) + tc.variables["WITH_FLATBUFFERS"] = self.options.get_safe("with_flatbuffers", False) + + # Special world option merging all enabled modules into one big library file + tc.variables["BUILD_opencv_world"] = self.options.world + + # Main modules + tc.variables["BUILD_opencv_core"] = True + for module in OPENCV_MAIN_MODULES_OPTIONS: + tc.variables[f"BUILD_opencv_{module}"] = self.options.get_safe(module, False) + tc.variables["WITH_PROTOBUF"] = self.options.get_safe("with_protobuf", False) + if self.options.get_safe("with_protobuf"): + tc.variables["PROTOBUF_UPDATE_FILES"] = True + tc.variables["WITH_ADE"] = self.options.gapi + + # Extra modules + if any([self.options.get_safe(module) for module in OPENCV_EXTRA_MODULES_OPTIONS]) or self.options.with_cuda: + tc.variables["OPENCV_EXTRA_MODULES_PATH"] = self._extra_modules_folder.replace("\\", "/") + tc.variables["BUILD_opencv_cudev"] = self.options.with_cuda + for module in OPENCV_EXTRA_MODULES_OPTIONS: + tc.variables[f"BUILD_opencv_{module}"] = self.options.get_safe(module, False) + tc.variables["BUILD_opencv_cnn_3dobj"] = False + if Version(self.version) >= "4.4.0": + tc.variables["BUILD_opencv_julia"] = False + tc.variables["BUILD_opencv_matlab"] = False + if self.options.text: + tc.variables["WITH_TESSERACT"] = self.options.with_tesseract + + if self.options.get_safe("with_jpeg2000") == "openjpeg": + openjpeg_version = Version(self.dependencies["openjpeg"].ref.version) + tc.variables["OPENJPEG_MAJOR_VERSION"] = openjpeg_version.major + tc.variables["OPENJPEG_MINOR_VERSION"] = openjpeg_version.minor + tc.variables["OPENJPEG_BUILD_VERSION"] = openjpeg_version.patch + + tc.variables["WITH_CUDA"] = self.options.with_cuda + if self.options.with_cuda: + # This allows compilation on older GCC/NVCC, otherwise build errors. + tc.variables["CUDA_NVCC_FLAGS"] = "--expt-relaxed-constexpr" + if self.options.cuda_arch_bin: + tc.variables["CUDA_ARCH_BIN"] = self.options.cuda_arch_bin + tc.variables["WITH_CUBLAS"] = self.options.get_safe("with_cublas", False) + tc.variables["WITH_CUFFT"] = self.options.get_safe("with_cufft", False) + tc.variables["WITH_CUDNN"] = self.options.get_safe("with_cudnn", False) + + tc.variables["ENABLE_PIC"] = self.options.get_safe("fPIC", True) + tc.variables["ENABLE_CCACHE"] = False + + if is_msvc(self): + tc.variables["BUILD_WITH_STATIC_CRT"] = is_msvc_static_runtime(self) + + if self.settings.os == "Android": + tc.variables["BUILD_ANDROID_EXAMPLES"] = False + + tc.generate() + + CMakeDeps(self).generate() + + if self.options.get_safe("with_wayland"): + deps = PkgConfigDeps(self) + if self._is_legacy_one_profile: + # Manually generate pkgconfig file of wayland-protocols since + # PkgConfigDeps.build_context_activated can't work with legacy 1 profile + wp_prefix = self.dependencies.build["wayland-protocols"].package_folder + wp_version = self.dependencies.build["wayland-protocols"].ref.version + wp_pkg_content = textwrap.dedent(f"""\ + prefix={wp_prefix} + datarootdir=${{prefix}}/res + pkgdatadir=${{datarootdir}}/wayland-protocols + Name: Wayland Protocols + Description: Wayland protocol files + Version: {wp_version} + """) + save(self, os.path.join(self.generators_folder, "wayland-protocols.pc"), wp_pkg_content) + else: + deps.build_context_activated = ["wayland-protocols"] + deps.generate() + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "cmake")) + if os.path.isfile(os.path.join(self.package_folder, "setup_vars_opencv4.cmd")): + rename(self, os.path.join(self.package_folder, "setup_vars_opencv4.cmd"), + os.path.join(self.package_folder, "res", "setup_vars_opencv4.cmd")) + + self._create_cmake_module_variables(os.path.join(self.package_folder, self._module_vars_rel_path)) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + targets_mapping = {self._cmake_target(k): f"opencv::{self._cmake_target(k)}" for k in self._opencv_modules.keys()} + if self.options.world: + targets_mapping.update({"opencv_world": "opencv::opencv_world"}) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_target_rel_path), + targets_mapping, + ) + + def _create_cmake_module_variables(self, module_file): + """ + Define several CMake variables from upstream CMake config file not defined by default by CMakeDeps. + See https://github.com/opencv/opencv/blob/4.8.1/cmake/templates/OpenCVConfig.cmake.in + """ + v = Version(self.version) + content = textwrap.dedent(f"""\ + if(NOT DEFINED OpenCV_LIBS) + set(OpenCV_LIBS opencv::opencv) + endif() + if(NOT DEFINED OpenCV_VERSION_MAJOR) + set(OpenCV_VERSION_MAJOR {v.major}) + endif() + if(NOT DEFINED OpenCV_VERSION_MINOR) + set(OpenCV_VERSION_MINOR {v.minor}) + endif() + if(NOT DEFINED OpenCV_VERSION_PATCH) + set(OpenCV_VERSION_PATCH {v.patch}) + endif() + """) + save(self, module_file, content) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_vars_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + @property + def _module_target_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + # returns true if GTK2 is selected. To do this, the version option + # of the gtk/system package is checked or the conan package version + # of an gtk conan package is checked. + @property + def _is_gtk_version2(self): + if not self.options.get_safe("with_gtk", False): + return False + gtk_version = self.dependencies["gtk"].ref.version + if gtk_version == "system": + return self.dependencies["gtk"].options.version == 2 + else: + return Version(gtk_version) < "3.0.0" + + @staticmethod + def _cmake_target(module): + if module in ("ippiw", "correspondence", "multiview", "numeric"): + return module + return f"opencv_{module}" + + def package_info(self): + version = self.version.split(".") + version = "".join(version) if self.settings.os == "Windows" else "" + debug = "d" if self.settings.build_type == "Debug" and self.settings.os == "Windows" else "" + + def get_libs(module): + if module == "ippiw": + return [ + f"{module}{debug}", + "ippicvmt" if self.settings.os == "Windows" else "ippicv", + ] + elif module in ("correspondence", "multiview", "numeric"): + return [module] + else: + libs = [f"opencv_{module}{version}{debug}"] + if module in ["core", "world"] and not self.options.shared: + lib_exclude_filter = "(opencv_|ippi|correspondence|multiview|numeric).*" + libs += list(filter(lambda x: not re.match(lib_exclude_filter, x), collect_libs(self))) + return libs + + def add_components(modules): + if self.options.world: + self.cpp_info.components["opencv_world"].set_property("cmake_target_name", "opencv_world") + self.cpp_info.components["opencv_world"].libs = get_libs("world") + self.cpp_info.components["opencv_world"].resdirs = ["res"] + if self.settings.os != "Windows": + self.cpp_info.components["opencv_world"].includedirs.append(os.path.join("include", "opencv4")) + world_requires = set() + world_requires_exclude = set() + world_system_libs = set() + world_frameworks = set() + + for module, values in modules.items(): + if not values.get("is_built"): + continue + cmake_target = self._cmake_target(module) + conan_component = cmake_target + # TODO: we should also define COMPONENTS names of each target for find_package() but + # not possible yet in CMakeDeps. See https://github.com/conan-io/conan/issues/10258 + self.cpp_info.components[conan_component].set_property("cmake_target_name", cmake_target) + self.cpp_info.components[conan_component].resdirs = ["res"] + if self.settings.os != "Windows": + self.cpp_info.components[conan_component].includedirs.append(os.path.join("include", "opencv4")) + + module_requires = values.get("requires", []) + module_system_libs = [] + for _condition, _system_libs in values.get("system_libs", []): + if _condition: + module_system_libs.extend(_system_libs) + module_frameworks = [] + for _condition, _frameworks in values.get("frameworks", []): + if _condition: + module_frameworks.extend(_frameworks) + + if self.options.world and values.get("is_part_of_world", True): + self.cpp_info.components[conan_component].requires = ["opencv_world"] + world_requires.update(module_requires) + world_requires_exclude.add(conan_component) + world_system_libs.update(module_system_libs) + world_frameworks.update(module_frameworks) + else: + self.cpp_info.components[conan_component].libs = get_libs(module) + self.cpp_info.components[conan_component].requires = module_requires + self.cpp_info.components[conan_component].system_libs = module_system_libs + self.cpp_info.components[conan_component].frameworks = module_frameworks + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components[conan_component].names["cmake_find_package"] = cmake_target + self.cpp_info.components[conan_component].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.components[conan_component].build_modules["cmake_find_package"] = [self._module_vars_rel_path, self._module_target_rel_path] + self.cpp_info.components[conan_component].build_modules["cmake_find_package_multi"] = [self._module_vars_rel_path, self._module_target_rel_path] + if module != cmake_target: + conan_component_alias = conan_component + "_alias" + self.cpp_info.components[conan_component_alias].names["cmake_find_package"] = module + self.cpp_info.components[conan_component_alias].names["cmake_find_package_multi"] = module + self.cpp_info.components[conan_component_alias].requires = [conan_component] + self.cpp_info.components[conan_component_alias].bindirs = [] + self.cpp_info.components[conan_component_alias].includedirs = [] + self.cpp_info.components[conan_component_alias].libdirs = [] + + if self.options.world: + self.cpp_info.components["opencv_world"].requires = list(world_requires - world_requires_exclude) + self.cpp_info.components["opencv_world"].system_libs = list(world_system_libs) + self.cpp_info.components["opencv_world"].frameworks = list(world_frameworks) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["opencv_world"].build_modules["cmake_find_package"] = [self._module_vars_rel_path, self._module_target_rel_path] + self.cpp_info.components["opencv_world"].build_modules["cmake_find_package_multi"] = [self._module_vars_rel_path, self._module_target_rel_path] + + self.cpp_info.set_property("cmake_file_name", "OpenCV") + self.cpp_info.set_property("cmake_build_modules", [self._module_vars_rel_path]) + + add_components(self._opencv_modules) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "OpenCV" + self.cpp_info.filenames["cmake_find_package_multi"] = "OpenCV" diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0001-find-openexr.patch b/thirdparty/opencv/4.x/patches/4.1.2-0001-find-openexr.patch new file mode 100644 index 0000000000..5fb088fdf0 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0001-find-openexr.patch @@ -0,0 +1,18 @@ +--- a/cmake/OpenCVFindOpenEXR.cmake ++++ b/cmake/OpenCVFindOpenEXR.cmake +@@ -9,6 +9,15 @@ + # OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR. + # + ++find_package(OpenEXR REQUIRED) ++if(TARGET OpenEXR::OpenEXR) ++ set(OPENEXR_LIBRARIES OpenEXR::OpenEXR) ++else() ++ set(OPENEXR_LIBRARIES openexr::openexr) ++endif() ++set(OPENEXR_FOUND TRUE) ++set(OPENEXR_VERSION ${OpenEXR_VERSION}) ++return() + SET(OPENEXR_LIBRARIES "") + SET(OPENEXR_LIBSEARCH_SUFFIXES "") + file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH) diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0002-find-ade.patch b/thirdparty/opencv/4.x/patches/4.1.2-0002-find-ade.patch new file mode 100644 index 0000000000..98f88b7c0e --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0002-find-ade.patch @@ -0,0 +1,11 @@ +--- a/modules/gapi/cmake/init.cmake ++++ b/modules/gapi/cmake/init.cmake +@@ -4,7 +4,7 @@ if(NOT WITH_ADE) + return() + endif() + +-if (ade_DIR) ++if (1) + # if ade_DIR is set, use ADE-supplied CMake script + # to set up variables to the prebuilt ADE + find_package(ade 0.1.0) diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0003-find-quirc.patch b/thirdparty/opencv/4.x/patches/4.1.2-0003-find-quirc.patch new file mode 100644 index 0000000000..acfad3e91a --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0003-find-quirc.patch @@ -0,0 +1,8 @@ +--- a/modules/objdetect/CMakeLists.txt ++++ b/modules/objdetect/CMakeLists.txt +@@ -5,3 +5,2 @@ if(HAVE_QUIRC) +- get_property(QUIRC_INCLUDE GLOBAL PROPERTY QUIRC_INCLUDE_DIR) +- ocv_include_directories(${QUIRC_INCLUDE}) +- ocv_target_link_libraries(${the_module} quirc) ++ find_package(quirc REQUIRED CONFIG) ++ ocv_target_link_libraries(${the_module} quirc::quirc) diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0004-jasper.patch b/thirdparty/opencv/4.x/patches/4.1.2-0004-jasper.patch new file mode 100644 index 0000000000..115bd9b90a --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0004-jasper.patch @@ -0,0 +1,20 @@ +--- a/modules/imgcodecs/src/grfmt_jpeg2000.cpp ++++ b/modules/imgcodecs/src/grfmt_jpeg2000.cpp +@@ -378,7 +378,7 @@ bool Jpeg2KDecoder::readComponent8u( uchar *data, void *_buffer, + + for( y = 0; y < yend - ystart; ) + { +- jas_seqent_t* pix_row = &jas_matrix_get( buffer, y / ystep, 0 ); ++ jas_seqent_t* pix_row = jas_matrix_getref( buffer, y / ystep, 0 ); + uchar* dst = data + (y - yoffset) * step - xoffset; + + if( xstep == 1 ) +@@ -444,7 +444,7 @@ bool Jpeg2KDecoder::readComponent16u( unsigned short *data, void *_buffer, + + for( y = 0; y < yend - ystart; ) + { +- jas_seqent_t* pix_row = &jas_matrix_get( buffer, y / ystep, 0 ); ++ jas_seqent_t* pix_row = jas_matrix_getref( buffer, y / ystep, 0 ); + ushort* dst = data + (y - yoffset) * step - xoffset; + + if( xstep == 1 ) diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0005-tracking-no-plot-deps.patch b/thirdparty/opencv/4.x/patches/4.1.2-0005-tracking-no-plot-deps.patch new file mode 100644 index 0000000000..9113058791 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0005-tracking-no-plot-deps.patch @@ -0,0 +1,7 @@ +--- a/contrib/modules/tracking/CMakeLists.txt ++++ b/contrib/modules/tracking/CMakeLists.txt +@@ -1,3 +1,3 @@ + set(the_description "Tracking API") +-ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_plot OPTIONAL opencv_dnn opencv_datasets WRAP java python) ++ocv_define_module(tracking opencv_imgproc opencv_core opencv_video OPTIONAL opencv_plot opencv_dnn opencv_datasets WRAP java python) + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow /wd4458) diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0006-hdf.patch b/thirdparty/opencv/4.x/patches/4.1.2-0006-hdf.patch new file mode 100644 index 0000000000..29f4b36e65 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0006-hdf.patch @@ -0,0 +1,21 @@ +--- a/contrib/modules/hdf/CMakeLists.txt ++++ b/contrib/modules/hdf/CMakeLists.txt +@@ -1,6 +1,4 @@ +-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) +- +-if(WIN32) ++if(0) + # windows cmake internal lookups are broken for now + # will lookup for headers and shared libs given HDF_DIR env + find_path(HDF5_INCLUDE_DIRS hdf5.h HINTS "$ENV{HDF5_DIR}\\..\\include") +@@ -16,8 +14,8 @@ if(WIN32) + set(HDF5_FOUND "NO") + endif() + else() +- if(NOT CMAKE_CROSSCOMPILING) # iOS build should not reuse OSX package +- find_package(HDF5) ++ if(1) ++ find_package(HDF5 CONFIG) + endif() + endif() + diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0007-android-install-layout.patch b/thirdparty/opencv/4.x/patches/4.1.2-0007-android-install-layout.patch new file mode 100644 index 0000000000..75157a1e7c --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0007-android-install-layout.patch @@ -0,0 +1,11 @@ +--- a/cmake/OpenCVInstallLayout.cmake ++++ b/cmake/OpenCVInstallLayout.cmake +@@ -1,7 +1,7 @@ + # message(STATUS "Initial install layout:") + # ocv_cmake_dump_vars("OPENCV_.*_INSTALL_PATH") + +-if(ANDROID) ++if(0) + + ocv_update(OPENCV_BIN_INSTALL_PATH "sdk/native/bin/${ANDROID_NDK_ABI_NAME}") + ocv_update(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}") diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0008-link-qt-targets.patch b/thirdparty/opencv/4.x/patches/4.1.2-0008-link-qt-targets.patch new file mode 100644 index 0000000000..b32a291681 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0008-link-qt-targets.patch @@ -0,0 +1,29 @@ +--- a/contrib/modules/cvv/CMakeLists.txt ++++ b/contrib/modules/cvv/CMakeLists.txt +@@ -14,7 +14,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) + foreach(dt5_dep Core Gui Widgets) + add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) + include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS}) +- list(APPEND CVV_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES}) ++ list(APPEND CVV_LIBRARIES Qt5::${dt5_dep}) + endforeach() + + ocv_glob_module_sources() +--- a/modules/highgui/CMakeLists.txt ++++ b/modules/highgui/CMakeLists.txt +@@ -58,13 +58,13 @@ if(HAVE_QT5) + foreach(dt5_dep Core Gui Widgets Test Concurrent) + add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) + include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS}) +- list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES}) ++ list(APPEND HIGHGUI_LIBRARIES Qt5::${dt5_dep}) + endforeach() + + if(HAVE_QT_OPENGL) + add_definitions(${Qt5OpenGL_DEFINITIONS}) + include_directories(${Qt5OpenGL_INCLUDE_DIRS}) +- list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES}) ++ list(APPEND HIGHGUI_LIBRARIES Qt5::OpenGL) + endif() + + elseif(HAVE_QT) diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0009-sfm-deps.patch b/thirdparty/opencv/4.x/patches/4.1.2-0009-sfm-deps.patch new file mode 100644 index 0000000000..c4ff008107 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0009-sfm-deps.patch @@ -0,0 +1,49 @@ +--- a/contrib/modules/sfm/CMakeLists.txt ++++ b/contrib/modules/sfm/CMakeLists.txt +@@ -9,8 +9,14 @@ find_package(Ceres QUIET) + if(NOT Ceres_FOUND) # Looks like Ceres find glog on the own, so separate search isn't necessary + find_package(Glog QUIET) + endif() ++if(NOT GFLAGS_LIBRARIES AND TARGET gflags::gflags) ++ set(GFLAGS_LIBRARIES gflags::gflags) ++endif() ++if(NOT GLOG_LIBRARIES AND TARGET glog::glog) ++ set(GLOG_LIBRARIES glog::glog) ++endif() + +-if((gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS)) ++if(0) + set(_fname "${CMAKE_CURRENT_BINARY_DIR}/test_sfm_deps.cpp") + file(WRITE "${_fname}" "#include \n#include \nint main() { (void)(0); return 0; }\n") + try_compile(SFM_DEPS_OK "${CMAKE_BINARY_DIR}" "${_fname}" +@@ -21,7 +27,7 @@ if((gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR GLOG + file(REMOVE "${_fname}") + message(STATUS "Checking SFM deps... ${SFM_DEPS_OK}") + else() +- set(SFM_DEPS_OK FALSE) ++ set(SFM_DEPS_OK TRUE) + endif() + + if(NOT HAVE_EIGEN OR NOT SFM_DEPS_OK) +--- a/contrib/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt ++++ b/contrib/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt +@@ -8,7 +8,7 @@ FILE(GLOB CORRESPONDENCE_HDRS *.h) + + ADD_LIBRARY(correspondence STATIC ${CORRESPONDENCE_SRC} ${CORRESPONDENCE_HDRS}) + +-TARGET_LINK_LIBRARIES(correspondence LINK_PRIVATE ${GLOG_LIBRARY} multiview) ++TARGET_LINK_LIBRARIES(correspondence LINK_PRIVATE ${GLOG_LIBRARIES} multiview) + IF(TARGET Eigen3::Eigen) + TARGET_LINK_LIBRARIES(correspondence LINK_PUBLIC Eigen3::Eigen) + ENDIF() +--- a/contrib/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt ++++ b/contrib/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt +@@ -17,7 +17,7 @@ SET(MULTIVIEW_SRC conditioning.cc + FILE(GLOB MULTIVIEW_HDRS *.h) + + ADD_LIBRARY(multiview STATIC ${MULTIVIEW_SRC} ${MULTIVIEW_HDRS}) +-TARGET_LINK_LIBRARIES(multiview LINK_PRIVATE ${GLOG_LIBRARY} numeric) ++TARGET_LINK_LIBRARIES(multiview LINK_PRIVATE ${GLOG_LIBRARIES} numeric) + IF(TARGET Eigen3::Eigen) + TARGET_LINK_LIBRARIES(multiview LINK_PUBLIC Eigen3::Eigen) + ENDIF() diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0010-compat-protobuf-ge-3.18.patch b/thirdparty/opencv/4.x/patches/4.1.2-0010-compat-protobuf-ge-3.18.patch new file mode 100644 index 0000000000..5bd6bfd1b3 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0010-compat-protobuf-ge-3.18.patch @@ -0,0 +1,22 @@ +--- a/modules/dnn/src/caffe/caffe_io.cpp ++++ b/modules/dnn/src/caffe/caffe_io.cpp +@@ -92,6 +92,7 @@ + #ifdef HAVE_PROTOBUF + #include + #include ++#include + #include + + #include +@@ -1111,7 +1112,11 @@ static const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 by + + bool ReadProtoFromBinary(ZeroCopyInputStream* input, Message *proto) { + CodedInputStream coded_input(input); ++#if GOOGLE_PROTOBUF_VERSION >= 3006000 ++ coded_input.SetTotalBytesLimit(kProtoReadBytesLimit); ++#else + coded_input.SetTotalBytesLimit(kProtoReadBytesLimit, 536870912); ++#endif + + return proto->ParseFromCodedStream(&coded_input); + } diff --git a/thirdparty/opencv/4.x/patches/4.1.2-0011-compat-openexr3.patch b/thirdparty/opencv/4.x/patches/4.1.2-0011-compat-openexr3.patch new file mode 100644 index 0000000000..3854d36a91 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.1.2-0011-compat-openexr3.patch @@ -0,0 +1,10 @@ +--- a/modules/imgcodecs/src/grfmt_exr.cpp ++++ b/modules/imgcodecs/src/grfmt_exr.cpp +@@ -56,6 +56,7 @@ + #include + #include + ++#include + #include + #include + #include diff --git a/thirdparty/opencv/4.x/patches/4.5.0-0002-find-ade.patch b/thirdparty/opencv/4.x/patches/4.5.0-0002-find-ade.patch new file mode 100644 index 0000000000..cf954ad2c0 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.0-0002-find-ade.patch @@ -0,0 +1,11 @@ +--- a/modules/gapi/cmake/init.cmake ++++ b/modules/gapi/cmake/init.cmake +@@ -7,7 +7,7 @@ if(NOT WITH_ADE) + return() + endif() + +-if(ade_DIR) ++if(1) + # if ade_DIR is set, use ADE-supplied CMake script + # to set up variables to the prebuilt ADE + find_package(ade 0.1.0) diff --git a/thirdparty/opencv/4.x/patches/4.5.1-0001-tracking-no-plot-deps.patch b/thirdparty/opencv/4.x/patches/4.5.1-0001-tracking-no-plot-deps.patch new file mode 100644 index 0000000000..6e57a96b98 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.1-0001-tracking-no-plot-deps.patch @@ -0,0 +1,13 @@ +--- a/contrib/modules/tracking/CMakeLists.txt ++++ b/contrib/modules/tracking/CMakeLists.txt +@@ -9,9 +9,9 @@ ocv_define_module(tracking + opencv_imgproc + opencv_core + opencv_video +- opencv_plot # samples only + ${debug_modules} + OPTIONAL ++ opencv_plot + opencv_dnn + opencv_datasets + opencv_highgui diff --git a/thirdparty/opencv/4.x/patches/4.5.1-0002-alphamat-header.patch b/thirdparty/opencv/4.x/patches/4.5.1-0002-alphamat-header.patch new file mode 100644 index 0000000000..847eeaa9e9 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.1-0002-alphamat-header.patch @@ -0,0 +1,11 @@ +--- a/contrib/modules/alphamat/include/opencv2/alphamat.hpp ++++ b/contrib/modules/alphamat/include/opencv2/alphamat.hpp +@@ -7,6 +7,8 @@ + #ifndef _OPENCV_ALPHAMAT_HPP_ + #define _OPENCV_ALPHAMAT_HPP_ + ++#include ++ + /** + * @defgroup alphamat Alpha Matting + * Alpha matting is used to extract a foreground object with soft boundaries from a background image. diff --git a/thirdparty/opencv/4.x/patches/4.5.2-0001-fix-zlib-static-android.patch b/thirdparty/opencv/4.x/patches/4.5.2-0001-fix-zlib-static-android.patch new file mode 100644 index 0000000000..5d3c6b55ce --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.2-0001-fix-zlib-static-android.patch @@ -0,0 +1,17 @@ +--- a/cmake/OpenCVFindLibsGrfmt.cmake ++++ b/cmake/OpenCVFindLibsGrfmt.cmake +@@ -7,12 +7,12 @@ if(BUILD_ZLIB) + ocv_clear_vars(ZLIB_FOUND) + else() + ocv_clear_internal_cache_vars(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) +- if(ANDROID) ++ if(0) + set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .so) + endif() + find_package(ZLIB "${MIN_VER_ZLIB}") +- if(ANDROID) ++ if(0) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + endif() diff --git a/thirdparty/opencv/4.x/patches/4.5.3-0001-find-openexr.patch b/thirdparty/opencv/4.x/patches/4.5.3-0001-find-openexr.patch new file mode 100644 index 0000000000..d78a290b65 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.3-0001-find-openexr.patch @@ -0,0 +1,23 @@ +--- a/cmake/OpenCVFindOpenEXR.cmake ++++ b/cmake/OpenCVFindOpenEXR.cmake +@@ -9,13 +9,15 @@ + # OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR. + # + +-find_package(OpenEXR 3.0 CONFIG QUIET) ++find_package(OpenEXR REQUIRED) + if(TARGET OpenEXR::OpenEXR) +- SET(OPENEXR_FOUND TRUE) +- SET(OPENEXR_LIBRARIES OpenEXR::OpenEXR) +- SET(OPENEXR_VERSION ${OpenEXR_VERSION}) +- return() ++ set(OPENEXR_LIBRARIES OpenEXR::OpenEXR) ++else() ++ set(OPENEXR_LIBRARIES openexr::openexr) + endif() ++set(OPENEXR_FOUND TRUE) ++set(OPENEXR_VERSION ${OpenEXR_VERSION}) ++return() + + SET(OPENEXR_LIBRARIES "") + SET(OPENEXR_LIBSEARCH_SUFFIXES "") diff --git a/thirdparty/opencv/4.x/patches/4.5.3-0002-link-qt-targets.patch b/thirdparty/opencv/4.x/patches/4.5.3-0002-link-qt-targets.patch new file mode 100644 index 0000000000..b9b34a9515 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.3-0002-link-qt-targets.patch @@ -0,0 +1,30 @@ +--- a/contrib/modules/cvv/CMakeLists.txt ++++ b/contrib/modules/cvv/CMakeLists.txt +@@ -14,7 +14,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) + foreach(dt5_dep Core Gui Widgets) + add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) + include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS}) +- list(APPEND CVV_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES}) ++ list(APPEND CVV_LIBRARIES Qt5::${dt5_dep}) + endforeach() + + ocv_glob_module_sources() +--- a/modules/highgui/CMakeLists.txt ++++ b/modules/highgui/CMakeLists.txt +@@ -69,14 +69,14 @@ if(HAVE_QT5) + foreach(dt5_dep Core Gui Widgets Test Concurrent) + add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) + include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS}) +- list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES}) ++ list(APPEND HIGHGUI_LIBRARIES Qt5::${dt5_dep}) + endforeach() + + if(HAVE_QT_OPENGL) + add_definitions(-DHAVE_QT_OPENGL) + add_definitions(${Qt5OpenGL_DEFINITIONS}) + include_directories(${Qt5OpenGL_INCLUDE_DIRS}) +- list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES}) ++ list(APPEND HIGHGUI_LIBRARIES Qt5::OpenGL) + endif() + elseif(HAVE_QT) + set(OPENCV_HIGHGUI_BUILTIN_BACKEND "QT4") diff --git a/thirdparty/opencv/4.x/patches/4.5.5-0001-find-openexr.patch b/thirdparty/opencv/4.x/patches/4.5.5-0001-find-openexr.patch new file mode 100644 index 0000000000..67e0aad7b7 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.5-0001-find-openexr.patch @@ -0,0 +1,32 @@ +--- a/cmake/OpenCVFindOpenEXR.cmake ++++ b/cmake/OpenCVFindOpenEXR.cmake +@@ -9,21 +9,15 @@ + # OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR. + # + +-if(NOT OPENCV_SKIP_OPENEXR_FIND_PACKAGE) +- find_package(OpenEXR 3 QUIET) +- #ocv_cmake_dump_vars(EXR) +- if(OpenEXR_FOUND) +- if(TARGET OpenEXR::OpenEXR) # OpenEXR 3+ +- set(OPENEXR_LIBRARIES OpenEXR::OpenEXR) +- set(OPENEXR_INCLUDE_PATHS "") +- set(OPENEXR_VERSION "${OpenEXR_VERSION}") +- set(OPENEXR_FOUND 1) +- return() +- else() +- message(STATUS "Unsupported find_package(OpenEXR) - missing OpenEXR::OpenEXR target (version ${OpenEXR_VERSION})") +- endif() +- endif() ++find_package(OpenEXR REQUIRED) ++if(TARGET OpenEXR::OpenEXR) ++ set(OPENEXR_LIBRARIES OpenEXR::OpenEXR) ++else() ++ set(OPENEXR_LIBRARIES openexr::openexr) + endif() ++set(OPENEXR_FOUND TRUE) ++set(OPENEXR_VERSION ${OpenEXR_VERSION}) ++return() + + SET(OPENEXR_LIBRARIES "") + SET(OPENEXR_LIBSEARCH_SUFFIXES "") diff --git a/thirdparty/opencv/4.x/patches/4.5.5-0002-objdetect-without-dnn.patch b/thirdparty/opencv/4.x/patches/4.5.5-0002-objdetect-without-dnn.patch new file mode 100644 index 0000000000..5313e7b762 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.5-0002-objdetect-without-dnn.patch @@ -0,0 +1,97 @@ +--- a/modules/objdetect/CMakeLists.txt ++++ b/modules/objdetect/CMakeLists.txt +@@ -1,5 +1,16 @@ + set(the_description "Object Detection") +-ocv_define_module(objdetect opencv_core opencv_imgproc opencv_calib3d opencv_dnn WRAP java objc python js) ++ocv_define_module(objdetect ++ opencv_core ++ opencv_imgproc ++ opencv_calib3d ++ OPTIONAL ++ opencv_dnn ++ WRAP ++ python ++ java ++ objc ++ js ++) + + if(HAVE_QUIRC) + get_property(QUIRC_INCLUDE GLOBAL PROPERTY QUIRC_INCLUDE_DIR) +--- a/modules/objdetect/src/face_detect.cpp ++++ b/modules/objdetect/src/face_detect.cpp +@@ -6,13 +6,16 @@ + + #include "opencv2/imgproc.hpp" + #include "opencv2/core.hpp" ++#ifdef HAVE_OPENCV_DNN + #include "opencv2/dnn.hpp" ++#endif + + #include + + namespace cv + { + ++#ifdef HAVE_OPENCV_DNN + class FaceDetectorYNImpl : public FaceDetectorYN + { + public: +@@ -273,6 +276,7 @@ class FaceDetectorYNImpl : public FaceDetectorYN + + std::vector priors; + }; ++#endif + + Ptr FaceDetectorYN::create(const String& model, + const String& config, +@@ -283,7 +287,12 @@ Ptr FaceDetectorYN::create(const String& model, + const int backend_id, + const int target_id) + { ++#ifdef HAVE_OPENCV_DNN + return makePtr(model, config, input_size, score_threshold, nms_threshold, top_k, backend_id, target_id); ++#else ++ CV_UNUSED(model); CV_UNUSED(config); CV_UNUSED(input_size); CV_UNUSED(score_threshold); CV_UNUSED(nms_threshold); CV_UNUSED(top_k); CV_UNUSED(backend_id); CV_UNUSED(target_id); ++ CV_Error(cv::Error::StsNotImplemented, "cv::FaceDetectorYN requires enabled 'dnn' module."); ++#endif + } + + } // namespace cv +--- a/modules/objdetect/src/face_recognize.cpp ++++ b/modules/objdetect/src/face_recognize.cpp +@@ -4,13 +4,17 @@ + + #include "precomp.hpp" + ++#include "opencv2/core.hpp" ++#ifdef HAVE_OPENCV_DNN + #include "opencv2/dnn.hpp" ++#endif + + #include + + namespace cv + { + ++#ifdef HAVE_OPENCV_DNN + class FaceRecognizerSFImpl : public FaceRecognizerSF + { + public: +@@ -173,10 +177,16 @@ class FaceRecognizerSFImpl : public FaceRecognizerSF + private: + dnn::Net net; + }; ++#endif + + Ptr FaceRecognizerSF::create(const String& model, const String& config, int backend_id, int target_id) + { ++#ifdef HAVE_OPENCV_DNN + return makePtr(model, config, backend_id, target_id); ++#else ++ CV_UNUSED(model); CV_UNUSED(config); CV_UNUSED(backend_id); CV_UNUSED(target_id); ++ CV_Error(cv::Error::StsNotImplemented, "cv::FaceRecognizerSF requires enabled 'dnn' module"); ++#endif + } + + } // namespace cv diff --git a/thirdparty/opencv/4.x/patches/4.5.5-0003-find-quirc.patch b/thirdparty/opencv/4.x/patches/4.5.5-0003-find-quirc.patch new file mode 100644 index 0000000000..e53df28368 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.5-0003-find-quirc.patch @@ -0,0 +1,12 @@ +--- a/modules/objdetect/CMakeLists.txt ++++ b/modules/objdetect/CMakeLists.txt +@@ -13,7 +13,6 @@ ocv_define_module(objdetect + ) + + if(HAVE_QUIRC) +- get_property(QUIRC_INCLUDE GLOBAL PROPERTY QUIRC_INCLUDE_DIR) +- ocv_include_directories(${QUIRC_INCLUDE}) +- ocv_target_link_libraries(${the_module} quirc) ++ find_package(quirc REQUIRED CONFIG) ++ ocv_target_link_libraries(${the_module} quirc::quirc) + endif() diff --git a/thirdparty/opencv/4.x/patches/4.5.5-0004-link-qt-targets.patch b/thirdparty/opencv/4.x/patches/4.5.5-0004-link-qt-targets.patch new file mode 100644 index 0000000000..4c497271a4 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.5.5-0004-link-qt-targets.patch @@ -0,0 +1,22 @@ +--- a/contrib/modules/cvv/CMakeLists.txt ++++ b/contrib/modules/cvv/CMakeLists.txt +@@ -14,7 +14,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) + foreach(dt5_dep Core Gui Widgets) + add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) + include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS}) +- list(APPEND CVV_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES}) ++ list(APPEND CVV_LIBRARIES Qt5::${dt5_dep}) + endforeach() + + ocv_glob_module_sources() +--- a/modules/highgui/CMakeLists.txt ++++ b/modules/highgui/CMakeLists.txt +@@ -89,7 +89,7 @@ if(HAVE_QT) + foreach(dt_dep ${qt_deps}) + add_definitions(${Qt${QT_VERSION_MAJOR}${dt_dep}_DEFINITIONS}) + include_directories(${Qt${QT_VERSION_MAJOR}${dt_dep}_INCLUDE_DIRS}) +- list(APPEND HIGHGUI_LIBRARIES ${Qt${QT_VERSION_MAJOR}${dt_dep}_LIBRARIES}) ++ list(APPEND HIGHGUI_LIBRARIES Qt${QT_VERSION_MAJOR}::${dt_dep}) + endforeach() + else() + ocv_assert(QT_VERSION_MAJOR EQUAL 4) diff --git a/thirdparty/opencv/4.x/patches/4.8.1-0001-find-ade.patch b/thirdparty/opencv/4.x/patches/4.8.1-0001-find-ade.patch new file mode 100644 index 0000000000..0e70b95358 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.8.1-0001-find-ade.patch @@ -0,0 +1,11 @@ +--- a/modules/gapi/cmake/init.cmake ++++ b/modules/gapi/cmake/init.cmake +@@ -8,7 +8,7 @@ if(NOT WITH_ADE) + return() + endif() + +-if(ade_DIR) ++if(1) + # if ade_DIR is set, use ADE-supplied CMake script + # to set up variables to the prebuilt ADE + find_package(ade 0.1.0) diff --git a/thirdparty/opencv/4.x/patches/4.8.1-0002-mingw-disable-obsensor.patch b/thirdparty/opencv/4.x/patches/4.8.1-0002-mingw-disable-obsensor.patch new file mode 100644 index 0000000000..33c9550f7c --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.8.1-0002-mingw-disable-obsensor.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -468,7 +468,7 @@ OCV_OPTION(WITH_TIMVX "Include Tim-VX support" OFF + VISIBLE_IF TRUE + VERIFY HAVE_TIMVX) + OCV_OPTION(WITH_OBSENSOR "Include obsensor support (Orbbec RGB-D modules: Astra+/Femto)" ON +- VISIBLE_IF (WIN32 AND NOT ARM AND NOT WINRT) OR ( UNIX AND NOT APPLE AND NOT ANDROID) ++ VISIBLE_IF (WIN32 AND NOT ARM AND NOT WINRT AND NOT MINGW) OR ( UNIX AND NOT APPLE AND NOT ANDROID) + VERIFY HAVE_OBSENSOR) + OCV_OPTION(WITH_CANN "Include CANN support" OFF + VISIBLE_IF TRUE diff --git a/thirdparty/opencv/4.x/patches/4.8.1-0004-link-qt-targets.patch b/thirdparty/opencv/4.x/patches/4.8.1-0004-link-qt-targets.patch new file mode 100644 index 0000000000..d4ceb77155 --- /dev/null +++ b/thirdparty/opencv/4.x/patches/4.8.1-0004-link-qt-targets.patch @@ -0,0 +1,22 @@ +--- a/contrib/modules/cvv/CMakeLists.txt ++++ b/contrib/modules/cvv/CMakeLists.txt +@@ -18,7 +18,7 @@ + set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + foreach(module ${CVV_QT_MODULES}) +- list(APPEND CVV_LIBRARIES ${Qt${QT_VERSION_MAJOR}${module}_LIBRARIES}) ++ list(APPEND CVV_LIBRARIES Qt${QT_VERSION_MAJOR}::${module}) + endforeach() + + ocv_glob_module_sources() +--- a/modules/highgui/CMakeLists.txt ++++ b/modules/highgui/CMakeLists.txt +@@ -116,7 +116,7 @@ if(HAVE_QT) + foreach(dt_dep ${qt_deps}) + add_definitions(${Qt${QT_VERSION_MAJOR}${dt_dep}_DEFINITIONS}) + include_directories(${Qt${QT_VERSION_MAJOR}${dt_dep}_INCLUDE_DIRS}) +- list(APPEND HIGHGUI_LIBRARIES ${Qt${QT_VERSION_MAJOR}${dt_dep}_LIBRARIES}) ++ list(APPEND HIGHGUI_LIBRARIES Qt${QT_VERSION_MAJOR}::${dt_dep}) + endforeach() + else() + ocv_assert(QT_VERSION_MAJOR EQUAL 4) diff --git a/thirdparty/opencv/4.x/test_package/CMakeLists.txt b/thirdparty/opencv/4.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000..5404f6ff23 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +enable_testing() + +set(TESTED_MODULES + # Main modules + "calib3d" "core" "dnn" "features2d" "flann" "gapi" "highgui" "imgcodecs" + "imgproc" "ml" "objdetect" "photo" "stitching" "video" "videoio" + # Extra modules + "alphamat" "aruco" "bgsegm" "bioinspired" "ccalib" "datasets" "dnn_superres" + "face" "freetype" "fuzzy" "hdf" "hfs" "img_hash" "intensity_transform" + "line_descriptor" "mcc" "optflow" "phase_unwrapping" "plot" "quality" "reg" + "rgbd" "saliency" "sfm" "shape" "structured_light" "superres" + "surface_matching" "text" "tracking" "wechat_qrcode" "xfeatures2d" + "ximgproc" "xobjdetect" "xphoto" +) + +find_package(OpenCV REQUIRED core CONFIG) + +foreach(_module ${TESTED_MODULES}) + string(TOUPPER ${_module} _module_upper) + if(OPENCV_WITH_${_module_upper}) + set(_test_target test_${_module}) + set(_module_target opencv_${_module}) + add_executable(${_test_target} ${_test_target}.cpp) + target_link_libraries(${_test_target} PRIVATE ${_module_target}) + target_compile_features(${_test_target} PRIVATE cxx_std_11) + if(NOT ${_module} STREQUAL "highgui") + add_test(NAME ${_test_target} COMMAND ${_test_target}) + endif() + endif() +endforeach() diff --git a/thirdparty/opencv/4.x/test_package/conanfile.py b/thirdparty/opencv/4.x/test_package/conanfile.py new file mode 100644 index 0000000000..e5b25fb84d --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/conanfile.py @@ -0,0 +1,55 @@ +from conan import ConanFile +from conan.tools.build import build_jobs, can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import chdir + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + @property + def _tested_modules(self): + return [ + # Main modules + "calib3d", "core", "dnn", "features2d", "flann", "gapi", "highgui", "imgcodecs", + "imgproc", "ml", "objdetect", "photo", "stitching", "video", "videoio", + # Extra modules + "alphamat", "aruco", "bgsegm", "bioinspired", "ccalib", "datasets", "dnn_superres", + "face", "freetype", "fuzzy", "hdf", "hfs", "img_hash", "intensity_transform", + "line_descriptor", "mcc", "optflow", "phase_unwrapping", "plot", "quality", "reg", + "rgbd", "saliency", "sfm", "shape", "structured_light", "superres", + "surface_matching", "text", "tracking", "wechat_qrcode", "xfeatures2d", + "ximgproc", "xobjdetect", "xphoto", + ] + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + for module in self._tested_modules: + cmake_option = f"OPENCV_WITH_{module.upper()}" + if module == "core": + tc.variables[cmake_option] = True + elif module == "imgcodecs": + tc.variables[cmake_option] = self.dependencies["opencv"].options.imgcodecs and self.dependencies["opencv"].options.with_png + elif module == "videoio": + tc.variables[cmake_option] = self.dependencies["opencv"].options.videoio and self.dependencies["opencv"].options.with_ffmpeg + else: + tc.variables[cmake_option] = self.dependencies["opencv"].options.get_safe(module, False) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + with chdir(self, self.build_folder): + self.run(f"ctest --output-on-failure -C {self.settings.build_type} -j {build_jobs(self)}", env="conanrun") diff --git a/thirdparty/opencv/4.x/test_package/test_alphamat.cpp b/thirdparty/opencv/4.x/test_package/test_alphamat.cpp new file mode 100644 index 0000000000..af8ea966d9 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_alphamat.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() { + cv::Mat image = cv::Mat::ones(400, 400, CV_8UC3) * 50; + cv::Mat tmap = cv::Mat::ones(400, 400, CV_8U) * 120; + cv::Mat result; + cv::alphamat::infoFlow(image, tmap, result); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_aruco.cpp b/thirdparty/opencv/4.x/test_package/test_aruco.cpp new file mode 100644 index 0000000000..bc510aeaf4 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_aruco.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + cv::Mat markerImage; + auto dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250); + cv::aruco::drawMarker(dictionary, 23, 200, markerImage, 1); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_bgsegm.cpp b/thirdparty/opencv/4.x/test_package/test_bgsegm.cpp new file mode 100644 index 0000000000..ba01af2fd1 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_bgsegm.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto bkg_subtractor = cv::bgsegm::createBackgroundSubtractorCNT(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_bioinspired.cpp b/thirdparty/opencv/4.x/test_package/test_bioinspired.cpp new file mode 100644 index 0000000000..219fc93559 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_bioinspired.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto retina_tone_mapping = cv::bioinspired::RetinaFastToneMapping::create(cv::Size(10, 10)); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_calib3d.cpp b/thirdparty/opencv/4.x/test_package/test_calib3d.cpp new file mode 100644 index 0000000000..ce5c7e8b7c --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_calib3d.cpp @@ -0,0 +1,26 @@ +#include +#include + +#include +#include + +int main() { + const int point_count = 100; + std::vector points1; + points1.reserve(point_count); + std::vector points2; + points2.reserve(point_count); + for (int i = 0; i < point_count; ++i) { + points1.emplace_back( + cv::Point2f(static_cast(100 + 30 * std::cos(i * CV_PI * 2 / 5)), + static_cast(100 - 30 * std::sin(i * CV_PI * 2 / 5))) + ); + points2.emplace_back( + cv::Point2f(static_cast(100 + 30 * std::sin(i * CV_PI * 2 / 5)), + static_cast(100 - 30 * std::cos(i * CV_PI * 2 / 5))) + ); + } + auto fundamental_matrix = cv::findFundamentalMat(points1, points2, cv::FM_RANSAC, 3, 0.99); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_ccalib.cpp b/thirdparty/opencv/4.x/test_package/test_ccalib.cpp new file mode 100644 index 0000000000..079bcb7ba2 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_ccalib.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + cv::randpattern::RandomPatternGenerator generator(50, 50); + generator.generatePattern(); + auto pattern = generator.getPattern(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_core.cpp b/thirdparty/opencv/4.x/test_package/test_core.cpp new file mode 100644 index 0000000000..b9635e35d0 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_core.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + cv::Mat m = cv::Mat::zeros(400, 400, CV_8UC3); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_datasets.cpp b/thirdparty/opencv/4.x/test_package/test_datasets.cpp new file mode 100644 index 0000000000..16c5eca1c9 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_datasets.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto dataset = cv::datasets::AR_hmdb::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_dnn.cpp b/thirdparty/opencv/4.x/test_package/test_dnn.cpp new file mode 100644 index 0000000000..3d8474fcdd --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_dnn.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto backends = cv::dnn::getAvailableBackends(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_dnn_superres.cpp b/thirdparty/opencv/4.x/test_package/test_dnn_superres.cpp new file mode 100644 index 0000000000..bbe3442b46 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_dnn_superres.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + cv::dnn_superres::DnnSuperResImpl dnn_superres_impl; + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_face.cpp b/thirdparty/opencv/4.x/test_package/test_face.cpp new file mode 100644 index 0000000000..9e3953a255 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_face.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto face_recognizer = cv::face::FisherFaceRecognizer::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_features2d.cpp b/thirdparty/opencv/4.x/test_package/test_features2d.cpp new file mode 100644 index 0000000000..2154a2126e --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_features2d.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto matcher = cv::DescriptorMatcher::create(cv::DescriptorMatcher::BRUTEFORCE); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_flann.cpp b/thirdparty/opencv/4.x/test_package/test_flann.cpp new file mode 100644 index 0000000000..0461a26511 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_flann.cpp @@ -0,0 +1,28 @@ +#include +#include + +#include +#include + +int main() { + const int point_count = 100; + std::vector points; + points.reserve(point_count); + for (int i = 0; i < point_count; ++i) { + points.emplace_back( + cv::Point2f(static_cast(100 + 30 * std::cos(i * CV_PI * 2 / 5)), + static_cast(100 - 30 * std::sin(i * CV_PI * 2 / 5))) + ); + } + + cv::flann::KDTreeIndexParams indexParams; + cv::flann::Index kdtree(cv::Mat(points).reshape(1), indexParams); + + std::vector query{110, 98}; + + std::vector indices; + std::vector dists; + kdtree.knnSearch(query, indices, dists, 3); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_freetype.cpp b/thirdparty/opencv/4.x/test_package/test_freetype.cpp new file mode 100644 index 0000000000..49ee14c10e --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_freetype.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto ft2 = cv::freetype::createFreeType2(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_fuzzy.cpp b/thirdparty/opencv/4.x/test_package/test_fuzzy.cpp new file mode 100644 index 0000000000..ad4485785a --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_fuzzy.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + cv::Mat image = cv::Mat::zeros(400, 400, CV_8UC3); + cv::Mat output; + cv::ft::FT02D_FL_process(image, 10, output); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_gapi.cpp b/thirdparty/opencv/4.x/test_package/test_gapi.cpp new file mode 100644 index 0000000000..1894733df9 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_gapi.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +int main() { + // derived from https://docs.opencv.org/4.5.0/d0/d1e/gapi.html + cv::GMat in; + cv::GMat vga = cv::gapi::resize(in, cv::Size(), 0.5, 0.5); + cv::GMat gray = cv::gapi::BGR2Gray(vga); + cv::GMat blurred = cv::gapi::blur(gray, cv::Size(5,5)); + cv::GMat edges = cv::gapi::Canny(blurred, 32, 128, 3); + cv::GMat b,g,r; + std::tie(b,g,r) = cv::gapi::split3(vga); + cv::GMat out = cv::gapi::merge3(b, g | edges, r); + cv::GComputation ac(in, out); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_hdf.cpp b/thirdparty/opencv/4.x/test_package/test_hdf.cpp new file mode 100644 index 0000000000..94d3e97ba4 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_hdf.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto hdf5 = cv::hdf::open("test_package_hdf.h5"); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_hfs.cpp b/thirdparty/opencv/4.x/test_package/test_hfs.cpp new file mode 100644 index 0000000000..8d5391b6b1 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_hfs.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto hfs_segment = cv::hfs::HfsSegment::create(100, 100); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_highgui.cpp b/thirdparty/opencv/4.x/test_package/test_highgui.cpp new file mode 100644 index 0000000000..69025d66e0 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_highgui.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() { + cv::Mat image = cv::Mat::zeros(400, 400, CV_8UC3); + cv::imshow("test highgui", image); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_img_hash.cpp b/thirdparty/opencv/4.x/test_package/test_img_hash.cpp new file mode 100644 index 0000000000..73ca684981 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_img_hash.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() { + cv::Mat image = cv::Mat::zeros(400, 400, CV_8UC3); + auto func = cv::img_hash::AverageHash::create(); + cv::Mat hash; + func->compute(image, hash); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_imgcodecs.cpp b/thirdparty/opencv/4.x/test_package/test_imgcodecs.cpp new file mode 100644 index 0000000000..909d28ae94 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_imgcodecs.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + cv::Mat img = cv::Mat::zeros(400, 400, CV_8UC3); + cv::imwrite("test_imgcodecs.png", img); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_imgproc.cpp b/thirdparty/opencv/4.x/test_package/test_imgproc.cpp new file mode 100644 index 0000000000..23784d8f0a --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_imgproc.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main() { + const int width = 400; + cv::Mat image = cv::Mat::zeros(width, width, CV_8UC3); + + cv::ellipse( + image, cv::Point(width / 2, width / 2), cv::Size(width / 4, width / 16), + 90, 0, 360, cv::Scalar(255, 0, 0), 2, 8 + ); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_intensity_transform.cpp b/thirdparty/opencv/4.x/test_package/test_intensity_transform.cpp new file mode 100644 index 0000000000..dce55e2e9e --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_intensity_transform.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + cv::Mat src_image = cv::Mat::zeros(400, 400, CV_8UC3); + cv::Mat dst_image; + cv::intensity_transform::autoscaling(src_image, dst_image); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_line_descriptor.cpp b/thirdparty/opencv/4.x/test_package/test_line_descriptor.cpp new file mode 100644 index 0000000000..a9c8f66bb0 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_line_descriptor.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto descriptor = cv::line_descriptor::BinaryDescriptor::createBinaryDescriptor(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_mcc.cpp b/thirdparty/opencv/4.x/test_package/test_mcc.cpp new file mode 100644 index 0000000000..7b2647b223 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_mcc.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto checker_detector = cv::mcc::CCheckerDetector::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_ml.cpp b/thirdparty/opencv/4.x/test_package/test_ml.cpp new file mode 100644 index 0000000000..e53dbd4cf9 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_ml.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto dtrees = cv::ml::DTrees::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_objdetect.cpp b/thirdparty/opencv/4.x/test_package/test_objdetect.cpp new file mode 100644 index 0000000000..2533cbb506 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_objdetect.cpp @@ -0,0 +1,17 @@ +#include +#include + +#include + +int main() { + std::vector rectangles; + rectangles.reserve(100); + for (int i = 0; i < 10; ++i) { + for (int j = 0; j < 10; ++j) { + rectangles.emplace_back(cv::Rect(10 * i, 5 * (i + j), 2, 3)); + } + } + cv::groupRectangles(rectangles, 2); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_optflow.cpp b/thirdparty/opencv/4.x/test_package/test_optflow.cpp new file mode 100644 index 0000000000..f7ef8c92b7 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_optflow.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + auto tree = cv::optflow::GPCTree::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_phase_unwrapping.cpp b/thirdparty/opencv/4.x/test_package/test_phase_unwrapping.cpp new file mode 100644 index 0000000000..d8863b429e --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_phase_unwrapping.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto histogram_phase_unwrapping = cv::phase_unwrapping::HistogramPhaseUnwrapping::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_photo.cpp b/thirdparty/opencv/4.x/test_package/test_photo.cpp new file mode 100644 index 0000000000..4a94f1b4c0 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_photo.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() { + auto src_image = cv::Mat::zeros(400, 400, CV_8UC3); + cv::Mat dst_image; + cv::fastNlMeansDenoising(src_image, dst_image); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_plot.cpp b/thirdparty/opencv/4.x/test_package/test_plot.cpp new file mode 100644 index 0000000000..40dc21023a --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_plot.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main() { + cv::Mat xData; + xData.create(1, 100, CV_64F); + for (int i = 0; i < 100; ++i) { + xData.at(i) = i / 10.0; + } + auto plot = cv::plot::Plot2d::create(xData); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_quality.cpp b/thirdparty/opencv/4.x/test_package/test_quality.cpp new file mode 100644 index 0000000000..75faaa7e15 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_quality.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() { + cv::Mat image = cv::Mat::ones(10, 10, CV_8UC3) * 40; + auto quality_mse = cv::quality::QualityMSE::create(image); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_reg.cpp b/thirdparty/opencv/4.x/test_package/test_reg.cpp new file mode 100644 index 0000000000..26957e3fa3 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_reg.cpp @@ -0,0 +1,9 @@ +#include + +int main() { + cv::reg::MapProjec map; + map.scale(5.5); + map.inverseMap(); + map.normalize(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_rgbd.cpp b/thirdparty/opencv/4.x/test_package/test_rgbd.cpp new file mode 100644 index 0000000000..f4c2a3c31e --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_rgbd.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + auto depth_cleaner = cv::rgbd::DepthCleaner::create(5); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_saliency.cpp b/thirdparty/opencv/4.x/test_package/test_saliency.cpp new file mode 100644 index 0000000000..c393801133 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_saliency.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto objectness_bing = cv::saliency::ObjectnessBING::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_sfm.cpp b/thirdparty/opencv/4.x/test_package/test_sfm.cpp new file mode 100644 index 0000000000..e4b4bacb2a --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_sfm.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() { + cv::Vec3f a; + a << 1,2,3; + cv::Matx33f ax = cv::sfm::skew(a); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_shape.cpp b/thirdparty/opencv/4.x/test_package/test_shape.cpp new file mode 100644 index 0000000000..ef5e9500ab --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_shape.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto extractor = cv::createChiHistogramCostExtractor(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_stitching.cpp b/thirdparty/opencv/4.x/test_package/test_stitching.cpp new file mode 100644 index 0000000000..8a445823ef --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_stitching.cpp @@ -0,0 +1,13 @@ +#include +#include + +int main() { + cv::Rect roi; + bool overlap = cv::detail::overlapRoi( + cv::Point2f(2, 3), cv::Point2f(4, -3), + cv::Size(10, 10), cv::Size(3, 4), + roi + ); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_structured_light.cpp b/thirdparty/opencv/4.x/test_package/test_structured_light.cpp new file mode 100644 index 0000000000..d6f0b0661c --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_structured_light.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto pattern = cv::structured_light::GrayCodePattern::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_superres.cpp b/thirdparty/opencv/4.x/test_package/test_superres.cpp new file mode 100644 index 0000000000..7009750003 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_superres.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto frame_source = cv::superres::createFrameSource_Empty(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_surface_matching.cpp b/thirdparty/opencv/4.x/test_package/test_surface_matching.cpp new file mode 100644 index 0000000000..3a21508428 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_surface_matching.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + cv::ppf_match_3d::PPF3DDetector detector(0.03, 0.05); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_text.cpp b/thirdparty/opencv/4.x/test_package/test_text.cpp new file mode 100644 index 0000000000..1c8dbed4b8 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_text.cpp @@ -0,0 +1,11 @@ +#include +#include + +#include + +int main() { + cv::Mat image = cv::Mat::zeros(10, 10, CV_8UC3); + std::vector channels; + cv::text::computeNMChannels(image, channels); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_tracking.cpp b/thirdparty/opencv/4.x/test_package/test_tracking.cpp new file mode 100644 index 0000000000..69efe349df --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_tracking.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto kcf_tracker = cv::TrackerKCF::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_video.cpp b/thirdparty/opencv/4.x/test_package/test_video.cpp new file mode 100644 index 0000000000..09a4342add --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_video.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + auto bkg_subtractor_knn = cv::createBackgroundSubtractorKNN(); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_videoio.cpp b/thirdparty/opencv/4.x/test_package/test_videoio.cpp new file mode 100644 index 0000000000..7b0955e888 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_videoio.cpp @@ -0,0 +1,11 @@ +#include +#include + +#include + +int main() { + if (!cv::videoio_registry::hasBackend(cv::CAP_FFMPEG)) + throw std::runtime_error("FFmpeg backend was not found"); + + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_wechat_qrcode.cpp b/thirdparty/opencv/4.x/test_package/test_wechat_qrcode.cpp new file mode 100644 index 0000000000..6dce15eeb7 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_wechat_qrcode.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + cv::Mat image = cv::Mat::ones(100, 100, CV_8UC3) * 50; + cv::wechat_qrcode::WeChatQRCode wechat_qrcode; + auto decoded_strings = wechat_qrcode.detectAndDecode(image); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_xfeatures2d.cpp b/thirdparty/opencv/4.x/test_package/test_xfeatures2d.cpp new file mode 100644 index 0000000000..673b9737b4 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_xfeatures2d.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto vgg = cv::xfeatures2d::VGG::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_ximgproc.cpp b/thirdparty/opencv/4.x/test_package/test_ximgproc.cpp new file mode 100644 index 0000000000..b4804362da --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_ximgproc.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto feature_getter = cv::ximgproc::createRFFeatureGetter(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_xobjdetect.cpp b/thirdparty/opencv/4.x/test_package/test_xobjdetect.cpp new file mode 100644 index 0000000000..15cecaff5b --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_xobjdetect.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto detector = cv::xobjdetect::WBDetector::create(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_package/test_xphoto.cpp b/thirdparty/opencv/4.x/test_package/test_xphoto.cpp new file mode 100644 index 0000000000..5c0eb661f2 --- /dev/null +++ b/thirdparty/opencv/4.x/test_package/test_xphoto.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto grayworld_wb = cv::xphoto::createGrayworldWB(); + return 0; +} diff --git a/thirdparty/opencv/4.x/test_v1_package/CMakeLists.txt b/thirdparty/opencv/4.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..c23ed5cfe6 --- /dev/null +++ b/thirdparty/opencv/4.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_v1_package) + +enable_testing() + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/thirdparty/opencv/4.x/test_v1_package/conanfile.py b/thirdparty/opencv/4.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000..9aa234fbd8 --- /dev/null +++ b/thirdparty/opencv/4.x/test_v1_package/conanfile.py @@ -0,0 +1,47 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanException + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + @property + def _tested_modules(self): + return [ + # Main modules + "calib3d", "core", "dnn", "features2d", "flann", "gapi", "highgui", "imgcodecs", + "imgproc", "ml", "objdetect", "photo", "stitching", "video", "videoio", + # Extra modules + "alphamat", "aruco", "bgsegm", "bioinspired", "ccalib", "datasets", "dnn_superres", + "face", "freetype", "fuzzy", "hdf", "hfs", "img_hash", "intensity_transform", + "line_descriptor", "mcc", "optflow", "phase_unwrapping", "plot", "quality", "reg", + "rgbd", "saliency", "sfm", "shape", "structured_light", "superres", + "surface_matching", "text", "tracking", "wechat_qrcode", "xfeatures2d", + "ximgproc", "xobjdetect", "xphoto", + ] + + def _opencv_option(self, name, default): + try: + return getattr(self.options["opencv"], name, default) + except (AttributeError, ConanException): + return default + + def build(self): + cmake = CMake(self) + for module in self._tested_modules: + cmake_option = f"OPENCV_WITH_{module.upper()}" + if module == "core": + cmake.definitions[cmake_option] = True + elif module == "imgcodecs": + cmake.definitions[cmake_option] = self.options["opencv"].imgcodecs and self.options["opencv"].with_png + elif module == "videoio": + cmake.definitions[cmake_option] = self.options["opencv"].videoio and self.options["opencv"].with_ffmpeg + else: + cmake.definitions[cmake_option] = self._opencv_option(module, False) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(f"ctest --output-on-failure -C {self.settings.build_type} -j {tools.cpu_count()}", run_environment=True) diff --git a/thirdparty/opencv/config.yml b/thirdparty/opencv/config.yml new file mode 100644 index 0000000000..42e7008ac9 --- /dev/null +++ b/thirdparty/opencv/config.yml @@ -0,0 +1,17 @@ +versions: + "4.9.0": + folder: "4.x" + "4.8.1": + folder: "4.x" + "4.5.5": + folder: "4.x" + "4.5.3": + folder: "4.x" + "4.1.2": + folder: "4.x" + "3.4.20": + folder: "3.x" + "3.4.17": + folder: "3.x" + "2.4.13.7": + folder: "2.x" diff --git a/thirdparty/openssl/3.x.x/conandata.yml b/thirdparty/openssl/3.x.x/conandata.yml new file mode 100644 index 0000000000..35de37d5f9 --- /dev/null +++ b/thirdparty/openssl/3.x.x/conandata.yml @@ -0,0 +1,46 @@ +sources: + 3.3.0: + url: + - "https://github.com/openssl/openssl/releases/download/openssl-3.3.0/openssl-3.3.0.tar.gz" + sha256: 53e66b043322a606abf0087e7699a0e033a37fa13feb9742df35c3a33b18fb02 + 3.2.1: + url: + - "https://www.openssl.org/source/openssl-3.2.1.tar.gz" + - "https://github.com/openssl/openssl/releases/download/openssl-3.2.1/openssl-3.2.1.tar.gz" + sha256: 83c7329fe52c850677d75e5d0b0ca245309b97e8ecbcfdc1dfdc4ab9fac35b39 + 3.2.0: + url: + - "https://www.openssl.org/source/openssl-3.2.0.tar.gz" + - "https://github.com/openssl/openssl/releases/download/openssl-3.2.0/openssl-3.2.0.tar.gz" + sha256: 14c826f07c7e433706fb5c69fa9e25dab95684844b4c962a2cf1bf183eb4690e + 3.1.5: + url: + - "https://www.openssl.org/source/openssl-3.1.5.tar.gz" + - "https://github.com/openssl/openssl/releases/download/openssl-3.1.5/openssl-3.1.5.tar.gz" + sha256: 6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262 + 3.1.4: + url: + - "https://www.openssl.org/source/openssl-3.1.4.tar.gz" + - "https://github.com/openssl/openssl/releases/download/openssl-3.1.4/openssl-3.1.4.tar.gz" + sha256: 840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3 + 3.1.3: + url: + - "https://www.openssl.org/source/openssl-3.1.3.tar.gz" + - "https://github.com/openssl/openssl/releases/download/openssl-3.1.3/openssl-3.1.3.tar.gz" + sha256: f0316a2ebd89e7f2352976445458689f80302093788c466692fb2a188b2eacf6 + 3.0.13: + url: + - "https://www.openssl.org/source/openssl-3.0.13.tar.gz" + - "https://github.com/openssl/openssl/releases/download/openssl-3.0.13/openssl-3.0.13.tar.gz" + sha256: 88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313 + 3.0.12: + url: + - "https://www.openssl.org/source/openssl-3.0.12.tar.gz" + - "https://github.com/openssl/openssl/releases/download/openssl-3.0.12/openssl-3.0.12.tar.gz" + sha256: f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61 +patches: + 3.2.0: + - patch_file: "patches/3.2.0-fix-winsock2.patch" + patch_description: "Only include winsock2.h for struct timeval if needed" + patch_type: "bugfix" + patch_source: "https://github.com/openssl/openssl/commit/ba58e9f1e22dd9ee2e37078640dcbe9f520a555d" diff --git a/thirdparty/openssl/3.x.x/conanfile.py b/thirdparty/openssl/3.x.x/conanfile.py new file mode 100644 index 0000000000..c858b3551b --- /dev/null +++ b/thirdparty/openssl/3.x.x/conanfile.py @@ -0,0 +1,684 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os, XCRun +from conan.tools.build import build_jobs +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rename, replace_in_file, rmdir, save +from conan.tools.gnu import AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path +from conan.tools.scm import Version + +import fnmatch +import os +import textwrap + +required_conan_version = ">=1.57.0" + + +class OpenSSLConan(ConanFile): + name = "openssl" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/openssl/openssl" + license = "Apache-2.0" + topics = ("ssl", "tls", "encryption", "security") + description = "A toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_weak_ssl_ciphers": [True, False], + "386": [True, False], + "capieng_dialog": [True, False], + "enable_capieng": [True, False], + "enable_trace": [True, False], + "no_aria": [True, False], + "no_apps": [True, False], + "no_autoload_config": [True, False], + "no_asm": [True, False], + "no_async": [True, False], + "no_blake2": [True, False], + "no_bf": [True, False], + "no_camellia": [True, False], + "no_chacha": [True, False], + "no_cms": [True, False], + "no_comp": [True, False], + "no_ct": [True, False], + "no_cast": [True, False], + "no_deprecated": [True, False], + "no_des": [True, False], + "no_dgram": [True, False], + "no_dh": [True, False], + "no_dsa": [True, False], + "no_dso": [True, False], + "no_ec": [True, False], + "no_ecdh": [True, False], + "no_ecdsa": [True, False], + "no_engine": [True, False], + "no_filenames": [True, False], + "no_fips": [True, False], + "no_gost": [True, False], + "no_idea": [True, False], + "no_legacy": [True, False], + "no_md2": [True, False], + "no_md4": [True, False], + "no_mdc2": [True, False], + "no_module": [True, False], + "no_ocsp": [True, False], + "no_pinshared": [True, False], + "no_rc2": [True, False], + "no_rc4": [True, False], + "no_rc5": [True, False], + "no_rfc3779": [True, False], + "no_rmd160": [True, False], + "no_sm2": [True, False], + "no_sm3": [True, False], + "no_sm4": [True, False], + "no_srp": [True, False], + "no_srtp": [True, False], + "no_sse2": [True, False], + "no_ssl": [True, False], + "no_stdio": [True, False], + "no_seed": [True, False], + "no_sock": [True, False], + "no_ssl3": [True, False], + "no_threads": [True, False], + "no_tls1": [True, False], + "no_ts": [True, False], + "no_whirlpool": [True, False], + "no_zlib": [True, False], + "openssldir": [None, "ANY"], + "tls_security_level": [None, 0, 1, 2, 3, 4, 5], + } + default_options = {key: False for key in options.keys()} + default_options["fPIC"] = True + default_options["no_md2"] = True + default_options["openssldir"] = None + default_options["tls_security_level"] = None + + @property + def _is_clang_cl(self): + return self.settings.os == "Windows" and self.settings.compiler == "clang" and \ + self.settings.compiler.get_safe("runtime") + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" + + @property + def _use_nmake(self): + return self._is_clang_cl or is_msvc(self) + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os != "Windows": + self.options.rm_safe("capieng_dialog") + self.options.rm_safe("enable_capieng") + else: + self.options.rm_safe("fPIC") + + if self.settings.os == "Emscripten": + self.options.no_asm = True + self.options.no_threads = True + self.options.no_stdio = True + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if not self.options.no_zlib: + self.requires("zlib/[>=1.2.11 <2]") + + def validate(self): + if self.settings.os == "Emscripten": + if not all((self.options.no_asm, self.options.no_threads, self.options.no_stdio)): + raise ConanInvalidConfiguration("os=Emscripten requires openssl:{no_asm,no_threads,no_stdio}=True") + + if self.settings.os == "iOS" and self.options.shared: + raise ConanInvalidConfiguration("OpenSSL 3 does not support building shared libraries for iOS") + + def build_requirements(self): + if self._settings_build.os == "Windows": + if not self.options.no_asm: + self.tool_requires("nasm/2.15.05") + if self._use_nmake: + self.tool_requires("strawberryperl/5.32.1.1") + else: + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + @property + def _target(self): + target = f"conan-{self.settings.build_type}-{self.settings.os}-{self.settings.arch}-{self.settings.compiler}-{self.settings.compiler.version}" + if self._use_nmake: + target = f"VC-{target}" # VC- prefix is important as it's checked by Configure + if self._is_mingw: + target = f"mingw-{target}" + return target + + @property + def _perlasm_scheme(self): + # right now, we need to tweak this for iOS & Android only, as they inherit from generic targets + if self.settings.os in ("iOS", "watchOS", "tvOS"): + return { + "armv7": "ios32", + "armv7s": "ios32", + "armv8": "ios64", + "armv8_32": "ios64", + "armv8.3": "ios64", + "armv7k": "ios32", + }.get(str(self.settings.arch), None) + elif self.settings.os == "Android": + return { + "armv7": "void", + "armv8": "linux64", + "mips": "o32", + "mips64": "64", + "x86": "android", + "x86_64": "elf", + }.get(str(self.settings.arch), None) + return None + + @property + def _asm_target(self): + if self.settings.os in ("Android", "iOS", "watchOS", "tvOS"): + return { + "x86": "x86_asm" if self.settings.os == "Android" else None, + "x86_64": "x86_64_asm" if self.settings.os == "Android" else None, + "armv5el": "armv4_asm", + "armv5hf": "armv4_asm", + "armv6": "armv4_asm", + "armv7": "armv4_asm", + "armv7hf": "armv4_asm", + "armv7s": "armv4_asm", + "armv7k": "armv4_asm", + "armv8": "aarch64_asm", + "armv8_32": "aarch64_asm", + "armv8.3": "aarch64_asm", + "mips": "mips32_asm", + "mips64": "mips64_asm", + "sparc": "sparcv8_asm", + "sparcv9": "sparcv9_asm", + "ia64": "ia64_asm", + "ppc32be": "ppc32_asm", + "ppc32": "ppc32_asm", + "ppc64le": "ppc64_asm", + "ppc64": "ppc64_asm", + "s390": "s390x_asm", + "s390x": "s390x_asm" + }.get(str(self.settings.os), None) + + @property + def _targets(self): + is_cygwin = self.settings.get_safe("os.subsystem") == "cygwin" + return { + "Linux-x86-clang": "linux-x86-clang", + "Linux-x86_64-clang": "linux-x86_64-clang", + "Linux-x86-*": "linux-x86", + "Linux-x86_64-*": "linux-x86_64", + "Linux-armv4-*": "linux-armv4", + "Linux-armv4i-*": "linux-armv4", + "Linux-armv5el-*": "linux-armv4", + "Linux-armv5hf-*": "linux-armv4", + "Linux-armv6-*": "linux-armv4", + "Linux-armv7-*": "linux-armv4", + "Linux-armv7hf-*": "linux-armv4", + "Linux-armv7s-*": "linux-armv4", + "Linux-armv7k-*": "linux-armv4", + "Linux-armv8-*": "linux-aarch64", + "Linux-armv8.3-*": "linux-aarch64", + "Linux-armv8-32-*": "linux-arm64ilp32", + "Linux-mips-*": "linux-mips32", + "Linux-mips64-*": "linux-mips64", + "Linux-ppc32-*": "linux-ppc32", + "Linux-ppc32le-*": "linux-pcc32", + "Linux-ppc32be-*": "linux-ppc32", + "Linux-ppc64-*": "linux-ppc64", + "Linux-ppc64le-*": "linux-ppc64le", + "Linux-pcc64be-*": "linux-pcc64", + "Linux-s390x-*": "linux64-s390x", + "Linux-e2k-*": "linux-generic64", + "Linux-sparc-*": "linux-sparcv8", + "Linux-sparcv9-*": "linux64-sparcv9", + "Linux-*-*": "linux-generic32", + "Macos-x86-*": "darwin-i386-cc", + "Macos-x86_64-*": "darwin64-x86_64-cc", + "Macos-ppc32-*": "darwin-ppc-cc", + "Macos-ppc32be-*": "darwin-ppc-cc", + "Macos-ppc64-*": "darwin64-ppc-cc", + "Macos-ppc64be-*": "darwin64-ppc-cc", + "Macos-armv8-*": "darwin64-arm64-cc", + "Macos-*-*": "darwin-common", + "iOS-x86_64-*": "darwin64-x86_64-cc", + "iOS-*-*": "iphoneos-cross", + "watchOS-*-*": "iphoneos-cross", + "tvOS-*-*": "iphoneos-cross", + # Android targets are very broken, see https://github.com/openssl/openssl/issues/7398 + "Android-armv7-*": "linux-generic32", + "Android-armv7hf-*": "linux-generic32", + "Android-armv8-*": "linux-generic64", + "Android-x86-*": "linux-x86-clang", + "Android-x86_64-*": "linux-x86_64-clang", + "Android-mips-*": "linux-generic32", + "Android-mips64-*": "linux-generic64", + "Android-*-*": "linux-generic32", + "Windows-x86-gcc": "Cygwin-x86" if is_cygwin else "mingw", + "Windows-x86_64-gcc": "Cygwin-x86_64" if is_cygwin else "mingw64", + "Windows-*-gcc": "Cygwin-common" if is_cygwin else "mingw-common", + "Windows-ia64-Visual Studio": "VC-WIN64I", # Itanium + "Windows-x86-Visual Studio": "VC-WIN32", + "Windows-x86_64-Visual Studio": "VC-WIN64A", + "Windows-armv7-Visual Studio": "VC-WIN32-ARM", + "Windows-armv8-Visual Studio": "VC-WIN64-ARM", + "Windows-*-Visual Studio": "VC-noCE-common", + "Windows-ia64-clang": "VC-WIN64I", # Itanium + "Windows-x86-clang": "VC-WIN32", + "Windows-x86_64-clang": "VC-WIN64A", + "Windows-armv7-clang": "VC-WIN32-ARM", + "Windows-armv8-clang": "VC-WIN64-ARM", + "Windows-*-clang": "VC-noCE-common", + "WindowsStore-x86-*": "VC-WIN32-UWP", + "WindowsStore-x86_64-*": "VC-WIN64A-UWP", + "WindowsStore-armv7-*": "VC-WIN32-ARM-UWP", + "WindowsStore-armv8-*": "VC-WIN64-ARM-UWP", + "WindowsStore-*-*": "VC-WIN32-ONECORE", + "WindowsCE-*-*": "VC-CE", + "SunOS-x86-gcc": "solaris-x86-gcc", + "SunOS-x86_64-gcc": "solaris64-x86_64-gcc", + "SunOS-sparc-gcc": "solaris-sparcv8-gcc", + "SunOS-sparcv9-gcc": "solaris64-sparcv9-gcc", + "SunOS-x86-suncc": "solaris-x86-cc", + "SunOS-x86_64-suncc": "solaris64-x86_64-cc", + "SunOS-sparc-suncc": "solaris-sparcv8-cc", + "SunOS-sparcv9-suncc": "solaris64-sparcv9-cc", + "SunOS-*-*": "solaris-common", + "*BSD-x86-*": "BSD-x86", + "*BSD-x86_64-*": "BSD-x86_64", + "*BSD-ia64-*": "BSD-ia64", + "*BSD-sparc-*": "BSD-sparcv8", + "*BSD-sparcv9-*": "BSD-sparcv9", + "*BSD-armv8-*": "BSD-generic64", + "*BSD-mips64-*": "BSD-generic64", + "*BSD-ppc64-*": "BSD-generic64", + "*BSD-ppc64le-*": "BSD-generic64", + "*BSD-ppc64be-*": "BSD-generic64", + "AIX-ppc32-gcc": "aix-gcc", + "AIX-ppc64-gcc": "aix64-gcc", + "AIX-pcc32-*": "aix-cc", + "AIX-ppc64-*": "aix64-cc", + "AIX-*-*": "aix-common", + "*BSD-*-*": "BSD-generic32", + "Emscripten-*-*": "cc", + "Neutrino-*-*": "BASE_unix", + } + + @property + def _ancestor_target(self): + if "CONAN_OPENSSL_CONFIGURATION" in os.environ: + return os.environ["CONAN_OPENSSL_CONFIGURATION"] + compiler = "Visual Studio" if self.settings.compiler == "msvc" else self.settings.compiler + query = f"{self.settings.os}-{self.settings.arch}-{compiler}" + ancestor = next((self._targets[i] for i in self._targets if fnmatch.fnmatch(query, i)), None) + if not ancestor: + raise ConanInvalidConfiguration( + f"Unsupported configuration ({self.settings.os}/{self.settings.arch}/{self.settings.compiler}).\n" + f"Please open an issue at {self.url}.\n" + f"Alternatively, set the CONAN_OPENSSL_CONFIGURATION environment variable into your conan profile." + ) + return ancestor + + def _get_default_openssl_dir(self): + if self.settings.os == "Linux": + return "/etc/ssl" + return os.path.join(self.package_folder, "res") + + def _adjust_path(self, path): + if self._use_nmake: + return path.replace("\\", "/") + return unix_path(self, path) + + @property + def _configure_args(self): + openssldir = self.options.openssldir or self._get_default_openssl_dir() + openssldir = unix_path(self, openssldir) if self.win_bash else openssldir + args = [ + '"%s"' % (self._target), + "shared" if self.options.shared else "no-shared", + "--prefix=/", + "--libdir=lib", + "--openssldir=\"%s\"" % openssldir, + "no-unit-test", + "no-threads" if self.options.no_threads else "threads", + "PERL=%s" % self._perl, + "no-tests", + "--debug" if self.settings.build_type == "Debug" else "--release", + ] + + if self.settings.os == "Android": + args.append(" -D__ANDROID_API__=%s" % str(self.settings.os.api_level)) # see NOTES.ANDROID + if self.settings.os == "Emscripten": + args.append("-D__STDC_NO_ATOMICS__=1") + if self.settings.os == "Windows": + if self.options.enable_capieng: + args.append("enable-capieng") + if self.options.capieng_dialog: + args.append("-DOPENSSL_CAPIENG_DIALOG=1") + else: + args.append("-fPIC" if self.options.get_safe("fPIC", True) else "no-pic") + + args.append("no-fips" if self.options.get_safe("no_fips", True) else "enable-fips") + args.append("no-md2" if self.options.get_safe("no_md2", True) else "enable-md2") + if str(self.options.tls_security_level) != "None": + args.append(f"-DOPENSSL_TLS_SECURITY_LEVEL={self.options.tls_security_level}") + + if self.options.get_safe("enable_trace"): + args.append("enable-trace") + + if self.settings.os == "Neutrino": + args.append("no-asm -lsocket -latomic") + + if not self.options.no_zlib: + zlib_cpp_info = self.dependencies["zlib"].cpp_info.aggregated_components() + include_path = self._adjust_path(zlib_cpp_info.includedirs[0]) + if self._use_nmake: + lib_path = self._adjust_path(os.path.join(zlib_cpp_info.libdirs[0], f"{zlib_cpp_info.libs[0]}.lib")) + else: + # Just path, GNU like compilers will find the right file + lib_path = self._adjust_path(zlib_cpp_info.libdirs[0]) + + if self.dependencies["zlib"].options.shared: + args.append("zlib-dynamic") + else: + args.append("zlib") + + args.extend([ + f'--with-zlib-include="{include_path}"', + f'--with-zlib-lib="{lib_path}"', + ]) + + for option_name in self.default_options.keys(): + if self.options.get_safe(option_name, False) and option_name not in ("shared", "fPIC", "openssldir", "tls_security_level", "capieng_dialog", "enable_capieng", "zlib", "no_fips", "no_md2"): + self.output.info(f"Activated option: {option_name}") + args.append(option_name.replace("_", "-")) + return args + + def generate(self): + tc = AutotoolsToolchain(self) + env = tc.environment() + env.define_path("PERL", self._perl) + if self.settings.compiler == "apple-clang": + xcrun = XCRun(self) + env.define_path("CROSS_SDK", os.path.basename(xcrun.sdk_path)) + env.define_path("CROSS_TOP", os.path.dirname(os.path.dirname(xcrun.sdk_path))) + + self._create_targets(tc.cflags, tc.cxxflags, tc.defines, tc.ldflags) + tc.generate(env) + + def _create_targets(self, cflags, cxxflags, defines, ldflags): + config_template = textwrap.dedent("""\ + {targets} = ( + "{target}" => {{ + inherit_from => {ancestor}, + cflags => add("{cflags}"), + cxxflags => add("{cxxflags}"), + {defines} + lflags => add("{lflags}"), + {shared_target} + {shared_cflag} + {shared_extension} + {perlasm_scheme} + }}, + ); + """) + + perlasm_scheme = "" + if self._perlasm_scheme: + perlasm_scheme = 'perlasm_scheme => "%s",' % self._perlasm_scheme + + defines = '", "'.join(defines) + defines = 'defines => add("%s"),' % defines if defines else "" + targets = "my %targets" + + if self._asm_target: + ancestor = '[ "%s", asm("%s") ]' % (self._ancestor_target, self._asm_target) + else: + ancestor = '[ "%s" ]' % self._ancestor_target + shared_cflag = "" + shared_extension = "" + shared_target = "" + if self.settings.os == "Neutrino": + if self.options.shared: + shared_extension = 'shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",' + shared_target = 'shared_target => "gnu-shared",' + if self.options.get_safe("fPIC", True): + shared_cflag = 'shared_cflag => "-fPIC",' + + if self.settings.os in ["iOS", "tvOS", "watchOS"] and self.conf.get("tools.apple:enable_bitcode", check_type=bool): + cflags.append("-fembed-bitcode") + cxxflags.append("-fembed-bitcode") + + config = config_template.format( + targets=targets, + target=self._target, + ancestor=ancestor, + cflags=" ".join(cflags), + cxxflags=" ".join(cxxflags), + defines=defines, + perlasm_scheme=perlasm_scheme, + shared_target=shared_target, + shared_extension=shared_extension, + shared_cflag=shared_cflag, + lflags=" ".join(ldflags) + ) + self.output.info("using target: %s -> %s" % (self._target, self._ancestor_target)) + self.output.info(config) + + save(self, os.path.join(self.source_folder, "Configurations", "20-conan.conf"), config) + + def _run_make(self, targets=None, parallel=True, install=False): + command = [self._make_program] + if install: + command.append(f"DESTDIR={self._adjust_path(self.package_folder)}") + if targets: + command.extend(targets) + if not self._use_nmake: + command.append(("-j%s" % build_jobs(self)) if parallel else "-j1") + self.run(" ".join(command), env="conanbuild") + + @property + def _perl(self): + if self._use_nmake: + return self.dependencies.build["strawberryperl"].conf_info.get("user.strawberryperl:perl", check_type=str) + return "perl" + + def _make(self): + with chdir(self, self.source_folder): + # workaround for clang-cl not producing .pdb files + if self._is_clang_cl: + save(self, "ossl_static.pdb", "") + args = " ".join(self._configure_args) + + if self._use_nmake: + self._replace_runtime_in_file(os.path.join("Configurations", "10-main.conf")) + + self.run("{perl} ./Configure {args}".format(perl=self._perl, args=args), env="conanbuild") + if self._use_nmake: + # When `--prefix=/`, the scripts derive `\` without escaping, which + # causes issues on Windows + replace_in_file(self, "Makefile", "INSTALLTOP_dir=\\", "INSTALLTOP_dir=\\\\") + self._run_make() + + def _make_install(self): + with chdir(self, self.source_folder): + self._run_make(targets=["install_sw"], parallel=False, install=True) + + def build(self): + apply_conandata_patches(self) + self._make() + configdata_pm = self._adjust_path(os.path.join(self.source_folder, "configdata.pm")) + self.run(f"{self._perl} {configdata_pm} --dump") + + @property + def _make_program(self): + return "nmake" if self._use_nmake else "make" + + def _replace_runtime_in_file(self, filename): + runtime = msvc_runtime_flag(self) + for e in ["MDd", "MTd", "MD", "MT"]: + replace_in_file(self, filename, f"/{e} ", f"/{runtime} ", strict=False) + replace_in_file(self, filename, f"/{e}\"", f"/{runtime}\"", strict=False) + + def package(self): + copy(self, "*LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + self._make_install() + if is_apple_os(self): + fix_apple_shared_install_name(self) + + for root, _, files in os.walk(self.package_folder): + for filename in files: + if fnmatch.fnmatch(filename, "*.pdb"): + os.unlink(os.path.join(self.package_folder, root, filename)) + if self.options.shared: + libdir = os.path.join(self.package_folder, "lib") + for file in os.listdir(libdir): + if self._is_mingw and file.endswith(".dll.a"): + continue + if file.endswith(".a"): + os.unlink(os.path.join(libdir, file)) + + if not self.options.no_fips: + provdir = os.path.join(self.source_folder, "providers") + modules_dir = os.path.join(self.package_folder, "lib", "ossl-modules") + if self.settings.os == "Macos": + copy(self, "fips.dylib", src=provdir, dst=modules_dir) + elif self.settings.os == "Windows": + copy(self, "fips.dll", src=provdir, dst=modules_dir) + else: + copy(self, "fips.so", src=provdir, dst=modules_dir) + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path) + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent("""\ + set(OPENSSL_FOUND TRUE) + if(DEFINED OpenSSL_INCLUDE_DIR) + set(OPENSSL_INCLUDE_DIR ${OpenSSL_INCLUDE_DIR}) + endif() + if(DEFINED OpenSSL_Crypto_LIBS) + set(OPENSSL_CRYPTO_LIBRARY ${OpenSSL_Crypto_LIBS}) + set(OPENSSL_CRYPTO_LIBRARIES ${OpenSSL_Crypto_LIBS} + ${OpenSSL_Crypto_DEPENDENCIES} + ${OpenSSL_Crypto_FRAMEWORKS} + ${OpenSSL_Crypto_SYSTEM_LIBS}) + elseif(DEFINED openssl_OpenSSL_Crypto_LIBS_%(config)s) + set(OPENSSL_CRYPTO_LIBRARY ${openssl_OpenSSL_Crypto_LIBS_%(config)s}) + set(OPENSSL_CRYPTO_LIBRARIES ${openssl_OpenSSL_Crypto_LIBS_%(config)s} + ${openssl_OpenSSL_Crypto_DEPENDENCIES_%(config)s} + ${openssl_OpenSSL_Crypto_FRAMEWORKS_%(config)s} + ${openssl_OpenSSL_Crypto_SYSTEM_LIBS_%(config)s}) + endif() + if(DEFINED OpenSSL_SSL_LIBS) + set(OPENSSL_SSL_LIBRARY ${OpenSSL_SSL_LIBS}) + set(OPENSSL_SSL_LIBRARIES ${OpenSSL_SSL_LIBS} + ${OpenSSL_SSL_DEPENDENCIES} + ${OpenSSL_SSL_FRAMEWORKS} + ${OpenSSL_SSL_SYSTEM_LIBS}) + elseif(DEFINED openssl_OpenSSL_SSL_LIBS_%(config)s) + set(OPENSSL_SSL_LIBRARY ${openssl_OpenSSL_SSL_LIBS_%(config)s}) + set(OPENSSL_SSL_LIBRARIES ${openssl_OpenSSL_SSL_LIBS_%(config)s} + ${openssl_OpenSSL_SSL_DEPENDENCIES_%(config)s} + ${openssl_OpenSSL_SSL_FRAMEWORKS_%(config)s} + ${openssl_OpenSSL_SSL_SYSTEM_LIBS_%(config)s}) + endif() + if(DEFINED OpenSSL_LIBRARIES) + set(OPENSSL_LIBRARIES ${OpenSSL_LIBRARIES}) + endif() + if(DEFINED OpenSSL_VERSION) + set(OPENSSL_VERSION ${OpenSSL_VERSION}) + endif() + """% {"config":str(self.settings.build_type).upper()}) + save(self, module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + "conan-official-{}-variables.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "OpenSSL") + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("pkg_config_name", "openssl") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.names["cmake_find_package"] = "OpenSSL" + self.cpp_info.names["cmake_find_package_multi"] = "OpenSSL" + self.cpp_info.components["ssl"].builddirs.append(self._module_subfolder) + self.cpp_info.components["ssl"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["ssl"].set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.components["crypto"].builddirs.append(self._module_subfolder) + self.cpp_info.components["crypto"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["crypto"].set_property("cmake_build_modules", [self._module_file_rel_path]) + + if self._use_nmake: + self.cpp_info.components["ssl"].libs = ["libssl"] + self.cpp_info.components["crypto"].libs = ["libcrypto"] + else: + self.cpp_info.components["ssl"].libs = ["ssl"] + self.cpp_info.components["crypto"].libs = ["crypto"] + + self.cpp_info.components["ssl"].requires = ["crypto"] + + if not self.options.no_zlib: + self.cpp_info.components["crypto"].requires.append("zlib::zlib") + + if self.settings.os == "Windows": + self.cpp_info.components["crypto"].system_libs.extend(["crypt32", "ws2_32", "advapi32", "user32", "bcrypt"]) + elif self.settings.os == "Linux": + self.cpp_info.components["crypto"].system_libs.extend(["dl", "rt"]) + self.cpp_info.components["ssl"].system_libs.append("dl") + if not self.options.no_threads: + self.cpp_info.components["crypto"].system_libs.append("pthread") + self.cpp_info.components["ssl"].system_libs.append("pthread") + elif self.settings.os == "Neutrino": + self.cpp_info.components["crypto"].system_libs.append("atomic") + self.cpp_info.components["ssl"].system_libs.append("atomic") + self.cpp_info.components["crypto"].system_libs.append("socket") + self.cpp_info.components["ssl"].system_libs.append("socket") + + self.cpp_info.components["crypto"].set_property("cmake_target_name", "OpenSSL::Crypto") + self.cpp_info.components["crypto"].set_property("pkg_config_name", "libcrypto") + self.cpp_info.components["ssl"].set_property("cmake_target_name", "OpenSSL::SSL") + self.cpp_info.components["ssl"].set_property("pkg_config_name", "libssl") + self.cpp_info.components["crypto"].names["cmake_find_package"] = "Crypto" + self.cpp_info.components["crypto"].names["cmake_find_package_multi"] = "Crypto" + self.cpp_info.components["ssl"].names["cmake_find_package"] = "SSL" + self.cpp_info.components["ssl"].names["cmake_find_package_multi"] = "SSL" + + openssl_modules_dir = os.path.join(self.package_folder, "lib", "ossl-modules") + self.runenv_info.define_path("OPENSSL_MODULES", openssl_modules_dir) + + # For legacy 1.x downstream consumers, remove once recipe is 2.0 only: + self.env_info.OPENSSL_MODULES = openssl_modules_dir diff --git a/thirdparty/openssl/3.x.x/patches/3.2.0-fix-winsock2.patch b/thirdparty/openssl/3.x.x/patches/3.2.0-fix-winsock2.patch new file mode 100644 index 0000000000..6e91678b02 --- /dev/null +++ b/thirdparty/openssl/3.x.x/patches/3.2.0-fix-winsock2.patch @@ -0,0 +1,36 @@ +From ba58e9f1e22dd9ee2e37078640dcbe9f520a555d Mon Sep 17 00:00:00 2001 +From: Hugo Landau +Date: Fri, 24 Nov 2023 10:03:30 +0000 +Subject: [PATCH] Only include winsock2.h for struct timeval if needed + +Fixes #22811 + +Reviewed-by: Tomas Mraz +Reviewed-by: Matt Caswell +Reviewed-by: Matthias St. Pierre +(Merged from https://github.com/openssl/openssl/pull/22813) +--- + include/openssl/e_ostime.h | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/include/openssl/e_ostime.h b/include/openssl/e_ostime.h +index 8a7cc9880fa79..0e17487504992 100644 +--- a/include/openssl/e_ostime.h ++++ b/include/openssl/e_ostime.h +@@ -22,7 +22,15 @@ + */ + + # if defined(OPENSSL_SYS_WINDOWS) +-# include ++# if !defined(_WINSOCKAPI_) ++ /* ++ * winsock2.h defines _WINSOCK2API_ and both winsock2.h and winsock.h define ++ * _WINSOCKAPI_. Both of these provide struct timeval. Don't include ++ * winsock2.h if either header has been included to avoid breakage with ++ * applications that prefer to use over . ++ */ ++# include ++# endif + # else + # include + # endif diff --git a/thirdparty/openssl/3.x.x/test_package/CMakeLists.txt b/thirdparty/openssl/3.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000..dfe7efcdc5 --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_package/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +option(OPENSSL_WITH_LEGACY "OpenSSL with support for the legacy provider" ON) +option(OPENSSL_WITH_MD4 "OpenSSL with MD4 support (needs legacy provider)" ON) +option(OPENSSL_WITH_RIPEMD160 "OpenSSL with RIPEMD16 support (needs legacy provider)" ON) + +set(OpenSSL_DEBUG 1) +find_package(OpenSSL REQUIRED) + +# Test whether variables from https://cmake.org/cmake/help/latest/module/FindOpenSSL.html +# are properly defined in conan generators +set(_custom_vars + OPENSSL_FOUND + OPENSSL_INCLUDE_DIR + OPENSSL_CRYPTO_LIBRARY + OPENSSL_CRYPTO_LIBRARIES + OPENSSL_SSL_LIBRARY + OPENSSL_SSL_LIBRARIES + OPENSSL_LIBRARIES + OPENSSL_VERSION +) +foreach(_custom_var ${_custom_vars}) + if(DEFINED ${_custom_var}) + message(STATUS "${_custom_var}: ${${_custom_var}}") + else() + message(FATAL_ERROR "${_custom_var} not defined") + endif() +endforeach() + +add_executable(test_package test_package.c digest.c) +message("OPENSSL_LIBRARIES = ${OPENSSL_LIBRARIES}") +# target_link_libraries(test_package PRIVATE OpenSSL::SSL OpenSSL::Crypto) +# target_link_libraries(test_package PRIVATE openssl::openssl OpenSSL::Crypto) +# target_link_libraries(test_package PRIVATE ${OPENSSL_LIBRARIES}) +target_link_libraries(test_package PRIVATE openssl::openssl) + +if(OPENSSL_WITH_LEGACY) + target_sources(test_package PRIVATE digest_legacy.c) + # do now show deperecation warnings + target_compile_definitions(test_package PRIVATE OPENSSL_SUPPRESS_DEPRECATED TEST_OPENSSL_LEGACY) + if(OPENSSL_WITH_MD4) + target_compile_definitions(test_package PRIVATE OPENSSL_WITH_MD4) + endif() + if(OPENSSL_WITH_RIPEMD160) + target_compile_definitions(test_package PRIVATE OPENSSL_WITH_RIPEMD160) + endif() +endif() diff --git a/thirdparty/openssl/3.x.x/test_package/CMakeUserPresets.json b/thirdparty/openssl/3.x.x/test_package/CMakeUserPresets.json new file mode 100644 index 0000000000..590666cb7a --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_package/CMakeUserPresets.json @@ -0,0 +1,9 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + "/home/ubuntu/src/james/pipeline/nifi-minifi-cpp/thirdparty/openssl/3.x.x/test_package/build/gcc-11-x86_64-gnu20-release/generators/CMakePresets.json" + ] +} \ No newline at end of file diff --git a/thirdparty/openssl/3.x.x/test_package/conanfile.py b/thirdparty/openssl/3.x.x/test_package/conanfile.py new file mode 100644 index 0000000000..76d2cc26c1 --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_package/conanfile.py @@ -0,0 +1,38 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def _with_legacy(self): + return (not self.dependencies["openssl"].options.no_legacy and + ((not self.dependencies["openssl"].options.no_md4) or + (not self.dependencies["openssl"].options.no_rmd160))) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["OPENSSL_WITH_LEGACY"] = self._with_legacy() + tc.cache_variables["OPENSSL_WITH_MD4"] = not self.dependencies["openssl"].options.no_md4 + tc.cache_variables["OPENSSL_WITH_RIPEMD160"] = not self.dependencies["openssl"].options.no_rmd160 + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/openssl/3.x.x/test_package/digest.c b/thirdparty/openssl/3.x.x/test_package/digest.c new file mode 100644 index 0000000000..94464635eb --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_package/digest.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include + +#include +#include +#include + +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#endif + +void SHA3_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) { + EVP_MD_CTX *mdctx; + + if((mdctx = EVP_MD_CTX_create()) == NULL) + printf("EVP_MD_CTX_create error!\n"); + + if(EVP_DigestInit_ex(mdctx, type, NULL) != 1) + printf("EVP_DigestInit_ex error!\n"); + + if(EVP_DigestUpdate(mdctx, message, message_len) != 1) + printf("EVP_DigestUpdate error!\n"); + + if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1) + printf("EVP_DigestFinal_ex error!\n"); + + EVP_MD_CTX_destroy(mdctx); +} + +void digest() +{ + unsigned int digest_len; + unsigned char sha256_digest[SHA256_DIGEST_LENGTH], + sha512_digest[SHA512_DIGEST_LENGTH], + sha3_256_digest[SHA256_DIGEST_LENGTH], + sha3_512_digest[SHA512_DIGEST_LENGTH]; + char sha256_string[SHA256_DIGEST_LENGTH*2+1] = {0}, + sha512_string[SHA512_DIGEST_LENGTH*2+1] = {0}, + sha3_256_string[SHA256_DIGEST_LENGTH*2+1] = {0}, + sha3_512_string[SHA512_DIGEST_LENGTH*2+1] = {0}; + char string[] = "happy"; + + SHA256((unsigned char*)&string, strlen(string), (unsigned char*)&sha256_digest); + SHA512((unsigned char*)&string, strlen(string), (unsigned char*)&sha512_digest); + SHA3_hash(EVP_sha3_256(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_256_digest, &digest_len); + SHA3_hash(EVP_sha3_512(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_512_digest, &digest_len); + + for(int i = 0; i < SHA256_DIGEST_LENGTH; i++) { + snprintf(&sha256_string[i*2], sizeof(sha256_string)-i*2, "%02x", (unsigned int)sha256_digest[i]); + snprintf(&sha3_256_string[i*2], sizeof(sha3_256_string)-i*2, "%02x", (unsigned int)sha3_256_digest[i]); + } + + for(int i = 0; i < SHA512_DIGEST_LENGTH; i++) { + snprintf(&sha512_string[i*2], sizeof(sha512_string)-i*2, "%02x", (unsigned int)sha512_digest[i]); + snprintf(&sha3_512_string[i*2], sizeof(sha3_512_string)-i*2, "%02x", (unsigned int)sha3_512_digest[i]); + } + + printf("sha256 digest: %s\n", sha256_string); + printf("sha512 digest: %s\n", sha512_string); + printf("sha3 256 digest: %s\n", sha3_256_string); + printf("sha3 512 digest: %s\n", sha3_512_string); + +} diff --git a/thirdparty/openssl/3.x.x/test_package/digest_legacy.c b/thirdparty/openssl/3.x.x/test_package/digest_legacy.c new file mode 100644 index 0000000000..9a23bf242c --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_package/digest_legacy.c @@ -0,0 +1,141 @@ +#include +#if OPENSSL_WITH_MD4 +#include // MD4 needs legacy provider +#endif +#if OPENSSL_WITH_RIPEMD160 +#include // RIPEMD160 needs legacy provider +#endif +#include +#include +#include +#include +#include + +#include +#include +#include + +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#endif + +int MDx_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) { + EVP_MD_CTX *mdctx; + + if((mdctx = EVP_MD_CTX_create()) == NULL) + { + printf("EVP_MD_CTX_create error!\n"); + return 1; + } + + if(EVP_DigestInit_ex(mdctx, type, NULL) != 1) + { + printf("EVP_DigestInit_ex error!\n"); + return 1; + } + + if(EVP_DigestUpdate(mdctx, message, message_len) != 1) + { + printf("EVP_DigestUpdate error!\n"); + return 1; + } + + if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1) + { + printf("EVP_DigestFinal_ex error!\n"); + return 1; + } + + EVP_MD_CTX_destroy(mdctx); + return 0; +} + +int digest_legacy() +{ + unsigned int digest_len; + unsigned char md5_digest[MD5_DIGEST_LENGTH]; + unsigned char md5_digest2[MD5_DIGEST_LENGTH]; + char md5_string[MD5_DIGEST_LENGTH*2+1] = {0}; + char md5_string2[MD5_DIGEST_LENGTH*2+1] = {0}; + char string[] = "happy"; + + MD5((unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest); + if (MDx_hash(EVP_md5(), (unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest2, &digest_len)) + return 1; + + for(int i = 0; i < MD5_DIGEST_LENGTH; i++) { + snprintf(&md5_string[i*2], sizeof(md5_string)-i*2, "%02x", (unsigned int)md5_digest[i]); + snprintf(&md5_string2[i*2], sizeof(md5_string2)-i*2, "%02x", (unsigned int)md5_digest2[i]); + } + + // MD4 needs the legacy provider + OSSL_LIB_CTX* context = OSSL_LIB_CTX_new(); + // From https://wiki.openssl.org/index.php/OpenSSL_3.0 + /* Load Multiple providers into the default (nullptr) library context */ + OSSL_PROVIDER* legacy = OSSL_PROVIDER_load(context, "legacy"); + if (0 == legacy) { + const char* error_string = ERR_error_string(ERR_get_error(), 0); + fprintf(stderr, "Loading legacy provider failed with this error:\n"); + fprintf(stderr, "\t%s\n", error_string); + return 1; + } + OSSL_LIB_CTX* oldcontex = OSSL_LIB_CTX_set0_default(context); + printf("Legacy provider successfully loaded.\n"); + +#if OPENSSL_WITH_MD4 + unsigned char md4_digest[MD4_DIGEST_LENGTH]; + unsigned char md4_digest2[MD4_DIGEST_LENGTH]; + char md4_string[MD4_DIGEST_LENGTH*2+1] = {0}; + char md4_string2[MD4_DIGEST_LENGTH*2+1] = {0}; + + MD4((unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest); + if (MDx_hash(EVP_md4(), (unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest2, &digest_len)) { + const char* error_string = ERR_error_string(ERR_get_error(), 0); + fprintf(stderr, "MD4 calculation failed with this error:\n"); + fprintf(stderr, "\t%s\n", error_string); + return 1; + } + + for(int i = 0; i < MD4_DIGEST_LENGTH; i++) { + snprintf(&md4_string[i*2], sizeof(md4_string)-i*2, "%02x", (unsigned int)md4_digest[i]); + snprintf(&md4_string2[i*2], sizeof(md4_string2)-i*2, "%02x", (unsigned int)md4_digest2[i]); + } +#endif + +#if OPENSSL_WITH_RIPEMD160 + unsigned char ripemd160_digest[RIPEMD160_DIGEST_LENGTH]; + unsigned char ripemd160_digest2[RIPEMD160_DIGEST_LENGTH]; + char ripemd160_string[RIPEMD160_DIGEST_LENGTH*2+1] = {0}; + char ripemd160_string2[RIPEMD160_DIGEST_LENGTH*2+1] = {0}; + + RIPEMD160((unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest); + if (MDx_hash(EVP_ripemd160(), (unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest2, &digest_len)) { + const char* error_string = ERR_error_string(ERR_get_error(), 0); + fprintf(stderr, "RIPEMD160 calculation failed with this error:\n"); + fprintf(stderr, "\t%s\n", error_string); + return 1; + } + + for(int i = 0; i < RIPEMD160_DIGEST_LENGTH; i++) { + snprintf(&ripemd160_string[i*2], sizeof(ripemd160_string)-i*2, "%02x", (unsigned int)ripemd160_digest[i]); + snprintf(&ripemd160_string2[i*2], sizeof(ripemd160_string2)-i*2, "%02x", (unsigned int)ripemd160_digest2[i]); + } +#endif + + OSSL_LIB_CTX_set0_default(oldcontex); + OSSL_PROVIDER_unload(legacy); + OSSL_LIB_CTX_free(context); + + printf("MD5 digest: %s\n", md5_string); + printf("MD5 digest (variant 2): %s\n", md5_string2); +#if OPENSSL_WITH_MD4 + printf("MD4 digest: %s\n", md4_string); + printf("MD4 digest (variant 2): %s\n", md4_string2); +#endif +#if OPENSSL_WITH_RIPEMD160 + printf("RIPEMD160 digest: %s\n", ripemd160_string); + printf("RIPEMD160 digest (variant 2): %s\n", ripemd160_string2); +#endif + + return 0; +} diff --git a/thirdparty/openssl/3.x.x/test_package/test_package.c b/thirdparty/openssl/3.x.x/test_package/test_package.c new file mode 100644 index 0000000000..8f4148fbf3 --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_package/test_package.c @@ -0,0 +1,24 @@ +#include +#include + +void digest(); +int digest_legacy(); + +int main() +{ + int legacy_result = 0; + OPENSSL_init_ssl(0, NULL); + printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION)); + + digest(); + +#if defined(TEST_OPENSSL_LEGACY) + legacy_result = digest_legacy(); + if (legacy_result != 0) { + printf("Error testing the digest_legacy() function\n"); + return 1; + } +#endif + + return 0; +} diff --git a/thirdparty/openssl/3.x.x/test_v1_package/CMakeLists.txt b/thirdparty/openssl/3.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..d52c980c93 --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +option(OPENSSL_WITH_ZLIB "OpenSSL with zlib support" ON) +option(OPENSSL_WITH_LEGACY "OpenSSL with support for the legacy provider" ON) +option(OPENSSL_WITH_MD4 "OpenSSL with MD4 support (needs legacy provider)" ON) +option(OPENSSL_WITH_RIPEMD160 "OpenSSL with RIPEMD16 support (needs legacy provider)" ON) + +set(OpenSSL_DEBUG 1) +find_package(OpenSSL REQUIRED) + +message("OPENSSL_FOUND: ${OPENSSL_FOUND}") +message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}") +message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}") +message("OPENSSL_CRYPTO_LIBRARIES: ${OPENSSL_CRYPTO_LIBRARIES}") +message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}") +message("OPENSSL_SSL_LIBRARIES: ${OPENSSL_SSL_LIBRARIES}") +message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}") +message("OPENSSL_VERSION: ${OPENSSL_VERSION}") + +add_executable(digest digest.c) +if(OPENSSL_WITH_ZLIB) + target_compile_definitions(digest PRIVATE WITH_ZLIB) +endif() +target_link_libraries(digest OpenSSL::Crypto) + +if(OPENSSL_WITH_LEGACY) + add_executable(digest_legacy digest_legacy.c) + # do now show deperecation warnings + target_compile_definitions(digest_legacy PRIVATE OPENSSL_SUPPRESS_DEPRECATED) + if(OPENSSL_WITH_MD4) + target_compile_definitions(digest_legacy PRIVATE OPENSSL_WITH_MD4) + endif() + if(OPENSSL_WITH_RIPEMD160) + target_compile_definitions(digest_legacy PRIVATE OPENSSL_WITH_RIPEMD160) + endif() + if(OPENSSL_WITH_ZLIB) + target_compile_definitions(digest_legacy PRIVATE WITH_ZLIB) + endif() + target_link_libraries(digest_legacy OpenSSL::Crypto) +endif() diff --git a/thirdparty/openssl/3.x.x/test_v1_package/conanfile.py b/thirdparty/openssl/3.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000..ad509932a9 --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_v1_package/conanfile.py @@ -0,0 +1,40 @@ +from conans import CMake, tools, ConanFile +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "arch", "build_type" + generators = "cmake", "cmake_find_package", "pkg_config" + + def _with_legacy(self): + return (not self.options["openssl"].no_legacy and + ((not self.options["openssl"].no_md4) or + (not self.options["openssl"].no_rmd160))) + + def build(self): + cmake = CMake(self) + cmake.definitions["OPENSSL_WITH_ZLIB"] = not self.options["openssl"].no_zlib + cmake.definitions["OPENSSL_WITH_LEGACY"] = self._with_legacy() + cmake.definitions["OPENSSL_WITH_MD4"] = not self.options["openssl"].no_md4 + cmake.definitions["OPENSSL_WITH_RIPEMD160"] = not self.options["openssl"].no_rmd160 + if self.settings.os == "Android": + cmake.definitions["CONAN_LIBCXX"] = "" + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "digest") + self.run(bin_path, run_environment=True) + + if not self.options["openssl"].no_legacy: + bin_legacy_path = os.path.join("bin", "digest_legacy") + self.run(bin_legacy_path, run_environment=True) + + if not self.options["openssl"].no_stdio: + self.run("openssl version", run_environment=True) + assert os.path.exists(os.path.join(self.deps_cpp_info["openssl"].rootpath, "licenses", "LICENSE.txt")) + + for fn in ("libcrypto.pc", "libssl.pc", "openssl.pc",): + assert os.path.isfile(os.path.join(self.build_folder, fn)) diff --git a/thirdparty/openssl/3.x.x/test_v1_package/digest.c b/thirdparty/openssl/3.x.x/test_v1_package/digest.c new file mode 100644 index 0000000000..0693be609a --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_v1_package/digest.c @@ -0,0 +1,73 @@ +#include +#include +#include +#include +#if defined(WITH_ZLIB) +#include +#endif + +#include +#include +#include + +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#endif + +void SHA3_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) { + EVP_MD_CTX *mdctx; + + if((mdctx = EVP_MD_CTX_create()) == NULL) + printf("EVP_MD_CTX_create error!\n"); + + if(EVP_DigestInit_ex(mdctx, type, NULL) != 1) + printf("EVP_DigestInit_ex error!\n"); + + if(EVP_DigestUpdate(mdctx, message, message_len) != 1) + printf("EVP_DigestUpdate error!\n"); + + if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1) + printf("EVP_DigestFinal_ex error!\n"); + + EVP_MD_CTX_destroy(mdctx); +} + +int main() +{ + unsigned int digest_len; + unsigned char sha256_digest[SHA256_DIGEST_LENGTH], + sha512_digest[SHA512_DIGEST_LENGTH], + sha3_256_digest[SHA256_DIGEST_LENGTH], + sha3_512_digest[SHA512_DIGEST_LENGTH]; + char sha256_string[SHA256_DIGEST_LENGTH*2+1] = {0}, + sha512_string[SHA512_DIGEST_LENGTH*2+1] = {0}, + sha3_256_string[SHA256_DIGEST_LENGTH*2+1] = {0}, + sha3_512_string[SHA512_DIGEST_LENGTH*2+1] = {0}; + char string[] = "happy"; + + SHA256((unsigned char*)&string, strlen(string), (unsigned char*)&sha256_digest); + SHA512((unsigned char*)&string, strlen(string), (unsigned char*)&sha512_digest); + SHA3_hash(EVP_sha3_256(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_256_digest, &digest_len); + SHA3_hash(EVP_sha3_512(), (unsigned char*)&string, strlen(string), (unsigned char*)&sha3_512_digest, &digest_len); + + for(int i = 0; i < SHA256_DIGEST_LENGTH; i++) { + snprintf(&sha256_string[i*2], sizeof(sha256_string)-i*2, "%02x", (unsigned int)sha256_digest[i]); + snprintf(&sha3_256_string[i*2], sizeof(sha3_256_string)-i*2, "%02x", (unsigned int)sha3_256_digest[i]); + } + + for(int i = 0; i < SHA512_DIGEST_LENGTH; i++) { + snprintf(&sha512_string[i*2], sizeof(sha512_string)-i*2, "%02x", (unsigned int)sha512_digest[i]); + snprintf(&sha3_512_string[i*2], sizeof(sha3_512_string)-i*2, "%02x", (unsigned int)sha3_512_digest[i]); + } + + printf("sha256 digest: %s\n", sha256_string); + printf("sha512 digest: %s\n", sha512_string); + printf("sha3 256 digest: %s\n", sha3_256_string); + printf("sha3 512 digest: %s\n", sha3_512_string); + printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION)); +#if defined(WITH_ZLIB) + printf("ZLIB version: %s\n", ZLIB_VERSION); +#endif + + return 0; +} diff --git a/thirdparty/openssl/3.x.x/test_v1_package/digest_legacy.c b/thirdparty/openssl/3.x.x/test_v1_package/digest_legacy.c new file mode 100644 index 0000000000..740f0d2c20 --- /dev/null +++ b/thirdparty/openssl/3.x.x/test_v1_package/digest_legacy.c @@ -0,0 +1,148 @@ +#include +#if OPENSSL_WITH_MD4 +#include // MD4 needs legacy provider +#endif +#if OPENSSL_WITH_RIPEMD160 +#include // RIPEMD160 needs legacy provider +#endif +#include +#include +#include +#include +#include +#if defined(WITH_ZLIB) +#include +#endif + +#include +#include +#include + +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#endif + +int MDx_hash(const EVP_MD *type, const unsigned char *message, size_t message_len, unsigned char *digest, unsigned int *digest_len) { + EVP_MD_CTX *mdctx; + + if((mdctx = EVP_MD_CTX_create()) == NULL) + { + printf("EVP_MD_CTX_create error!\n"); + return 1; + } + + if(EVP_DigestInit_ex(mdctx, type, NULL) != 1) + { + printf("EVP_DigestInit_ex error!\n"); + return 1; + } + + if(EVP_DigestUpdate(mdctx, message, message_len) != 1) + { + printf("EVP_DigestUpdate error!\n"); + return 1; + } + + if(EVP_DigestFinal_ex(mdctx, digest, digest_len) != 1) + { + printf("EVP_DigestFinal_ex error!\n"); + return 1; + } + + EVP_MD_CTX_destroy(mdctx); + return 0; +} + +int main() +{ + unsigned int digest_len; + unsigned char md5_digest[MD5_DIGEST_LENGTH]; + unsigned char md5_digest2[MD5_DIGEST_LENGTH]; + char md5_string[MD5_DIGEST_LENGTH*2+1] = {0}; + char md5_string2[MD5_DIGEST_LENGTH*2+1] = {0}; + char string[] = "happy"; + + MD5((unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest); + if (MDx_hash(EVP_md5(), (unsigned char*)&string, strlen(string), (unsigned char*)&md5_digest2, &digest_len)) + return 1; + + for(int i = 0; i < MD5_DIGEST_LENGTH; i++) { + snprintf(&md5_string[i*2], sizeof(md5_string)-i*2, "%02x", (unsigned int)md5_digest[i]); + snprintf(&md5_string2[i*2], sizeof(md5_string2)-i*2, "%02x", (unsigned int)md5_digest2[i]); + } + + // MD4 needs the legacy provider + OSSL_LIB_CTX* context = OSSL_LIB_CTX_new(); + // From https://wiki.openssl.org/index.php/OpenSSL_3.0 + /* Load Multiple providers into the default (nullptr) library context */ + OSSL_PROVIDER* legacy = OSSL_PROVIDER_load(context, "legacy"); + if (0 == legacy) { + const char* error_string = ERR_error_string(ERR_get_error(), 0); + fprintf(stderr, "Loading legacy provider failed with this error:\n"); + fprintf(stderr, "\t%s\n", error_string); + return 1; + } + OSSL_LIB_CTX* oldcontex = OSSL_LIB_CTX_set0_default(context); + printf("Legacy provider successfully loaded.\n"); + +#if OPENSSL_WITH_MD4 + unsigned char md4_digest[MD4_DIGEST_LENGTH]; + unsigned char md4_digest2[MD4_DIGEST_LENGTH]; + char md4_string[MD4_DIGEST_LENGTH*2+1] = {0}; + char md4_string2[MD4_DIGEST_LENGTH*2+1] = {0}; + + MD4((unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest); + if (MDx_hash(EVP_md4(), (unsigned char*)&string, strlen(string), (unsigned char*)&md4_digest2, &digest_len)) { + const char* error_string = ERR_error_string(ERR_get_error(), 0); + fprintf(stderr, "MD4 calculation failed with this error:\n"); + fprintf(stderr, "\t%s\n", error_string); + return 1; + } + + for(int i = 0; i < MD4_DIGEST_LENGTH; i++) { + snprintf(&md4_string[i*2], sizeof(md4_string)-i*2, "%02x", (unsigned int)md4_digest[i]); + snprintf(&md4_string2[i*2], sizeof(md4_string2)-i*2, "%02x", (unsigned int)md4_digest2[i]); + } +#endif + +#if OPENSSL_WITH_RIPEMD160 + unsigned char ripemd160_digest[RIPEMD160_DIGEST_LENGTH]; + unsigned char ripemd160_digest2[RIPEMD160_DIGEST_LENGTH]; + char ripemd160_string[RIPEMD160_DIGEST_LENGTH*2+1] = {0}; + char ripemd160_string2[RIPEMD160_DIGEST_LENGTH*2+1] = {0}; + + RIPEMD160((unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest); + if (MDx_hash(EVP_ripemd160(), (unsigned char*)&string, strlen(string), (unsigned char*)&ripemd160_digest2, &digest_len)) { + const char* error_string = ERR_error_string(ERR_get_error(), 0); + fprintf(stderr, "RIPEMD160 calculation failed with this error:\n"); + fprintf(stderr, "\t%s\n", error_string); + return 1; + } + + for(int i = 0; i < RIPEMD160_DIGEST_LENGTH; i++) { + snprintf(&ripemd160_string[i*2], sizeof(ripemd160_string)-i*2, "%02x", (unsigned int)ripemd160_digest[i]); + snprintf(&ripemd160_string2[i*2], sizeof(ripemd160_string2)-i*2, "%02x", (unsigned int)ripemd160_digest2[i]); + } +#endif + + OSSL_LIB_CTX_set0_default(oldcontex); + OSSL_PROVIDER_unload(legacy); + OSSL_LIB_CTX_free(context); + + printf("MD5 digest: %s\n", md5_string); + printf("MD5 digest (variant 2): %s\n", md5_string2); +#if OPENSSL_WITH_MD4 + printf("MD4 digest: %s\n", md4_string); + printf("MD4 digest (variant 2): %s\n", md4_string2); +#endif +#if OPENSSL_WITH_RIPEMD160 + printf("RIPEMD160 digest: %s\n", ripemd160_string); + printf("RIPEMD160 digest (variant 2): %s\n", ripemd160_string2); +#endif + printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION)); +#if defined(WITH_ZLIB) + printf("ZLIB version: %s\n", ZLIB_VERSION); +#endif + + return 0; +} diff --git a/thirdparty/openssl/config.yml b/thirdparty/openssl/config.yml new file mode 100644 index 0000000000..ffb25cd0b8 --- /dev/null +++ b/thirdparty/openssl/config.yml @@ -0,0 +1,24 @@ +versions: + # 3.3.x releases + 3.3.0: + folder: "3.x.x" + # 3.2.x releases + 3.2.1: + folder: "3.x.x" + 3.2.0: + folder: "3.x.x" + # 3.1.x releases + 3.1.5: + folder: "3.x.x" + 3.1.4: + folder: "3.x.x" + 3.1.3: + folder: "3.x.x" + # 3.0.x releases + 3.0.13: + folder: "3.x.x" + 3.0.12: + folder: "3.x.x" + # 1.1.1x releases + 1.1.1w: + folder: "1.x.x" diff --git a/thirdparty/pcapplusplus/all/conandata.yml b/thirdparty/pcapplusplus/all/conandata.yml new file mode 100644 index 0000000000..7a68e16e6b --- /dev/null +++ b/thirdparty/pcapplusplus/all/conandata.yml @@ -0,0 +1,51 @@ +sources: + "21.05": + url: "https://github.com/seladb/PcapPlusPlus/archive/v21.05.tar.gz" + sha256: "f7bc2caea72544f42e3547c8acf65fca07ddd4cd45f7be2f5132dd1826ea27bb" + "21.11": + url: "https://github.com/seladb/PcapPlusPlus/archive/v21.11.tar.gz" + sha256: "56b8566b14b2586b8afc358e7c98268bc1dd6192197b29a3917b9df2120c51b0" + "22.05": + url: "https://github.com/seladb/PcapPlusPlus/archive/v22.05.tar.gz" + sha256: "5f299c4503bf5d3c29f82b8d876a19be7dea29c2aadcb52f2f3b394846c21da9" + "22.11": + url: "https://github.com/seladb/PcapPlusPlus/archive/v22.11.tar.gz" + sha256: "3172f12f2f8a8902ae1ad6be5d65c3059c42c49c1a28e97e5d8d25a48b05e44f" + "23.09": + url: "https://github.com/seladb/PcapPlusPlus/releases/tag/v23.09" + sha256: "608292f7d2a2e1b7af26adf89347597a6131547eea4e513194bc4f584a40fe74" +patches: + "21.05": + - patch_file: "patches/0001-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch" + patch_description: Pass CXXFLAGS and CPPFLAGS when-compiling 3rd party source + patch_type: conan + - patch_file: "patches/0003-Use-pthreads4w.patch" + patch_description: Use pthreads4w from conan center + patch_type: conan + - patch_file: patches/0004-Fix-md5-include.patch + patch_description: Fix md5 include configuration + patch_type: conan + "21.11": + - patch_file: "patches/0001-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch" + patch_description: Pass CXXFLAGS and CPPFLAGS when-compiling 3rd party source + patch_type: conan + - patch_file: "patches/0003-Use-pthreads4w.patch" + patch_description: Use pthreads4w from conan center + patch_type: conan + - patch_file: patches/0005-Fix-md5-include.patch + patch_description: Fix md5 include configuration + patch_type: conan + "22.05": + - patch_file: "patches/0002-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch" + patch_description: Pass CXXFLAGS and CPPFLAGS when-compiling 3rd party source + patch_type: conan + - patch_file: "patches/0003-Use-pthreads4w.patch" + patch_description: Use pthreads4w from conan center + patch_type: conan + - patch_file: patches/0006-Fix-md5-include.patch + patch_description: Fix md5 include configuration + patch_type: conan + "22.11": + - patch_file: "patches/0002-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch" + patch_description: Pass CXXFLAGS and CPPFLAGS when-compiling 3rd party source + patch_type: conan diff --git a/thirdparty/pcapplusplus/all/conanfile.py b/thirdparty/pcapplusplus/all/conanfile.py new file mode 100644 index 0000000000..398650c106 --- /dev/null +++ b/thirdparty/pcapplusplus/all/conanfile.py @@ -0,0 +1,145 @@ +import glob +import os + +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.files import apply_conandata_patches, copy, chdir, export_conandata_patches, get, rename, replace_in_file +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path, MSBuild, MSBuildToolchain +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.57.0" + + +class PcapplusplusConan(ConanFile): + name = "pcapplusplus" + package_type = "static-library" + license = "Unlicense" + description = "PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets" + topics = ("pcap", "network", "security", "packet") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/seladb/PcapPlusPlus" + settings = "os", "compiler", "build_type", "arch" + options = { + "fPIC": [True, False], + "immediate_mode": [True, False], + } + default_options = { + "fPIC": True, + "immediate_mode": False, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.settings.os == "Windows": + self.requires("npcap/1.70") + if self.version < "22.11": + self.requires("pthreads4w/3.0.0") + else: + self.requires("libpcap/1.10.1") + + # TODO: use conan recipe instead of embedded one + # self.requires("hash-library/8.0") + + def validate(self): + if self.settings.os == "Windows" and not is_msvc(self): + raise ConanInvalidConfiguration("Can not build on Windows: only msvc compiler is supported.") + if self.settings.os not in ("FreeBSD", "Linux", "Macos", "Windows"): + raise ConanInvalidConfiguration(f"{self.settings.os} is not supported") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + @property + def _configure_sh_script(self): + return { + "Android": "configure-android.sh", + "Linux": "configure-linux.sh", + "Macos": "configure-mac_os_x.sh", + "FreeBSD": "configure-freebsd.sh", + }[str(self.settings.os)] + + def _patch_sources(self): + if not self.options.get_safe("fPIC") and self.settings.os != "Windows": + replace_in_file(self, os.path.join(self.source_folder, "PcapPlusPlus.mk.common"), + "-fPIC", "") + apply_conandata_patches(self) + if self.settings.os != "Windows": + rename(self, os.path.join(self.source_folder, self._configure_sh_script), os.path.join(self.source_folder, "configure")) + else: + props_file = os.path.join(self.generators_folder, "conantoolchain.props") + vcxproj_templates = glob.glob(f"{self.source_folder}/mk/vs/*.vcxproj.template") + for template_file in vcxproj_templates: + # Load conan-generated conantoolchain.props before Microsoft.Cpp.props + # so that we have precedence over PlatformToolset version + replace_in_file(self, template_file, '', + f'\n') + + def generate(self): + if self.settings.os == "Windows": + tc = MSBuildToolchain(self) + tc.generate() + else: + tc = AutotoolsToolchain(self) + tc.configure_args.clear() # this configure script does not accept the typical arguments + tc.configure_args.extend([ + "--libpcap-include-dir", unix_path(self, self.dependencies["libpcap"].cpp_info.aggregated_components().includedirs[0]), + "--libpcap-lib-dir", unix_path(self, self.dependencies["libpcap"].cpp_info.aggregated_components().includedirs[0]), + ]) + + if self.options.immediate_mode: + tc.configure_args.append("--use-immediate-mode") + if is_apple_os(self) and "arm" in self.settings.arch: + tc.configure_args.append("--arm64") + + tc.generate() + + def build(self): + self._patch_sources() + if self.settings.os == "Windows": + self._build_windows() + else: + with chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.configure() + autotools.make(target="libs") + + def _build_windows(self): + with chdir(self, self.source_folder): + config_args = [ + "configure-windows-visual-studio.bat", + "--pcap-sdk", self.dependencies["npcap"].package_folder, + "--vs-version", "vs2015", # this will be later overridden by the props file generated by MSBuildToolchain + ] + if self.version < "22.11": + config_args += ["--pthreads-home", self.dependencies["pthreads4w"].package_folder] + self.run(" ".join(config_args), env="conanbuild") + msbuild = MSBuild(self) + targets = ['Common++', 'Packet++', 'Pcap++'] + msbuild.build("mk/vs2015/PcapPlusPlus.sln", targets=targets) + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), keep_path=False) + copy(self, "*.h", src=os.path.join(self.source_folder, "Dist", "header"), dst=os.path.join(self.package_folder, "include")) + copy(self, "*.a", src=os.path.join(self.source_folder, "Dist"), dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.lib", src=os.path.join(self.source_folder, "Dist"), dst=os.path.join(self.package_folder, "lib"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["Pcap++", "Packet++", "Common++"] + if self.version < "22.11" and self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs.append("pthread") + if self.settings.os == "Macos": + self.cpp_info.frameworks.extend(["CoreFoundation", "Security", "SystemConfiguration"]) + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32"] diff --git a/thirdparty/pcapplusplus/all/patches/0001-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch b/thirdparty/pcapplusplus/all/patches/0001-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch new file mode 100644 index 0000000000..9f23a37847 --- /dev/null +++ b/thirdparty/pcapplusplus/all/patches/0001-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch @@ -0,0 +1,22 @@ +--- 3rdParty/LightPcapNg/Makefile ++++ 3rdParty/LightPcapNg/Makefile +@@ -15,7 +15,7 @@ + + Obj/%.o: LightPcapNg/src/%.c + @echo Building file: $< +- @$(CC) $(INCLUDES) -Wall -O2 $(GLOBAL_FLAGS) $(DEFS) -g -c -o "$@" "$<" ++ @$(CC) $(CPPFLAGS) $(CLFAGS) $(INCLUDES) -Wall -O2 $(GLOBAL_FLAGS) $(DEFS) -g -c -o "$@" "$<" + + CUR_TARGET := $(notdir $(shell pwd)) + +--- 3rdParty/hash-library/Makefile ++++ 3rdParty/hash-library/Makefile +@@ -13,7 +13,7 @@ DEFS := -DUNIVERSAL -fPIC + + Obj/%.o: %.cpp + @echo Building file: $< +- @$(CXX) $(INCLUDES) -Wall -O2 $(GLOBAL_FLAGS) $(DEFS) -g -c -o "$@" "$<" ++ @$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -Wall -O2 $(GLOBAL_FLAGS) $(DEFS) -g -c -o "$@" "$<" + + CUR_TARGET := $(notdir $(shell pwd)) + diff --git a/thirdparty/pcapplusplus/all/patches/0002-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch b/thirdparty/pcapplusplus/all/patches/0002-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch new file mode 100644 index 0000000000..a3df9981b3 --- /dev/null +++ b/thirdparty/pcapplusplus/all/patches/0002-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch @@ -0,0 +1,11 @@ +--- 3rdParty/LightPcapNg/Makefile ++++ 3rdParty/LightPcapNg/Makefile +@@ -15,7 +15,7 @@ + + Obj/%.o: LightPcapNg/src/%.c + @echo Building file: $< +- @$(CC) $(INCLUDES) -Wall -O2 $(GLOBAL_FLAGS) $(DEFS) -g -c -o "$@" "$<" ++ @$(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) -Wall -O2 $(GLOBAL_FLAGS) $(DEFS) -g -c -o "$@" "$<" + + CUR_TARGET := $(notdir $(shell pwd)) + diff --git a/thirdparty/pcapplusplus/all/patches/0003-Use-pthreads4w.patch b/thirdparty/pcapplusplus/all/patches/0003-Use-pthreads4w.patch new file mode 100644 index 0000000000..d44a98ef07 --- /dev/null +++ b/thirdparty/pcapplusplus/all/patches/0003-Use-pthreads4w.patch @@ -0,0 +1,18 @@ +--- mk/vs/PcapPlusPlusPropertySheet.props.template ++++ mk/vs/PcapPlusPlusPropertySheet.props.template +@@ -23,12 +23,11 @@ + + + +- $(PThreadWin32Home)\Pre-built.2\include;%(AdditionalIncludeDirectories) ++ $(PThreadWin32Home)\include;%(AdditionalIncludeDirectories) + HAVE_STRUCT_TIMESPEC;%(PreprocessorDefinitions) + + +- $(PThreadWin32Home)\Pre-built.2\lib\x86;%(AdditionalLibraryDirectories) +- $(PThreadWin32Home)\Pre-built.2\lib\x64;%(AdditionalLibraryDirectories) ++ $(PThreadWin32Home)\lib;%(AdditionalLibraryDirectories) +- pthreadVC2.lib;%(AdditionalDependencies) ++ pthreadVC3.lib;%(AdditionalDependencies) + + diff --git a/thirdparty/pcapplusplus/all/patches/0004-Fix-md5-include.patch b/thirdparty/pcapplusplus/all/patches/0004-Fix-md5-include.patch new file mode 100644 index 0000000000..4232648a08 --- /dev/null +++ b/thirdparty/pcapplusplus/all/patches/0004-Fix-md5-include.patch @@ -0,0 +1,11 @@ +--- mk/vs/Packet++.vcxproj.template ++++ mk/vs/Packet++.vcxproj.template +@@ -271,7 +271,7 @@ + + + +- ++ + + + diff --git a/thirdparty/pcapplusplus/all/patches/0005-Fix-md5-include.patch b/thirdparty/pcapplusplus/all/patches/0005-Fix-md5-include.patch new file mode 100644 index 0000000000..4bb47fbc85 --- /dev/null +++ b/thirdparty/pcapplusplus/all/patches/0005-Fix-md5-include.patch @@ -0,0 +1,11 @@ +--- mk/vs/Packet++.vcxproj.template ++++ mk/vs/Packet++.vcxproj.template +@@ -273,7 +273,7 @@ + + + +- ++ + + + diff --git a/thirdparty/pcapplusplus/all/patches/0006-Fix-md5-include.patch b/thirdparty/pcapplusplus/all/patches/0006-Fix-md5-include.patch new file mode 100644 index 0000000000..115ab8bfc2 --- /dev/null +++ b/thirdparty/pcapplusplus/all/patches/0006-Fix-md5-include.patch @@ -0,0 +1,11 @@ +--- mk/vs/Packet++.vcxproj.template ++++ mk/vs/Packet++.vcxproj.template +@@ -275,7 +275,7 @@ + + + +- ++ + + + diff --git a/thirdparty/pcapplusplus/all/test_package/CMakeLists.txt b/thirdparty/pcapplusplus/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..8c5f8b3c73 --- /dev/null +++ b/thirdparty/pcapplusplus/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(pcapplusplus REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} pcapplusplus::pcapplusplus) diff --git a/thirdparty/pcapplusplus/all/test_package/conanfile.py b/thirdparty/pcapplusplus/all/test_package/conanfile.py new file mode 100644 index 0000000000..a9fb96656f --- /dev/null +++ b/thirdparty/pcapplusplus/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/pcapplusplus/all/test_package/test_package.cpp b/thirdparty/pcapplusplus/all/test_package/test_package.cpp new file mode 100644 index 0000000000..a39e3bf39b --- /dev/null +++ b/thirdparty/pcapplusplus/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include +#include + +int main() { + std::cout << "PCAP++ VERSION: " << pcpp::getPcapPlusPlusVersionFull() << std::endl; + return EXIT_SUCCESS; +} diff --git a/thirdparty/pcapplusplus/all/test_v1_package/CMakeLists.txt b/thirdparty/pcapplusplus/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..925ecbe19e --- /dev/null +++ b/thirdparty/pcapplusplus/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/thirdparty/pcapplusplus/all/test_v1_package/conanfile.py b/thirdparty/pcapplusplus/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..5a05af3c2d --- /dev/null +++ b/thirdparty/pcapplusplus/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/pcapplusplus/cmake/conandata.yml b/thirdparty/pcapplusplus/cmake/conandata.yml new file mode 100644 index 0000000000..26ff7631cb --- /dev/null +++ b/thirdparty/pcapplusplus/cmake/conandata.yml @@ -0,0 +1,4 @@ +sources: + "23.09": + url: "https://github.com/seladb/PcapPlusPlus/archive/v23.09.tar.gz" + sha256: "608292f7d2a2e1b7af26adf89347597a6131547eea4e513194bc4f584a40fe74" diff --git a/thirdparty/pcapplusplus/cmake/conanfile.py b/thirdparty/pcapplusplus/cmake/conanfile.py new file mode 100644 index 0000000000..e1a985494d --- /dev/null +++ b/thirdparty/pcapplusplus/cmake/conanfile.py @@ -0,0 +1,73 @@ +import os +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.errors import ConanInvalidConfiguration + + +required_conan_version = ">=1.52.0" + +class PcapplusplusConan(ConanFile): + name = "pcapplusplus" + package_type = "static-library" + license = "Unlicense" + description = "PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets" + topics = ("pcap", "network", "security", "packet") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/seladb/PcapPlusPlus" + settings = "os", "arch", "build_type", "compiler" + options = { + "immediate_mode": [True, False], + "fPIC": [True, False], + } + default_options = { + "immediate_mode": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def requirements(self): + if self.settings.os == "Windows": + self.requires("npcap/1.70") + else: + self.requires("libpcap/1.10.1") + + def validate(self): + if self.settings.os not in ("FreeBSD", "Linux", "Macos", "Windows"): + raise ConanInvalidConfiguration(f"{self.settings.os} is not supported") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["PCAPPP_BUILD_TESTS"] = False + tc.variables["PCAPPP_BUILD_EXAMPLES"] = False + tc.generate() + + def layout(self): + cmake_layout(self, src_folder="src") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), keep_path=False) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = ["Pcap++", "Packet++", "Common++"] + if self.settings.os == "Macos": + self.cpp_info.frameworks = ["CoreFoundation", "SystemConfiguration"] + elif self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32", "iphlpapi"] + self.cpp_info.set_property("cmake_file_name", "PcapPlusPlus") + self.cpp_info.set_property("cmake_target_name", "PcapPlusPlus::PcapPlusPlus") diff --git a/thirdparty/pcapplusplus/cmake/test_package/CMakeLists.txt b/thirdparty/pcapplusplus/cmake/test_package/CMakeLists.txt new file mode 100644 index 0000000000..d30ed5e5ea --- /dev/null +++ b/thirdparty/pcapplusplus/cmake/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(PcapPlusPlus REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PcapPlusPlus::PcapPlusPlus) diff --git a/thirdparty/pcapplusplus/cmake/test_package/conanfile.py b/thirdparty/pcapplusplus/cmake/test_package/conanfile.py new file mode 100644 index 0000000000..cc326072eb --- /dev/null +++ b/thirdparty/pcapplusplus/cmake/test_package/conanfile.py @@ -0,0 +1,29 @@ +import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/thirdparty/pcapplusplus/cmake/test_package/test_package.cpp b/thirdparty/pcapplusplus/cmake/test_package/test_package.cpp new file mode 100644 index 0000000000..65ce01f5c6 --- /dev/null +++ b/thirdparty/pcapplusplus/cmake/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include +#include "pcapplusplus/PcapPlusPlusVersion.h" + +int main() { + std::cout << "PCAP++ VERSION: " << pcpp::getPcapPlusPlusVersionFull() << std::endl; + return EXIT_SUCCESS; +} diff --git a/thirdparty/pcapplusplus/config.yml b/thirdparty/pcapplusplus/config.yml new file mode 100644 index 0000000000..d89c980a8b --- /dev/null +++ b/thirdparty/pcapplusplus/config.yml @@ -0,0 +1,11 @@ +versions: + "21.05": + folder: all + "21.11": + folder: all + "22.05": + folder: all + "22.11": + folder: all + "23.09": + folder: cmake diff --git a/thirdparty/rocksdb/all/conandata.yml b/thirdparty/rocksdb/all/conandata.yml new file mode 100644 index 0000000000..ed09c733cf --- /dev/null +++ b/thirdparty/rocksdb/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "8.10.2": + url: "https://github.com/facebook/rocksdb/archive/refs/tags/v8.10.2.tar.gz" + sha256: "44b6ec2f4723a0d495762da245d4a59d38704e0d9d3d31c45af4014bee853256" +patches: + "8.10.2": + - patch_file: "patches/arm7.patch" + patch_description: "Fix for ARM7" + patch_type: "portability" + patch_source: "https://github.com/apache/nifi-minifi-cpp/commit/36244376bb46c5c85657c6dfe92a6a0c4cea650a" + - patch_file: "patches/dboptions_equality_operator.patch" + patch_description: "Fix for missing equality operator in DBOptions and make DBOptions configurable" + patch_type: "portability" + patch_source: "https://github.com/apache/nifi-minifi-cpp/commit/545236fd06b613f2d2b38f74ff9ee85df9190d59" diff --git a/thirdparty/rocksdb/all/conanfile.py b/thirdparty/rocksdb/all/conanfile.py new file mode 100644 index 0000000000..4bd0fe3ab6 --- /dev/null +++ b/thirdparty/rocksdb/all/conanfile.py @@ -0,0 +1,243 @@ +import os +import glob +import shutil + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" + + +class RocksDBConan(ConanFile): + name = "rocksdb" + homepage = "https://github.com/facebook/rocksdb" + license = ("GPL-2.0-only", "Apache-2.0") + url = "https://github.com/conan-io/conan-center-index" + description = "A library that provides an embeddable, persistent key-value store for fast storage" + topics = ("database", "leveldb", "facebook", "key-value") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "lite": [True, False], + "with_gflags": [True, False], + "with_snappy": [True, False], + "with_lz4": [True, False], + "with_zlib": [True, False], + "with_bz2": [True, False], + "with_zstd": [True, False], + "with_tbb": [True, False], + "with_jemalloc": [True, False], + "enable_sse": [False, "sse42", "avx2"], + "use_rtti": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "lite": False, + "with_snappy": False, + "with_lz4": True, + "with_zlib": True, + "with_bz2": True, + "with_zstd": True, + "with_gflags": False, + "with_tbb": False, + "with_jemalloc": False, + "enable_sse": False, + "use_rtti": True, + } + + @property + def _min_cppstd(self): + return "11" if Version(self.version) < "8.8.1" else "20" + + @property + def _compilers_minimum_version(self): + return {} if self._min_cppstd == "11" else { + "apple-clang": "10", + "clang": "7", + "gcc": "7", + "msvc": "191", + "Visual Studio": "15", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.arch != "x86_64": + del self.options.with_tbb + if self.settings.build_type == "Debug": + self.options.use_rtti = True # Rtti are used in asserts for debug mode... + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_gflags: + self.requires("gflags/2.2.2") + if self.options.with_snappy: + self.requires("snappy/1.1.10") + if self.options.with_lz4: + self.requires("lz4/1.9.4") + if self.options.with_zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.with_bz2: + self.requires("bzip2/1.0.8") + # self.requires("bzip2/1.0.8@minifi/dev") # prebuilt with minifi bz2 patch + if self.options.with_zstd: + self.requires("zstd/1.5.5") + if self.options.get_safe("with_tbb"): + self.requires("onetbb/2021.10.0") + if self.options.with_jemalloc: + self.requires("jemalloc/5.3.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + if self.settings.arch not in ["x86_64", "ppc64le", "ppc64", "mips64", "armv8"]: + raise ConanInvalidConfiguration("Rocksdb requires 64 bits") + + check_min_vs(self, "191") + + if self.version == "6.20.3" and \ + self.settings.os == "Linux" and \ + self.settings.compiler == "gcc" and \ + Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration("Rocksdb 6.20.3 is not compilable with gcc <5.") # See https://github.com/facebook/rocksdb/issues/3522 + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FAIL_ON_WARNINGS"] = False + tc.variables["WITH_TESTS"] = False + tc.variables["WITH_TOOLS"] = True + tc.variables["WITH_CORE_TOOLS"] = False + tc.variables["WITH_BENCHMARK_TOOLS"] = False + tc.variables["WITH_FOLLY_DISTRIBUTED_MUTEX"] = False + if is_msvc(self): + tc.variables["WITH_MD_LIBRARY"] = not is_msvc_static_runtime(self) + tc.variables["ROCKSDB_INSTALL_ON_WINDOWS"] = self.settings.os == "Windows" + tc.variables["ROCKSDB_LITE"] = self.options.lite + tc.variables["WITH_GFLAGS"] = self.options.with_gflags + tc.variables["WITH_SNAPPY"] = self.options.with_snappy + tc.variables["WITH_LZ4"] = self.options.with_lz4 + tc.variables["WITH_ZLIB"] = self.options.with_zlib + tc.variables["WITH_BZ2"] = self.options.with_bz2 + tc.variables["WITH_ZSTD"] = self.options.with_zstd + tc.variables["WITH_TBB"] = self.options.get_safe("with_tbb", False) + tc.variables["WITH_JEMALLOC"] = self.options.with_jemalloc + tc.variables["ROCKSDB_BUILD_SHARED"] = self.options.shared + tc.variables["ROCKSDB_LIBRARY_EXPORTS"] = self.settings.os == "Windows" and self.options.shared + tc.variables["ROCKSDB_DLL" ] = self.settings.os == "Windows" and self.options.shared + tc.variables["USE_RTTI"] = self.options.use_rtti + if not bool(self.options.enable_sse): + tc.variables["PORTABLE"] = True + tc.variables["FORCE_SSE42"] = False + elif self.options.enable_sse == "sse42": + tc.variables["PORTABLE"] = True + tc.variables["FORCE_SSE42"] = True + elif self.options.enable_sse == "avx2": + tc.variables["PORTABLE"] = True + tc.variables["FORCE_SSE42"] = False + # not available yet in CCI + tc.variables["WITH_NUMA"] = False + tc.generate() + + deps = CMakeDeps(self) + if self.options.with_jemalloc: + deps.set_property("jemalloc", "cmake_file_name", "JeMalloc") + deps.set_property("jemalloc", "cmake_target_name", "JeMalloc::JeMalloc") + if self.options.with_zstd: + deps.set_property("zstd", "cmake_target_name", "zstd::zstd") + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def _remove_static_libraries(self): + rm(self, "rocksdb.lib", os.path.join(self.package_folder, "lib")) + for lib in glob.glob(os.path.join(self.package_folder, "lib", "*.a")): + if not lib.endswith(".dll.a"): + os.remove(lib) + + def _remove_cpp_headers(self): + for path in glob.glob(os.path.join(self.package_folder, "include", "rocksdb", "*")): + if path != os.path.join(self.package_folder, "include", "rocksdb", "c.h"): + if os.path.isfile(path): + os.remove(path) + else: + shutil.rmtree(path) + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + if self.options.shared: + self._remove_static_libraries() + self._remove_cpp_headers() # Force stable ABI for shared libraries + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + cmake_target = "rocksdb-shared" if self.options.shared else "rocksdb" + self.cpp_info.set_property("cmake_file_name", "RocksDB") + self.cpp_info.set_property("cmake_target_name", f"RocksDB::{cmake_target}") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["librocksdb"].libs = collect_libs(self) + if self.settings.os == "Windows": + self.cpp_info.components["librocksdb"].system_libs = ["shlwapi", "rpcrt4"] + if self.options.shared: + self.cpp_info.components["librocksdb"].defines = ["ROCKSDB_DLL"] + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["librocksdb"].system_libs = ["pthread", "m"] + if self.options.lite: + self.cpp_info.components["librocksdb"].defines.append("ROCKSDB_LITE") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "RocksDB" + self.cpp_info.names["cmake_find_package_multi"] = "RocksDB" + self.cpp_info.components["librocksdb"].names["cmake_find_package"] = cmake_target + self.cpp_info.components["librocksdb"].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.components["librocksdb"].set_property("cmake_target_name", f"RocksDB::{cmake_target}") + if self.options.with_gflags: + self.cpp_info.components["librocksdb"].requires.append("gflags::gflags") + if self.options.with_snappy: + self.cpp_info.components["librocksdb"].requires.append("snappy::snappy") + if self.options.with_lz4: + self.cpp_info.components["librocksdb"].requires.append("lz4::lz4") + if self.options.with_zlib: + self.cpp_info.components["librocksdb"].requires.append("zlib::zlib") + if self.options.with_bz2: + self.cpp_info.components["librocksdb"].requires.append("bzip2::bzip2") + if self.options.with_zstd: + self.cpp_info.components["librocksdb"].requires.append("zstd::zstd") + if self.options.get_safe("with_tbb"): + self.cpp_info.components["librocksdb"].requires.append("onetbb::onetbb") + if self.options.with_jemalloc: + self.cpp_info.components["librocksdb"].requires.append("jemalloc::jemalloc") diff --git a/thirdparty/rocksdb/arm7.patch b/thirdparty/rocksdb/all/patches/arm7.patch similarity index 91% rename from thirdparty/rocksdb/arm7.patch rename to thirdparty/rocksdb/all/patches/arm7.patch index 1eb64ed5ce..bd1eb6aa22 100644 --- a/thirdparty/rocksdb/arm7.patch +++ b/thirdparty/rocksdb/all/patches/arm7.patch @@ -4,7 +4,7 @@ index 225e3fa72..cd5f935f1 100644 +++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h @@ -131,6 +131,10 @@ static inline tokutime_t toku_time_now(void) { uint64_t result; - __asm __volatile__("mrs %[rt], cntvct_el0" : [ rt ] "=r"(result)); + __asm __volatile__("mrs %[rt], cntvct_el0" : [rt] "=r"(result)); return result; +#elif defined(__arm__) + uint32_t lo, hi; diff --git a/thirdparty/rocksdb/cstdint.patch b/thirdparty/rocksdb/all/patches/cstdint.patch similarity index 100% rename from thirdparty/rocksdb/cstdint.patch rename to thirdparty/rocksdb/all/patches/cstdint.patch diff --git a/thirdparty/rocksdb/dboptions_equality_operator.patch b/thirdparty/rocksdb/all/patches/dboptions_equality_operator.patch similarity index 100% rename from thirdparty/rocksdb/dboptions_equality_operator.patch rename to thirdparty/rocksdb/all/patches/dboptions_equality_operator.patch diff --git a/thirdparty/rocksdb/all/test_package/CMakeLists.txt b/thirdparty/rocksdb/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..b23ea40acd --- /dev/null +++ b/thirdparty/rocksdb/all/test_package/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +enable_testing() + +find_package(RocksDB REQUIRED CONFIG) + +add_executable(${PROJECT_NAME}_stable_abi test_package_stable_abi.cpp) +add_test(NAME ${PROJECT_NAME}_stable_abi COMMAND ${PROJECT_NAME}_stable_abi) +if(ROCKSDB_SHARED) + target_link_libraries(${PROJECT_NAME}_stable_abi PRIVATE RocksDB::rocksdb-shared) +else() + target_link_libraries(${PROJECT_NAME}_stable_abi PRIVATE RocksDB::rocksdb) + + add_executable(${PROJECT_NAME}_cpp test_package.cpp) + target_link_libraries(${PROJECT_NAME}_cpp PRIVATE RocksDB::rocksdb) + if(RocksDB_VERSION VERSION_LESS "8.8.1") + target_compile_features(${PROJECT_NAME}_cpp PRIVATE cxx_std_11) + else() + target_compile_features(${PROJECT_NAME}_cpp PRIVATE cxx_std_17) + endif() + add_test(NAME ${PROJECT_NAME}_cpp COMMAND ${PROJECT_NAME}_cpp) +endif() diff --git a/thirdparty/rocksdb/all/test_package/conanfile.py b/thirdparty/rocksdb/all/test_package/conanfile.py new file mode 100644 index 0000000000..06b097c220 --- /dev/null +++ b/thirdparty/rocksdb/all/test_package/conanfile.py @@ -0,0 +1,29 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ROCKSDB_SHARED"] = self.dependencies["rocksdb"].options.shared + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + self.run(f"ctest --output-on-failure -C {self.settings.build_type}", env="conanrun") diff --git a/thirdparty/rocksdb/all/test_package/test_package.cpp b/thirdparty/rocksdb/all/test_package/test_package.cpp new file mode 100644 index 0000000000..8b0956584b --- /dev/null +++ b/thirdparty/rocksdb/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "rocksdb/db.h" + +int main() { + rocksdb::DB* db; + rocksdb::Options options; + options.create_if_missing = true; + rocksdb::Status status = rocksdb::DB::Open(options, "testdb", &db); + + if (!status.ok()) { + std::cerr << "DB error: " << status.ToString() << std::endl; + } + delete db; + return EXIT_SUCCESS; +} diff --git a/thirdparty/rocksdb/all/test_package/test_package_stable_abi.cpp b/thirdparty/rocksdb/all/test_package/test_package_stable_abi.cpp new file mode 100644 index 0000000000..92a984477f --- /dev/null +++ b/thirdparty/rocksdb/all/test_package/test_package_stable_abi.cpp @@ -0,0 +1,26 @@ +#include +#include +#include "rocksdb/c.h" + +int main() { + rocksdb_options_t *options = rocksdb_options_create(); + rocksdb_options_set_create_if_missing(options, 1); + char* err = NULL; + rocksdb_t* db = rocksdb_open(options, "testdb_stable", &err); + + if (!db) { + printf("DB error: %s\n", err); + } else { + rocksdb_close(db); + } + + if(err) { + rocksdb_free(err); + } + + if(options) { + rocksdb_free(options); + } + + return EXIT_SUCCESS; +} diff --git a/thirdparty/rocksdb/config.yml b/thirdparty/rocksdb/config.yml new file mode 100644 index 0000000000..21a3c25eab --- /dev/null +++ b/thirdparty/rocksdb/config.yml @@ -0,0 +1,3 @@ +versions: + "8.10.2": + folder: all diff --git a/thirdparty/soci/all/conandata.yml b/thirdparty/soci/all/conandata.yml new file mode 100644 index 0000000000..47dda7cf20 --- /dev/null +++ b/thirdparty/soci/all/conandata.yml @@ -0,0 +1,17 @@ +sources: + "4.0.3": + url: "https://github.com/SOCI/soci/archive/v4.0.3.tar.gz" + sha256: "4b1ff9c8545c5d802fbe06ee6cd2886630e5c03bf740e269bb625b45cf934928" + "4.0.1": + url: "https://github.com/SOCI/soci/archive/4.0.1.tar.gz" + sha256: "fa69347b1a1ef74450c0382b665a67bd6777cc7005bbe09726479625bcf1e29c" +patches: + "4.0.3": + - patch_file: "patches/0001-Remove-hardcoded-INSTALL_NAME_DIR-for-relocatable-li.patch" + patch_description: "Generate relocatable libraries on MacOS" + patch_type: "portability" + "4.0.1": + - patch_file: "patches/sqlite3-path.patch" + patch_description: "Add HINTS with environment variable of SQLITE_ROOT for finding sqlite3 library" + patch_type: "portability" + diff --git a/thirdparty/soci/all/conanfile.py b/thirdparty/soci/all/conanfile.py new file mode 100644 index 0000000000..e46bae0948 --- /dev/null +++ b/thirdparty/soci/all/conanfile.py @@ -0,0 +1,321 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.55.0" + + +class SociConan(ConanFile): + name = "soci" + homepage = "https://github.com/SOCI/soci" + url = "https://github.com/conan-io/conan-center-index" + description = "The C++ Database Access Library " + topics = ("mysql", "odbc", "postgresql", "sqlite3") + license = "BSL-1.0" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "empty": [True, False], + "with_sqlite3": [True, False], + "with_db2": [True, False], + "with_odbc": [True, False], + "with_oracle": [True, False], + "with_firebird": [True, False], + "with_mysql": [True, False], + "with_postgresql": [True, False], + "with_boost": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "empty": False, + "with_sqlite3": False, + "with_db2": False, + "with_odbc": True, + "with_oracle": False, + "with_firebird": False, + "with_mysql": False, + "with_postgresql": False, + "with_boost": False, + } + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="src") + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def requirements(self): + if self.options.with_sqlite3: + self.requires("sqlite3/3.44.2") + if self.options.with_odbc and self.settings.os != "Windows": + self.requires("odbc/2.3.11") + if self.options.with_mysql: + self.requires("libmysqlclient/8.1.0") + if self.options.with_postgresql: + self.requires("libpq/15.4") + if self.options.with_boost: + self.requires("boost/1.83.0") + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "14", + "gcc": "4.8", + "clang": "3.8", + "apple-clang": "8.0" + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + compiler = str(self.settings.compiler) + compiler_version = Version(self.settings.compiler.version.value) + if compiler not in self._minimum_compilers_version: + self.output.warning("{} recipe lacks information about the {} compiler support.".format(self.name, self.settings.compiler)) + elif compiler_version < self._minimum_compilers_version[compiler]: + raise ConanInvalidConfiguration("{} requires a {} version >= {}".format(self.name, compiler, compiler_version)) + + prefix = "Dependencies for" + message = "not configured in this conan package." + if self.options.with_db2: + # self.requires("db2/0.0.0") # TODO add support for db2 + raise ConanInvalidConfiguration("{} DB2 {} ".format(prefix, message)) + if self.options.with_oracle: + # self.requires("oracle_db/0.0.0") # TODO add support for oracle + raise ConanInvalidConfiguration("{} ORACLE {} ".format(prefix, message)) + if self.options.with_firebird: + # self.requires("firebird/0.0.0") # TODO add support for firebird + raise ConanInvalidConfiguration("{} firebird {} ".format(prefix, message)) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + + # MacOS @rpath + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.variables["SOCI_SHARED"] = self.options.shared + tc.variables["SOCI_STATIC"] = not self.options.shared + tc.variables["SOCI_TESTS"] = False + tc.variables["SOCI_CXX11"] = True + tc.variables["SOCI_EMPTY"] = self.options.empty + tc.variables["WITH_SQLITE3"] = self.options.with_sqlite3 + tc.variables["WITH_DB2"] = self.options.with_db2 + tc.variables["WITH_ODBC"] = self.options.with_odbc + tc.variables["WITH_ORACLE"] = self.options.with_oracle + tc.variables["WITH_FIREBIRD"] = self.options.with_firebird + tc.variables["WITH_MYSQL"] = self.options.with_mysql + tc.variables["WITH_POSTGRESQL"] = self.options.with_postgresql + tc.variables["WITH_BOOST"] = self.options.with_boost + tc.generate() + + deps = CMakeDeps(self) + deps.set_property("mysql", "cmake_file_name", "MYSQL") + deps.set_property("libpq", "cmake_file_name", "POSTGRESQL") + deps.set_property("sqlite3", "cmake_file_name", "SQLITE3") + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE_1_0.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + + cmake = CMake(self) + cmake.install() + + # rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path) + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent(f"""\ + set(SOCI_FOUND TRUE) + if(DEFINED SOCI_INCLUDE_DIRS) + set(SOCI_INCLUDE_DIRS ${{SOCI_INCLUDE_DIRS}}) + endif() + if(DEFINED SOCI_LIBRARIES) + set(SOCI_LIBRARIES ${{SOCI_LIBRARIES}}) + endif() + set(SOCI_VERSION_MAJOR {Version(self.version).major}) + set(SOCI_VERSION_MINOR {Version(self.version).minor}) + set(SOCI_VERSION_PATCH {Version(self.version).patch}) + set(SOCI_VERSION_STRING "{self.version}") + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + + + def package_403_info(self): + self.cpp_info.set_property("cmake_file_name", "SOCI") + target_suffix = "" if self.options.shared else "_static" + lib_prefix = "lib" if is_msvc(self) and not self.options.shared else "" + version = Version(self.version) + lib_suffix = "_{}_{}".format(version.major, version.minor) if self.settings.os == "Windows" else "" + + # soci_core + self.cpp_info.components["soci_core"].set_property("cmake_target_name", "SOCI::soci_core{}".format(target_suffix)) + self.cpp_info.components["soci_core"].libs = ["{}soci_core{}".format(lib_prefix, lib_suffix)] + if self.options.with_boost: + self.cpp_info.components["soci_core"].requires.append("boost::boost") + + # soci_empty + if self.options.empty: + self.cpp_info.components["soci_empty"].set_property("cmake_target_name", "SOCI::soci_empty{}".format(target_suffix)) + self.cpp_info.components["soci_empty"].libs = ["{}soci_empty{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_empty"].requires = ["soci_core"] + + # soci_sqlite3 + if self.options.with_sqlite3: + self.cpp_info.components["soci_sqlite3"].set_property("cmake_target_name", "SOCI::soci_sqlite3{}".format(target_suffix)) + self.cpp_info.components["soci_sqlite3"].libs = ["{}soci_sqlite3{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_sqlite3"].requires = ["soci_core", "sqlite3::sqlite3"] + + # soci_odbc + if self.options.with_odbc: + self.cpp_info.components["soci_odbc"].set_property("cmake_target_name", "SOCI::soci_odbc{}".format(target_suffix)) + self.cpp_info.components["soci_odbc"].libs = ["{}soci_odbc{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_odbc"].requires = ["soci_core"] + if self.settings.os == "Windows": + self.cpp_info.components["soci_odbc"].system_libs.append("odbc32") + else: + self.cpp_info.components["soci_odbc"].requires.append("odbc::odbc") + + # soci_mysql + if self.options.with_mysql: + self.cpp_info.components["soci_mysql"].set_property("cmake_target_name", "SOCI::soci_mysql{}".format(target_suffix)) + self.cpp_info.components["soci_mysql"].libs = ["{}soci_mysql{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_mysql"].requires = ["soci_core", "libmysqlclient::libmysqlclient"] + + # soci_postgresql + if self.options.with_postgresql: + self.cpp_info.components["soci_postgresql"].set_property("cmake_target_name", "SOCI::soci_postgresql{}".format(target_suffix)) + self.cpp_info.components["soci_postgresql"].libs = ["{}soci_postgresql{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_postgresql"].requires = ["soci_core", "libpq::libpq"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "SOCI" + self.cpp_info.names["cmake_find_package_multi"] = "SOCI" + self.cpp_info.components["soci_core"].names["cmake_find_package"] = "soci_core{}".format(target_suffix) + self.cpp_info.components["soci_core"].names["cmake_find_package_multi"] = "soci_core{}".format(target_suffix) + if self.options.empty: + self.cpp_info.components["soci_empty"].names["cmake_find_package"] = "soci_empty{}".format(target_suffix) + self.cpp_info.components["soci_empty"].names["cmake_find_package_multi"] = "soci_empty{}".format(target_suffix) + if self.options.with_sqlite3: + self.cpp_info.components["soci_sqlite3"].names["cmake_find_package"] = "soci_sqlite3{}".format(target_suffix) + self.cpp_info.components["soci_sqlite3"].names["cmake_find_package_multi"] = "soci_sqlite3{}".format(target_suffix) + if self.options.with_odbc: + self.cpp_info.components["soci_odbc"].names["cmake_find_package"] = "soci_odbc{}".format(target_suffix) + self.cpp_info.components["soci_odbc"].names["cmake_find_package_multi"] = "soci_odbc{}".format(target_suffix) + if self.options.with_mysql: + self.cpp_info.components["soci_mysql"].names["cmake_find_package"] = "soci_mysql{}".format(target_suffix) + self.cpp_info.components["soci_mysql"].names["cmake_find_package_multi"] = "soci_mysql{}".format(target_suffix) + if self.options.with_postgresql: + self.cpp_info.components["soci_postgresql"].names["cmake_find_package"] = "soci_postgresql{}".format(target_suffix) + self.cpp_info.components["soci_postgresql"].names["cmake_find_package_multi"] = "soci_postgresql{}".format(target_suffix) + + + def package_401_info(self): + self.cpp_info.set_property("cmake_file_name", "SOCI") + target_suffix = "" if self.options.shared else "_static" + lib_prefix = "lib" if is_msvc(self) and not self.options.shared else "" + version = Version(self.version) + lib_suffix = "_{}_{}".format(version.major, version.minor) if self.settings.os == "Windows" else "" + + self.cpp_info.set_property("cmake_target_name", "SOCI::soci_core") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.libs = ["soci_core"] + + # soci_core + self.cpp_info.components["libsoci_core"].set_property("cmake_target_name", "SOCI::libsoci_core") + if self.options.with_boost: + self.cpp_info.components["libsoci_core"].requires.append("boost::boost") + + + # soci_empty + if self.options.empty: + self.cpp_info.components["soci_empty"].set_property("cmake_target_name", "SOCI::soci_empty{}".format(target_suffix)) + self.cpp_info.components["soci_empty"].libs = ["{}soci_empty{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_empty"].requires = ["soci_core"] + + # soci_sqlite3 + if self.options.with_sqlite3: + self.cpp_info.components["soci_sqlite3"].set_property("cmake_target_name", "SOCI::soci_sqlite3{}".format(target_suffix)) + self.cpp_info.components["soci_sqlite3"].libs = ["{}soci_sqlite3{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_sqlite3"].requires = ["soci_core", "sqlite3::sqlite3"] + + # soci_odbc + if self.options.with_odbc: + self.cpp_info.components["soci_odbc"].set_property("cmake_target_name", "SOCI::libsoci_odbc") + self.cpp_info.components["soci_odbc"].requires = ["soci_core"] + if self.settings.os == "Windows": + self.cpp_info.components["soci_odbc"].system_libs.append("odbc32") + else: + self.cpp_info.components["soci_odbc"].requires.append("odbc::odbc") + + # soci_mysql + if self.options.with_mysql: + self.cpp_info.components["soci_mysql"].set_property("cmake_target_name", "SOCI::soci_mysql{}".format(target_suffix)) + self.cpp_info.components["soci_mysql"].libs = ["{}soci_mysql{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_mysql"].requires = ["soci_core", "libmysqlclient::libmysqlclient"] + + # soci_postgresql + if self.options.with_postgresql: + self.cpp_info.components["soci_postgresql"].set_property("cmake_target_name", "SOCI::soci_postgresql{}".format(target_suffix)) + self.cpp_info.components["soci_postgresql"].libs = ["{}soci_postgresql{}".format(lib_prefix, lib_suffix)] + self.cpp_info.components["soci_postgresql"].requires = ["soci_core", "libpq::libpq"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "SOCI" + self.cpp_info.names["cmake_find_package_multi"] = "SOCI" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["soci_core"].names["cmake_find_package"] = "libsoci_core" + self.cpp_info.components["soci_core"].names["cmake_find_package_multi"] = "libsoci_core" + if self.options.empty: + self.cpp_info.components["soci_empty"].names["cmake_find_package"] = "soci_empty{}".format(target_suffix) + self.cpp_info.components["soci_empty"].names["cmake_find_package_multi"] = "soci_empty{}".format(target_suffix) + if self.options.with_sqlite3: + self.cpp_info.components["soci_sqlite3"].names["cmake_find_package"] = "soci_sqlite3{}".format(target_suffix) + self.cpp_info.components["soci_sqlite3"].names["cmake_find_package_multi"] = "soci_sqlite3{}".format(target_suffix) + if self.options.with_odbc: + self.cpp_info.components["soci_odbc"].names["cmake_find_package"] = "soci_odbc" + self.cpp_info.components["soci_odbc"].names["cmake_find_package_multi"] = "soci_odbc" + if self.options.with_mysql: + self.cpp_info.components["soci_mysql"].names["cmake_find_package"] = "soci_mysql{}".format(target_suffix) + self.cpp_info.components["soci_mysql"].names["cmake_find_package_multi"] = "soci_mysql{}".format(target_suffix) + if self.options.with_postgresql: + self.cpp_info.components["soci_postgresql"].names["cmake_find_package"] = "soci_postgresql{}".format(target_suffix) + self.cpp_info.components["soci_postgresql"].names["cmake_find_package_multi"] = "soci_postgresql{}".format(target_suffix) + + def package_info(self): + + self.package_401_info() + + # self.package_403_info() diff --git a/thirdparty/soci/all/patches/0001-Remove-hardcoded-INSTALL_NAME_DIR-for-relocatable-li.patch b/thirdparty/soci/all/patches/0001-Remove-hardcoded-INSTALL_NAME_DIR-for-relocatable-li.patch new file mode 100644 index 0000000000..5de0027f75 --- /dev/null +++ b/thirdparty/soci/all/patches/0001-Remove-hardcoded-INSTALL_NAME_DIR-for-relocatable-li.patch @@ -0,0 +1,39 @@ +From d491bf7b5040d314ffd0c6310ba01f78ff44c85e Mon Sep 17 00:00:00 2001 +From: Rasmus Thomsen +Date: Fri, 14 Apr 2023 09:16:29 +0200 +Subject: [PATCH] Remove hardcoded INSTALL_NAME_DIR for relocatable libraries + on MacOS + +--- + cmake/SociBackend.cmake | 2 +- + src/core/CMakeLists.txt | 1 - + 2 files changed, 1 insertion(+), 2 deletions(-) + +diff --git a/cmake/SociBackend.cmake b/cmake/SociBackend.cmake +index 5d4ef0df..39fe1f77 100644 +--- a/cmake/SociBackend.cmake ++++ b/cmake/SociBackend.cmake +@@ -171,7 +171,7 @@ macro(soci_backend NAME) + set_target_properties(${THIS_BACKEND_TARGET} + PROPERTIES + SOVERSION ${${PROJECT_NAME}_SOVERSION} +- INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib) ++ ) + + if(APPLE) + set_target_properties(${THIS_BACKEND_TARGET} +diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt +index 3e7deeae..f9eae564 100644 +--- a/src/core/CMakeLists.txt ++++ b/src/core/CMakeLists.txt +@@ -59,7 +59,6 @@ if (SOCI_SHARED) + PROPERTIES + VERSION ${SOCI_VERSION} + SOVERSION ${SOCI_SOVERSION} +- INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib + CLEAN_DIRECT_OUTPUT 1) + endif() + +-- +2.25.1 + diff --git a/thirdparty/soci/sqlite3-path.patch b/thirdparty/soci/all/patches/sqlite3-path.patch similarity index 80% rename from thirdparty/soci/sqlite3-path.patch rename to thirdparty/soci/all/patches/sqlite3-path.patch index 13d8e38e03..8138c87a2b 100644 --- a/thirdparty/soci/sqlite3-path.patch +++ b/thirdparty/soci/all/patches/sqlite3-path.patch @@ -1,6 +1,6 @@ -diff -rupN orig/cmake/modules/FindSQLite3.cmake patched/cmake/modules/FindSQLite3.cmake ---- orig/cmake/modules/FindSQLite3.cmake 2020-10-19 16:59:47 -+++ patched/cmake/modules/FindSQLite3.cmake 2024-02-14 13:05:00 +diff --git a/cmake/modules/FindSQLite3.cmake b/cmake/modules/FindSQLite3.cmake +--- a/cmake/modules/FindSQLite3.cmake ++++ b/cmake/modules/FindSQLite3.cmake @@ -17,6 +17,8 @@ find_path(SQLITE3_INCLUDE_DIR find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h diff --git a/thirdparty/soci/all/test_package/CMakeLists.txt b/thirdparty/soci/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..d4b8a7f3af --- /dev/null +++ b/thirdparty/soci/all/test_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +find_package(SOCI REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +if(TARGET SOCI::soci_core_static) + target_link_libraries(${PROJECT_NAME} SOCI::soci_core_static) +elseif(TARGET SOCI::libsoci_core) + target_link_libraries(${PROJECT_NAME} SOCI::libsoci_core) +elseif(TARGET SOCI::soci_core) + target_link_libraries(${PROJECT_NAME} SOCI::soci_core) +else() + target_link_libraries(${PROJECT_NAME} soci::soci) +endif() +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/thirdparty/soci/all/test_package/conanfile.py b/thirdparty/soci/all/test_package/conanfile.py new file mode 100644 index 0000000000..84eaa369e4 --- /dev/null +++ b/thirdparty/soci/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type", + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/thirdparty/soci/all/test_package/test_package.cpp b/thirdparty/soci/all/test_package/test_package.cpp new file mode 100644 index 0000000000..8bae2bf204 --- /dev/null +++ b/thirdparty/soci/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include "soci/soci.h" +#include + +int main() +{ + const auto& connectString{"../database0.empty.db"}; + const auto& table{"table1"}; + std::cout << "soci database connected successfully\n"; + + return 0; +} diff --git a/thirdparty/soci/all/test_v1_package/CMakeLists.txt b/thirdparty/soci/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000..91630d79f4 --- /dev/null +++ b/thirdparty/soci/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/thirdparty/soci/all/test_v1_package/conanfile.py b/thirdparty/soci/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000..38f4483872 --- /dev/null +++ b/thirdparty/soci/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/thirdparty/soci/config.yml b/thirdparty/soci/config.yml new file mode 100644 index 0000000000..ed0f11bce8 --- /dev/null +++ b/thirdparty/soci/config.yml @@ -0,0 +1,6 @@ +versions: + "4.0.3": + folder: all + "4.0.1": + folder: all +