Merge topic 'test-ExportImport'
be5603d031 Tests: Fix ExportImport test with read-only source tree
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8813
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 82350bb..639cc5f 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -46,7 +46,7 @@
The version given to the :command:`find_package` directive is the Matlab
**version**, which should not be confused with the Matlab *release* name
- (eg. `R2014`).
+ (e.g. `R2023b`).
The :command:`matlab_get_version_from_release_name` and
:command:`matlab_get_release_name_from_version` provide a mapping
between the release name and the version.
@@ -57,7 +57,7 @@
* Windows: The installed versions of Matlab/MCR are retrieved from the
Windows registry
-* OS X: The installed versions of Matlab/MCR are given by the MATLAB
+* 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``.
* Unix: The desired Matlab should be accessible from the ``PATH``. This does
@@ -353,7 +353,7 @@
#]=======================================================================]
macro(matlab_get_version_from_release_name release_name version_name)
- string(REGEX MATCHALL "${release_name}=([0-9]+\\.?[0-9]*)" _matched ${MATLAB_VERSIONS_MAPPING})
+ string(REGEX MATCHALL "${release_name}=([0-9]+\\.[0-9]+)" _matched ${MATLAB_VERSIONS_MAPPING})
set(${version_name} "")
if(NOT _matched STREQUAL "")
@@ -380,9 +380,17 @@
#]=======================================================================]
macro(matlab_get_release_name_from_version version release_name)
+ # only the major.minor version is used
+ string(REGEX MATCH "([0-9]+\\.[0-9]+)" _match ${version})
+ if(CMAKE_MATCH_1)
+ set(short_version ${CMAKE_MATCH_1})
+ else()
+ set(short_version ${version})
+ endif()
+
set(${release_name} "")
foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
- string(REGEX MATCHALL "(.+)=${version}" _matched ${_var})
+ string(REGEX MATCHALL "(.+)=${short_version}" _matched ${_var})
if(NOT _matched STREQUAL "")
set(${release_name} ${CMAKE_MATCH_1})
break()
@@ -392,7 +400,7 @@
unset(_var)
unset(_matched)
if(${release_name} STREQUAL "")
- message(WARNING "[MATLAB] The version ${version} is not registered")
+ message(WARNING "[MATLAB] The version ${short_version} is not registered")
endif()
endmacro()
@@ -403,7 +411,7 @@
macro(matlab_get_supported_releases list_releases)
set(${list_releases})
foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
- string(REGEX MATCHALL "(.+)=([0-9]+\\.?[0-9]*)" _matched ${_var})
+ string(REGEX MATCHALL "(.+)=([0-9]+\\.[0-9]+)" _matched ${_var})
if(NOT _matched STREQUAL "")
list(APPEND ${list_releases} ${CMAKE_MATCH_1})
endif()
@@ -420,7 +428,7 @@
macro(matlab_get_supported_versions list_versions)
set(${list_versions})
foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
- string(REGEX MATCHALL "(.+)=([0-9]+\\.?[0-9]*)" _matched ${_var})
+ string(REGEX MATCHALL "(.+)=([0-9]+\\.[0-9]+)" _matched ${_var})
if(NOT _matched STREQUAL "")
list(APPEND ${list_versions} ${CMAKE_MATCH_2})
endif()
@@ -458,50 +466,44 @@
function(matlab_extract_all_installed_versions_from_registry win64 matlab_versions)
if(NOT CMAKE_HOST_WIN32)
- message(FATAL_ERROR "[MATLAB] This macro can only be called by a windows host (call to reg.exe)")
+ message(FATAL_ERROR "[MATLAB] This macro can only be called by a Windows host")
endif()
if(${win64} AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "64")
- set(APPEND_REG "/reg:64")
+ set(_view "64")
else()
- set(APPEND_REG "/reg:32")
+ set(_view "32")
endif()
set(matlabs_from_registry)
foreach(_installation_type IN ITEMS "MATLAB" "MATLAB Runtime" "MATLAB Compiler Runtime")
- # /reg:64 should be added on 64 bits capable OSs in order to enable the
- # redirection of 64 bits applications
- execute_process(
- COMMAND reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Mathworks\\${_installation_type}" /f * /k ${APPEND_REG}
- RESULT_VARIABLE resultMatlab
- OUTPUT_VARIABLE varMatlab
- ERROR_VARIABLE errMatlab
- INPUT_FILE NUL
- )
+ cmake_host_system_information(RESULT _reg
+ QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/${_installation_type}"
+ SUBKEYS VIEW ${_view}
+ )
+ if(_reg)
- if(resultMatlab EQUAL 0)
+ string(REGEX MATCHALL "([0-9]+\\.[0-9]+)" _versions_regex ${_reg})
- string(
- REGEX MATCHALL "${_installation_type}\\\\([0-9]+(\\.[0-9]+)?)"
- matlab_versions_regex ${varMatlab})
+ foreach(match IN LISTS _versions_regex)
+ string(REGEX MATCH "([0-9]+\\.[0-9]+)" current_match ${match})
- foreach(match IN LISTS matlab_versions_regex)
- string(
- REGEX MATCH "${_installation_type}\\\\(([0-9]+)(\\.([0-9]+))?)"
- current_match ${match})
-
- set(_matlab_current_version ${CMAKE_MATCH_1})
- set(current_matlab_version_major ${CMAKE_MATCH_2})
- set(current_matlab_version_minor ${CMAKE_MATCH_4})
- if(NOT current_matlab_version_minor)
- set(current_matlab_version_minor "0")
+ if(NOT CMAKE_MATCH_1)
+ continue()
endif()
- list(APPEND matlabs_from_registry ${_matlab_current_version})
- unset(_matlab_current_version)
+ cmake_host_system_information(RESULT _reg
+ QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Mathworks/${_installation_type}/${CMAKE_MATCH_1}"
+ VALUE "MATLABROOT"
+ )
+
+ _Matlab_VersionInfoXML(${_reg} _matlab_version_tmp)
+ if(NOT "${_matlab_version_tmp}" STREQUAL "unknown")
+ list(APPEND matlabs_from_registry ${_matlab_version_tmp})
+ endif()
endforeach()
endif()
@@ -509,8 +511,7 @@
if(matlabs_from_registry)
list(REMOVE_DUPLICATES matlabs_from_registry)
- list(SORT matlabs_from_registry COMPARE NATURAL)
- list(REVERSE matlabs_from_registry)
+ list(SORT matlabs_from_registry COMPARE NATURAL ORDER DESCENDING)
endif()
set(${matlab_versions} ${matlabs_from_registry} PARENT_SCOPE)
@@ -528,8 +529,7 @@
# we order from more recent to older
if(matlab_supported_versions)
list(REMOVE_DUPLICATES matlab_supported_versions)
- list(SORT matlab_supported_versions COMPARE NATURAL)
- list(REVERSE matlab_supported_versions)
+ list(SORT matlab_supported_versions COMPARE NATURAL ORDER DESCENDING)
endif()
set(${matlab_versions} ${matlab_supported_versions})
@@ -841,7 +841,7 @@
string(SUBSTRING "${_matlab_version_from_cmd}" ${index} -1 substring_ans)
string(
- REGEX MATCHALL "ans[\r\n\t ]*=[\r\n\t ]*'?([0-9]+(\\.[0-9]+)?)"
+ REGEX MATCHALL "ans[\r\n\t ]*=[\r\n\t ]*'?([0-9]+(\\.[0-9]+)+)"
matlab_versions_regex
${substring_ans})
foreach(match IN LISTS matlab_versions_regex)
@@ -1280,7 +1280,7 @@
if(NOT matlab_known_version STREQUAL "NOTFOUND")
# the version is known, we just return it
set(${matlab_final_version} ${matlab_known_version} PARENT_SCOPE)
- set(Matlab_VERSION_STRING_INTERNAL ${matlab_known_version} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
+ set(Matlab_VERSION_STRING_INTERNAL ${matlab_known_version} CACHE INTERNAL "Matlab version (automatically determined)")
return()
endif()
@@ -1341,8 +1341,8 @@
if(MATLAB_FIND_DEBUG)
message(WARNING "[MATLAB] Cannot find the main matlab program under ${matlab_root}")
endif()
- set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
- set(Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
+ set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version")
+ set(Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version")
unset(_matlab_current_program)
unset(_matlab_current_program CACHE)
return()
@@ -1362,12 +1362,12 @@
# update the location of the program
set(Matlab_PROG_VERSION_STRING_AUTO_DETECT
${_matlab_main_real_path_tmp}
- CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
+ CACHE INTERNAL "internal matlab location for the discovered version")
- _Matlab_VersionInfoXML()
- if(Matlab_VERSION_STRING_INTERNAL AND NOT Matlab_VERSION_STRING_INTERNAL STREQUAL "unknown")
+ _Matlab_VersionInfoXML(${matlab_root} _matlab_version_tmp)
+ if(NOT "${_matlab_version_tmp}" STREQUAL "unknown")
# at least back to R2016 VersionInfo.xml exists
- set(matlab_list_of_all_versions ${Matlab_VERSION_STRING_INTERNAL})
+ set(matlab_list_of_all_versions ${_matlab_version_tmp})
else()
# time consuming, less stable way to find Matlab version by running Matlab
matlab_get_version_from_matlab_run("${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions)
@@ -1381,7 +1381,7 @@
endif()
# set the version into the cache
- set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
+ set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)")
# warning, just in case several versions found (should not happen)
if((list_of_all_versions_length GREATER 1) AND MATLAB_FIND_DEBUG)
@@ -1392,7 +1392,10 @@
# MCR
# we cannot run anything in order to extract the version. We assume that the file
# VersionInfo.xml exists under the MatlabRoot, we look for it and extract the version from there
- _Matlab_VersionInfoXML()
+ _Matlab_VersionInfoXML(${matlab_root} _matlab_version_tmp)
+ if(NOT "${_matlab_version_tmp}" STREQUAL "unknown")
+ set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)")
+ endif()
endif() # Matlab or MCR
# return the updated value
@@ -1401,9 +1404,9 @@
endfunction()
-function(_Matlab_VersionInfoXML)
+function(_Matlab_VersionInfoXML matlab_root _version)
- set(_matlab_version_tmp "unknown")
+ set(_ver "unknown")
set(_XMLfile ${matlab_root}/VersionInfo.xml)
if(NOT EXISTS ${_XMLfile})
@@ -1414,19 +1417,17 @@
if(versioninfo_string)
# parses "<version>23.2.0.2365128</version>"
- string(REGEX MATCH "<version>(.*)</version>"
+ string(REGEX MATCH "<version>([0-9]+(\\.[0-9]+)+)</version>"
version_reg_match
${versioninfo_string}
)
- if(CMAKE_MATCH_1 MATCHES "(([0-9]+)\\.([0-9]+))[\\.0-9]*")
- set(_matlab_version_tmp "${CMAKE_MATCH_1}")
+ if(CMAKE_MATCH_1)
+ set(_ver "${CMAKE_MATCH_1}")
endif()
endif()
- if(_matlab_version_tmp)
- set(Matlab_VERSION_STRING_INTERNAL "${_matlab_version_tmp}" CACHE INTERNAL "Matlab version" FORCE)
- endif()
+ set(${_version} ${_ver} PARENT_SCOPE)
endfunction()
@@ -1462,8 +1463,8 @@
endfunction()
-# Utility function for finding Matlab or MCR on OSX
-function(_Matlab_find_instances_osx matlab_roots)
+# Utility function for finding Matlab or MCR on macOS
+function(_Matlab_find_instances_macos matlab_roots)
set(_matlab_possible_roots)
# on mac, we look for the /Application paths
@@ -1480,6 +1481,11 @@
string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}")
set(_matlab_base_path "/Applications/MATLAB_${_matlab_current_release}.app")
+ _Matlab_VersionInfoXML(${_matlab_base_path} _matlab_version_tmp)
+ if(NOT "${_matlab_version_tmp}" STREQUAL "unknown")
+ set(_matlab_current_version ${_matlab_version_tmp})
+ endif()
+
# Check Matlab, has precedence over MCR
if(IS_DIRECTORY "${_matlab_base_path}")
if(MATLAB_FIND_DEBUG)
@@ -1605,8 +1611,8 @@
_Matlab_find_instances_win32(_matlab_possible_roots_win32)
list(APPEND _matlab_possible_roots ${_matlab_possible_roots_win32})
elseif(APPLE)
- _Matlab_find_instances_osx(_matlab_possible_roots_osx)
- list(APPEND _matlab_possible_roots ${_matlab_possible_roots_osx})
+ _Matlab_find_instances_macos(_matlab_possible_roots_macos)
+ list(APPEND _matlab_possible_roots ${_matlab_possible_roots_macos})
endif()
endif()
@@ -1622,10 +1628,6 @@
message(STATUS "[MATLAB] Matlab root folders are ${_matlab_possible_roots}")
endif()
-
-
-
-
# take the first possible Matlab root
list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
set(Matlab_VERSION_STRING "NOTFOUND")
@@ -1817,7 +1819,7 @@
# This small stub around find_library is to prevent any pollution of CMAKE_FIND_LIBRARY_PREFIXES in the global scope.
# This is the function to be used below instead of the find_library directives.
function(_Matlab_find_library _matlab_library_prefix)
- set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} ${_matlab_library_prefix})
+ list(APPEND CMAKE_FIND_LIBRARY_PREFIXES ${_matlab_library_prefix})
find_library(${ARGN})
endfunction()
diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake
index a32f83a..19e5ba9 100644
--- a/Modules/FindPhysFS.cmake
+++ b/Modules/FindPhysFS.cmake
@@ -5,16 +5,20 @@
FindPhysFS
----------
+Locate PhysFS library This module defines:
+``PHYSFS_LIBRARY``
+ the name of the library to link against
+``PHYSFS_FOUND``
+ if false, do not try to link to PHYSFS
+``PHYSFS_INCLUDE_DIR``
+ where to find physfs.h
-Locate PhysFS library This module defines PHYSFS_LIBRARY, the name of
-the library to link against PHYSFS_FOUND, if false, do not try to link
-to PHYSFS PHYSFS_INCLUDE_DIR, where to find physfs.h
+``$PHYSFSDIR`` is an environment variable that would correspond to::
-$PHYSFSDIR is an environment variable that would correspond to the
-./configure --prefix=$PHYSFSDIR used in building PHYSFS.
+ ./configure --prefix=$PHYSFSDIR
-Created by Eric Wing.
+used in building PHYSFS.
#]=======================================================================]
find_path(PHYSFS_INCLUDE_DIR physfs.h
diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake
index 65495b5..8a16e8a 100644
--- a/Modules/FindProducer.cmake
+++ b/Modules/FindProducer.cmake
@@ -5,8 +5,6 @@
FindProducer
------------
-
-
Though Producer isn't directly part of OpenSceneGraph, its primary
user is OSG so I consider this part of the Findosg* suite used to find
OpenSceneGraph components. You'll notice that I accept OSGDIR as an
@@ -17,19 +15,25 @@
it for you. This is to allow you control over your own system piece
by piece in case you need to opt out of certain components or change
the Find behavior for a particular module (perhaps because the default
-FindOpenGL.cmake module doesn't work with your system as an example).
+:module:`FindOpenGL` module doesn't work with your system as an example).
If you want to use a more convenient module that includes everything,
-use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake
+use the :module:`FindOpenSceneGraph` instead of the Findosg*.cmake
modules.
-Locate Producer This module defines PRODUCER_LIBRARY PRODUCER_FOUND,
-if false, do not try to link to Producer PRODUCER_INCLUDE_DIR, where
-to find the headers
+Locate Producer This module defines:
-$PRODUCER_DIR is an environment variable that would correspond to the
-./configure --prefix=$PRODUCER_DIR used in building osg.
+``PRODUCER_LIBRARY``
-Created by Eric Wing.
+``PRODUCER_FOUND``
+ if false, do not try to link to Producer
+``PRODUCER_INCLUDE_DIR``
+ where to find the headers
+
+``$PRODUCER_DIR`` is an environment variable that would correspond to::
+
+ ./configure --prefix=$PRODUCER_DIR
+
+used in building osg.
#]=======================================================================]
# Header files are presumed to be included like
diff --git a/Modules/FindQuickTime.cmake b/Modules/FindQuickTime.cmake
index 107486d..89be2a6 100644
--- a/Modules/FindQuickTime.cmake
+++ b/Modules/FindQuickTime.cmake
@@ -5,16 +5,18 @@
FindQuickTime
-------------
+Locate QuickTime This module defines:
+``QUICKTIME_LIBRARY``
-Locate QuickTime This module defines QUICKTIME_LIBRARY
-QUICKTIME_FOUND, if false, do not try to link to gdal
-QUICKTIME_INCLUDE_DIR, where to find the headers
+``QUICKTIME_FOUND``
+ if false, do not try to link to gdal
+``QUICKTIME_INCLUDE_DIR``
+ where to find the headers
-$QUICKTIME_DIR is an environment variable that would correspond to the
-./configure --prefix=$QUICKTIME_DIR
+``$QUICKTIME_DIR`` is an environment variable that would correspond to::
-Created by Eric Wing.
+ ./configure --prefix=$QUICKTIME_DIR
#]=======================================================================]
find_path(QUICKTIME_INCLUDE_DIR QuickTime/QuickTime.h QuickTime.h
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 80dd503..d1b4193 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 27)
-set(CMake_VERSION_PATCH 20230918)
+set(CMake_VERSION_PATCH 20230919)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 1d8a847..f7b7ada 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -785,6 +785,9 @@
mf.SetArgcArgv(args);
}
+ if (!cmSystemTools::FileExists(path, true)) {
+ cmSystemTools::Error("Not a file: " + path);
+ }
if (!mf.ReadListFile(path)) {
cmSystemTools::Error("Error processing file: " + path);
}
diff --git a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt
index b65a349..5d3d4b3 100644
--- a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt
+++ b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt
@@ -1,3 +1,3 @@
-^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt
+^CMake Error: Not a file: .*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt
CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/C-no-file-build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/Cno-file-stderr.txt b/Tests/RunCMake/CommandLine/Cno-file-stderr.txt
index 416686c..4024499 100644
--- a/Tests/RunCMake/CommandLine/Cno-file-stderr.txt
+++ b/Tests/RunCMake/CommandLine/Cno-file-stderr.txt
@@ -1,3 +1,3 @@
-^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine/Cno-file-build/nosuchcachefile.txt
+^CMake Error: Not a file: .*/Tests/RunCMake/CommandLine/Cno-file-build/nosuchcachefile.txt
CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/Cno-file-build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/P_directory-stderr.txt b/Tests/RunCMake/CommandLine/P_directory-stderr.txt
index b8319a1..ec33aed 100644
--- a/Tests/RunCMake/CommandLine/P_directory-stderr.txt
+++ b/Tests/RunCMake/CommandLine/P_directory-stderr.txt
@@ -1 +1 @@
-^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine$
+^CMake Error: Not a file: .*/Tests/RunCMake/CommandLine$
diff --git a/Tests/RunCMake/CommandLine/P_no-file-stderr.txt b/Tests/RunCMake/CommandLine/P_no-file-stderr.txt
index 2e12399..a3b4e8e 100644
--- a/Tests/RunCMake/CommandLine/P_no-file-stderr.txt
+++ b/Tests/RunCMake/CommandLine/P_no-file-stderr.txt
@@ -1 +1,2 @@
-^CMake Error: Error processing file: nosuchscriptfile.cmake$
+^CMake Error: Not a file: nosuchscriptfile.cmake
+CMake Error: Error processing file: nosuchscriptfile.cmake$
diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
index 320aecc..87999d5 100644
--- a/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
+++ b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
@@ -1 +1 @@
-^CMake Error: Error processing file:
+^CMake Error: Not a file: