diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeASM_NASMInformation.cmake | 11 | ||||
-rw-r--r-- | Modules/CTestTargets.cmake | 30 | ||||
-rw-r--r-- | Modules/CheckLibraryExists.lists.in | 8 | ||||
-rw-r--r-- | Modules/DartConfiguration.tcl.in | 3 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 195 | ||||
-rw-r--r-- | Modules/ExternalProject/download.cmake.in | 1 | ||||
-rw-r--r-- | Modules/FetchContent.cmake | 1 | ||||
-rw-r--r-- | Modules/FindCUDA.cmake | 23 | ||||
-rw-r--r-- | Modules/FindCUDAToolkit.cmake | 27 | ||||
-rw-r--r-- | Modules/FindMatlab.cmake | 295 | ||||
-rw-r--r-- | Modules/GoogleTest.cmake | 45 | ||||
-rw-r--r-- | Modules/UseJava/javaTargets.cmake.in | 2 |
12 files changed, 387 insertions, 254 deletions
diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake index a72575b..898b823 100644 --- a/Modules/CMakeASM_NASMInformation.cmake +++ b/Modules/CMakeASM_NASMInformation.cmake @@ -12,6 +12,8 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) set(CMAKE_ASM_NASM_OBJECT_FORMAT win64) elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8) set(CMAKE_ASM_NASM_OBJECT_FORMAT win64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(CMAKE_ASM_NASM_OBJECT_FORMAT win64) else() set(CMAKE_ASM_NASM_OBJECT_FORMAT win32) endif() @@ -20,6 +22,8 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8) set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) else() set(CMAKE_ASM_NASM_OBJECT_FORMAT macho) endif() @@ -28,6 +32,8 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8) set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) else() set(CMAKE_ASM_NASM_OBJECT_FORMAT elf) endif() @@ -38,6 +44,11 @@ if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT) set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") endif() +if(NOT CMAKE_ASM_NASM_LINK_EXECUTABLE) + set(CMAKE_ASM_NASM_LINK_EXECUTABLE + "<CMAKE_LINKER> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") +endif() + if(CMAKE_ASM_NASM_COMPILER_ID STREQUAL "NASM") set(CMAKE_DEPFILE_FLAGS_ASM_NASM "-MD <DEP_FILE> -MT <DEP_TARGET>") diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake index 99ef8e5..f672410 100644 --- a/Modules/CTestTargets.cmake +++ b/Modules/CTestTargets.cmake @@ -20,15 +20,27 @@ mark_as_advanced(CMAKE_CTEST_COMMAND) # Use CTest # configure files -if(CTEST_NEW_FORMAT) - configure_file( - ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in - ${PROJECT_BINARY_DIR}/CTestConfiguration.ini ) -else() - configure_file( - ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in - ${PROJECT_BINARY_DIR}/DartConfiguration.tcl ) -endif() +block() + if(NOT DEFINED CTEST_TLS_VERSION) + if(DEFINED CMAKE_TLS_VERSION) + set(CTEST_TLS_VERSION "${CMAKE_TLS_VERSION}") + elseif(DEFINED ENV{CMAKE_TLS_VERSION}) + set(CTEST_TLS_VERSION "$ENV{CMAKE_TLS_VERSION}") + endif() + endif() + if(NOT DEFINED CTEST_TLS_VERIFY AND DEFINED CMAKE_TLS_VERIFY) + set(CTEST_TLS_VERIFY "${CMAKE_TLS_VERIFY}") + endif() + if(CTEST_NEW_FORMAT) + configure_file( + ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in + ${PROJECT_BINARY_DIR}/CTestConfiguration.ini ) + else() + configure_file( + ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in + ${PROJECT_BINARY_DIR}/DartConfiguration.tcl ) + endif() +endblock() # # Section 3: diff --git a/Modules/CheckLibraryExists.lists.in b/Modules/CheckLibraryExists.lists.in deleted file mode 100644 index 741b87d..0000000 --- a/Modules/CheckLibraryExists.lists.in +++ /dev/null @@ -1,8 +0,0 @@ -PROJECT(CHECK_LIBRARY_EXISTS) - - -ADD_DEFINITIONS(-DCHECK_FUNCTION_EXISTS=${CHECK_LIBRARY_EXISTS_FUNCTION}) -LINK_DIRECTORIES(${CHECK_LIBRARY_EXISTS_LOCATION}) -ADD_EXECUTABLE(CheckLibraryExists ${CHECK_LIBRARY_EXISTS_SOURCE}) -TARGET_LINK_LIBRARIES(CheckLibraryExists ${CHECK_LIBRARY_EXISTS_LIBRARY}) - diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index afa36f7..67d9f8f 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -95,6 +95,9 @@ TimeOut: @DART_TESTING_TIMEOUT@ # so would cause the system load to exceed this value. TestLoad: @CTEST_TEST_LOAD@ +TLSVerify: @CTEST_TLS_VERIFY@ +TLSVersion: @CTEST_TLS_VERSION@ + UseLaunchers: @CTEST_USE_LAUNCHERS@ CurlOptions: @CTEST_CURL_OPTIONS@ # warning, if you add new options here that have to do with submit, diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 8b10135..5644cf5 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -225,10 +225,25 @@ URL Provides an arbitrary list of HTTP headers for the download operation. This can be useful for accessing content in systems like AWS, etc. +``TLS_VERSION <min>`` + .. versionadded:: 3.30 + + Specify minimum TLS version for ``https://`` URLs. If this option is + not provided, the value of the :variable:`CMAKE_TLS_VERSION` variable + or the :envvar:`CMAKE_TLS_VERSION` environment variable will be used + instead (see :command:`file(DOWNLOAD)`). + + This option also applies to ``git clone`` invocations, although the + default behavior is different. If none of the ``TLS_VERSION`` option, + :variable:`CMAKE_TLS_VERSION` variable, or :envvar:`CMAKE_TLS_VERSION` + environment variable is specified, the behavior will be determined by + git's default or a ``http.sslVersion`` git config option the user may + have set at a global level. + ``TLS_VERIFY <bool>`` Specifies whether certificate verification should be performed for - https URLs. If this option is not provided, the default behavior is - determined by the :variable:`CMAKE_TLS_VERIFY` variable (see + ``https://`` URLs. If this option is not provided, the default behavior + is determined by the :variable:`CMAKE_TLS_VERIFY` variable (see :command:`file(DOWNLOAD)`). If that is also not set, certificate verification will not be performed. In situations where ``URL_HASH`` cannot be provided, this option can be an alternative verification @@ -236,11 +251,10 @@ URL .. versionchanged:: 3.6 This option also applies to ``git clone`` invocations, although the - default behavior is different. If ``TLS_VERIFY`` is not given and - :variable:`CMAKE_TLS_VERIFY` is not set, the behavior will be - determined by git's defaults. Normally, the ``sslVerify`` git - config setting defaults to true, but the user may have overridden - this at a global level. + default behavior is different. If neither the ``TLS_VERIFY`` option + or :variable:`CMAKE_TLS_VERIFY` variable is specified, the behavior + will be determined by git's default (true) or a ``http.sslVerify`` + git config option the user may have set at a global level. ``TLS_CAINFO <file>`` Specify a custom certificate authority file to use if ``TLS_VERIFY`` @@ -1346,6 +1360,59 @@ define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED) define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED) define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED) +function(_ep_get_tls_version name tls_version_var) + set(tls_version_regex "^1\\.[0-3]$") + get_property(tls_version TARGET ${name} PROPERTY _EP_TLS_VERSION) + if(NOT "x${tls_version}" STREQUAL "x") + if(NOT tls_version MATCHES "${tls_version_regex}") + message(FATAL_ERROR "TLS_VERSION '${tls_version}' not known") + endif() + elseif(NOT "x${CMAKE_TLS_VERSION}" STREQUAL "x") + set(tls_version "${CMAKE_TLS_VERSION}") + if(NOT tls_version MATCHES "${tls_version_regex}") + message(FATAL_ERROR "CMAKE_TLS_VERSION '${tls_version}' not known") + endif() + elseif(NOT "x$ENV{CMAKE_TLS_VERSION}" STREQUAL "x") + set(tls_version "$ENV{CMAKE_TLS_VERSION}") + if(NOT tls_version MATCHES "${tls_version_regex}") + message(FATAL_ERROR "ENV{CMAKE_TLS_VERSION} '${tls_version}' not known") + endif() + endif() + set("${tls_version_var}" "${tls_version}" PARENT_SCOPE) +endfunction() + +function(_ep_get_tls_verify name tls_verify_var) + get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) + if("x${tls_verify}" STREQUAL "x" AND DEFINED CMAKE_TLS_VERIFY) + set(tls_verify "${CMAKE_TLS_VERIFY}") + endif() + set("${tls_verify_var}" "${tls_verify}" PARENT_SCOPE) +endfunction() + +function(_ep_get_tls_cainfo name tls_cainfo_var) + get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) + if("x${tls_cainfo}" STREQUAL "x" AND DEFINED CMAKE_TLS_CAINFO) + set(tls_cainfo "${CMAKE_TLS_CAINFO}") + endif() + set("${tls_cainfo_var}" "${tls_cainfo}" PARENT_SCOPE) +endfunction() + +function(_ep_get_netrc name netrc_var) + get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) + if("x${netrc}" STREQUAL "x" AND DEFINED CMAKE_NETRC) + set(netrc "${CMAKE_NETRC}") + endif() + set("${netrc_var}" "${netrc}" PARENT_SCOPE) +endfunction() + +function(_ep_get_netrc_file name netrc_file_var) + get_property(netrc_file TARGET ${name} PROPERTY _EP_NETRC_FILE) + if("x${netrc_file}" STREQUAL "x" AND DEFINED CMAKE_NETRC_FILE) + set(netrc_file "${CMAKE_NETRC_FILE}") + endif() + set("${netrc_file_var}" "${netrc_file}" PARENT_SCOPE) +endfunction() + function(_ep_write_gitclone_script script_filename source_dir @@ -1363,6 +1430,7 @@ function(_ep_write_gitclone_script work_dir gitclone_infofile gitclone_stampfile + tls_version tls_verify ) @@ -1379,8 +1447,6 @@ function(_ep_write_gitclone_script message(FATAL_ERROR "Tag for git checkout should not be empty.") endif() - set(git_submodules_config_options "") - if(GIT_VERSION_STRING VERSION_LESS 2.20 OR 2.21 VERSION_LESS_EQUAL GIT_VERSION_STRING) set(git_clone_options "--no-checkout") @@ -1403,21 +1469,27 @@ function(_ep_write_gitclone_script if(NOT ${git_remote_name} STREQUAL "origin") list(APPEND git_clone_options --origin \"${git_remote_name}\") endif() + + # The clone config option is sticky, it will apply to all subsequent git + # update operations. The submodules config option is not sticky, because + # git doesn't provide any way to do that. Thus, we will have to pass the + # same config option in the update step too for submodules, but not for + # the main git repo. + set(git_submodules_config_options "") + if(NOT "x${tls_version}" STREQUAL "x") + list(APPEND git_clone_options -c http.sslVersion=tlsv${tls_version}) + list(APPEND git_submodules_config_options -c http.sslVersion=tlsv${tls_version}) + endif() if(NOT "x${tls_verify}" STREQUAL "x") - # The clone config option is sticky, it will apply to all subsequent git - # update operations. The submodules config option is not sticky, because - # git doesn't provide any way to do that. Thus, we will have to pass the - # same config option in the update step too for submodules, but not for - # the main git repo. if(tls_verify) # Default git behavior is "true", but the user might have changed the # global default to "false". Since TLS_VERIFY was given, ensure we honor # the specified setting regardless of what the global default might be. list(APPEND git_clone_options -c http.sslVerify=true) - set(git_submodules_config_options -c http.sslVerify=true) + list(APPEND git_submodules_config_options -c http.sslVerify=true) else() list(APPEND git_clone_options -c http.sslVerify=false) - set(git_submodules_config_options -c http.sslVerify=false) + list(APPEND git_submodules_config_options -c http.sslVerify=false) endif() endif() @@ -1465,6 +1537,7 @@ function(_ep_write_gitupdate_script git_repository work_dir git_update_strategy + tls_version tls_verify ) @@ -1480,19 +1553,22 @@ function(_ep_write_gitupdate_script list(APPEND git_stash_save_options --all) endif() + # The submodules config option is not sticky, git doesn't provide any way + # to do that. We have to pass this config option for the update step too. + # We don't need to set it for the non-submodule update because it gets + # recorded as part of the clone operation in a sticky manner. set(git_submodules_config_options "") + if(NOT "x${tls_version}" STREQUAL "x") + list(APPEND git_submodules_config_options -c http.sslVersion=tlsv${tls_version}) + endif() if(NOT "x${tls_verify}" STREQUAL "x") - # The submodules config option is not sticky, git doesn't provide any way - # to do that. We have to pass this config option for the update step too. - # We don't need to set it for the non-submodule update because it gets - # recorded as part of the clone operation in a sticky manner. if(tls_verify) # Default git behavior is "true", but the user might have changed the # global default to "false". Since TLS_VERIFY was given, ensure we honor # the specified setting regardless of what the global default might be. - set(git_submodules_config_options -c http.sslVerify=true) + list(APPEND git_submodules_config_options -c http.sslVerify=true) else() - set(git_submodules_config_options -c http.sslVerify=false) + list(APPEND git_submodules_config_options -c http.sslVerify=false) endif() endif() @@ -1511,6 +1587,7 @@ function(_ep_write_downloadfile_script inactivity_timeout no_progress hash + tls_version tls_verify tls_cainfo userpwd @@ -1563,46 +1640,28 @@ function(_ep_write_downloadfile_script set(EXPECT_VALUE "") endif() - set(TLS_VERIFY_CODE "") - set(TLS_CAINFO_CODE "") - set(NETRC_CODE "") - set(NETRC_FILE_CODE "") - - # check for curl globals in the project - if(DEFINED CMAKE_TLS_VERIFY) - set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})") - endif() - if(DEFINED CMAKE_TLS_CAINFO) - set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")") - endif() - if(DEFINED CMAKE_NETRC) - set(NETRC_CODE "set(CMAKE_NETRC \"${CMAKE_NETRC}\")") - endif() - if(DEFINED CMAKE_NETRC_FILE) - set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${CMAKE_NETRC_FILE}\")") + set(TLS_VERSION_CODE "") + if(NOT "x${tls_version}" STREQUAL "x") + set(TLS_VERSION_CODE "set(CMAKE_TLS_VERSION \"${tls_version}\")") endif() - # now check for curl locals so that the local values - # will override the globals - - # check for tls_verify argument - string(LENGTH "${tls_verify}" tls_verify_len) - if(tls_verify_len GREATER 0) - set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${tls_verify})") + set(TLS_VERIFY_CODE "") + if(NOT "x${tls_verify}" STREQUAL "x") + set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY \"${tls_verify}\")") endif() - # check for tls_cainfo argument - string(LENGTH "${tls_cainfo}" tls_cainfo_len) - if(tls_cainfo_len GREATER 0) + + set(TLS_CAINFO_CODE "") + if(NOT "x${tls_cainfo}" STREQUAL "x") set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")") endif() - # check for netrc argument - string(LENGTH "${netrc}" netrc_len) - if(netrc_len GREATER 0) + + set(NETRC_CODE "") + if(NOT "x${netrc}" STREQUAL "x") set(NETRC_CODE "set(CMAKE_NETRC \"${netrc}\")") endif() - # check for netrc_file argument - string(LENGTH "${netrc_file}" netrc_file_len) - if(netrc_file_len GREATER 0) + + set(NETRC_FILE_CODE "") + if(NOT "x${netrc_file}" STREQUAL "x") set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${netrc_file}\")") endif() @@ -1622,6 +1681,7 @@ function(_ep_write_downloadfile_script endif() # Used variables: + # * TLS_VERSION_CODE # * TLS_VERIFY_CODE # * TLS_CAINFO_CODE # * ALGO @@ -2959,10 +3019,8 @@ function(_ep_add_download_command name) set(git_remote_name "origin") endif() - get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) - if("x${tls_verify}" STREQUAL "x" AND DEFINED CMAKE_TLS_VERIFY) - set(tls_verify "${CMAKE_TLS_VERIFY}") - endif() + _ep_get_tls_version(${name} tls_version) + _ep_get_tls_verify(${name} tls_verify) get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW) get_property(git_progress TARGET ${name} PROPERTY _EP_GIT_PROGRESS) get_property(git_config TARGET ${name} PROPERTY _EP_GIT_CONFIG) @@ -3012,6 +3070,7 @@ CMP0097=${_EP_CMP0097} ${work_dir} ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt + "${tls_version}" "${tls_verify}" ) set(comment "Performing download step (git clone) for '${name}'") @@ -3146,10 +3205,11 @@ hash=${hash} TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS ) - get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) - get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) - get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) - get_property(netrc_file TARGET ${name} PROPERTY _EP_NETRC_FILE) + _ep_get_tls_version(${name} tls_version) + _ep_get_tls_verify(${name} tls_verify) + _ep_get_tls_cainfo(${name} tls_cainfo) + _ep_get_netrc(${name} netrc) + _ep_get_netrc_file(${name} netrc_file) get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME) get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) @@ -3162,6 +3222,7 @@ hash=${hash} "${inactivity_timeout}" "${no_progress}" "${hash}" + "${tls_version}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" @@ -3472,10 +3533,8 @@ function(_ep_add_update_command name) _ep_get_git_submodules_recurse(git_submodules_recurse) - get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) - if("x${tls_verify}" STREQUAL "x" AND DEFINED CMAKE_TLS_VERIFY) - set(tls_verify "${CMAKE_TLS_VERIFY}") - endif() + _ep_get_tls_version(${name} tls_version) + _ep_get_tls_verify(${name} tls_verify) set(update_script "${tmp_dir}/${name}-gitupdate.cmake") list(APPEND file_deps ${update_script}) @@ -3490,6 +3549,7 @@ function(_ep_add_update_command name) "${git_repository}" "${work_dir}" "${git_update_strategy}" + "${tls_version}" "${tls_verify}" ) set(cmd ${CMAKE_COMMAND} -Dcan_fetch=YES -P ${update_script}) @@ -4263,6 +4323,7 @@ function(ExternalProject_Add name) HTTP_USERNAME HTTP_PASSWORD HTTP_HEADER + TLS_VERSION # Also used for git clone operations TLS_VERIFY # Also used for git clone operations TLS_CAINFO NETRC diff --git a/Modules/ExternalProject/download.cmake.in b/Modules/ExternalProject/download.cmake.in index 0ad0dd3..2158ffd 100644 --- a/Modules/ExternalProject/download.cmake.in +++ b/Modules/ExternalProject/download.cmake.in @@ -111,6 +111,7 @@ foreach(i RANGE ${retry_number}) if(NOT url IN_LIST skip_url_list) message(STATUS "Using src='${url}'") + @TLS_VERSION_CODE@ @TLS_VERIFY_CODE@ @TLS_CAINFO_CODE@ @NETRC_CODE@ diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index fae51cf..3c01c2a 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -1650,6 +1650,7 @@ ExternalProject_Add_Step(${contentName}-populate copyfile set(__FETCHCONTENT_CACHED_INFO "") set(__passthrough_vars CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY + CMAKE_TLS_VERSION CMAKE_TLS_VERIFY CMAKE_TLS_CAINFO CMAKE_NETRC diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 203a473..130b239 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -891,26 +891,29 @@ if(CMAKE_CROSSCOMPILING) SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") # Support for NVPACK - set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + set (CUDA_TOOLKIT_TARGET_NAMES "armv7-linux-androideabi") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") # Support for arm cross compilation - set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + set(CUDA_TOOLKIT_TARGET_NAMES "armv7-linux-gnueabihf") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") # Support for aarch64 cross compilation if (ANDROID_ARCH_NAME STREQUAL "arm64") - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + set(CUDA_TOOLKIT_TARGET_NAMES "aarch64-linux-androideabi") elseif (CMAKE_SYSTEM_NAME STREQUAL "QNX") - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-qnx") + set(CUDA_TOOLKIT_TARGET_NAMES "aarch64-qnx") else() - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + set(CUDA_TOOLKIT_TARGET_NAMES "aarch64-linux" "sbsa-linux") endif (ANDROID_ARCH_NAME STREQUAL "arm64") endif() - if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") - set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") - SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) - mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) - endif() + foreach(CUDA_TOOLKIT_TARGET_NAME IN LISTS CUDA_TOOLKIT_TARGET_NAMES) + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT} CACHE PATH "Toolkit location." FORCE) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + break() + endif() + endforeach() # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 2229de6..7543f16 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -123,6 +123,8 @@ of the following libraries that are part of the CUDAToolkit: - :ref:`nvidia-ML<cuda_toolkit_nvML>` - :ref:`nvPTX Compiler<cuda_toolkit_nvptx>` - :ref:`nvRTC<cuda_toolkit_nvRTC>` +- :ref:`nvJitLink<cuda_toolkit_nvJitLink>` +- :ref:`nvFatBin<cuda_toolkit_nvfatbin>` - :ref:`nvToolsExt<cuda_toolkit_nvToolsExt>` - :ref:`nvtx3<cuda_toolkit_nvtx3>` - :ref:`OpenCL<cuda_toolkit_opencl>` @@ -418,6 +420,20 @@ Targets Created: - ``CUDA::nvJitLink`` starting in CUDA 12.0 - ``CUDA::nvJitLink_static`` starting in CUDA 12.0 +.. _`cuda_toolkit_nvfatbin`: + +nvFatBin +""""""""" + +.. versionadded:: 3.30 + +The `nvFatBin <https://docs.nvidia.com/cuda/>`_ (Runtime fatbin creation) library. + +Targets Created: + +- ``CUDA::nvfatbin`` starting in CUDA 12.4 +- ``CUDA::nvfatbin_static`` starting in CUDA 12.4 + .. _`cuda_toolkit_nvml`: nvidia-ML @@ -1168,6 +1184,11 @@ if(CUDAToolkit_FOUND) _CUDAToolkit_find_and_add_import_lib(nvJitLink_static DEPS cudart_static_deps) endif() + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.4.0) + _CUDAToolkit_find_and_add_import_lib(nvfatbin DEPS cudart_static_deps) + _CUDAToolkit_find_and_add_import_lib(nvfatbin_static DEPS cudart_static_deps) + endif() + _CUDAToolkit_find_and_add_import_lib(culibos) # it's a static library foreach (cuda_lib cublasLt cufft nvjpeg) _CUDAToolkit_find_and_add_import_lib(${cuda_lib}) @@ -1281,17 +1302,17 @@ if(CUDAToolkit_FOUND) if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.1.0) if(NOT TARGET CUDA::nvptxcompiler_static) - _CUDAToolkit_find_and_add_import_lib(nvptxcompiler_static DEPS cuda_driver) + _CUDAToolkit_find_and_add_import_lib(nvptxcompiler_static) if(TARGET CUDA::nvptxcompiler_static) target_link_libraries(CUDA::nvptxcompiler_static INTERFACE CUDA::cudart_static_deps) endif() endif() endif() - _CUDAToolkit_find_and_add_import_lib(nvrtc_builtins ALT nvrtc-builtins DEPS cuda_driver) + _CUDAToolkit_find_and_add_import_lib(nvrtc_builtins ALT nvrtc-builtins) _CUDAToolkit_find_and_add_import_lib(nvrtc DEPS nvrtc_builtins nvJitLink) if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.5.0) - _CUDAToolkit_find_and_add_import_lib(nvrtc_builtins_static ALT nvrtc-builtins_static DEPS cuda_driver) + _CUDAToolkit_find_and_add_import_lib(nvrtc_builtins_static ALT nvrtc-builtins_static) if(NOT TARGET CUDA::nvrtc_static) _CUDAToolkit_find_and_add_import_lib(nvrtc_static DEPS nvrtc_builtins_static nvptxcompiler_static nvJitLink_static) if(TARGET CUDA::nvrtc_static AND WIN32 AND NOT (BORLAND OR MINGW OR CYGWIN)) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 6c80506..0339e99 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -42,6 +42,13 @@ The module supports the following components: Removed the ``MX_LIBRARY``, ``ENGINE_LIBRARY`` and ``DATAARRAY_LIBRARY`` components. These libraries are found unconditionally. +.. versionadded:: 3.30 + Added support for specifying a version range to :command:`find_package` and + added support for specifying ``REGISTRY_VIEW`` to :command:`find_package`, + :command:`matlab_extract_all_installed_versions_from_registry` and + :command:`matlab_get_all_valid_matlab_roots_from_registry`. The default + behavior remained unchanged, by using the registry view ``TARGET``. + .. note:: The version given to the :command:`find_package` directive is the Matlab @@ -56,7 +63,8 @@ the path of the desired Matlab version. Otherwise, the behavior is platform specific: * Windows: The installed versions of Matlab/MCR are retrieved from the - Windows registry + Windows registry. The ``REGISTRY_VIEW`` argument may optionally be specified + to manually control whether 32bit or 64bit versions shall be searched for. * macOS: The installed versions of Matlab/MCR are given by the MATLAB default installation paths in ``/Application``. If no such application is found, it falls back to the one that might be accessible from the ``PATH``. @@ -287,9 +295,12 @@ cmake_policy(SET CMP0057 NEW) # if IN_LIST set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}") include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -include(CheckCXXCompilerFlag) -include(CheckCCompilerFlag) +if(NOT WIN32 AND NOT APPLE AND NOT Threads_FOUND) + # MEX files use pthread if available + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) +endif() # The currently supported versions. Other version can be added by the user by # providing MATLAB_ADDITIONAL_VERSIONS @@ -437,20 +448,33 @@ endmacro() #[=======================================================================[.rst: .. command:: matlab_extract_all_installed_versions_from_registry - .. code-block:: cmake + This function parses the Windows registry and finds the Matlab versions that + are installed. The found versions are stored in ``matlab_versions``. + + .. signature:: + matlab_extract_all_installed_versions_from_registry(matlab_versions + [REGISTRY_VIEW view]) + + .. versionadded:: 3.30 + * Output: ``matlab_versions`` is a list of all the versions of Matlab found + * Input: ``REGISTRY_VIEW`` Optional registry view to use for registry + interaction. The argument is passed (or omitted) to + :command:`cmake_host_system_information` without further checks or + modification. + + .. signature:: matlab_extract_all_installed_versions_from_registry(win64 matlab_versions) - * Input: ``win64`` is a boolean to search for the 64 bit version of Matlab - * Output: ``matlab_versions`` is a list of all the versions of Matlab found + * Input: ``win64`` is a boolean to search for the 64 bit version of + Matlab. Set to ``ON`` to use the 64bit registry view or ``OFF`` to use the + 32bit registry view. If finer control is needed, see signature above. + * Output: ``matlab_versions`` is a list of all the versions of Matlab found - This function parses the Windows registry and founds the Matlab versions that - are installed. The found versions are returned in `matlab_versions`. - Set `win64` to `TRUE` if the 64 bit version of Matlab should be looked for The returned list contains all versions under - ``HKLM\\SOFTWARE\\Mathworks\\MATLAB``, - ``HKLM\\SOFTWARE\\Mathworks\\MATLAB Runtime`` and - ``HKLM\\SOFTWARE\\Mathworks\\MATLAB Compiler Runtime`` or an empty list in + ``HKLM\SOFTWARE\Mathworks\MATLAB``, + ``HKLM\SOFTWARE\Mathworks\MATLAB Runtime`` and + ``HKLM\SOFTWARE\Mathworks\MATLAB Compiler Runtime`` or an empty list in case an error occurred (or nothing found). .. note:: @@ -459,16 +483,32 @@ endmacro() installation referenced in the registry, #]=======================================================================] -function(matlab_extract_all_installed_versions_from_registry win64 matlab_versions) +function(matlab_extract_all_installed_versions_from_registry win64_or_matlab_versions) if(NOT CMAKE_HOST_WIN32) message(FATAL_ERROR "[MATLAB] This function can only be called by a Windows host") endif() - if(${win64} AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "64") - set(_view "64") + set(_registry_view_args) + if("${ARGC}" EQUAL "2") + # Old API: <win64> <matlab_versions> + if(${win64_or_matlab_versions}) + set(_registry_view_args VIEW 64) + else() + set(_registry_view_args VIEW 32) + endif() + set(matlab_versions ${ARGV1}) else() - set(_view "32") + # New API: <matlab_versions> [REGISTRY_VIEW <view>] + set(matlab_versions ${win64_or_matlab_versions}) + cmake_parse_arguments(_Matlab "" "REGISTRY_VIEW" "" ${ARGN}) + if(_Matlab_REGISTRY_VIEW) + set(_registry_view_args VIEW "${_Matlab_REGISTRY_VIEW}") + endif() + endif() + + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] Extracting MATLAB versions with registry view args '${_registry_view_args}'") endif() set(matlabs_from_registry) @@ -476,20 +516,15 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio foreach(_installation_type IN ITEMS "MATLAB" "MATLAB Runtime" "MATLAB Compiler Runtime") cmake_host_system_information(RESULT _reg - QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/${_installation_type}" - SUBKEYS VIEW ${_view} + QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/${_installation_type}" + SUBKEYS + ${_registry_view_args} ) - if(_reg) - string(REGEX MATCHALL "([0-9]+(\\.[0-9]+)+)" _versions_regex "${_reg}") + string(REGEX MATCHALL "([0-9]+(\\.[0-9]+)+)" _versions_regex "${_reg}") - foreach(_match IN LISTS _versions_regex) - if(_match MATCHES "([0-9]+(\\.[0-9]+)+)") - list(APPEND matlabs_from_registry ${_match}) - endif() - endforeach() + list(APPEND matlabs_from_registry ${_versions_regex}) - endif() endforeach() if(matlabs_from_registry) @@ -530,10 +565,19 @@ endmacro() .. code-block:: cmake - matlab_get_all_valid_matlab_roots_from_registry(matlab_versions matlab_roots) + matlab_get_all_valid_matlab_roots_from_registry(matlab_versions matlab_roots [REGISTRY_VIEW view]) * Input: ``matlab_versions`` of each of the Matlab or MCR installations * Output: ``matlab_roots`` location of each of the Matlab or MCR installations + * Input: ``REGISTRY_VIEW`` Optional registry view to use for registry + interaction. The argument is passed (or omitted) to + :command:`cmake_host_system_information` without further checks or + modification. + + .. versionadded:: 3.30 + The optional ``REGISTRY_VIEW`` argument was added to provide a more precise + interface on how to interact with the Windows Registry. + #]=======================================================================] function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_roots) @@ -541,6 +585,15 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_ # extract_matlab_versions_from_registry_brute_force or # matlab_extract_all_installed_versions_from_registry. + cmake_parse_arguments(_Matlab "" "REGISTRY_VIEW" "" ${ARGN}) + set(_registry_view_args) + if(_Matlab_REGISTRY_VIEW) + set(_registry_view_args VIEW "${_Matlab_REGISTRY_VIEW}") + endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] Getting MATLAB roots with registry view args '${_registry_view_args}'") + endif() + # Mostly the major.minor version is used in Mathworks Windows Registry keys. # If the patch is not zero, major.minor.patch is used. list(TRANSFORM matlab_versions REPLACE "^([0-9]+\\.[0-9]+(\\.[1-9][0-9]*)?).*" "\\1") @@ -551,57 +604,41 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_ cmake_host_system_information(RESULT current_MATLAB_ROOT QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/MATLAB/${_matlab_current_version}" VALUE "MATLABROOT" + ${_registry_view_args} ) cmake_path(CONVERT "${current_MATLAB_ROOT}" TO_CMAKE_PATH_LIST current_MATLAB_ROOT) if(IS_DIRECTORY "${current_MATLAB_ROOT}") _Matlab_VersionInfoXML("${current_MATLAB_ROOT}" _matlab_version_tmp) if("${_matlab_version_tmp}" STREQUAL "unknown") - list(APPEND _matlab_roots_list "MATLAB" ${_matlab_current_version} ${current_MATLAB_ROOT}) - else() - list(APPEND _matlab_roots_list "MATLAB" ${_matlab_version_tmp} ${current_MATLAB_ROOT}) + set(_matlab_version_tmp ${_matlab_current_version}) endif() + list(APPEND _matlab_roots_list "MATLAB" ${_matlab_version_tmp} ${current_MATLAB_ROOT}) endif() endforeach() # Check for MCR installations - foreach(_matlab_current_version IN LISTS matlab_versions) - cmake_host_system_information(RESULT current_MATLAB_ROOT - QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/MATLAB Runtime/${_matlab_current_version}" - VALUE "MATLABROOT" - ) - cmake_path(CONVERT "${current_MATLAB_ROOT}" TO_CMAKE_PATH_LIST current_MATLAB_ROOT) + foreach(_installation_type IN ITEMS "MATLAB Runtime" "MATLAB Compiler Runtime") + foreach(_matlab_current_version IN LISTS matlab_versions) + cmake_host_system_information(RESULT current_MATLAB_ROOT + QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/${_installation_type}/${_matlab_current_version}" + VALUE "MATLABROOT" + ${_registry_view_args} + ) + cmake_path(CONVERT "${current_MATLAB_ROOT}" TO_CMAKE_PATH_LIST current_MATLAB_ROOT) - # remove the dot - string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}") + # remove the dot + string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}") - if(IS_DIRECTORY "${current_MATLAB_ROOT}") - _Matlab_VersionInfoXML("${current_MATLAB_ROOT}" _matlab_version_tmp) - if("${_matlab_version_tmp}" STREQUAL "unknown") - list(APPEND _matlab_roots_list "MCR" ${_matlab_current_version} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}") - else() + if(IS_DIRECTORY "${current_MATLAB_ROOT}") + _Matlab_VersionInfoXML("${current_MATLAB_ROOT}" _matlab_version_tmp) + if("${_matlab_version_tmp}" STREQUAL "unknown") + set(_matlab_version_tmp ${_matlab_current_version}) + endif() list(APPEND _matlab_roots_list "MCR" ${_matlab_version_tmp} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}") endif() - endif() - - endforeach() - - # Check for old MCR installations - foreach(_matlab_current_version IN LISTS matlab_versions) - cmake_host_system_information(RESULT current_MATLAB_ROOT - QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/MATLAB Compiler Runtime/${_matlab_current_version}" - VALUE "MATLABROOT" - ) - cmake_path(CONVERT "${current_MATLAB_ROOT}" TO_CMAKE_PATH_LIST current_MATLAB_ROOT) - - # remove the dot - string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}") - - if(IS_DIRECTORY "${current_MATLAB_ROOT}") - list(APPEND _matlab_roots_list "MCR" ${_matlab_current_version} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}") - endif() - + endforeach() endforeach() set(${matlab_roots} ${_matlab_roots_list} PARENT_SCOPE) endfunction() @@ -1068,20 +1105,6 @@ endfunction() #]=======================================================================] function(matlab_add_mex) - if(NOT WIN32) - # we do not need all this on Windows - # pthread options - if(CMAKE_CXX_COMPILER_LOADED) - check_cxx_compiler_flag(-pthread HAS_MINUS_PTHREAD) - elseif(CMAKE_C_COMPILER_LOADED) - check_c_compiler_flag(-pthread HAS_MINUS_PTHREAD) - endif() - # we should use try_compile instead, the link flags are discarded from - # this compiler_flag function. - #check_cxx_compiler_flag(-Wl,--exclude-libs,ALL HAS_SYMBOL_HIDING_CAPABILITY) - - endif() - set(options EXECUTABLE MODULE SHARED R2017b R2018a EXCLUDE_FROM_ALL NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES) set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME) set(multiValueArgs LINK_TO SRC) @@ -1098,14 +1121,27 @@ function(matlab_add_mex) endif() if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, add version source file + # Compilers officially supported by Matlab 9.1 (R2016b): + # MinGW 4.9, MSVC 2012, Intel C++ 2013, Xcode 6, GCC 4.9 + # These compilers definitely support the -w flag to suppress warnings. + # Other compilers (Clang) may support the -w flag and can be added here. + set(_Matlab_silenceable_compilers AppleClang Clang GNU Intel IntelLLVM MSVC) + # Add the correct version file depending on which languages are enabled in the project if(CMAKE_C_COMPILER_LOADED) # If C is enabled, use the .c file as it will work fine also with C++ set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/c_mexapi_version.c") + # Silence warnings for version source file + if("${CMAKE_C_COMPILER_ID}" IN_LIST _Matlab_silenceable_compilers) + set_source_files_properties("${MEX_VERSION_FILE}" PROPERTIES COMPILE_OPTIONS -w) + endif() elseif(CMAKE_CXX_COMPILER_LOADED) # If C is not enabled, check if CXX is enabled and use the .cpp file # to avoid that the .c file is silently ignored set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/cpp_mexapi_version.cpp") + if("${CMAKE_CXX_COMPILER_ID}" IN_LIST _Matlab_silenceable_compilers) + set_source_files_properties("${MEX_VERSION_FILE}" PROPERTIES COMPILE_OPTIONS -w) + endif() else() # If neither C or CXX is enabled, warn because we cannot add the source. # TODO: add support for fortran mex files @@ -1236,10 +1272,8 @@ function(matlab_add_mex) else() # Linux - if(HAS_MINUS_PTHREAD) - # Apparently, compiling with -pthread generated the proper link flags - # and some defines at compilation - target_compile_options(${${prefix}_NAME} PRIVATE "-pthread") + if(Threads_FOUND) + target_link_libraries(${${prefix}_NAME} Threads::Threads) endif() string(APPEND _link_flags " -Wl,--as-needed") @@ -1432,13 +1466,7 @@ function(_Matlab_find_instances_win32 matlab_roots) # testing if we are able to extract the needed information from the registry set(_matlab_versions_from_registry) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_matlab_win64 ON) - else() - set(_matlab_win64 OFF) - endif() - - matlab_extract_all_installed_versions_from_registry(_matlab_win64 _matlab_versions_from_registry) + matlab_extract_all_installed_versions_from_registry(_matlab_versions_from_registry ${ARGN}) # the returned list is empty, doing the search on all known versions if(NOT _matlab_versions_from_registry) @@ -1449,7 +1477,7 @@ function(_Matlab_find_instances_win32 matlab_roots) endif() # filtering the results with the registry keys - matlab_get_all_valid_matlab_roots_from_registry("${_matlab_versions_from_registry}" _matlab_possible_roots) + matlab_get_all_valid_matlab_roots_from_registry("${_matlab_versions_from_registry}" _matlab_possible_roots ${ARGN}) set(${matlab_roots} ${_matlab_possible_roots} PARENT_SCOPE) endfunction() @@ -1599,7 +1627,10 @@ else() # one installation using the appropriate heuristics. # There is apparently no standard way on Linux. if(CMAKE_HOST_WIN32) - _Matlab_find_instances_win32(_matlab_possible_roots_win32) + if(NOT DEFINED Matlab_FIND_REGISTRY_VIEW) + set(Matlab_FIND_REGISTRY_VIEW TARGET) + endif() + _Matlab_find_instances_win32(_matlab_possible_roots_win32 REGISTRY_VIEW ${Matlab_FIND_REGISTRY_VIEW}) list(APPEND _matlab_possible_roots ${_matlab_possible_roots_win32}) elseif(APPLE) _Matlab_find_instances_macos(_matlab_possible_roots_macos) @@ -1624,62 +1655,29 @@ list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots) set(Matlab_VERSION_STRING "NOTFOUND") set(Matlab_Or_MCR "UNKNOWN") if(_numbers_of_matlab_roots GREATER 0) - if(Matlab_FIND_VERSION_EXACT) - set(_list_index -1) - foreach(_matlab_root_index RANGE 1 ${_numbers_of_matlab_roots} 3) - list(GET _matlab_possible_roots ${_matlab_root_index} _matlab_root_version) - # only the major.minor version is used - string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _matlab_root_version "${_matlab_root_version}") - if(_matlab_root_version VERSION_EQUAL Matlab_FIND_VERSION) - set(_list_index ${_matlab_root_index}) - break() - endif() - endforeach() - - if(_list_index LESS 0) - set(_list_index 1) + set(_list_index -1) + foreach(_matlab_root_index RANGE 1 ${_numbers_of_matlab_roots} 3) + list(GET _matlab_possible_roots ${_matlab_root_index} _matlab_root_version) + find_package_check_version(${_matlab_root_version} _matlab_version_ok HANDLE_VERSION_RANGE) + if(_matlab_version_ok) + set(_list_index ${_matlab_root_index}) + break() endif() + endforeach() - math(EXPR _matlab_or_mcr_index "${_list_index} - 1") - math(EXPR _matlab_root_dir_index "${_list_index} + 1") - - list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR) - list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING) - list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR) - elseif(DEFINED Matlab_FIND_VERSION) - set(_list_index -1) - foreach(_matlab_root_index RANGE 1 ${_numbers_of_matlab_roots} 3) - list(GET _matlab_possible_roots ${_matlab_root_index} _matlab_root_version) - if(_matlab_root_version VERSION_GREATER_EQUAL Matlab_FIND_VERSION) - set(_list_index ${_matlab_root_index}) - break() - endif() - endforeach() - - if(_list_index LESS 0) - set(_list_index 1) - endif() + if(_list_index LESS 0) + set(_list_index 1) + endif() - math(EXPR _matlab_or_mcr_index "${_list_index} - 1") - math(EXPR _matlab_root_dir_index "${_list_index} + 1") - list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR) - list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING) - list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR) - # adding a warning in case of ambiguity - if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG) - message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})." - " If this is not the desired behavior, use the EXACT keyword or provide the -DMatlab_ROOT_DIR=... on the command line") - endif() - else() - list(GET _matlab_possible_roots 0 Matlab_Or_MCR) - list(GET _matlab_possible_roots 1 Matlab_VERSION_STRING) - list(GET _matlab_possible_roots 2 Matlab_ROOT_DIR) - - # adding a warning in case of ambiguity - if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG) - message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})." - " If this is not the desired behavior, use the EXACT keyword or provide the -DMatlab_ROOT_DIR=... on the command line") - endif() + math(EXPR _matlab_or_mcr_index "${_list_index} - 1") + math(EXPR _matlab_root_dir_index "${_list_index} + 1") + list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR) + list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING) + list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR) + # adding a warning in case of ambiguity + if(_numbers_of_matlab_roots GREATER 3 AND NOT Matlab_FIND_VERSION_EXACT AND MATLAB_FIND_DEBUG) + message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})." + " If this is not the desired behavior, use the EXACT keyword or provide the -DMatlab_ROOT_DIR=... on the command line") endif() endif() @@ -1743,12 +1741,6 @@ if(Matlab_ROOT_DIR) file(TO_CMAKE_PATH ${Matlab_ROOT_DIR} Matlab_ROOT_DIR) endif() -if(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(_matlab_64Build FALSE) -else() - set(_matlab_64Build TRUE) -endif() - if(NOT DEFINED Matlab_MEX_EXTENSION) set(_matlab_mex_extension "") @@ -1782,7 +1774,7 @@ endif() set(MATLAB_INCLUDE_DIR_TO_LOOK ${Matlab_ROOT_DIR}/extern/include) -if(_matlab_64Build) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_matlab_current_suffix ${_matlab_bin_suffix_64bits}) else() set(_matlab_current_suffix ${_matlab_bin_suffix_32bits}) @@ -1807,11 +1799,9 @@ else() set(_matlab_lib_prefix_for_search "lib") endif() -unset(_matlab_64Build) - if(MATLAB_FIND_DEBUG) - message(STATUS "[MATLAB] [DEBUG]_matlab_lib_prefix_for_search = ${_matlab_lib_prefix_for_search} | _matlab_lib_dir_for_search = ${_matlab_lib_dir_for_search}") + message(STATUS "[MATLAB] _matlab_lib_prefix_for_search = ${_matlab_lib_prefix_for_search} | _matlab_lib_dir_for_search = ${_matlab_lib_dir_for_search}") endif() @@ -2030,6 +2020,7 @@ find_package_handle_standard_args( FOUND_VAR Matlab_FOUND REQUIRED_VARS ${_matlab_required_variables} VERSION_VAR Matlab_VERSION + HANDLE_VERSION_RANGE HANDLE_COMPONENTS) unset(_matlab_required_variables) diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index b62f839..e187804 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -347,16 +347,51 @@ function(gtest_add_tests) unset(testList) - set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*") + set(gtest_case_name_regex ".*\\([ \r\n\t]*([A-Za-z_0-9]+)[ \r\n\t]*,[ \r\n\t]*([A-Za-z_0-9]+)[ \r\n\t]*\\).*") set(gtest_test_type_regex "(TYPED_TEST|TEST)_?[FP]?") + set(each_line_regex "([^\r\n]*[\r\n])") foreach(source IN LISTS ARGS_SOURCES) if(NOT ARGS_SKIP_DEPENDENCY) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source}) endif() file(READ "${source}" contents) - string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests "${contents}") - foreach(hit ${found_tests}) + # Replace characters in file content that are special to CMake + string(REPLACE "[" "<OPEN_BRACKET>" contents "${contents}") + string(REPLACE "]" "<CLOSE_BRACKET>" contents "${contents}") + string(REPLACE ";" "\\;" contents "${contents}") + # Split into lines + string(REGEX MATCHALL "${each_line_regex}" content_lines "${contents}") + set(line "0") + # Stores the line number of the start of a test definition + set(accumulate_line "0") + # Stores accumulated lines to match multi-line test definitions + set(accumulated "") + # Iterate over each line in the file so that we know the line number of a test definition + foreach(line_str IN LISTS content_lines) + MATH(EXPR line "${line}+1") + # Check if the current line is the start of a test definition + string(REGEX MATCH "[ \t]*${gtest_test_type_regex}[ \t]*[\\(]*" accumlate_start_hit "${line_str}") + if(accumlate_start_hit) + set(accumulate_line "${line}") + endif() + # Append the current line to the accumulated string + set(accumulated "${accumulated}${line_str}") + # Attempt to match a complete test definition in the accumulated string + string(REGEX MATCH "${gtest_test_type_regex}[ \r\n\t]*\\(([A-Za-z_0-9 ,\r\n\t]+)\\)" hit "${accumulated}") + if(hit) + # Reset accumulated for the next match + set(accumulated "") + else() + # Continue accumulating lines + continue() + endif() + # At this point, the start line of the test definition is known + # Hence, we can set the test's DEF_SOURCE_LINE property with + # ${source}:${accumulate_line} below. + # VS Code CMake Tools extension looks for DEF_SOURCE_LINE + # to locate the test definition for its "Go to test" feature. + string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit}) # Parameterized tests have a different signature for the filter @@ -394,7 +429,8 @@ function(gtest_add_tests) --gtest_filter=${gtest_test_name} ${ARGS_EXTRA_ARGS} ) - set_tests_properties(${ctest_test_name} PROPERTIES DISABLED TRUE) + set_tests_properties(${ctest_test_name} PROPERTIES DISABLED TRUE + DEF_SOURCE_LINE "${source}:${accumulate_line}") list(APPEND testList ${ctest_test_name}) endif() else() @@ -410,6 +446,7 @@ function(gtest_add_tests) ${ctest_test_name} PROPERTIES SKIP_REGULAR_EXPRESSION "\\[ SKIPPED \\]" + DEF_SOURCE_LINE "${source}:${accumulate_line}" ) list(APPEND testList ${ctest_test_name}) endif() diff --git a/Modules/UseJava/javaTargets.cmake.in b/Modules/UseJava/javaTargets.cmake.in index f3670c2..dc20c82 100644 --- a/Modules/UseJava/javaTargets.cmake.in +++ b/Modules/UseJava/javaTargets.cmake.in @@ -1,5 +1,5 @@ cmake_policy(PUSH) -cmake_policy(VERSION 2.8.12...3.27) +cmake_policy(VERSION 2.8.12...3.28) #---------------------------------------------------------------- # Generated CMake Java target import file. |