diff options
74 files changed, 392 insertions, 344 deletions
diff --git a/.gitlab/ci/env.ps1 b/.gitlab/ci/env.ps1 index e24bc37..72a8cb8 100755 --- a/.gitlab/ci/env.ps1 +++ b/.gitlab/ci/env.ps1 @@ -1,3 +1,4 @@ +$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName if (Test-Path -Path ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" -PathType Leaf) { - Invoke-Expression ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" + . ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" } diff --git a/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 b/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 index f8a86c4..a96658d 100755 --- a/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 +++ b/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 @@ -1,3 +1,3 @@ if ("$env:CMAKE_CI_NIGHTLY" -eq "true") { - Invoke-Expression ".gitlab/ci/ispc-env.ps1" + . ".gitlab/ci/ispc-env.ps1" } diff --git a/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 b/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 index e8d242c..e5f538a 100755 --- a/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 +++ b/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 @@ -1,9 +1,9 @@ if ("$env:CMAKE_CI_NIGHTLY" -eq "true") { - Invoke-Expression -Command ".gitlab/ci/ispc-env.ps1" + . ".gitlab/ci/ispc-env.ps1" } $pwdpath = $pwd.Path -powershell -File ".gitlab/ci/ninja.ps1" +& "$pwsh" -File ".gitlab/ci/ninja.ps1" Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" ninja --version diff --git a/.gitlab/ci/ispc-env.ps1 b/.gitlab/ci/ispc-env.ps1 index 1baea31..816c485 100755 --- a/.gitlab/ci/ispc-env.ps1 +++ b/.gitlab/ci/ispc-env.ps1 @@ -1,4 +1,4 @@ $pwdpath = $pwd.Path -powershell -File ".gitlab/ci/ispc.ps1" +& "$pwsh" -File ".gitlab/ci/ispc.ps1" Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\ispc\bin;$env:PATH" ispc --version diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index 282cf1e..5c6be11 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -293,13 +293,13 @@ ## Windows-specific scripts .before_script_windows: &before_script_windows - - Invoke-Expression -Command .gitlab/ci/env.ps1 + - . .gitlab/ci/env.ps1 - $pwdpath = $pwd.Path - - powershell -File ".gitlab/ci/wix.ps1" + - (& "$pwsh" -File ".gitlab/ci/wix.ps1") - Set-Item -Force -Path "env:WIX" -Value "$pwdpath\.gitlab\wix" - - powershell -File ".gitlab/ci/cmake.ps1" + - (& "$pwsh" -File ".gitlab/ci/cmake.ps1") - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\cmake\bin;$env:PATH" - - powershell -File ".gitlab/ci/ninja.ps1" + - (& "$pwsh" -File ".gitlab/ci/ninja.ps1") - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" - (& "$env:WIX\bin\light.exe" -help) | Select -First 1 - cmake --version @@ -352,7 +352,7 @@ stage: test-ext script: - - Invoke-Expression -Command .gitlab/ci/env.ps1 + - . .gitlab/ci/env.ps1 - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake interruptible: true @@ -361,6 +361,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake @@ -370,6 +371,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/jom.ps1 - $pwdpath = $pwd.Path - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\jom;$env:PATH" @@ -382,6 +384,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/borland.ps1 - $pwdpath = $pwd.Path - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\bcc\bin;$env:PATH" @@ -393,8 +396,9 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - $pwdpath = $pwd.Path - - powershell -File ".gitlab/ci/ninja.ps1" + - (& "$pwsh" -File ".gitlab/ci/ninja.ps1") - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" - Invoke-Expression -Command .gitlab/ci/clang.ps1 - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 @@ -407,6 +411,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/msvc.ps1 - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake @@ -417,6 +422,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/openwatcom.ps1 - $pwdpath = $pwd.Path - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\watcom\binnt;$pwdpath\.gitlab\watcom\binw;$env:PATH" diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 35dac76..d7acbef 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -10,6 +10,8 @@ cmake-presets(7) Introduction ============ +.. versionadded:: 3.19 + One problem that CMake users often face is sharing settings with other people for common ways to configure a project. This may be done to support CI builds, or for users who frequently use the same build. CMake supports two main files, @@ -190,8 +192,12 @@ that may contain the following fields: ``architecture``, ``toolset`` Optional fields representing the platform and toolset, respectively, for - generators that support them. Each may be either a string or an object - with the following fields: + :manual:`generators <cmake-generators(7)>` that support them. + + See :option:`cmake -A` option for for possible values for ``architecture`` + and :option:`cmake -T` for ``toolset``. + + Each may be either a string or an object with the following fields: ``value`` An optional string representing the value. diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index 7fa73e7..8a83807 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -17,6 +17,9 @@ determines the toolchain for host builds based on system introspection and defaults. In cross-compiling scenarios, a toolchain file may be specified with information about compiler and utility paths. +.. versionadded:: 3.19 + One may use :manual:`cmake-presets(7)` to specify toolchain files. + Languages ========= @@ -58,20 +61,24 @@ Variables and Properties ======================== Several variables relate to the language components of a toolchain which are -enabled. :variable:`CMAKE_<LANG>_COMPILER` is the full path to the compiler used -for ``<LANG>``. :variable:`CMAKE_<LANG>_COMPILER_ID` is the identifier used -by CMake for the compiler and :variable:`CMAKE_<LANG>_COMPILER_VERSION` is the -version of the compiler. - -The :variable:`CMAKE_<LANG>_FLAGS` variables and the configuration-specific -equivalents contain flags that will be added to the compile command when -compiling a file of a particular language. - -As the linker is invoked by the compiler driver, CMake needs a way to determine -which compiler to use to invoke the linker. This is calculated by the -:prop_sf:`LANGUAGE` of source files in the target, and in the case of static -libraries, the language of the dependent libraries. The choice CMake makes may -be overridden with the :prop_tgt:`LINKER_LANGUAGE` target property. +enabled: + +:variable:`CMAKE_<LANG>_COMPILER` + The full path to the compiler used for ``<LANG>`` +:variable:`CMAKE_<LANG>_COMPILER_ID` + The compiler identifier used by CMake +:variable:`CMAKE_<LANG>_COMPILER_VERSION` + The version of the compiler. +:variable:`CMAKE_<LANG>_FLAGS` + The variables and the configuration-specific equivalents contain flags that + will be added to the compile command when compiling a file of a particular + language. + +CMake needs a way to determine which compiler to use to invoke the linker. +This is determined by the :prop_sf:`LANGUAGE` property of source files of the +:manual:`target <cmake-buildsystem(7)>`, and in the case of static libraries, +the ``LANGUAGE`` of the dependent libraries. The choice CMake makes may be overridden +with the :prop_tgt:`LINKER_LANGUAGE` target property. Toolchain Features ================== @@ -133,24 +140,24 @@ as: set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -The :variable:`CMAKE_SYSTEM_NAME` is the CMake-identifier of the target platform -to build for. - -The :variable:`CMAKE_SYSTEM_PROCESSOR` is the CMake-identifier of the target architecture -to build for. +Where: -The :variable:`CMAKE_SYSROOT` is optional, and may be specified if a sysroot -is available. - -The :variable:`CMAKE_STAGING_PREFIX` is also optional. It may be used to specify -a path on the host to install to. The :variable:`CMAKE_INSTALL_PREFIX` is always -the runtime installation location, even when cross-compiling. - -The :variable:`CMAKE_<LANG>_COMPILER` variables may be set to full paths, or to -names of compilers to search for in standard locations. For toolchains that -do not support linking binaries without custom flags or scripts one may set -the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to ``STATIC_LIBRARY`` -to tell CMake not to try to link executables during its checks. +:variable:`CMAKE_SYSTEM_NAME` + is the CMake-identifier of the target platform to build for. +:variable:`CMAKE_SYSTEM_PROCESSOR` + is the CMake-identifier of the target architecture. +:variable:`CMAKE_SYSROOT` + is optional, and may be specified if a sysroot is available. +:variable:`CMAKE_STAGING_PREFIX` + is also optional. It may be used to specify a path on the host to install to. + The :variable:`CMAKE_INSTALL_PREFIX` is always the runtime installation + location, even when cross-compiling. +:variable:`CMAKE_<LANG>_COMPILER` + variable may be set to full paths, or to names of compilers to search for + in standard locations. For toolchains that do not support linking binaries + without custom flags or scripts one may set the + :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to ``STATIC_LIBRARY`` to + tell CMake not to try to link executables during its checks. CMake ``find_*`` commands will look in the sysroot, and the :variable:`CMAKE_FIND_ROOT_PATH` entries by default in all cases, as well as looking in the host system root prefix. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index ad6bfbc..6533ca5 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -309,6 +309,8 @@ Variables that Describe the System /variable/CMAKE_CL_64 /variable/CMAKE_COMPILER_2005 /variable/CMAKE_HOST_APPLE + /variable/CMAKE_HOST_BSD + /variable/CMAKE_HOST_LINUX /variable/CMAKE_HOST_SOLARIS /variable/CMAKE_HOST_SYSTEM /variable/CMAKE_HOST_SYSTEM_NAME @@ -324,8 +326,6 @@ Variables that Describe the System /variable/CMAKE_SYSTEM_PROCESSOR /variable/CMAKE_SYSTEM_VERSION /variable/CYGWIN - /variable/DRAGONFLYBSD - /variable/FREEBSD /variable/GHSMULTI /variable/IOS /variable/LINUX @@ -344,8 +344,6 @@ Variables that Describe the System /variable/MSVC_TOOLSET_VERSION /variable/MSVC_VERSION /variable/MSYS - /variable/NETBSD - /variable/OPENBSD /variable/UNIX /variable/WIN32 /variable/WINCE diff --git a/Help/release/3.24.rst b/Help/release/3.24.rst index ecf6f1c..3857c5d 100644 --- a/Help/release/3.24.rst +++ b/Help/release/3.24.rst @@ -359,9 +359,9 @@ Updates Changes made since CMake 3.24.0 include the following. -3.24.1 ------- +3.24.1, 3.24.2 +-------------- -* This version made no changes to documented features or interfaces. +* These versions made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes and/or fix regressions. diff --git a/Help/release/dev/BSD.rst b/Help/release/dev/BSD.rst new file mode 100644 index 0000000..cd2352b --- /dev/null +++ b/Help/release/dev/BSD.rst @@ -0,0 +1,8 @@ +Variables +--------- + +* The :variable:`BSD` variable is set to a string value when the target system is BSD. + This value can be one of the following: DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD. + +* The :variable:`CMAKE_HOST_BSD` variable is set to a string value when the host system is BSD. + This value can be one of the following: DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD. diff --git a/Help/release/dev/LINUX.rst b/Help/release/dev/LINUX.rst index 45b7029..b837a1f 100644 --- a/Help/release/dev/LINUX.rst +++ b/Help/release/dev/LINUX.rst @@ -2,3 +2,5 @@ Variables --------- * The :variable:`LINUX` variable is set to true when the target system is Linux. + +* The :variable:`CMAKE_HOST_LINUX` variable is set to true when the host system is Linux. diff --git a/Help/release/dev/UseSWIG-perl-extra-files.rst b/Help/release/dev/UseSWIG-perl-extra-files.rst new file mode 100644 index 0000000..d7490ec --- /dev/null +++ b/Help/release/dev/UseSWIG-perl-extra-files.rst @@ -0,0 +1,5 @@ +UseSWIG-perl-extra-files +------------------------ + +* The :module:`UseSWIG` module gained knowledge about generated Perl module + files (extension ``.pm``). diff --git a/Help/release/dev/bsd-variables.rst b/Help/release/dev/bsd-variables.rst deleted file mode 100644 index 9d59edc..0000000 --- a/Help/release/dev/bsd-variables.rst +++ /dev/null @@ -1,9 +0,0 @@ -bsd-variables -------------- - -* The :variable:`BSD` variable is set to true when the target system - is BSD (DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD) -* The :variable:`DRAGONFLYBSD` variable is set to true when the target system is DragonFlyBSD. -* The :variable:`FREEBSD` variable is set to true when the target system is FreeBSD. -* The :variable:`NETBSD` variable is set to true when the target system is NetBSD. -* The :variable:`OPENBSD` variable is set to true when the target system is OpenBSD. diff --git a/Help/variable/BSD.rst b/Help/variable/BSD.rst index 0b3e5dc..fdfe5ec 100644 --- a/Help/variable/BSD.rst +++ b/Help/variable/BSD.rst @@ -3,4 +3,5 @@ BSD .. versionadded:: 3.25 -Set to true when the target system is BSD (DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD) +Set to a string value when the target system is BSD. This value can be one of +the following: DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD. diff --git a/Help/variable/CMAKE_HOST_BSD.rst b/Help/variable/CMAKE_HOST_BSD.rst new file mode 100644 index 0000000..d3554f9 --- /dev/null +++ b/Help/variable/CMAKE_HOST_BSD.rst @@ -0,0 +1,7 @@ +CMAKE_HOST_BSD +-------------- + +.. versionadded:: 3.25 + +Set to a string value when the host system is BSD. This value can be one of +the following: DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD. diff --git a/Help/variable/CMAKE_HOST_LINUX.rst b/Help/variable/CMAKE_HOST_LINUX.rst new file mode 100644 index 0000000..e2361bd --- /dev/null +++ b/Help/variable/CMAKE_HOST_LINUX.rst @@ -0,0 +1,6 @@ +CMAKE_HOST_LINUX +---------------- + +.. versionadded:: 3.25 + +Set to true when the host system is Linux. diff --git a/Help/variable/DRAGONFLYBSD.rst b/Help/variable/DRAGONFLYBSD.rst deleted file mode 100644 index f006156..0000000 --- a/Help/variable/DRAGONFLYBSD.rst +++ /dev/null @@ -1,6 +0,0 @@ -DRAGONFLYBSD ------------- - -.. versionadded:: 3.25 - -Set to true when the target system is DragonFlyBSD. diff --git a/Help/variable/FREEBSD.rst b/Help/variable/FREEBSD.rst deleted file mode 100644 index 9990948..0000000 --- a/Help/variable/FREEBSD.rst +++ /dev/null @@ -1,6 +0,0 @@ -FREEBSD -------- - -.. versionadded:: 3.25 - -Set to true when the target system is FreeBSD. diff --git a/Help/variable/NETBSD.rst b/Help/variable/NETBSD.rst deleted file mode 100644 index e7965f8..0000000 --- a/Help/variable/NETBSD.rst +++ /dev/null @@ -1,6 +0,0 @@ -NETBSD ------- - -.. versionadded:: 3.25 - -Set to true when the target system is NetBSD. diff --git a/Help/variable/OPENBSD.rst b/Help/variable/OPENBSD.rst deleted file mode 100644 index dd9b23d..0000000 --- a/Help/variable/OPENBSD.rst +++ /dev/null @@ -1,6 +0,0 @@ -OPENBSD -------- - -.. versionadded:: 3.25 - -Set to true when the target system is OpenBSD. diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index e045932..b5dc8d3 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -16,6 +16,8 @@ set(UNIX ) set(CYGWIN ) set(MSYS ) set(WIN32 ) +set(BSD ) +set(LINUX ) function(_cmake_record_install_prefix ) set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_VALUE "${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 9306ce6..22a25bd 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1840,7 +1840,11 @@ function(_ep_get_build_command else() set(cmd "${CMAKE_COMMAND}") endif() - set(args --build ".") + if(step STREQUAL "INSTALL") + set(args --install ".") + else() + set(args --build ".") + endif() get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) if (CMAKE_CFG_INTDIR AND @@ -1862,9 +1866,6 @@ function(_ep_get_build_command endif() list(APPEND args --config ${config}) endif() - if(step STREQUAL "INSTALL") - list(APPEND args --target install) - endif() # But for "TEST" drive the project with corresponding "ctest". if("x${step}x" STREQUAL "xTESTx") string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 3501317..7e69dfe 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -303,13 +303,16 @@ Commands ``<lowercaseName>-extra.cmake`` or ``<name>Extra.cmake`` file with the ``OPTIONAL`` flag (so the files can be missing and won't generate a warning). Similarly, if no config version file exists, a very simple - one will be written which sets ``PACKAGE_VERSION_COMPATIBLE`` to true. + one will be written which sets ``PACKAGE_VERSION_COMPATIBLE`` and + ``PACKAGE_VERSION_EXACT`` to true. This ensures all future calls to + :command:`find_package()` for the dependency will use the redirected + config file, regardless of any version requirements. CMake cannot automatically determine an arbitrary dependency's version, - so it cannot set ``PACKAGE_VERSION`` or ``PACKAGE_VERSION_EXACT``. + so it cannot set ``PACKAGE_VERSION``. When a dependency is pulled in via :command:`add_subdirectory` in the next step, it may choose to overwrite the generated config version file in :variable:`CMAKE_FIND_PACKAGE_REDIRECTS_DIR` with one that also sets - ``PACKAGE_VERSION``, and if appropriate, ``PACKAGE_VERSION_EXACT``. + ``PACKAGE_VERSION``. The dependency may also write a ``<lowercaseName>-extra.cmake`` or ``<name>Extra.cmake`` file to perform custom processing or define any variables that their normal (installed) package config file would @@ -822,7 +825,7 @@ details: CMake provides a FindGTest module which defines some variables that older projects may use instead of linking to the imported targets. To support -those cases, we can provide an extras file. In keeping with the +those cases, we can provide an extra file. In keeping with the "first to define, wins" philosophy of ``FetchContent``, we only write out that file if something else hasn't already done so. @@ -830,9 +833,9 @@ that file if something else hasn't already done so. FetchContent_MakeAvailable(googletest) - if(NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/googletest-extras.cmake AND - NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/googletestExtras.cmake) - file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/googletest-extras.cmake + if(NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/googletest-extra.cmake AND + NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/googletestExtra.cmake) + file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/googletest-extra.cmake [=[ if("${GTEST_LIBRARIES}" STREQUAL "" AND TARGET GTest::gtest) set(GTEST_LIBRARIES GTest::gtest) @@ -1894,13 +1897,13 @@ macro(FetchContent_MakeAvailable) set(__cmake_fcProvider_${__cmake_contentNameLower} YES) cmake_language(EVAL CODE "${__cmake_providerCommand}(${__cmake_providerArgs})") - unset(__cmake_fcProvider_${__cmake_contentNameLower}) list(POP_BACK __cmake_fcCurrentVarsStack __cmake_contentNameLower __cmake_contentName ) + unset(__cmake_fcProvider_${__cmake_contentNameLower}) unset(__cmake_providerArgs) unset(__cmake_addfpargs) unset(__cmake_fpargs) diff --git a/Modules/FetchContent/package-config-version.cmake.in b/Modules/FetchContent/package-config-version.cmake.in index 7f19094..9fcade7 100644 --- a/Modules/FetchContent/package-config-version.cmake.in +++ b/Modules/FetchContent/package-config-version.cmake.in @@ -1,5 +1,8 @@ # Automatically generated by CMake's FetchContent module. # Do not edit this file, it will be regenerated every time CMake runs. -# Version not available, assuming it is compatible +# Version not available, assuming it is compatible. We must also say it is an +# exact match to ensure find_package() calls with the EXACT keyword still get +# redirected. set(PACKAGE_VERSION_COMPATIBLE TRUE) +set(PACKAGE_VERSION_EXACT TRUE) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index a96fadd..2faab0e 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -391,11 +391,11 @@ function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) # library that has invalid or missing version information there would be warning # messages emitted by ld.so in the compiler output. In either case, we'll treat # the output as invalid. - if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available|command not found") + if(WRAPPER_OUTPUT MATCHES "undefined reference|unrecognized|need to set|no version information available|command not found") set(WRAPPER_RETURN 255) endif() # Ensure that no error output might be passed upwards. - if(NOT WRAPPER_RETURN EQUAL 0) + if(NOT WRAPPER_RETURN EQUAL "0") unset(WRAPPER_OUTPUT) else() # Strip leading whitespace @@ -441,13 +441,13 @@ function (_MPI_interrogate_compiler LANG) if(MSVC) get_filename_component(_MPI_UNDERLAYING_COMPILER "${_MPI_UNDERLAYING_COMPILER}" NAME) endif() - if("${LANG}" STREQUAL "C") + if(LANG STREQUAL "C") _MPI_env_set_ifnot(I_MPI_CC _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(MPICH_CC _MPI_UNDERLAYING_COMPILER) - elseif("${LANG}" STREQUAL "CXX") + elseif(LANG STREQUAL "CXX") _MPI_env_set_ifnot(I_MPI_CXX _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(MPICH_CXX _MPI_UNDERLAYING_COMPILER) - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") _MPI_env_set_ifnot(I_MPI_FC _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(MPICH_FC _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(I_MPI_F77 _MPI_UNDERLAYING_COMPILER) @@ -470,10 +470,10 @@ function (_MPI_interrogate_compiler LANG) # or a newer version of LAM/MPI, and implies that -showme:link will also work. # Open MPI also supports -show, but separates linker and compiler information _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) + if (MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") unset(MPI_COMPILE_CMDLINE) endif() endif() @@ -482,13 +482,13 @@ function (_MPI_interrogate_compiler LANG) # For modern versions, both do the same as -show. However, for old versions, they do differ # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the # removed MPI C++ bindings. - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) + if (MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") unset(MPI_COMPILE_CMDLINE) endif() endif() @@ -496,18 +496,18 @@ function (_MPI_interrogate_compiler LANG) # Cray compiler wrappers come usually without a separate mpicc/c++/ftn, but offer # --cray-print-opts=... - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "--cray-print-opts=cflags" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) + if (MPI_COMPILER_RETURN EQUAL "0") # Pass --no-as-needed so the mpi library is always linked. Otherwise, the # Cray compiler wrapper puts an --as-needed flag around the mpi library, # and it is not linked unless code directly refers to it. _MPI_check_compiler(${LANG} "--no-as-needed;--cray-print-opts=libs" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") unset(MPI_COMPILE_CMDLINE) unset(MPI_LINK_CMDLINE) endif() @@ -516,24 +516,24 @@ function (_MPI_interrogate_compiler LANG) # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the # -showme commands are more specialized. - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) endif() # Older versions of LAM/MPI have "-showme". Open MPI also supports this. # Unknown to MPICH, MVAPICH and Intel MPI. - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) endif() - if (MPI_COMPILER_RETURN EQUAL 0 AND DEFINED MPI_COMPILE_CMDLINE) + if (MPI_COMPILER_RETURN EQUAL "0" AND DEFINED MPI_COMPILE_CMDLINE) # Intel MPI can be run with -compchk or I_MPI_CHECK_COMPILER set to 1. # In this case, -show will be prepended with a line to the compiler checker. This is a script that performs # compatibility checks and returns a non-zero exit code together with an error if something fails. # It has to be called as "compchk.sh <arch> <compiler>". Here, <arch> is one out of 32 (i686), 64 (ia64) or 32e (x86_64). # The compiler is identified by filename, and can be either the MPI compiler or the underlying compiler. # NOTE: It is vital to run this script while the environment variables are set up, otherwise it can check the wrong compiler. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^([^\" ]+/compchk.sh|\"[^\"]+/compchk.sh\") +([^ ]+)") + if(MPI_COMPILE_CMDLINE MATCHES "^([^\" ]+/compchk.sh|\"[^\"]+/compchk.sh\") +([^ ]+)") # Now CMAKE_MATCH_1 contains the path to the compchk.sh file and CMAKE_MATCH_2 the architecture flag. unset(COMPILER_CHECKER_OUTPUT) execute_process( @@ -542,7 +542,7 @@ function (_MPI_interrogate_compiler LANG) ERROR_VARIABLE COMPILER_CHECKER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE MPI_COMPILER_RETURN) # If it returned a non-zero value, the check below will fail and cause the interrogation to be aborted. - if(NOT MPI_COMPILER_RETURN EQUAL 0) + if(NOT MPI_COMPILER_RETURN EQUAL "0") if(NOT MPI_FIND_QUIETLY) message(STATUS "Intel MPI compiler check failed: ${COMPILER_CHECKER_OUTPUT}") endif() @@ -554,13 +554,13 @@ function (_MPI_interrogate_compiler LANG) endif() # Revert changes to the environment made previously - if("${LANG}" STREQUAL "C") + if(LANG STREQUAL "C") _MPI_env_unset_ifnot(I_MPI_CC) _MPI_env_unset_ifnot(MPICH_CC) - elseif("${LANG}" STREQUAL "CXX") + elseif(LANG STREQUAL "CXX") _MPI_env_unset_ifnot(I_MPI_CXX) _MPI_env_unset_ifnot(MPICH_CXX) - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") _MPI_env_unset_ifnot(I_MPI_FC) _MPI_env_unset_ifnot(MPICH_FC) _MPI_env_unset_ifnot(I_MPI_F77) @@ -572,7 +572,7 @@ function (_MPI_interrogate_compiler LANG) _MPI_env_unset_ifnot(I_MPI_DEBUG_INFO_STRIP) _MPI_env_unset_ifnot(I_MPI_FORT_BIND) - if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) + if (NOT (MPI_COMPILER_RETURN EQUAL "0") OR NOT (DEFINED MPI_COMPILE_CMDLINE)) # Cannot interrogate this compiler, so exit. set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) return() @@ -613,13 +613,13 @@ function (_MPI_interrogate_compiler LANG) if(UNIX) # At this point, we obtained some output from a compiler wrapper that works. # We'll now try to parse it into variables with meaning to us. - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") # If MPICH (and derivates) didn't recognize the Fortran compiler include flag during configuration, # they'll return a set of three commands, consisting out of a symlink command for mpif.h, # the actual compiler command and deletion of the created symlink. # Especially with M(VA)PICH-1, this appears to happen erroneously, and therefore we should translate # this output into an additional include directory and then drop it from the output. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") + if(MPI_COMPILE_CMDLINE MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") @@ -651,7 +651,7 @@ function (_MPI_interrogate_compiler LANG) # produce inconsistent results with the regularly flags. # Similarly, aliasing flags do not belong into our flag array. # Also strip out `-framework` flags. - if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce]|ramework)") + if(NOT _MPI_COMPILE_OPTION MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce]|ramework)") list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") endif() endforeach() @@ -673,7 +673,7 @@ function (_MPI_interrogate_compiler LANG) foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) string(REGEX REPLACE "^ ?${_MPI_PREPROCESSOR_FLAG_REGEX}-D *" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") + if(NOT _MPI_COMPILE_DEFINITION MATCHES "^_FORTIFY_SOURCE.*") list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") endif() endforeach() @@ -788,7 +788,7 @@ function (_MPI_interrogate_compiler LANG) # decide how to link it based on file type, not based on a prefix like 'lib'. set(_MPI_LIB_SUFFIX_REGEX "${CMAKE_STATIC_LIBRARY_SUFFIX}") if(DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX) - if(NOT ("${CMAKE_IMPORT_LIBRARY_SUFFIX}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")) + if(NOT (CMAKE_IMPORT_LIBRARY_SUFFIX STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)) string(APPEND _MPI_LIB_SUFFIX_REGEX "|${CMAKE_IMPORT_LIBRARY_SUFFIX}") endif() else() @@ -804,7 +804,7 @@ function (_MPI_interrogate_compiler LANG) if(_MPI_LIB_NAME_TEST STREQUAL "") string(REGEX REPLACE "^ +\"?|\"? +$" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + if(NOT _MPI_LIB_PATH STREQUAL "") list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") else() list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") @@ -845,7 +845,7 @@ function (_MPI_interrogate_compiler LANG) foreach(_MPI_LINK_DIRECTORY IN LISTS MPI_LINK_DIRECTORIES_LEFTOVER) file(TO_NATIVE_PATH "${_MPI_LINK_DIRECTORY}" _MPI_LINK_DIRECTORY_ACTUAL) string(FIND "${_MPI_LINK_DIRECTORY_ACTUAL}" " " _MPI_LINK_DIRECTORY_CONTAINS_SPACE) - if(NOT _MPI_LINK_DIRECTORY_CONTAINS_SPACE EQUAL -1) + if(NOT _MPI_LINK_DIRECTORY_CONTAINS_SPACE EQUAL "-1") set(_MPI_LINK_DIRECTORY_ACTUAL "\"${_MPI_LINK_DIRECTORY_ACTUAL}\"") endif() if(MPI_LINK_FLAGS_WORK) @@ -871,7 +871,7 @@ function (_MPI_interrogate_compiler LANG) # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to # link it in that case. -lpthread is covered by the normal library treatment on the other hand. - if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") + if(MPI_COMPILE_CMDLINE MATCHES "-pthread") list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") if(MPI_LINK_FLAGS_WORK) string(APPEND MPI_LINK_FLAGS_WORK " -pthread") @@ -918,10 +918,10 @@ function(_MPI_guess_settings LANG) # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers # or import libraries and vice versa. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") + if(NOT MPI_GUESS_LIBRARY_NAME OR MPI_GUESS_LIBRARY_NAME STREQUAL "MSMPI") # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed # Microsoft MPI. - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + if(CMAKE_SIZEOF_VOID_P EQUAL "8") file(TO_CMAKE_PATH "$ENV{MSMPI_LIB64}" MPI_MSMPI_LIB_PATH) file(TO_CMAKE_PATH "$ENV{MSMPI_INC}/x64" MPI_MSMPI_INC_PATH_EXTRA) else() @@ -975,9 +975,9 @@ function(_MPI_guess_settings LANG) # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. - if ("${LANG}" STREQUAL "Fortran") + if (LANG STREQUAL "Fortran") set(MPI_MSMPI_CALLINGCONVS c) - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + if(CMAKE_SIZEOF_VOID_P EQUAL "4") list(APPEND MPI_MSMPI_CALLINGCONVS s) endif() foreach(mpistrlenpos IN ITEMS e m) @@ -1025,7 +1025,7 @@ function(_MPI_guess_settings LANG) # At this point there's not many MPIs that we could still consider. # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. - if(NOT MPI_GUESS_FOUND AND (NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2")) + if(NOT MPI_GUESS_FOUND AND (NOT MPI_GUESS_LIBRARY_NAME OR MPI_GUESS_LIBRARY_NAME STREQUAL "MPICH2")) set(MPI_MPICH_PREFIX_PATHS "$ENV{ProgramW6432}/MPICH2/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" @@ -1042,7 +1042,7 @@ function(_MPI_guess_settings LANG) set(MPI_MPICH_LIB_NAMES "mpi") # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. - if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) + if(LANG STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) find_library(MPI_cxx_LIBRARY NAMES cxx HINTS ${MPI_MPICH_PREFIX_PATHS}) @@ -1055,7 +1055,7 @@ function(_MPI_guess_settings LANG) # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") find_library(MPI_fmpich2_LIBRARY NAMES fmpich2 HINTS ${MPI_MPICH_PREFIX_PATHS}) @@ -1103,7 +1103,7 @@ function(_MPI_guess_settings LANG) endfunction() function(_MPI_adjust_compile_definitions LANG) - if("${LANG}" STREQUAL "CXX") + if(LANG STREQUAL "CXX") # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ # bindings in MPI-2. if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") @@ -1119,7 +1119,7 @@ endfunction() macro(_MPI_assemble_libraries LANG) set(MPI_${LANG}_LIBRARIES "") # Only for libraries do we need to check whether the compiler's linking stage is separate. - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER OR NOT MPI_${LANG}_WORKS_IMPLICIT) foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) endforeach() @@ -1131,7 +1131,7 @@ macro(_MPI_assemble_include_dirs LANG) ${MPI_${LANG}_COMPILER_INCLUDE_DIRS} ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} ) - if("${LANG}" MATCHES "(C|CXX)") + if(LANG MATCHES "^(C|CXX)$") if(MPI_${LANG}_HEADER_DIR) list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") endif() @@ -1156,7 +1156,7 @@ macro(_MPI_split_include_dirs LANG) # We try to find the headers/modules among those paths (and system paths) # For C/C++, we just need to have a look for mpi.h. - if("${LANG}" MATCHES "(C|CXX)") + if(LANG MATCHES "^(C|CXX)$") find_path(MPI_${LANG}_HEADER_DIR "mpi.h" HINTS ${MPI_${LANG}_COMPILER_INCLUDE_DIRS} @@ -1171,7 +1171,7 @@ macro(_MPI_split_include_dirs LANG) # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI # only provides Fortran 77 and - if mpi.f90 is built - potentially # a Fortran 90 module. - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" HINTS ${MPI_${LANG}_COMPILER_INCLUDE_DIRS} @@ -1238,20 +1238,20 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE set(SRC_DIR "${CMAKE_ROOT}/Modules/FindMPI") set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") unset(MPI_TEST_COMPILE_DEFINITIONS) - if("${LANG}" STREQUAL "Fortran") - if("${MODE}" STREQUAL "F90_MODULE") + if(LANG STREQUAL "Fortran") + if(MODE STREQUAL "F90_MODULE") set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") - elseif("${MODE}" STREQUAL "F08_MODULE") + elseif(MODE STREQUAL "F08_MODULE") set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") else() # F77 header set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") endif() configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") - elseif("${LANG}" STREQUAL "CXX") + elseif(LANG STREQUAL "CXX") configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") - if("${MODE}" STREQUAL "TEST_MPICXX") + if(MODE STREQUAL "TEST_MPICXX") set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) endif() else() # C @@ -1290,7 +1290,7 @@ macro(_MPI_check_lang_works LANG SUPPRESS_ERRORS) # - *both*, the mpi module and 'mpif.h' # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. if( NOT MPI_${LANG}_WORKS ) - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE ${SUPPRESS_ERRORS}) _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE ${SUPPRESS_ERRORS}) @@ -1339,11 +1339,11 @@ macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) endmacro() set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/<name> # We enumerate the subfolders and append each as a prefix MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") +elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD ships mpich under the normal system paths - but available openmpi implementations # will be found in /usr/local/mpi/<name> MPI_search_mpi_prefix_folder("/usr/local/mpi") @@ -1410,7 +1410,7 @@ if(NOT MPI_IGNORE_LEGACY_VARIABLES) if(MPI_${LANG}_COMPILE_FLAGS) separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) - if("${_MPI_FLAG}" MATCHES "^ *-D([^ ]+)") + if(_MPI_FLAG MATCHES "^ *-D([^ ]+)") list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") else() list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}") @@ -1459,7 +1459,7 @@ foreach(LANG IN ITEMS C CXX Fortran) set(_MPI_FIND_${LANG} TRUE) elseif( LANG IN_LIST MPI_FIND_COMPONENTS) set(_MPI_FIND_${LANG} TRUE) - elseif( "${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) + elseif( LANG STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) set(_MPI_FIND_${LANG} TRUE) else() set(_MPI_FIND_${LANG} FALSE) @@ -1471,7 +1471,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() if(_MPI_FIND_${LANG}) - if( "${LANG}" STREQUAL "CXX" AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) + if( LANG STREQUAL "CXX" AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) option(MPI_CXX_SKIP_MPICXX "If true, the MPI-2 C++ bindings are disabled using definitions." FALSE) mark_as_advanced(MPI_CXX_SKIP_MPICXX) endif() @@ -1493,7 +1493,7 @@ foreach(LANG IN ITEMS C CXX Fortran) set(MPI_${LANG}_TRIED_IMPLICIT TRUE) endif() - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER OR NOT MPI_${LANG}_WORKS) set(MPI_${LANG}_WRAPPER_FOUND FALSE) set(MPI_PINNED_COMPILER FALSE) @@ -1529,7 +1529,7 @@ foreach(LANG IN ITEMS C CXX Fortran) DOC "MPI compiler for ${LANG}" ) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + if(MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) set(MPI_PINNED_COMPILER TRUE) # If we haven't made the implicit compiler test yet, perform it now. @@ -1590,7 +1590,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() if(_MPI_PKG AND PKG_CONFIG_FOUND) pkg_check_modules("MPI_${LANG}_PKG" "${_MPI_PKG}") - if("${MPI_${LANG}_PKG_FOUND}") + if(MPI_${LANG}_PKG_FOUND) set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_${LANG}_PKG_CFLAGS} CACHE STRING "MPI ${LANG} compilation options" FORCE) set(MPI_${LANG}_INCLUDE_PATH ${MPI_${LANG}_PKG_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} include directories" FORCE) set(MPI_${LANG}_LINK_FLAGS ${MPI_${LANG}_PKG_LDFLAGS} CACHE STRING "MPI ${LANG} linker flags" FORCE) @@ -1611,10 +1611,10 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() - if(NOT MPI_SKIP_GUESSING AND NOT "${MPI_${LANG}_PKG_FOUND}") + if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_PKG_FOUND) # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. - if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) + if(LANG STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) set(MPI_${LANG}_COMPILER_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} compiler wrapper include directories") @@ -1628,7 +1628,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) _MPI_split_include_dirs(${LANG}) _MPI_assemble_include_dirs(${LANG}) else() @@ -1665,7 +1665,7 @@ foreach(LANG IN ITEMS C CXX Fortran) # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. if(MPI_${LANG}_WORKS) - if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) + if(LANG STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE FALSE) if(MPI_RESULT_${LANG}_test_mpi_MPICXX) @@ -1689,7 +1689,7 @@ foreach(LANG IN ITEMS C CXX Fortran) # Fortran parameters, since those depend on the method of consumption. # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") if(MPI_${LANG}_HAVE_F08_MODULE) set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) elseif(MPI_${LANG}_HAVE_F90_MODULE) @@ -1705,7 +1705,7 @@ foreach(LANG IN ITEMS C CXX Fortran) _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE FALSE) if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + if(_MPI_VERSION_STRING MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") @@ -1724,12 +1724,12 @@ foreach(LANG IN ITEMS C CXX Fortran) _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE FALSE) if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") - if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES + if(MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod} MATCHES ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") - if("${CMAKE_MATCH_1}" STREQUAL "T") + if(CMAKE_MATCH_1 STREQUAL "T") set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) endif() - if("${CMAKE_MATCH_2}" STREQUAL "T") + if(CMAKE_MATCH_2 STREQUAL "T") set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) endif() endif() @@ -1744,7 +1744,7 @@ foreach(LANG IN ITEMS C CXX Fortran) # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. if(NOT DEFINED MPI_${LANG}_VERSION) file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + if(_MPI_VERSION_STRING MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") @@ -1764,7 +1764,7 @@ foreach(LANG IN ITEMS C CXX Fortran) if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE FALSE) if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND - "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") + MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} EQUAL "0") string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" MPI_${LANG}_LIBRARY_VERSION_STRING) else() @@ -1778,12 +1778,12 @@ foreach(LANG IN ITEMS C CXX Fortran) set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) unset(MPI_${LANG}_REQUIRED_VARS) - if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + if (NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") endforeach() list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") # For Fortran we only need one of the module or header directories to have *some* support for MPI. if(NOT MPI_${LANG}_MODULE_DIR) list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") @@ -1883,7 +1883,7 @@ else() endif() list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) -if (MPI_NUMLIBS GREATER 1) +if (MPI_NUMLIBS GREATER "1") set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index fbcf7cd..6de7dbf 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -535,9 +535,10 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(VERSION_MSG "") set(VERSION_OK TRUE) - # check with DEFINED here as the requested or found version may be "0" + # check that the version variable is not empty to avoid emitting a misleading + # message (i.e. `Found unsuitable version ""`) if (DEFINED ${_NAME}_FIND_VERSION) - if(DEFINED ${FPHSA_VERSION_VAR}) + if(NOT "${${FPHSA_VERSION_VAR}}" STREQUAL "") set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) if (FPHSA_HANDLE_VERSION_RANGE) set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) @@ -547,6 +548,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG ${FPCV_HANDLE_VERSION_RANGE}) else() + set(VERSION_OK FALSE) # if the package was not found, but a version was given, add that to the output: if(${_NAME}_FIND_VERSION_EXACT) set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index fb35ff0..4bd7006 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -43,6 +43,8 @@ set(module_symbols MYMODULE_mp_MYSUB # Intel on Windows mymodule_mysub_ # PGI mymodule_MP_mysub # NAG + _QMmy_modulePmy_sub # LLVMFlang + _QMmymodulePmysub # LLVMFlang ${FortranCInterface_MODULE_SYMBOLS} ) list(REMOVE_DUPLICATES module_symbols) diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 72e5544..567fc37 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -95,8 +95,8 @@ set(_case_MYSUB "UPPER") set(_case_MY_SUB "UPPER") set(_global_regex "^(_*)(mysub|MYSUB)([_$]*)$") set(_global__regex "^(_*)(my_sub|MY_SUB)([_$]*)$") -set(_module_regex "^(_*)(mymodule|MYMODULE)([A-Za-z_$]*)(mysub|MYSUB)([_$]*)$") -set(_module__regex "^(_*)(my_module|MY_MODULE)([A-Za-z_$]*)(my_sub|MY_SUB)([_$]*)$") +set(_module_regex "^(_*)([A-Za-z$]*)(mymodule|MYMODULE)([A-Za-z_$]*)(mysub|MYSUB)([_$]*)$") +set(_module__regex "^(_*)([A-Za-z$]*)(my_module|MY_MODULE)([A-Za-z_$]*)(my_sub|MY_SUB)([_$]*)$") # Parse the symbol names. foreach(symbol ${FortranCInterface_SYMBOLS}) @@ -115,7 +115,7 @@ foreach(symbol ${FortranCInterface_SYMBOLS}) # Look for module symbols. string(REGEX REPLACE "${_module_${form}regex}" - "\\1;\\2;\\3;\\4;\\5" pieces "${symbol}") + "\\1\\2;\\3;\\4;\\5;\\6" pieces "${symbol}") list(LENGTH pieces len) if(len EQUAL 5) set(FortranCInterface_MODULE_${form}SYMBOL "${symbol}") diff --git a/Modules/Platform/DragonFly.cmake b/Modules/Platform/DragonFly.cmake index d8bc05a..994ba79 100644 --- a/Modules/Platform/DragonFly.cmake +++ b/Modules/Platform/DragonFly.cmake @@ -3,8 +3,7 @@ # see http://archive.netbsd.se/?ml=dfbsd-users&a=2007-07&m=4678361 include(Platform/FreeBSD) -unset(FREEBSD) -set(DRAGONFLYBSD 1) +set(BSD "DragonFlyBSD") # DragonFly BSD requires -z origin to enable $ORIGIN expansion in RPATH. # This is not required for FreeBSD since 10.2-RELEASE. diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index e968a78..9cd9399 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -1,5 +1,4 @@ -set(FREEBSD 1) -set(BSD 1) +set(BSD "FreeBSD") set(CMAKE_DL_LIBS "") set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index a64bf0b..52c6594 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -1,5 +1,4 @@ -set(NETBSD 1) -set(BSD 1) +set(BSD "NetBSD") set(CMAKE_DL_LIBS "") set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index f6b955a..51ea60d 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -1,6 +1,5 @@ include(Platform/NetBSD) -unset(NETBSD) -set(OPENBSD 1) +set(BSD "OpenBSD") # On OpenBSD, the compile time linker does not share it's configuration with # the runtime linker. This will extract the library search paths from the diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 35b1704..5b653ad 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -377,6 +377,7 @@ set(SWIG_EXTRA_LIBRARIES "") set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py") set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java") set(SWIG_CSHARP_EXTRA_FILE_EXTENSIONS ".cs" "PINVOKE.cs") +set(SWIG_PERL_EXTRA_FILE_EXTENSIONS ".pm") set(SWIG_MANAGE_SUPPORT_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/UseSWIG/ManageSupportFiles.cmake") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d52bbbe..bd67b0d 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 24) -set(CMake_VERSION_PATCH 20220908) +set(CMake_VERSION_PATCH 20220914) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d1fad62..daaf5fd 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -363,7 +363,11 @@ void cmCTestTestHandler::PopulateCustomVectors(cmMakefile* mf) cmValue dval = mf->GetDefinition("CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION"); if (dval) { - this->SetTestOutputTruncation(dval); + if (!this->SetTestOutputTruncation(dval)) { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Invalid value for CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION: " + << dval << std::endl); + } } } diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index c168a45..5b216bb 100644 --- a/Source/cmCMakePresetsGraph.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -1115,7 +1115,7 @@ const char* cmCMakePresetsGraph::ResultToString(ReadFileResult result) return "File version must be 2 or higher for build and test preset " "support."; case ReadFileResult::PACKAGE_PRESETS_UNSUPPORTED: - return "File version must be 5 or higher for package preset support"; + return "File version must be 6 or higher for package preset support"; case ReadFileResult::INCLUDE_UNSUPPORTED: return "File version must be 4 or higher for include support"; case ReadFileResult::INVALID_INCLUDE: diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 0a6c359..654c9a3 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -13,6 +13,7 @@ #include <cmext/string_view> #include "cmsys/Directory.hxx" +#include "cmsys/FStream.hxx" #include "cmArgumentParser.h" #include "cmExportTryCompileFileGenerator.h" @@ -694,6 +695,17 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, } fprintf(fout, ")\n"); + /* Write out the output location of the target we are building */ + std::string perConfigGenex; + if (this->Makefile->GetGlobalGenerator()->IsMultiConfig()) { + perConfigGenex = "_$<UPPER_CASE:$<CONFIG>>"; + } + fprintf(fout, + "file(GENERATE OUTPUT " + "\"${CMAKE_BINARY_DIR}/%s%s_loc\"\n", + targetName.c_str(), perConfigGenex.c_str()); + fprintf(fout, " CONTENT $<TARGET_FILE:%s>)\n", targetName.c_str()); + bool warnCMP0067 = false; bool honorStandard = true; @@ -935,7 +947,7 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, if (this->SrcFileSignature) { std::string copyFileErrorMessage; - this->FindOutputFile(targetName, targetType); + this->FindOutputFile(targetName); if ((res == 0) && arguments.CopyFileTo) { std::string const& copyFile = *arguments.CopyFileTo; @@ -1035,62 +1047,37 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir) } } -void cmCoreTryCompile::FindOutputFile(const std::string& targetName, - cmStateEnums::TargetType targetType) +void cmCoreTryCompile::FindOutputFile(const std::string& targetName) { this->FindErrorMessage.clear(); this->OutputFile.clear(); std::string tmpOutputFile = "/"; - if (targetType == cmStateEnums::EXECUTABLE) { - tmpOutputFile += targetName; - tmpOutputFile += - this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX"); - } else // if (targetType == cmStateEnums::STATIC_LIBRARY) - { - tmpOutputFile += - this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); - tmpOutputFile += targetName; - tmpOutputFile += - this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); - } + tmpOutputFile += targetName; - // a list of directories where to search for the compilation result - // at first directly in the binary dir - std::vector<std::string> searchDirs; - searchDirs.emplace_back(); - - cmValue config = - this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); - // if a config was specified try that first - if (cmNonempty(config)) { - std::string tmp = cmStrCat('/', *config); - searchDirs.emplace_back(std::move(tmp)); + if (this->Makefile->GetGlobalGenerator()->IsMultiConfig()) { + tmpOutputFile += "_DEBUG"; } - searchDirs.emplace_back("/Debug"); - - // handle app-bundles (for targeting apple-platforms) - std::string app = "/" + targetName + ".app"; - if (cmNonempty(config)) { - std::string tmp = cmStrCat('/', *config, app); - searchDirs.emplace_back(std::move(tmp)); + tmpOutputFile += "_loc"; + + std::string command = cmStrCat(this->BinaryDirectory, tmpOutputFile); + if (!cmSystemTools::FileExists(command)) { + std::ostringstream emsg; + emsg << "Unable to find the recorded try_compile output location:\n"; + emsg << cmStrCat(" ", command, "\n"); + this->FindErrorMessage = emsg.str(); + return; } - std::string tmp = "/Debug" + app; - searchDirs.emplace_back(std::move(tmp)); - searchDirs.emplace_back(std::move(app)); - - searchDirs.emplace_back("/Development"); - for (std::string const& sdir : searchDirs) { - std::string command = cmStrCat(this->BinaryDirectory, sdir, tmpOutputFile); - if (cmSystemTools::FileExists(command)) { - this->OutputFile = cmSystemTools::CollapseFullPath(command); - return; - } + std::string outputFileLocation; + cmsys::ifstream ifs(command.c_str()); + cmSystemTools::GetLineFromStream(ifs, outputFileLocation); + if (!cmSystemTools::FileExists(outputFileLocation)) { + std::ostringstream emsg; + emsg << "Recorded try_compile output location doesn't exist:\n"; + emsg << cmStrCat(" ", outputFileLocation, "\n"); + this->FindErrorMessage = emsg.str(); + return; } - std::ostringstream emsg; - emsg << "Unable to find the executable at any of:\n"; - emsg << cmWrap(" " + this->BinaryDirectory, searchDirs, tmpOutputFile, "\n") - << "\n"; - this->FindErrorMessage = emsg.str(); + this->OutputFile = cmSystemTools::CollapseFullPath(outputFileLocation); } diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index b483f0f..729aa9f 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -94,8 +94,7 @@ public: TryCompileCode. The result is stored in OutputFile. If nothing is found, the error message is stored in FindErrorMessage. */ - void FindOutputFile(const std::string& targetName, - cmStateEnums::TargetType targetType); + void FindOutputFile(const std::string& targetName); std::string BinaryDirectory; std::string OutputFile; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 54c900f..7f1e426 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8666,7 +8666,7 @@ bool cmGeneratorTarget::AddHeaderSetVerification() verifyTarget->SetProperty("UNITY_BUILD", "OFF"); cm::optional<std::map<std::string, cmValue>> perConfigCompileDefinitions; - verifyTarget->FinalizeTargetCompileInfo( + verifyTarget->FinalizeTargetConfiguration( this->Makefile->GetCompileDefinitionsEntries(), perConfigCompileDefinitions); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 07ad1e8..09aaa24 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1501,7 +1501,7 @@ bool cmGlobalGenerator::Compute() if (!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) { return false; } - this->FinalizeTargetCompileInfo(); + this->FinalizeTargetConfiguration(); this->CreateGenerationObjects(); @@ -1825,7 +1825,7 @@ cmGlobalGenerator::CreateMSVC60LinkLineComputer( cm::make_unique<cmMSVC60LinkLineComputer>(outputConverter, stateDir)); } -void cmGlobalGenerator::FinalizeTargetCompileInfo() +void cmGlobalGenerator::FinalizeTargetConfiguration() { std::vector<std::string> const langs = this->CMakeInstance->GetState()->GetEnabledLanguages(); @@ -1838,8 +1838,8 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() for (auto& target : mf->GetTargets()) { cmTarget* t = &target.second; - t->FinalizeTargetCompileInfo(noConfigCompileDefinitions, - perConfigCompileDefinitions); + t->FinalizeTargetConfiguration(noConfigCompileDefinitions, + perConfigCompileDefinitions); } // The standard include directories for each language diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index dcef070..6e3072b 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -694,7 +694,7 @@ private: void WriteSummary(); void WriteSummary(cmGeneratorTarget* target); - void FinalizeTargetCompileInfo(); + void FinalizeTargetConfiguration(); virtual void ForceLinkerLanguages(); diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index ed89e91..2b8f836 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -35,7 +35,5 @@ bool cmLinkLibrariesCommand(std::vector<std::string> const& args, mf.AppendProperty("LINK_LIBRARIES", *i); } - mf.CheckProperty("LINK_LIBRARIES"); - return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 760ed5f..cf5d880 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4035,31 +4035,6 @@ std::vector<std::string> cmMakefile::GetPropertyKeys() const return this->StateSnapshot.GetDirectory().GetPropertyKeys(); } -void cmMakefile::CheckProperty(const std::string& prop) const -{ - // Certain properties need checking. - if (prop == "LINK_LIBRARIES") { - if (cmValue value = this->GetProperty(prop)) { - // Look for <LINK_LIBRARY:> internal pattern - static cmsys::RegularExpression linkPattern( - "(^|;)(</?LINK_(LIBRARY|GROUP):[^;>]*>)(;|$)"); - if (!linkPattern.find(value)) { - return; - } - - // Report an error. - this->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Property ", prop, " contains the invalid item \"", - linkPattern.match(2), "\". The ", prop, - " property may contain the generator-expression \"$<LINK_", - linkPattern.match(3), - ":...>\" which may be used to specify how the libraries are " - "linked.")); - } - } -} - cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const { auto i = this->Targets.find(name); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1763177..873454d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -808,7 +808,6 @@ public: cmValue GetProperty(const std::string& prop, bool chain) const; bool GetPropertyAsBool(const std::string& prop) const; std::vector<std::string> GetPropertyKeys() const; - void CheckProperty(const std::string& prop) const; //! Initialize a makefile from its parent void InitializeFromParent(cmMakefile* parent); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 8adaa6c..4753e61 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2175,18 +2175,9 @@ void cmQtAutoMocUicT::JobMocsCompilationT::Process() if (this->MocEval().CompFiles.empty()) { // Placeholder content - cmCryptoHash hash(cmCryptoHash::AlgoSHA256); - const std::string hashedPath = hash.HashString(compAbs); - const std::string functionName = - "cmake_automoc_silence_linker_warning" + hashedPath; - content += "// No files found that require moc or the moc files are " "included\n" - "void " + - functionName + - "();\n" - "void " + - functionName + "() {}\n"; + "enum some_compilers { need_more_than_nothing };\n"; } else { // Valid content const bool mc = this->BaseConst().MultiConfig; diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index f73df8f..c51650a 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -317,6 +317,25 @@ void cmStateSnapshot::SetDefaultDefinitions() this->SetDefinition("CMAKE_HOST_SOLARIS", "1"); #endif +#if defined(__OpenBSD__) + this->SetDefinition("BSD", "OpenBSD"); + this->SetDefinition("CMAKE_HOST_BSD", "OpenBSD"); +#elif defined(__FreeBSD__) + this->SetDefinition("BSD", "FreeBSD"); + this->SetDefinition("CMAKE_HOST_BSD", "FreeBSD"); +#elif defined(__NetBSD__) + this->SetDefinition("BSD", "NetBSD"); + this->SetDefinition("CMAKE_HOST_BSD", "NetBSD"); +#elif defined(__DragonFly__) + this->SetDefinition("BSD", "DragonFlyBSD"); + this->SetDefinition("CMAKE_HOST_BSD", "DragonFlyBSD"); +#endif + +#if defined(__linux__) + this->SetDefinition("LINUX", "1"); + this->SetDefinition("CMAKE_HOST_LINUX", "1"); +#endif + this->SetDefinition("CMAKE_MAJOR_VERSION", std::to_string(cmVersion::GetMajorVersion())); this->SetDefinition("CMAKE_MINOR_VERSION", diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index eb3feaa..25ff3bf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1947,7 +1947,41 @@ void cmTarget::AppendBuildInterfaceIncludes() } } -void cmTarget::FinalizeTargetCompileInfo( +namespace { +bool CheckLinkLibraryPattern(cm::string_view property, + const std::vector<BT<std::string>>& value, + cmake* context) +{ + // Look for <LINK_LIBRARY:> and </LINK_LIBRARY:> internal tags + static cmsys::RegularExpression linkPattern( + "(^|;)(</?LINK_(LIBRARY|GROUP):[^;>]*>)(;|$)"); + + bool isValid = true; + + for (const auto& item : value) { + if (!linkPattern.find(item.Value)) { + continue; + } + + isValid = false; + + // Report an error. + context->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat( + "Property ", property, " contains the invalid item \"", + linkPattern.match(2), "\". The ", property, + " property may contain the generator-expression \"$<LINK_", + linkPattern.match(3), + ":...>\" which may be used to specify how the libraries are linked."), + item.Backtrace); + } + + return isValid; +} +} + +void cmTarget::FinalizeTargetConfiguration( const cmBTStringRange& noConfigCompileDefinitions, cm::optional<std::map<std::string, cmValue>>& perConfigCompileDefinitions) { @@ -1955,6 +1989,18 @@ void cmTarget::FinalizeTargetCompileInfo( return; } + if (!CheckLinkLibraryPattern("LINK_LIBRARIES"_s, + this->impl->LinkImplementationPropertyEntries, + this->GetMakefile()->GetCMakeInstance()) || + !CheckLinkLibraryPattern("INTERFACE_LINK_LIBRARIES"_s, + this->impl->LinkInterfacePropertyEntries, + this->GetMakefile()->GetCMakeInstance()) || + !CheckLinkLibraryPattern("INTERFACE_LINK_LIBRARIES_DIRECT"_s, + this->impl->LinkInterfaceDirectPropertyEntries, + this->GetMakefile()->GetCMakeInstance())) { + return; + } + this->AppendBuildInterfaceIncludes(); if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -2035,27 +2081,6 @@ void cmTarget::InsertPrecompileHeader(BT<std::string> const& entry) } namespace { -void CheckLinkLibraryPattern(const std::string& property, - const std::string& value, cmMakefile* context) -{ - // Look for <LINK_LIBRARY:> and </LINK_LIBRARY:> internal tags - static cmsys::RegularExpression linkPattern( - "(^|;)(</?LINK_(LIBRARY|GROUP):[^;>]*>)(;|$)"); - if (!linkPattern.find(value)) { - return; - } - - // Report an error. - context->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat( - "Property ", property, " contains the invalid item \"", - linkPattern.match(2), "\". The ", property, - " property may contain the generator-expression \"$<LINK_", - linkPattern.match(3), - ":...>\" which may be used to specify how the libraries are linked.")); -} - void CheckLINK_INTERFACE_LIBRARIES(const std::string& prop, const std::string& value, cmMakefile* context, bool imported) @@ -2090,13 +2115,6 @@ void CheckLINK_INTERFACE_LIBRARIES(const std::string& prop, } context->IssueMessage(MessageType::FATAL_ERROR, e.str()); } - - CheckLinkLibraryPattern(base, value, context); -} - -void CheckLINK_LIBRARIES(const std::string& value, cmMakefile* context) -{ - CheckLinkLibraryPattern("LINK_LIBRARIES", value, context); } void CheckINTERFACE_LINK_LIBRARIES(const std::string& value, @@ -2117,8 +2135,6 @@ void CheckINTERFACE_LINK_LIBRARIES(const std::string& value, context->IssueMessage(MessageType::FATAL_ERROR, e.str()); } - - CheckLinkLibraryPattern("INTERFACE_LINK_LIBRARIES", value, context); } void CheckIMPORTED_GLOBAL(const cmTarget* target, cmMakefile* context) @@ -2151,10 +2167,6 @@ void cmTarget::CheckProperty(const std::string& prop, if (cmValue value = this->GetProperty(prop)) { CheckLINK_INTERFACE_LIBRARIES(prop, *value, context, true); } - } else if (prop == "LINK_LIBRARIES") { - if (cmValue value = this->GetProperty(prop)) { - CheckLINK_LIBRARIES(*value, context); - } } else if (prop == "INTERFACE_LINK_LIBRARIES") { if (cmValue value = this->GetProperty(prop)) { CheckINTERFACE_LINK_LIBRARIES(*value, context); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1550f5b..38bd036 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -238,7 +238,7 @@ public: void InsertPrecompileHeader(BT<std::string> const& entry); void AppendBuildInterfaceIncludes(); - void FinalizeTargetCompileInfo( + void FinalizeTargetConfiguration( const cmBTStringRange& noConfigCompileDefinitions, cm::optional<std::map<std::string, cmValue>>& perConfigCompileDefinitions); diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index fb03b62..0b123b2 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -379,9 +379,6 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args, target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); } - target->CheckProperty("LINK_LIBRARIES", &mf); - target->CheckProperty("INTERFACE_LINK_LIBRARIES", &mf); - return true; } diff --git a/Tests/RunCMake/CMakePresetsPackage/UnsupportedVersion-configure-x-stderr.txt b/Tests/RunCMake/CMakePresetsPackage/UnsupportedVersion-configure-x-stderr.txt index 325af70..4c461e3 100644 --- a/Tests/RunCMake/CMakePresetsPackage/UnsupportedVersion-configure-x-stderr.txt +++ b/Tests/RunCMake/CMakePresetsPackage/UnsupportedVersion-configure-x-stderr.txt @@ -1,2 +1,2 @@ ^CMake Error: Could not read presets from [^ -]*/Tests/RunCMake/CMakePresetsPackage/UnsupportedVersion: File version must be 5 or higher for package preset support$ +]*/Tests/RunCMake/CMakePresetsPackage/UnsupportedVersion: File version must be 6 or higher for package preset support$ diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 2ac1f36..df3e82a 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -294,6 +294,7 @@ endfunction() run_TestOutputTruncation("head" "\\.\\.\\.6789") run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89") run_TestOutputTruncation("tail" "12345\\.\\.\\.") +run_TestOutputTruncation("bad" "") # Test --stop-on-failure function(run_stop_on_failure) diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt new file mode 100644 index 0000000..6afc02b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Invalid value for '--test-output-truncation': bad$ diff --git a/Tests/RunCMake/CommandLine/P_working-dir.cmake b/Tests/RunCMake/CommandLine/P_working-dir.cmake index 4ea0293..e2c0378 100644 --- a/Tests/RunCMake/CommandLine/P_working-dir.cmake +++ b/Tests/RunCMake/CommandLine/P_working-dir.cmake @@ -9,6 +9,11 @@ foreach(d CMAKE_BINARY_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRE if(EXPECTED_WORKING_DIR STREQUAL "${${d}}") message(STATUS "${d} is the expected working directory (${EXPECTED_WORKING_DIR})") else() - message(FATAL_ERROR "${d} = \"${${d}}\" is not the expected working directory (${EXPECTED_WORKING_DIR})") + get_filename_component(resolved "${EXPECTED_WORKING_DIR}" REALPATH) + if(resolved STREQUAL "${${d}}") + message(STATUS "${d} is the expected working directory (${resolved}) after symlink resolution") + else() + message(FATAL_ERROR "${d} = \"${${d}}\" is not the expected working directory (${EXPECTED_WORKING_DIR})") + endif() endif() endforeach() diff --git a/Tests/RunCMake/Configure/FailCopyFileABI-override.cmake b/Tests/RunCMake/Configure/CopyFileABI-override.cmake index c633555..67f6ed5 100644 --- a/Tests/RunCMake/Configure/FailCopyFileABI-override.cmake +++ b/Tests/RunCMake/Configure/CopyFileABI-override.cmake @@ -1,5 +1,6 @@ # Change the executable suffix that try_compile will use for -# COPY_FILE but not inside the test project. This forces failure. +# COPY_FILE but not inside the test project, to verify +# we can handle envs that try and break everything get_property(in_try_compile GLOBAL PROPERTY IN_TRY_COMPILE) if(NOT in_try_compile) set(CMAKE_EXECUTABLE_SUFFIX .missing) diff --git a/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt b/Tests/RunCMake/Configure/CopyFileABI-stdout.txt index 92fe233..6a856a4 100644 --- a/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt +++ b/Tests/RunCMake/Configure/CopyFileABI-stdout.txt @@ -1,4 +1,4 @@ -- Detecting C compiler ABI info --- Detecting C compiler ABI info - failed.* +-- Detecting C compiler ABI info - done.* -- Configuring done -- Generating done diff --git a/Tests/RunCMake/Configure/FailCopyFileABI.cmake b/Tests/RunCMake/Configure/CopyFileABI.cmake index 74efd97..4eee100 100644 --- a/Tests/RunCMake/Configure/FailCopyFileABI.cmake +++ b/Tests/RunCMake/Configure/CopyFileABI.cmake @@ -1,2 +1,2 @@ -set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/FailCopyFileABI-override.cmake) +set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/CopyFileABI-override.cmake) enable_language(C) diff --git a/Tests/RunCMake/Configure/FailCopyFileABI-check.cmake b/Tests/RunCMake/Configure/FailCopyFileABI-check.cmake deleted file mode 100644 index db0cb0a..0000000 --- a/Tests/RunCMake/Configure/FailCopyFileABI-check.cmake +++ /dev/null @@ -1,14 +0,0 @@ -set(log "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/CMakeError.log") -if(EXISTS "${log}") - file(READ "${log}" error_log) -else() - set(error_log "") -endif() -string(REPLACE "\r\n" "\n" regex "Cannot copy output executable.* -to destination specified by COPY_FILE:.* -Unable to find the executable at any of: - .*\\.missing") -if(NOT error_log MATCHES "${regex}") - string(REGEX REPLACE "\n" "\n " error_log " ${error_log}") - set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected COPY_FILE failure message:\n${error_log}") -endif() diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 9fd4499..750fa3c 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -1,9 +1,9 @@ include(RunCMake) run_cmake(ContinueAfterError) +run_cmake(CopyFileABI) run_cmake(CustomTargetAfterError) run_cmake(ErrorLogs) -run_cmake(FailCopyFileABI) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunCMake-build) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index 28b8570..e389e6b 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -38,9 +38,12 @@ run_cmake(exact_1.2.3.5) unset(RunCMake_DEFAULT_stderr) # check if searching for a version 0 works -list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0") +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0") run_cmake(exact_0_matching) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=") +run_cmake(empty_version) + # check custom error message set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCustomMessage_VERSION=1.2.3.4") run_cmake(custom_message_1) diff --git a/Tests/RunCMake/FPHSA/empty_version-result.txt b/Tests/RunCMake/FPHSA/empty_version-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/empty_version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/empty_version-stderr.txt b/Tests/RunCMake/FPHSA/empty_version-stderr.txt new file mode 100644 index 0000000..3b60c7a --- /dev/null +++ b/Tests/RunCMake/FPHSA/empty_version-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at [^ +]*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find Pseudo: \(Required is at least version "1"\) \(found TRUE\) +Call Stack \(most recent call first\): + [^ +]*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(_FPHSA_FAILURE_MESSAGE\) + FindPseudo.cmake:[0-9]+ \(find_package_handle_standard_args\) + empty_version.cmake:[0-9]+ \(find_package\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/FPHSA/empty_version.cmake b/Tests/RunCMake/FPHSA/empty_version.cmake new file mode 100644 index 0000000..7b7ff34 --- /dev/null +++ b/Tests/RunCMake/FPHSA/empty_version.cmake @@ -0,0 +1 @@ +find_package(Pseudo 1 REQUIRED) diff --git a/Tests/RunCMake/FetchContent_find_package/PreferFetchContent.cmake b/Tests/RunCMake/FetchContent_find_package/PreferFetchContent.cmake index c1030fb..4943f9e 100644 --- a/Tests/RunCMake/FetchContent_find_package/PreferFetchContent.cmake +++ b/Tests/RunCMake/FetchContent_find_package/PreferFetchContent.cmake @@ -18,3 +18,7 @@ message(STATUS "Lowercase extra file was read") # This is expected to be re-routed to a FetchContent_MakeAvailable() call find_package(AddedProject REQUIRED) + +# Verify that find_package() version constraints are fully ignored by the +# default-generated config version file +find_package(AddedProject 1.2.3 EXACT REQUIRED) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt index bae6505..b29303b 100644 --- a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt @@ -1,6 +1,6 @@ -CMake Error at forbidden-arguments.cmake:[0-9]+ \(link_libraries\): - Property LINK_LIBRARIES contains the invalid item "<LINK_GROUP:feat>". The - LINK_LIBRARIES property may contain the generator-expression +CMake Error at forbidden-arguments.cmake:[0-9]+ \(add_library\): + Property LINK_LIBRARIES contains the invalid item "</LINK_GROUP:feat>". + The LINK_LIBRARIES property may contain the generator-expression "\$<LINK_GROUP:...>" which may be used to specify how the libraries are linked. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt index 5245dd8..fc8e383 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt @@ -1,5 +1,5 @@ -CMake Error at forbidden-arguments.cmake:[0-9]+ \(link_libraries\): - Property LINK_LIBRARIES contains the invalid item "<LINK_LIBRARY:feat>". +CMake Error at forbidden-arguments.cmake:[0-9]+ \(add_library\): + Property LINK_LIBRARIES contains the invalid item "</LINK_LIBRARY:feat>". The LINK_LIBRARIES property may contain the generator-expression "\$<LINK_LIBRARY:...>" which may be used to specify how the libraries are linked. diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 1aa6359..74ae99c 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -95,6 +95,7 @@ endfunction() run_TestOutputTruncation("head" "\\.\\.\\.6789") run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89") run_TestOutputTruncation("tail" "12345\\.\\.\\.") +run_TestOutputTruncation("bad" "") run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3) run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1) diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake new file mode 100644 index 0000000..4315074f --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake @@ -0,0 +1,4 @@ +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + set(RunCMake_TEST_FAILED "Test.xml should not exist:\n ${test_xml_file}") +endif() diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt new file mode 100644 index 0000000..ef4d11b --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt @@ -0,0 +1 @@ +^Invalid value for CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION: bad$ diff --git a/Tests/RunCMake/try_compile/BuildType.cmake b/Tests/RunCMake/try_compile/BuildType.cmake new file mode 100644 index 0000000..f2709f8 --- /dev/null +++ b/Tests/RunCMake/try_compile/BuildType.cmake @@ -0,0 +1,6 @@ +enable_language(C) +set(CMAKE_BUILD_TYPE RelWithDebInfo) + +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/out.bin" + ) diff --git a/Tests/RunCMake/try_compile/BuildTypeAsFlag.cmake b/Tests/RunCMake/try_compile/BuildTypeAsFlag.cmake new file mode 100644 index 0000000..e9384c7 --- /dev/null +++ b/Tests/RunCMake/try_compile/BuildTypeAsFlag.cmake @@ -0,0 +1,7 @@ +enable_language(C) +set(CMAKE_BUILD_TYPE RelWithDebInfo) + +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/out.bin" + CMAKE_FLAGS "-DCMAKE_BUILD_TYPE=Release" + ) diff --git a/Tests/RunCMake/try_compile/OutputDirAsFlag.cmake b/Tests/RunCMake/try_compile/OutputDirAsFlag.cmake new file mode 100644 index 0000000..5c4dca5 --- /dev/null +++ b/Tests/RunCMake/try_compile/OutputDirAsFlag.cmake @@ -0,0 +1,7 @@ +enable_language(C) +set(CMAKE_BUILD_TYPE RelWithDebInfo) + +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/out.bin" + CMAKE_FLAGS "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=bin" + ) diff --git a/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake b/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake index e156e12..f80d445 100644 --- a/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake +++ b/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake @@ -11,6 +11,9 @@ run_cmake(BadSources2) run_cmake(EmptyValueArgs) run_cmake(EmptyListArgs) run_cmake(TryRunArgs) +run_cmake(BuildType) +run_cmake(BuildTypeAsFlag) +run_cmake(OutputDirAsFlag) run_cmake(EnvConfig) |