This is an automated email from the ASF dual-hosted git repository. fgerlits pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 0bf8ce968bdebfa6867eb339049bfabca19e5df0 Author: Gabor Gyimesi <[email protected]> AuthorDate: Mon Jul 4 12:04:08 2022 +0200 MINIFICPP-1878 Enable Ninja build in Windows builds Do not use ninja in CI: The ninja build does not seem to be faster in the CI environment probably due to the limited 2 threads available. Signed-off-by: Ferenc Gerlits <[email protected]> This closes #1364 --- CMakeLists.txt | 18 +++--- Windows.md | 1 + cmake/Abseil.cmake | 1 + cmake/BundledCivetWeb.cmake | 107 -------------------------------- cmake/CivetWeb.cmake | 44 +++++++++++++ cmake/civetweb/dummy/FindCivetWeb.cmake | 22 ------- extensions/civetweb/CMakeLists.txt | 14 ++--- extensions/openwsman/CMakeLists.txt | 2 +- thirdparty/civetweb/civetweb.patch | 29 --------- win_build_vs.bat | 8 ++- 10 files changed, 68 insertions(+), 178 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 327060891..3db06e7ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -325,8 +325,7 @@ if ((ENABLE_OPENWSMAN AND NOT DISABLE_CIVET AND NOT DISABLE_CURL) OR ENABLE_ALL endif() if (ENABLE_ALL OR ENABLE_PROMETHEUS OR NOT DISABLE_CIVET) - include(BundledCivetWeb) - use_bundled_civetweb(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + include(CivetWeb) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/civetweb/dummy") endif() @@ -474,16 +473,13 @@ if(WIN32) set(CPACK_WIX_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/msi/WixWinMergeModules.wsi") else() message("Creating installer with redistributables") - if(CMAKE_VS_PLATFORM_TOOLSET STREQUAL "v141") - file(GLOB VCRUNTIME_X86_REDIST_CRT_DIR "${VCRUNTIME_REDIST_DIR}/x86/Microsoft.VC141.CRT") - file(GLOB VCRUNTIME_X64_REDIST_CRT_DIR "${VCRUNTIME_REDIST_DIR}/x64/Microsoft.VC141.CRT") - elseif(CMAKE_VS_PLATFORM_TOOLSET STREQUAL "v142") - file(GLOB VCRUNTIME_X86_REDIST_CRT_DIR "${VCRUNTIME_REDIST_DIR}/x86/Microsoft.VC142.CRT") - file(GLOB VCRUNTIME_X64_REDIST_CRT_DIR "${VCRUNTIME_REDIST_DIR}/x64/Microsoft.VC142.CRT") - endif() - - if (NOT VCRUNTIME_X86_REDIST_CRT_DIR OR NOT VCRUNTIME_X64_REDIST_CRT_DIR) + file(GLOB VC_RUNTIME_X86_REDIST_CRT_DIR_LIST LIST_DIRECTORIES true "${VCRUNTIME_REDIST_DIR}/x86/Microsoft.VC*.CRT") + file(GLOB VC_RUNTIME_X64_REDIST_CRT_DIR_LIST LIST_DIRECTORIES true "${VCRUNTIME_REDIST_DIR}/x64/Microsoft.VC*.CRT") + if (NOT VC_RUNTIME_X86_REDIST_CRT_DIR_LIST OR NOT VC_RUNTIME_X64_REDIST_CRT_DIR_LIST) message(FATAL_ERROR "Could not find the VC Redistributable. Please set VCRUNTIME_X86_REDIST_CRT_DIR and VCRUNTIME_X64_REDIST_CRT_DIR manually!") + else() + list(GET VCRUNTIME_X86_REDIST_CRT_DIR 0 VC_RUNTIME_X86_REDIST_CRT_DIR_LIST) + list(GET VCRUNTIME_X64_REDIST_CRT_DIR 0 VC_RUNTIME_X64_REDIST_CRT_DIR_LIST) endif() if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Windows.md b/Windows.md index 8a7bfb1cc..bdf9bbd64 100644 --- a/Windows.md +++ b/Windows.md @@ -74,6 +74,7 @@ After the build directory it will take optional parameters modifying the CMake c | /D | Builds RelWithDebInfo build instead of Release | | /DD | Builds Debug build instead of Release | | /CI | Sets STRICT_GSL_CHECKS to AUDIT | +| /NINJA | Uses Ninja build system instead of MSBuild | Examples: - 32-bit build with kafka, disabling tests, enabling MSI creation: `win_build_vs.bat build32 /T /K /P` diff --git a/cmake/Abseil.cmake b/cmake/Abseil.cmake index 5df8063ba..48bb01712 100644 --- a/cmake/Abseil.cmake +++ b/cmake/Abseil.cmake @@ -19,6 +19,7 @@ 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/20211102.0.tar.gz diff --git a/cmake/BundledCivetWeb.cmake b/cmake/BundledCivetWeb.cmake deleted file mode 100644 index 88e5b4d15..000000000 --- a/cmake/BundledCivetWeb.cmake +++ /dev/null @@ -1,107 +0,0 @@ -# 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_civetweb SOURCE_DIR BINARY_DIR) - message("Using bundled civetweb") - - # Define patch step - set(PC "${Patch_EXECUTABLE}" -p1 -i "${SOURCE_DIR}/thirdparty/civetweb/civetweb.patch") - - set(LIBDIR "lib") - # Define byproducts - if (WIN32) - set(SUFFIX "lib") - else() - set(PREFIX "lib") - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - set(SUFFIX "a") - endif() - - set(BYPRODUCTS - "${LIBDIR}/${PREFIX}civetweb.${SUFFIX}" - "${LIBDIR}/${PREFIX}civetweb-cpp.${SUFFIX}" - ) - - set(CIVETWEB_BIN_DIR "${BINARY_DIR}/thirdparty/civetweb-install/" CACHE STRING "" FORCE) - - FOREACH(BYPRODUCT ${BYPRODUCTS}) - LIST(APPEND CIVETWEB_LIBRARIES_LIST "${CIVETWEB_BIN_DIR}/${BYPRODUCT}") - ENDFOREACH(BYPRODUCT) - - # Set build options - set(CIVETWEB_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - -DCMAKE_INSTALL_PREFIX=${CIVETWEB_BIN_DIR} - -DCMAKE_PREFIX_PATH=${CIVETWEB_BIN_DIR} - -DCIVETWEB_ENABLE_SSL_DYNAMIC_LOADING=OFF - -DCIVETWEB_BUILD_TESTING=OFF - -DCIVETWEB_ENABLE_DUKTAPE=OFF - -DCIVETWEB_ENABLE_LUA=OFF - -DCIVETWEB_ENABLE_CXX=ON - -DCIVETWEB_ALLOW_WARNINGS=ON - -DCIVETWEB_ENABLE_ASAN=OFF) - if (OPENSSL_OFF) - list(APPEND CIVETWEB_CMAKE_ARGS -DCIVETWEB_ENABLE_SSL=OFF) - endif() - - append_third_party_passthrough_args(CIVETWEB_CMAKE_ARGS "${CIVETWEB_CMAKE_ARGS}") - - # Build project - ExternalProject_Add( - civetweb-external - URL "https://github.com/civetweb/civetweb/archive/v1.12.tar.gz" - URL_HASH "SHA256=8cab1e2ad8fb3e2e81fed0b2321a5afbd7269a644c44ed4c3607e0a212c6d9e1" - SOURCE_DIR "${BINARY_DIR}/thirdparty/civetweb-src" - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - CMAKE_ARGS ${CIVETWEB_CMAKE_ARGS} - PATCH_COMMAND ${PC} - BUILD_BYPRODUCTS "${CIVETWEB_LIBRARIES_LIST}" - EXCLUDE_FROM_ALL TRUE - ) - - # Set dependencies - if (NOT OPENSSL_OFF) - add_dependencies(civetweb-external OpenSSL::SSL OpenSSL::Crypto) - endif() - - # Set variables - set(CIVETWEB_FOUND "YES" CACHE STRING "" FORCE) - set(CIVETWEB_INCLUDE_DIR "${CIVETWEB_BIN_DIR}/include" CACHE STRING "" FORCE) - set(CIVETWEB_LIBRARIES "${CIVETWEB_BIN_DIR}/${LIBDIR}/${PREFIX}civetweb.${SUFFIX}" "${CIVETWEB_BIN_DIR}/${LIBDIR}/${PREFIX}civetweb-cpp.${SUFFIX}" CACHE STRING "" FORCE) - - # Set exported variables for FindPackage.cmake - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_CIVETWEB_INCLUDE_DIR=${CIVETWEB_INCLUDE_DIR}" CACHE STRING "" FORCE) - set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_CIVETWEB_LIBRARIES=${CIVETWEB_LIBRARIES}" CACHE STRING "" FORCE) - - # Create imported targets - file(MAKE_DIRECTORY ${CIVETWEB_INCLUDE_DIR}) - - add_library(CIVETWEB::c-library STATIC IMPORTED GLOBAL) - set_target_properties(CIVETWEB::c-library PROPERTIES IMPORTED_LOCATION "${CIVETWEB_BIN_DIR}/${LIBDIR}/${PREFIX}civetweb.${SUFFIX}") - set_property(TARGET CIVETWEB::c-library APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CIVETWEB_INCLUDE_DIR}) - add_dependencies(CIVETWEB::c-library civetweb-external) - if (NOT OPENSSL_OFF) - target_link_libraries(CIVETWEB::c-library INTERFACE OpenSSL::SSL OpenSSL::Crypto Threads::Threads) - endif() - - add_library(CIVETWEB::civetweb-cpp STATIC IMPORTED GLOBAL) - set_target_properties(CIVETWEB::civetweb-cpp PROPERTIES IMPORTED_LOCATION "${CIVETWEB_BIN_DIR}/${LIBDIR}/${PREFIX}civetweb-cpp.${SUFFIX}") - target_link_libraries(CIVETWEB::civetweb-cpp INTERFACE CIVETWEB::c-library) - add_dependencies(CIVETWEB::civetweb-cpp civetweb-external) - add_library(civetweb::civetweb-cpp ALIAS CIVETWEB::civetweb-cpp) -endfunction(use_bundled_civetweb) diff --git a/cmake/CivetWeb.cmake b/cmake/CivetWeb.cmake new file mode 100644 index 000000000..dc7cc4b19 --- /dev/null +++ b/cmake/CivetWeb.cmake @@ -0,0 +1,44 @@ +# 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. + +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) + +FetchContent_Declare(civetweb + GIT_REPOSITORY "https://github.com/civetweb/civetweb.git" + GIT_TAG "4447b6501d5c568b4c6c0940eac801ec690b2250" # commit containing fix for MSVC issue https://github.com/civetweb/civetweb/issues/1024 +) + +FetchContent_MakeAvailable(civetweb) + +add_dependencies(civetweb-c-library OpenSSL::Crypto OpenSSL::SSL) +add_dependencies(civetweb-cpp OpenSSL::Crypto OpenSSL::SSL) + +if (NOT WIN32) + target_compile_options(civetweb-c-library PRIVATE -Wno-error) + target_compile_options(civetweb-cpp PRIVATE -Wno-error) +endif() + +add_library(civetweb::c-library ALIAS civetweb-c-library) +add_library(civetweb::civetweb-cpp ALIAS civetweb-cpp) diff --git a/cmake/civetweb/dummy/FindCivetWeb.cmake b/cmake/civetweb/dummy/FindCivetWeb.cmake deleted file mode 100644 index 420db1132..000000000 --- a/cmake/civetweb/dummy/FindCivetWeb.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# 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 (NOT CIVETWEB_FOUND) - set(CIVETWEB_FOUND "YES" CACHE STRING "" FORCE) - set(CIVETWEB_INCLUDE_DIR "${EXPORT_CIVETWEB_INCLUDE_DIR}" CACHE STRING "" FORCE) - set(CIVETWEB_LIBRARIES "${EXPORT_CIVETWEB_LIBRARIES}" CACHE STRING "" FORCE) -endif() \ No newline at end of file diff --git a/extensions/civetweb/CMakeLists.txt b/extensions/civetweb/CMakeLists.txt index e7ac23da5..7c41ebb99 100644 --- a/extensions/civetweb/CMakeLists.txt +++ b/extensions/civetweb/CMakeLists.txt @@ -23,16 +23,16 @@ endif() include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) -include_directories(${CMAKE_SOURCE_DIR}/libminifi/include - ${CMAKE_SOURCE_DIR}/libminifi/include/core - ${CMAKE_SOURCE_DIR}/thirdparty/ - ./include) - file(GLOB SOURCES "processors/*.cpp" "protocols/*.cpp") add_library(minifi-civet-extensions SHARED ${SOURCES}) -target_link_libraries(minifi-civet-extensions ${LIBMINIFI} Threads::Threads) -target_link_libraries(minifi-civet-extensions CIVETWEB::c-library CIVETWEB::civetweb-cpp) +target_include_directories(minifi-civet-extensions BEFORE PUBLIC + ${CMAKE_SOURCE_DIR}/libminifi/include + ${CMAKE_SOURCE_DIR}/libminifi/include/core + ${CMAKE_SOURCE_DIR}/thirdparty/ + ${civetweb_SOURCE_DIR}/include + ./include) +target_link_libraries(minifi-civet-extensions ${LIBMINIFI} Threads::Threads civetweb::civetweb-cpp civetweb::c-library) register_extension(minifi-civet-extensions CIVETWEB CIVETWEB "This enables ListenHTTP" "extensions/civetweb/tests") register_extension_linter(minifi-civet-extensions-linter) diff --git a/extensions/openwsman/CMakeLists.txt b/extensions/openwsman/CMakeLists.txt index 980c17051..d6322600f 100644 --- a/extensions/openwsman/CMakeLists.txt +++ b/extensions/openwsman/CMakeLists.txt @@ -31,7 +31,7 @@ file(GLOB SOURCES "processors/*.cpp") add_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) +target_link_libraries(minifi-openwsman OpenWSMAN::libwsman civetweb::civetweb-cpp civetweb::c-library LibXml2::LibXml2) register_extension(minifi-openwsman "OPENWSMAN EXTENSIONS" OPENWSMAN-EXTENSIONS "This enables Openwsman support") register_extension_linter(minifi-openwsman-linter) diff --git a/thirdparty/civetweb/civetweb.patch b/thirdparty/civetweb/civetweb.patch deleted file mode 100644 index dc574e483..000000000 --- a/thirdparty/civetweb/civetweb.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/cmake/AddCCompilerFlag.cmake -+++ b/cmake/AddCCompilerFlag.cmake -@@ -24,9 +24,8 @@ function(add_c_compiler_flag FLAG) - string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG}) - string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) - string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) -- set(CMAKE_REQUIRED_FLAGS "${FLAG}") -- check_c_compiler_flag("" ${SANITIZED_FLAG}) -- if(${SANITIZED_FLAG}) -+ check_c_compiler_flag(${SANITIZED_FLAG} NO_DIAGNOSTICS_PRODUCED) -+ if(${NO_DIAGNOSTICS_PRODUCED}) - set(VARIANT ${ARGV1}) - if(ARGV1) - string(REGEX REPLACE "[^A-Za-z_0-9]" "_" VARIANT "${VARIANT}") -diff --git a/cmake/AddCXXCompilerFlag.cmake b/cmake/AddCXXCompilerFlag.cmake ---- a/cmake/AddCXXCompilerFlag.cmake -+++ b/cmake/AddCXXCompilerFlag.cmake -@@ -24,9 +24,8 @@ function(add_cxx_compiler_flag FLAG) - string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG}) - string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) - string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) -- set(CMAKE_REQUIRED_FLAGS "${FLAG}") -- check_cxx_compiler_flag("" ${SANITIZED_FLAG}) -- if(${SANITIZED_FLAG}) -+ check_cxx_compiler_flag(${SANITIZED_FLAG} NO_DIAGNOSTICS_PRODUCED) -+ if(${NO_DIAGNOSTICS_PRODUCED}) - set(VARIANT ${ARGV1}) - if(ARGV1) - string(REGEX REPLACE "[^A-Za-z_0-9]" "_" VARIANT "${VARIANT}") diff --git a/win_build_vs.bat b/win_build_vs.bat index c91d210fe..c1af2bfcf 100755 --- a/win_build_vs.bat +++ b/win_build_vs.bat @@ -73,12 +73,18 @@ for %%x in (%*) do ( if [%%~x] EQU [/NONFREEUCRT] set "redist=-DMSI_REDISTRIBUTE_UCRT_NONASL=ON" if [%%~x] EQU [/L] set build_linter=ON if [%%~x] EQU [/RO] set real_odbc=ON + if [%%~x] EQU [/NINJA] set generator="Ninja" ) mkdir %builddir% pushd %builddir%\ -cmake -G %generator% -A %build_platform% -DINSTALLER_MERGE_MODULES=%installer_merge_modules% -DTEST_CUSTOM_WEL_PROVIDER=%test_custom_wel_provider% -DENABLE_SQL=%build_SQL% -DUSE_REAL_ODBC_TEST_DRIVER=%real_odbc% -DCMAKE_BUILD_TYPE_INIT=%cmake_build_type% -DCMAKE_BUILD_TYPE=%cmake_build_type% -DWIN32=WIN32 -DENABLE_LIBRDKAFKA=%build_kafka% -DENABLE_JNI=%build_jni% -DOPENSSL_OFF=OFF -DENABLE_COAP=%build_coap% -DENABLE_AWS=%build_AWS% -DENABLE_PDH=%build_PDH% -DENABLE_AZURE=%build_azure% -D [...] +if [%generator%] EQU ["Ninja"] ( + set "buildcmd=ninja && copy bin\minifi.exe main\" +) else ( + set "buildcmd=msbuild /m nifi-minifi-cpp.sln /property:Configuration=%cmake_build_type% /property:Platform=%build_platform% && copy bin\%cmake_build_type%\minifi.exe main\" +) +cmake -G %generator% -DINSTALLER_MERGE_MODULES=%installer_merge_modules% -DTEST_CUSTOM_WEL_PROVIDER=%test_custom_wel_provider% -DENABLE_SQL=%build_SQL% -DUSE_REAL_ODBC_TEST_DRIVER=%real_odbc% -DCMAKE_BUILD_TYPE_INIT=%cmake_build_type% -DCMAKE_BUILD_TYPE=%cmake_build_type% -DWIN32=WIN32 -DENABLE_LIBRDKAFKA=%build_kafka% -DENABLE_JNI=%build_jni% -DOPENSSL_OFF=OFF -DENABLE_COAP=%build_coap% -DENABLE_AWS=%build_AWS% -DENABLE_PDH=%build_PDH% -DENABLE_AZURE=%build_azure% -DENABLE_SFTP=%build_S [...] IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL% if [%cpack%] EQU [ON] ( cpack -C %cmake_build_type%
