diff options
150 files changed, 1226 insertions, 180 deletions
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 73dd9d3..97ad481 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -14,10 +14,15 @@ Try Compiling Whole Projects .. code-block:: cmake - try_compile(<resultVar> <bindir> <srcdir> - <projectName> [<targetName>] [CMAKE_FLAGS <flags>...] + try_compile(<resultVar> PROJECT <projectName> + SOURCE_DIR <srcdir> + [BINARY_DIR <bindir>] + [TARGET <targetName>] + [CMAKE_FLAGS <flags>...] [OUTPUT_VARIABLE <var>]) +.. versionadded:: 3.25 + Try building a project. The success or failure of the ``try_compile``, i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``. @@ -34,6 +39,15 @@ below for the meaning of other options. Previously this was only done by the :ref:`source file <Try Compiling Source Files>` signature. +This command also supports an alternate signature +which was present in older versions of CMake: + +.. code-block:: cmake + + try_compile(<resultVar> <bindir> <srcdir> + <projectName> [<targetName>] [CMAKE_FLAGS <flags>...] + [OUTPUT_VARIABLE <var>]) + .. _`Try Compiling Source Files`: Try Compiling Source Files @@ -244,3 +258,8 @@ a build configuration. .. versionadded:: 3.24 The :variable:`CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES` variable may be set to disable passing platform variables into the test project. + +.. versionadded:: 3.25 + If :policy:`CMP0141` is set to ``NEW``, one can use + :variable:`CMAKE_MSVC_DEBUG_INFORMATION_FORMAT` to specify MSVC debug + information format. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index a1133b9..d6a30ff 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -58,6 +58,8 @@ Policies Introduced by CMake 3.25 .. toctree:: :maxdepth: 1 + CMP0142: The Xcode generator does not append per-config suffixes to library search paths. </policy/CMP0142> + CMP0141: MSVC debug information format flags are selected by an abstraction. </policy/CMP0141> CMP0140: The return() command checks its arguments. </policy/CMP0140> Policies Introduced by CMake 3.24 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index d98f7cc..09c3c88 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -340,6 +340,7 @@ Properties on Targets /prop_tgt/MACOSX_RPATH /prop_tgt/MANUALLY_ADDED_DEPENDENCIES /prop_tgt/MAP_IMPORTED_CONFIG_CONFIG + /prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT /prop_tgt/MSVC_RUNTIME_LIBRARY /prop_tgt/NAME /prop_tgt/NO_SONAME diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 6533ca5..02efc9c 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -484,6 +484,7 @@ Variables that Control the Build /variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG_INIT /variable/CMAKE_MODULE_LINKER_FLAGS_INIT /variable/CMAKE_MSVCIDE_RUN_PATH + /variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT /variable/CMAKE_MSVC_RUNTIME_LIBRARY /variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX /variable/CMAKE_NO_BUILTIN_CHRPATH @@ -510,6 +511,7 @@ Variables that Control the Build /variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG /variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG_INIT /variable/CMAKE_STATIC_LINKER_FLAGS_INIT + /variable/CMAKE_TASKING_TOOLSET /variable/CMAKE_TRY_COMPILE_CONFIGURATION /variable/CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES /variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES diff --git a/Help/policy/CMP0141.rst b/Help/policy/CMP0141.rst new file mode 100644 index 0000000..51fa5fd --- /dev/null +++ b/Help/policy/CMP0141.rst @@ -0,0 +1,55 @@ +CMP0141 +------- + +.. versionadded:: 3.25 + +MSVC debug information format flags are selected by an abstraction. + +Compilers targeting the MSVC ABI have flags to select the debug information +format. Debug information format selection typically varies with build +configuration. + +In CMake 3.24 and below, debug information format flags are added to +the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache entries by CMake +automatically. This allows users to edit their cache entries to adjust the +flags. However, the presence of such default flags is problematic for +projects that want to choose a different runtime library programmatically. +In particular, it requires string editing of the +:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variables with knowledge of the +CMake builtin defaults so they can be replaced. + +CMake 3.25 and above prefer to leave the debug information format flags +out of the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` values and instead +offer a first-class abstraction. The +:variable:`CMAKE_MSVC_DEBUG_INFORMATION_FORMAT` variable and +:prop_tgt:`MSVC_DEBUG_INFORMATION_FORMAT` target property may be set to +select the MSVC debug information format. If they are not set, CMake +enables debug information in debug configurations using the default value +``$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>``, if supported by the +compiler, and otherwise ``$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>``. + +This policy provides compatibility with projects that have not been updated +to be aware of the abstraction. The policy setting takes effect as of the +first :command:`project` or :command:`enable_language` command that enables +a language whose compiler targets the MSVC ABI. + +.. note:: + + Once the policy has taken effect at the top of a project, that choice + will be used throughout the tree. In projects that have nested projects + in subdirectories, be sure to confirm if everything is working with the + selected policy behavior. + +The ``OLD`` behavior for this policy is to place MSVC debug information +format flags in the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache +entries and ignore the :variable:`CMAKE_MSVC_DEBUG_INFORMATION_FORMAT` +abstraction. The ``NEW`` behavior for this policy is to *not* place MSVC +debug information format flags flags in the default cache entries and use +the abstraction instead. + +This policy was introduced in CMake version 3.25. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +Unlike many policies, CMake version |release| does *not* warn +when this policy is not set and simply uses ``OLD`` behavior. + +.. include:: DEPRECATED.txt diff --git a/Help/policy/CMP0142.rst b/Help/policy/CMP0142.rst new file mode 100644 index 0000000..1f928f0 --- /dev/null +++ b/Help/policy/CMP0142.rst @@ -0,0 +1,27 @@ +CMP0142 +------- + +.. versionadded:: 3.25 + +The :generator:`Xcode` generator does not append per-config suffixes to +library search paths. + +In CMake 3.24 and below, the :generator:`Xcode` generator preceded each +entry of a library search path with a copy of itself appended with +``$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)``. This was left from +very early versions of CMake in which per-config directories were not well +modeled. Such paths often do not exist, resulting in warnings from the +toolchain. CMake 3.25 and above prefer to not add such library search +paths. This policy provides compatibility for projects that may have been +accidentally relying on the old behavior. + +The ``OLD`` behavior for this policy is to append +``$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)`` to all library search paths. +The ``NEW`` behavior is to not modify library search paths. + +This policy was introduced in CMake version 3.25. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +Unlike many policies, CMake version |release| does *not* warn +when this policy is not set and simply uses ``OLD`` behavior. + +.. include:: DEPRECATED.txt diff --git a/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt b/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt new file mode 100644 index 0000000..9a68460 --- /dev/null +++ b/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt @@ -0,0 +1,15 @@ +``Embedded`` + Compile with ``-Z7`` or equivalent flag(s) to produce object files + with full symbolic debugging information. +``ProgramDatabase`` + Compile with ``-Zi`` or equivalent flag(s) to produce a program + database that contains all the symbolic debugging information. +``EditAndContinue`` + Compile with ``-ZI`` or equivalent flag(s) to produce a program + database that supports the Edit and Continue feature. + +The value is ignored on non-MSVC compilers but an unsupported value will +be rejected as an error when using a compiler targeting the MSVC ABI. + +The value may also be the empty string (``""``) in which case no debug +information format flag will be added explicitly by CMake. diff --git a/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT.rst b/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT.rst new file mode 100644 index 0000000..2314cff --- /dev/null +++ b/Help/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT.rst @@ -0,0 +1,33 @@ +MSVC_DEBUG_INFORMATION_FORMAT +----------------------------- + +.. versionadded:: 3.25 + +Select debug information format targeting the MSVC ABI. + +The allowed values are: + +.. include:: MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt + +Use :manual:`generator expressions <cmake-generator-expressions(7)>` to +support per-configuration specification. For example, the code: + +.. code-block:: cmake + + add_executable(foo foo.c) + set_property(TARGET foo PROPERTY + MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>") + +selects for the target ``foo`` the program database debug information format +for the Debug configuration. + +If this property is not set, CMake selects a debug information format using +the default value ``$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>``, if +supported by the compiler, and otherwise +``$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>``. + +.. note:: + + This property has effect only when policy :policy:`CMP0141` is set to ``NEW`` + prior to the first :command:`project` or :command:`enable_language` command + that enables a language using a compiler targeting the MSVC ABI. diff --git a/Help/release/dev/MsvcDebugInformationFormatAbstraction.rst b/Help/release/dev/MsvcDebugInformationFormatAbstraction.rst new file mode 100644 index 0000000..d0c077c --- /dev/null +++ b/Help/release/dev/MsvcDebugInformationFormatAbstraction.rst @@ -0,0 +1,7 @@ +MsvcDebugInformationFormatAbstraction +------------------------------------- + +* The :variable:`CMAKE_MSVC_DEBUG_INFORMATION_FORMAT` variable and + :prop_tgt:`MSVC_DEBUG_INFORMATION_FORMAT` target property were introduced + to select the debug information format for compilers targeting the MSVC ABI. + See policy :policy:`CMP0141`. diff --git a/Help/release/dev/add_tasking_compiler.rst b/Help/release/dev/add_tasking_compiler.rst new file mode 100644 index 0000000..705f923 --- /dev/null +++ b/Help/release/dev/add_tasking_compiler.rst @@ -0,0 +1,8 @@ +add_tasking_compiler +-------------------- + + * Support for the `Tasking compiler toolsets`_ (SmartCode, TriCore, + Standalone: ARM, MCS, 8051) was added with compiler id ``Tasking``. + See the :variable:`CMAKE_TASKING_TOOLSET` variable. + +.. _`Tasking compiler toolsets`: https://tasking.com diff --git a/Help/release/dev/xcode-lib-dirs.rst b/Help/release/dev/xcode-lib-dirs.rst new file mode 100644 index 0000000..fc1fe1b --- /dev/null +++ b/Help/release/dev/xcode-lib-dirs.rst @@ -0,0 +1,6 @@ +xcode-lib-dirs +-------------- + +* The :generator:`Xcode` generator no longer adds the per-config suffix + ``$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)`` to library search paths. + See policy :policy:`CMP0142`. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index f0534ba..0dbc0a0 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -44,6 +44,7 @@ Value Name ``XL``, ``VisualAge``, ``zOS`` IBM XL ``XLClang`` IBM Clang-based XL ``IBMClang`` IBM LLVM-based Compiler +``Tasking`` `Tasking Compiler Toolsets`_ =============================== =============================================== This variable is not guaranteed to be defined for all compilers or @@ -63,3 +64,4 @@ languages. .. _Open Watcom: https://open-watcom.github.io .. _Small Device C Compiler: http://sdcc.sourceforge.net .. _Tiny C Compiler: https://bellard.org/tcc +.. _Tasking Compiler Toolsets: https://tasking.com diff --git a/Help/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.rst b/Help/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.rst new file mode 100644 index 0000000..80df8fc --- /dev/null +++ b/Help/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.rst @@ -0,0 +1,36 @@ +CMAKE_MSVC_DEBUG_INFORMATION_FORMAT +----------------------------------- + +.. versionadded:: 3.25 + +Select the MSVC debug information format targeting the MSVC ABI. +This variable is used to initialize the +:prop_tgt:`MSVC_DEBUG_INFORMATION_FORMAT` property on all targets as they are +created. It is also propagated by calls to the :command:`try_compile` command +into the test project. + +The allowed values are: + +.. include:: ../prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT-VALUES.txt + +Use :manual:`generator expressions <cmake-generator-expressions(7)>` to +support per-configuration specification. For example, the code: + +.. code-block:: cmake + + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>") + +selects for all following targets the program database debug information format +for the Debug configuration. + +If this variable is not set, the :prop_tgt:`MSVC_DEBUG_INFORMATION_FORMAT` +target property will not be set automatically. If that property is not set, +CMake selects a debug information format using the default value +``$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>``, if supported by the +compiler, and otherwise ``$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>``. + +.. note:: + + This variable has effect only when policy :policy:`CMP0141` is set to ``NEW`` + prior to the first :command:`project` or :command:`enable_language` command + that enables a language using a compiler targeting the MSVC ABI. diff --git a/Help/variable/CMAKE_TASKING_TOOLSET.rst b/Help/variable/CMAKE_TASKING_TOOLSET.rst new file mode 100644 index 0000000..430207e --- /dev/null +++ b/Help/variable/CMAKE_TASKING_TOOLSET.rst @@ -0,0 +1,31 @@ +CMAKE_TASKING_TOOLSET +--------------------- + +.. versionadded:: 3.25 + +Select the Tasking toolset which provides the compiler + +Architecture compilers are provided by different toolchains with +incompatible versioning schemes. Set this variable in a +:variable:`toolchain file <CMAKE_TOOLCHAIN_FILE>` so CMake can detect +the compiler and version correctly. If no toolset is specified, +``Standalone`` is assumed. + +Projects, that can be build with different architectures and/or toolsets, must +take :variable:`CMAKE_TASKING_TOOLSET` and +:variable:`CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID` into account to qualify +:variable:`CMAKE_<LANG>_COMPILER_VERSION`. + +``TriCore`` + Compilers are provided by the TriCore toolset. + +``SmartCode`` + Compilers are provided by the SmartCode toolset. + +``Standalone`` + Compilers are provided by the standalone toolsets. + + .. note:: + + For the TriCore architecture, the compiler from the TriCore toolset is + selected as standalone compiler. diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index f19bc97..2643326 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -82,6 +82,7 @@ int main(int argc, char* argv[]) int require = 0; require += info_compiler[argc]; require += info_platform[argc]; + require += info_arch[argc]; #ifdef COMPILER_VERSION_MAJOR require += info_version[argc]; #endif diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index f15974a..75d33e8 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -70,6 +70,7 @@ function(compiler_id_detection outvar lang) FujitsuClang Fujitsu GHS + Tasking ) if ("x${lang}" STREQUAL "xC") list(APPEND ordered_compilers diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 69021c1..c148f8a 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -55,7 +55,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) set(ENV{LANG} C) try_compile(CMAKE_${lang}_ABI_COMPILED - ${CMAKE_BINARY_DIR} ${src} + SOURCES ${src} CMAKE_FLAGS ${CMAKE_FLAGS} # Ignore unused flags when we are just determining the ABI. "--no-warn-unused-cli" diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index 53868d2..0d360b5 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -105,8 +105,7 @@ function(_DetermineVSServicePack_CheckVersionWithTryCompile _SUCCESS_VAR _VERSI try_compile( _CompileResult - "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}/return0.cc" + SOURCES "${CMAKE_BINARY_DIR}/return0.cc" OUTPUT_VARIABLE _output COPY_FILE "${CMAKE_BINARY_DIR}/return0.cc") @@ -128,8 +127,7 @@ function(_DetermineVSServicePack_CheckVersionWithTryRun _SUCCESS_VAR _VERSION_V try_run( _RunResult _CompileResult - "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}/return0.cc" + SOURCES "${CMAKE_BINARY_DIR}/return0.cc" RUN_OUTPUT_VARIABLE _runoutput ) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index a6bd0d1..2ac8879 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -170,7 +170,7 @@ else() if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang) if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC") list(PREPEND _CMAKE_LINKER_NAMES "lld-link") - else() + elseif(NOT APPLE) list(PREPEND _CMAKE_LINKER_NAMES "ld.lld") endif() if(APPLE) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 06f5ecd..32b7166 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -242,6 +242,30 @@ # elif defined(__ADSPBLACKFIN__) # define ARCHITECTURE_ID "Blackfin" +#elif defined(__TASKING__) + +# if defined(__CTC__) || defined(__CPTC__) +# define ARCHITECTURE_ID "TriCore" + +# elif defined(__CMCS__) +# define ARCHITECTURE_ID "MCS" + +# elif defined(__CARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__CARC__) +# define ARCHITECTURE_ID "ARC" + +# elif defined(__C51__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__CPCP__) +# define ARCHITECTURE_ID "PCP" + +# else +# define ARCHITECTURE_ID "" +# endif + #else # define ARCHITECTURE_ID #endif diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index ae5aa27..102b638 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -53,8 +53,8 @@ if(NOT CMAKE_C_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_C_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c + try_compile(CMAKE_C_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS}) diff --git a/Modules/CMakeTestCSharpCompiler.cmake b/Modules/CMakeTestCSharpCompiler.cmake index adea250..d7a0bb5 100644 --- a/Modules/CMakeTestCSharpCompiler.cmake +++ b/Modules/CMakeTestCSharpCompiler.cmake @@ -33,7 +33,8 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_CSharp_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_CSharp_COMPILER_WORKS ${CMAKE_BINARY_DIR} "${test_compile_file}" + try_compile(CMAKE_CSharp_COMPILER_WORKS + SOURCES "${test_compile_file}" OUTPUT_VARIABLE __CMAKE_CSharp_COMPILER_OUTPUT ) # Move result from cache to normal variable. diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake index a6d0f8b..9c49f5d 100644 --- a/Modules/CMakeTestCUDACompiler.cmake +++ b/Modules/CMakeTestCUDACompiler.cmake @@ -86,8 +86,8 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS) unset(CMAKE_CUDA_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu + try_compile(CMAKE_CUDA_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu OUTPUT_VARIABLE __CMAKE_CUDA_COMPILER_OUTPUT) # Move result from cache to normal variable. diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index bbe3533..9a3638f 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -46,8 +46,8 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_CXX_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx + try_compile(CMAKE_CXX_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx OUTPUT_VARIABLE __CMAKE_CXX_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS}) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 579f83f..4e413af 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -46,8 +46,8 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_Fortran_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + try_compile(CMAKE_Fortran_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f OUTPUT_VARIABLE OUTPUT) # Move result from cache to normal variable. set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS}) @@ -77,8 +77,8 @@ if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do END PROGRAM TESTFortran90 ") - try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 + try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 OUTPUT_VARIABLE OUTPUT) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(CHECK_PASS "yes") diff --git a/Modules/CMakeTestHIPCompiler.cmake b/Modules/CMakeTestHIPCompiler.cmake index ecbfa7f..a0b6bfd 100644 --- a/Modules/CMakeTestHIPCompiler.cmake +++ b/Modules/CMakeTestHIPCompiler.cmake @@ -49,8 +49,8 @@ if(NOT CMAKE_HIP_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_HIP_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_HIP_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testHIPCompiler.hip + try_compile(CMAKE_HIP_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testHIPCompiler.hip OUTPUT_VARIABLE __CMAKE_HIP_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_HIP_COMPILER_WORKS ${CMAKE_HIP_COMPILER_WORKS}) diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake index 20d1f8b..a8e6319 100644 --- a/Modules/CMakeTestOBJCCompiler.cmake +++ b/Modules/CMakeTestOBJCCompiler.cmake @@ -50,8 +50,8 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_OBJC_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m + try_compile(CMAKE_OBJC_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS}) diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake index 4f7185f..afa053f 100644 --- a/Modules/CMakeTestOBJCXXCompiler.cmake +++ b/Modules/CMakeTestOBJCXXCompiler.cmake @@ -49,8 +49,8 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_OBJCXX_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm + try_compile(CMAKE_OBJCXX_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm OUTPUT_VARIABLE __CMAKE_OBJCXX_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS}) diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake index 2f2546f..4982819 100644 --- a/Modules/CMakeTestSwiftCompiler.cmake +++ b/Modules/CMakeTestSwiftCompiler.cmake @@ -26,8 +26,8 @@ if(NOT CMAKE_Swift_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_Swift_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_Swift_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift + try_compile(CMAKE_Swift_COMPILER_WORKS + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift OUTPUT_VARIABLE __CMAKE_Swift_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_Swift_COMPILER_WORKS ${CMAKE_Swift_COMPILER_WORKS}) diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index 8f1ca9d..f82399a 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -68,8 +68,7 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) " ) try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} OUTPUT_VARIABLE OUTPUT diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index 9efa132..0135218 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -90,8 +90,7 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${_cfe_source} + SOURCES ${_cfe_source} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 71ddde7..2253fab 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -93,8 +93,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index 953224e..453751e 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -92,8 +92,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 1800ca8..22af4f2 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -136,8 +136,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) message(CHECK_START "Looking for ${_description}") endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${src} + SOURCES ${src} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index 804e0cb..e126f70 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -70,8 +70,7 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${_cle_source} + SOURCES ${_cle_source} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_LIBRARY_EXISTS_LINK_OPTIONS} LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES} diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index d29c5e8..5a07502 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -100,8 +100,7 @@ function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) try_compile(${_VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_PROTOTYPE_DEFINITION_LINK_OPTIONS} ${CHECK_PROTOTYPE_DEFINITION_LIBS} diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index a7139af..ebaeb7c 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -146,8 +146,7 @@ int main(int argc, char** argv) message(CHECK_START "Looking for ${SYMBOL}") endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - "${SOURCEFILE}" + SOURCES "${SOURCEFILE}" COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_SYMBOL_EXISTS_LINK_OPTIONS} ${CHECK_SYMBOL_EXISTS_LIBS} diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 602170c..4cffa1a 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -143,7 +143,7 @@ function(__check_type_size_impl type var map builtin language) # Perform the check. set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin) configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY) - try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src} + try_compile(HAVE_${var} SOURCES ${src} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS} LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index 7420124..5dc3441 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -62,8 +62,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/CheckVariableExists.c + SOURCES ${CMAKE_ROOT}/Modules/CheckVariableExists.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS} ${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES} diff --git a/Modules/Compiler/Tasking-ASM.cmake b/Modules/Compiler/Tasking-ASM.cmake new file mode 100644 index 0000000..19bce19 --- /dev/null +++ b/Modules/Compiler/Tasking-ASM.cmake @@ -0,0 +1,7 @@ +include(Compiler/Tasking) + +set(CMAKE_ASM_OUTPUT_EXTENSION ".o") +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) + +set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>") +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S;s;asm;msa) diff --git a/Modules/Compiler/Tasking-C.cmake b/Modules/Compiler/Tasking-C.cmake new file mode 100644 index 0000000..0ea3cd2 --- /dev/null +++ b/Modules/Compiler/Tasking-C.cmake @@ -0,0 +1,47 @@ +include(Compiler/Tasking) +__compiler_tasking(C) + +set(CMAKE_C90_STANDARD_COMPILE_OPTION "--iso=90" "--strict") +set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--iso=90" " ") + +set(CMAKE_C99_STANDARD_COMPILE_OPTION "--iso=99" "--strict") +set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--iso=99" " ") + +set(CMAKE_C11_STANDARD_COMPILE_OPTION "--iso=11" "--strict") +set(CMAKE_C11_EXTENSION_COMPILE_OPTION "--iso=11" " ") + +if(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "TriCore") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + else() + __compiler_check_default_language_standard(C 6.3 11) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(C 6.3 11) + else() + __compiler_check_default_language_standard(C 6.0 11) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "MCS") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(C 6.3 11) + else() + __compiler_check_default_language_standard(C 3.3 11) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARC") + __compiler_check_default_language_standard(C 10.1 11) +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "8051") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(C 6.3 11) + else() + __compiler_check_default_language_standard(C 7.2 89) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "PCP") + __compiler_check_default_language_standard(C 6.3 11) +endif() diff --git a/Modules/Compiler/Tasking-CXX.cmake b/Modules/Compiler/Tasking-CXX.cmake new file mode 100644 index 0000000..635104c --- /dev/null +++ b/Modules/Compiler/Tasking-CXX.cmake @@ -0,0 +1,31 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +include(Compiler/Tasking) +__compiler_tasking(CXX) + +set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--c++=03" "--strict") +set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--iso=03" " ") + +set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "--c++=11" "--strict") +set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "--c++=11" " ") + +set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "--c++=14" "--strict") +set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "--c++=14" " ") + +if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "TriCore") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(CXX 10.1 14) + else() + __compiler_check_default_language_standard(CXX 6.3 14) + endif() +elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(CXX 10.1 14) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(CXX 6.3 14) + else() + __compiler_check_default_language_standard(CXX 6.0 14) + endif() +else() + message(FATAL_ERROR "CXX is not supported with the ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} architecture.") +endif() diff --git a/Modules/Compiler/Tasking-DetermineCompiler.cmake b/Modules/Compiler/Tasking-DetermineCompiler.cmake new file mode 100644 index 0000000..a40be19 --- /dev/null +++ b/Modules/Compiler/Tasking-DetermineCompiler.cmake @@ -0,0 +1,10 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +set(_compiler_id_pp_test "defined(__TASKING__)") + +set(_compiler_id_version_compute " + # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__VERSION__/1000) + # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__VERSION__ % 100)") + +string(APPEND _compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__VERSION__)") diff --git a/Modules/Compiler/Tasking-FindBinUtils.cmake b/Modules/Compiler/Tasking-FindBinUtils.cmake new file mode 100644 index 0000000..eab31d7 --- /dev/null +++ b/Modules/Compiler/Tasking-FindBinUtils.cmake @@ -0,0 +1,18 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Find the archiver for the compiler architecture, which is always in the same +# directory as the compiler. +if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "") + message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set") +endif() + +get_filename_component(__tasking_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) + +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR + NAMES artc ararm armcs ar51 ararc arpcp + HINTS ${__tasking_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH + DOC "Tasking Archiver" +) +mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) diff --git a/Modules/Compiler/Tasking.cmake b/Modules/Compiler/Tasking.cmake new file mode 100644 index 0000000..30d4c69 --- /dev/null +++ b/Modules/Compiler/Tasking.cmake @@ -0,0 +1,86 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This module is shared by multiple languages; use include blocker. +if(_Tasking_CMAKE_LOADED) + return() +endif() +set(_Tasking_CMAKE_LOADED TRUE) +include(Compiler/CMakeCommonCompilerMacros) + +set(CMAKE_EXECUTABLE_SUFFIX ".elf") +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) +set(BUILD_SHARED_LIBS FALSE CACHE BOOL "") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") +set(CMAKE_LINK_SEARCH_START_STATIC TRUE) + +function(__tasking_set_processor_list lang out_var) + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --cpu-list + OUTPUT_VARIABLE processor_list + ERROR_VARIABLE processor_list) + string(REGEX MATCHALL "[ ]+([A-Za-z0-9_]+)[ ]+[^ ]([^ ]+ ?)*[ ]+[A-Za-z0-9\\.]+[ ]+[A-Za-z0-9\.]+\n" processor_list "${processor_list}") + list(POP_FRONT processor_list) + string(REGEX REPLACE "[ ]+([A-Za-z0-9_]+)[ ]+[^ ]([^ ]+ ?)*[ ]+[A-Za-z0-9\\.]+[ ]+[A-Za-z0-9\.]+\n" "\\1" processor_list "${processor_list}") + set(${out_var} "${processor_list}" PARENT_SCOPE) +endfunction() + +function(__tasking_check_processor processor list out_var) + string(TOLOWER "${processor}" processor) + if(processor IN_LIST list) + set(${out_var} TRUE PARENT_SCOPE) + else() + set(${out_var} FALSE PARENT_SCOPE) + endif() +endfunction() + +if(NOT CMAKE_TASKING_TOOLSET) + set(CMAKE_TASKING_TOOLSET "Standalone") +endif() + +macro(__compiler_tasking lang) + + if(CMAKE_SYSTEM_PROCESSOR) + if(NOT _TASKING_${lang}_PROCESSOR_LIST) + __tasking_set_processor_list(${lang} _TASKING_${lang}_PROCESSOR_LIST) + endif() + __tasking_check_processor(${CMAKE_SYSTEM_PROCESSOR} "${_TASKING_${lang}_PROCESSOR_LIST}" _TASKING_${lang}_VALID_PROCESSOR) + if(${_TASKING_${lang}_VALID_PROCESSOR}) + string(APPEND CMAKE_${lang}_FLAGS_INIT " -C${CMAKE_SYSTEM_PROCESSOR}") + else() + message(FATAL_ERROR "Invalid processor ${CMAKE_SYSTEM_PROCESSOR} specified.\n" + "Supported processors: ${_TASKING_${lang}_PROCESSOR_LIST}") + endif() + endif() + + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl" " ") + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ") + set(CMAKE_DEPFILE_FLAGS_${lang} "--dep-file=<DEP_FILE>") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "--warning-as-errors") + + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -O0 -g") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O2 -t4 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -t2 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -t2 -g -DNDEBUG") + + set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_${lang}_COMPILER_AR}\" -r <TARGET> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "\"${CMAKE_${lang}_COMPILER_AR}\" -r <TARGET> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_FINISH "") + + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -cs <SOURCE> -o <ASSEMBLY_SOURCE>") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -Ep <SOURCE> > <PREPROCESSED_SOURCE>") + + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}") + if(CMAKE_${lang}_COMPILER_ARG1) + separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}") + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS}) + unset(_COMPILER_ARGS) + endif() + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-Ep" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + +endmacro() diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index a35b3f8..5fad337 100644 --- a/Modules/FindCUDA/select_compute_arch.cmake +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -135,10 +135,10 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) "}\n") if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language - try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file} + try_run(run_result compile_result SOURCES ${file} RUN_OUTPUT_VARIABLE compute_capabilities) else() - try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file} + try_run(run_result compile_result SOURCES ${file} CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}" LINK_LIBRARIES ${CUDA_LIBRARIES} RUN_OUTPUT_VARIABLE compute_capabilities) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 40ed9a9..d662a7d 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -238,7 +238,7 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" " return 0;\n" "}") - try_compile(${success} ${scratch_directory} ${test_file} + try_compile(${success} SOURCES ${test_file} COPY_FILE ${scratch_directory}/compiler_has_h5_c ) endif() @@ -286,7 +286,7 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel) " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" " return 0;\n" "}") - try_compile(${success} ${scratch_directory} ${test_file} + try_compile(${success} SOURCES ${test_file} COPY_FILE ${scratch_directory}/compiler_has_h5_cxx ) endif() @@ -323,7 +323,7 @@ function(_HDF5_test_regular_compiler_Fortran success is_parallel) " call h5open_f(error)\n" " call h5close_f(error)\n" "end\n") - try_compile(${success} ${scratch_directory} ${test_file}) + try_compile(${success} SOURCES ${test_file}) if(${success}) execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig OUTPUT_VARIABLE config_output diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index b8ca71b..0574ab5 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -34,8 +34,7 @@ if(MFC_ATTEMPT_TRY_COMPILE) message(CHECK_START "Looking for MFC") # Try both shared and static as the root project may have set the /MT flag try_compile(MFC_HAVE_MFC - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx CMAKE_FLAGS -DCMAKE_MFC_FLAG:STRING=2 -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL @@ -44,8 +43,7 @@ if(MFC_ATTEMPT_TRY_COMPILE) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) try_compile(MFC_HAVE_MFC - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx CMAKE_FLAGS -DCMAKE_MFC_FLAG:STRING=1 OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index c6aeab0..2faab0e 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1259,7 +1259,7 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE endif() if(RUN_BINARY) try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCES "${MPI_TEST_SOURCE_FILE}" COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} @@ -1267,7 +1267,7 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) else() try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCES "${MPI_TEST_SOURCE_FILE}" COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} COPY_FILE "${BIN_FILE}" diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index ec2c345..07a9adf 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -296,6 +296,7 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS) endif() set(MATLAB_VERSIONS_MAPPING + "R2022b=9.13" "R2022a=9.12" "R2021b=9.11" "R2021a=9.10" @@ -1765,7 +1766,11 @@ endif() if(APPLE) set(_matlab_bin_prefix "mac") # i should be for intel set(_matlab_bin_suffix_32bits "i") - set(_matlab_bin_suffix_64bits "i64") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + set(_matlab_bin_suffix_64bits "a64") + else() + set(_matlab_bin_suffix_64bits "i64") + endif() elseif(UNIX) set(_matlab_bin_prefix "gln") set(_matlab_bin_suffix_32bits "x86") diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake index 71bd84f..e05d0c6 100644 --- a/Modules/FindOpenACC.cmake +++ b/Modules/FindOpenACC.cmake @@ -187,7 +187,7 @@ function(_OPENACC_GET_FLAGS LANG FLAG_VAR) _OPENACC_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenACCTryFlag _OPENACC_TEST_SRC) foreach(FLAG IN LISTS FLAG_CANDIDATES) - try_compile(OpenACC_FLAG_TEST_RESULT ${CMAKE_BINARY_DIR} ${_OPENACC_TEST_SRC} + try_compile(OpenACC_FLAG_TEST_RESULT SOURCES ${_OPENACC_TEST_SRC} CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${FLAG}" OUTPUT_VARIABLE OpenACC_TRY_COMPILE_OUTPUT ) @@ -215,7 +215,7 @@ function(_OPENACC_GET_SPEC_DATE LANG SPEC_DATE) _OPENACC_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenACCCheckVersion _OPENACC_TEST_SRC) set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC/accver_${LANG}.bin") - try_compile(OpenACC_SPECTEST_${LANG} "${CMAKE_BINARY_DIR}" "${_OPENACC_TEST_SRC}" + try_compile(OpenACC_SPECTEST_${LANG} SOURCES "${_OPENACC_TEST_SRC}" CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenACC_${LANG}_FLAGS}" COPY_FILE ${BIN_FILE} OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 8a061e2..040cbe9 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -214,7 +214,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) string(APPEND OPENMP_FLAGS_TEST " ${OpenMP_VERBOSE_COMPILE_OPTIONS}") endif() string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCES ${_OPENMP_TEST_SRC} CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -311,7 +312,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) # Try without specifying include directory first. We only want to # explicitly add a search path if the header can't be found on the # default header search path already. - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCES ${_OPENMP_TEST_SRC} CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -321,7 +323,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) mark_as_advanced(OpenMP_${LANG}_INCLUDE_DIR) set(OpenMP_${LANG}_INCLUDE_DIR "${OpenMP_${LANG}_INCLUDE_DIR}" PARENT_SCOPE) if(OpenMP_${LANG}_INCLUDE_DIR) - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCES ${_OPENMP_TEST_SRC} CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} @@ -343,7 +346,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) ) mark_as_advanced(OpenMP_libomp_LIBRARY) if(OpenMP_libomp_LIBRARY) - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCES ${_OPENMP_TEST_SRC} CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -414,7 +418,8 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin") string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") - try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} "${CMAKE_BINARY_DIR}" "${_OPENMP_TEST_SRC}" + try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} + SOURCES "${_OPENMP_TEST_SRC}" CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" ${_includeDirFlags} COPY_FILE ${BIN_FILE} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 6de7dbf..56ba1e6 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -538,17 +538,21 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) # 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(NOT "${${FPHSA_VERSION_VAR}}" STREQUAL "") - set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - if (FPHSA_HANDLE_VERSION_RANGE) - set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) + 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) + else() + set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) + endif() + find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG + ${FPCV_HANDLE_VERSION_RANGE}) else() - set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) + set(VERSION_OK FALSE) endif() - find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG - ${FPCV_HANDLE_VERSION_RANGE}) - else() - set(VERSION_OK FALSE) + endif() + if("${${FPHSA_VERSION_VAR}}" STREQUAL "") # 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/FindThreads.cmake b/Modules/FindThreads.cmake index a675fd6..f9ffb40 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -135,8 +135,7 @@ macro(_threads_check_flag_pthread) configure_file(${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c "${_threads_src}" COPYONLY) endif() try_compile(THREADS_HAVE_PTHREAD_ARG - ${CMAKE_BINARY_DIR} - ${_threads_src} + SOURCES ${_threads_src} CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread OUTPUT_VARIABLE _cmake_check_pthreads_output) diff --git a/Modules/Internal/CheckSourceCompiles.cmake b/Modules/Internal/CheckSourceCompiles.cmake index 27aa3e0..a4415c4 100644 --- a/Modules/Internal/CheckSourceCompiles.cmake +++ b/Modules/Internal/CheckSourceCompiles.cmake @@ -93,8 +93,7 @@ function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) message(CHECK_START "Performing Test ${_var}") endif() try_compile(${_var} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES} diff --git a/Modules/Internal/CheckSourceRuns.cmake b/Modules/Internal/CheckSourceRuns.cmake index 75e9896..4d58bb6 100644 --- a/Modules/Internal/CheckSourceRuns.cmake +++ b/Modules/Internal/CheckSourceRuns.cmake @@ -92,8 +92,7 @@ function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var) message(CHECK_START "Performing Test ${_var}") endif() try_run(${_var}_EXITCODE ${_var}_COMPILED - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} + SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_${_lang}_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_${_lang}_SOURCE_COMPILES_ADD_LIBRARIES} diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index b6f3c09..0b10032 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -31,7 +31,7 @@ macro(_record_compiler_features lang compile_flags feature_list) endif() try_compile(CMAKE_${lang}_FEATURE_TEST - ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" + SOURCES "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" COMPILE_DEFINITIONS "${compile_flags}" LINK_LIBRARIES "${compile_flags_for_link}" OUTPUT_VARIABLE _output diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 3941311..5edcb61 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -89,17 +89,27 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd) if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) - set(__ADDED_FLAGS "") - set(__ADDED_FLAGS_DEBUG "") + set(_RTL_FLAGS "") + set(_RTL_FLAGS_DEBUG "") else() - set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd") - set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt") + set(_RTL_FLAGS_DEBUG " -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd") + set(_RTL_FLAGS " -D_DLL -D_MT -Xclang --dependent-lib=msvcrt") endif() - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}") - string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}") + if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + set(_DBG_FLAGS "") + else() + set(_DBG_FLAGS " -g -Xclang -gcodeview") + endif() + + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -O0${_DBG_FLAGS}${_RTL_FLAGS_DEBUG}") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG${_RTL_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG${_RTL_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -DNDEBUG${_DBG_FLAGS}${_RTL_FLAGS}") + + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -g -Xclang -gcodeview) + #set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase) # not supported by Clang + #set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue) # not supported by Clang endif() set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) @@ -109,8 +119,9 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>) set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}}) - unset(__ADDED_FLAGS) - unset(__ADDED_FLAGS_DEBUG) + unset(_DBG_FLAGS) + unset(_RTL_FLAGS) + unset(_RTL_FLAGS_DEBUG) string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER) set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames") @@ -190,6 +201,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" macro(__windows_compiler_clang_base lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) + unset(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue) # -ZI not supported by Clang set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc") endmacro() @@ -202,6 +214,14 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" endif() unset(__WINDOWS_CLANG_CMP0091) + cmake_policy(GET CMP0141 __WINDOWS_MSVC_CMP0141) + if(__WINDOWS_MSVC_CMP0141 STREQUAL "NEW") + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>") + else() + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "") + endif() + unset(__WINDOWS_MSVC_CMP0141) + set(CMAKE_BUILD_TYPE_INIT Debug) __enable_llvm_rc_preprocessing("" "-x c") diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake index e4d9b93..8ae6852 100644 --- a/Modules/Platform/Windows-Intel-C.cmake +++ b/Modules/Platform/Windows-Intel-C.cmake @@ -19,9 +19,8 @@ if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) endif() -if("${CMAKE_SOURCE_DIR}${CMAKE_BINARY_DIR}" MATCHES " ") - # The Intel compiler does not properly escape spaces in a depfile. - # Fall back to msvc depfile format. - set(CMAKE_DEPFILE_FLAGS_C "/showIncludes") - set(CMAKE_C_DEPFILE_FORMAT msvc) -endif() +# The Intel compiler does not properly escape spaces in a depfile which can +# occur in source and binary cmake paths as well as external include paths. +# Until Intel fixes this bug, fall back unconditionally to msvc depfile format. +set(CMAKE_DEPFILE_FLAGS_C "/showIncludes") +set(CMAKE_C_DEPFILE_FORMAT msvc) diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake index 6adbb6e..e2fa2af 100644 --- a/Modules/Platform/Windows-Intel-CXX.cmake +++ b/Modules/Platform/Windows-Intel-CXX.cmake @@ -20,9 +20,8 @@ if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) endif() -if("${CMAKE_SOURCE_DIR}${CMAKE_BINARY_DIR}" MATCHES " ") - # The Intel compiler does not properly escape spaces in a depfile. - # Fall back to msvc depfile format. - set(CMAKE_DEPFILE_FLAGS_CXX "/showIncludes") - set(CMAKE_CXX_DEPFILE_FORMAT msvc) -endif() +# The Intel compiler does not properly escape spaces in a depfile which can +# occur in source and binary cmake paths as well as external include paths. +# Until Intel fixes this bug, fall back unconditionally to msvc depfile format. +set(CMAKE_DEPFILE_FLAGS_CXX "/showIncludes") +set(CMAKE_CXX_DEPFILE_FORMAT msvc) diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake index e3804fb..c9b70d5 100644 --- a/Modules/Platform/Windows-Intel-Fortran.cmake +++ b/Modules/Platform/Windows-Intel-Fortran.cmake @@ -33,6 +33,8 @@ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -th set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi) # Intel Fortran for Windows supports single-threaded RTL but it is # not implemented by the Visual Studio integration. diff --git a/Modules/Platform/Windows-IntelLLVM-Fortran.cmake b/Modules/Platform/Windows-IntelLLVM-Fortran.cmake index 06d0a00..202ba23 100644 --- a/Modules/Platform/Windows-IntelLLVM-Fortran.cmake +++ b/Modules/Platform/Windows-IntelLLVM-Fortran.cmake @@ -33,6 +33,8 @@ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -th set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi) # Intel Fortran for Windows supports single-threaded RTL but it is # not implemented by the Visual Studio integration. diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e74ec9e..8e96bf4 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -331,6 +331,13 @@ else() endif() unset(__WINDOWS_MSVC_CMP0091) +cmake_policy(GET CMP0141 __WINDOWS_MSVC_CMP0141) +if(__WINDOWS_MSVC_CMP0141 STREQUAL "NEW") + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>") +else() + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "") +endif() +unset(__WINDOWS_MSVC_CMP0141) # Features for LINK_LIBRARY generator expression if(MSVC_VERSION GREATER "1900") @@ -441,6 +448,12 @@ macro(__windows_compiler_msvc lang) endif() unset(_cmp0092) + if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + set(_Zi "") + else() + set(_Zi " /Zi") + endif() + if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects # that include MS's own headers. CMake itself is affected project too. @@ -451,20 +464,24 @@ macro(__windows_compiler_msvc lang) string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang else() string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS${_W3}${_FLAGS_${lang}}") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd} /Zi /Ob0 /Od ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd}${_Zi} /Ob0 /Od ${_RTC1}") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT "${_MD} /O2 /Ob2 /DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD} /Zi /O2 /Ob1 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD}${_Zi} /O2 /Ob1 /DNDEBUG") string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} /O1 /Ob1 /DNDEBUG") endif() unset(_Wall) unset(_W3) unset(_MDd) unset(_MD) + unset(_Zi) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -MT) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -MD) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -MTd) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -MDd) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue -ZI) endif() set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index 6c1699b..326e715 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -57,6 +57,12 @@ else() set(_MD "-MD ") endif() +if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + set(_Zi "") +else() + set(_Zi " -Zi") +endif() + cmake_policy(GET CMP0092 _cmp0092) if(_cmp0092 STREQUAL "NEW") set(_W3 "") @@ -66,11 +72,12 @@ endif() unset(_cmp0092) string(APPEND CMAKE_CUDA_FLAGS_INIT " ${PLATFORM_DEFINES_CUDA} -D_WINDOWS -Xcompiler=\"${_W3}${_FLAGS_CXX}\"") -string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"${_MDd}-Zi -Ob0 -Od ${_RTC1}\"") +string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"${_MDd}${_Zi} -Ob0 -Od ${_RTC1}\"") string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"${_MD}-O2 -Ob2\" -DNDEBUG") -string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"${_MD}-Zi -O2 -Ob1\" -DNDEBUG") +string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"${_MD}${_Zi} -O2 -Ob1\" -DNDEBUG") string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Xcompiler=\"${_MD}-O1 -Ob1\" -DNDEBUG") unset(_W3) +unset(_Zi) unset(_MDd) unset(_MD) @@ -78,6 +85,9 @@ set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xcomp set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -Xcompiler=-MD) set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -Xcompiler=-MTd) set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -Xcompiler=-MDd) +set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Xcompiler=-Z7) +set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Xcompiler=-Zi) +set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue -Xcompiler=-ZI) set(CMAKE_CUDA_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index ea8ca73..e738d32 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -89,8 +89,7 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE) file(READ ${_test_file} TEST_ENDIANESS_FILE_CONTENT) try_compile(HAVE_${VARIABLE} - "${CMAKE_BINARY_DIR}" - ${_test_file} + SOURCES ${_test_file} OUTPUT_VARIABLE OUTPUT COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" ) diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index ce505f3..2e511ae 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -25,8 +25,7 @@ macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE) if(NOT DEFINED ${VARIABLE}) message(CHECK_START "Checking to see if CXX compiler accepts flag ${FLAGS}") try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx + SOURCES ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS} OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake index 0f2dc01..06db586 100644 --- a/Modules/TestForANSIForScope.cmake +++ b/Modules/TestForANSIForScope.cmake @@ -17,8 +17,8 @@ for-init-statement to the loop body. if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE) message(CHECK_START "Check for ANSI scope") - try_compile(CMAKE_ANSI_FOR_SCOPE ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx + try_compile(CMAKE_ANSI_FOR_SCOPE + SOURCES ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_ANSI_FOR_SCOPE) message(CHECK_PASS "found") diff --git a/Modules/TestForSSTREAM.cmake b/Modules/TestForSSTREAM.cmake index 545b7ec..9a09ac7 100644 --- a/Modules/TestForSSTREAM.cmake +++ b/Modules/TestForSSTREAM.cmake @@ -16,8 +16,8 @@ check if the compiler supports the standard ANSI sstream header if(NOT DEFINED CMAKE_HAS_ANSI_STRING_STREAM) message(CHECK_START "Check for sstream") - try_compile(CMAKE_HAS_ANSI_STRING_STREAM ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/TestForSSTREAM.cxx + try_compile(CMAKE_HAS_ANSI_STRING_STREAM + SOURCES ${CMAKE_ROOT}/Modules/TestForSSTREAM.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_HAS_ANSI_STRING_STREAM) message(CHECK_PASS "found") diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake index d101c83..cd9c782 100644 --- a/Modules/TestForSTDNamespace.cmake +++ b/Modules/TestForSTDNamespace.cmake @@ -16,8 +16,8 @@ check if the compiler supports std:: on stl classes if(NOT DEFINED CMAKE_STD_NAMESPACE) message(CHECK_START "Check for STD namespace") - try_compile(CMAKE_STD_NAMESPACE ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx + try_compile(CMAKE_STD_NAMESPACE + SOURCES ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_STD_NAMESPACE) message(CHECK_PASS "found") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3eb1666..488c8a9 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 20220913) +set(CMake_VERSION_PATCH 20220919) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index c168a45..7fbcdab 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: @@ -1147,10 +1147,12 @@ void cmCMakePresetsGraph::ClearPresets() this->ConfigurePresets.clear(); this->BuildPresets.clear(); this->TestPresets.clear(); + this->PackagePresets.clear(); this->ConfigurePresetOrder.clear(); this->BuildPresetOrder.clear(); this->TestPresetOrder.clear(); + this->PackagePresetOrder.clear(); this->Files.clear(); } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 850b7a3..cda70fc 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -368,6 +368,10 @@ cmComputeLinkInformation::cmComputeLinkInformation( LibraryFeatureDescriptor{ "__CMAKE_LINK_EXECUTABLE", cmStrCat(this->LoaderFlag, "<LIBRARY>") }); } + // To link framewortk using a full path + this->LibraryFeatureDescriptors.emplace( + "__CMAKE_LINK_FRAMEWORK", + LibraryFeatureDescriptor{ "__CMAKE_LINK_FRAMEWORK", "<LIBRARY>" }); // Check the platform policy for missing soname case. this->NoSONameUsesPath = @@ -1560,12 +1564,6 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) this->OldLinkDirItems.push_back(item.Value); } - if (target->IsFrameworkOnApple() && this->GlobalGenerator->IsXcode() && - entry.Feature == DEFAULT) { - // ensure FRAMEWORK feature is loaded - this->AddLibraryFeature("FRAMEWORK"); - } - if (target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) { // Add the framework directory and the framework item itself auto fwItems = this->GlobalGenerator->SplitFrameworkPath(item.Value, true); @@ -1597,7 +1595,7 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) this->FindLibraryFeature( entry.Feature == DEFAULT ? (target->IsFrameworkOnApple() && this->GlobalGenerator->IsXcode() - ? "FRAMEWORK" + ? "__CMAKE_LINK_FRAMEWORK" : "__CMAKE_LINK_LIBRARY") : entry.Feature)); } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 654c9a3..2f63b3c 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -95,6 +95,8 @@ std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES = std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED"; std::string const kCMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT = "CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT"; +std::string const kCMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT = + "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT"; /* GHS Multi platform variables */ std::set<std::string> const ghs_platform_vars{ @@ -119,6 +121,26 @@ ArgumentParser::Continue TryCompileCompileDefs(Arguments& args, return ArgumentParser::Continue::Yes; } +cmArgumentParser<Arguments> makeTryCompileParser( + const cmArgumentParser<Arguments>& base) +{ + return cmArgumentParser<Arguments>{ base }.Bind("OUTPUT_VARIABLE"_s, + &Arguments::OutputVariable); +} + +cmArgumentParser<Arguments> makeTryRunParser( + const cmArgumentParser<Arguments>& base) +{ + return cmArgumentParser<Arguments>{ base } + .Bind("COMPILE_OUTPUT_VARIABLE"_s, &Arguments::CompileOutputVariable) + .Bind("RUN_OUTPUT_VARIABLE"_s, &Arguments::RunOutputVariable) + .Bind("RUN_OUTPUT_STDOUT_VARIABLE"_s, &Arguments::RunOutputStdOutVariable) + .Bind("RUN_OUTPUT_STDERR_VARIABLE"_s, &Arguments::RunOutputStdErrVariable) + .Bind("WORKING_DIRECTORY"_s, &Arguments::RunWorkingDirectory) + .Bind("ARGS"_s, &Arguments::RunArgs) + /* keep semicolon on own line */; +} + #define BIND_LANG_PROPS(lang) \ Bind(#lang "_STANDARD"_s, TryCompileLangProp) \ .Bind(#lang "_STANDARD_REQUIRED"_s, TryCompileLangProp) \ @@ -127,13 +149,17 @@ ArgumentParser::Continue TryCompileCompileDefs(Arguments& args, auto const TryCompileBaseArgParser = cmArgumentParser<Arguments>{} .Bind(0, &Arguments::CompileResultVariable) - .Bind("SOURCES"_s, &Arguments::Sources) .Bind("CMAKE_FLAGS"_s, &Arguments::CMakeFlags) + .Bind("__CMAKE_INTERNAL"_s, &Arguments::CMakeInternal) + /* keep semicolon on own line */; + +auto const TryCompileBaseNonProjectArgParser = + cmArgumentParser<Arguments>{ TryCompileBaseArgParser } + .Bind("SOURCES"_s, &Arguments::Sources) .Bind("COMPILE_DEFINITIONS"_s, TryCompileCompileDefs, ArgumentParser::ExpectAtLeast{ 0 }) .Bind("LINK_LIBRARIES"_s, &Arguments::LinkLibraries) .Bind("LINK_OPTIONS"_s, &Arguments::LinkOptions) - .Bind("__CMAKE_INTERNAL"_s, &Arguments::CMakeInternal) .Bind("COPY_FILE"_s, &Arguments::CopyFileTo) .Bind("COPY_FILE_ERROR"_s, &Arguments::CopyFileError) .BIND_LANG_PROPS(C) @@ -144,38 +170,35 @@ auto const TryCompileBaseArgParser = .BIND_LANG_PROPS(OBJCXX) /* keep semicolon on own line */; -auto const TryCompileArgParser = - cmArgumentParser<Arguments>{ TryCompileBaseArgParser }.Bind( - "OUTPUT_VARIABLE"_s, &Arguments::OutputVariable) +auto const TryCompileBaseProjectArgParser = + cmArgumentParser<Arguments>{ TryCompileBaseArgParser } + .Bind("PROJECT"_s, &Arguments::ProjectName) + .Bind("SOURCE_DIR"_s, &Arguments::SourceDirectoryOrFile) + .Bind("BINARY_DIR"_s, &Arguments::BinaryDirectory) + .Bind("TARGET"_s, &Arguments::TargetName) /* keep semicolon on own line */; +auto const TryCompileProjectArgParser = + makeTryCompileParser(TryCompileBaseProjectArgParser); + +auto const TryCompileSourcesArgParser = + makeTryCompileParser(TryCompileBaseNonProjectArgParser); + auto const TryCompileOldArgParser = - cmArgumentParser<Arguments>{ TryCompileArgParser } + makeTryCompileParser(TryCompileBaseNonProjectArgParser) .Bind(1, &Arguments::BinaryDirectory) .Bind(2, &Arguments::SourceDirectoryOrFile) .Bind(3, &Arguments::ProjectName) .Bind(4, &Arguments::TargetName) /* keep semicolon on own line */; -auto const TryRunArgParser = - cmArgumentParser<Arguments>{ TryCompileBaseArgParser } - .Bind("COMPILE_OUTPUT_VARIABLE"_s, &Arguments::CompileOutputVariable) - .Bind("RUN_OUTPUT_VARIABLE"_s, &Arguments::RunOutputVariable) - .Bind("RUN_OUTPUT_STDOUT_VARIABLE"_s, &Arguments::RunOutputStdOutVariable) - .Bind("RUN_OUTPUT_STDERR_VARIABLE"_s, &Arguments::RunOutputStdErrVariable) - .Bind("WORKING_DIRECTORY"_s, &Arguments::RunWorkingDirectory) - .Bind("ARGS"_s, &Arguments::RunArgs) - /* keep semicolon on own line */; +auto const TryRunProjectArgParser = + makeTryRunParser(TryCompileBaseProjectArgParser); -auto const TryRunOldArgParser = - cmArgumentParser<Arguments>{ TryCompileOldArgParser } - .Bind("COMPILE_OUTPUT_VARIABLE"_s, &Arguments::CompileOutputVariable) - .Bind("RUN_OUTPUT_VARIABLE"_s, &Arguments::RunOutputVariable) - .Bind("RUN_OUTPUT_STDOUT_VARIABLE"_s, &Arguments::RunOutputStdOutVariable) - .Bind("RUN_OUTPUT_STDERR_VARIABLE"_s, &Arguments::RunOutputStdErrVariable) - .Bind("WORKING_DIRECTORY"_s, &Arguments::RunWorkingDirectory) - .Bind("ARGS"_s, &Arguments::RunArgs) - /* keep semicolon on own line */; +auto const TryRunSourcesArgParser = + makeTryRunParser(TryCompileBaseNonProjectArgParser); + +auto const TryRunOldArgParser = makeTryRunParser(TryCompileOldArgParser); #undef BIND_LANG_PROPS } @@ -201,11 +224,24 @@ Arguments cmCoreTryCompile::ParseArgs( cmRange<std::vector<std::string>::const_iterator> args, bool isTryRun) { std::vector<std::string> unparsedArguments; - if (cmHasLiteralPrefix(*(++args.begin()), "SOURCE")) { - // New signature. - auto arguments = - this->ParseArgs(args, isTryRun ? TryRunArgParser : TryCompileArgParser, - unparsedArguments); + const auto& second = *(++args.begin()); + + if (second == "PROJECT") { + // New PROJECT signature. + auto arguments = this->ParseArgs( + args, isTryRun ? TryRunProjectArgParser : TryCompileProjectArgParser, + unparsedArguments); + if (!arguments.BinaryDirectory) { + arguments.BinaryDirectory = unique_binary_directory; + } + return arguments; + } + + if (cmHasLiteralPrefix(second, "SOURCE")) { + // New SOURCES signature. + auto arguments = this->ParseArgs( + args, isTryRun ? TryRunSourcesArgParser : TryCompileSourcesArgParser, + unparsedArguments); arguments.BinaryDirectory = unique_binary_directory; return arguments; } @@ -254,8 +290,14 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, std::string sourceDirectory; std::string projectName; std::string targetName; - if (arguments.SourceDirectoryOrFile && arguments.ProjectName) { + if (arguments.ProjectName) { this->SrcFileSignature = false; + if (!arguments.SourceDirectoryOrFile || + arguments.SourceDirectoryOrFile->empty()) { + this->Makefile->IssueMessage(MessageType::FATAL_ERROR, + "No <srcdir> specified."); + return false; + } sourceDirectory = *arguments.SourceDirectoryOrFile; projectName = *arguments.ProjectName; if (arguments.TargetName) { @@ -498,6 +540,14 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, *cmp0123 == "NEW"_s ? "NEW" : "OLD"); } + /* Set MSVC debug information format policy to match our selection. */ + if (cmValue msvcDebugInformationFormatDefault = + this->Makefile->GetDefinition( + kCMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT)) { + fprintf(fout, "cmake_policy(SET CMP0141 %s)\n", + !msvcDebugInformationFormatDefault->empty() ? "NEW" : "OLD"); + } + /* Set cache/normal variable policy to match outer project. It may affect toolchain files. */ if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) != @@ -861,6 +911,7 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, vars.insert(kCMAKE_WARN_DEPRECATED); vars.emplace("CMAKE_MSVC_RUNTIME_LIBRARY"_s); vars.emplace("CMAKE_WATCOM_RUNTIME_LIBRARY"_s); + vars.emplace("CMAKE_MSVC_DEBUG_INFORMATION_FORMAT"_s); if (cmValue varListStr = this->Makefile->GetDefinition( kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) { diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 7d8572d..195737b 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -436,7 +436,10 @@ void cmExportInstallFileGenerator::SetImportLocationProperty( // Append the installed file name. if (target->IsAppBundleOnApple()) { value += cmInstallTargetGenerator::GetInstallFilename(target, config); - value += ".app/Contents/MacOS/"; + value += ".app/"; + if (!target->Makefile->PlatformIsAppleEmbedded()) { + value += "Contents/MacOS/"; + } value += cmInstallTargetGenerator::GetInstallFilename(target, config); } else { value += cmInstallTargetGenerator::GetInstallFilename( diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 09aaa24..8130521 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -50,6 +50,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" #include "cmVersion.h" @@ -2579,7 +2580,7 @@ cmGlobalGenerator::SplitFrameworkPath(const std::string& path, auto name = frameworkPath.match(3); auto libname = cmSystemTools::GetFilenameWithoutExtension(frameworkPath.match(6)); - if (!libname.empty() && name != libname) { + if (!libname.empty() && !cmHasPrefix(libname, name)) { return cm::nullopt; } return std::pair<std::string, std::string>{ frameworkPath.match(2), name }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index eb85b47..2c455cf 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3776,14 +3776,20 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) // add the library search paths { BuildObjectListOrString libSearchPaths(this, true); + std::string linkDirs; for (auto const& libDir : cli->GetDirectories()) { if (!libDir.empty() && libDir != "/usr/lib") { - libSearchPaths.Add(this->XCodeEscapePath( - libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)")); + cmPolicies::PolicyStatus cmp0142 = + target->GetTarget()->GetPolicyStatusCMP0142(); + if (cmp0142 == cmPolicies::OLD || cmp0142 == cmPolicies::WARN) { + libSearchPaths.Add(this->XCodeEscapePath( + libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)")); + } libSearchPaths.Add(this->XCodeEscapePath(libDir)); } } + // Add previously collected paths where to look for libraries // that were added to "Link Binary With Libraries" for (auto& libDir : linkSearchPaths) { @@ -3841,9 +3847,17 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) // an implicit search path, so we need it libPaths.Add("-F " + this->XCodeEscapePath(fwItems->first)); } - libPaths.Add( - libName.GetFormattedItem(this->XCodeEscapePath(fwItems->second)) - .Value); + if (libName.GetFeatureName() == "__CMAKE_LINK_FRAMEWORK"_s) { + // use the full path + libPaths.Add( + libName.GetFormattedItem(this->XCodeEscapePath(cleanPath)) + .Value); + } else { + libPaths.Add( + libName + .GetFormattedItem(this->XCodeEscapePath(fwItems->second)) + .Value); + } } else { libPaths.Add( libName.GetFormattedItem(this->XCodeEscapePath(cleanPath)) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b44d2a0..defcba3 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2041,6 +2041,41 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } } } + + // Add MSVC debug information format flags. This is activated by the presence + // of a default selection whether or not it is overridden by a property. + cmValue msvcDebugInformationFormatDefault = this->Makefile->GetDefinition( + "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT"); + if (cmNonempty(msvcDebugInformationFormatDefault)) { + cmValue msvcDebugInformationFormatValue = + target->GetProperty("MSVC_DEBUG_INFORMATION_FORMAT"); + if (!msvcDebugInformationFormatValue) { + msvcDebugInformationFormatValue = msvcDebugInformationFormatDefault; + } + std::string const msvcDebugInformationFormat = + cmGeneratorExpression::Evaluate(*msvcDebugInformationFormatValue, this, + config, target); + if (!msvcDebugInformationFormat.empty()) { + if (cmValue msvcDebugInformationFormatOptions = + this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, + "_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_", + msvcDebugInformationFormat))) { + this->AppendCompileOptions(flags, *msvcDebugInformationFormatOptions); + } else if ((this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_COMPILER_ID")) == "MSVC"_s || + this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_SIMULATE_ID")) == "MSVC"_s) && + !cmSystemTools::GetErrorOccurredFlag()) { + // The compiler uses the MSVC ABI so it needs a known runtime library. + this->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("MSVC_DEBUG_INFORMATION_FORMAT value '", + msvcDebugInformationFormat, + "' not known for this ", lang, + " compiler.")); + } + } + } } void cmLocalGenerator::AddLanguageFlagsForLinking( diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index fdda31e..4643868 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -423,7 +423,15 @@ class cmMakefile; "The if() command supports path comparisons using PATH_EQUAL operator.", \ 3, 24, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0140, "The return() command checks its arguments.", 3, \ - 25, 0, cmPolicies::WARN) + 25, 0, cmPolicies::WARN) \ + SELECT( \ + POLICY, CMP0141, \ + "MSVC debug information format flags are selected by an abstraction.", 3, \ + 25, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0142, \ + "The Xcode generator does not append per-config suffixes to " \ + "library search paths.", \ + 3, 25, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ @@ -460,7 +468,8 @@ class cmMakefile; F(CMP0112) \ F(CMP0113) \ F(CMP0119) \ - F(CMP0131) + F(CMP0131) \ + F(CMP0142) /** \class cmPolicies * \brief Handles changes in CMake behavior and policies diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 25ff3bf..e8fdc39 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -563,6 +563,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("AUTORCC_OPTIONS"); initProp("LINK_DEPENDS_NO_SHARED"); initProp("LINK_INTERFACE_LIBRARIES"); + initProp("MSVC_DEBUG_INFORMATION_FORMAT"); initProp("MSVC_RUNTIME_LIBRARY"); initProp("WATCOM_RUNTIME_LIBRARY"); initProp("WIN32_EXECUTABLE"); diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index b59c225..a2c4ce1 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -16,12 +16,15 @@ bool cmTryCompileCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { + cmMakefile& mf = status.GetMakefile(); + if (args.size() < 3) { + mf.IssueMessage( + MessageType::FATAL_ERROR, + "The try_compile() command requires at least 3 arguments."); return false; } - cmMakefile& mf = status.GetMakefile(); - if (mf.GetCMakeInstance()->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) { mf.IssueMessage( MessageType::FATAL_ERROR, diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 7a29521..70c7cf1 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -469,12 +469,14 @@ void TryRunCommandImpl::DoNotRunExecutable( bool cmTryRunCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { + cmMakefile& mf = status.GetMakefile(); + if (args.size() < 4) { + mf.IssueMessage(MessageType::FATAL_ERROR, + "The try_run() command requires at least 4 arguments."); return false; } - cmMakefile& mf = status.GetMakefile(); - if (mf.GetCMakeInstance()->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) { mf.IssueMessage( MessageType::FATAL_ERROR, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 281e63f..3b105e3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1145,7 +1145,7 @@ void cmake::SetArgs(const std::vector<std::string>& args) } else { cmSystemTools::Error( "Invalid value specified for --list-presets.\n" - "Valid values are configure, build, test, or all. " + "Valid values are configure, build, test, package, or all. " "When no value is passed the default is configure."); return false; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b6fec4d..abe742e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2080,6 +2080,15 @@ if(BUILD_TESTING) if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") ADD_TEST_MACRO(PrecompiledHeader foo) endif() + + set(MSVCDebugInformationFormat_BUILD_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + if(CMAKE_Fortran_COMPILER) + list(APPEND MSVCDebugInformationFormat_BUILD_OPTIONS -DCMake_TEST_Fortran=1) + endif() + ADD_TEST_MACRO(MSVCDebugInformationFormat) + set_property(TEST MSVCDebugInformationFormat APPEND + PROPERTY LABELS "CUDA") + set(MSVCRuntimeLibrary_BUILD_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) ADD_TEST_MACRO(MSVCRuntimeLibrary) set_property(TEST MSVCRuntimeLibrary APPEND diff --git a/Tests/MSVCDebugInformationFormat/CMakeLists.txt b/Tests/MSVCDebugInformationFormat/CMakeLists.txt new file mode 100644 index 0000000..b09bc6c --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 3.24) +cmake_policy(SET CMP0141 NEW) + +# The debug information format flags do not change preprocessor definitions, +# so override our table of flags to artificially add a definition we can check. +set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/override-C.cmake) +set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/override-CXX.cmake) +set(CMAKE_USER_MAKE_RULES_OVERRIDE_CUDA ${CMAKE_CURRENT_SOURCE_DIR}/override-CUDA.cmake) +set(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran ${CMAKE_CURRENT_SOURCE_DIR}/override-Fortran.cmake) + +project(MSVCDebugInformationFormat) +if(CMake_TEST_CUDA) + enable_language(CUDA) +endif() +if(CMake_TEST_Fortran) + enable_language(Fortran) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +if("${CMAKE_C_COMPILER_ID};${CMAKE_C_SIMULATE_ID};${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "Clang;MSVC;GNU") + set(verify_default VERIFY_Z7) + set(NO_COMPILER_PDB 1) +elseif("${CMAKE_C_COMPILER_ID};${CMAKE_C_SIMULATE_ID};${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "Clang;MSVC;MSVC") + set(verify_default VERIFY_Zi) + set(NO_EDIT_AND_CONTINUE 1) +else() + set(verify_default VERIFY_Zi) +endif() + +set(verify_def_Embedded -DVERIFY_Z7) +set(verify_def_ProgramDatabase -DVERIFY_Zi) +set(verify_def_EditAndContinue -DVERIFY_ZI) + +function(verify_combination format lang src) + # Test that try_compile builds with this debug format. + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "${format}") + set(CMAKE_TRY_COMPILE_CONFIGURATION "Debug") + set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") + try_compile(${format}_COMPILES + ${CMAKE_CURRENT_BINARY_DIR}/try_compile/${format} + ${CMAKE_CURRENT_SOURCE_DIR}/${src} + COMPILE_DEFINITIONS ${verify_def_${format}} + CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE ${format}_OUTPUT + ) + if(${format}_COMPILES) + message(STATUS "try_compile ${lang} with ${format} worked") + else() + string(REPLACE "\n" "\n " ${format}_OUTPUT " ${${format}_OUTPUT}") + message(SEND_ERROR "try_compile ${lang} with ${format} failed:\n${${format}_OUTPUT}") + endif() + + # Test that targets build with this debug format. + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${format}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>") + add_library(${format}-${lang} ${src}) + set_property(TARGET ${format}-${lang} PROPERTY BOOL_TRUE TRUE) + target_compile_definitions(${format}-${lang} PRIVATE ${verify_def_${format}}) +endfunction() + +function(verify lang src) + add_library(default-${lang} ${src}) + target_compile_definitions(default-${lang} PRIVATE "$<$<CONFIG:Debug,RelWithDebInfo>:${verify_default}>") + + verify_combination(Embedded ${lang} ${src}) + if(NOT NO_COMPILER_PDB) + verify_combination(ProgramDatabase ${lang} ${src}) + if(NOT NO_EDIT_AND_CONTINUE AND NOT lang MATCHES "^(Fortran)$") + verify_combination(EditAndContinue ${lang} ${src}) + endif() + endif() +endfunction() + +verify(C verify.c) +verify(CXX verify.cxx) +if(CMake_TEST_CUDA) + verify(CUDA verify.cu) +endif() +if(CMake_TEST_Fortran) + verify(Fortran verify.F90) +endif() diff --git a/Tests/MSVCDebugInformationFormat/override-C.cmake b/Tests/MSVCDebugInformationFormat/override-C.cmake new file mode 100644 index 0000000..e8f5ae4 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/override-C.cmake @@ -0,0 +1,7 @@ +set(var "CMAKE_C_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded") +string(REPLACE "-Z7" "-Z7;-DTEST_Z7" "${var}" "${${var}}") +string(REPLACE "-gcodeview" "-gcodeview;-DTEST_Z7" "${var}" "${${var}}") +set(var "CMAKE_C_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase") +string(REPLACE "-Zi" "-Zi;-DTEST_Zi" "${var}" "${${var}}") +set(var "CMAKE_C_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue") +string(REPLACE "-ZI" "-ZI;-DTEST_ZI" "${var}" "${${var}}") diff --git a/Tests/MSVCDebugInformationFormat/override-CUDA.cmake b/Tests/MSVCDebugInformationFormat/override-CUDA.cmake new file mode 100644 index 0000000..f870775 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/override-CUDA.cmake @@ -0,0 +1,6 @@ +set(var "CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded") +string(REPLACE "-Z7" "-Z7;-DTEST_Z7" "${var}" "${${var}}") +set(var "CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase") +string(REPLACE "-Zi" "-Zi;-DTEST_Zi" "${var}" "${${var}}") +set(var "CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue") +string(REPLACE "-ZI" "-ZI;-DTEST_ZI" "${var}" "${${var}}") diff --git a/Tests/MSVCDebugInformationFormat/override-CXX.cmake b/Tests/MSVCDebugInformationFormat/override-CXX.cmake new file mode 100644 index 0000000..caa23fe --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/override-CXX.cmake @@ -0,0 +1,7 @@ +set(var "CMAKE_CXX_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded") +string(REPLACE "-Z7" "-Z7;-DTEST_Z7" "${var}" "${${var}}") +string(REPLACE "-gcodeview" "-gcodeview;-DTEST_Z7" "${var}" "${${var}}") +set(var "CMAKE_CXX_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase") +string(REPLACE "-Zi" "-Zi;-DTEST_Zi" "${var}" "${${var}}") +set(var "CMAKE_CXX_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue") +string(REPLACE "-ZI" "-ZI;-DTEST_ZI" "${var}" "${${var}}") diff --git a/Tests/MSVCDebugInformationFormat/override-Fortran.cmake b/Tests/MSVCDebugInformationFormat/override-Fortran.cmake new file mode 100644 index 0000000..5d2db58 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/override-Fortran.cmake @@ -0,0 +1,4 @@ +set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded") +string(REPLACE "-Z7" "-Z7;-DTEST_Z7" "${var}" "${${var}}") +set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase") +string(REPLACE "-Zi" "-Zi;-DTEST_Zi" "${var}" "${${var}}") diff --git a/Tests/MSVCDebugInformationFormat/verify.F90 b/Tests/MSVCDebugInformationFormat/verify.F90 new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/verify.F90 @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/MSVCDebugInformationFormat/verify.c b/Tests/MSVCDebugInformationFormat/verify.c new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/verify.c @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/MSVCDebugInformationFormat/verify.cu b/Tests/MSVCDebugInformationFormat/verify.cu new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/verify.cu @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/MSVCDebugInformationFormat/verify.cxx b/Tests/MSVCDebugInformationFormat/verify.cxx new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/verify.cxx @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/MSVCDebugInformationFormat/verify.h b/Tests/MSVCDebugInformationFormat/verify.h new file mode 100644 index 0000000..4bd6529 --- /dev/null +++ b/Tests/MSVCDebugInformationFormat/verify.h @@ -0,0 +1,29 @@ +#ifdef VERIFY_Z7 +# ifndef TEST_Z7 +# error "TEST_Z7 incorrectly not defined by debug format selection" +# endif +#else +# ifdef TEST_Z7 +# error "TEST_Z7 incorrectly defined by non-debug format selection" +# endif +#endif + +#ifdef VERIFY_Zi +# ifndef TEST_Zi +# error "TEST_Zi incorrectly not defined by debug format selection" +# endif +#else +# ifdef TEST_Zi +# error "TEST_Zi incorrectly defined by non-debug format selection" +# endif +#endif + +#ifdef VERIFY_ZI +# ifndef TEST_ZI +# error "TEST_ZI incorrectly not defined by debug format selection" +# endif +#else +# ifdef TEST_ZI +# error "TEST_ZI incorrectly defined by non-debug format selection" +# endif +#endif diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 42ff450..db4200b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -359,6 +359,7 @@ if(MSVC) add_RunCMake_test(MSVCRuntimeLibrary) add_RunCMake_test(MSVCRuntimeTypeInfo) add_RunCMake_test(MSVCWarningFlags) + add_RunCMake_test(MSVCDebugInformationFormat) endif() if(XCODE_VERSION) set(ObjectLibrary_ARGS -DXCODE_VERSION=${XCODE_VERSION}) diff --git a/Tests/RunCMake/CMakePresets/ListPresetsInvalidType-result.txt b/Tests/RunCMake/CMakePresets/ListPresetsInvalidType-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsInvalidType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ListPresetsInvalidType-stderr.txt b/Tests/RunCMake/CMakePresets/ListPresetsInvalidType-stderr.txt new file mode 100644 index 0000000..153abee --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsInvalidType-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error: Invalid value specified for --list-presets\. +Valid values are configure, build, test, package, or all\. When no value is passed the default is configure\. +CMake Error: Run 'cmake --help' for all supported options\.$ diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index c511b34..4f57e2f 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -289,6 +289,7 @@ run_cmake_presets(UserInheritance) # Test listing presets set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/ListPresets.json.in") run_cmake_presets(ListPresets --list-presets) +run_cmake_presets(ListPresetsInvalidType --list-presets=invalid-type) set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ListPresetsWorkingDir") set(RunCMake_TEST_NO_CLEAN 1) 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/CUDA_architectures/architectures-suffix-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt index 7b6eb53..ce40a7a 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt @@ -1,4 +1,4 @@ ^(CMake Warning in [^ -]*/Tests/RunCMake/CUDA_architectures/architectures-suffix-build/CMakeFiles/CMakeTmp/CMakeLists.txt: +]*/Tests/RunCMake/CUDA_architectures/architectures-suffix-build/CMakeFiles/CMakeScratch/TryCompile-[^/]*/CMakeLists.txt: Clang doesn't support disabling CUDA real code generation. *)*$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 7da0f8d..1b5a1d6 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -978,6 +978,8 @@ set(RunCMake_TEST_OPTIONS --debug-trycompile) run_cmake(debug-trycompile) unset(RunCMake_TEST_OPTIONS) +run_cmake(trycompile-clean) + function(run_cmake_depends) set(RunCMake_TEST_SOURCE_DIR "${RunCMake_SOURCE_DIR}/cmake_depends") set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/cmake_depends-build") diff --git a/Tests/RunCMake/CommandLine/debug-trycompile.cmake b/Tests/RunCMake/CommandLine/debug-trycompile.cmake index a3835a7..9619ba8 100644 --- a/Tests/RunCMake/CommandLine/debug-trycompile.cmake +++ b/Tests/RunCMake/CommandLine/debug-trycompile.cmake @@ -1,5 +1,8 @@ enable_language(C) + # Look for a source tree left by enable_language internal checks. -if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeLists.txt) +set(scratch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeScratch) +file(GLOB_RECURSE remnants ${scratch}/TryCompile-*/CMakeLists.txt) +if(NOT remnants) message(FATAL_ERROR "--debug-trycompile should leave the source behind") endif() diff --git a/Tests/RunCMake/CommandLine/trycompile-clean.cmake b/Tests/RunCMake/CommandLine/trycompile-clean.cmake new file mode 100644 index 0000000..11ec2b9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trycompile-clean.cmake @@ -0,0 +1,8 @@ +enable_language(C) + +# Look for a source tree left by enable_language internal checks. +set(scratch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeScratch) +file(GLOB_RECURSE remnants ${scratch}/TryCompile-*/*) +if(remnants) + message(FATAL_ERROR "try_compile should not leave artifacts behind") +endif() diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index e389e6b..3b095a6 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -44,6 +44,9 @@ run_cmake(exact_0_matching) set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=") run_cmake(empty_version) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}") +run_cmake(exact_1_no_version_var) + # 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/exact_1_no_version_var-stdout.txt b/Tests/RunCMake/FPHSA/exact_1_no_version_var-stdout.txt new file mode 100644 index 0000000..7cbdf6e --- /dev/null +++ b/Tests/RunCMake/FPHSA/exact_1_no_version_var-stdout.txt @@ -0,0 +1 @@ +-- Found Pseudo: TRUE \(Required is at least version "1"\) diff --git a/Tests/RunCMake/FPHSA/exact_1_no_version_var.cmake b/Tests/RunCMake/FPHSA/exact_1_no_version_var.cmake new file mode 100644 index 0000000..7b7ff34 --- /dev/null +++ b/Tests/RunCMake/FPHSA/exact_1_no_version_var.cmake @@ -0,0 +1 @@ +find_package(Pseudo 1 REQUIRED) diff --git a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake index 51e627d..3afda4d 100644 --- a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake +++ b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake @@ -23,3 +23,8 @@ string(APPEND content "set(target_file_name ${target_name})\n") file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkMultiConfigPostfixInfo.cmake CONTENT "${content}") + + +# Try to link this framework to ensure postfix is correctly handled +add_library(otherlib SHARED foo.c) +target_link_libraries(otherlib PRIVATE ${target_name}) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW-result.txt b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW-stderr.txt b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW-stderr.txt new file mode 100644 index 0000000..fb61d4b --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error in CMakeLists.txt: + MSVC_DEBUG_INFORMATION_FORMAT value 'BogusValue' not known for this (C|CXX) + compiler. ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW.cmake new file mode 100644 index 0000000..165ea38 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0141 NEW) +include(CMP0141-common.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NoEffect.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NoEffect.cmake new file mode 100644 index 0000000..82754a9 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-NoEffect.cmake @@ -0,0 +1,4 @@ +include(CMP0141-common.cmake) + +# Setting this policy after enable_language command has no effect. +cmake_policy(SET CMP0141 NEW) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-OLD.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-OLD.cmake new file mode 100644 index 0000000..7bbe586 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0141 OLD) +include(CMP0141-common.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-WARN.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-WARN.cmake new file mode 100644 index 0000000..912112a --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0141-common.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-common.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-common.cmake new file mode 100644 index 0000000..8e43a25 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-common.cmake @@ -0,0 +1,31 @@ +enable_language(CXX) + +cmake_policy(GET CMP0141 cmp0141) +if(cmp0141 STREQUAL "NEW") + if(NOT CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + message(SEND_ERROR "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT not set under NEW behavior") + endif() +else() + if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + message(SEND_ERROR "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT is set under OLD behavior") + endif() +endif() + +if(cmp0141 STREQUAL "NEW") + if(CMAKE_CXX_FLAGS_DEBUG MATCHES "[/-]Zi( |$)") + message(SEND_ERROR "CMAKE_CXX_FLAGS_DEBUG has -Zi flags under NEW behavior.") + endif() + if(CMAKE_CXX_FLAGS_RELWITHDEBINFO MATCHES "[/-]Zi( |$)") + message(SEND_ERROR "CMAKE_CXX_FLAGS_RELWITHDEBINFO has -Zi flags under NEW behavior.") + endif() +else() + if(NOT (CMAKE_CXX_FLAGS_DEBUG MATCHES "[/-]Zi( |$)")) + message(SEND_ERROR "CMAKE_CXX_FLAGS_DEBUG does not have -Zi flags under OLD behavior.") + endif() + if(NOT (CMAKE_CXX_FLAGS_RELWITHDEBINFO MATCHES "[/-]Zi( |$)")) + message(SEND_ERROR "CMAKE_CXX_FLAGS_RELWITHDEBINFO does not have -Zi flags under OLD behavior.") + endif() +endif() + +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT BogusValue) +add_library(foo empty.cxx) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMakeLists.txt b/Tests/RunCMake/MSVCDebugInformationFormat/CMakeLists.txt new file mode 100644 index 0000000..aba1016 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.24) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/RunCMakeTest.cmake b/Tests/RunCMake/MSVCDebugInformationFormat/RunCMakeTest.cmake new file mode 100644 index 0000000..f678acf --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(CMP0141-WARN) +run_cmake(CMP0141-OLD) +run_cmake(CMP0141-NEW) +run_cmake(CMP0141-NoEffect) diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/empty.cxx b/Tests/RunCMake/MSVCDebugInformationFormat/empty.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/MSVCDebugInformationFormat/empty.cxx diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 97c3394..0d8e4c9 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -36,6 +36,7 @@ \* CMP0113 \* CMP0119 \* CMP0131 + \* CMP0142 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/VS10Project/DebugInformationFormat-check.cmake b/Tests/RunCMake/VS10Project/DebugInformationFormat-check.cmake new file mode 100644 index 0000000..46af974 --- /dev/null +++ b/Tests/RunCMake/VS10Project/DebugInformationFormat-check.cmake @@ -0,0 +1,46 @@ +macro(DebugInformationFormat_check tgt Debug_expect Release_expect MinSizeRel_expect RelWithDebInfo_expect) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(Debug_actual "") + set(Release_actual "") + set(MinSizeRel_actual "") + set(RelWithDebInfo_actual "") + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<ItemDefinitionGroup Condition=\"'\\$\\(Configuration\\)\\|\\$\\(Platform\\)'=='([^<>]+)\\|[A-Za-z0-9_]+'\">") + set(Configuration "${CMAKE_MATCH_1}") + endif() + if(line MATCHES "^ *<DebugInformationFormat>([^<>]+)</DebugInformationFormat>") + set(${Configuration}_actual "${CMAKE_MATCH_1}") + endif() + endforeach() + + if (NOT "${Debug_actual}" STREQUAL "${Debug_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj Debug Configuration has DebugInformationFormat '${Debug_actual}', not '${Debug_expect}'.") + endif() + if (NOT "${Release_actual}" STREQUAL "${Release_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj Release Configuration has DebugInformationFormat '${Release_actual}', not '${Release_expect}'.") + endif() + if (NOT "${MinSizeRel_actual}" STREQUAL "${MinSizeRel_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj MinSizeRel Configuration has DebugInformationFormat '${MinSizeRel_actual}', not '${MinSizeRel_expect}'.") + endif() + if (NOT "${RelWithDebInfo_actual}" STREQUAL "${RelWithDebInfo_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj RelWithDebInfo Configuration has DebugInformationFormat '${RelWithDebInfo_actual}', not '${RelWithDebInfo_expect}'.") + endif() +endmacro() + +DebugInformationFormat_check(default-C ProgramDatabase "" "" ProgramDatabase) +DebugInformationFormat_check(default-CXX ProgramDatabase "" "" ProgramDatabase) +DebugInformationFormat_check(empty-C "" "" "" "") +DebugInformationFormat_check(empty-CXX "" "" "" "") +DebugInformationFormat_check(Embedded-C OldStyle OldStyle OldStyle OldStyle) +DebugInformationFormat_check(Embedded-CXX OldStyle OldStyle OldStyle OldStyle) +DebugInformationFormat_check(ProgramDatabase-C ProgramDatabase ProgramDatabase ProgramDatabase ProgramDatabase) +DebugInformationFormat_check(ProgramDatabase-CXX ProgramDatabase ProgramDatabase ProgramDatabase ProgramDatabase) +DebugInformationFormat_check(EditAndContinue-C EditAndContinue EditAndContinue EditAndContinue EditAndContinue) +DebugInformationFormat_check(EditAndContinue-CXX EditAndContinue EditAndContinue EditAndContinue EditAndContinue) diff --git a/Tests/RunCMake/VS10Project/DebugInformationFormat.cmake b/Tests/RunCMake/VS10Project/DebugInformationFormat.cmake new file mode 100644 index 0000000..f670166 --- /dev/null +++ b/Tests/RunCMake/VS10Project/DebugInformationFormat.cmake @@ -0,0 +1,24 @@ +set(CMAKE_CONFIGURATION_TYPES Debug Release MinSizeRel RelWithDebInfo) +cmake_policy(SET CMP0141 NEW) +enable_language(C) +enable_language(CXX) + +add_library(default-C empty.c) +add_library(default-CXX empty.cxx) + +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "") +add_library(empty-C empty.c) +add_library(empty-CXX empty.cxx) + +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "Embedded") +add_library(Embedded-C empty.c) +add_library(Embedded-CXX empty.cxx) + +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase") +add_library(ProgramDatabase-C empty.c) +add_library(ProgramDatabase-CXX empty.cxx) + +add_library(EditAndContinue-C empty.c) +set_property(TARGET EditAndContinue-C PROPERTY MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue") +add_library(EditAndContinue-CXX empty.cxx) +set_property(TARGET EditAndContinue-CXX PROPERTY MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue") diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index e540b9f..f027e94 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -88,3 +88,4 @@ run_cmake(VsDotnetStartupObject) run_cmake(VsDotnetTargetFramework) run_cmake(VsDotnetTargetFrameworkVersion) run_cmake(VsNoCompileBatching) +run_cmake(DebugInformationFormat) diff --git a/Tests/RunCMake/XcodeProject/SearchPaths-check.cmake b/Tests/RunCMake/XcodeProject/SearchPaths-check.cmake index 71b7d8f..bec8790 100644 --- a/Tests/RunCMake/XcodeProject/SearchPaths-check.cmake +++ b/Tests/RunCMake/XcodeProject/SearchPaths-check.cmake @@ -12,6 +12,8 @@ set(found_target_library_FRAMEWORK_SEARCH_PATHS 0) set(found_inherited_FRAMEWORK_SEARCH_PATHS 0) set(found_project_LIBRARY_SEARCH_PATHS 0) set(found_target_library_LIBRARY_SEARCH_PATHS 0) +set(found_target_cmp0142old_LIBRARY_SEARCH_PATHS 0) +set(found_target_cmp0142new_LIBRARY_SEARCH_PATHS 0) set(found_inherited_LIBRARY_SEARCH_PATHS 0) file(STRINGS "${xcProjectFile}" lines) foreach(line IN LISTS lines) @@ -42,6 +44,12 @@ foreach(line IN LISTS lines) if(line MATCHES [[LIBRARY_SEARCH_PATHS = \("(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathLib/\$\(CONFIGURATION\)\$\(EFFECTIVE_PLATFORM_NAME\)(\\")?","(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathLib(\\")?","\$\(inherited\)"\);]]) set(found_target_library_LIBRARY_SEARCH_PATHS 1) endif() + if(line MATCHES [[LIBRARY_SEARCH_PATHS = \("(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathCMP0142OLD/\$\(CONFIGURATION\)\$\(EFFECTIVE_PLATFORM_NAME\)(\\")?","(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathCMP0142OLD(\\")?","\$\(inherited\)"\);]]) + set(found_target_cmp0142old_LIBRARY_SEARCH_PATHS 1) + endif() + if(line MATCHES [[LIBRARY_SEARCH_PATHS = \("(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathCMP0142NEW(\\")?","\$\(inherited\)"\);]]) + set(found_target_cmp0142new_LIBRARY_SEARCH_PATHS 1) + endif() if(line MATCHES [[LIBRARY_SEARCH_PATHS = \("\$\(inherited\)"\);]]) set(found_inherited_LIBRARY_SEARCH_PATHS 1) endif() @@ -68,6 +76,12 @@ endif() if(NOT found_target_library_LIBRARY_SEARCH_PATHS) string(APPEND RunCMake_TEST_FAILED "Did not find expected LIBRARY_SEARCH_PATHS for target 'library' in\n ${xcProjectFile}\n") endif() +if(NOT found_target_cmp0142old_LIBRARY_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected LIBRARY_SEARCH_PATHS for target 'cmp0142old' in\n ${xcProjectFile}\n") +endif() +if(NOT found_target_cmp0142new_LIBRARY_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected LIBRARY_SEARCH_PATHS for target 'cmp0142new' in\n ${xcProjectFile}\n") +endif() if(found_inherited_LIBRARY_SEARCH_PATHS) string(APPEND RunCMake_TEST_FAILED "Found unexpected LIBRARY_SEARCH_PATHS inherited-only value in\n ${xcProjectFile}\n") endif() diff --git a/Tests/RunCMake/XcodeProject/SearchPaths.cmake b/Tests/RunCMake/XcodeProject/SearchPaths.cmake index ef97709..b469772 100644 --- a/Tests/RunCMake/XcodeProject/SearchPaths.cmake +++ b/Tests/RunCMake/XcodeProject/SearchPaths.cmake @@ -3,6 +3,8 @@ enable_language(C) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/ProjectSearchPath") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathInc/TargetInc.framework") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathLib/TargetLib.framework") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathCMP0142OLD") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathCMP0142NEW") set(CMAKE_XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS "${CMAKE_CURRENT_BINARY_DIR}/ProjectSearchPath") set(CMAKE_XCODE_ATTRIBUTE_LIBRARY_SEARCH_PATHS "${CMAKE_CURRENT_BINARY_DIR}/ProjectSearchPath") @@ -19,3 +21,11 @@ target_include_directories(include PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSe add_executable(library main.c) target_link_libraries(library PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathLib/TargetLib.framework") target_link_directories(library PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathLib") + +cmake_policy(SET CMP0142 OLD) +add_executable(cmp0142old main.c) +target_link_directories(cmp0142old PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathCMP0142OLD") + +cmake_policy(SET CMP0142 NEW) +add_executable(cmp0142new main.c) +target_link_directories(cmp0142new PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathCMP0142NEW") diff --git a/Tests/RunCMake/try_compile/BuildType.cmake b/Tests/RunCMake/try_compile/BuildType.cmake index f2709f8..8d7e3be 100644 --- a/Tests/RunCMake/try_compile/BuildType.cmake +++ b/Tests/RunCMake/try_compile/BuildType.cmake @@ -1,6 +1,8 @@ enable_language(C) set(CMAKE_BUILD_TYPE RelWithDebInfo) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) +try_compile(RESULT + ${try_compile_bindir_or_SOURCES} ${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 index e9384c7..a822156 100644 --- a/Tests/RunCMake/try_compile/BuildTypeAsFlag.cmake +++ b/Tests/RunCMake/try_compile/BuildTypeAsFlag.cmake @@ -1,7 +1,9 @@ enable_language(C) set(CMAKE_BUILD_TYPE RelWithDebInfo) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) +try_compile(RESULT + ${try_compile_bindir_or_SOURCES} ${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/NoArgs-stderr.txt b/Tests/RunCMake/try_compile/NoArgs-stderr.txt index 72a697e..4228580 100644 --- a/Tests/RunCMake/try_compile/NoArgs-stderr.txt +++ b/Tests/RunCMake/try_compile/NoArgs-stderr.txt @@ -1,4 +1,4 @@ CMake Error at NoArgs.cmake:[0-9]+ \(try_compile\): - try_compile unknown error. + The try_compile\(\) command requires at least 3 arguments. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt new file mode 100644 index 0000000..e9ec450 --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at OldProjectBinDirEmpty.cmake:[0-9]+ \(try_compile\): + No <bindir> specified. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake new file mode 100644 index 0000000..fa922d9 --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake @@ -0,0 +1 @@ +try_compile(RESULT "" ${CMAKE_CURRENT_SOURCE_DIR}/proj Foo) diff --git a/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt new file mode 100644 index 0000000..47dd60f --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at OldProjectSrcDirEmpty.cmake:[0-9]+ \(try_compile\): + No <srcdir> specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake new file mode 100644 index 0000000..dfbfba6 --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake @@ -0,0 +1 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} "" Foo) diff --git a/Tests/RunCMake/try_compile/OneArg-stderr.txt b/Tests/RunCMake/try_compile/OneArg-stderr.txt index bb0239e..a2e983e 100644 --- a/Tests/RunCMake/try_compile/OneArg-stderr.txt +++ b/Tests/RunCMake/try_compile/OneArg-stderr.txt @@ -1,4 +1,4 @@ CMake Error at OneArg.cmake:[0-9]+ \(try_compile\): - try_compile unknown error. + The try_compile\(\) command requires at least 3 arguments. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/OutputDirAsFlag.cmake b/Tests/RunCMake/try_compile/OutputDirAsFlag.cmake index 5c4dca5..1214bbb 100644 --- a/Tests/RunCMake/try_compile/OutputDirAsFlag.cmake +++ b/Tests/RunCMake/try_compile/OutputDirAsFlag.cmake @@ -1,7 +1,9 @@ enable_language(C) set(CMAKE_BUILD_TYPE RelWithDebInfo) -try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) +try_compile(RESULT + ${try_compile_bindir_or_SOURCES} ${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/ProjectBinDirEmpty-result.txt b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt new file mode 100644 index 0000000..57a2bd0 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at ProjectBinDirEmpty.cmake:[0-9]+ \(try_compile\): + No <bindir> specified. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake b/Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake new file mode 100644 index 0000000..e867cc6 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake @@ -0,0 +1,4 @@ +try_compile(RESULT PROJECT Foo + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proj + BINARY_DIR "" + ) diff --git a/Tests/RunCMake/try_compile/ProjectCopyFile-result.txt b/Tests/RunCMake/try_compile/ProjectCopyFile-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectCopyFile-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt b/Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt new file mode 100644 index 0000000..45241c9 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at ProjectCopyFile.cmake:[0-9]+ \(try_compile\): + Unknown arguments: + + "COPY_FILE" + "result" +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/ProjectCopyFile.cmake b/Tests/RunCMake/try_compile/ProjectCopyFile.cmake new file mode 100644 index 0000000..6bfec99 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectCopyFile.cmake @@ -0,0 +1,4 @@ +try_compile(RESULT + PROJECT TestProject + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proj + COPY_FILE result) diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt new file mode 100644 index 0000000..dc6f354 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ProjectSrcDirEmpty.cmake:[0-9]+ \(try_compile\): + No <srcdir> specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake new file mode 100644 index 0000000..ac33ed0 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake @@ -0,0 +1 @@ +try_compile(RESULT PROJECT Foo SOURCE_DIR "") diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt new file mode 100644 index 0000000..af6edd5 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ProjectSrcDirMissing.cmake:[0-9]+ \(try_compile\): + No <srcdir> specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake b/Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake new file mode 100644 index 0000000..e32cdf4 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake @@ -0,0 +1 @@ +try_compile(RESULT PROJECT Foo) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index c0fdd9f..bb11a57 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -6,6 +6,11 @@ run_cmake(TwoArgs) run_cmake(NoSources) run_cmake(BinDirEmpty) run_cmake(BinDirRelative) +run_cmake(ProjectSrcDirMissing) +run_cmake(ProjectSrcDirEmpty) +run_cmake(ProjectBinDirEmpty) +run_cmake(OldProjectSrcDirEmpty) +run_cmake(OldProjectBinDirEmpty) set(RunCMake_TEST_OPTIONS -Dtry_compile_DEFS=old_signature.cmake) include(${RunCMake_SOURCE_DIR}/old_and_new_signature_tests.cmake) @@ -15,6 +20,7 @@ set(RunCMake_TEST_OPTIONS -Dtry_compile_DEFS=new_signature.cmake) include(${RunCMake_SOURCE_DIR}/old_and_new_signature_tests.cmake) unset(RunCMake_TEST_OPTIONS) +run_cmake(ProjectCopyFile) run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) diff --git a/Tests/RunCMake/try_compile/TwoArgs-stderr.txt b/Tests/RunCMake/try_compile/TwoArgs-stderr.txt index 38f1d75..b68e78e 100644 --- a/Tests/RunCMake/try_compile/TwoArgs-stderr.txt +++ b/Tests/RunCMake/try_compile/TwoArgs-stderr.txt @@ -1,4 +1,4 @@ CMake Error at TwoArgs.cmake:[0-9]+ \(try_compile\): - try_compile unknown error. + The try_compile\(\) command requires at least 3 arguments. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) 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 f80d445..ac07ad3 100644 --- a/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake +++ b/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake @@ -1,3 +1,12 @@ +# These tests are performed using both the historic and the newer SOURCES +# signatures of try_compile. It is critical that they behave the same and +# produce comparable output for both signatures. Tests that cannot do this +# belong in RunCMakeTests.txt, not here. +# +# Tests here MUST include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) and +# use the variables defined therein appropriately. Refer to existing tests for +# examples. + run_cmake(CopyFileErrorNoCopyFile) run_cmake(NoCopyFile) run_cmake(NoCopyFile2) diff --git a/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake b/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake index 2332127..e1c1784 100644 --- a/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake +++ b/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake @@ -1,3 +1,12 @@ +# These tests are performed using both the historic and the newer SOURCES +# signatures of try_run. It is critical that they behave the same and produce +# comparable output for both signatures. Tests that cannot do this belong in +# RunCMakeTests.txt, not here. +# +# Tests here MUST include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) and +# use the variables defined therein appropriately. Refer to existing tests for +# examples. + run_cmake(BadLinkLibraries) run_cmake(BinDirEmpty) run_cmake(BinDirRelative) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index a53dd93..8ebb00a 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -65,7 +65,7 @@ set(try_compile_run_output_var RUN_OUTPUT) include(old_and_new_signature_tests.cmake) # try to compile a project (old signature) -message("Testing try_compile project mode") +message("Testing try_compile project mode (old signature)") try_compile(TEST_INNER ${TryCompile_BINARY_DIR}/CMakeFiles/Inner ${TryCompile_SOURCE_DIR}/Inner @@ -73,6 +73,15 @@ try_compile(TEST_INNER OUTPUT_VARIABLE output) TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") +# try to compile a project (new signature) +message("Testing try_compile project mode (new signature)") +try_compile(TEST_INNER + PROJECT TryCompileInner + SOURCE_DIR ${TryCompile_SOURCE_DIR}/Inner + TARGET innerexe + OUTPUT_VARIABLE output) +TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") + add_executable(TryCompile pass.c) ####################################################################### |