diff options
199 files changed, 1070 insertions, 1085 deletions
diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index 96b95c8..88756eb 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -12,7 +12,7 @@ .run_automatically: rules: - if: '$CI_PROJECT_PATH == "cmake/cmake"' - when: always + when: on_success - if: '$CI_MERGE_REQUEST_ID' - when: always + when: on_success - when: never diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index 01c415a..52536bb 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -64,42 +64,6 @@ See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are pre-processed, and you want to have the original sources reachable from within IDE. -Imported Libraries -^^^^^^^^^^^^^^^^^^ - -.. code-block:: cmake - - add_library(<name> <SHARED|STATIC|MODULE|OBJECT|UNKNOWN> IMPORTED - [GLOBAL]) - -An :ref:`IMPORTED library target <Imported Targets>` references a library -file located outside the project. No rules are generated to build it, and -the :prop_tgt:`IMPORTED` target property is ``True``. The target name has -scope in the directory in which it is created and below, but the ``GLOBAL`` -option extends visibility. It may be referenced like any target built -within the project. ``IMPORTED`` libraries are useful for convenient -reference from commands like :command:`target_link_libraries`. Details -about the imported library are specified by setting properties whose names -begin in ``IMPORTED_`` and ``INTERFACE_``. - -The most important properties are: - -* :prop_tgt:`IMPORTED_LOCATION` (and its per-configuration - variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the - location of the main library file on disk. -* :prop_tgt:`IMPORTED_OBJECTS` (and :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`) - for object libraries, specifies the locations of object files on disk. -* :prop_tgt:`PUBLIC_HEADER` files to be installed during :command:`install` invocation - -See documentation of the ``IMPORTED_*`` and ``INTERFACE_*`` properties -for more information. - -An ``UNKNOWN`` library type is typically only used in the implementation of -:ref:`Find Modules`. It allows the path to an imported library (often found -using the :command:`find_library` command) to be used without having to know -what type of library it is. This is especially useful on Windows where a -static library and a DLL's import library both have the same file extension. - Object Libraries ^^^^^^^^^^^^^^^^ @@ -129,6 +93,85 @@ systems (such as Xcode) may not like targets that have only object files, so consider adding at least one real source file to any target that references ``$<TARGET_OBJECTS:objlib>``. +Interface Libraries +^^^^^^^^^^^^^^^^^^^ + +.. code-block:: cmake + + add_library(<name> INTERFACE) + +Creates an :ref:`Interface Library <Interface Libraries>`. +An ``INTERFACE`` library target does not compile sources and does +not produce a library artifact on disk. However, it may have +properties set on it and it may be installed and exported. +Typically, ``INTERFACE_*`` properties are populated on an interface +target using the commands: + +* :command:`set_property`, +* :command:`target_link_libraries(INTERFACE)`, +* :command:`target_link_options(INTERFACE)`, +* :command:`target_include_directories(INTERFACE)`, +* :command:`target_compile_options(INTERFACE)`, +* :command:`target_compile_definitions(INTERFACE)`, and +* :command:`target_sources(INTERFACE)`, + +and then it is used as an argument to :command:`target_link_libraries` +like any other target. + +An interface library has no source files itself and is not included +as a target in the generated buildsystem. + +Imported Libraries +^^^^^^^^^^^^^^^^^^ + +.. code-block:: cmake + + add_library(<name> <type> IMPORTED [GLOBAL]) + +Creates an :ref:`IMPORTED library target <Imported Targets>` called ``<name>``. +No rules are generated to build it, and the :prop_tgt:`IMPORTED` target +property is ``True``. The target name has scope in the directory in which +it is created and below, but the ``GLOBAL`` option extends visibility. +It may be referenced like any target built within the project. +``IMPORTED`` libraries are useful for convenient reference from commands +like :command:`target_link_libraries`. Details about the imported library +are specified by setting properties whose names begin in ``IMPORTED_`` and +``INTERFACE_``. + +The ``<type>`` must be one of: + +``STATIC``, ``SHARED``, ``MODULE``, ``UNKNOWN`` + References a library file located outside the project. The + :prop_tgt:`IMPORTED_LOCATION` target property (or its per-configuration + variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) specifies the + location of the main library file on disk. In the case of a ``SHARED`` + library on Windows, the :prop_tgt:`IMPORTED_IMPLIB` target property + (or its per-configuration variant :prop_tgt:`IMPORTED_IMPLIB_<CONFIG>`) + specifies the location of the DLL import library file (``.lib`` or + ``.dll.a``) on disk, and the ``IMPORTED_LOCATION`` is the location of + the ``.dll`` runtime library (and is optional). + Additional usage requirements may be specified in ``INTERFACE_*`` properties. + + An ``UNKNOWN`` library type is typically only used in the implementation of + :ref:`Find Modules`. It allows the path to an imported library (often found + using the :command:`find_library` command) to be used without having to know + what type of library it is. This is especially useful on Windows where a + static library and a DLL's import library both have the same file extension. + +``OBJECT`` + References a set of object files located outside the project. + The :prop_tgt:`IMPORTED_OBJECTS` target property (or its per-configuration + variant :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`) specifies the locations of + object files on disk. + Additional usage requirements may be specified in ``INTERFACE_*`` properties. + +``INTERFACE`` + Does not reference any library or object files on disk, but may + specify usage requirements in ``INTERFACE_*`` properties. + +See documentation of the ``IMPORTED_*`` and ``INTERFACE_*`` properties +for more information. + Alias Libraries ^^^^^^^^^^^^^^^ @@ -153,35 +196,3 @@ to modify properties of ``<target>``, that is, it may not be used as the operand of :command:`set_property`, :command:`set_target_properties`, :command:`target_link_libraries` etc. An ``ALIAS`` target may not be installed or exported. - -Interface Libraries -^^^^^^^^^^^^^^^^^^^ - -.. code-block:: cmake - - add_library(<name> INTERFACE [IMPORTED [GLOBAL]]) - -Creates an :ref:`Interface Library <Interface Libraries>`. An ``INTERFACE`` -library target does not directly create build output, though it may -have properties set on it and it may be installed, exported and -imported. Typically the ``INTERFACE_*`` properties are populated on -the interface target using the commands: - -* :command:`set_property`, -* :command:`target_link_libraries(INTERFACE)`, -* :command:`target_link_options(INTERFACE)`, -* :command:`target_include_directories(INTERFACE)`, -* :command:`target_compile_options(INTERFACE)`, -* :command:`target_compile_definitions(INTERFACE)`, and -* :command:`target_sources(INTERFACE)`, - -and then it is used as an argument to :command:`target_link_libraries` -like any other target. - -An ``INTERFACE`` :ref:`Imported Target <Imported Targets>` may also be -created with this signature. An ``IMPORTED`` library target references a -library defined outside the project. The target name has scope in the -directory in which it is created and below, but the ``GLOBAL`` option -extends visibility. It may be referenced like any target built within -the project. ``IMPORTED`` libraries are useful for convenient reference -from commands like :command:`target_link_libraries`. diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst index c0677d2..a77ba37 100644 --- a/Help/command/add_test.rst +++ b/Help/command/add_test.rst @@ -10,9 +10,8 @@ Add a test to the project to be run by :manual:`ctest(1)`. [WORKING_DIRECTORY <dir>] [COMMAND_EXPAND_LISTS]) -Adds a test called ``<name>``. The test name may contain arbitrary -characters except for double-quotes. However, if it contains spaces -or semicolons it must be enclosed in double-quotes. The options are: +Adds a test called ``<name>``. The test name may not contain spaces, +quotes, or other characters special in CMake syntax. The options are: ``COMMAND`` Specify the test command-line. If ``<command>`` specifies an diff --git a/Help/command/file.rst b/Help/command/file.rst index 693c059..2cf938b 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -776,11 +776,14 @@ Transfer .. code-block:: cmake - file(DOWNLOAD <url> <file> [<options>...]) + file(DOWNLOAD <url> [<file>] [<options>...]) file(UPLOAD <file> <url> [<options>...]) -The ``DOWNLOAD`` mode downloads the given ``<url>`` to a local ``<file>``. -The ``UPLOAD`` mode uploads a local ``<file>`` to a given ``<url>``. +The ``DOWNLOAD`` mode downloads the given ``<url>`` to a local ``<file>``. If +``<file>`` is not specified for ``file(DOWNLOAD)``, the file is not saved. This +can be useful if you want to know if a file can be downloaded (for example, to +check that it exists) without actually saving it anywhere. The ``UPLOAD`` mode +uploads a local ``<file>`` to a given ``<url>``. Options to both ``DOWNLOAD`` and ``UPLOAD`` are: @@ -853,10 +856,12 @@ Additional options to ``DOWNLOAD`` are: Verify that the downloaded content hash matches the expected value, where ``ALGO`` is one of the algorithms supported by ``file(<HASH>)``. - If it does not match, the operation fails with an error. + If it does not match, the operation fails with an error. It is an error to + specify this if ``DOWNLOAD`` is not given a ``<file>``. ``EXPECTED_MD5 <value>`` - Historical short-hand for ``EXPECTED_HASH MD5=<value>``. + Historical short-hand for ``EXPECTED_HASH MD5=<value>``. It is an error to + specify this if ``DOWNLOAD`` is not given a ``<file>``. Locking ^^^^^^^ diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst index 856d869..653b8d7 100644 --- a/Help/command/target_sources.rst +++ b/Help/command/target_sources.rst @@ -11,19 +11,21 @@ Add sources to a target. <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specifies sources to use when compiling a given target. Relative -source file paths are interpreted as being relative to the current +Specifies sources to use when building a target and/or its dependents. +Relative source file paths are interpreted as being relative to the current source directory (i.e. :variable:`CMAKE_CURRENT_SOURCE_DIR`). The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to -specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC`` +specify the scope of the items following them. ``PRIVATE`` and ``PUBLIC`` items will populate the :prop_tgt:`SOURCES` property of -``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the -:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``. -(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.) +``<target>``, which are used when building the target itself. +``PUBLIC`` and ``INTERFACE`` items will populate the +:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``, which are used +when building dependents. (:ref:`IMPORTED targets <Imported Targets>` +only support ``INTERFACE`` items because they are not build targets.) The following arguments specify sources. Repeated calls for the same ``<target>`` append items in the order called. diff --git a/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst b/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst index b923800..c9301b5 100644 --- a/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst @@ -10,7 +10,7 @@ If this property is set to ``ON``, then the value of the property is ``OFF`` or unset, the :prop_tgt:`CUDA_STANDARD` target property is treated as optional and may "decay" to a previous standard if the requested is not available. For compilers that have no notion of a standard level, such as -MSVC, this has no effect. +MSVC 1800 (Visual Studio 2013) and lower, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst index 2ea2215..8b17490 100644 --- a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst @@ -10,7 +10,7 @@ If this property is set to ``ON``, then the value of the property is ``OFF`` or unset, the :prop_tgt:`CXX_STANDARD` target property is treated as optional and may "decay" to a previous standard if the requested is not available. For compilers that have no notion of a standard level, such as -MSVC, this has no effect. +MSVC 1800 (Visual Studio 2013) and lower, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/prop_tgt/C_STANDARD_REQUIRED.rst b/Help/prop_tgt/C_STANDARD_REQUIRED.rst index c1b58a0..55bff04 100644 --- a/Help/prop_tgt/C_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/C_STANDARD_REQUIRED.rst @@ -10,7 +10,7 @@ If this property is set to ``ON``, then the value of the property is ``OFF`` or unset, the :prop_tgt:`C_STANDARD` target property is treated as optional and may "decay" to a previous standard if the requested is not available. For compilers that have no notion of a standard level, such as -MSVC, this has no effect. +MSVC 1800 (Visual Studio 2013) and lower, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/release/3.18.rst b/Help/release/3.18.rst index 427840e..ba80d2b 100644 --- a/Help/release/3.18.rst +++ b/Help/release/3.18.rst @@ -332,3 +332,10 @@ Changes made since CMake 3.18.0 include the following. architecture (the Xcode ``ARCHS`` setting). This is needed for Xcode 12 to select the host's architecture, which older versions of Xcode did by default. + +* In CMake 3.18.0 the :command:`add_test` command learned to support + special characters in test names. This was accidentally left out of + its release notes. Unfortunately the fix breaks existing projects + that were using manual quoting or escaping to work around the prior + limitation. This fix has been reverted in 3.18.1, but may be + re-introduced in future versions of CMake with a policy for compatibility. diff --git a/Help/release/dev/EXCLUDE_FROM_ALL-genex.rst b/Help/release/dev/EXCLUDE_FROM_ALL-genex.rst new file mode 100644 index 0000000..4d5a83c --- /dev/null +++ b/Help/release/dev/EXCLUDE_FROM_ALL-genex.rst @@ -0,0 +1,5 @@ +EXCLUDE_FROM_ALL-genex +---------------------- + +* The :prop_tgt:`EXCLUDE_FROM_ALL` target property gained support for + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/release/dev/file-download-optional-file.rst b/Help/release/dev/file-download-optional-file.rst new file mode 100644 index 0000000..f3dc24c --- /dev/null +++ b/Help/release/dev/file-download-optional-file.rst @@ -0,0 +1,5 @@ +file-download-optional-file +--------------------------- + +* The ``<file>`` argument is now optional for :command:`file(DOWNLOAD)`. If it + is not specified, the file is not saved. diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 2f3b9e1..f521d22 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -894,11 +894,16 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs) # to install_name_tool: # if(changes) - set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}") - execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result) - if(NOT install_name_tool_result EQUAL 0) - string(REPLACE ";" "' '" msg "'${cmd}'") - message(FATAL_ERROR "Command failed:\n ${msg}") + # Check for a script by extension (.bat,.sh,...) or if the file starts with "#!" (shebang) + file(READ ${resolved_embedded_item} file_contents LIMIT 5) + if(NOT "${resolved_embedded_item}" MATCHES "\\.(bat|c?sh|bash|ksh|cmd)$" AND + NOT file_contents MATCHES "^#!") + set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}") + execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result) + if(NOT install_name_tool_result EQUAL 0) + string(REPLACE ";" "' '" msg "'${cmd}'") + message(FATAL_ERROR "Command failed:\n ${msg}") + endif() endif() endif() endfunction() diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 03195cc..2dc1585 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -96,15 +96,5 @@ if(NOT CMAKE_EXECUTABLE_RPATH_LINK_ASM${ASM_DIALECT}_FLAG) set(CMAKE_EXECUTABLE_RPATH_LINK_ASM${ASM_DIALECT}_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_ASM${ASM_DIALECT}_FLAG}) endif() -# to be done -if(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY) - set(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY) -endif() - -if(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE) - set(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE) -endif() - set(CMAKE_ASM${ASM_DIALECT}_INFOMATION_LOADED 1) - diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 5aa7dd8..96f32e5 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -87,7 +87,9 @@ else() "--target=arm-arm-none-eabi -mcpu=cortex-m3" ) endif() - +if(CMAKE_C_COMPILER_TARGET) + list(PREPEND CMAKE_C_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_C_COMPILER_TARGET}") +endif() # Build a small source file to identify the compiler. if(NOT CMAKE_C_COMPILER_ID_RUN) set(CMAKE_C_COMPILER_ID_RUN 1) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index e7e294f..4c2924a 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -83,6 +83,10 @@ else() ) endif() +if(CMAKE_CXX_COMPILER_TARGET) + list(PREPEND CMAKE_CXX_COPMILER_ID_TEST_FLAGS "-c --target=${CMAKE_CXX_COMPILER_TARGET}") +endif() + # Build a small source file to identify the compiler. if(NOT CMAKE_CXX_COMPILER_ID_RUN) set(CMAKE_CXX_COMPILER_ID_RUN 1) diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index a1da441..2780399 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -144,7 +144,9 @@ function(_cmake_find_compiler_sysroot lang) OUTPUT_VARIABLE _cmake_sysroot_run_out ERROR_VARIABLE _cmake_sysroot_run_err) - if(_cmake_sysroot_run_out AND NOT _cmake_sysroot_run_err AND IS_DIRECTORY "${_cmake_sysroot_run_out}/usr") + if(_cmake_sysroot_run_out AND NOT _cmake_sysroot_run_err + AND NOT _cmake_sysroot_run_out STREQUAL "/" + AND IS_DIRECTORY "${_cmake_sysroot_run_out}/usr") file(TO_CMAKE_PATH "${_cmake_sysroot_run_out}/usr" _cmake_sysroot_run_out_usr) set(CMAKE_${lang}_COMPILER_SYSROOT "${_cmake_sysroot_run_out_usr}" PARENT_SCOPE) else() diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index bb516d3..52d5350 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -222,11 +222,11 @@ macro(__compiler_clang_cxx_standards lang) # can be attempted. macro(cmake_record_${lang}_compile_features) list(APPEND CMAKE_${lang}_COMPILE_FEATURES - ${lang}_std_98 - ${lang}_std_11 - ${lang}_std_14 - ${lang}_std_17 - ${lang}_std_20 + cxx_std_98 + cxx_std_11 + cxx_std_14 + cxx_std_17 + cxx_std_20 ) _record_compiler_features(${lang} "" CMAKE_${lang}_COMPILE_FEATURES) endmacro() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 3a47090..aecc00b 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1124,7 +1124,11 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git message(FATAL_ERROR "Tag for git checkout should not be empty.") endif() - set(git_clone_options "--no-checkout") + if(GIT_VERSION_STRING VERSION_LESS 2.20 OR 2.21 VERSION_LESS_EQUAL GIT_VERSION_STRING) + set(git_clone_options "--no-checkout") + else() + set(git_clone_options) + endif() if(git_shallow) if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10) list(APPEND git_clone_options "--depth 1 --no-single-branch") diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index 3acadc2..74b36c6 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -150,16 +150,16 @@ if(CURL_FIND_COMPONENTS) endif() foreach(component IN LISTS CURL_FIND_COMPONENTS) list(FIND CURL_KNOWN_PROTOCOLS ${component} _found) - if(_found) + if(NOT _found EQUAL -1) list(FIND CURL_SUPPORTED_PROTOCOLS ${component} _found) - if(_found) + if(NOT _found EQUAL -1) set(CURL_${component}_FOUND TRUE) elseif(CURL_FIND_REQUIRED) message(FATAL_ERROR "CURL: Required protocol ${component} is not found") endif() else() list(FIND CURL_SUPPORTED_FEATURES ${component} _found) - if(_found) + if(NOT _found EQUAL -1) set(CURL_${component}_FOUND TRUE) elseif(CURL_FIND_REQUIRED) message(FATAL_ERROR "CURL: Required feature ${component} is not found") diff --git a/Modules/FindXalanC.cmake b/Modules/FindXalanC.cmake index ca9195c..a7fb766 100644 --- a/Modules/FindXalanC.cmake +++ b/Modules/FindXalanC.cmake @@ -49,9 +49,9 @@ The following cache variables may also be set: function(_XalanC_GET_VERSION version_hdr) file(STRINGS ${version_hdr} _contents REGEX "^[ \t]*#define XALAN_VERSION_.*") if(_contents) - string(REGEX REPLACE "[^*]*#define XALAN_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" XalanC_MAJOR "${_contents}") - string(REGEX REPLACE "[^*]*#define XALAN_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" XalanC_MINOR "${_contents}") - string(REGEX REPLACE "[^*]*#define XALAN_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" XalanC_PATCH "${_contents}") + string(REGEX REPLACE "[^*]*#define XALAN_VERSION_MAJOR[ \t(]+([0-9]+).*" "\\1" XalanC_MAJOR "${_contents}") + string(REGEX REPLACE "[^*]*#define XALAN_VERSION_MINOR[ \t(]+([0-9]+).*" "\\1" XalanC_MINOR "${_contents}") + string(REGEX REPLACE "[^*]*#define XALAN_VERSION_REVISION[ \t(]+([0-9]+).*" "\\1" XalanC_PATCH "${_contents}") if(NOT XalanC_MAJOR MATCHES "^[0-9]+$") message(FATAL_ERROR "Version parsing failed for XALAN_VERSION_MAJOR!") diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index 2ef7382..057b29d 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -495,7 +495,7 @@ function(gtest_discover_tests TARGET) string(CONCAT ctest_include_content "if(EXISTS \"$<TARGET_FILE:${TARGET}>\")" "\n" " if(\"$<TARGET_FILE:${TARGET}>\" IS_NEWER_THAN \"${ctest_tests_file}\")" "\n" - " include(GoogleTestAddTests)" "\n" + " include(\"${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}\")" "\n" " gtest_discover_tests_impl(" "\n" " TEST_EXECUTABLE" " [==[" "$<TARGET_FILE:${TARGET}>" "]==]" "\n" " TEST_EXECUTOR" " [==[" "${crosscompiling_emulator}" "]==]" "\n" diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 5d098d9..883e1f4 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -44,8 +44,8 @@ function(gtest_discover_tests_impl) cmake_parse_arguments( "" "" - "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_EXECUTOR;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR" - "TEST_EXTRA_ARGS;TEST_PROPERTIES" + "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR" + "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR" ${ARGN} ) diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 2476a33..e272da9 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -356,6 +356,11 @@ macro(__windows_compiler_msvc lang) set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0) + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") + else() + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") + endif() # '-flto=thin' available since Clang 3.9 and Xcode 8 # * http://clang.llvm.org/docs/ThinLTO.html#clang-llvm # * https://trac.macports.org/wiki/XcodeVersionInfo diff --git a/Modules/UseSWIG/ManageSupportFiles.cmake b/Modules/UseSWIG/ManageSupportFiles.cmake index 4a03900..6618fd5 100644 --- a/Modules/UseSWIG/ManageSupportFiles.cmake +++ b/Modules/UseSWIG/ManageSupportFiles.cmake @@ -4,7 +4,7 @@ if (ACTION STREQUAL "CLEAN") # Collect current list of generated files - file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") if (files) # clean-up the output directory @@ -22,7 +22,7 @@ endif() if (ACTION STREQUAL "COPY") # Collect current list of generated files - file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + file (GLOB files LIST_DIRECTORIES TRUE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") if (files) # copy files to the output directory diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 871da4f..091f97f 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 18) -set(CMake_VERSION_PATCH 20200723) +set(CMake_VERSION_PATCH 20200806) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 3d5fe6b..560e5c1 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -696,57 +696,57 @@ int cmCPackDebGenerator::createDeb() const char* debian_pkg_source = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE"); - if (debian_pkg_source && *debian_pkg_source) { + if (cmNonempty(debian_pkg_source)) { controlValues["Source"] = debian_pkg_source; } const char* debian_pkg_dep = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS"); - if (debian_pkg_dep && *debian_pkg_dep) { + if (cmNonempty(debian_pkg_dep)) { controlValues["Depends"] = debian_pkg_dep; } const char* debian_pkg_rec = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS"); - if (debian_pkg_rec && *debian_pkg_rec) { + if (cmNonempty(debian_pkg_rec)) { controlValues["Recommends"] = debian_pkg_rec; } const char* debian_pkg_sug = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS"); - if (debian_pkg_sug && *debian_pkg_sug) { + if (cmNonempty(debian_pkg_sug)) { controlValues["Suggests"] = debian_pkg_sug; } const char* debian_pkg_url = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE"); - if (debian_pkg_url && *debian_pkg_url) { + if (cmNonempty(debian_pkg_url)) { controlValues["Homepage"] = debian_pkg_url; } const char* debian_pkg_predep = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS"); - if (debian_pkg_predep && *debian_pkg_predep) { + if (cmNonempty(debian_pkg_predep)) { controlValues["Pre-Depends"] = debian_pkg_predep; } const char* debian_pkg_enhances = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES"); - if (debian_pkg_enhances && *debian_pkg_enhances) { + if (cmNonempty(debian_pkg_enhances)) { controlValues["Enhances"] = debian_pkg_enhances; } const char* debian_pkg_breaks = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS"); - if (debian_pkg_breaks && *debian_pkg_breaks) { + if (cmNonempty(debian_pkg_breaks)) { controlValues["Breaks"] = debian_pkg_breaks; } const char* debian_pkg_conflicts = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS"); - if (debian_pkg_conflicts && *debian_pkg_conflicts) { + if (cmNonempty(debian_pkg_conflicts)) { controlValues["Conflicts"] = debian_pkg_conflicts; } const char* debian_pkg_provides = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES"); - if (debian_pkg_provides && *debian_pkg_provides) { + if (cmNonempty(debian_pkg_provides)) { controlValues["Provides"] = debian_pkg_provides; } const char* debian_pkg_replaces = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES"); - if (debian_pkg_replaces && *debian_pkg_replaces) { + if (cmNonempty(debian_pkg_replaces)) { controlValues["Replaces"] = debian_pkg_replaces; } @@ -756,7 +756,7 @@ int cmCPackDebGenerator::createDeb() const char* debian_pkg_shlibs = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS"); const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") && - debian_pkg_shlibs && *debian_pkg_shlibs; + cmNonempty(debian_pkg_shlibs); if (gen_shibs) { cmGeneratedFileStream out; out.Open(shlibsfilename, false, true); @@ -832,11 +832,11 @@ int cmCPackDebGenerator::createDbgsymDDeb() const char* debian_pkg_source = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE"); - if (debian_pkg_source && *debian_pkg_source) { + if (cmNonempty(debian_pkg_source)) { controlValues["Source"] = debian_pkg_source; } const char* debian_build_ids = this->GetOption("GEN_BUILD_IDS"); - if (debian_build_ids && *debian_build_ids) { + if (cmNonempty(debian_build_ids)) { controlValues["Build-Ids"] = debian_build_ids; } diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index 53be4fe..0bc8456 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -61,7 +61,7 @@ int cmCPackExternalGenerator::PackageFiles() } const char* packageScript = this->GetOption("CPACK_EXTERNAL_PACKAGE_SCRIPT"); - if (packageScript && *packageScript) { + if (cmNonempty(packageScript)) { if (!cmSystemTools::FileIsFullPath(packageScript)) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -211,7 +211,7 @@ int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteToJSON( const char* defaultDirectoryPermissions = this->Parent->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (defaultDirectoryPermissions && *defaultDirectoryPermissions) { + if (cmNonempty(defaultDirectoryPermissions)) { root["defaultDirectoryPermissions"] = defaultDirectoryPermissions; } if (cmIsInternallyOn(this->Parent->GetOption("CPACK_SET_DESTDIR"))) { diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index c641175..3880f65 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -216,7 +216,7 @@ int cmCPackGenerator::InstallProject() mode_t* default_dir_mode = nullptr; const char* default_dir_install_permissions = this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (default_dir_install_permissions && *default_dir_install_permissions) { + if (cmNonempty(default_dir_install_permissions)) { std::vector<std::string> items = cmExpandedList(default_dir_install_permissions); for (const auto& arg : items) { @@ -293,7 +293,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( { (void)setDestDir; const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); - if (installCommands && *installCommands) { + if (cmNonempty(installCommands)) { std::string tempInstallDirectoryEnv = cmStrCat("CMAKE_INSTALL_PREFIX=", tempInstallDirectory); cmSystemTools::PutEnv(tempInstallDirectoryEnv); @@ -344,7 +344,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } const char* installDirectories = this->GetOption("CPACK_INSTALLED_DIRECTORIES"); - if (installDirectories && *installDirectories) { + if (cmNonempty(installDirectories)) { std::vector<std::string> installDirectoriesVector = cmExpandedList(installDirectories); if (installDirectoriesVector.size() % 2 != 0) { @@ -541,7 +541,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR"); std::string absoluteDestFiles; - if (cmakeProjects && *cmakeProjects) { + if (cmNonempty(cmakeProjects)) { if (!cmakeGenerator) { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_INSTALL_CMAKE_PROJECTS is specified, but " @@ -594,7 +594,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string installTypesVar = "CPACK_" + cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES"; const char* installTypes = this->GetOption(installTypesVar); - if (installTypes && *installTypes) { + if (cmNonempty(installTypes)) { std::vector<std::string> installTypesVector = cmExpandedList(installTypes); for (std::string const& installType : installTypesVector) { @@ -607,7 +607,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string componentsVar = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component); const char* components = this->GetOption(componentsVar); - if (components && *components) { + if (cmNonempty(components)) { cmExpandList(components, componentsVector); for (std::string const& comp : componentsVector) { project.Components.push_back( @@ -771,7 +771,7 @@ int cmCPackGenerator::InstallCMakeProject( const char* default_dir_inst_permissions = this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (default_dir_inst_permissions && *default_dir_inst_permissions) { + if (cmNonempty(default_dir_inst_permissions)) { mf.AddDefinition("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS", default_dir_inst_permissions); } @@ -983,7 +983,7 @@ void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, const char* value) { const char* def = this->MakefileMap->GetDefinition(op); - if (def && *def) { + if (cmNonempty(def)) { return; } this->SetOption(op, value); @@ -1215,7 +1215,7 @@ bool cmCPackGenerator::IsOn(const std::string& name) const bool cmCPackGenerator::IsSetToOff(const std::string& op) const { const char* ret = this->MakefileMap->GetDefinition(op); - if (ret && *ret) { + if (cmNonempty(ret)) { return cmIsOff(ret); } return false; @@ -1509,7 +1509,7 @@ cmCPackInstallationType* cmCPackGenerator::GetInstallationType( installType->Name = name; const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME"); - if (displayName && *displayName) { + if (cmNonempty(displayName)) { installType->DisplayName = displayName; } else { installType->DisplayName = installType->Name; @@ -1531,7 +1531,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( "CPACK_COMPONENT_" + cmsys::SystemTools::UpperCase(name); component->Name = name; const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME"); - if (displayName && *displayName) { + if (cmNonempty(displayName)) { component->DisplayName = displayName; } else { component->DisplayName = component->Name; @@ -1543,17 +1543,17 @@ cmCPackComponent* cmCPackGenerator::GetComponent( cmIsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE"); - if (archiveFile && *archiveFile) { + if (cmNonempty(archiveFile)) { component->ArchiveFile = archiveFile; } const char* plist = this->GetOption(macroPrefix + "_PLIST"); - if (plist && *plist) { + if (cmNonempty(plist)) { component->Plist = plist; } const char* groupName = this->GetOption(macroPrefix + "_GROUP"); - if (groupName && *groupName) { + if (cmNonempty(groupName)) { component->Group = GetComponentGroup(projectName, groupName); component->Group->Components.push_back(component); } else { @@ -1561,13 +1561,13 @@ cmCPackComponent* cmCPackGenerator::GetComponent( } const char* description = this->GetOption(macroPrefix + "_DESCRIPTION"); - if (description && *description) { + if (cmNonempty(description)) { component->Description = description; } // Determine the installation types. const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES"); - if (installTypes && *installTypes) { + if (cmNonempty(installTypes)) { std::vector<std::string> installTypesVector = cmExpandedList(installTypes); for (std::string const& installType : installTypesVector) { @@ -1578,7 +1578,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( // Determine the component dependencies. const char* depends = this->GetOption(macroPrefix + "_DEPENDS"); - if (depends && *depends) { + if (cmNonempty(depends)) { std::vector<std::string> dependsVector = cmExpandedList(depends); for (std::string const& depend : dependsVector) { cmCPackComponent* child = GetComponent(projectName, depend); @@ -1602,21 +1602,21 @@ cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup( // Define the group group->Name = name; const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME"); - if (displayName && *displayName) { + if (cmNonempty(displayName)) { group->DisplayName = displayName; } else { group->DisplayName = group->Name; } const char* description = this->GetOption(macroPrefix + "_DESCRIPTION"); - if (description && *description) { + if (cmNonempty(description)) { group->Description = description; } group->IsBold = this->IsOn(macroPrefix + "_BOLD_TITLE"); group->IsExpandedByDefault = this->IsOn(macroPrefix + "_EXPANDED"); const char* parentGroupName = this->GetOption(macroPrefix + "_PARENT_GROUP"); - if (parentGroupName && *parentGroupName) { + if (cmNonempty(parentGroupName)) { group->ParentGroup = GetComponentGroup(projectName, parentGroupName); group->ParentGroup->Subgroups.push_back(group); } else { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 058b090..2109b4e 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -696,7 +696,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( const char* userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY"); std::string uploadDirectory; - if (userUploadDirectory && *userUploadDirectory) { + if (cmNonempty(userUploadDirectory)) { uploadDirectory = userUploadDirectory; } else { uploadDirectory = diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index db426b2..a18cbb4 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -182,10 +182,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) std::vector<std::string> extraPaths; std::vector<std::string> failed; fullPath = cmCTestTestHandler::FindExecutable( - this->CTest, this->ConfigSample.c_str(), resultingConfig, extraPaths, - failed); + this->CTest, this->ConfigSample, resultingConfig, extraPaths, failed); if (!fullPath.empty() && !resultingConfig.empty()) { - this->CTest->SetConfigType(resultingConfig.c_str()); + this->CTest->SetConfigType(resultingConfig); } out << "Using config sample with results: " << fullPath << " and " << resultingConfig << std::endl; @@ -296,9 +295,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) extraPaths.push_back(tempPath); } std::vector<std::string> failed; - fullPath = - cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(), - resultingConfig, extraPaths, failed); + fullPath = cmCTestTestHandler::FindExecutable( + this->CTest, this->TestCommand, resultingConfig, extraPaths, failed); if (!cmSystemTools::FileExists(fullPath)) { out << "Could not find path to executable, perhaps it was not built: " diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 44fdc29..8aab167 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -12,6 +12,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -38,10 +39,9 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Handler = handler; - const char* ctestBuildCommand = - this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); - if (ctestBuildCommand && *ctestBuildCommand) { - this->CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand, + cmProp ctestBuildCommand = this->Makefile->GetDef("CTEST_BUILD_COMMAND"); + if (cmNonempty(ctestBuildCommand)) { + this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand, this->Quiet); } else { const char* cmakeGeneratorName = @@ -56,7 +56,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); const char* cmakeBuildConfiguration = !this->Configuration.empty() ? this->Configuration.c_str() - : ((ctestBuildConfiguration && *ctestBuildConfiguration) + : (cmNonempty(ctestBuildConfiguration) ? ctestBuildConfiguration : this->CTest->GetConfigType().c_str()); @@ -67,7 +67,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() ? this->Target.c_str() : this->Makefile->GetDefinition("CTEST_BUILD_TARGET"); - if (cmakeGeneratorName && *cmakeGeneratorName) { + if (cmNonempty(cmakeGeneratorName)) { if (!cmakeBuildConfiguration) { cmakeBuildConfiguration = "Release"; } @@ -108,7 +108,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand << "\n", this->Quiet); - this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str(), + this->CTest->SetCTestConfiguration("MakeCommand", buildCommand, this->Quiet); } else { std::ostringstream ostr; @@ -123,16 +123,15 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() } } - if (const char* useLaunchers = - this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) { - this->CTest->SetCTestConfiguration("UseLaunchers", useLaunchers, + if (cmProp useLaunchers = this->Makefile->GetDef("CTEST_USE_LAUNCHERS")) { + this->CTest->SetCTestConfiguration("UseLaunchers", *useLaunchers, this->Quiet); } - if (const char* labelsForSubprojects = - this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + if (cmProp labelsForSubprojects = + this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", - labelsForSubprojects, this->Quiet); + *labelsForSubprojects, this->Quiet); } handler->SetQuiet(this->Quiet); diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index f42c3f1..ac57130 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -12,6 +12,7 @@ #include "cmCTestConfigureHandler.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -38,16 +39,16 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() return nullptr; } - const char* ctestConfigureCommand = - this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); + cmProp ctestConfigureCommand = + this->Makefile->GetDef("CTEST_CONFIGURE_COMMAND"); - if (ctestConfigureCommand && *ctestConfigureCommand) { + if (cmNonempty(ctestConfigureCommand)) { this->CTest->SetCTestConfiguration("ConfigureCommand", - ctestConfigureCommand, this->Quiet); + *ctestConfigureCommand, this->Quiet); } else { const char* cmakeGeneratorName = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); - if (cmakeGeneratorName && *cmakeGeneratorName) { + if (cmNonempty(cmakeGeneratorName)) { const std::string& source_dir = this->CTest->GetCTestConfiguration("SourceDirectory"); if (source_dir.empty()) { @@ -107,7 +108,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() const char* cmakeGeneratorPlatform = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM"); - if (cmakeGeneratorPlatform && *cmakeGeneratorPlatform) { + if (cmNonempty(cmakeGeneratorPlatform)) { cmakeConfigureCommand += " \"-A"; cmakeConfigureCommand += cmakeGeneratorPlatform; cmakeConfigureCommand += "\""; @@ -115,7 +116,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() const char* cmakeGeneratorToolset = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET"); - if (cmakeGeneratorToolset && *cmakeGeneratorToolset) { + if (cmNonempty(cmakeGeneratorToolset)) { cmakeConfigureCommand += " \"-T"; cmakeConfigureCommand += cmakeGeneratorToolset; cmakeConfigureCommand += "\""; @@ -125,8 +126,8 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() cmakeConfigureCommand += source_dir; cmakeConfigureCommand += "\""; - this->CTest->SetCTestConfiguration( - "ConfigureCommand", cmakeConfigureCommand.c_str(), this->Quiet); + this->CTest->SetCTestConfiguration("ConfigureCommand", + cmakeConfigureCommand, this->Quiet); } else { this->SetError( "Configure command is not specified. If this is a " @@ -136,10 +137,10 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } } - if (const char* labelsForSubprojects = - this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + if (cmProp labelsForSubprojects = + this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", - labelsForSubprojects, this->Quiet); + *labelsForSubprojects, this->Quiet); } cmCTestConfigureHandler* handler = this->CTest->GetConfigureHandler(); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index b839c10..093b2d1 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -469,8 +469,8 @@ int cmCTestCoverageHandler::ProcessHandler() } const std::string fileName = cmSystemTools::GetFilenameName(fullFileName); - std::string shortFileName = - this->CTest->GetShortPathToFile(fullFileName.c_str()); + const std::string shortFileName = + this->CTest->GetShortPathToFile(fullFileName); const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov = file.second; covLogXML.StartElement("File"); @@ -538,7 +538,7 @@ int cmCTestCoverageHandler::ProcessHandler() covSumXML.StartElement("File"); covSumXML.Attribute("Name", fileName); covSumXML.Attribute("FullPath", - this->CTest->GetShortPathToFile(fullFileName.c_str())); + this->CTest->GetShortPathToFile(fullFileName)); covSumXML.Attribute("Covered", tested + untested > 0 ? "true" : "false"); covSumXML.Element("LOCTested", tested); covSumXML.Element("LOCUnTested", untested); @@ -1887,8 +1887,8 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( // start the file output covLogXML.StartElement("File"); covLogXML.Attribute("Name", i->first); - covLogXML.Attribute( - "FullPath", this->CTest->GetShortPathToFile(i->second.c_str())); + covLogXML.Attribute("FullPath", + this->CTest->GetShortPathToFile(i->second)); covLogXML.StartElement("Report"); // write the bullseye header line = 0; @@ -2064,8 +2064,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( total_untested += (totalFunctions - functionsCalled); std::string fileName = cmSystemTools::GetFilenameName(file); - std::string shortFileName = - this->CTest->GetShortPathToFile(file.c_str()); + std::string shortFileName = this->CTest->GetShortPathToFile(file); float cper = static_cast<float>(percentBranch + percentFunction); if (totalBranches > 0) { @@ -2266,7 +2265,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) // is the end of the target-wide labels. inTarget = false; - source = this->CTest->GetShortPathToFile(line.c_str()); + source = this->CTest->GetShortPathToFile(line); // Label the source with the target labels. LabelSet& labelSet = this->SourceLabels[source]; @@ -2320,7 +2319,7 @@ bool cmCTestCoverageHandler::IsFilteredOut(std::string const& source) // The source is filtered out if it does not have any labels in // common with the filter set. - std::string shortSrc = this->CTest->GetShortPathToFile(source.c_str()); + std::string shortSrc = this->CTest->GetShortPathToFile(source); auto li = this->SourceLabels.find(shortSrc); if (li != this->SourceLabels.end()) { return !this->IntersectsFilter(li->second); @@ -2342,14 +2341,14 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles( std::vector<std::string> files = gl.GetFiles(); for (std::string const& f : files) { if (this->ShouldIDoCoverage(f, cont->SourceDir, cont->BinaryDir)) { - extraMatches.insert(this->CTest->GetShortPathToFile(f.c_str())); + extraMatches.insert(this->CTest->GetShortPathToFile(f)); } } } if (!extraMatches.empty()) { for (auto const& i : cont->TotalCoverage) { - std::string shortPath = this->CTest->GetShortPathToFile(i.first.c_str()); + std::string shortPath = this->CTest->GetShortPathToFile(i.first); extraMatches.erase(shortPath); } } diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index cc0b4ed..a71f550 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -100,7 +100,7 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, << std::endl); return false; } - this->CTest->AddSubmitFile(part, ostr.str().c_str()); + this->CTest->AddSubmitFile(part, ostr.str()); return true; } diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index a755632..03b7173 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -14,6 +14,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" @@ -125,23 +126,21 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, // CTEST_CONFIGURATION_TYPE script variable if it is defined. // The current script value trumps the -C argument on the command // line. - const char* ctestConfigType = - this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE"); + cmProp ctestConfigType = this->Makefile->GetDef("CTEST_CONFIGURATION_TYPE"); if (ctestConfigType) { - this->CTest->SetConfigType(ctestConfigType); + this->CTest->SetConfigType(*ctestConfigType); } if (!this->Build.empty()) { this->CTest->SetCTestConfiguration( - "BuildDirectory", cmSystemTools::CollapseFullPath(this->Build).c_str(), + "BuildDirectory", cmSystemTools::CollapseFullPath(this->Build), this->Quiet); } else { std::string const& bdir = this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY"); if (!bdir.empty()) { this->CTest->SetCTestConfiguration( - "BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(), - this->Quiet); + "BuildDirectory", cmSystemTools::CollapseFullPath(bdir), this->Quiet); } else { cmCTestLog(this->CTest, ERROR_MESSAGE, "CTEST_BINARY_DIRECTORY not set" << std::endl;); @@ -151,20 +150,18 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, cmCTestLog(this->CTest, DEBUG, "Set source directory to: " << this->Source << std::endl); this->CTest->SetCTestConfiguration( - "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(), + "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source), this->Quiet); } else { this->CTest->SetCTestConfiguration( "SourceDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")) - .c_str(), + this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")), this->Quiet); } - if (const char* changeId = - this->Makefile->GetDefinition("CTEST_CHANGE_ID")) { - this->CTest->SetCTestConfiguration("ChangeId", changeId, this->Quiet); + if (cmProp changeId = this->Makefile->GetDef("CTEST_CHANGE_ID")) { + this->CTest->SetCTestConfiguration("ChangeId", *changeId, this->Quiet); } cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index d2772a7..822049e 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -354,7 +354,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) cmCTestMemCheckHandler::TestResultsVector::size_type cc; for (cmCTestTestResult const& result : this->TestResults) { std::string testPath = result.Path + "/" + result.Name; - xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str())); + xml.Element("Test", this->CTest->GetShortPathToFile(testPath)); } xml.EndElement(); // TestList cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.cxx b/Source/CTest/cmCTestReadCustomFilesCommand.cxx index ed14d06..a25cca4 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.cxx +++ b/Source/CTest/cmCTestReadCustomFilesCommand.cxx @@ -15,7 +15,7 @@ bool cmCTestReadCustomFilesCommand::InitialPass( } for (std::string const& arg : args) { - this->CTest->ReadCustomConfigurationFileTree(arg.c_str(), this->Makefile); + this->CTest->ReadCustomConfigurationFileTree(arg, this->Makefile); } return true; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 2c8e385..4d65c9b 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -619,11 +619,11 @@ void cmCTestRunTest::ComputeArguments() cmCTestMemCheckHandler* handler = static_cast<cmCTestMemCheckHandler*>(this->TestHandler); this->ActualCommand = handler->MemoryTester; - this->TestProperties->Args[1] = this->TestHandler->FindTheExecutable( - this->TestProperties->Args[1].c_str()); + this->TestProperties->Args[1] = + this->TestHandler->FindTheExecutable(this->TestProperties->Args[1]); } else { - this->ActualCommand = this->TestHandler->FindTheExecutable( - this->TestProperties->Args[1].c_str()); + this->ActualCommand = + this->TestHandler->FindTheExecutable(this->TestProperties->Args[1]); ++j; // skip the executable (it will be actualCommand) } std::string testCommand = diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index fe68406..6398d66 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -94,10 +94,9 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir); std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir); - this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str(), - this->Quiet); - this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(), + this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir, this->Quiet); + this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir, this->Quiet); if (smodel) { cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 279216e..026e98f 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -35,12 +35,12 @@ std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone() cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() { - const char* submitURL = !this->SubmitURL.empty() - ? this->SubmitURL.c_str() - : this->Makefile->GetDefinition("CTEST_SUBMIT_URL"); + const std::string* submitURL = !this->SubmitURL.empty() + ? &this->SubmitURL + : this->Makefile->GetDef("CTEST_SUBMIT_URL"); if (submitURL) { - this->CTest->SetCTestConfiguration("SubmitURL", submitURL, this->Quiet); + this->CTest->SetCTestConfiguration("SubmitURL", *submitURL, this->Quiet); } else { this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "DropMethod", "CTEST_DROP_METHOD", this->Quiet); @@ -108,7 +108,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (this->PartsMentioned) { auto parts = cmMakeRange(this->Parts).transform([this](std::string const& arg) { - return this->CTest->GetPartFromName(arg.c_str()); + return this->CTest->GetPartFromName(arg); }); handler->SelectParts(std::set<cmCTest::Part>(parts.begin(), parts.end())); } @@ -177,7 +177,7 @@ void cmCTestSubmitCommand::CheckArguments( !this->Files.empty() || cm::contains(keywords, "FILES"); cm::erase_if(this->Parts, [this](std::string const& arg) -> bool { - cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str()); + cmCTest::Part p = this->CTest->GetPartFromName(arg); if (p == cmCTest::PartCount) { std::ostringstream e; e << "Part name \"" << arg << "\" is invalid."; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index ea36df5..5b54573 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -797,7 +797,7 @@ int cmCTestSubmitHandler::ProcessHandler() gfile = gfile.substr(glen); cmCTestOptionalLog(this->CTest, DEBUG, "Glob file: " << gfile << std::endl, this->Quiet); - this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfile.c_str()); + this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfile); } } else { cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl); diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index c71b409..cbc3c0c 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -13,6 +13,7 @@ #include "cmCTestTestHandler.h" #include "cmDuration.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" void cmCTestTestCommand::BindArguments() @@ -116,13 +117,13 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() unsigned long testLoad; const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD"); if (!this->TestLoad.empty()) { - if (!cmStrToULong(this->TestLoad.c_str(), &testLoad)) { + if (!cmStrToULong(this->TestLoad, &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, "Invalid value for 'TEST_LOAD' : " << this->TestLoad << std::endl); } - } else if (ctestTestLoad && *ctestTestLoad) { + } else if (cmNonempty(ctestTestLoad)) { if (!cmStrToULong(ctestTestLoad, &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, @@ -134,10 +135,10 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() } handler->SetTestLoad(testLoad); - if (const char* labelsForSubprojects = - this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + if (cmProp labelsForSubprojects = + this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", - labelsForSubprojects, this->Quiet); + *labelsForSubprojects, this->Quiet); } handler->SetQuiet(this->Quiet); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d0dbaae..70e84ee 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1374,7 +1374,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.StartElement("TestList"); for (cmCTestTestResult const& result : this->TestResults) { std::string testPath = result.Path + "/" + result.Name; - xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str())); + xml.Element("Test", this->CTest->GetShortPathToFile(testPath)); } xml.EndElement(); // TestList for (cmCTestTestResult& result : this->TestResults) { @@ -1483,8 +1483,8 @@ void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml, } std::string testPath = result.Path + "/" + result.Name; xml.Element("Name", result.Name); - xml.Element("Path", this->CTest->GetShortPathToFile(result.Path.c_str())); - xml.Element("FullName", this->CTest->GetShortPathToFile(testPath.c_str())); + xml.Element("Path", this->CTest->GetShortPathToFile(result.Path)); + xml.Element("FullName", this->CTest->GetShortPathToFile(testPath)); xml.Element("FullCommandLine", result.FullCommandLine); } @@ -1546,12 +1546,12 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) } // Find the appropriate executable to run for a test -std::string cmCTestTestHandler::FindTheExecutable(const char* exe) +std::string cmCTestTestHandler::FindTheExecutable(const std::string& exe) { std::string resConfig; std::vector<std::string> extraPaths; std::vector<std::string> failedPaths; - if (strcmp(exe, "NOT_AVAILABLE") == 0) { + if (exe == "NOT_AVAILABLE") { return exe; } return cmCTestTestHandler::FindExecutable(this->CTest, exe, resConfig, @@ -1607,7 +1607,7 @@ void cmCTestTestHandler::AddConfigurations( // Find the appropriate executable to run for a test std::string cmCTestTestHandler::FindExecutable( - cmCTest* ctest, const char* testCommand, std::string& resultingConfig, + cmCTest* ctest, const std::string& testCommand, std::string& resultingConfig, std::vector<std::string>& extraPaths, std::vector<std::string>& failed) { // now run the compiled test if we can find it diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 0d88c30..b26f8a6 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -198,7 +198,8 @@ public: std::string filepath, std::string& filename); // full signature static method to find an executable - static std::string FindExecutable(cmCTest* ctest, const char* testCommand, + static std::string FindExecutable(cmCTest* ctest, + const std::string& testCommand, std::string& resultingConfig, std::vector<std::string>& extraPaths, std::vector<std::string>& failed); @@ -309,7 +310,7 @@ private: /** * Find the executable for a test */ - std::string FindTheExecutable(const char* exe); + std::string FindTheExecutable(const std::string& exe); std::string GetTestStatus(cmCTestTestResult const&); void ExpandTestsToRunInformation(size_t numPossibleTests); diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 673eb9a..95cae13 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -11,14 +11,13 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() { if (!this->Source.empty()) { this->CTest->SetCTestConfiguration( - "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(), + "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source), this->Quiet); } else { this->CTest->SetCTestConfiguration( "SourceDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")) - .c_str(), + this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")), this->Quiet); } std::string source_dir = diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index a549117..9ee1c17 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -545,17 +545,17 @@ std::string cmProcess::GetExitExceptionString() # endif # ifdef SIGABRT case SIGABRT: - exception_str = "Child aborted"; + exception_str = "Subprocess aborted"; break; # endif # ifdef SIGKILL case SIGKILL: - exception_str = "Child killed"; + exception_str = "Subprocess killed"; break; # endif # ifdef SIGTERM case SIGTERM: - exception_str = "Child terminated"; + exception_str = "Subprocess terminated"; break; # endif # ifdef SIGHUP diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 4254e2e..a5fde89 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -394,7 +394,7 @@ bool cmCTest::ShouldCompressTestOutput() return this->Impl->CompressTestOutput; } -cmCTest::Part cmCTest::GetPartFromName(const char* name) +cmCTest::Part cmCTest::GetPartFromName(const std::string& name) { // Look up by lower-case to make names case-insensitive. std::string lower_name = cmSystemTools::LowerCase(name); @@ -458,8 +458,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmMakefile mf(&gg, cm.GetCurrentSnapshot()); - if (!this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir.c_str(), - &mf)) { + if (!this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir, &mf)) { cmCTestOptionalLog( this, DEBUG, "Cannot find custom configuration file tree" << std::endl, quiet); @@ -523,7 +522,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) std::string model; if (cmSystemTools::GetLineFromStream(tfin, model) && !this->Impl->Parts[PartStart] && !command) { - this->Impl->TestModel = GetTestModelFromString(model.c_str()); + this->Impl->TestModel = GetTestModelFromString(model); } tfin.close(); } @@ -579,7 +578,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cmSystemTools::GetLineFromStream(tfin, tag); cmSystemTools::GetLineFromStream(tfin, group); if (cmSystemTools::GetLineFromStream(tfin, modelStr)) { - model = GetTestModelFromString(modelStr.c_str()); + model = GetTestModelFromString(modelStr); } tfin.close(); } @@ -793,7 +792,7 @@ int cmCTest::GetTestModel() const return this->Impl->TestModel; } -bool cmCTest::SetTest(const char* ttype, bool report) +bool cmCTest::SetTest(const std::string& ttype, bool report) { if (cmSystemTools::LowerCase(ttype) == "all") { for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { @@ -856,7 +855,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name, return true; } -bool cmCTest::AddIfExists(Part part, const char* file) +bool cmCTest::AddIfExists(Part part, const std::string& file) { if (this->CTestFileExists(file)) { this->AddSubmitFile(part, file); @@ -1008,7 +1007,7 @@ int cmCTest::ProcessSteps() if (this->Impl->Parts[PartNotes]) { this->UpdateCTestConfiguration(); if (!this->Impl->NotesFiles.empty()) { - this->GenerateNotesFile(this->Impl->NotesFiles.c_str()); + this->GenerateNotesFile(this->Impl->NotesFiles); } } if (this->Impl->Parts[PartSubmit]) { @@ -1037,9 +1036,9 @@ std::string cmCTest::GetTestModelString() return "Experimental"; } -int cmCTest::GetTestModelFromString(const char* str) +int cmCTest::GetTestModelFromString(const std::string& str) { - if (!str) { + if (str.empty()) { return cmCTest::EXPERIMENTAL; } std::string rstr = cmSystemTools::LowerCase(str); @@ -1565,9 +1564,9 @@ int cmCTest::GenerateNotesFile(std::vector<std::string> const& files) return 0; } -int cmCTest::GenerateNotesFile(const char* cfiles) +int cmCTest::GenerateNotesFile(const std::string& cfiles) { - if (!cfiles) { + if (cfiles.empty()) { return 1; } @@ -1650,14 +1649,14 @@ bool cmCTest::SubmitExtraFiles(std::vector<std::string> const& files) << std::endl;); return false; } - this->AddSubmitFile(PartExtraFiles, file.c_str()); + this->AddSubmitFile(PartExtraFiles, file); } return true; } -bool cmCTest::SubmitExtraFiles(const char* cfiles) +bool cmCTest::SubmitExtraFiles(const std::string& cfiles) { - if (!cfiles) { + if (cfiles.empty()) { return true; } @@ -1941,7 +1940,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, else if (this->CheckArgument(arg, "-C"_s, "--build-config") && i < args.size() - 1) { i++; - this->SetConfigType(args[i].c_str()); + this->SetConfigType(args[i]); } else if (this->CheckArgument(arg, "--debug"_s)) { @@ -2016,7 +2015,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, else if (this->CheckArgument(arg, "-O"_s, "--output-log") && i < args.size() - 1) { i++; - this->SetOutputLogFileName(args[i].c_str()); + this->SetOutputLogFileName(args[i]); } else if (this->CheckArgument(arg, "--tomorrow-tag"_s)) { @@ -2048,7 +2047,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, this->Impl->ProduceXML = true; this->SetTest("Notes"); i++; - this->SetNotesFiles(args[i].c_str()); + this->SetNotesFiles(args[i]); return true; } @@ -2305,7 +2304,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) this->Impl->ProduceXML = true; this->SetTest("Submit"); i++; - if (!this->SubmitExtraFiles(args[i].c_str())) { + if (!this->SubmitExtraFiles(args[i])) { return 0; } } @@ -2376,7 +2375,7 @@ bool cmCTest::HandleTestActionArgument(const char* ctestExec, size_t& i, (i < args.size() - 1)) { this->Impl->ProduceXML = true; i++; - if (!this->SetTest(args[i].c_str(), false)) { + if (!this->SetTest(args[i], false)) { success = false; cmCTestLog(this, ERROR_MESSAGE, "CTest -T called with incorrect option: " << args[i] @@ -2491,11 +2490,8 @@ int cmCTest::RunCMakeAndTest(std::string* output) return retv; } -void cmCTest::SetNotesFiles(const char* notes) +void cmCTest::SetNotesFiles(const std::string& notes) { - if (!notes) { - return; - } this->Impl->NotesFiles = notes; } @@ -2561,7 +2557,8 @@ void cmCTest::SetScheduleType(std::string const& type) this->Impl->ScheduleType = type; } -int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) +int cmCTest::ReadCustomConfigurationFileTree(const std::string& dir, + cmMakefile* mf) { bool found = false; cmCTestLog(this, DEBUG, @@ -2648,7 +2645,7 @@ void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def, val = atoi(dval); } -std::string cmCTest::GetShortPathToFile(const char* cfname) +std::string cmCTest::GetShortPathToFile(const std::string& cfname) { const std::string& sourceDir = cmSystemTools::CollapseFullPath( this->GetCTestConfiguration("SourceDirectory")); @@ -2712,18 +2709,17 @@ void cmCTest::EmptyCTestConfiguration() this->Impl->CTestConfiguration.clear(); } -void cmCTest::SetCTestConfiguration(const char* name, const char* value, +void cmCTest::SetCTestConfiguration(const char* name, const std::string& value, bool suppress) { cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT, - "SetCTestConfiguration:" - << name << ":" << (value ? value : "(null)") << "\n", + "SetCTestConfiguration:" << name << ":" << value << "\n", suppress); if (!name) { return; } - if (!value) { + if (value.empty()) { this->Impl->CTestConfiguration.erase(name); return; } @@ -2928,7 +2924,7 @@ std::string cmCTest::GetBuildID() const return this->Impl->BuildID; } -void cmCTest::AddSubmitFile(Part part, const char* name) +void cmCTest::AddSubmitFile(Part part, const std::string& name) { this->Impl->Parts[part].SubmitFiles.emplace_back(name); } @@ -2964,9 +2960,9 @@ void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr) this->Impl->CTestConfigurationOverwrites[key] = value; } -void cmCTest::SetConfigType(const char* ct) +void cmCTest::SetConfigType(const std::string& ct) { - this->Impl->ConfigType = ct ? ct : ""; + this->Impl->ConfigType = ct; cmSystemTools::ReplaceString(this->Impl->ConfigType, ".\\", ""); std::string confTypeEnv = "CMAKE_CONFIG_TYPE=" + this->Impl->ConfigType; cmSystemTools::PutEnv(confTypeEnv); @@ -2976,8 +2972,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable( cmMakefile* mf, const char* dconfig, const std::string& cmake_var, bool suppress) { - const char* ctvar; - ctvar = mf->GetDefinition(cmake_var); + cmProp ctvar = mf->GetDef(cmake_var); if (!ctvar) { return false; } @@ -2985,7 +2980,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable( "SetCTestConfigurationFromCMakeVariable:" << dconfig << ":" << cmake_var << std::endl, suppress); - this->SetCTestConfiguration(dconfig, ctvar, suppress); + this->SetCTestConfiguration(dconfig, *ctvar, suppress); return true; } @@ -3086,9 +3081,9 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args, return result; } -void cmCTest::SetOutputLogFileName(const char* name) +void cmCTest::SetOutputLogFileName(const std::string& name) { - if (name) { + if (!name.empty()) { this->Impl->OutputLogFile = cm::make_unique<cmGeneratedFileStream>(name); } else { this->Impl->OutputLogFile.reset(); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index a39b8fe..1e0fb8c 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -64,7 +64,7 @@ public: /** Get a testing part id from its string name. Returns PartCount if the string does not name a valid part. */ - Part GetPartFromName(const char* name); + Part GetPartFromName(const std::string& name); /** Process Command line arguments */ int Run(std::vector<std::string>&, std::string* output = nullptr); @@ -127,12 +127,12 @@ public: * Check if CTest file exists */ bool CTestFileExists(const std::string& filename); - bool AddIfExists(Part part, const char* file); + bool AddIfExists(Part part, const std::string& file); /** * Set the cmake test */ - bool SetTest(const char*, bool report = true); + bool SetTest(const std::string&, bool report = true); /** * Set the cmake test mode (experimental, nightly, continuous). @@ -141,11 +141,11 @@ public: int GetTestModel() const; std::string GetTestModelString(); - static int GetTestModelFromString(const char* str); + static int GetTestModelFromString(const std::string& str); static std::string CleanString(const std::string& str, std::string::size_type spos = 0); std::string GetCTestConfiguration(const std::string& name); - void SetCTestConfiguration(const char* name, const char* value, + void SetCTestConfiguration(const char* name, const std::string& value, bool suppress = false); void EmptyCTestConfiguration(); @@ -161,7 +161,7 @@ public: cmCTest& operator=(const cmCTest&) = delete; /** Set the notes files to be created. */ - void SetNotesFiles(const char* notes); + void SetNotesFiles(const std::string& notes); void PopulateCustomVector(cmMakefile* mf, const std::string& definition, std::vector<std::string>& vec); @@ -272,7 +272,7 @@ public: * This means if the file is in binary or * source directory, it will become /.../relative/path/to/file */ - std::string GetShortPathToFile(const char* fname); + std::string GetShortPathToFile(const std::string& fname); enum { @@ -354,14 +354,14 @@ public: int GenerateDoneFile(); /** Submit extra files to the server */ - bool SubmitExtraFiles(const char* files); + bool SubmitExtraFiles(const std::string& files); bool SubmitExtraFiles(std::vector<std::string> const& files); /** Set the output log file name */ - void SetOutputLogFileName(const char* name); + void SetOutputLogFileName(const std::string& name); /** Set the visual studio or Xcode config type */ - void SetConfigType(const char* ct); + void SetConfigType(const std::string& ct); /** Various log types */ enum @@ -399,14 +399,14 @@ public: std::string GetBuildID() const; /** Add file to be submitted */ - void AddSubmitFile(Part part, const char* name); + void AddSubmitFile(Part part, const std::string& name); std::vector<std::string> const& GetSubmitFiles(Part part) const; void ClearSubmitFiles(Part part); /** * Read the custom configuration files and apply them to the current ctest */ - int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf); + int ReadCustomConfigurationFileTree(const std::string& dir, cmMakefile* mf); std::vector<std::string>& GetInitialCommandLineArguments(); @@ -462,7 +462,7 @@ public: void SetRunCurrentScript(bool value); private: - int GenerateNotesFile(const char* files); + int GenerateNotesFile(const std::string& files); void BlockTestErrorDiagnostics(); diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx index 81cd878..6591fb1 100644 --- a/Source/cmComputeComponentGraph.cxx +++ b/Source/cmComputeComponentGraph.cxx @@ -8,6 +8,12 @@ cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input) : InputGraph(input) { +} + +cmComputeComponentGraph::~cmComputeComponentGraph() = default; + +void cmComputeComponentGraph::Compute() +{ // Identify components. this->Tarjan(); @@ -17,8 +23,6 @@ cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input) this->TransferEdges(); } -cmComputeComponentGraph::~cmComputeComponentGraph() = default; - void cmComputeComponentGraph::Tarjan() { int n = static_cast<int>(this->InputGraph.size()); diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index 202888c..b873131 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -31,6 +31,9 @@ public: cmComputeComponentGraph(Graph const& input); ~cmComputeComponentGraph(); + /** Run the computation. */ + void Compute(); + /** Get the adjacency list of the component graph. */ Graph const& GetComponentGraph() const { return this->ComponentGraph; } EdgeList const& GetComponentGraphEdges(int c) const diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 607b948..8ca2168 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -626,6 +626,7 @@ void cmComputeLinkDepends::OrderLinkEntires() // constraints disallow it. this->CCG = cm::make_unique<cmComputeComponentGraph>(this->EntryConstraintGraph); + this->CCG->Compute(); // The component graph is guaranteed to be acyclic. Start a DFS // from every entry to compute a topological order for the diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fbb95e1..43cceae 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -832,8 +832,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() // We can support link type switching only if all needed flags are // known. - if (static_link_type_flag && *static_link_type_flag && - shared_link_type_flag && *shared_link_type_flag) { + if (cmNonempty(static_link_type_flag) && cmNonempty(shared_link_type_flag)) { this->LinkTypeEnabled = true; this->StaticLinkTypeFlag = static_link_type_flag; this->SharedLinkTypeFlag = shared_link_type_flag; @@ -1768,7 +1767,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, std::string d = ri; if (!rootPath.empty() && cmHasPrefix(d, rootPath)) { d.erase(0, rootPath.size()); - } else if (stagePath && *stagePath && cmHasPrefix(d, stagePath)) { + } else if (cmNonempty(stagePath) && cmHasPrefix(d, stagePath)) { d.erase(0, strlen(stagePath)); d = cmStrCat(installPrefix, '/', d); cmSystemTools::ConvertToUnixSlashes(d); @@ -1799,7 +1798,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, std::string d = ri; if (!rootPath.empty() && cmHasPrefix(d, rootPath)) { d.erase(0, rootPath.size()); - } else if (stagePath && *stagePath && cmHasPrefix(d, stagePath)) { + } else if (cmNonempty(stagePath) && cmHasPrefix(d, stagePath)) { d.erase(0, strlen(stagePath)); d = cmStrCat(installPrefix, '/', d); cmSystemTools::ConvertToUnixSlashes(d); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 6b4d110..e717f71 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -118,6 +118,7 @@ bool cmComputeTargetDepends::Compute() // Identify components. cmComputeComponentGraph ccg(this->InitialGraph); + ccg.Compute(); if (this->DebugMode) { this->DisplayComponents(ccg); } @@ -184,7 +185,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. cmGeneratorTarget const* depender = this->Targets[depender_index]; - if (depender->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!depender->IsInBuildSystem()) { return; } @@ -198,16 +199,18 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::vector<std::string> const& configs = depender->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& it : configs) { - cmLinkImplementation const* impl = depender->GetLinkImplementation(it); - // A target should not depend on itself. emitted.insert(cmLinkItem(depender, false, cmListFileBacktrace())); emitted.insert(cmLinkItem(depender, true, cmListFileBacktrace())); - for (cmLinkImplItem const& lib : impl->Libraries) { - // Don't emit the same library twice for this target. - if (emitted.insert(lib).second) { - this->AddTargetDepend(depender_index, lib, true, false); - this->AddInterfaceDepends(depender_index, lib, it, emitted); + + if (cmLinkImplementation const* impl = + depender->GetLinkImplementation(it)) { + for (cmLinkImplItem const& lib : impl->Libraries) { + // Don't emit the same library twice for this target. + if (emitted.insert(lib).second) { + this->AddTargetDepend(depender_index, lib, true, false); + this->AddInterfaceDepends(depender_index, lib, it, emitted); + } } } @@ -356,10 +359,9 @@ void cmComputeTargetDepends::AddTargetDepend( int depender_index, cmGeneratorTarget const* dependee, cmListFileBacktrace const& dependee_backtrace, bool linking, bool cross) { - if (dependee->IsImported() || - dependee->GetType() == cmStateEnums::INTERFACE_LIBRARY) { - // Skip IMPORTED and INTERFACE targets but follow their utility - // dependencies. + if (!dependee->IsInBuildSystem()) { + // Skip targets that are not in the buildsystem but follow their + // utility dependencies. std::set<cmLinkItem> const& utils = dependee->GetUtilityItems(); for (cmLinkItem const& i : utils) { if (cmGeneratorTarget const* transitive_dependee = i.Target) { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 8465c58..63c1484 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -1045,14 +1045,14 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName, const char* config = this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); // if a config was specified try that first - if (config && config[0]) { + if (cmNonempty(config)) { std::string tmp = cmStrCat('/', config); searchDirs.push_back(std::move(tmp)); } searchDirs.emplace_back("/Debug"); #if defined(__APPLE__) std::string app = "/" + targetName + ".app"; - if (config && config[0]) { + if (cmNonempty(config)) { std::string tmp = cmStrCat('/', config, app); searchDirs.push_back(std::move(tmp)); } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 8f02d95..54418df 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -395,7 +395,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, << ' ' << stampFileForShell; cmMakefile* mf = this->LocalGenerator->GetMakefile(); const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID"); - if (cid && *cid) { + if (cmNonempty(cid)) { makeDepends << ' ' << cid; } makeDepends << '\n'; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 7101e22..9db8b85 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1394,8 +1394,10 @@ size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data) { int realsize = static_cast<int>(size * nmemb); cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data); - const char* chPtr = static_cast<char*>(ptr); - fout->write(chPtr, realsize); + if (fout) { + const char* chPtr = static_cast<char*>(ptr); + fout->write(chPtr, realsize); + } return realsize; } @@ -1551,15 +1553,14 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, { #if !defined(CMAKE_BOOTSTRAP) auto i = args.begin(); - if (args.size() < 3) { - status.SetError("DOWNLOAD must be called with at least three arguments."); + if (args.size() < 2) { + status.SetError("DOWNLOAD must be called with at least two arguments."); return false; } ++i; // Get rid of subcommand std::string url = *i; ++i; - std::string file = *i; - ++i; + std::string file; long timeout = 0; long inactivity_timeout = 0; @@ -1690,6 +1691,8 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, return false; } curl_headers.push_back(*i); + } else if (file.empty()) { + file = *i; } else { // Do not return error for compatibility reason. std::string err = cmStrCat("Unexpected argument: ", *i); @@ -1697,11 +1700,18 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, } ++i; } + // Can't calculate hash if we don't save the file. + // TODO Incrementally calculate hash in the write callback as the file is + // being downloaded so this check can be relaxed. + if (file.empty() && hash) { + status.SetError("DOWNLOAD cannot calculate hash if file is not saved."); + return false; + } // If file exists already, and caller specified an expected md5 or sha, // and the existing file already has the expected hash, then simply // return. // - if (cmSystemTools::FileExists(file) && hash.get()) { + if (!file.empty() && cmSystemTools::FileExists(file) && hash.get()) { std::string msg; std::string actualHash = hash->HashFile(file); if (actualHash == expectedHash) { @@ -1716,20 +1726,26 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, // Make sure parent directory exists so we can write to the file // as we receive downloaded bits from curl... // - std::string dir = cmSystemTools::GetFilenamePath(file); - if (!dir.empty() && !cmSystemTools::FileExists(dir) && - !cmSystemTools::MakeDirectory(dir)) { - std::string errstring = "DOWNLOAD error: cannot create directory '" + dir + - "' - Specify file by full path name and verify that you " - "have directory creation and file write privileges."; - status.SetError(errstring); - return false; + if (!file.empty()) { + std::string dir = cmSystemTools::GetFilenamePath(file); + if (!dir.empty() && !cmSystemTools::FileExists(dir) && + !cmSystemTools::MakeDirectory(dir)) { + std::string errstring = "DOWNLOAD error: cannot create directory '" + + dir + + "' - Specify file by full path name and verify that you " + "have directory creation and file write privileges."; + status.SetError(errstring); + return false; + } } - cmsys::ofstream fout(file.c_str(), std::ios::binary); - if (!fout) { - status.SetError("DOWNLOAD cannot open file for write."); - return false; + cmsys::ofstream fout; + if (!file.empty()) { + fout.open(file.c_str(), std::ios::binary); + if (!fout) { + status.SetError("DOWNLOAD cannot open file for write."); + return false; + } } # if defined(_WIN32) @@ -1791,7 +1807,8 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, cmFileCommandVectorOfChar chunkDebug; - res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &fout); + res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, + file.empty() ? nullptr : &fout); check_curl_result(res, "DOWNLOAD cannot set write data: "); res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug); @@ -1865,8 +1882,10 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, // Explicitly flush/close so we can measure the md5 accurately. // - fout.flush(); - fout.close(); + if (!file.empty()) { + fout.flush(); + fout.close(); + } // Verify MD5 sum if requested: // diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 627e05b..5d44a06 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -173,7 +173,7 @@ bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode) // check if default dir creation permissions were set const char* default_dir_install_permissions = this->Makefile->GetDefinition( "CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (default_dir_install_permissions && *default_dir_install_permissions) { + if (cmNonempty(default_dir_install_permissions)) { std::vector<std::string> items = cmExpandedList(default_dir_install_permissions); for (const auto& arg : items) { diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 3e97150..3401eff 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -208,10 +208,10 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) const char* sysrootLink = this->Makefile->GetDefinition("CMAKE_SYSROOT_LINK"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - const bool noSysroot = !sysroot || !*sysroot; - const bool noCompileSysroot = !sysrootCompile || !*sysrootCompile; - const bool noLinkSysroot = !sysrootLink || !*sysrootLink; - const bool noRootPath = !rootPath || !*rootPath; + const bool noSysroot = !cmNonempty(sysroot); + const bool noCompileSysroot = !cmNonempty(sysrootCompile); + const bool noLinkSysroot = !cmNonempty(sysrootLink); + const bool noRootPath = !cmNonempty(rootPath); if (noSysroot && noCompileSysroot && noLinkSysroot && noRootPath) { return; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b10ce89..41cff01 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1089,6 +1089,27 @@ std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPostBuildCommands() return this->Target->GetPostBuildCommands(); } +bool cmGeneratorTarget::IsInBuildSystem() const +{ + if (this->IsImported()) { + return false; + } + switch (this->Target->GetType()) { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: + return true; + case cmStateEnums::INTERFACE_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: + break; + } + return false; +} + bool cmGeneratorTarget::IsImported() const { return this->Target->IsImported(); @@ -1099,6 +1120,11 @@ bool cmGeneratorTarget::IsImportedGloballyVisible() const return this->Target->IsImportedGloballyVisible(); } +bool cmGeneratorTarget::CanCompileSources() const +{ + return this->Target->CanCompileSources(); +} + const std::string& cmGeneratorTarget::GetLocationForBuild() const { static std::string location; @@ -1365,7 +1391,7 @@ void AddSwiftImplicitIncludeDirectories( for (const cmLinkImplItem& library : libraries->Libraries) { if (const cmGeneratorTarget* dependency = library.Target) { - if (dependency->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!dependency->IsInBuildSystem()) { continue; } if (cm::contains(dependency->GetAllConfigCompileLanguages(), @@ -1995,7 +2021,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const std::string sepVar = cmStrCat("CMAKE_SHARED_LIBRARY_RUNTIME_", ll, "_FLAG_SEP"); const char* sep = this->Makefile->GetDefinition(sepVar); - if (sep && *sep) { + if (cmNonempty(sep)) { // TODO: Add ELF check to ABI detection and get rid of // CMAKE_EXECUTABLE_FORMAT. if (const char* fmt = @@ -2441,6 +2467,12 @@ private: cmGeneratorTarget::LinkClosure const* cmGeneratorTarget::GetLinkClosure( const std::string& config) const { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { + static LinkClosure const empty = { {}, {} }; + return ∅ + } + std::string key(cmSystemTools::UpperCase(config)); auto i = this->LinkClosureMap.find(key); if (i == this->LinkClosureMap.end()) { @@ -2757,6 +2789,12 @@ const std::vector<const cmGeneratorTarget*>& cmGeneratorTarget::GetLinkImplementationClosure( const std::string& config) const { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { + static std::vector<const cmGeneratorTarget*> const empty; + return empty; + } + LinkImplClosure& tgts = this->LinkImplClosureMap[config]; if (!tgts.Done) { tgts.Done = true; @@ -2764,6 +2802,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config); + assert(impl); for (cmLinkImplItem const& lib : impl->Libraries) { processILibs(config, this, lib, @@ -2813,29 +2852,26 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target) this->CurrentEntry = nullptr; // Queue all the source files already specified for the target. - if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - std::set<cmSourceFile*> emitted; - std::vector<std::string> const& configs = - this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); - for (std::string const& c : configs) { - std::vector<cmSourceFile*> sources; - this->GeneratorTarget->GetSourceFiles(sources, c); - for (cmSourceFile* sf : sources) { - const std::set<cmGeneratorTarget const*> tgts = - this->GlobalGenerator->GetFilenameTargetDepends(sf); - if (cm::contains(tgts, this->GeneratorTarget)) { - std::ostringstream e; - e << "Evaluation output file\n \"" << sf->ResolveFullPath() - << "\"\ndepends on the sources of a target it is used in. This " - "is a dependency loop and is not allowed."; - this->GeneratorTarget->LocalGenerator->IssueMessage( - MessageType::FATAL_ERROR, e.str()); - return; - } - if (emitted.insert(sf).second && - this->SourcesQueued.insert(sf).second) { - this->SourceQueue.push(sf); - } + std::set<cmSourceFile*> emitted; + std::vector<std::string> const& configs = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + for (std::string const& c : configs) { + std::vector<cmSourceFile*> sources; + this->GeneratorTarget->GetSourceFiles(sources, c); + for (cmSourceFile* sf : sources) { + const std::set<cmGeneratorTarget const*> tgts = + this->GlobalGenerator->GetFilenameTargetDepends(sf); + if (cm::contains(tgts, this->GeneratorTarget)) { + std::ostringstream e; + e << "Evaluation output file\n \"" << sf->ResolveFullPath() + << "\"\ndepends on the sources of a target it is used in. This " + "is a dependency loop and is not allowed."; + this->GeneratorTarget->LocalGenerator->IssueMessage( + MessageType::FATAL_ERROR, e.str()); + return; + } + if (emitted.insert(sf).second && this->SourcesQueued.insert(sf).second) { + this->SourceQueue.push(sf); } } } @@ -3413,23 +3449,24 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories( &dagChecker, entries); if (this->Makefile->IsOn("APPLE")) { - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config); - for (cmLinkImplItem const& lib : impl->Libraries) { - std::string libDir = cmSystemTools::CollapseFullPath( - lib.AsStr(), this->Makefile->GetHomeOutputDirectory()); - - static cmsys::RegularExpression frameworkCheck( - "(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); - if (!frameworkCheck.find(libDir)) { - continue; - } + if (cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config)) { + for (cmLinkImplItem const& lib : impl->Libraries) { + std::string libDir = cmSystemTools::CollapseFullPath( + lib.AsStr(), this->Makefile->GetHomeOutputDirectory()); + + static cmsys::RegularExpression frameworkCheck( + "(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); + if (!frameworkCheck.find(libDir)) { + continue; + } - libDir = frameworkCheck.match(1); + libDir = frameworkCheck.match(1); - EvaluatedTargetPropertyEntry ee(lib, cmListFileBacktrace()); - ee.Values.emplace_back(std::move(libDir)); - entries.Entries.emplace_back(std::move(ee)); + EvaluatedTargetPropertyEntry ee(lib, cmListFileBacktrace()); + ee.Values.emplace_back(std::move(libDir)); + entries.Entries.emplace_back(std::move(ee)); + } } } @@ -6524,15 +6561,20 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( iface.HadHeadSensitiveCondition, iface.HadContextSensitiveCondition, iface.HadLinkLanguageSensitiveCondition); - } else if (!cmp0022NEW) + return; + } + // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back // to the link implementation. - { - // The link implementation is the default link interface. - cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibrariesInternal(config, headTarget); + if (cmp0022NEW) { + return; + } + + // The link implementation is the default link interface. + if (cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibrariesInternal(config, headTarget)) { iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN && @@ -6826,8 +6868,8 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( const std::string& config, bool secondPass) const { - // There is no link implementation for imported targets. - if (this->IsImported()) { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { return nullptr; } @@ -6990,6 +7032,11 @@ std::string cmGeneratorTarget::GetDeprecation() const void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, const std::string& config) const { + // Targets that do not compile anything have no languages. + if (!this->CanCompileSources()) { + return; + } + std::vector<cmSourceFile*> sourceFiles; this->GetSourceFiles(sourceFiles, config); for (cmSourceFile* src : sourceFiles) { @@ -7085,8 +7132,8 @@ cmLinkImplementationLibraries const* cmGeneratorTarget::GetLinkImplementationLibrariesInternal( const std::string& config, cmGeneratorTarget const* head) const { - // There is no link implementation for imported targets. - if (this->IsImported()) { + // There is no link implementation for targets that cannot compile sources. + if (!this->CanCompileSources()) { return nullptr; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 08aa015..4a03f65 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -45,8 +45,10 @@ public: cmGlobalGenerator* GetGlobalGenerator() const; + bool IsInBuildSystem() const; bool IsImported() const; bool IsImportedGloballyVisible() const; + bool CanCompileSources() const; const std::string& GetLocation(const std::string& config) const; std::vector<cmCustomCommand> const& GetPreBuildCommands() const; diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx index 5eff3b8..9e5bbca 100644 --- a/Source/cmGlobalCommonGenerator.cxx +++ b/Source/cmGlobalCommonGenerator.cxx @@ -42,12 +42,7 @@ cmGlobalCommonGenerator::ComputeDirectoryTargets() const // for all targets in the directory. for (const auto& gt : lg->GetGeneratorTargets()) { cmStateEnums::TargetType const type = gt->GetType(); - if (type != cmStateEnums::EXECUTABLE && - type != cmStateEnums::STATIC_LIBRARY && - type != cmStateEnums::SHARED_LIBRARY && - type != cmStateEnums::MODULE_LIBRARY && - type != cmStateEnums::OBJECT_LIBRARY && - type != cmStateEnums::UTILITY) { + if (type == cmStateEnums::GLOBAL_TARGET || !gt->IsInBuildSystem()) { continue; } DirectoryTarget::Target t; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b227599..cad5d1f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -310,9 +310,7 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const bool failed = false; for (const auto& localGen : this->LocalGenerators) { for (const auto& target : localGen->GetGeneratorTargets()) { - if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET || - target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY || - target->GetType() == cmStateEnums::TargetType::UTILITY || + if (!target->CanCompileSources() || cmIsOn(target->GetProperty("ghs_integrity_app"))) { continue; } @@ -366,9 +364,7 @@ bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const bool failed = false; for (const auto& generator : this->LocalGenerators) { for (const auto& target : generator->GetGeneratorTargets()) { - if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET || - target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY || - target->GetType() == cmStateEnums::TargetType::UTILITY || + if (!target->CanCompileSources() || cmIsOn(target->GetProperty("ghs_integrity_app"))) { continue; } @@ -413,15 +409,13 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) "all generators must specify this->FindMakeProgramFile"); return false; } - if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || - cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { + if (cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile); if (!setMakeProgram.empty()) { mf->ReadListFile(setMakeProgram); } } - if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || - cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { + if (cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { std::ostringstream err; err << "CMake was unable to find a build program corresponding to \"" << this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You " @@ -787,7 +781,7 @@ void cmGlobalGenerator::EnableLanguage( std::string compilerEnv = cmStrCat("CMAKE_", lang, "_COMPILER_ENV_VAR"); std::ostringstream noCompiler; const char* compilerFile = mf->GetDefinition(compilerName); - if (!compilerFile || !*compilerFile || cmIsNOTFOUND(compilerFile)) { + if (!cmNonempty(compilerFile) || cmIsNOTFOUND(compilerFile)) { /* clang-format off */ noCompiler << "No " << compilerName << " could be found.\n" @@ -1603,9 +1597,7 @@ bool cmGlobalGenerator::AddAutomaticSources() for (const auto& lg : this->LocalGenerators) { lg->CreateEvaluationFileOutputs(); for (const auto& gt : lg->GetGeneratorTargets()) { - if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY || - gt->GetType() == cmStateEnums::UTILITY || - gt->GetType() == cmStateEnums::GLOBAL_TARGET) { + if (!gt->CanCompileSources()) { continue; } lg->AddUnityBuild(gt.get()); @@ -1617,9 +1609,7 @@ bool cmGlobalGenerator::AddAutomaticSources() } for (const auto& lg : this->LocalGenerators) { for (const auto& gt : lg->GetGeneratorTargets()) { - if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY || - gt->GetType() == cmStateEnums::UTILITY || - gt->GetType() == cmStateEnums::GLOBAL_TARGET) { + if (!gt->CanCompileSources()) { continue; } // Handle targets that re-use a PCH from an above-handled target. @@ -2173,7 +2163,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, const cmGeneratorTarget* target) const { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { return true; } cmMakefile* mf = root->GetMakefile(); @@ -2197,7 +2187,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, // configurations. if (trueCount && falseCount) { std::ostringstream e; - e << "The EXCLUDED_FROM_ALL property of target \"" << target->GetName() + e << "The EXCLUDE_FROM_ALL property of target \"" << target->GetName() << "\" varies by configuration. This is not supported by the \"" << root->GetGlobalGenerator()->GetName() << "\" generator."; mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); @@ -2462,7 +2452,7 @@ void cmGlobalGenerator::AddGlobalTarget_Package( gti.WorkingDir = mf->GetCurrentBinaryDirectory(); cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCPackCommand()); - if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { + if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { singleLine.push_back("-C"); singleLine.push_back(cmakeCfgIntDir); } @@ -2547,7 +2537,7 @@ void cmGlobalGenerator::AddGlobalTarget_Test( singleLine.push_back(arg); } } - if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { + if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { singleLine.push_back("-C"); singleLine.push_back(cmakeCfgIntDir); } else // TODO: This is a hack. Should be something to do with the @@ -2628,7 +2618,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( "installation rules have been specified", mf->GetBacktrace()); } else if (this->InstallTargetEnabled && !skipInstallRules) { - if (!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') { + if (!(cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.')) { std::set<std::string>* componentsSet = &this->InstallComponents; std::ostringstream ostr; if (!componentsSet->empty()) { @@ -2667,7 +2657,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( cmd = "cmake"; } singleLine.push_back(cmd); - if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { + if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { std::string cfgArg = "-DBUILD_TYPE="; bool useEPN = this->UseEffectivePlatformName(mf.get()); if (useEPN) { @@ -3062,7 +3052,7 @@ void cmGlobalGenerator::WriteSummary() for (const auto& lg : this->LocalGenerators) { for (const auto& tgt : lg->GetGeneratorTargets()) { - if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!tgt->IsInBuildSystem()) { continue; } this->WriteSummary(tgt.get()); diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 1664dd0..7c87131 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -218,10 +218,11 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, { const char* ghsRoot = mf->GetDefinition("GHS_TOOLSET_ROOT"); - if (!ghsRoot || ghsRoot[0] == '\0') { - ghsRoot = DEFAULT_TOOLSET_ROOT; + if (cmNonempty(ghsRoot)) { + tsd = ghsRoot; + } else { + tsd = DEFAULT_TOOLSET_ROOT; } - tsd = ghsRoot; if (ts.empty()) { std::vector<std::string> output; @@ -467,7 +468,7 @@ void cmGlobalGhsMultiGenerator::WriteAllTarget( this->ProjectTargets.push_back(t); } for (cmGeneratorTarget const* t : sortedProjectTargets) { - if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!t->IsInBuildSystem()) { continue; } if (!IsExcluded(t->GetLocalGenerator(), t)) { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 786cde7..2ef202d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1105,8 +1105,9 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( break; } - default: - return; + case cmStateEnums::INTERFACE_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: + break; } } @@ -1128,7 +1129,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( cmNinjaDeps outs; for (cmTargetDepend const& targetDep : this->GetTargetDirectDepends(target)) { - if (targetDep->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!targetDep->IsInBuildSystem()) { continue; } if (targetDep.IsCross()) { @@ -1170,7 +1171,7 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure( cmNinjaOuts this_outs; // this will be the new cache entry for (auto const& dep_target : this->GetTargetDirectDepends(target)) { - if (dep_target->GetType() == cmStateEnums::INTERFACE_LIBRARY || + if (!dep_target->IsInBuildSystem() || (this->EnableCrossConfigBuild() && !dep_target.IsCross())) { continue; } @@ -1189,7 +1190,7 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure( // finally generate the outputs of the target itself, if applicable cmNinjaDeps outs; if (!omit_self) { - this->AppendTargetOutputs(target, outs, config); + this->AppendTargetOutputs(target, outs, config, DependOnTargetArtifact); } outputs.insert(outs.begin(), outs.end()); } @@ -1201,7 +1202,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, std::string outputPath = this->NinjaOutputPath(alias); std::string buildAlias = this->BuildAlias(outputPath, config); cmNinjaDeps outputs; - this->AppendTargetOutputs(target, outputs, config); + this->AppendTargetOutputs(target, outputs, config, DependOnTargetArtifact); // Mark the target's outputs as ambiguous to ensure that no other target // uses the output as an alias. for (std::string const& output : outputs) { @@ -1267,11 +1268,12 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) if (ta.second.Config == "all") { for (auto const& config : this->CrossConfigs) { this->AppendTargetOutputs(ta.second.GeneratorTarget, - build.ExplicitDeps, config); + build.ExplicitDeps, config, + DependOnTargetArtifact); } } else { this->AppendTargetOutputs(ta.second.GeneratorTarget, build.ExplicitDeps, - ta.second.Config); + ta.second.Config, DependOnTargetArtifact); } this->WriteBuild(this->EnableCrossConfigBuild() && (ta.second.Config == "all" || @@ -1299,7 +1301,8 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) build.Outputs.front() = ta.first; build.ExplicitDeps.clear(); this->AppendTargetOutputs(ta.second.GeneratorTarget, - build.ExplicitDeps, config); + build.ExplicitDeps, config, + DependOnTargetArtifact); this->WriteBuild(*this->GetConfigFileStream(config), build); } } @@ -1321,7 +1324,8 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) build.ExplicitDeps.clear(); for (auto const& config : this->DefaultConfigs) { this->AppendTargetOutputs(ta.second.GeneratorTarget, - build.ExplicitDeps, config); + build.ExplicitDeps, config, + DependOnTargetArtifact); } this->WriteBuild(*this->GetDefaultFileStream(), build); } @@ -1358,7 +1362,8 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) configDeps.emplace_back(build.Outputs.front()); for (DirectoryTarget::Target const& t : dt.Targets) { if (!IsExcludedFromAllInConfig(t, config)) { - this->AppendTargetOutputs(t.GT, build.ExplicitDeps, config); + this->AppendTargetOutputs(t.GT, build.ExplicitDeps, config, + DependOnTargetArtifact); } } for (DirectoryTarget::Dir const& d : dt.Children) { diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 44e632f..10f5cf6 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -318,14 +318,13 @@ public: virtual std::string OrderDependsTargetForTarget( cmGeneratorTarget const* target, const std::string& config) const; - void AppendTargetOutputs( - cmGeneratorTarget const* target, cmNinjaDeps& outputs, - const std::string& config, - cmNinjaTargetDepends depends = DependOnTargetArtifact); - void AppendTargetDepends( - cmGeneratorTarget const* target, cmNinjaDeps& outputs, - const std::string& config, const std::string& fileConfig, - cmNinjaTargetDepends depends = DependOnTargetArtifact); + void AppendTargetOutputs(cmGeneratorTarget const* target, + cmNinjaDeps& outputs, const std::string& config, + cmNinjaTargetDepends depends); + void AppendTargetDepends(cmGeneratorTarget const* target, + cmNinjaDeps& outputs, const std::string& config, + const std::string& fileConfig, + cmNinjaTargetDepends depends); void AppendTargetDependsClosure(cmGeneratorTarget const* target, cmNinjaDeps& outputs, const std::string& config); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 1764429..ebc90b6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -845,8 +845,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() for (const auto& gt : lg->GetGeneratorTargets()) { cmLocalGenerator* tlg = gt->GetLocalGenerator(); - if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY || - IsExcluded(lg.get(), gt.get())) { + if (!gt->IsInBuildSystem() || IsExcluded(lg.get(), gt.get())) { continue; } @@ -881,7 +880,7 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInTarget( if (emitted.insert(target).second) { count = this->ProgressMap[target].Marks.size(); for (cmTargetDepend const& depend : this->GetTargetDirectDepends(target)) { - if (depend->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!depend->IsInBuildSystem()) { continue; } count += this->CountProgressMarksInTarget(depend, emitted); @@ -938,7 +937,7 @@ void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends( for (cmTargetDepend const& i : this->GetTargetDirectDepends(target)) { // Create the target-level dependency. cmGeneratorTarget const* dep = i; - if (dep->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!dep->IsInBuildSystem()) { continue; } cmLocalUnixMakefileGenerator3* lg3 = diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index c851eea..f8b438a 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -339,7 +339,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( // loop over again and write out configurations for each target // in the solution for (cmGeneratorTarget const* target : projectTargets) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { continue; } cmProp expath = target->GetProperty("EXTERNAL_MSPROJECT"); @@ -369,7 +369,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( std::string rootBinaryDir = root->GetCurrentBinaryDirectory(); for (cmGeneratorTarget const* target : projectTargets) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { continue; } bool written = false; @@ -436,7 +436,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( std::ostream& fout, OrderedTargetDependSet const& projectTargets) { for (cmGeneratorTarget const* target : projectTargets) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { continue; } cmProp vcprojName = target->GetProperty("GENERATOR_FILE_NAME"); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 29ca154..fcdfc50 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -325,7 +325,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends( TargetDependSet const& unordered = this->GetTargetDirectDepends(gt); OrderedTargetDependSet depends(unordered, std::string()); for (cmTargetDepend const& i : depends) { - if (i->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!i->IsInBuildSystem()) { continue; } std::string guid = this->GetGUID(i->GetName()); @@ -341,7 +341,7 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( if (cmGeneratorTarget* depTarget = target->GetLocalGenerator()->FindGeneratorTargetToUse( ui.Value.first)) { - if (depTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY && + if (depTarget->IsInBuildSystem() && depTarget->GetProperty("EXTERNAL_MSPROJECT")) { // This utility dependency names an external .vcproj target. // We use LinkLibraryDependencies="true" to link to it without diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b31d069..001d876 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -368,7 +368,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target) void cmGlobalVisualStudioGenerator::FollowLinkDepends( const cmGeneratorTarget* target, std::set<const cmGeneratorTarget*>& linked) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { return; } if (linked.insert(target).second && diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e54de5d..574e0f5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1199,7 +1199,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( return true; } - if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!gtgt->IsInBuildSystem()) { return true; } @@ -1845,7 +1845,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, cmXCodeObject* buildSettings, const std::string& configName) { - if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!gtgt->IsInBuildSystem()) { return; } @@ -2678,7 +2678,7 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType( cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget( cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases) { - if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!gtgt->IsInBuildSystem()) { return nullptr; } cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget); @@ -2821,7 +2821,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) cmSystemTools::Error("Error no target on xobject\n"); return; } - if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!gt->IsInBuildSystem()) { return; } @@ -3113,13 +3113,9 @@ bool cmGlobalXCodeGenerator::CreateGroups( // end up with (empty anyhow) ZERO_CHECK, install, or test source // groups: // - if (gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) { - continue; - } - if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { - continue; - } - if (gtgt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) { + if (!gtgt->IsInBuildSystem() || + gtgt->GetType() == cmStateEnums::GLOBAL_TARGET || + gtgt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) { continue; } @@ -3385,7 +3381,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES")); // When targeting macOS, use only the host architecture. if (this->SystemName == "Darwin"_s && - (!sysroot || !*sysroot || + (!cmNonempty(sysroot) || cmSystemTools::LowerCase(sysroot).find("macos") != std::string::npos)) { buildSettings->AddAttribute("ARCHS", @@ -3395,7 +3391,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO). buildSettings->AddAttribute("ARCHS", this->CreateString(archs)); } - if (deploymentTarget && *deploymentTarget) { + if (cmNonempty(deploymentTarget)) { buildSettings->AddAttribute(GetDeploymentPlatform(root->GetMakefile()), this->CreateString(deploymentTarget)); } @@ -3753,6 +3749,8 @@ void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings( if (this->XcodeVersion >= 100) { xout.Element("key", "BuildSystemType"); xout.Element("string", "Original"); + xout.Element("key", "DisableBuildSystemDeprecationWarning"); + xout.Element("true"); } if (hasGeneratedSchemes) { xout.Element("key", diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index c23156d..570f4ea 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -125,14 +125,6 @@ cmGraphVizWriter::cmGraphVizWriter(std::string const& fileName, cmGraphVizWriter::~cmGraphVizWriter() { this->WriteFooter(this->GlobalFileStream); - - for (auto& fileStream : this->PerTargetFileStreams) { - this->WriteFooter(*fileStream.second); - } - - for (auto& fileStream : this->TargetDependersFileStreams) { - this->WriteFooter(*fileStream.second); - } } void cmGraphVizWriter::VisitGraph(std::string const&) @@ -151,20 +143,10 @@ void cmGraphVizWriter::OnItem(cmLinkItem const& item) ++NextNodeId; this->WriteNode(this->GlobalFileStream, item); - - if (this->GeneratePerTarget) { - this->CreateTargetFile(this->PerTargetFileStreams, item); - } - - if (this->GenerateDependers) { - this->CreateTargetFile(this->TargetDependersFileStreams, item, - ".dependers"); - } } -void cmGraphVizWriter::CreateTargetFile(FileStreamMap& fileStreamMap, - cmLinkItem const& item, - std::string const& fileNameSuffix) +std::unique_ptr<cmGeneratedFileStream> cmGraphVizWriter::CreateTargetFile( + cmLinkItem const& item, std::string const& fileNameSuffix) { auto const pathSafeItemName = PathSafeString(item.AsStr()); auto const perTargetFileName = @@ -175,7 +157,7 @@ void cmGraphVizWriter::CreateTargetFile(FileStreamMap& fileStreamMap, this->WriteHeader(*perTargetFileStream, item.AsStr()); this->WriteNode(*perTargetFileStream, item); - fileStreamMap.emplace(item.AsStr(), std::move(perTargetFileStream)); + return perTargetFileStream; } void cmGraphVizWriter::OnDirectLink(cmLinkItem const& depender, @@ -260,7 +242,7 @@ void cmGraphVizWriter::ReadSettings( do { \ const char* value = mf.GetDefinition(cmakeDefinition); \ if (value) { \ - (var) = mf.IsOn(cmakeDefinition); \ + (var) = cmIsOn(value); \ } \ } while (false) @@ -323,13 +305,12 @@ void cmGraphVizWriter::Write() } if (this->GeneratePerTarget) { - WritePerTargetConnections<DependeesDir>(PerTargetConnections, - PerTargetFileStreams); + WritePerTargetConnections<DependeesDir>(PerTargetConnections); } if (this->GenerateDependers) { WritePerTargetConnections<DependersDir>(TargetDependersConnections, - TargetDependersFileStreams); + ".dependers"); } } @@ -368,7 +349,7 @@ void cmGraphVizWriter::FindAllConnections(const ConnectionsMap& connectionMap, template <typename DirFunc> void cmGraphVizWriter::WritePerTargetConnections( - const ConnectionsMap& connections, const FileStreamMap& streams) + const ConnectionsMap& connections, const std::string& fileNameSuffix) { // the per target connections must be extended by indirect dependencies ConnectionsMap extendedConnections; @@ -387,7 +368,9 @@ void cmGraphVizWriter::WritePerTargetConnections( } const Connections& cons = conPerTarget.second; - auto fileStream = streams.at(rootItem.AsStr()).get(); + + std::unique_ptr<cmGeneratedFileStream> fileStream = + this->CreateTargetFile(rootItem, fileNameSuffix); for (const Connection& con : cons) { const cmLinkItem& src = DirFunc::src(con); @@ -395,6 +378,8 @@ void cmGraphVizWriter::WritePerTargetConnections( this->WriteNode(*fileStream, con.dst); this->WriteConnection(*fileStream, src, dst, con.scopeType); } + + this->WriteFooter(*fileStream); } } diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 9766068..d1300ac 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -46,9 +46,6 @@ public: void Write(); private: - using FileStreamMap = - std::map<std::string, std::unique_ptr<cmGeneratedFileStream>>; - struct Connection { Connection(cmLinkItem s, cmLinkItem d, std::string scope) @@ -76,8 +73,8 @@ private: void WriteNode(cmGeneratedFileStream& fs, cmLinkItem const& item); - void CreateTargetFile(FileStreamMap& fileStreamMap, cmLinkItem const& target, - std::string const& fileNameSuffix = ""); + std::unique_ptr<cmGeneratedFileStream> CreateTargetFile( + cmLinkItem const& target, std::string const& fileNameSuffix = ""); void WriteConnection(cmGeneratedFileStream& fs, cmLinkItem const& dependerTargetName, @@ -95,7 +92,7 @@ private: template <typename DirFunc> void WritePerTargetConnections(const ConnectionsMap& connections, - const FileStreamMap& streams); + const std::string& fileNameSuffix = ""); bool ItemExcluded(cmLinkItem const& item); bool ItemNameFilteredOut(std::string const& itemName); @@ -111,8 +108,6 @@ private: std::string FileName; cmGeneratedFileStream GlobalFileStream; - FileStreamMap PerTargetFileStreams; - FileStreamMap TargetDependersFileStreams; ConnectionsMap PerTargetConnections; ConnectionsMap TargetDependersConnections; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 028053d..7e35fe7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -221,7 +221,7 @@ void cmLocalGenerator::ComputeObjectMaxPath() this->ObjectPathMax = 1000; #endif const char* plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX"); - if (plen && *plen) { + if (cmNonempty(plen)) { unsigned int pmax; if (sscanf(plen, "%u", &pmax) == 1) { if (pmax >= 128) { @@ -284,7 +284,7 @@ void cmLocalGenerator::TraceDependencies() // Generate the rule files for each target. const auto& targets = this->GetGeneratorTargets(); for (const auto& target : targets) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { continue; } target->TraceDependencies(); @@ -434,7 +434,7 @@ void cmLocalGenerator::GenerateInstallRules() prefix_win32 = "C:"; } const char* project_name = this->Makefile->GetDefinition("PROJECT_NAME"); - if (project_name && project_name[0]) { + if (cmNonempty(project_name)) { prefix_win32 += "/Program Files/"; prefix_win32 += project_name; } else { @@ -760,7 +760,7 @@ void cmLocalGenerator::ComputeTargetManifest() // Add our targets to the manifest for each configuration. const auto& targets = this->GetGeneratorTargets(); for (const auto& target : targets) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { continue; } for (std::string const& c : configNames) { @@ -797,7 +797,7 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures() // Now that C/C++ _STANDARD values have been computed // set the values to ObjC/ObjCXX _STANDARD variables - if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { + if (target->CanCompileSources()) { for (std::string const& c : configNames) { target->ComputeCompileFeatures(c, inferredEnabledLanguages); } @@ -893,7 +893,7 @@ std::string cmLocalGenerator::GetIncludeFlags( emitted.insert("/System/Library/Frameworks"); #endif for (std::string const& i : includes) { - if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") && + if (cmNonempty(fwSearchFlag) && this->Makefile->IsOn("APPLE") && cmSystemTools::IsPathToFramework(i)) { std::string const frameworkDir = cmSystemTools::CollapseFullPath(cmStrCat(i, "/../")); @@ -1653,7 +1653,7 @@ static std::string GetFrameworkFlags(const std::string& lang, std::string fwSearchFlagVar = "CMAKE_" + lang + "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = mf->GetDefinition(fwSearchFlagVar); - if (!(fwSearchFlag && *fwSearchFlag)) { + if (!cmNonempty(fwSearchFlag)) { return std::string(); } @@ -1892,7 +1892,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string sysrootFlagVar = std::string("CMAKE_") + lang + "_SYSROOT_FLAG"; const char* sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar); - if (sysrootFlag && *sysrootFlag) { + if (cmNonempty(sysrootFlag)) { if (!this->AppleArchSysroots.empty() && !this->AllAppleArchSysrootsAreTheSame(archs, sysroot)) { for (std::string const& arch : archs) { @@ -1921,8 +1921,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; const char* deploymentTargetFlag = this->Makefile->GetDefinition(deploymentTargetFlagVar); - if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget && - *deploymentTarget) { + if (cmNonempty(deploymentTargetFlag) && cmNonempty(deploymentTarget)) { flags += " "; flags += deploymentTargetFlag; flags += deploymentTarget; @@ -2614,7 +2613,7 @@ void cmLocalGenerator::CopyPchCompilePdb( } file << " break()\n" << " endif()\n"; - file << " else()\n" + file << " elseif(NOT EXISTS \"" << from_file << "\")\n" << " execute_process(COMMAND ${CMAKE_COMMAND}" << " -E sleep 1)\n" << " endif()\n"; @@ -2673,7 +2672,6 @@ inline void RegisterUnitySources(cmGeneratorTarget* target, cmSourceFile* sf, { target->AddSourceFileToUnityBatch(sf->ResolveFullPath()); sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str()); - sf->SetProperty("SKIP_AUTOGEN", "ON"); } inline void IncludeFileInUnitySources(cmGeneratedFileStream& unity_file, @@ -3062,7 +3060,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, if (!lang.empty()) { const char* df = this->Makefile->GetDefinition(cmStrCat("CMAKE_", lang, "_DEFINE_FLAG")); - if (df && *df) { + if (cmNonempty(df)) { dflag = df; } } diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 098fa5a..a23ad57 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -11,7 +11,6 @@ #include "cmGhsMultiTargetGenerator.h" #include "cmGlobalGenerator.h" #include "cmSourceFile.h" -#include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -33,7 +32,7 @@ std::string cmLocalGhsMultiGenerator::GetTargetDirectory( void cmLocalGhsMultiGenerator::GenerateTargetsDepthFirst( cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& remaining) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { return; } // Find this target in the list of remaining targets. diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index aee7f45..ef34953 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() } for (const auto& target : this->GetGeneratorTargets()) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { continue; } auto tg = cmNinjaTargetGenerator::New(target.get()); @@ -102,9 +102,10 @@ void cmLocalNinjaGenerator::Generate() this->GetGlobalGenerator()->IsMultiConfig()) { cmNinjaBuild phonyAlias("phony"); this->GetGlobalNinjaGenerator()->AppendTargetOutputs( - target.get(), phonyAlias.Outputs, ""); + target.get(), phonyAlias.Outputs, "", DependOnTargetArtifact); this->GetGlobalNinjaGenerator()->AppendTargetOutputs( - target.get(), phonyAlias.ExplicitDeps, config); + target.get(), phonyAlias.ExplicitDeps, config, + DependOnTargetArtifact); this->GetGlobalNinjaGenerator()->WriteBuild( *this->GetGlobalNinjaGenerator()->GetConfigFileStream(config), phonyAlias); @@ -115,11 +116,12 @@ void cmLocalNinjaGenerator::Generate() if (!this->GetGlobalNinjaGenerator()->GetDefaultConfigs().empty()) { cmNinjaBuild phonyAlias("phony"); this->GetGlobalNinjaGenerator()->AppendTargetOutputs( - target.get(), phonyAlias.Outputs, ""); + target.get(), phonyAlias.Outputs, "", DependOnTargetArtifact); for (auto const& config : this->GetGlobalNinjaGenerator()->GetDefaultConfigs()) { this->GetGlobalNinjaGenerator()->AppendTargetOutputs( - target.get(), phonyAlias.ExplicitDeps, config); + target.get(), phonyAlias.ExplicitDeps, config, + DependOnTargetArtifact); } this->GetGlobalNinjaGenerator()->WriteBuild( *this->GetGlobalNinjaGenerator()->GetDefaultFileStream(), @@ -127,10 +129,11 @@ void cmLocalNinjaGenerator::Generate() } cmNinjaBuild phonyAlias("phony"); this->GetGlobalNinjaGenerator()->AppendTargetOutputs( - target.get(), phonyAlias.Outputs, "all"); + target.get(), phonyAlias.Outputs, "all", DependOnTargetArtifact); for (auto const& config : this->GetConfigNames()) { this->GetGlobalNinjaGenerator()->AppendTargetOutputs( - target.get(), phonyAlias.ExplicitDeps, config); + target.get(), phonyAlias.ExplicitDeps, config, + DependOnTargetArtifact); } this->GetGlobalNinjaGenerator()->WriteBuild( *this->GetGlobalNinjaGenerator()->GetDefaultFileStream(), @@ -355,8 +358,8 @@ void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs, const std::string& config) { - this->GetGlobalNinjaGenerator()->AppendTargetOutputs(target, outputs, - config); + this->GetGlobalNinjaGenerator()->AppendTargetOutputs(target, outputs, config, + DependOnTargetArtifact); } void cmLocalNinjaGenerator::AppendTargetDepends(cmGeneratorTarget* target, diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index ef160e7..73c0cde 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -66,10 +66,10 @@ public: void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs, const std::string& config); - void AppendTargetDepends( - cmGeneratorTarget* target, cmNinjaDeps& outputs, const std::string& config, - const std::string& fileConfig, - cmNinjaTargetDepends depends = DependOnTargetArtifact); + void AppendTargetDepends(cmGeneratorTarget* target, cmNinjaDeps& outputs, + const std::string& config, + const std::string& fileConfig, + cmNinjaTargetDepends depends); void AddCustomCommandTarget(cmCustomCommand const* cc, cmGeneratorTarget* target); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index df4bf6a..8acd1e3 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -101,7 +101,7 @@ void cmLocalUnixMakefileGenerator3::Generate() cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); for (const auto& target : this->GetGeneratorTargets()) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { continue; } std::unique_ptr<cmMakefileTargetGenerator> tg( @@ -137,7 +137,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( std::map<std::string, LocalObjectInfo>& localObjectFiles) { for (const auto& gt : this->GetGeneratorTargets()) { - if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!gt->CanCompileSources()) { continue; } std::vector<cmSourceFile const*> objectSources; @@ -1807,7 +1807,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( std::string cidVar = cmStrCat("CMAKE_", implicitLang.first, "_COMPILER_ID"); const char* cid = this->Makefile->GetDefinition(cidVar); - if (cid && *cid) { + if (cmNonempty(cid)) { cmakefileStream << "set(CMAKE_" << implicitLang.first << "_COMPILER_ID \"" << cid << "\")\n"; } diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 9076e26..6c7d6c6 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -69,7 +69,7 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst( cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& remaining) { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!target->IsInBuildSystem()) { return; } // Find this target in the list of remaining targets. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index ad61ad3..fec6a9d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -66,7 +66,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() // Now create GUIDs for targets const auto& tgts = this->GetGeneratorTargets(); for (const auto& l : tgts) { - if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!l->IsInBuildSystem()) { continue; } cmProp path = l->GetProperty("EXTERNAL_MSPROJECT"); @@ -129,7 +129,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() // Create the project file for each target. for (const auto& l : tgts) { - if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!l->IsInBuildSystem()) { continue; } // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index aca40fa..5e1f070 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -196,7 +196,7 @@ void cmMakefile::MaybeWarnCMP0074(std::string const& pkg) std::string env; cmSystemTools::GetEnv(varName, env); - bool const haveVar = var && *var; + bool const haveVar = cmNonempty(var); bool const haveEnv = !env.empty(); if ((haveVar || haveEnv) && this->WarnedCMP0074.insert(varName).second) { std::ostringstream w; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 286a3dc..13c2fe9 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -839,7 +839,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( run_iwyu += " --tidy="; const char* driverMode = this->Makefile->GetDefinition( "CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE"); - if (!(driverMode && *driverMode)) { + if (!cmNonempty(driverMode)) { driverMode = lang == "C" ? "gcc" : "g++"; } run_iwyu += this->LocalGenerator->EscapeForShell( @@ -1857,7 +1857,7 @@ void cmMakefileTargetGenerator::GenDefFile( this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file), cmOutputConverter::SHELL); const char* nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); - if (nm_executable && *nm_executable) { + if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( nm_executable, cmOutputConverter::SHELL); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index de68371..bde5ee7 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -733,17 +733,14 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement( static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - globalGen->GetRuleCmdLength(this->LanguageLinkerDeviceRule(config)); - std::string path = localGen.GetHomeRelativeOutputPath(); - if (!path.empty()) { - path += '/'; - } build.RspFile = this->ConvertToNinjaPath( - cmStrCat(path, "CMakeFiles/", genTarget->GetName(), + cmStrCat("CMakeFiles/", genTarget->GetName(), globalGen->IsMultiConfig() ? cmStrCat('.', config) : "", ".rsp")); // Gather order-only dependencies. this->GetLocalGenerator()->AppendTargetDepends( - this->GetGeneratorTarget(), build.OrderOnlyDeps, config, config); + this->GetGeneratorTarget(), build.OrderOnlyDeps, config, config, + DependOnTargetArtifact); // Write the build statement for this target. bool usedResponseFile = false; @@ -1095,7 +1092,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( obj_list_file, cmOutputConverter::SHELL); const char* nm_executable = GetMakefile()->GetDefinition("CMAKE_NM"); - if (nm_executable && *nm_executable) { + if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( nm_executable, cmOutputConverter::SHELL); @@ -1159,17 +1156,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( globalGen->GetRuleCmdLength(linkBuild.Rule); } - std::string path = localGen.GetHomeRelativeOutputPath(); - if (!path.empty()) { - path += '/'; - } linkBuild.RspFile = this->ConvertToNinjaPath( - cmStrCat(path, "CMakeFiles/", gt->GetName(), + cmStrCat("CMakeFiles/", gt->GetName(), globalGen->IsMultiConfig() ? cmStrCat('.', config) : "", ".rsp")); // Gather order-only dependencies. - this->GetLocalGenerator()->AppendTargetDepends(gt, linkBuild.OrderOnlyDeps, - config, fileConfig); + this->GetLocalGenerator()->AppendTargetDepends( + gt, linkBuild.OrderOnlyDeps, config, fileConfig, DependOnTargetArtifact); // Add order-only dependencies on versioning symlinks of shared libs we link. if (!this->GeneratorTarget->IsDLLPlatform()) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index de18536..048dbb6 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -847,7 +847,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, run_iwyu += " --tidy="; const char* driverMode = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE")); - if (!(driverMode && *driverMode)) { + if (!cmNonempty(driverMode)) { driverMode = lang == "C" ? "gcc" : "g++"; } run_iwyu += this->GetLocalGenerator()->EscapeForShell( diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 8d863c3..9508bb9 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -101,7 +101,8 @@ void cmNinjaUtilityTargetGenerator::Generate(const std::string& config) lg->AppendTargetOutputs(genTarget, gg->GetByproductsForCleanTarget(), config); } - lg->AppendTargetDepends(genTarget, deps, config, config); + lg->AppendTargetDepends(genTarget, deps, config, config, + DependOnTargetArtifact); if (commands.empty()) { phonyBuild.Comment = "Utility command for " + this->GetTargetName(); diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 2ec66d9..bb6db92 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -303,7 +303,7 @@ bool cmProjectCommand(std::vector<std::string> const& args, std::string vw; for (std::string const& i : vv) { const char* const v = mf.GetDefinition(i); - if (v && *v) { + if (cmNonempty(v)) { if (cmp0048 == cmPolicies::WARN) { if (!injectedProjectCommand) { vw += "\n "; diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 205097d..06957b0 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1181,11 +1181,54 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() if (useNinjaDepfile) { // Create a custom command that generates a timestamp file and // has a depfile assigned. The depfile is created by JobDepFilesMergeT. - - // Add additional autogen target dependencies + // + // Also create an additional '_autogen_timestamp_deps' that the custom + // command will depend on. It will have no sources or commands to + // execute, but it will have dependencies that would originally be + // assigned to the pre-Qt 5.15 'autogen' target. These dependencies will + // serve as a list of order-only dependencies for the custom command, + // without forcing the custom command to re-execute. + // + // The dependency tree would then look like + // '_autogen_timestamp_deps (order-only)' <- '/timestamp' file <- + // '_autogen' target. + const auto timestampTargetName = + cmStrCat(this->GenTarget->GetName(), "_autogen_timestamp_deps"); + std::vector<std::string> timestampTargetProvides; + cmCustomCommandLines timestampTargetCommandLines; + + // Add additional autogen target dependencies to + // '_autogen_timestamp_deps'. for (const cmTarget* t : this->AutogenTarget.DependTargets) { dependencies.push_back(t->GetName()); } + + cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand( + timestampTargetName, true, this->Dir.Work.c_str(), + /*byproducts=*/timestampTargetProvides, + /*depends=*/dependencies, timestampTargetCommandLines, false, nullptr); + this->LocalGen->AddGeneratorTarget( + cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen)); + + // Set FOLDER property on the timestamp target, so it appears in the + // appropriate folder in an IDE or in the file api. + if (!this->TargetsFolder.empty()) { + timestampTarget->SetProperty("FOLDER", this->TargetsFolder); + } + + // Make '/timestamp' file depend on '_autogen_timestamp_deps' and on the + // moc and uic executables (whichever are enabled). + dependencies.clear(); + dependencies.push_back(timestampTargetName); + + if (this->Moc.ExecutableTarget != nullptr) { + dependencies.push_back(this->Moc.ExecutableTarget->Target->GetName()); + } + if (this->Uic.ExecutableTarget != nullptr) { + dependencies.push_back(this->Uic.ExecutableTarget->Target->GetName()); + } + + // Create the custom command that outputs the timestamp file. const char timestampFileName[] = "timestamp"; const std::string outputFile = cmStrCat(this->Dir.Build, "/", timestampFileName); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 9adcabb..f6cccfb 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2163,7 +2163,9 @@ std::string escapeDependencyPath(cm::string_view path) void cmQtAutoMocUicT::JobDepFilesMergeT::Process() { if (Log().Verbose()) { - Log().Info(GenT::MOC, "Merging MOC dependencies"); + Log().Info(GenT::MOC, + cmStrCat("Merging MOC dependencies into ", + MessagePath(BaseConst().DepFile.c_str()))); } auto processDepFile = [](const std::string& mocOutputFile) -> std::vector<std::string> { diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 766d347..eb8fcaf 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -180,7 +180,7 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, if (subdir == "include" || subdir == "lib") { const char* arch = this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); - if (arch && *arch) { + if (cmNonempty(arch)) { if (this->FC->Makefile->IsDefinitionSet("CMAKE_SYSROOT") && this->FC->Makefile->IsDefinitionSet( "CMAKE_PREFIX_LIBRARY_ARCHITECTURE")) { diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index 0eb869c..6dbab98 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -65,7 +65,7 @@ struct StanardLevelComputer const char* defaultStd = makefile->GetDefinition( cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT")); - if (!defaultStd || !*defaultStd) { + if (!cmNonempty(defaultStd)) { // this compiler has no notion of language standard levels return std::string{}; } @@ -472,7 +472,7 @@ const char* cmStandardLevelResolver::CompileFeaturesAvailable( const char* featuresKnown = this->Makefile->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES"); - if (!featuresKnown || !*featuresKnown) { + if (!cmNonempty(featuresKnown)) { std::ostringstream e; if (error) { e << "no"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index aec9afa..0e5dfef 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -216,6 +216,15 @@ public: std::string ProcessSourceItemCMP0049(const std::string& s); }; +namespace { +#define SETUP_COMMON_LANGUAGE_PROPERTIES(lang) \ + initProp(#lang "_COMPILER_LAUNCHER"); \ + initProp(#lang "_STANDARD"); \ + initProp(#lang "_STANDARD_REQUIRED"); \ + initProp(#lang "_EXTENSIONS"); \ + initProp(#lang "_VISIBILITY_PRESET") +} + cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, Visibility vis, cmMakefile* mf, PerConfig perConfig) : impl(cm::make_unique<cmTargetInternals>()) @@ -272,8 +281,14 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, }; // Setup default property values. - if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && - this->GetType() != cmStateEnums::UTILITY) { + if (this->CanCompileSources()) { + + SETUP_COMMON_LANGUAGE_PROPERTIES(C); + SETUP_COMMON_LANGUAGE_PROPERTIES(OBJC); + SETUP_COMMON_LANGUAGE_PROPERTIES(CXX); + SETUP_COMMON_LANGUAGE_PROPERTIES(OBJCXX); + SETUP_COMMON_LANGUAGE_PROPERTIES(CUDA); + initProp("ANDROID_API"); initProp("ANDROID_API_MIN"); initProp("ANDROID_ARCH"); @@ -335,38 +350,22 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("NO_SYSTEM_FROM_IMPORTED"); initProp("BUILD_WITH_INSTALL_NAME_DIR"); initProp("C_CLANG_TIDY"); - initProp("C_COMPILER_LAUNCHER"); initProp("C_CPPLINT"); initProp("C_CPPCHECK"); initProp("C_INCLUDE_WHAT_YOU_USE"); initProp("LINK_WHAT_YOU_USE"); - initProp("C_STANDARD"); - initProp("C_STANDARD_REQUIRED"); - initProp("C_EXTENSIONS"); - initProp("OBJC_COMPILER_LAUNCHER"); - initProp("OBJC_STANDARD"); - initProp("OBJC_STANDARD_REQUIRED"); - initProp("OBJC_EXTENSIONS"); initProp("CXX_CLANG_TIDY"); - initProp("CXX_COMPILER_LAUNCHER"); initProp("CXX_CPPLINT"); initProp("CXX_CPPCHECK"); initProp("CXX_INCLUDE_WHAT_YOU_USE"); - initProp("CXX_STANDARD"); - initProp("CXX_STANDARD_REQUIRED"); - initProp("CXX_EXTENSIONS"); - initProp("OBJCXX_COMPILER_LAUNCHER"); - initProp("OBJCXX_STANDARD"); - initProp("OBJCXX_STANDARD_REQUIRED"); - initProp("OBJCXX_EXTENSIONS"); - initProp("CUDA_STANDARD"); - initProp("CUDA_STANDARD_REQUIRED"); - initProp("CUDA_EXTENSIONS"); - initProp("CUDA_COMPILER_LAUNCHER"); initProp("CUDA_SEPARABLE_COMPILATION"); initProp("CUDA_RESOLVE_DEVICE_SYMBOLS"); initProp("CUDA_RUNTIME_LIBRARY"); initProp("CUDA_ARCHITECTURES"); + initProp("VISIBILITY_INLINES_HIDDEN"); + initProp("JOB_POOL_COMPILE"); + initProp("JOB_POOL_LINK"); + initProp("JOB_POOL_PRECOMPILE_HEADER"); initProp("LINK_SEARCH_START_STATIC"); initProp("LINK_SEARCH_END_STATIC"); initProp("Swift_LANGUAGE_VERSION"); @@ -377,6 +376,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initPropValue("UNITY_BUILD_BATCH_SIZE", "8"); initPropValue("UNITY_BUILD_MODE", "BATCH"); initPropValue("PCH_WARN_INVALID", "ON"); + #ifdef __APPLE__ if (this->GetGlobalGenerator()->IsXcode()) { initProp("XCODE_SCHEME_ADDRESS_SANITIZER"); @@ -410,7 +410,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } // Setup per-configuration property default values. - if (this->GetType() != cmStateEnums::UTILITY) { + if (this->GetType() != cmStateEnums::UTILITY && + this->GetType() != cmStateEnums::GLOBAL_TARGET) { static const auto configProps = { /* clang-format needs this comment to break after the opening brace */ "ARCHIVE_OUTPUT_DIRECTORY_", "LIBRARY_OUTPUT_DIRECTORY_", @@ -487,16 +488,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->Makefile->GetLinkDirectoriesBacktraces()); } - if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && - this->GetType() != cmStateEnums::UTILITY) { - initProp("C_VISIBILITY_PRESET"); - initProp("CXX_VISIBILITY_PRESET"); - initProp("OBJC_VISIBILITY_PRESET"); - initProp("OBJCXX_VISIBILITY_PRESET"); - initProp("CUDA_VISIBILITY_PRESET"); - initProp("VISIBILITY_INLINES_HIDDEN"); - } - if (impl->TargetType == cmStateEnums::EXECUTABLE) { initProp("ANDROID_GUI"); initProp("CROSSCOMPILING_EMULATOR"); @@ -505,6 +496,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || impl->TargetType == cmStateEnums::MODULE_LIBRARY) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); + } else if (this->CanCompileSources()) { + initProp("POSITION_INDEPENDENT_CODE"); } if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || impl->TargetType == cmStateEnums::EXECUTABLE) { @@ -512,11 +505,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("WINDOWS_EXPORT_ALL_SYMBOLS"); } - if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && - this->GetType() != cmStateEnums::UTILITY) { - initProp("POSITION_INDEPENDENT_CODE"); - } - // Record current policies for later use. impl->Makefile->RecordPolicies(impl->PolicyMap); @@ -528,13 +516,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW); } - if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && - this->GetType() != cmStateEnums::UTILITY) { - initProp("JOB_POOL_COMPILE"); - initProp("JOB_POOL_LINK"); - initProp("JOB_POOL_PRECOMPILE_HEADER"); - } - if (impl->TargetType <= cmStateEnums::GLOBAL_TARGET) { initProp("DOTNET_TARGET_FRAMEWORK"); initProp("DOTNET_TARGET_FRAMEWORK_VERSION"); @@ -1917,6 +1898,27 @@ bool cmTarget::IsPerConfig() const return impl->PerConfig; } +bool cmTarget::CanCompileSources() const +{ + if (this->IsImported()) { + return false; + } + switch (this->GetType()) { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: + return true; + case cmStateEnums::UTILITY: + case cmStateEnums::INTERFACE_LIBRARY: + case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::UNKNOWN_LIBRARY: + break; + } + return false; +} + const char* cmTarget::GetSuffixVariableInternal( cmStateEnums::ArtifactType artifact) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 7a16de8..43f1887 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -196,6 +196,7 @@ public: bool IsImported() const; bool IsImportedGloballyVisible() const; bool IsPerConfig() const; + bool CanCompileSources() const; bool GetMappedConfig(std::string const& desired_config, cmProp& loc, cmProp& imp, std::string& suffix) const; diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 7c0ce71..78b230c 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -77,7 +77,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, cmGeneratorExpression ge(this->Test->GetBacktrace()); // Start the test command. - os << indent << "add_test(\"" << this->Test->GetName() << "\" "; + os << indent << "add_test(" << this->Test->GetName() << " "; // Evaluate command line arguments std::vector<std::string> argv = @@ -127,8 +127,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, os << ")\n"; // Output properties for the test. - os << indent << "set_tests_properties(\"" << this->Test->GetName() - << "\" PROPERTIES "; + os << indent << "set_tests_properties(" << this->Test->GetName() + << " PROPERTIES "; for (auto const& i : this->Test->GetProperties().GetList()) { os << " " << i.first << " " << cmOutputConverter::EscapeForCMake( @@ -140,8 +140,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, Indent indent) { - os << indent << "add_test(\"" << this->Test->GetName() - << "\" NOT_AVAILABLE)\n"; + os << indent << "add_test(" << this->Test->GetName() << " NOT_AVAILABLE)\n"; } bool cmTestGenerator::NeedsScriptNoConfig() const @@ -161,8 +160,9 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent) std::string exe = command[0]; cmSystemTools::ConvertToUnixSlashes(exe); - fout << indent << "add_test(\"" << this->Test->GetName() << "\" \"" << exe - << "\""; + fout << indent; + fout << "add_test("; + fout << this->Test->GetName() << " \"" << exe << "\""; for (std::string const& arg : cmMakeRange(command).advance(1)) { // Just double-quote all arguments so they are re-parsed diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f291cbd..6369c1f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2919,6 +2919,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.RemoveFlag("SpectreMitigation"); } + // Remove any target-wide -TC or -TP flag added by the project. + // Such flags are unnecessary and break our model of language selection. + if (langForClCompile == "C" || langForClCompile == "CXX") { + clOptions.RemoveFlag("CompileAs"); + } + this->ClOptions[configName] = std::move(pOptions); return true; } @@ -4138,7 +4144,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) Elem e1(e0, "ItemGroup"); e1.SetHasElements(); for (cmGeneratorTarget const* dt : depends) { - if (dt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (!dt->IsInBuildSystem()) { continue; } // skip fortran targets as they can not be processed by MSBuild diff --git a/Source/cmake.cxx b/Source/cmake.cxx index aa8298f..dcb96f8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2273,7 +2273,7 @@ int cmake::CheckBuildSystem() if (this->ClearBuildSystem) { // Get the generator used for this build system. const char* genName = mf.GetDefinition("CMAKE_DEPENDS_GENERATOR"); - if (!genName || genName[0] == '\0') { + if (!cmNonempty(genName)) { genName = "Unix Makefiles"; } diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 7c66c5c..4600fc5 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -71,7 +71,7 @@ const char* cmDocumentationOptions[][2] = { { "--open <dir>", "Open generated project in the associated application." }, { "-N", "View mode only." }, { "-P <file>", "Process script mode." }, - { "--find-package", "Run in pkg-config like mode." }, + { "--find-package", "Legacy pkg-config like mode. Do not use." }, { "--graphviz=[file]", "Generate graphviz of dependencies, see " "CMakeGraphVizOptions.cmake for more." }, diff --git a/Source/kwsys/CTestConfig.cmake b/Source/kwsys/CTestConfig.cmake index 33ea84c..12347b6 100644 --- a/Source/kwsys/CTestConfig.cmake +++ b/Source/kwsys/CTestConfig.cmake @@ -3,7 +3,9 @@ set(CTEST_PROJECT_NAME "KWSys") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DROP_METHOD "http") +if (NOT CTEST_DROP_METHOD STREQUAL "https") + set(CTEST_DROP_METHOD "http") +endif () set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index 5452f73..c6d4b19 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -27,7 +27,7 @@ #include <cstdio> #include <cstring> namespace KWSYS_NAMESPACE { -#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__APPLE__) // On Windows and Apple, no difference between lower and upper case # define KWSYS_GLOB_CASE_INDEPENDENT #endif diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in index b5a34d5..e8474e2 100644 --- a/Source/kwsys/Glob.hxx.in +++ b/Source/kwsys/Glob.hxx.in @@ -126,8 +126,8 @@ protected: bool RecurseListDirs; private: - Glob(const Glob&); // Not implemented. - void operator=(const Glob&); // Not implemented. + Glob(const Glob&) = delete; + void operator=(const Glob&) = delete; }; } // namespace @KWSYS_NAMESPACE@ diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index cc45529..e1e7721 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -2128,17 +2128,17 @@ static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig, #endif #ifdef SIGABRT case SIGABRT: - KWSYSPE_CASE(Other, "Child aborted"); + KWSYSPE_CASE(Other, "Subprocess aborted"); break; #endif #ifdef SIGKILL case SIGKILL: - KWSYSPE_CASE(Other, "Child killed"); + KWSYSPE_CASE(Other, "Subprocess killed"); break; #endif #ifdef SIGTERM case SIGTERM: - KWSYSPE_CASE(Other, "Child terminated"); + KWSYSPE_CASE(Other, "Subprocess terminated"); break; #endif #ifdef SIGHUP diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index ed1cdc0..9c34a56 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -863,7 +863,7 @@ void SystemInformation::RunMemoryCheck() // Hide implementation details in an anonymous namespace. namespace { // ***************************************************************************** -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__) int LoadLines(FILE* file, std::vector<std::string>& lines) { // Load each line in the given file into a the vector. @@ -893,7 +893,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines) return nRead; } -# if defined(__linux) +# if defined(__linux) || defined(__CYGWIN__) // ***************************************************************************** int LoadLines(const char* fileName, std::vector<std::string>& lines) { @@ -926,7 +926,7 @@ int NameValue(std::vector<std::string> const& lines, std::string const& name, } #endif -#if defined(__linux) +#if defined(__linux) || defined(__CYGWIN__) // **************************************************************************** template <typename T> int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values) @@ -3393,7 +3393,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() pos = buffer.find("processor\t", pos + 1); } -#ifdef __linux +#if defined(__linux) || defined(__CYGWIN__) // Count sockets. std::set<int> PhysicalIDs; std::string idc = this->ExtractValueFromCpuInfoFile(buffer, "physical id"); @@ -3414,8 +3414,8 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() this->NumberOfPhysicalCPU = NumberOfCoresPerSocket * (unsigned int)NumberOfSockets; -#else // __CYGWIN__ - // does not have "physical id" entries, neither "cpu cores" +#else + // For systems which do not have "physical id" entries, neither "cpu cores" // this has to be fixed for hyper-threading. std::string cpucount = this->ExtractValueFromCpuInfoFile(buffer, "cpu count"); @@ -3597,7 +3597,7 @@ long long SystemInformationImplementation::GetHostMemoryTotal() GlobalMemoryStatusEx(&statex); return statex.ullTotalPhys / 1024; # endif -#elif defined(__linux) +#elif defined(__linux) || defined(__CYGWIN__) long long memTotal = 0; int ierr = GetFieldFromFile("/proc/meminfo", "MemTotal:", memTotal); if (ierr) { @@ -3712,6 +3712,16 @@ long long SystemInformationImplementation::GetHostMemoryUsed() GlobalMemoryStatusEx(&statex); return (statex.ullTotalPhys - statex.ullAvailPhys) / 1024; # endif +#elif defined(__CYGWIN__) + const char* names[3] = { "MemTotal:", "MemFree:", nullptr }; + long long values[2] = { 0 }; + int ierr = GetFieldsFromFile("/proc/meminfo", names, values); + if (ierr) { + return ierr; + } + long long& memTotal = values[0]; + long long& memFree = values[1]; + return memTotal - memFree; #elif defined(__linux) // First try to use MemAvailable, but it only works on newer kernels const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr }; @@ -3773,7 +3783,7 @@ long long SystemInformationImplementation::GetProcMemoryUsed() return -2; } return pmc.WorkingSetSize / 1024; -#elif defined(__linux) +#elif defined(__linux) || defined(__CYGWIN__) long long memUsed = 0; int ierr = GetFieldFromFile("/proc/self/status", "VmRSS:", memUsed); if (ierr) { @@ -3850,7 +3860,8 @@ long long SystemInformationImplementation::GetProcessId() #if defined(_WIN32) return GetCurrentProcessId(); #elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \ - defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) + defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ + defined(__CYGWIN__) return getpid(); #else return -1; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 25705ea..6144d9c 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -96,19 +96,12 @@ # if defined(_MSC_VER) && _MSC_VER >= 1800 # define KWSYS_WINDOWS_DEPRECATED_GetVersionEx # endif -#elif defined(__CYGWIN__) -# include <windows.h> -# undef _WIN32 #endif #if !KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H extern char** environ; #endif -#ifdef __CYGWIN__ -# include <sys/cygwin.h> -#endif - // getpwnam doesn't exist on Windows and Cray Xt3/Catamount // same for TIOCGWINSZ #if defined(_WIN32) || defined(__LIBCATAMOUNT__) || \ @@ -1290,15 +1283,7 @@ bool SystemTools::PathExists(const std::string& path) if (path.empty()) { return false; } -#if defined(__CYGWIN__) - // Convert path to native windows path if possible. - char winpath[MAX_PATH]; - if (SystemTools::PathCygwinToWin32(path.c_str(), winpath)) { - return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES); - } - struct stat st; - return lstat(path.c_str(), &st) == 0; -#elif defined(_WIN32) +#if defined(_WIN32) return (GetFileAttributesW(Encoding::ToWindowsExtendedPath(path).c_str()) != INVALID_FILE_ATTRIBUTES); #else @@ -1320,14 +1305,7 @@ bool SystemTools::FileExists(const std::string& filename) if (filename.empty()) { return false; } -#if defined(__CYGWIN__) - // Convert filename to native windows path if possible. - char winpath[MAX_PATH]; - if (SystemTools::PathCygwinToWin32(filename.c_str(), winpath)) { - return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES); - } - return access(filename.c_str(), R_OK) == 0; -#elif defined(_WIN32) +#if defined(_WIN32) DWORD attr = GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { @@ -1433,27 +1411,9 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf) #endif } -#ifdef __CYGWIN__ -bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path) -{ - auto itr = SystemToolsStatics->Cyg2Win32Map.find(path); - if (itr != SystemToolsStatics->Cyg2Win32Map.end()) { - strncpy(win32_path, itr->second.c_str(), MAX_PATH); - } else { - if (cygwin_conv_path(CCP_POSIX_TO_WIN_A, path, win32_path, MAX_PATH) != - 0) { - win32_path[0] = 0; - } - SystemToolsStatics->Cyg2Win32Map.insert( - SystemToolsStatic::StringMap::value_type(path, win32_path)); - } - return win32_path[0] != 0; -} -#endif - bool SystemTools::Touch(const std::string& filename, bool create) { - if (!SystemTools::PathExists(filename)) { + if (!SystemTools::FileExists(filename)) { if (create) { FILE* file = Fopen(filename, "a+b"); if (file) { diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 5dbb726..74dc176 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -331,15 +331,6 @@ public: static int Stat(const char* path, Stat_t* buf); static int Stat(const std::string& path, Stat_t* buf); -/** - * Converts Cygwin path to Win32 path. Uses dictionary container for - * caching and calls to cygwin_conv_to_win32_path from Cygwin dll - * for actual translation. Returns true on success, else false. - */ -#ifdef __CYGWIN__ - static bool PathCygwinToWin32(const char* path, char* win32_path); -#endif - /** * Return file length */ diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c index 0c658f5..eed770c 100644 --- a/Source/kwsys/testProcess.c +++ b/Source/kwsys/testProcess.c @@ -450,24 +450,25 @@ static int runChild2(kwsysProcess* kp, const char* cmd[], int state, printf("The process is still executing.\n"); break; case kwsysProcess_State_Expired: - printf("Child was killed when timeout expired.\n"); + printf("Subprocess was killed when timeout expired.\n"); break; case kwsysProcess_State_Exited: - printf("Child exited with value = %d\n", kwsysProcess_GetExitValue(kp)); + printf("Subprocess exited with value = %d\n", + kwsysProcess_GetExitValue(kp)); result = ((exception != kwsysProcess_GetExitException(kp)) || (value != kwsysProcess_GetExitValue(kp))); break; case kwsysProcess_State_Killed: - printf("Child was killed by parent.\n"); + printf("Subprocess was killed by parent.\n"); break; case kwsysProcess_State_Exception: - printf("Child terminated abnormally: %s\n", + printf("Subprocess terminated abnormally: %s\n", kwsysProcess_GetExceptionString(kp)); result = ((exception != kwsysProcess_GetExitException(kp)) || (value != kwsysProcess_GetExitValue(kp))); break; case kwsysProcess_State_Disowned: - printf("Child was disowned.\n"); + printf("Subprocess was disowned.\n"); break; case kwsysProcess_State_Error: printf("Error in administrating child process: [%s]\n", diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 1d34614..cfa420d 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -422,6 +422,28 @@ static bool CheckFileOperations() res = false; } +#if !defined(_WIN32) + std::string const testBadSymlink(testNewDir + "/badSymlink.txt"); + std::string const testBadSymlinkTgt(testNewDir + "/missing/symlinkTgt.txt"); + if (!kwsys::SystemTools::CreateSymlink(testBadSymlinkTgt, testBadSymlink)) { + std::cerr << "Problem with CreateSymlink for: " << testBadSymlink << " -> " + << testBadSymlinkTgt << std::endl; + res = false; + } + + if (!kwsys::SystemTools::Touch(testBadSymlink, false)) { + std::cerr << "Problem with Touch (no create) for: " << testBadSymlink + << std::endl; + res = false; + } +#endif + + if (!kwsys::SystemTools::Touch(testNewDir, false)) { + std::cerr << "Problem with Touch (no create) for: " << testNewDir + << std::endl; + res = false; + } + kwsys::SystemTools::Touch(testNewFile, true); if (!kwsys::SystemTools::RemoveADirectory(testNewDir)) { std::cerr << "Problem with RemoveADirectory for: " << testNewDir diff --git a/Tests/CMakeLib/testCMExtMemory.cxx b/Tests/CMakeLib/testCMExtMemory.cxx index 6663c17..2aeaf7f 100644 --- a/Tests/CMakeLib/testCMExtMemory.cxx +++ b/Tests/CMakeLib/testCMExtMemory.cxx @@ -13,7 +13,7 @@ public: class Derived : public Base { public: - ~Derived() = default; + ~Derived() override = default; void method() {} }; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 19aa4c4..4a774dd 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2906,7 +2906,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH PASS_REGULAR_EXPRESSION "Failed") else() set_tests_properties(CTestTestCrash PROPERTIES - PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Child aborted)") + PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Subprocess aborted)") endif() configure_file( diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index e32d693..348e6d0 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -35,7 +35,7 @@ AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") set_tests_properties(CMake.FileDownload PROPERTIES PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" - FAIL_REGULAR_EXPRESSION "Unexpected status" + FAIL_REGULAR_EXPRESSION "Unexpected status|incorrectly interpreted" ) AddCMakeTest(FileDownloadBadHash "") set_property(TEST CMake.FileDownloadBadHash PROPERTY diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 76c0000..69d9a14 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -163,3 +163,16 @@ __reportIfWrongStatus("${status}" 0) if(NOT EXISTS file12.png) message(SEND_ERROR "file12.png not downloaded: ${status}") endif() + +message(STATUS "FileDownload:13") +file(DOWNLOAD + ${url} + TIMEOUT ${timeout} + STATUS status + ) +__reportIfWrongStatus("${status}" 0) +if(EXISTS TIMEOUT) + file(REMOVE TIMEOUT) + message(SEND_ERROR "TIMEOUT argument was incorrectly interpreted as a filename") +endif() +message(STATUS "${status}") diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake index 145f28a..fc3c28a 100644 --- a/Tests/CMakeTests/FileTestScript.cmake +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -10,7 +10,7 @@ elseif(testname STREQUAL different_not_enough_args) # fail file(DIFFERENT ffff) elseif(testname STREQUAL download_not_enough_args) # fail - file(DOWNLOAD ffff) + file(DOWNLOAD) elseif(testname STREQUAL read_not_enough_args) # fail file(READ ffff) @@ -181,7 +181,7 @@ elseif(testname STREQUAL to_native_path) # pass message("v='${v}'") elseif(testname STREQUAL download_wrong_number_of_args) # fail - file(DOWNLOAD zzzz://bogus/ffff) + file(DOWNLOAD) elseif(testname STREQUAL download_file_with_no_path) # pass file(DOWNLOAD zzzz://bogus/ffff ffff) diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index a19a9ae..dfa5ea0 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -29,6 +29,7 @@ ADD_AUTOGEN_TEST(UicInterface QtAutoUicInterface) ADD_AUTOGEN_TEST(UicNoGui uicNoGui) ADD_AUTOGEN_TEST(UicOnly uicOnly) ADD_AUTOGEN_TEST(UicSkipSource) +ADD_AUTOGEN_TEST(UnityMocSource) if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) diff --git a/Tests/QtAutogen/UnityMocSource/CMakeLists.txt b/Tests/QtAutogen/UnityMocSource/CMakeLists.txt new file mode 100644 index 0000000..d472319 --- /dev/null +++ b/Tests/QtAutogen/UnityMocSource/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.16) +project(UnityMocSource) +include("../AutogenGuiTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CMAKE_UNITY_BUILD ON) + +add_library(library library.cpp) +target_link_libraries(library ${QT_LIBRARIES}) + +add_executable(unityMocSource main.cpp) +target_link_libraries(unityMocSource PRIVATE library) diff --git a/Tests/QtAutogen/UnityMocSource/library.cpp b/Tests/QtAutogen/UnityMocSource/library.cpp new file mode 100644 index 0000000..1e30d4b --- /dev/null +++ b/Tests/QtAutogen/UnityMocSource/library.cpp @@ -0,0 +1,6 @@ +#include <QObject> +class Test : public QObject +{ + Q_OBJECT +}; +#include "library.moc" diff --git a/Tests/QtAutogen/UnityMocSource/main.cpp b/Tests/QtAutogen/UnityMocSource/main.cpp new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/QtAutogen/UnityMocSource/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/AndroidTestUtilities/check.cmake b/Tests/RunCMake/AndroidTestUtilities/check.cmake index c24a3cd..ccd4d74 100644 --- a/Tests/RunCMake/AndroidTestUtilities/check.cmake +++ b/Tests/RunCMake/AndroidTestUtilities/check.cmake @@ -13,7 +13,7 @@ function(compare_build_to_expected) endfunction() function(check_for_setup_test) - file(STRINGS "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" output_var REGEX "add_test\\(\"setup_test\".*") + file(STRINGS "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" output_var REGEX "add_test\\(setup_test.*") if(NOT output_var) set(RunCMake_TEST_FAILED "Could not find the test: setup_test" PARENT_SCOPE) endif() diff --git a/Tests/RunCMake/BundleUtilities/ExecutableScripts.cmake b/Tests/RunCMake/BundleUtilities/ExecutableScripts.cmake new file mode 100644 index 0000000..78a9b66 --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/ExecutableScripts.cmake @@ -0,0 +1,18 @@ +include(BundleUtilities) + +set(BU_CHMOD_BUNDLE_ITEMS ON) + +function(check_script script) + fixup_bundle_item(${script} ${script} "" "") +endfunction() + +# Should not throw any errors +# Shell script +set(script_sh_EMBEDDED_ITEM ${CMAKE_CURRENT_LIST_DIR}/test.app/script.sh) +check_script(${CMAKE_CURRENT_LIST_DIR}/test.app/script.sh) +# Batch script +set(script_bat_EMBEDDED_ITEM ${CMAKE_CURRENT_LIST_DIR}/test.app/script.bat) +check_script(${CMAKE_CURRENT_LIST_DIR}/test.app/script.bat) +# Shell script without extension +set(script_EMBEDDED_ITEM ${CMAKE_CURRENT_LIST_DIR}/test.app/script) +check_script(${CMAKE_CURRENT_LIST_DIR}/test.app/script) diff --git a/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake b/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake index 14aaff1..df28102 100644 --- a/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake +++ b/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake @@ -9,3 +9,4 @@ run_cmake(CMP0080-WARN) run_cmake_command(CMP0080-COMMAND-OLD ${CMAKE_COMMAND} -DCMP0080_VALUE:STRING=OLD -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake) run_cmake_command(CMP0080-COMMAND-NEW ${CMAKE_COMMAND} -DCMP0080_VALUE:STRING=NEW -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake) run_cmake_command(CMP0080-COMMAND-WARN ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake) +run_cmake_command(ExecutableScripts ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ExecutableScripts.cmake) diff --git a/Tests/RunCMake/BundleUtilities/test.app/script b/Tests/RunCMake/BundleUtilities/test.app/script new file mode 100755 index 0000000..23bf47c --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/test.app/script @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Hello World" diff --git a/Tests/RunCMake/BundleUtilities/test.app/script.bat b/Tests/RunCMake/BundleUtilities/test.app/script.bat new file mode 100755 index 0000000..dbb0ec2 --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/test.app/script.bat @@ -0,0 +1,3 @@ +@echo off + +echo "Hello world" diff --git a/Tests/RunCMake/BundleUtilities/test.app/script.sh b/Tests/RunCMake/BundleUtilities/test.app/script.sh new file mode 100755 index 0000000..23bf47c --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/test.app/script.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Hello World" diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 5c35040..e08b30a 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -142,6 +142,9 @@ if(CMAKE_GENERATOR MATCHES "Ninja") if(CMAKE_Fortran_COMPILER) list(APPEND Ninja_ARGS -DTEST_Fortran=1) endif() + if(CMake_TEST_Qt5 AND Qt5Core_FOUND) + list(APPEND Ninja_ARGS -DCMake_TEST_Qt5=1 -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION}) + endif() add_RunCMake_test(Ninja) set(NinjaMultiConfig_ARGS -DCYGWIN=${CYGWIN} @@ -289,7 +292,6 @@ add_RunCMake_test(add_dependencies) add_RunCMake_test(add_executable) add_RunCMake_test(add_library) add_RunCMake_test(add_subdirectory) -add_RunCMake_test(add_test) add_RunCMake_test(build_command) add_executable(exit_code exit_code.c) set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake index 3cbbc07..588b77b 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake @@ -7,22 +7,22 @@ endif() set(error_details "There is a problem with generated test file: ${testfile}") -if(testfile_contents MATCHES "add_test[(][\"]DoesNotUseEmulator[\"] [^\n]+pseudo_emulator[^\n]+\n") +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n") message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") endif() -if(NOT testfile_contents MATCHES "add_test[(][\"]UsesEmulator[\"] [^\n]+pseudo_emulator[^\n]+\n") +if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator [^\n]+pseudo_emulator[^\n]+\n") message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}") endif() -if(testfile_contents MATCHES "add_test[(][\"]DoesNotUseEmulatorWithGenex[\"] [^\n]+pseudo_emulator[^\n]+\n") +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithGenex [^\n]+pseudo_emulator[^\n]+\n") message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") endif() -if(NOT testfile_contents MATCHES "add_test[(][\"]UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex[\"] [^\n]+pseudo_emulator[^\n]+\n") +if(NOT testfile_contents MATCHES "add_test[(]UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n") message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}") endif() -if(testfile_contents MATCHES "add_test[(][\"]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex[\"] [^\n]+pseudo_emulator[^\n]+\n") +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n") message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") endif() diff --git a/Tests/RunCMake/ExcludeFromAll/RunCMakeTest.cmake b/Tests/RunCMake/ExcludeFromAll/RunCMakeTest.cmake index 25201e4..2b4fc89 100644 --- a/Tests/RunCMake/ExcludeFromAll/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExcludeFromAll/RunCMakeTest.cmake @@ -9,7 +9,7 @@ function(run_single_config_test label config exclude_from_all_value expectation) -DCMAKE_BUILD_TYPE=${config} -DTOOL_EXCLUDE_FROM_ALL=${exclude_from_all_value}) set(RunCMake_TEST_NO_CLEAN 1) - include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) + include(${RunCMake_TEST_BINARY_DIR}/target_files_${config}.cmake) run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config ${config}) endfunction() diff --git a/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-stderr.txt b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-stderr.txt index eee5278..6dc785f 100644 --- a/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-stderr.txt +++ b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-stderr.txt @@ -1,3 +1,3 @@ CMake Error in CMakeLists.txt: - The EXCLUDED_FROM_ALL property of target "release_only_tool" varies by + The EXCLUDE_FROM_ALL property of target "release_only_tool" varies by configuration. This is not supported by the "[^"]+" diff --git a/Tests/RunCMake/ExcludeFromAll/main.c b/Tests/RunCMake/ExcludeFromAll/main.c index 5047a34..f8b643a 100644 --- a/Tests/RunCMake/ExcludeFromAll/main.c +++ b/Tests/RunCMake/ExcludeFromAll/main.c @@ -1,3 +1,4 @@ int main() { + return 0; } diff --git a/Tests/RunCMake/ExcludeFromAll/single-config.cmake b/Tests/RunCMake/ExcludeFromAll/single-config.cmake index 71a9f06..aa49c21 100644 --- a/Tests/RunCMake/ExcludeFromAll/single-config.cmake +++ b/Tests/RunCMake/ExcludeFromAll/single-config.cmake @@ -2,10 +2,6 @@ enable_language(C) add_executable(tool main.c) set_property(TARGET tool PROPERTY EXCLUDE_FROM_ALL "${TOOL_EXCLUDE_FROM_ALL}") -include(../NinjaMultiConfig/Common.cmake) -set(orig_CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES}) -if("${CMAKE_CONFIGURATION_TYPES}" STREQUAL "") - set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE}) -endif() -generate_output_files(tool) -set(CMAKE_CONFIGURATION_TYPES ${orig_CMAKE_CONFIGURATION_TYPES}) +file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/target_files_$<CONFIG>.cmake" CONTENT [[ +set(TARGET_FILE_tool_$<CONFIG> [==[$<TARGET_FILE:tool>]==]) +]]) diff --git a/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake new file mode 100644 index 0000000..d69a119 --- /dev/null +++ b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) + +find_package(Qt5Core REQUIRED) + +set(CMAKE_AUTOMOC ON) + +add_library(simple_lib SHARED simple_lib.cpp) +add_executable(app_with_qt app.cpp app_qt.cpp) +target_link_libraries(app_with_qt PRIVATE simple_lib Qt5::Core) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 8f9c263..d43023b 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -138,6 +138,7 @@ ${ninja_stderr} message(FATAL_ERROR "top ninja build failed exited with status ${ninja_result}") endif() + set(ninja_stdout "${ninja_stdout}" PARENT_SCOPE) endfunction(run_ninja) function (run_LooseObjectDepends) @@ -322,3 +323,23 @@ function (run_ChangeBuildType) run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err) endfunction() run_ChangeBuildType() + +function(run_Qt5AutoMocDeps) + if(CMake_TEST_Qt5 AND CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5AutoMocDeps-build) + run_cmake(Qt5AutoMocDeps) + unset(RunCMake_TEST_OPTIONS) + # Build the project. + run_ninja("${RunCMake_TEST_BINARY_DIR}") + # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC + # for app_with_qt target. + touch("${RunCMake_SOURCE_DIR}/simple_lib.cpp") + # Build and assert that AUTOMOC was not run for app_with_qt. + run_ninja("${RunCMake_TEST_BINARY_DIR}") + if(ninja_stdout MATCHES "Automatic MOC for target app_with_qt") + message(FATAL_ERROR + "AUTOMOC should not have executed for 'app_with_qt' target:\nstdout:\n${ninja_stdout}") + endif() + endif() +endfunction() +run_Qt5AutoMocDeps() diff --git a/Tests/RunCMake/Ninja/app.cpp b/Tests/RunCMake/Ninja/app.cpp new file mode 100644 index 0000000..57380e4 --- /dev/null +++ b/Tests/RunCMake/Ninja/app.cpp @@ -0,0 +1,6 @@ +int main(int argc, char* argv[]) +{ + (void)argc; + (void)argv; + return 0; +} diff --git a/Tests/RunCMake/Ninja/app_qt.cpp b/Tests/RunCMake/Ninja/app_qt.cpp new file mode 100644 index 0000000..302c672 --- /dev/null +++ b/Tests/RunCMake/Ninja/app_qt.cpp @@ -0,0 +1,11 @@ +#include <QObject> + +class Mango : public QObject +{ + Q_OBJECT +public: +Q_SIGNALS: + void eatFruit(); +}; + +#include "app_qt.moc" diff --git a/Tests/RunCMake/Ninja/simple_lib.cpp b/Tests/RunCMake/Ninja/simple_lib.cpp new file mode 100644 index 0000000..cf8d689 --- /dev/null +++ b/Tests/RunCMake/Ninja/simple_lib.cpp @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void dummy_symbol() +{ +} diff --git a/Tests/RunCMake/add_test/CMakeLists.txt.in b/Tests/RunCMake/add_test/CMakeLists.txt.in deleted file mode 100644 index 495240d..0000000 --- a/Tests/RunCMake/add_test/CMakeLists.txt.in +++ /dev/null @@ -1,27 +0,0 @@ -if (NOT DEFINED RUN_AS_SCRIPT) - - cmake_minimum_required(VERSION 3.7) - project(@CASE_NAME@ NONE) - include(CTest) - - # Two fallback tests for set_tests_properties. - add_test(NAME PrefixTest COMMAND "${CMAKE_COMMAND}" --version) - add_test(NAME SuffixTest COMMAND "${CMAKE_COMMAND}" --version) - - add_test( - NAME @CASE_CMAKELISTS_NAME_1@ - COMMAND "${CMAKE_COMMAND}" -D RUN_AS_SCRIPT=1 -P "${CMAKE_CURRENT_LIST_FILE}" - ) - set_tests_properties( - @CASE_CMAKELISTS_NAME_2@ - PROPERTIES - ENVIRONMENT CMAKE_add_test_ENVVAR=1 - ) - -else() - - if(NOT DEFINED ENV{CMAKE_add_test_ENVVAR}) - message(FATAL_ERROR "Setting property on test did not succeed!") - endif() - -endif() diff --git a/Tests/RunCMake/add_test/NameContainsBracketArgument1-stdout.txt b/Tests/RunCMake/add_test/NameContainsBracketArgument1-stdout.txt deleted file mode 100644 index 00865d0..0000000 --- a/Tests/RunCMake/add_test/NameContainsBracketArgument1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \[=\[BracketArgument;SuffixTest\]=\] \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/NameContainsBracketArgument2-stdout.txt b/Tests/RunCMake/add_test/NameContainsBracketArgument2-stdout.txt deleted file mode 100644 index a744beb..0000000 --- a/Tests/RunCMake/add_test/NameContainsBracketArgument2-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: BracketArgument;SuffixTest \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/NameContainsBracketArgument3-result.txt b/Tests/RunCMake/add_test/NameContainsBracketArgument3-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsBracketArgument3-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsBracketArgument3-stderr.txt b/Tests/RunCMake/add_test/NameContainsBracketArgument3-stderr.txt deleted file mode 100644 index 32c2112..0000000 --- a/Tests/RunCMake/add_test/NameContainsBracketArgument3-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -Error\(s\) when configuring the project -No tests were found!!! diff --git a/Tests/RunCMake/add_test/NameContainsBracketArgument4-result.txt b/Tests/RunCMake/add_test/NameContainsBracketArgument4-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsBracketArgument4-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsBracketArgument4-stderr.txt b/Tests/RunCMake/add_test/NameContainsBracketArgument4-stderr.txt deleted file mode 100644 index 32c2112..0000000 --- a/Tests/RunCMake/add_test/NameContainsBracketArgument4-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -Error\(s\) when configuring the project -No tests were found!!! diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote1-result.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote1-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote1-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote1-stderr.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote1-stderr.txt deleted file mode 100644 index 0661945..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote1-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -Unable to find executable: SuffixTest diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote1-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote1-stdout.txt deleted file mode 100644 index 4875409..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: EscapedQuote \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote2-result.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote2-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote2-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote2-stderr.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote2-stderr.txt deleted file mode 100644 index 0661945..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote2-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -Unable to find executable: SuffixTest diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote2-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote2-stdout.txt deleted file mode 100644 index 4875409..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote2-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: EscapedQuote \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote3-result.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote3-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote3-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote3-stderr.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote3-stderr.txt deleted file mode 100644 index 0661945..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote3-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -Unable to find executable: SuffixTest diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote3-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote3-stdout.txt deleted file mode 100644 index 4875409..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote3-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: EscapedQuote \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote4-result.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote4-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote4-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote4-stderr.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote4-stderr.txt deleted file mode 100644 index 0661945..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote4-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -Unable to find executable: SuffixTest diff --git a/Tests/RunCMake/add_test/NameContainsEscapedQuote4-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedQuote4-stdout.txt deleted file mode 100644 index 4875409..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedQuote4-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: EscapedQuote \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars1-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars1-stdout.txt deleted file mode 100644 index 80435b6..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \(\) # \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars2-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars2-stdout.txt deleted file mode 100644 index 80435b6..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars2-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \(\) # \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars3-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars3-stdout.txt deleted file mode 100644 index 80435b6..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars3-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \(\) # \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars4-stdout.txt b/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars4-stdout.txt deleted file mode 100644 index 80435b6..0000000 --- a/Tests/RunCMake/add_test/NameContainsEscapedSpecialChars4-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \(\) # \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax1-stdout.txt b/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax1-stdout.txt deleted file mode 100644 index 172ff99..0000000 --- a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \$<BOOL:0> \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax2-stdout.txt b/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax2-stdout.txt deleted file mode 100644 index 172ff99..0000000 --- a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax2-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \$<BOOL:0> \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax3-stdout.txt b/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax3-stdout.txt deleted file mode 100644 index 172ff99..0000000 --- a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax3-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \$<BOOL:0> \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax4-stdout.txt b/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax4-stdout.txt deleted file mode 100644 index 172ff99..0000000 --- a/Tests/RunCMake/add_test/NameContainsGeneratorExpressionSyntax4-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: \$<BOOL:0> \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars1-stdout.txt b/Tests/RunCMake/add_test/NameContainsOtherSpecialChars1-stdout.txt deleted file mode 100644 index 83e3f86..0000000 --- a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: !§\$%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars2-stdout.txt b/Tests/RunCMake/add_test/NameContainsOtherSpecialChars2-stdout.txt deleted file mode 100644 index 83e3f86..0000000 --- a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars2-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: !§\$%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars3-stdout.txt b/Tests/RunCMake/add_test/NameContainsOtherSpecialChars3-stdout.txt deleted file mode 100644 index 83e3f86..0000000 --- a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars3-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: !§\$%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars4-stdout.txt b/Tests/RunCMake/add_test/NameContainsOtherSpecialChars4-stdout.txt deleted file mode 100644 index 83e3f86..0000000 --- a/Tests/RunCMake/add_test/NameContainsOtherSpecialChars4-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: !§\$%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsSemicolon1-stdout.txt b/Tests/RunCMake/add_test/NameContainsSemicolon1-stdout.txt deleted file mode 100644 index 0fbf486..0000000 --- a/Tests/RunCMake/add_test/NameContainsSemicolon1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: PrefixTest;SuffixTest \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsSemicolon2-result.txt b/Tests/RunCMake/add_test/NameContainsSemicolon2-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsSemicolon2-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsSemicolon2-stderr.txt b/Tests/RunCMake/add_test/NameContainsSemicolon2-stderr.txt deleted file mode 100644 index 32c2112..0000000 --- a/Tests/RunCMake/add_test/NameContainsSemicolon2-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -Error\(s\) when configuring the project -No tests were found!!! diff --git a/Tests/RunCMake/add_test/NameContainsSemicolon3-stdout.txt b/Tests/RunCMake/add_test/NameContainsSemicolon3-stdout.txt deleted file mode 100644 index c5ab1d8..0000000 --- a/Tests/RunCMake/add_test/NameContainsSemicolon3-stdout.txt +++ /dev/null @@ -1,3 +0,0 @@ -3/3 Test #3: PrefixTest;SuffixTest \.+\*\*\*Failed.* -CMake Error at .+/CMakeLists.txt:[0-9]+ \(message\): -[ ]*Setting property on test did not succeed! diff --git a/Tests/RunCMake/add_test/NameContainsSemicolon4-result.txt b/Tests/RunCMake/add_test/NameContainsSemicolon4-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsSemicolon4-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsSemicolon4-stderr.txt b/Tests/RunCMake/add_test/NameContainsSemicolon4-stderr.txt deleted file mode 100644 index 32c2112..0000000 --- a/Tests/RunCMake/add_test/NameContainsSemicolon4-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -Error\(s\) when configuring the project -No tests were found!!! diff --git a/Tests/RunCMake/add_test/NameContainsSpaces1-stdout.txt b/Tests/RunCMake/add_test/NameContainsSpaces1-stdout.txt deleted file mode 100644 index a255fb1..0000000 --- a/Tests/RunCMake/add_test/NameContainsSpaces1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: PrefixTest SuffixTest \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsSpaces2-result.txt b/Tests/RunCMake/add_test/NameContainsSpaces2-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsSpaces2-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsSpaces2-stderr.txt b/Tests/RunCMake/add_test/NameContainsSpaces2-stderr.txt deleted file mode 100644 index 32c2112..0000000 --- a/Tests/RunCMake/add_test/NameContainsSpaces2-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -Error\(s\) when configuring the project -No tests were found!!! diff --git a/Tests/RunCMake/add_test/NameContainsSpaces3-stdout.txt b/Tests/RunCMake/add_test/NameContainsSpaces3-stdout.txt deleted file mode 100644 index 3d42b0b..0000000 --- a/Tests/RunCMake/add_test/NameContainsSpaces3-stdout.txt +++ /dev/null @@ -1,3 +0,0 @@ -3/3 Test #3: PrefixTest SuffixTest \.+\*\*\*Failed.* -CMake Error at .+/CMakeLists.txt:[0-9]+ \(message\): -[ ]*Setting property on test did not succeed! diff --git a/Tests/RunCMake/add_test/NameContainsSpaces4-result.txt b/Tests/RunCMake/add_test/NameContainsSpaces4-result.txt deleted file mode 100644 index b57e2de..0000000 --- a/Tests/RunCMake/add_test/NameContainsSpaces4-result.txt +++ /dev/null @@ -1 +0,0 @@ -(-1|255) diff --git a/Tests/RunCMake/add_test/NameContainsSpaces4-stderr.txt b/Tests/RunCMake/add_test/NameContainsSpaces4-stderr.txt deleted file mode 100644 index 32c2112..0000000 --- a/Tests/RunCMake/add_test/NameContainsSpaces4-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -Error\(s\) when configuring the project -No tests were found!!! diff --git a/Tests/RunCMake/add_test/NameContainsValidSpecialChars1-stdout.txt b/Tests/RunCMake/add_test/NameContainsValidSpecialChars1-stdout.txt deleted file mode 100644 index ae1a0b1..0000000 --- a/Tests/RunCMake/add_test/NameContainsValidSpecialChars1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsValidSpecialChars2-stdout.txt b/Tests/RunCMake/add_test/NameContainsValidSpecialChars2-stdout.txt deleted file mode 100644 index ae1a0b1..0000000 --- a/Tests/RunCMake/add_test/NameContainsValidSpecialChars2-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsValidSpecialChars3-stdout.txt b/Tests/RunCMake/add_test/NameContainsValidSpecialChars3-stdout.txt deleted file mode 100644 index ae1a0b1..0000000 --- a/Tests/RunCMake/add_test/NameContainsValidSpecialChars3-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameContainsValidSpecialChars4-stdout.txt b/Tests/RunCMake/add_test/NameContainsValidSpecialChars4-stdout.txt deleted file mode 100644 index ae1a0b1..0000000 --- a/Tests/RunCMake/add_test/NameContainsValidSpecialChars4-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameIsAlphaNumeric1-stdout.txt b/Tests/RunCMake/add_test/NameIsAlphaNumeric1-stdout.txt deleted file mode 100644 index ed939bf..0000000 --- a/Tests/RunCMake/add_test/NameIsAlphaNumeric1-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameIsAlphaNumeric2-stdout.txt b/Tests/RunCMake/add_test/NameIsAlphaNumeric2-stdout.txt deleted file mode 100644 index ed939bf..0000000 --- a/Tests/RunCMake/add_test/NameIsAlphaNumeric2-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameIsAlphaNumeric3-stdout.txt b/Tests/RunCMake/add_test/NameIsAlphaNumeric3-stdout.txt deleted file mode 100644 index ed939bf..0000000 --- a/Tests/RunCMake/add_test/NameIsAlphaNumeric3-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/NameIsAlphaNumeric4-stdout.txt b/Tests/RunCMake/add_test/NameIsAlphaNumeric4-stdout.txt deleted file mode 100644 index ed939bf..0000000 --- a/Tests/RunCMake/add_test/NameIsAlphaNumeric4-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/RunCMakeTest.cmake b/Tests/RunCMake/add_test/RunCMakeTest.cmake deleted file mode 100644 index 6e9edda..0000000 --- a/Tests/RunCMake/add_test/RunCMakeTest.cmake +++ /dev/null @@ -1,263 +0,0 @@ -include(RunCTest) - -set(ENV{CTEST_OUTPUT_ON_FAILURE} 1) - -function(run_NameIsAlphaNumeric1_test) - set(CASE_CMAKELISTS_NAME_1 [==[ abcdefghijklmnopqrstuvwxyz0123456789 ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ abcdefghijklmnopqrstuvwxyz0123456789 ]==]) - run_ctest(NameIsAlphaNumeric1) -endfunction() -run_NameIsAlphaNumeric1_test() - -function(run_NameIsAlphaNumeric2_test) - set(CASE_CMAKELISTS_NAME_1 [==["abcdefghijklmnopqrstuvwxyz0123456789"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["abcdefghijklmnopqrstuvwxyz0123456789"]==]) - run_ctest(NameIsAlphaNumeric2) -endfunction() -run_NameIsAlphaNumeric2_test() - -function(run_NameIsAlphaNumeric3_test) - set(CASE_CMAKELISTS_NAME_1 [==["abcdefghijklmnopqrstuvwxyz0123456789"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ abcdefghijklmnopqrstuvwxyz0123456789 ]==]) - run_ctest(NameIsAlphaNumeric3) -endfunction() -run_NameIsAlphaNumeric3_test() - -function(run_NameIsAlphaNumeric4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ abcdefghijklmnopqrstuvwxyz0123456789 ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["abcdefghijklmnopqrstuvwxyz0123456789"]==]) - run_ctest(NameIsAlphaNumeric4) -endfunction() -run_NameIsAlphaNumeric4_test() - - -function(run_NameContainsValidSpecialChars1_test) - set(CASE_CMAKELISTS_NAME_1 [==[ abc_.+-012 ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ abc_.+-012 ]==]) - run_ctest(NameContainsValidSpecialChars1) -endfunction() -run_NameContainsValidSpecialChars1_test() - -function(run_NameContainsValidSpecialChars2_test) - set(CASE_CMAKELISTS_NAME_1 [==["abc_.+-012"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["abc_.+-012"]==]) - run_ctest(NameContainsValidSpecialChars2) -endfunction() -run_NameContainsValidSpecialChars2_test() - -function(run_NameContainsValidSpecialChars3_test) - set(CASE_CMAKELISTS_NAME_1 [==["abc_.+-012"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ abc_.+-012 ]==]) - run_ctest(NameContainsValidSpecialChars3) -endfunction() -run_NameContainsValidSpecialChars3_test() - -function(run_NameContainsValidSpecialChars4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ abc_.+-012 ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["abc_.+-012"]==]) - run_ctest(NameContainsValidSpecialChars4) -endfunction() -run_NameContainsValidSpecialChars4_test() - - -function(run_NameContainsOtherSpecialChars1_test) - set(CASE_CMAKELISTS_NAME_1 [==[ !§$%&/ü:*😤~ ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ !§$%&/ü:*😤~ ]==]) - run_ctest(NameContainsOtherSpecialChars1) -endfunction() -run_NameContainsOtherSpecialChars1_test() - -function(run_NameContainsOtherSpecialChars2_test) - set(CASE_CMAKELISTS_NAME_1 [==["!§$%&/ü:*😤~"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["!§$%&/ü:*😤~"]==]) - run_ctest(NameContainsOtherSpecialChars2) -endfunction() -run_NameContainsOtherSpecialChars2_test() - -function(run_NameContainsOtherSpecialChars3_test) - set(CASE_CMAKELISTS_NAME_1 [==["!§$%&/ü:*😤~"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ !§$%&/ü:*😤~ ]==]) - run_ctest(NameContainsOtherSpecialChars3) -endfunction() -run_NameContainsOtherSpecialChars3_test() - -function(run_NameContainsOtherSpecialChars4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ !§$%&/ü:*😤~ ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["!§$%&/ü:*😤~"]==]) - run_ctest(NameContainsOtherSpecialChars4) -endfunction() -run_NameContainsOtherSpecialChars4_test() - - -function(run_NameContainsEscapedSpecialChars1_test) - set(CASE_CMAKELISTS_NAME_1 [==[ \(\)\ \# ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ \(\)\ \# ]==]) - run_ctest(NameContainsEscapedSpecialChars1) -endfunction() -run_NameContainsEscapedSpecialChars1_test() - -function(run_NameContainsEscapedSpecialChars2_test) - set(CASE_CMAKELISTS_NAME_1 [==["\(\)\ \#"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["\(\)\ \#"]==]) - run_ctest(NameContainsEscapedSpecialChars2) -endfunction() -run_NameContainsEscapedSpecialChars2_test() - -function(run_NameContainsEscapedSpecialChars3_test) - set(CASE_CMAKELISTS_NAME_1 [==["\(\)\ \#"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ \(\)\ \# ]==]) - run_ctest(NameContainsEscapedSpecialChars3) -endfunction() -run_NameContainsEscapedSpecialChars3_test() - -function(run_NameContainsEscapedSpecialChars4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ \(\)\ \# ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["\(\)\ \#"]==]) - run_ctest(NameContainsEscapedSpecialChars4) -endfunction() -run_NameContainsEscapedSpecialChars4_test() - - -function(run_NameContainsGeneratorExpressionSyntax1_test) - set(CASE_CMAKELISTS_NAME_1 [==[ $<BOOL:0> ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ $<BOOL:0> ]==]) - run_ctest(NameContainsGeneratorExpressionSyntax1) -endfunction() -run_NameContainsGeneratorExpressionSyntax1_test() - -function(run_NameContainsGeneratorExpressionSyntax2_test) - set(CASE_CMAKELISTS_NAME_1 [==["$<BOOL:0>"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["$<BOOL:0>"]==]) - run_ctest(NameContainsGeneratorExpressionSyntax2) -endfunction() -run_NameContainsGeneratorExpressionSyntax2_test() - -function(run_NameContainsGeneratorExpressionSyntax3_test) - set(CASE_CMAKELISTS_NAME_1 [==["$<BOOL:0>"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ $<BOOL:0> ]==]) - run_ctest(NameContainsGeneratorExpressionSyntax3) -endfunction() -run_NameContainsGeneratorExpressionSyntax3_test() - -function(run_NameContainsGeneratorExpressionSyntax4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ $<BOOL:0> ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["$<BOOL:0>"]==]) - run_ctest(NameContainsGeneratorExpressionSyntax4) -endfunction() -run_NameContainsGeneratorExpressionSyntax4_test() - - -function(run_NameContainsSpaces1_test) - set(CASE_CMAKELISTS_NAME_1 [==["PrefixTest SuffixTest"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["PrefixTest SuffixTest"]==]) - run_ctest(NameContainsSpaces1) -endfunction() -run_NameContainsSpaces1_test() - -function(run_NameContainsSpaces2_test) - set(CASE_CMAKELISTS_NAME_1 [==[ PrefixTest SuffixTest ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ PrefixTest SuffixTest ]==]) - run_ctest(NameContainsSpaces2) -endfunction() -run_NameContainsSpaces2_test() - -function(run_NameContainsSpaces3_test) - set(CASE_CMAKELISTS_NAME_1 [==["PrefixTest SuffixTest"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ PrefixTest SuffixTest ]==]) - run_ctest(NameContainsSpaces3) -endfunction() -run_NameContainsSpaces3_test() - -function(run_NameContainsSpaces4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ PrefixTest SuffixTest ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["PrefixTest SuffixTest"]==]) - run_ctest(NameContainsSpaces4) -endfunction() -run_NameContainsSpaces4_test() - - -function(run_NameContainsSemicolon1_test) - set(CASE_CMAKELISTS_NAME_1 [==["PrefixTest;SuffixTest"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["PrefixTest;SuffixTest"]==]) - run_ctest(NameContainsSemicolon1) -endfunction() -run_NameContainsSemicolon1_test() - -function(run_NameContainsSemicolon2_test) - set(CASE_CMAKELISTS_NAME_1 [==[ PrefixTest;SuffixTest ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ PrefixTest;SuffixTest ]==]) - run_ctest(NameContainsSemicolon2) -endfunction() -run_NameContainsSemicolon2_test() - -function(run_NameContainsSemicolon3_test) - set(CASE_CMAKELISTS_NAME_1 [==["PrefixTest;SuffixTest"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ PrefixTest;SuffixTest ]==]) - run_ctest(NameContainsSemicolon3) -endfunction() -run_NameContainsSemicolon3_test() - -function(run_NameContainsSemicolon4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ PrefixTest;SuffixTest ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["PrefixTest;SuffixTest"]==]) - run_ctest(NameContainsSemicolon4) -endfunction() -run_NameContainsSemicolon4_test() - - -function(run_NameContainsEscapedQuote1_test) - set(CASE_CMAKELISTS_NAME_1 [==["EscapedQuote\"\"SuffixTest"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["EscapedQuote\"\"SuffixTest"]==]) - run_ctest(NameContainsEscapedQuote1) -endfunction() -run_NameContainsEscapedQuote1_test() - -function(run_NameContainsEscapedQuote2_test) - set(CASE_CMAKELISTS_NAME_1 [==[ EscapedQuote\"\"SuffixTest ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ EscapedQuote\"\"SuffixTest ]==]) - run_ctest(NameContainsEscapedQuote2) -endfunction() -run_NameContainsEscapedQuote2_test() - -function(run_NameContainsEscapedQuote3_test) - set(CASE_CMAKELISTS_NAME_1 [==["EscapedQuote\"\"SuffixTest"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ EscapedQuote\"\"SuffixTest ]==]) - run_ctest(NameContainsEscapedQuote3) -endfunction() -run_NameContainsEscapedQuote3_test() - -function(run_NameContainsEscapedQuote4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ EscapedQuote\"\"SuffixTest ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["EscapedQuote\"\"SuffixTest"]==]) - run_ctest(NameContainsEscapedQuote4) -endfunction() -run_NameContainsEscapedQuote4_test() - - -function(run_NameContainsBracketArgument1_test) - set(CASE_CMAKELISTS_NAME_1 [==["[=[BracketArgument;SuffixTest]=]"]==]) - set(CASE_CMAKELISTS_NAME_2 [==["[=[BracketArgument;SuffixTest]=]"]==]) - run_ctest(NameContainsBracketArgument1) -endfunction() -run_NameContainsBracketArgument1_test() - -function(run_NameContainsBracketArgument2_test) - set(CASE_CMAKELISTS_NAME_1 [==[ [=[BracketArgument;SuffixTest]=] ]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ [=[BracketArgument;SuffixTest]=] ]==]) - run_ctest(NameContainsBracketArgument2) -endfunction() -run_NameContainsBracketArgument2_test() - -function(run_NameContainsBracketArgument3_test) - set(CASE_CMAKELISTS_NAME_1 [==["[=[BracketArgument;SuffixTest]=]"]==]) - set(CASE_CMAKELISTS_NAME_2 [==[ [=[BracketArgument;SuffixTest]=] ]==]) - run_ctest(NameContainsBracketArgument3) -endfunction() -run_NameContainsBracketArgument3_test() - -function(run_NameContainsBracketArgument4_test) - set(CASE_CMAKELISTS_NAME_1 [==[ [=[BracketArgument;SuffixTest]=] ]==]) - set(CASE_CMAKELISTS_NAME_2 [==["[=[BracketArgument;SuffixTest]=]"]==]) - run_ctest(NameContainsBracketArgument4) -endfunction() -run_NameContainsBracketArgument4_test() diff --git a/Tests/RunCMake/add_test/test.cmake.in b/Tests/RunCMake/add_test/test.cmake.in deleted file mode 100644 index 9821c1c..0000000 --- a/Tests/RunCMake/add_test/test.cmake.in +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.17) - -set(CTEST_SITE "test-site") -set(CTEST_BUILD_NAME "test-build-name") -set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") -set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") -set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") -set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") - -set(ctest_test_args "@CASE_CTEST_TEST_ARGS@") -ctest_start(Experimental) -ctest_configure() -#ctest_build() -ctest_test(${ctest_test_args}) diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt new file mode 100644 index 0000000..b0f0d19 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at DOWNLOAD-no-save-hash\.cmake:[0-9]+ \(file\): + file DOWNLOAD cannot calculate hash if file is not saved\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake new file mode 100644 index 0000000..ce959a7 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake @@ -0,0 +1,8 @@ +if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/") + set(slash /) +endif() +file(DOWNLOAD + "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-no-save-md5.txt" + EXPECTED_HASH MD5=55555555555555555555555555555555 + STATUS status + ) diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index a4de1d3..8d84943 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -11,6 +11,7 @@ run_cmake(DOWNLOAD-netrc-bad) run_cmake(DOWNLOAD-tls-cainfo-not-set) run_cmake(DOWNLOAD-tls-verify-not-set) run_cmake(DOWNLOAD-pass-not-set) +run_cmake(DOWNLOAD-no-save-hash) run_cmake(TOUCH) run_cmake(TOUCH-error-in-source-directory) run_cmake(TOUCH-error-missing-directory) diff --git a/Tests/SetLang/CMakeLists.txt b/Tests/SetLang/CMakeLists.txt index af90f11..616421e 100644 --- a/Tests/SetLang/CMakeLists.txt +++ b/Tests/SetLang/CMakeLists.txt @@ -9,6 +9,13 @@ set_source_files_properties(foo.c bar.c PROPERTIES LANGUAGE CXX) target_link_libraries(SetLang foo) set_target_properties(SetLang PROPERTIES LINKER_LANGUAGE CXX) +# VS generators historically tolerated target-wide -TP flags added +# by project code, so cover that case to preserve the behavior. +if(CMAKE_GENERATOR MATCHES "^Visual Studio" AND "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC") + add_library(stay stay_c.c stay_cxx.cxx) + set_property(TARGET stay PROPERTY COMPILE_OPTIONS "-TP") +endif() + if((CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang|MSVC|Borland|Embarcadero|Intel|TI|XL)")) add_library(zoom zoom.zzz) set_source_files_properties(zoom.zzz PROPERTIES LANGUAGE CXX) diff --git a/Tests/SetLang/stay_c.c b/Tests/SetLang/stay_c.c new file mode 100644 index 0000000..70755f3 --- /dev/null +++ b/Tests/SetLang/stay_c.c @@ -0,0 +1,8 @@ +#ifdef __cplusplus +# error C source incorrectly compiled as C++ +#endif + +int stay_c(void) +{ + return 0; +} diff --git a/Tests/SetLang/stay_cxx.cxx b/Tests/SetLang/stay_cxx.cxx new file mode 100644 index 0000000..e035260 --- /dev/null +++ b/Tests/SetLang/stay_cxx.cxx @@ -0,0 +1,8 @@ +#ifndef __cplusplus +# error C++ source incorrectly compiled as C +#endif + +int stay_cxx() +{ + return 0; +} diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index d102846..7046fab 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -33,6 +33,16 @@ if (CMAKE_CSharp_COMPILER) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) endif() +add_test(NAME UseSWIG.NamespaceCsharp COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/NamespaceCsharp" + "${CMake_BINARY_DIR}/Tests/UseSWIG/NamespaceCsharp" + ${build_generator_args} + --build-project TestNamespaceCsharp + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) add_test(NAME UseSWIG.BasicPython COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> diff --git a/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt new file mode 100644 index 0000000..39566a8 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.12...3.13) + +project(TestNamsespaceCsharp CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +set(UseSWIG_MODULE_VERSION 2) + + +add_library(ns_example STATIC ns_example.cpp) +target_include_directories(ns_example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +set_property(SOURCE ns_example.i PROPERTY CPLUSPLUS ON) + +swig_add_library(ns_csharp TYPE SHARED LANGUAGE csharp SOURCES ns_example.i) +set_target_properties(ns_csharp PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE) + +target_link_libraries(ns_csharp PRIVATE ns_example) + +get_target_property(NS_CSHARP_SUPPORT_FILES_DIR ns_csharp SWIG_SUPPORT_FILES_DIRECTORY) + +add_test(NAME NamespaceCsharp COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_DIRECTORY=${NS_CSHARP_SUPPORT_FILES_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake") diff --git a/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake b/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake new file mode 100644 index 0000000..828d54c --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake @@ -0,0 +1,8 @@ + +file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_DIRECTORY}" "${SUPPORT_FILES_DIRECTORY}/*") + +list(SORT files) + +if (NOT files STREQUAL "NSExample.cs;NSExamplePINVOKE.cs;ns;ns/my_class_in_namespace.cs") + message (FATAL_ERROR "Support files not correctly collected.") +endif() diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp b/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp new file mode 100644 index 0000000..a03dbad --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp @@ -0,0 +1,14 @@ +#include "ns_example.hpp" + +namespace ns { + +void my_class_in_namespace::add(int value) +{ + Sum += value; +} + +int my_class_in_namespace::get_sum() const +{ + return Sum; +} +} diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp b/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp new file mode 100644 index 0000000..65b9ab5 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp @@ -0,0 +1,19 @@ +#pragma once + +namespace ns { + +class my_class_in_namespace +{ +public: + my_class_in_namespace() + : Sum(0) + { + } + + void add(int value); + int get_sum() const; + +private: + int Sum; +}; +} diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.i b/Tests/UseSWIG/NamespaceCsharp/ns_example.i new file mode 100644 index 0000000..036f7ca --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.i @@ -0,0 +1,8 @@ +%module NSExample + +%{ +#include "ns_example.hpp" +%} + +%nspace ns::my_class_in_namespace; +%include "ns_example.hpp" diff --git a/Utilities/std/cm/bits/fs_path.cxx b/Utilities/std/cm/bits/fs_path.cxx index b8c5631..8089998 100644 --- a/Utilities/std/cm/bits/fs_path.cxx +++ b/Utilities/std/cm/bits/fs_path.cxx @@ -331,7 +331,7 @@ private: while (ptr != end && (*ptr == '/' # if defined(_WIN32) - || *ptr == ' \\' + || *ptr == '\\' # endif )) { ptr += step; @@ -1188,7 +1188,7 @@ int check_cxx14() } #endif -#if (__cplusplus >= 201703L || defined(__INTEL_COMPILER) && defined(__cpp_if_constexpr)) +#if (__cplusplus >= 201703L || defined(__INTEL_COMPILER) && defined(__cpp_deduction_guides)) #include <optional> template <typename T, typename std::invoke_result<decltype(&T::get), T>::type = nullptr> |