diff --git a/CMake/External_CppDB.cmake b/CMake/External_CppDB.cmake index f8b1001ff..7f5d7e6e6 100644 --- a/CMake/External_CppDB.cmake +++ b/CMake/External_CppDB.cmake @@ -26,9 +26,8 @@ ExternalProject_Add(CppDB -DCppDB_source=${fletch_BUILD_PREFIX}/src/CppDB -P ${fletch_SOURCE_DIR}/Patches/CppDB/Patch.cmake CMAKE_ARGS - -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX:PATH=${fletch_BUILD_INSTALL_PREFIX} + ${COMMON_CMAKE_ARGS} + -DDISABLE_SQLITE:BOOL=ON ${_CppDB_ARGS_PostgreSQL} ) diff --git a/CMake/External_libgeotiff.cmake b/CMake/External_libgeotiff.cmake index 764ff45a8..7d1611a92 100644 --- a/CMake/External_libgeotiff.cmake +++ b/CMake/External_libgeotiff.cmake @@ -121,6 +121,9 @@ ExternalProject_Add(libgeotiff URL_MD5 ${libgeotiff_md5} ${COMMON_EP_ARGS} ${COMMON_CMAKE_EP_ARGS} + PATCH_COMMAND ${CMAKE_COMMAND} + -Dlibgeotiff_source:PATH=${fletch_BUILD_PREFIX}/src/libgeotiff + -P ${fletch_SOURCE_DIR}/Patches/libgeotiff/Patch.cmake CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=${fletch_BUILD_INSTALL_PREFIX} diff --git a/CMake/External_yasm.cmake b/CMake/External_yasm.cmake index bd303ed46..d59bdc53f 100644 --- a/CMake/External_yasm.cmake +++ b/CMake/External_yasm.cmake @@ -30,6 +30,17 @@ if (fletch_ENABLE_CPython) ) endif() +set(yasm_patch ${fletch_SOURCE_DIR}/Patches/yasm) +if(EXISTS ${yasm_patch}) + set(yasm_PATCH_COMMAND ${CMAKE_COMMAND} + -Dyasm_patch:PATH=${yasm_patch} + -Dyasm_source:PATH=${fletch_BUILD_PREFIX}/src/yasm + -P ${yasm_patch}/Patch.cmake + ) +else() + set(yasm_PATCH_COMMAND "") +endif() + if (NOT _external_yasm_include) set(_external_yasm_include TRUE) ExternalProject_Add(yasm @@ -38,11 +49,12 @@ if (NOT _external_yasm_include) URL_MD5 ${yasm_md5} ${COMMON_EP_ARGS} ${COMMON_CMAKE_EP_ARGS} + PATCH_COMMAND ${yasm_PATCH_COMMAND} INSTALL_COMMAND "" CMAKE_ARGS + ${COMMON_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=${yasm_PYTHON_EXECUTABLE} - -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DBUILD_SHARED_LIBS=OFF ) diff --git a/CMakeLists.txt b/CMakeLists.txt index a55fdc445..59e54fe17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.3.0) +cmake_minimum_required(VERSION 3.10) project(fletch) # Policy to address @foo@ variable expansion @@ -365,6 +365,7 @@ set (COMMON_CMAKE_ARGS "-DCMAKE_CONFIGURATION_TYPES:STRING=${CMAKE_SS_CONF_TYPES}" -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} -DCMAKE_POLICY_DEFAULT_CMP0042=NEW + -DCMAKE_POLICY_VERSION_MINIMUM=3.10 -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DCMAKE_INSTALL_LIBDIR:PATH=lib @@ -378,6 +379,13 @@ set (COMMON_CMAKE_ARGS -DCUDAToolkit_NVCC_EXECUTABLE=${CUDA_NVCC_EXECUTABLE} ) +if (WIN32) + list(APPEND COMMON_CMAKE_ARGS + -DCMAKE_POLICY_DEFAULT_CMP0091=NEW + -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL + ) +endif() + # # Set up fletch targets # diff --git a/Patches/Boost/Common.cmake b/Patches/Boost/Common.cmake index ad144c008..0be647fa2 100644 --- a/Patches/Boost/Common.cmake +++ b/Patches/Boost/Common.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.3.0) +cmake_minimum_required(VERSION 3.10) # Retrieve the list of CMAKE variables include("${CMAKE_VARS_FILE}") diff --git a/Patches/CppDB/CMakeLists.txt b/Patches/CppDB/CMakeLists.txt index 65ebab668..6ab3e4b79 100644 --- a/Patches/CppDB/CMakeLists.txt +++ b/Patches/CppDB/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.10) project(cppdb) set(CPPDB_MAJOR 0) diff --git a/Patches/PostgreSQL/CMakeLists.txt b/Patches/PostgreSQL/CMakeLists.txt index 1756b7b48..027019fd3 100644 --- a/Patches/PostgreSQL/CMakeLists.txt +++ b/Patches/PostgreSQL/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.10) project(pq) set(postgresql_SOURCE_DIR ${pq_SOURCE_DIR}/../../..) diff --git a/Patches/PostgreSQL/Patch.cmake b/Patches/PostgreSQL/Patch.cmake index 08cb24d54..6631cb5e2 100644 --- a/Patches/PostgreSQL/Patch.cmake +++ b/Patches/PostgreSQL/Patch.cmake @@ -12,6 +12,8 @@ if(WIN32) file(WRITE ${PostgreSQL_source}/CMakeLists.txt " +cmake_minimum_required(VERSION 3.10) +project(PostgreSQL) add_subdirectory(src) ") file(WRITE ${PostgreSQL_source}/src/CMakeLists.txt " diff --git a/Patches/VTK/8.0/Patch.cmake b/Patches/VTK/8.0/Patch.cmake index 64bf29519..5db6f45a2 100644 --- a/Patches/VTK/8.0/Patch.cmake +++ b/Patches/VTK/8.0/Patch.cmake @@ -40,3 +40,8 @@ file(COPY ${VTK_PATCH_DIR}/Wrapping/PythonCore/vtkPythonArgs.cxx file(COPY ${VTK_PATCH_DIR}/CMake/VTKGenerateExportHeader.cmake DESTINATION ${VTK_SOURCE_DIR}/CMake/ ) + +# Fix for CMake 4 compatibility - CMP0022 policy cannot be set to OLD +file(COPY ${VTK_PATCH_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake + DESTINATION ${VTK_SOURCE_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/ +) diff --git a/Patches/VTK/8.0/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake b/Patches/VTK/8.0/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake new file mode 100644 index 000000000..a40ec25a5 --- /dev/null +++ b/Patches/VTK/8.0/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake @@ -0,0 +1,6 @@ +# Policies patched for CMake 4 compatibility +# CMP0022: INTERFACE_LINK_LIBRARIES defines the link interface +# CMake 4 no longer supports setting this to OLD, so we set it to NEW +if(POLICY CMP0022) + cmake_policy(SET CMP0022 NEW) +endif() diff --git a/Patches/VTK/8.2/Patch.cmake b/Patches/VTK/8.2/Patch.cmake index 30a8c90ca..20b6a1091 100644 --- a/Patches/VTK/8.2/Patch.cmake +++ b/Patches/VTK/8.2/Patch.cmake @@ -26,3 +26,8 @@ file(COPY ${VTK_PATCH_DIR}/ThirdParty/exodusII/vtkexodusII/src/ex_open_par.c file(COPY ${VTK_PATCH_DIR}/CMake/VTKGenerateExportHeader.cmake DESTINATION ${VTK_SOURCE_DIR}/CMake ) + +# Fix for CMake 4 compatibility - CMP0022 policy cannot be set to OLD +file(COPY ${VTK_PATCH_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake + DESTINATION ${VTK_SOURCE_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/ +) diff --git a/Patches/VTK/8.2/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake b/Patches/VTK/8.2/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake new file mode 100644 index 000000000..a40ec25a5 --- /dev/null +++ b/Patches/VTK/8.2/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake @@ -0,0 +1,6 @@ +# Policies patched for CMake 4 compatibility +# CMP0022: INTERFACE_LINK_LIBRARIES defines the link interface +# CMake 4 no longer supports setting this to OLD, so we set it to NEW +if(POLICY CMP0022) + cmake_policy(SET CMP0022 NEW) +endif() diff --git a/Patches/VTK/9.0/Patch.cmake b/Patches/VTK/9.0/Patch.cmake index e12d042f9..abda7fdba 100644 --- a/Patches/VTK/9.0/Patch.cmake +++ b/Patches/VTK/9.0/Patch.cmake @@ -21,3 +21,8 @@ file(COPY ${VTK_PATCH_DIR}/Rendering/Core/vtkColorTransferFunction.cxx file(COPY ${VTK_PATCH_DIR}/Filters/HyperTree/vtkHyperTreeGridThreshold.cxx DESTINATION ${VTK_SOURCE_DIR}/Filters/HyperTree/ ) + +# Fix for CMake 4 compatibility - CMP0022 policy cannot be set to OLD +file(COPY ${VTK_PATCH_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake + DESTINATION ${VTK_SOURCE_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/ +) diff --git a/Patches/VTK/9.0/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake b/Patches/VTK/9.0/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake new file mode 100644 index 000000000..a40ec25a5 --- /dev/null +++ b/Patches/VTK/9.0/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake @@ -0,0 +1,6 @@ +# Policies patched for CMake 4 compatibility +# CMP0022: INTERFACE_LINK_LIBRARIES defines the link interface +# CMake 4 no longer supports setting this to OLD, so we set it to NEW +if(POLICY CMP0022) + cmake_policy(SET CMP0022 NEW) +endif() diff --git a/Patches/VTK/9.5/Patch.cmake b/Patches/VTK/9.5/Patch.cmake new file mode 100644 index 000000000..d82f48d36 --- /dev/null +++ b/Patches/VTK/9.5/Patch.cmake @@ -0,0 +1,9 @@ +#+ +# This file is called as CMake -P script for the patch step of +# External_VTK.cmake for VTK 9.5 +#- + +# Fix for CMake 4 compatibility - CMP0022 policy cannot be set to OLD +file(COPY ${VTK_PATCH_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake + DESTINATION ${VTK_SOURCE_DIR}/ThirdParty/libproj4/vtklibproj4/cmake/ +) diff --git a/Patches/VTK/9.5/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake b/Patches/VTK/9.5/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake new file mode 100644 index 000000000..a40ec25a5 --- /dev/null +++ b/Patches/VTK/9.5/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake @@ -0,0 +1,6 @@ +# Policies patched for CMake 4 compatibility +# CMP0022: INTERFACE_LINK_LIBRARIES defines the link interface +# CMake 4 no longer supports setting this to OLD, so we set it to NEW +if(POLICY CMP0022) + cmake_policy(SET CMP0022 NEW) +endif() diff --git a/Patches/VXL/Patch.cmake b/Patches/VXL/Patch.cmake index cc5ba0396..035dabf7a 100644 --- a/Patches/VXL/Patch.cmake +++ b/Patches/VXL/Patch.cmake @@ -3,10 +3,17 @@ # External_VXL.cmake for VXL #- +message(STATUS "Patching VXL in ${VXL_SOURCE_DIR}") + file(COPY ${VXL_PATCH_DIR}/core/vbl/vbl_array_2d.h DESTINATION ${VXL_SOURCE_DIR}/core/vbl/ ) +# Fix CMake 4.x compatibility: cmake_minimum_required version too old +file(COPY ${VXL_PATCH_DIR}/config/cmake/config/vxl_shared_link_test/CMakeLists.txt + DESTINATION ${VXL_SOURCE_DIR}/config/cmake/config/vxl_shared_link_test/ +) + # fixes an issue with duplicate definition of lrintf() on Windows file(COPY ${VXL_PATCH_DIR}/v3p/openjpeg2/opj_includes.h DESTINATION ${VXL_SOURCE_DIR}/v3p/openjpeg2/ diff --git a/Patches/VXL/config/cmake/config/vxl_shared_link_test/CMakeLists.txt b/Patches/VXL/config/cmake/config/vxl_shared_link_test/CMakeLists.txt new file mode 100644 index 000000000..19f8ffedc --- /dev/null +++ b/Patches/VXL/config/cmake/config/vxl_shared_link_test/CMakeLists.txt @@ -0,0 +1,33 @@ +# +cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR) +# Set policies consistent with newer versions of cmake +# to ease integration with projects that require newer +# cmake versions. + +foreach(p + ## Only policies introduced after the cmake_minimum_required + ## version need to explicitly be set to NEW. + + ##----- Policies Introduced by CMake 3.10 + CMP0071 #: Let AUTOMOC and AUTOUIC process GENERATED files. + CMP0070 #: Define file(GENERATE) behavior for relative paths. + ##----- Policies Introduced by CMake 3.9 + CMP0069 #: INTERPROCEDURAL_OPTIMIZATION is enforced when enabled. + CMP0068 #: RPATH settings on macOS do not affect install_name. + ##----- Policies Introduced by CMake 3.8 + CMP0067 #: Honor language standard in try_compile() source-file signature. + ##----- Policies Introduced by CMake 3.7 + CMP0066 #: Honor per-config flags in try_compile() source-file signature. + ##----- Policies Introduced by CMake 3.4 + CMP0065 #: Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property. + CMP0064 #: Support new TEST if() operator. + ) + if(POLICY ${p}) + cmake_policy(SET ${p} NEW) + endif() +endforeach() +project(vxl_pic_compatible) + +add_library(cmTryCompileStaticLib STATIC static_src.cxx) +add_library(cmTryCompileSharedLib SHARED shared_src.cxx) +target_link_libraries(cmTryCompileSharedLib cmTryCompileStaticLib ${LINK_LIBRARIES}) diff --git a/Patches/libgeotiff/Patch.cmake b/Patches/libgeotiff/Patch.cmake new file mode 100644 index 000000000..7ce9ad81c --- /dev/null +++ b/Patches/libgeotiff/Patch.cmake @@ -0,0 +1,13 @@ +#+ +# This file is called as CMake -P script for the patch step of +# External_libgeotiff.cmake +#- + +message("Patching libgeotiff ${libgeotiff_source}") + +# Remove cmake_policy(SET CMP0022 OLD) and cmake_policy(SET CMP0042 OLD) +# which are no longer supported in newer CMake versions +file(READ ${libgeotiff_source}/CMakeLists.txt _cmakelists_content) +string(REPLACE "cmake_policy(SET CMP0022 OLD)" "" _cmakelists_content "${_cmakelists_content}") +string(REPLACE "cmake_policy(SET CMP0042 OLD)" "" _cmakelists_content "${_cmakelists_content}") +file(WRITE ${libgeotiff_source}/CMakeLists.txt "${_cmakelists_content}") diff --git a/Patches/libjpeg-turbo/Patch.cmake b/Patches/libjpeg-turbo/Patch.cmake index 2b4579f52..945078a46 100644 --- a/Patches/libjpeg-turbo/Patch.cmake +++ b/Patches/libjpeg-turbo/Patch.cmake @@ -11,6 +11,12 @@ if (WIN32) ${libjpeg-turbo_patch}/simd/CMakeLists.txt DESTINATION ${libjpeg-turbo_source}/simd/ ) + + # Remove cmake_policy(SET CMP0022 OLD) which is no longer supported + # in newer CMake versions + file(READ ${libjpeg-turbo_source}/CMakeLists.txt _cmakelists_content) + string(REPLACE "cmake_policy(SET CMP0022 OLD)" "" _cmakelists_content "${_cmakelists_content}") + file(WRITE ${libjpeg-turbo_source}/CMakeLists.txt "${_cmakelists_content}") endif() # Patch config.guess for arm boards. diff --git a/Patches/libsvm/CMakeLists.txt b/Patches/libsvm/CMakeLists.txt index d7aebe63e..59a2d5a26 100644 --- a/Patches/libsvm/CMakeLists.txt +++ b/Patches/libsvm/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.3) +cmake_minimum_required(VERSION 3.16.0) project(libsvm VERSION 3.11 LANGUAGES CXX) # Build shared library from svm.cpp diff --git a/Patches/x265/Patch.cmake b/Patches/x265/Patch.cmake index 02577e467..1c992bb64 100644 --- a/Patches/x265/Patch.cmake +++ b/Patches/x265/Patch.cmake @@ -4,3 +4,15 @@ configure_file( ${x265_source}/source/encoder/ COPYONLY ) + +# CMake 4 compatibility: Remove deprecated policy settings that cannot be set to OLD +# CMP0025 and CMP0054 can no longer be set to OLD in CMake 4.x +set(_x265_cmakelists "${x265_source}/source/CMakeLists.txt") +if(EXISTS "${_x265_cmakelists}") + file(READ "${_x265_cmakelists}" _x265_cmake_content) + # Remove cmake_policy(SET CMP0025 OLD) lines + string(REGEX REPLACE "cmake_policy\\([ \t]*SET[ \t]+CMP0025[ \t]+OLD[ \t]*\\)" "# cmake_policy(SET CMP0025 OLD) # Removed for CMake 4 compatibility" _x265_cmake_content "${_x265_cmake_content}") + # Remove cmake_policy(SET CMP0054 OLD) lines + string(REGEX REPLACE "cmake_policy\\([ \t]*SET[ \t]+CMP0054[ \t]+OLD[ \t]*\\)" "# cmake_policy(SET CMP0054 OLD) # Removed for CMake 4 compatibility" _x265_cmake_content "${_x265_cmake_content}") + file(WRITE "${_x265_cmakelists}" "${_x265_cmake_content}") +endif() diff --git a/Patches/yasm/Patch.cmake b/Patches/yasm/Patch.cmake new file mode 100644 index 000000000..a436c3de0 --- /dev/null +++ b/Patches/yasm/Patch.cmake @@ -0,0 +1,61 @@ +# CMake 4 compatibility patch for yasm +# Updates cmake_minimum_required to VERSION 3.10 (minimum required by CMake 4) +# Fixes LOCATION property errors (CMP0026) by using generator expressions + +set(_yasm_cmakelists "${yasm_source}/CMakeLists.txt") +if(EXISTS "${_yasm_cmakelists}") + file(READ "${_yasm_cmakelists}" _yasm_cmake_content) + # Replace cmake_minimum_required with versions < 3.10 to 3.10 (lowercase) + string(REGEX REPLACE + "cmake_minimum_required[ \t]*\\([ \t]*VERSION[ \t]+([0-2]\\.[0-9]+|3\\.[0-9])[ \t]*\\)" + "cmake_minimum_required(VERSION 3.10)" + _yasm_cmake_content "${_yasm_cmake_content}") + # Replace CMAKE_MINIMUM_REQUIRED with versions < 3.10 to 3.10 (uppercase) + string(REGEX REPLACE + "CMAKE_MINIMUM_REQUIRED[ \t]*\\([ \t]*VERSION[ \t]+([0-2]\\.[0-9]+|3\\.[0-9])[ \t]*\\)" + "cmake_minimum_required(VERSION 3.10)" + _yasm_cmake_content "${_yasm_cmake_content}") + file(WRITE "${_yasm_cmakelists}" "${_yasm_cmake_content}") +endif() + +# Fix YasmMacros.cmake - replace get_target_property LOCATION with generator expressions +# This fixes CMake policy CMP0026 violations +set(_yasm_macros "${yasm_source}/cmake/modules/YasmMacros.cmake") +if(EXISTS "${_yasm_macros}") + file(READ "${_yasm_macros}" _macros_content) + + # Fix YASM_GENPERF macro - handle both GET_TARGET_PROPERTY and get_target_property + # Match: GET_TARGET_PROPERTY(GENPERF_EXE genperf LOCATION) or similar variable names + string(REGEX REPLACE + "[Gg][Ee][Tt]_[Tt][Aa][Rr][Gg][Ee][Tt]_[Pp][Rr][Oo][Pp][Ee][Rr][Tt][Yy][ \t]*\\([ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]+genperf[ \t]+LOCATION[ \t]*\\)" + "set(\\1 \"$\")" + _macros_content "${_macros_content}") + + # Fix YASM_RE2C macro + string(REGEX REPLACE + "[Gg][Ee][Tt]_[Tt][Aa][Rr][Gg][Ee][Tt]_[Pp][Rr][Oo][Pp][Ee][Rr][Tt][Yy][ \t]*\\([ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]+re2c[ \t]+LOCATION[ \t]*\\)" + "set(\\1 \"$\")" + _macros_content "${_macros_content}") + + # Fix YASM_GENMACRO macro + string(REGEX REPLACE + "[Gg][Ee][Tt]_[Tt][Aa][Rr][Gg][Ee][Tt]_[Pp][Rr][Oo][Pp][Ee][Rr][Tt][Yy][ \t]*\\([ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]+genmacro[ \t]+LOCATION[ \t]*\\)" + "set(\\1 \"$\")" + _macros_content "${_macros_content}") + + file(WRITE "${_yasm_macros}" "${_macros_content}") +endif() + +# Fix modules/preprocs/nasm/CMakeLists.txt - genversion LOCATION property +set(_nasm_preproc "${yasm_source}/modules/preprocs/nasm/CMakeLists.txt") +if(EXISTS "${_nasm_preproc}") + file(READ "${_nasm_preproc}" _nasm_content) + + # Fix genversion LOCATION property - handle both GET_TARGET_PROPERTY and get_target_property + string(REGEX REPLACE + "[Gg][Ee][Tt]_[Tt][Aa][Rr][Gg][Ee][Tt]_[Pp][Rr][Oo][Pp][Ee][Rr][Tt][Yy][ \t]*\\([ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]+genversion[ \t]+LOCATION[ \t]*\\)" + "set(\\1 \"$\")" + _nasm_content "${_nasm_content}") + + file(WRITE "${_nasm_preproc}" "${_nasm_content}") +endif()