diff options
188 files changed, 1674 insertions, 476 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index bd6a58f..de4ce3d 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -190,6 +190,7 @@ Variables that Change Behavior /variable/CMAKE_LIBRARY_PATH /variable/CMAKE_LINK_DIRECTORIES_BEFORE /variable/CMAKE_MFC_FLAG + /variable/CMAKE_MAXIMUM_RECURSION_DEPTH /variable/CMAKE_MODULE_PATH /variable/CMAKE_NOT_USING_CONFIG_FLAGS /variable/CMAKE_POLICY_DEFAULT_CMPNNNN diff --git a/Help/prop_dir/EXCLUDE_FROM_ALL.rst b/Help/prop_dir/EXCLUDE_FROM_ALL.rst index 1aa24e4..9d3192c 100644 --- a/Help/prop_dir/EXCLUDE_FROM_ALL.rst +++ b/Help/prop_dir/EXCLUDE_FROM_ALL.rst @@ -7,3 +7,9 @@ A property on a directory that indicates if its targets are excluded from the default build target. If it is not, then with a Makefile for example typing make will cause the targets to be built. The same concept applies to the default build of other generators. + +Targets inherit the :prop_tgt:`EXCLUDE_FROM_ALL` property from the directory +that they are created in. When a directory is excluded, all of its targets will +have :prop_tgt:`EXCLUDE_FROM_ALL` set to ``TRUE``. After creating such a target +you can change its :prop_tgt:`EXCLUDE_FROM_ALL` property to ``FALSE``. This +will cause the target to be included in the default build target. diff --git a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst index caa5741..e7457e1 100644 --- a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst +++ b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst @@ -8,3 +8,6 @@ the default build target. If it is not, then with a Makefile for example typing make will cause this target to be built. The same concept applies to the default build of other generators. Installing a target with EXCLUDE_FROM_ALL set to true has undefined behavior. + +This property is enabled by default for targets that are created in +directories that have :prop_dir:`EXCLUDE_FROM_ALL` set to ``TRUE``. diff --git a/Help/release/dev/EXCLUDE_FROM_ALL.rst b/Help/release/dev/EXCLUDE_FROM_ALL.rst new file mode 100644 index 0000000..519ac42 --- /dev/null +++ b/Help/release/dev/EXCLUDE_FROM_ALL.rst @@ -0,0 +1,7 @@ +EXCLUDE_FROM_ALL +---------------- + +* A target's :prop_tgt:`EXCLUDE_FROM_ALL` property can now override the + setting of its directory. A target will now be built as part of "all" + if its :prop_tgt:`EXCLUDE_FROM_ALL` property is set to ``OFF``, even if its + containing directory is marked as :prop_dir:`EXCLUDE_FROM_ALL`. diff --git a/Help/release/dev/FindPython-NumPy-component.rst b/Help/release/dev/FindPython-NumPy-component.rst new file mode 100644 index 0000000..5ea6cfb --- /dev/null +++ b/Help/release/dev/FindPython-NumPy-component.rst @@ -0,0 +1,5 @@ +FindPython-NumPy-component +-------------------------- + +* The :module:`FindPython`, :module:`FindPython2`, and :module:`FindPython3` + modules gained support for ``NumPy`` component. diff --git a/Help/release/dev/findpython-script.rst b/Help/release/dev/findpython-script.rst new file mode 100644 index 0000000..5de1ebf --- /dev/null +++ b/Help/release/dev/findpython-script.rst @@ -0,0 +1,6 @@ +findpython-script +----------------- + +* The :module:`FindPython2`, :module:`FindPython3`, and :module:`FindPython` + modules now support running in script mode by skipping the creation of + imported targets and helper functions. diff --git a/Help/release/dev/max-recursion-depth.rst b/Help/release/dev/max-recursion-depth.rst new file mode 100644 index 0000000..3d9c781 --- /dev/null +++ b/Help/release/dev/max-recursion-depth.rst @@ -0,0 +1,6 @@ +max-recursion-depth +------------------- + +* CMake now imposes a maximum recursion limit to prevent a stack overflow on + scripts that recurse infinitely. The limit can be adjusted at runtime with + :variable:`CMAKE_MAXIMUM_RECURSION_DEPTH`. diff --git a/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst b/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst new file mode 100644 index 0000000..7110b16 --- /dev/null +++ b/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst @@ -0,0 +1,33 @@ +CMAKE_MAXIMUM_RECURSION_DEPTH +----------------------------- + +Maximum recursion depth for CMake scripts. It is intended to be set on the +command line with ``-DCMAKE_MAXIMUM_RECURSION_DEPTH=<x>``, or within +``CMakeLists.txt`` by projects that require a large recursion depth. Projects +that set this variable should provide the user with a way to override it. For +example: + +.. code-block:: cmake + + # About to perform deeply recursive actions + if(NOT CMAKE_MAXIMUM_RECURSION_DEPTH) + set(CMAKE_MAXIMUM_RECURSION_DEPTH 2000) + endif() + +If it is not set, or is set to a non-integer value, a sensible default limit is +used. If the recursion limit is reached, the script terminates immediately with +a fatal error. + +Calling any of the following commands increases the recursion depth: + +* :command:`include` +* :command:`find_package` +* :command:`add_subdirectory` +* :command:`try_compile` +* :command:`ctest_read_custom_files` +* :command:`ctest_run_script` (unless ``NEW_PROCESS`` is specified) +* User-defined :command:`function`'s and :command:`macro`'s (note that + :command:`function` and :command:`macro` themselves don't increase recursion + depth) +* Reading or writing variables that are being watched by a + :command:`variable_watch` diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake index 1820407..f94b254 100644 --- a/Modules/CheckFortranSourceCompiles.cmake +++ b/Modules/CheckFortranSourceCompiles.cmake @@ -17,8 +17,20 @@ Check if given Fortran source compiles and links into an executable. ) Checks that the source supplied in ``<code>`` can be compiled as a Fortran - source file and linked as an executable (so it must contain at least a - ``PROGRAM`` entry point). The result will be stored in the internal cache + source file and linked as an executable. The ``<code>`` must be a Fortran program + containing at least an ``end`` statement--for example: + + .. code-block:: cmake + + check_fortran_source_compiles("character :: b; error stop b; end" F2018ESTOPOK SRC_EXT F90) + + This command can help avoid costly build processes when a compiler lacks support + for a necessary feature, or a particular vendor library is not compatible with + the Fortran compiler version being used. This generate-time check may advise the + user of such before the main build process. See also the + :command:`check_fortran_source_runs` command to actually run the compiled code. + + The result will be stored in the internal cache variable ``<resultVar>``, with a boolean true value for success and boolean false for failure. diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index 58d90d7..13fdb0b 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -16,8 +16,20 @@ subsequently be run. [SRC_EXT <extension>]) Check that the source supplied in ``<code>`` can be compiled as a Fortran source - file, linked as an executable and then run. The ``<code>`` must contain at - least ``program; end program`` statements. If the ``<code>`` could be built and run + file, linked as an executable and then run. The ``<code>`` must be a Fortran program + containing at least an ``end`` statement--for example: + + .. code-block:: cmake + + check_fortran_source_runs("real :: x[*]; call co_sum(x); end" F2018coarrayOK) + + This command can help avoid costly build processes when a compiler lacks support + for a necessary feature, or a particular vendor library is not compatible with + the Fortran compiler version being used. Some of these failures only occur at runtime + instead of linktime, and a trivial runtime example can catch the issue before the + main build process. + + If the ``<code>`` could be built and run successfully, the internal cache variable specified by ``<resultVar>`` will be set to 1, otherwise it will be set to an value that evaluates to boolean false (e.g. an empty string or an error message). diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake index 0df6c0f..aa35b97 100644 --- a/Modules/Compiler/Intel-CXX-FeatureTests.cmake +++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake @@ -24,7 +24,7 @@ set(DETECT_CXX14 "((__cplusplus >= 201300L) || ((__cplusplus == 201103L) && !def unset(DETECT_BUGGY_ICC15) set(Intel17_CXX14 "__INTEL_COMPILER >= 1700 && ${DETECT_CXX14}") -set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && __INTEL_COMPILER != 1800 && !defined(_MSC_VER))") +set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && !(__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 5) && !defined(_MSC_VER))") set(Intel16_CXX14 "__INTEL_COMPILER >= 1600 && ${DETECT_CXX14}") set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}") diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake index 900e4f5..3491cdc 100644 --- a/Modules/FindGit.cmake +++ b/Modules/FindGit.cmake @@ -5,7 +5,8 @@ FindGit ------- -The module defines the following ``IMPORTED`` targets: +The module defines the following ``IMPORTED`` targets (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``): ``Git::Git`` Executable of the Git command-line client. diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake index 70e10f5..e4b4909 100644 --- a/Modules/FindICU.cmake +++ b/Modules/FindICU.cmake @@ -165,7 +165,9 @@ function(_ICU_FIND) find_program("${cache_var}" "${program}" HINTS ${icu_roots} PATH_SUFFIXES ${icu_binary_suffixes} - DOC "ICU ${program} executable") + DOC "ICU ${program} executable" + NO_PACKAGE_ROOT_PATH + ) mark_as_advanced(cache_var) set("${program_var}" "${${cache_var}}" PARENT_SCOPE) endforeach() @@ -229,11 +231,15 @@ function(_ICU_FIND) find_library("${component_cache_release}" ${component_libnames} HINTS ${icu_roots} PATH_SUFFIXES ${icu_library_suffixes} - DOC "ICU ${component} library (release)") + DOC "ICU ${component} library (release)" + NO_PACKAGE_ROOT_PATH + ) find_library("${component_cache_debug}" ${component_debug_libnames} HINTS ${icu_roots} PATH_SUFFIXES ${icu_library_suffixes} - DOC "ICU ${component} library (debug)") + DOC "ICU ${component} library (debug)" + NO_PACKAGE_ROOT_PATH + ) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(ICU_${component_upcase}) mark_as_advanced("${component_cache_release}" "${component_cache_debug}") diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 8645a0d..f014916 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -14,11 +14,12 @@ Three components are supported: * ``Compiler``: search for Python compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and libraries). +* ``NumPy``: search for NumPy include directories. If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed. -To ensure consistent versions between components ``Interpreter``, ``Compiler`` -and ``Development``, specify all components at the same time:: +To ensure consistent versions between components ``Interpreter``, ``Compiler``, +``Development`` and ``NumPy``, specify all components at the same time:: find_package (Python COMPONENTS Interpreter Development) @@ -30,7 +31,8 @@ To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets <Imported Targets>`: +This module defines the following :ref:`Imported Targets <Imported Targets>` +(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): ``Python::Interpreter`` Python interpreter. Target defined if component ``Interpreter`` is found. @@ -38,6 +40,8 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`: Python compiler. Target defined if component ``Compiler`` is found. ``Python::Python`` Python library. Target defined if component ``Development`` is found. +``Python::NumPy`` + NumPy Python library. Target defined if component ``NumPy`` is found. Result Variables ^^^^^^^^^^^^^^^^ @@ -103,6 +107,12 @@ This module will set the following variables in your project Python minor version. ``Python_VERSION_PATCH`` Python patch version. +``Python_NumPy_FOUND`` + System has the NumPy. +``Python_NumPy_INCLUDE_DIRS`` + The NumPy include directries. +``Python_NumPy_VERSION`` + The NumPy version. Hints ^^^^^ @@ -144,9 +154,10 @@ Hints Commands ^^^^^^^^ -This module defines the command ``Python_add_library`` which have the same -semantic as :command:`add_library` but take care of Python module naming rules -(only applied if library is of type ``MODULE``) and add dependency to target +This module defines the command ``Python_add_library`` (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as +:command:`add_library`, but takes care of Python module naming rules +(only applied if library is of type ``MODULE``), and adds a dependency to target ``Python::Python``:: Python_add_library (my_module MODULE src1.cpp) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index e0ebb90..0138b04 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -24,6 +24,8 @@ else() message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() +get_property(_${_PYTHON_PREFIX}_CMAKE_ROLE GLOBAL PROPERTY CMAKE_ROLE) + # # helper commands @@ -207,6 +209,10 @@ if (NOT ${_PYTHON_PREFIX}_FIND_COMPONENTS) set (${_PYTHON_PREFIX}_FIND_COMPONENTS Interpreter) set (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter TRUE) endif() +if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) + list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Interpreter" "Development") + list (REMOVE_DUPLICATES ${_PYTHON_PREFIX}_FIND_COMPONENTS) +endif() foreach (_${_PYTHON_PREFIX}_COMPONENT IN LISTS ${_PYTHON_PREFIX}_FIND_COMPONENTS) set (${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_FOUND FALSE) endforeach() @@ -1120,6 +1126,41 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() +if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND) + if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy) + list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + endif() + execute_process( + COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + "from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_PATH + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _${_PYTHON_PREFIX}_RESULT) + find_path(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR + NAMES arrayobject.h numpyconfig.h + HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}" + PATH_SUFFIXES numpy + NO_DEFAULT_PATH) + endif() + if(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + set(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + set(${_PYTHON_PREFIX}_NumPy_FOUND TRUE) + endif() + if(${_PYTHON_PREFIX}_NumPy_FOUND) + execute_process( + COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + "from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_VERSION) + if (NOT _${_PYTHON_PREFIX}_RESULT) + set(${_PYTHON_PREFIX}_NumPy_VERSION "${_${_PYTHON_PREFIX}_NumPy_VERSION}") + endif() + endif() +endif() + # final validation if (${_PYTHON_PREFIX}_VERSION_MAJOR AND NOT ${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) @@ -1133,118 +1174,128 @@ find_package_handle_standard_args (${_PYTHON_PREFIX} HANDLE_COMPONENTS) # Create imported targets and helper functions -if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS - AND ${_PYTHON_PREFIX}_Interpreter_FOUND - AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter) - add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED) - set_property (TARGET ${_PYTHON_PREFIX}::Interpreter - PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}") -endif() - -if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS - AND ${_PYTHON_PREFIX}_Compiler_FOUND - AND NOT TARGET ${_PYTHON_PREFIX}::Compiler) - add_executable (${_PYTHON_PREFIX}::Compiler IMPORTED) - set_property (TARGET ${_PYTHON_PREFIX}::Compiler - PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}") -endif() - -if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS - AND ${_PYTHON_PREFIX}_Development_FOUND AND NOT TARGET ${_PYTHON_PREFIX}::Python) +if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") + if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS + AND ${_PYTHON_PREFIX}_Interpreter_FOUND + AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter) + add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED) + set_property (TARGET ${_PYTHON_PREFIX}::Interpreter + PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}") + endif() - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" - OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" - OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) - set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED) - else() - set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC) + if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS + AND ${_PYTHON_PREFIX}_Compiler_FOUND + AND NOT TARGET ${_PYTHON_PREFIX}::Compiler) + add_executable (${_PYTHON_PREFIX}::Compiler IMPORTED) + set_property (TARGET ${_PYTHON_PREFIX}::Compiler + PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}") endif() - add_library (${_PYTHON_PREFIX}::Python ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED) - - set_property (TARGET ${_PYTHON_PREFIX}::Python - PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}") - - if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) - OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)) - # System manage shared libraries in two parts: import and runtime - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) - set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" - IMPORTED_IMPLIB_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" - IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}") - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" - IMPORTED_IMPLIB_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" - IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}") + if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS + AND ${_PYTHON_PREFIX}_Development_FOUND AND NOT TARGET ${_PYTHON_PREFIX}::Python) + + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" + OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" + OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) + set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED) else() - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}" - IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}") + set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC) endif() - else() - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) - set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" - IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}") - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" - IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}") + + add_library (${_PYTHON_PREFIX}::Python ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED) + + set_property (TARGET ${_PYTHON_PREFIX}::Python + PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}") + + if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) + OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)) + # System manage shared libraries in two parts: import and runtime + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) + set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_IMPLIB_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" + IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}") + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_IMPLIB_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" + IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}") + else() + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}" + IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}") + endif() else() - set_target_properties (${_PYTHON_PREFIX}::Python - PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}") + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) + set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}") + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}") + else() + set_target_properties (${_PYTHON_PREFIX}::Python + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}") + endif() endif() - endif() - if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC") - # extend link information with dependent libraries - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}") - # remove elements relative to python library itself - list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython") - foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS) - list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}") - endforeach() - set_property (TARGET ${_PYTHON_PREFIX}::Python - PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES}) + if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC") + # extend link information with dependent libraries + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _${_PYTHON_PREFIX}_RESULT) + string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}") + # remove elements relative to python library itself + list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython") + foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS) + list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}") + endforeach() + set_property (TARGET ${_PYTHON_PREFIX}::Python + PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES}) + endif() endif() - endif() - # - # PYTHON_ADD_LIBRARY (<name> [STATIC|SHARED|MODULE] src1 src2 ... srcN) - # It is used to build modules for python. - # - function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name) - cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY - "STATIC;SHARED;MODULE" "" "") - - unset (type) - if (NOT (PYTHON_ADD_LIBRARY_STATIC - OR PYTHON_ADD_LIBRARY_SHARED - OR PYTHON_ADD_LIBRARY_MODULE)) - set (type MODULE) - endif() - add_library (${name} ${type} ${ARGN}) - target_link_libraries (${name} PRIVATE ${prefix}::Python) - - # customize library name to follow module name rules - get_property (type TARGET ${name} PROPERTY TYPE) - if (type STREQUAL "MODULE_LIBRARY") - set_property (TARGET ${name} PROPERTY PREFIX "") - if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set_property (TARGET ${name} PROPERTY SUFFIX ".pyd") + # + # PYTHON_ADD_LIBRARY (<name> [STATIC|SHARED|MODULE] src1 src2 ... srcN) + # It is used to build modules for python. + # + function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name) + cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY + "STATIC;SHARED;MODULE" "" "") + + unset (type) + if (NOT (PYTHON_ADD_LIBRARY_STATIC + OR PYTHON_ADD_LIBRARY_SHARED + OR PYTHON_ADD_LIBRARY_MODULE)) + set (type MODULE) endif() - endif() - endfunction() + add_library (${name} ${type} ${ARGN}) + target_link_libraries (${name} PRIVATE ${prefix}::Python) + + # customize library name to follow module name rules + get_property (type TARGET ${name} PROPERTY TYPE) + if (type STREQUAL "MODULE_LIBRARY") + set_property (TARGET ${name} PROPERTY PREFIX "") + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set_property (TARGET ${name} PROPERTY SUFFIX ".pyd") + endif() + endif() + endfunction() + endif() + + if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_NumPy_FOUND + AND NOT TARGET ${_PYTHON_PREFIX}::NumPy AND TARGET ${_PYTHON_PREFIX}::Python) + add_library (${_PYTHON_PREFIX}::NumPy INTERFACE IMPORTED) + set_property (TARGET ${_PYTHON_PREFIX}::NumPy + PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + target_link_libraries (${_PYTHON_PREFIX}::NumPy INTERFACE ${_PYTHON_PREFIX}::Python) + endif() endif() # final clean-up diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 998e992..0bb7b28 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -14,11 +14,12 @@ Three components are supported: * ``Compiler``: search for Python 2 compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and libraries) +* ``NumPy``: search for NumPy include directories. If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed. -To ensure consistent versions between components ``Interpreter``, ``Compiler`` -and ``Development``, specify all components at the same time:: +To ensure consistent versions between components ``Interpreter``, ``Compiler``, +``Development`` and ``NumPy``, specify all components at the same time:: find_package (Python2 COMPONENTS Interpreter Development) @@ -31,7 +32,8 @@ for you. Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets <Imported Targets>`: +This module defines the following :ref:`Imported Targets <Imported Targets>` +(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): ``Python2::Interpreter`` Python 2 interpreter. Target defined if component ``Interpreter`` is found. @@ -39,6 +41,8 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`: Python 2 compiler. Target defined if component ``Compiler`` is found. ``Python2::Python`` Python 2 library. Target defined if component ``Development`` is found. +``Python2::NumPy`` + NumPy library for Python 2. Target defined if component ``NumPy`` is found. Result Variables ^^^^^^^^^^^^^^^^ @@ -104,6 +108,12 @@ This module will set the following variables in your project Python 2 minor version. ``Python2_VERSION_PATCH`` Python 2 patch version. +``Python2_NumPy_FOUND`` + System has the NumPy. +``Python2_NumPy_INCLUDE_DIRS`` + The NumPy include directries. +``Python2_NumPy_VERSION`` + The NumPy version. Hints ^^^^^ @@ -145,9 +155,10 @@ Hints Commands ^^^^^^^^ -This module defines the command ``Python2_add_library`` which have the same -semantic as :command:`add_library` but take care of Python module naming rules -(only applied if library is of type ``MODULE``) and add dependency to target +This module defines the command ``Python2_add_library`` (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as +:command:`add_library`, but takes care of Python module naming rules +(only applied if library is of type ``MODULE``), and adds a dependency to target ``Python2::Python``:: Python2_add_library (my_module MODULE src1.cpp) diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 2176f3f..b3dfff3 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -14,11 +14,12 @@ Three components are supported: * ``Compiler``: search for Python 3 compiler. Only offered by IronPython. * ``Development``: search for development artifacts (include directories and libraries) +* ``NumPy``: search for NumPy include directories. If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed. -To ensure consistent versions between components ``Interpreter``, ``Compiler`` -and ``Development``, specify all components at the same time:: +To ensure consistent versions between components ``Interpreter``, ``Compiler``, +``Development`` and ``NumPy``, specify all components at the same time:: find_package (Python3 COMPONENTS Interpreter Development) @@ -31,7 +32,8 @@ for you. Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the following :ref:`Imported Targets <Imported Targets>`: +This module defines the following :ref:`Imported Targets <Imported Targets>` +(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``): ``Python3::Interpreter`` Python 3 interpreter. Target defined if component ``Interpreter`` is found. @@ -39,6 +41,8 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`: Python 3 compiler. Target defined if component ``Compiler`` is found. ``Python3::Python`` Python 3 library. Target defined if component ``Development`` is found. +``Python3::NumPy`` + NumPy library for Python 3. Target defined if component ``NumPy`` is found. Result Variables ^^^^^^^^^^^^^^^^ @@ -104,6 +108,12 @@ This module will set the following variables in your project Python 3 minor version. ``Python3_VERSION_PATCH`` Python 3 patch version. +``Python3_NumPy_FOUND`` + System has the NumPy. +``Python3_NumPy_INCLUDE_DIRS`` + The NumPy include directries. +``Python3_NumPy_VERSION`` + The NumPy version. Hints ^^^^^ @@ -145,9 +155,10 @@ Hints Commands ^^^^^^^^ -This module defines the command ``Python3_add_library`` which have the same -semantic as :command:`add_library` but take care of Python module naming rules -(only applied if library is of type ``MODULE``) and add dependency to target +This module defines the command ``Python3_add_library`` (when +:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as +:command:`add_library`, but takes care of Python module naming rules +(only applied if library is of type ``MODULE``), and adds a dependency to target ``Python3::Python``:: Python3_add_library (my_module MODULE src1.cpp) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index d1f7b31..da33301 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -130,7 +130,9 @@ if(PYTHON_EXECUTABLE) endif() else() # sys.version predates sys.version_info, so use that - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" + # sys.version was first documented for Python 1.5, so assume version 1.4 + # if retrieving sys.version fails. + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "try: import sys; sys.stdout.write(sys.version)\nexcept: sys.stdout.write(\"1.4.0\")" OUTPUT_VARIABLE _VERSION RESULT_VARIABLE _PYTHON_VERSION_RESULT ERROR_QUIET) @@ -144,12 +146,10 @@ if(PYTHON_EXECUTABLE) set(PYTHON_VERSION_PATCH "0") endif() else() - # sys.version was first documented for Python 1.5, so assume - # this is older. - set(PYTHON_VERSION_STRING "1.4") - set(PYTHON_VERSION_MAJOR "1") - set(PYTHON_VERSION_MINOR "4") - set(PYTHON_VERSION_PATCH "0") + unset(PYTHON_VERSION_STRING) + unset(PYTHON_VERSION_MAJOR) + unset(PYTHON_VERSION_MINOR) + unset(PYTHON_VERSION_PATCH) endif() endif() unset(_PYTHON_VERSION_RESULT) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9e753e6..c73c6df 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -31,6 +31,16 @@ else() set(CMAKE_USE_ELF_PARSER) endif() +if(NOT CMake_DEFAULT_RECURSION_LIMIT) + if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST}) + set(CMake_DEFAULT_RECURSION_LIMIT 100) + elseif(MINGW) + set(CMake_DEFAULT_RECURSION_LIMIT 400) + else() + set(CMake_DEFAULT_RECURSION_LIMIT 1000) + endif() +endif() + if(APPLE) set(CMAKE_USE_MACH_PARSER 1) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b06c382..69c2ed0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 13) -set(CMake_VERSION_PATCH 20190123) +set(CMake_VERSION_PATCH 20190128) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 987cad8..8042167 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -200,7 +200,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml() fout.Close(); - return cmSystemTools::RenameFile(updatesPatchXml.data(), updatesXml.data()); + return cmSystemTools::RenameFile(updatesPatchXml, updatesXml); } void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 6c68f46..e39e25a 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -15,7 +15,6 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" #include "cmXMLWriter.h" -#include "cmake.h" #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" @@ -2226,7 +2225,7 @@ int cmCTestCoverageHandler::GetLabelId(std::string const& label) void cmCTestCoverageHandler::LoadLabels() { std::string fileList = this->CTest->GetBinaryDir(); - fileList += cmake::GetCMakeFilesDirectory(); + fileList += "/CMakeFiles"; fileList += "/TargetDirectories.txt"; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " target directory list [" << fileList << "]\n", diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index ec3307f..5e66e05 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -283,7 +283,7 @@ void cmCTestLaunch::LoadLabels() // Labels are listed in per-target files. std::string fname = this->OptionBuildDir; - fname += cmake::GetCMakeFilesDirectory(); + fname += "/CMakeFiles"; fname += "/"; fname += this->OptionTargetName; fname += ".dir/Labels.txt"; diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 320647a..d3aa2b4 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -538,7 +538,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() fout << f << "\n"; } fout.close(); - cmSystemTools::RenameFile(tmpout.c_str(), fname.c_str()); + cmSystemTools::RenameFile(tmpout, fname); } void cmCTestMultiProcessHandler::ReadCostData() diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index 238284a..a7e47d3 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -39,7 +39,8 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args, ++i; } else { int ret; - cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret); + cmCTestScriptHandler::RunScript(this->CTest, this->Makefile, + args[i].c_str(), !np, &ret); std::ostringstream str; str << ret; this->Makefile->AddDefinition(returnVariable, str.str().c_str()); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index f417f53..b949023 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -78,6 +78,7 @@ cmCTestScriptHandler::cmCTestScriptHandler() this->EmptyBinDir = false; this->EmptyBinDirOnce = false; this->Makefile = nullptr; + this->ParentMakefile = nullptr; this->CMake = nullptr; this->GlobalGenerator = nullptr; @@ -117,6 +118,7 @@ void cmCTestScriptHandler::Initialize() delete this->Makefile; this->Makefile = nullptr; + this->ParentMakefile = nullptr; delete this->GlobalGenerator; this->GlobalGenerator = nullptr; @@ -292,6 +294,10 @@ void cmCTestScriptHandler::CreateCMake() snapshot.GetDirectory().SetCurrentSource(cwd); snapshot.GetDirectory().SetCurrentBinary(cwd); this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot); + if (this->ParentMakefile) { + this->Makefile->SetRecursionDepth( + this->ParentMakefile->GetRecursionDepth()); + } this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); @@ -891,11 +897,13 @@ void cmCTestScriptHandler::RestoreBackupDirectories() } } -bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char* sname, - bool InProcess, int* returnValue) +bool cmCTestScriptHandler::RunScript(cmCTest* ctest, cmMakefile* mf, + const char* sname, bool InProcess, + int* returnValue) { cmCTestScriptHandler* sh = new cmCTestScriptHandler(); sh->SetCTestInstance(ctest); + sh->ParentMakefile = mf; sh->AddConfigurationScript(sname, InProcess); int res = sh->ProcessHandler(); if (returnValue) { diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index cf0762e..d93b5f8 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -72,8 +72,8 @@ public: /* * Run a script */ - static bool RunScript(cmCTest* ctest, const char* script, bool InProcess, - int* returnValue); + static bool RunScript(cmCTest* ctest, cmMakefile* mf, const char* script, + bool InProcess, int* returnValue); int RunCurrentScript(); /* @@ -166,6 +166,7 @@ private: std::chrono::steady_clock::time_point ScriptStartTime; cmMakefile* Makefile; + cmMakefile* ParentMakefile; cmGlobalGenerator* GlobalGenerator; cmake* CMake; }; diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 8ed43f9..811af56 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -720,7 +720,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir, ext != headerExts.end(); ++ext) { e << " ." << *ext; } - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); } void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 4e2f275..989c7ee 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2173,7 +2173,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) // handle the simple commandline arguments std::string errormsg; if (!this->HandleCommandLineArguments(i, args, errormsg)) { - cmSystemTools::Error(errormsg.c_str()); + cmSystemTools::Error(errormsg); return 1; } diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index e1d312b..2728f0f 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -16,7 +16,6 @@ #include "cmState.h" #include "cmSystemTools.h" #include "cmVersion.h" -#include "cmake.h" cmCacheManager::cmCacheManager() { @@ -27,7 +26,7 @@ cmCacheManager::cmCacheManager() void cmCacheManager::CleanCMakeFiles(const std::string& path) { std::string glob = path; - glob += cmake::GetCMakeFilesDirectory(); + glob += "/CMakeFiles"; glob += "/*.cmake"; cmsys::Glob globIt; globIt.FindFiles(glob); @@ -123,7 +122,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, std::ostringstream error; error << "Parse error in cache file " << cacheFile; error << " on line " << lineno << ". Offending entry: " << realbuffer; - cmSystemTools::Error(error.str().c_str()); + cmSystemTools::Error(error.str()); } } this->CacheMajorVersion = 0; @@ -171,7 +170,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, << " where CMakeCache.txt was created. This may result " "in binaries being created in the wrong place. If you " "are not sure, reedit the CMakeCache.txt"; - cmSystemTools::Error(message.str().c_str()); + cmSystemTools::Error(message.str()); } } return true; @@ -360,7 +359,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger) fout << "\n"; fout.Close(); std::string checkCacheFile = path; - checkCacheFile += cmake::GetCMakeFilesDirectory(); + checkCacheFile += "/CMakeFiles"; cmSystemTools::MakeDirectory(checkCacheFile); checkCacheFile += "/cmake.check_cache"; cmsys::ofstream checkCache(checkCacheFile.c_str()); @@ -384,7 +383,7 @@ bool cmCacheManager::DeleteCache(const std::string& path) cmSystemTools::RemoveFile(cacheFile); // now remove the files in the CMakeFiles directory // this cleans up language cache files - cmakeFiles += cmake::GetCMakeFilesDirectory(); + cmakeFiles += "/CMakeFiles"; if (cmSystemTools::FileIsDirectory(cmakeFiles)) { cmSystemTools::RemoveADirectory(cmakeFiles); } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 87bc150..c68bb21 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1237,7 +1237,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) std::ostringstream e; e << "Could not parse framework path \"" << item << "\" " << "linked by target " << this->Target->GetName() << "."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index fde9750..1d20cff 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -495,7 +495,7 @@ void cmComputeTargetDepends::ComplainAboutBadComponent( e << "At least one of these targets is not a STATIC_LIBRARY. " << "Cyclic dependencies are allowed only among static libraries."; } - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); } bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap, diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index c80439b..9d00c21 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -20,6 +20,7 @@ #cmakedefine CMAKE_USE_ELF_PARSER #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE +#define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@ #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 272535d..bd110ec 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -400,7 +400,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, // compute the binary dir when TRY_COMPILE is called with a src file // signature if (this->SrcFileSignature) { - this->BinaryDirectory += cmake::GetCMakeFilesDirectory(); + this->BinaryDirectory += "/CMakeFiles"; this->BinaryDirectory += "/CMakeTmp"; } else { // only valid for srcfile signatures diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index c6b66a3..c8f743a 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -83,7 +83,7 @@ bool cmExportFileGenerator::GenerateImportFile() std::string se = cmSystemTools::GetLastSystemError(); std::ostringstream e; e << "cannot write to file \"" << this->MainImportFile << "\": " << se; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } std::ostream& os = *foutPtr; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 3821144..f8bc0ab 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -54,7 +54,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) << "\" ...) " << "includes target \"" << te->Target->GetName() << "\" more than once in the export set."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } } @@ -112,7 +112,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::string errorMessage; if (!this->PopulateExportProperties(gt, properties, errorMessage)) { - cmSystemTools::Error(errorMessage.c_str()); + cmSystemTools::Error(errorMessage); return false; } @@ -294,7 +294,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig( std::string se = cmSystemTools::GetLastSystemError(); std::ostringstream e; e << "cannot write to file \"" << fileName << "\": " << se; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } std::ostream& os = exportFileStream; @@ -518,7 +518,7 @@ void cmExportInstallFileGenerator::ComplainAboutMissingTarget( e << "that is not in this export set, but " << occurrences << " times in others."; } - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); } std::string cmExportInstallFileGenerator::InstallNameDir( diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index 89bd258..34b6b33 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -169,7 +169,7 @@ std::string cmFileAPI::WriteJsonFile( // If the final name already exists then assume it has proper content. // Otherwise, atomically place the reply file at its final name if (cmSystemTools::FileExists(file, true) || - !cmSystemTools::RenameFile(tmpFile.c_str(), file.c_str())) { + !cmSystemTools::RenameFile(tmpFile, file)) { cmSystemTools::RemoveFile(tmpFile); } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 999af54..afb0b2a 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -561,7 +561,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) if (hex_conversion_enabled) { // TODO: should work without temp file, but just on a memory buffer std::string binaryFileName = this->Makefile->GetCurrentBinaryDirectory(); - binaryFileName += cmake::GetCMakeFilesDirectory(); + binaryFileName += "/CMakeFiles"; binaryFileName += "/FileCommandStringsBinaryFile"; if (cmHexFileConverter::TryConvert(fileName.c_str(), binaryFileName.c_str())) { @@ -2461,7 +2461,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args) newname += "/" + args[2]; } - if (!cmSystemTools::RenameFile(oldname.c_str(), newname.c_str())) { + if (!cmSystemTools::RenameFile(oldname, newname)) { std::string err = cmSystemTools::GetLastSystemError(); std::ostringstream e; /* clang-format off */ @@ -2916,10 +2916,6 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); check_curl_result(res, "DOWNLOAD cannot set url: "); - // enable auth - res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - check_curl_result(res, "DOWNLOAD cannot set httpauth: "); - // enable HTTP ERROR parsing res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); check_curl_result(res, "DOWNLOAD cannot set http failure option: "); @@ -3219,10 +3215,6 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); check_curl_result(res, "UPLOAD cannot set url: "); - // enable auth - res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - check_curl_result(res, "UPLOAD cannot set httpauth: "); - res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToMemoryCallback); check_curl_result(res, "UPLOAD cannot set write function: "); diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index bf53dbf..eef5dc0 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -210,7 +210,7 @@ int cmGeneratedFileStreamBase::CompressFile(std::string const&, int cmGeneratedFileStreamBase::RenameFile(std::string const& oldname, std::string const& newname) { - return cmSystemTools::RenameFile(oldname.c_str(), newname.c_str()); + return cmSystemTools::RenameFile(oldname, newname); } void cmGeneratedFileStream::SetName(const std::string& fname) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0e3ace3..86f10dc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -203,7 +203,7 @@ std::string cmGeneratorTarget::GetExportName() const std::ostringstream e; e << "EXPORT_NAME property \"" << exportName << "\" for \"" << this->GetName() << "\": is not valid."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return ""; } return exportName; @@ -4587,7 +4587,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, << " property requirement\nof " "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); break; } propContent = consistent.second; @@ -4612,7 +4612,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, "already. The INTERFACE_" << p << " property on\ndependency \"" << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); break; } propContent = consistent.second; @@ -4632,7 +4632,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, e << "The INTERFACE_" << p << " property of \"" << theTarget->GetName() << "\" does\nnot agree with the value of " << p << " already determined\nfor \"" << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); break; } propContent = consistent.second; @@ -6141,7 +6141,7 @@ bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const std::string cmGeneratorTarget::GetSupportDirectory() const { std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory(); - dir += cmake::GetCMakeFilesDirectory(); + dir += "/CMakeFiles"; dir += "/"; dir += this->GetName(); #if defined(__VMS) diff --git a/Source/cmGlobVerificationManager.cxx b/Source/cmGlobVerificationManager.cxx index e8959f2..5fd890e 100644 --- a/Source/cmGlobVerificationManager.cxx +++ b/Source/cmGlobVerificationManager.cxx @@ -9,7 +9,6 @@ #include "cmListFileCache.h" #include "cmSystemTools.h" #include "cmVersion.h" -#include "cmake.h" bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path) { @@ -18,7 +17,7 @@ bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path) } std::string scriptFile = path; - scriptFile += cmake::GetCMakeFilesDirectory(); + scriptFile += "/CMakeFiles"; std::string stampFile = scriptFile; cmSystemTools::MakeDirectory(scriptFile); scriptFile += "/VerifyGlobs.cmake"; @@ -165,7 +164,7 @@ void cmGlobVerificationManager::AddCacheEntry( message << "\n " << std::get<0>(bt); std::get<1>(bt).PrintTitle(message); } - cmSystemTools::Error(message.str().c_str()); + cmSystemTools::Error(message.str()); } else { value.Backtraces.emplace_back(variable, backtrace); } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b2b0e38..04af013 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -98,6 +98,8 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) this->ConfigureDoneCMP0026AndCMP0024 = false; this->FirstTimeProgress = 0.0f; + this->RecursionDepth = 0; + cm->GetState()->SetIsGeneratorMultiConfig(false); cm->GetState()->SetMinGWMake(false); cm->GetState()->SetMSYSShell(false); @@ -364,7 +366,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) err << "CMake was unable to find a build program corresponding to \"" << this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You " << "probably need to select a different build tool."; - cmSystemTools::Error(err.str().c_str()); + cmSystemTools::Error(err.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -484,7 +486,7 @@ void cmGlobalGenerator::EnableLanguage( mf->AddDefinition("RUN_CONFIGURE", true); std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory(); - rootBin += cmake::GetCMakeFilesDirectory(); + rootBin += "/CMakeFiles"; // If the configuration files path has been set, // then we are in a try compile and need to copy the enable language @@ -1166,6 +1168,7 @@ void cmGlobalGenerator::Configure() this->CMakeInstance->GetHomeOutputDirectory()); cmMakefile* dirMf = new cmMakefile(this, snapshot); + dirMf->SetRecursionDepth(this->RecursionDepth); this->Makefiles.push_back(dirMf); this->IndexMakefile(dirMf); @@ -1210,7 +1213,7 @@ void cmGlobalGenerator::Configure() const char* logs[] = { "CMakeOutput.log", "CMakeError.log", nullptr }; for (const char** log = logs; *log; ++log) { std::string f = this->CMakeInstance->GetHomeOutputDirectory(); - f += cmake::GetCMakeFilesDirectory(); + f += "/CMakeFiles"; f += "/"; f += *log; if (cmSystemTools::FileExists(f)) { @@ -1282,7 +1285,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const << "duplicate custom targets. " << "Consider using a Makefiles generator or fix the project to not " << "use duplicate target names."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } @@ -1996,7 +1999,7 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) this->ConfiguredFilesPath = gen->ConfiguredFilesPath; } else { this->ConfiguredFilesPath = gen->CMakeInstance->GetHomeOutputDirectory(); - this->ConfiguredFilesPath += cmake::GetCMakeFilesDirectory(); + this->ConfiguredFilesPath += "/CMakeFiles"; } } @@ -2030,17 +2033,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, return this->IsExcluded(rootSnp, snp); } -bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmGeneratorTarget* target) const +bool cmGlobalGenerator::IsExcluded(cmGeneratorTarget* target) const { - if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY || - target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - // This target is excluded from its directory. - return true; - } - // This target is included in its directory. Check whether the - // directory is excluded. - return this->IsExcluded(root, target->GetLocalGenerator()); + return target->GetType() == cmStateEnums::INTERFACE_LIBRARY || + target->GetPropertyAsBool("EXCLUDE_FROM_ALL"); } void cmGlobalGenerator::GetEnabledLanguages( @@ -2614,8 +2610,7 @@ std::string cmGlobalGenerator::GenerateRuleFile( ruleFile += ".rule"; const char* dir = this->GetCMakeCFGIntDir(); if (dir && dir[0] == '$') { - cmSystemTools::ReplaceString(ruleFile, dir, - cmake::GetCMakeFilesDirectory()); + cmSystemTools::ReplaceString(ruleFile, dir, "/CMakeFiles"); } return ruleFile; } @@ -2816,7 +2811,7 @@ void cmGlobalGenerator::CheckRuleHashes() #if defined(CMAKE_BUILD_WITH_CMAKE) std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory(); std::string pfile = home; - pfile += cmake::GetCMakeFilesDirectory(); + pfile += "/CMakeFiles"; pfile += "/CMakeRuleHashes.txt"; this->CheckRuleHashes(pfile, home); this->WriteRuleHashes(pfile); @@ -2895,7 +2890,7 @@ void cmGlobalGenerator::WriteSummary() { // Record all target directories in a central location. std::string fname = this->CMakeInstance->GetHomeOutputDirectory(); - fname += cmake::GetCMakeFilesDirectory(); + fname += "/CMakeFiles"; fname += "/TargetDirectories.txt"; cmGeneratedFileStream fout(fname); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 36d3d10..84ec7a9 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -432,6 +432,8 @@ public: std::string MakeSilentFlag; + int RecursionDepth; + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend @@ -468,7 +470,7 @@ protected: bool IsExcluded(cmStateSnapshot const& root, cmStateSnapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; + bool IsExcluded(cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} struct GlobalTargetInfo diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 557efec..7963c8a 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -93,7 +93,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts, message += prevTool; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return false; } else { /* store the toolset that is being used for this build */ @@ -178,7 +178,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, if (output.empty()) { std::string msg = "No GHS toolsets found in GHS_TOOLSET_ROOT \"" + tsd + "\"."; - cmSystemTools::Error(msg.c_str()); + cmSystemTools::Error(msg); tsd = ""; } else { tsd += output.back(); @@ -189,7 +189,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, tryPath = cmSystemTools::CollapseCombinedPath(tsd, ts); if (!cmSystemTools::FileExists(tryPath)) { std::string msg = "GHS toolset \"" + tryPath + "\" not found."; - cmSystemTools::Error(msg.c_str()); + cmSystemTools::Error(msg); tsd = ""; } else { tsd = tryPath; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 00fa348..f1ab852 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -331,9 +331,9 @@ public: return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) + bool IsExcluded(cmGeneratorTarget* target) { - return cmGlobalGenerator::IsExcluded(root, target); + return cmGlobalGenerator::IsExcluded(target); } int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 52bb046..792adc0 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -146,7 +146,7 @@ void cmGlobalUnixMakefileGenerator3::Generate() for (cmLocalGenerator* lg : this->LocalGenerators) { std::string markFileName = lg->GetCurrentBinaryDirectory(); markFileName += "/"; - markFileName += cmake::GetCMakeFilesDirectory(); + markFileName += "/CMakeFiles"; markFileName += "/progress.marks"; cmGeneratedFileStream markFile(markFileName); markFile << this->CountProgressMarksInAll(lg) << "\n"; @@ -196,7 +196,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() // see if the build system must be regenerated. std::string makefileName = this->GetCMakeInstance()->GetHomeOutputDirectory(); - makefileName += cmake::GetCMakeFilesDirectory(); + makefileName += "/CMakeFiles"; makefileName += "/Makefile2"; cmGeneratedFileStream makefileStream(makefileName, false, this->GetMakefileEncoding()); @@ -268,7 +268,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // see if the build system must be regenerated. std::string cmakefileName = this->GetCMakeInstance()->GetHomeOutputDirectory(); - cmakefileName += cmake::GetCMakeFilesDirectory(); + cmakefileName += "/CMakeFiles"; cmakefileName += "/Makefile.cmake"; cmGeneratedFileStream cmakefileStream(cmakefileName); if (!cmakefileStream) { @@ -332,7 +332,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // Build the path to the cache check file. std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory(); - check += cmake::GetCMakeFilesDirectory(); + check += "/CMakeFiles"; check += "/cmake.check_cache"; // Set the corresponding makefile in the cmake file. @@ -363,7 +363,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() for (cmLocalGenerator* localGen : this->LocalGenerators) { lg = static_cast<cmLocalUnixMakefileGenerator3*>(localGen); tmpStr = lg->GetCurrentBinaryDirectory(); - tmpStr += cmake::GetCMakeFilesDirectory(); + tmpStr += "/CMakeFiles"; tmpStr += "/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, tmpStr) << "\"\n"; @@ -572,9 +572,9 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( // Write the rule. commands.clear(); - std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string tmp = "CMakeFiles/"; tmp += "Makefile2"; - commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), name)); + commands.push_back(lg->GetRecursiveMakeCall(tmp, name)); depends.clear(); if (regenerate) { depends.emplace_back("cmake_check_build_system"); @@ -594,7 +594,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( localName = name; localName += "/fast"; commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); lg->WriteMakeRule(ruleFileStream, "fast build rule for target.", localName, depends, commands, true); @@ -608,7 +608,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( depends.clear(); commands.clear(); commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); lg->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", localName, depends, commands, true); @@ -659,12 +659,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( makeTargetName = localName; makeTargetName += "/depend"; commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); makeTargetName = localName; makeTargetName += "/build"; commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); // Write the rule. localName += "/all"; @@ -672,7 +672,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( cmLocalUnixMakefileGenerator3::EchoProgress progress; progress.Dir = lg->GetBinaryDirectory(); - progress.Dir += cmake::GetCMakeFilesDirectory(); + progress.Dir += "/CMakeFiles"; { std::ostringstream progressArg; const char* sep = ""; @@ -702,7 +702,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( localName, depends, commands, true); // add the all/all dependency - if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) { + if (!this->IsExcluded(gtarget)) { depends.clear(); depends.push_back(localName); commands.clear(); @@ -726,9 +726,9 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted); commands.push_back(progCmd.str()); } - std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string tmp = "CMakeFiles/"; tmp += "Makefile2"; - commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), localName)); + commands.push_back(lg->GetRecursiveMakeCall(tmp, localName)); { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 @@ -761,13 +761,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( localName += "/preinstall"; depends.clear(); commands.clear(); - commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), localName)); + commands.push_back(lg->GetRecursiveMakeCall(makefileName, localName)); lg->WriteMakeRule(ruleFileStream, "Pre-install relink rule for target.", localName, depends, commands, true); - if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) { + if (!this->IsExcluded(gtarget)) { depends.clear(); depends.push_back(localName); commands.clear(); @@ -783,7 +782,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( depends.clear(); commands.clear(); commands.push_back( - lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + lg->GetRecursiveMakeCall(makefileName, makeTargetName)); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", makeTargetName, depends, commands, true); commands.clear(); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index dbe582b..9a8014c 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -706,7 +706,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) wd = this->ConfiguredFilesPath; } else { wd = this->GetCMakeInstance()->GetHomeOutputDirectory(); - wd += cmake::GetCMakeFilesDirectory(); + wd += "/CMakeFiles"; } wd += "/"; wd += cmVersion::GetCMakeVersion(); @@ -1005,7 +1005,7 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile( // The VS 10 generator needs to create the .rule files on disk. // Hide them away under the CMakeFiles directory. std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory(); - ruleDir += cmake::GetCMakeFilesDirectory(); + ruleDir += "/CMakeFiles"; ruleDir += "/"; ruleDir += cmSystemTools::ComputeStringMD5( cmSystemTools::GetFilenamePath(output).c_str()); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 16796cf..8e67fad 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -149,7 +149,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends( m += target->GetName(); m += " depends on unknown target: "; m += name; - cmSystemTools::Error(m.c_str()); + cmSystemTools::Error(m); } fout << "\t\t{" << guid << "} = {" << guid << "}\n"; } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 4d165c2..f6db018 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -117,7 +117,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Create a list of all stamp files for this project. std::vector<std::string> stamps; - std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string stampList = "CMakeFiles/"; stampList += cmGlobalVisualStudio8Generator::GetGenerateStampList(); { std::string stampListFile = @@ -129,7 +129,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() for (cmLocalGenerator const* gi : generators) { stampFile = gi->GetMakefile()->GetCurrentBinaryDirectory(); stampFile += "/"; - stampFile += cmake::GetCMakeFilesDirectoryPostSlash(); + stampFile += "CMakeFiles/"; stampFile += "generate.stamp"; fout << stampFile << "\n"; stamps.push_back(stampFile); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 41d961c..cbea3dd 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -201,7 +201,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() tgt->IsImported()) { continue; } - if (!this->IsExcluded(gen[0], tgt)) { + if (!this->IsExcluded(tgt)) { allBuild->AddUtility(tgt->GetName()); } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 79d77e7..0d70a0e 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -538,10 +538,6 @@ void cmGlobalXCodeGenerator::AddExtraTargets( // now make the allbuild depend on all the non-utility targets // in the project for (auto& gen : gens) { - if (this->IsExcluded(root, gen)) { - continue; - } - for (auto target : gen->GetGeneratorTargets()) { if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; @@ -574,8 +570,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( false, "", false, cmMakefile::AcceptObjectLibraryCommands); } - if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY && - !target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + if (!this->IsExcluded(target)) { allbuild->AddUtility(target->GetName()); } } @@ -623,7 +618,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( std::string checkCache = root->GetBinaryDirectory(); checkCache += "/"; - checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); + checkCache += "CMakeFiles/"; checkCache += "cmake.check_cache"; if (cm->DoWriteGlobVerifyTarget()) { @@ -1413,7 +1408,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) // language. cmMakefile* mf = gtgt->Target->GetMakefile(); std::string fname = gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fname += cmake::GetCMakeFilesDirectory(); + fname += "/CMakeFiles"; fname += "/"; fname += gtgt->GetName(); fname += "-CMakeForceLinker"; @@ -3721,7 +3716,7 @@ std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation( cmGeneratorTarget* target) { std::string plist = target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - plist += cmake::GetCMakeFilesDirectory(); + plist += "/CMakeFiles"; plist += "/"; plist += target->GetName(); plist += ".dir/Info.plist"; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 4cc081c..47b9785 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -15,7 +15,6 @@ #include "cmInstallType.h" #include "cmLocalGenerator.h" #include "cmSystemTools.h" -#include "cmake.h" cmInstallExportGenerator::cmInstallExportGenerator( cmExportSet* exportSet, const char* destination, @@ -57,7 +56,7 @@ void cmInstallExportGenerator::ComputeTempDir() // Choose a temporary directory in which to generate the import // files to be installed. this->TempDir = this->LocalGenerator->GetCurrentBinaryDirectory(); - this->TempDir += cmake::GetCMakeFilesDirectory(); + this->TempDir += "/CMakeFiles"; this->TempDir += "/Export"; if (this->Destination.empty()) { return; @@ -127,7 +126,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) std::ostringstream e; e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName() << "\""; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 08f46aa..d1d4316 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -19,7 +19,6 @@ #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cmake.h" cmInstallTargetGenerator::cmInstallTargetGenerator( std::string targetName, const char* dest, bool implib, @@ -102,7 +101,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( if (this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fromDirConfig += cmake::GetCMakeFilesDirectory(); + fromDirConfig += "/CMakeFiles"; fromDirConfig += "/CMakeRelink.dir/"; } else { cmStateEnums::ArtifactType artifact = this->ImportLibrary diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 05b22cf..b24c5ba 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -666,7 +666,12 @@ bool cmListCommand::HandleTransformCommand( ActionDescriptor(std::string name, int arity, transform_type transform) : Name(std::move(name)) , Arity(arity) +#if defined(__GNUC__) && __GNUC__ == 6 && defined(__aarch64__) + // std::function move constructor miscompiles on this architecture + , Transform(transform) +#else , Transform(std::move(transform)) +#endif { } diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index ff793f6..cc2c09f 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -193,8 +193,9 @@ bool cmListFileParser::ParseFunction(const char* name, long line) unsigned long lastLine; unsigned long parenDepth = 0; this->Separation = SeparationOkay; - while ((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer), - token = cmListFileLexer_Scan(this->Lexer))) { + while ( + (static_cast<void>(lastLine = cmListFileLexer_GetCurrentLine(this->Lexer)), + token = cmListFileLexer_Scan(this->Lexer))) { if (token->type == cmListFileLexer_Token_Space || token->type == cmListFileLexer_Token_Newline) { this->Separation = SeparationOkay; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3771737..62aff99 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1794,7 +1794,7 @@ static void AddVisibilityCompileOption(std::string& flags, std::ostringstream e; e << "Target " << target->GetName() << " uses unsupported value \"" << prop << "\" for " << flagDefine << "."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } std::string option = std::string(opt) + prop; @@ -2800,7 +2800,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, std::ostringstream e; e << "Target " << target->GetName() << " Info.plist template \"" << inFile << "\" could not be found."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } @@ -2838,7 +2838,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList( std::ostringstream e; e << "Target " << target->GetName() << " Info.plist template \"" << inFile << "\" could not be found."; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index dc54314..ebc613b 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -233,8 +233,8 @@ public: virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {} /** Called from command-line hook to update dependencies. */ - virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/, - bool /*color*/) + virtual bool UpdateDependencies(const std::string& /* tgtInfo */, + bool /*verbose*/, bool /*color*/) { return true; } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index a8647b1..4b9837c 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,9 +90,7 @@ void cmLocalNinjaGenerator::Generate() if (tg) { tg->Generate(); // Add the target to "all" if required. - if (!this->GetGlobalNinjaGenerator()->IsExcluded( - this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - target)) { + if (!this->GetGlobalNinjaGenerator()->IsExcluded(target)) { this->GetGlobalNinjaGenerator()->AddDependencyToAll(target); } delete tg; @@ -106,7 +104,7 @@ void cmLocalNinjaGenerator::Generate() std::string cmLocalNinjaGenerator::GetTargetDirectory( cmGeneratorTarget const* target) const { - std::string dir = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string dir = "CMakeFiles/"; dir += target->GetName(); #if defined(__VMS) dir += "_dir"; @@ -305,7 +303,7 @@ std::string cmLocalNinjaGenerator::WriteCommandScript( scriptPath = target->GetSupportDirectory(); } else { scriptPath = this->GetCurrentBinaryDirectory(); - scriptPath += cmake::GetCMakeFilesDirectory(); + scriptPath += "/CMakeFiles"; } cmSystemTools::MakeDirectory(scriptPath); scriptPath += '/'; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index c50dcb7..7cb98b9 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -248,8 +248,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() for (auto& localObjectFile : localObjectFiles) { // Add a convenience rule for building the object file. this->WriteObjectConvenienceRule( - ruleFileStream, "target to build an object file", - localObjectFile.first.c_str(), localObjectFile.second); + ruleFileStream, "target to build an object file", localObjectFile.first, + localObjectFile.second); // Check whether preprocessing and assembly rules make sense. // They make sense only for C and C++ sources. @@ -271,9 +271,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() if (lang_has_preprocessor && do_preprocess_rules) { std::string::size_type dot_pos = localObjectFile.first.rfind("."); std::string base = localObjectFile.first.substr(0, dot_pos); - this->WriteObjectConvenienceRule( - ruleFileStream, "target to preprocess a source file", - (base + ".i").c_str(), localObjectFile.second); + this->WriteObjectConvenienceRule(ruleFileStream, + "target to preprocess a source file", + (base + ".i"), localObjectFile.second); localObjectFile.second.HasPreprocessRule = true; } @@ -282,7 +282,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() std::string base = localObjectFile.first.substr(0, dot_pos); this->WriteObjectConvenienceRule( ruleFileStream, "target to generate assembly for a file", - (base + ".s").c_str(), localObjectFile.second); + (base + ".s"), localObjectFile.second); localObjectFile.second.HasAssembleRule = true; } } @@ -298,7 +298,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() } void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule( - std::ostream& ruleFileStream, const char* comment, const char* output, + std::ostream& ruleFileStream, const char* comment, const std::string& output, LocalObjectInfo const& info) { // If the rule includes the source file extension then create a @@ -334,7 +334,7 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule( targetName += "/"; targetName += output; commands.push_back( - this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName)); + this->GetRecursiveMakeCall(tgtMakefileName, targetName)); } this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); @@ -371,10 +371,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( depends.clear(); // Build the target for this pass. - std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string makefile2 = "CMakeFiles/"; makefile2 += "Makefile2"; - commands.push_back( - this->GetRecursiveMakeCall(makefile2.c_str(), localName)); + commands.push_back(this->GetRecursiveMakeCall(makefile2, localName)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", @@ -399,7 +398,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( depends.clear(); commands.clear(); commands.push_back( - this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); + this->GetRecursiveMakeCall(makefileName, makeTargetName)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "fast build rule for target.", @@ -415,7 +414,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( depends.clear(); commands.clear(); commands.push_back( - this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName)); + this->GetRecursiveMakeCall(makefile2, makeTargetName)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, @@ -429,7 +428,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() { std::string infoFileName = this->GetCurrentBinaryDirectory(); - infoFileName += cmake::GetCMakeFilesDirectory(); + infoFileName += "/CMakeFiles"; infoFileName += "/CMakeDirectoryInformation.cmake"; // Open the output file. @@ -771,7 +770,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom( cmOutputConverter::SHELL); commands.push_back(rescanRule); } - std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string cmakefileName = "CMakeFiles/"; cmakefileName += "Makefile.cmake"; std::string runRule = "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; @@ -1254,9 +1253,8 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable( return ret; } -bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, - bool verbose, - bool color) +bool cmLocalUnixMakefileGenerator3::UpdateDependencies( + const std::string& tgtInfo, bool verbose, bool color) { // read in the target info file if (!this->Makefile->ReadListFile(tgtInfo) || @@ -1280,7 +1278,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, this->GlobalGenerator->GetCMakeInstance()->GetFileComparison(); { int result; - if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) || + if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo.c_str(), + &result) || result < 0) { if (verbose) { std::ostringstream msg; @@ -1296,7 +1295,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, // may have changed. In this case discard all old dependencies. bool needRescanDirInfo = false; std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += cmake::GetCMakeFilesDirectory(); + dirInfoFile += "/CMakeFiles"; dirInfoFile += "/CMakeDirectoryInformation.cmake"; { int result; @@ -1362,7 +1361,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( cmMakefile* mf = this->Makefile; bool haveDirectoryInfo = false; std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += cmake::GetCMakeFilesDirectory(); + dirInfoFile += "/CMakeFiles"; dirInfoFile += "/CMakeDirectoryInformation.cmake"; if (mf->ReadListFile(dirInfoFile) && !cmSystemTools::GetErrorOccuredFlag()) { haveDirectoryInfo = true; @@ -1593,14 +1592,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( } std::string progressDir = this->GetBinaryDirectory(); - progressDir += cmake::GetCMakeFilesDirectory(); + progressDir += "/CMakeFiles"; { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; progCmd << this->ConvertToOutputFormat( cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL); - std::string progressFile = cmake::GetCMakeFilesDirectory(); + std::string progressFile = "/CMakeFiles"; progressFile += "/progress.marks"; std::string progressFileNameFull = this->ConvertToFullPath(progressFile); progCmd << " " @@ -1609,10 +1608,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( cmOutputConverter::SHELL); commands.push_back(progCmd.str()); } - std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string mf2Dir = "CMakeFiles/"; mf2Dir += "Makefile2"; - commands.push_back( - this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); + commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); { @@ -1631,8 +1629,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( recursiveTarget += "/clean"; commands.clear(); depends.clear(); - commands.push_back( - this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); + commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", @@ -1657,8 +1654,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( // At least make sure the build system is up to date. depends.emplace_back("cmake_check_build_system"); } - commands.push_back( - this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); + commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", @@ -1678,7 +1674,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( cmOutputConverter::SHELL); commands.push_back(rescanRule); } - std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string cmakefileName = "CMakeFiles/"; cmakefileName += "Makefile.cmake"; { std::string runRule = @@ -1886,7 +1882,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) } std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall( - const char* makefile, const std::string& tgt) + const std::string& makefile, const std::string& tgt) { // Call make on the given file. std::string cmd; @@ -1956,7 +1952,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os, } std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( - const char* p, bool useWatcomQuote) + const std::string& p, bool useWatcomQuote) { // Split the path into its components. std::vector<std::string> components; @@ -2023,7 +2019,7 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( std::string cmLocalUnixMakefileGenerator3::GetTargetDirectory( cmGeneratorTarget const* target) const { - std::string dir = cmake::GetCMakeFilesDirectoryPostSlash(); + std::string dir = "CMakeFiles/"; dir += target->GetName(); #if defined(__VMS) dir += "_dir"; @@ -2040,8 +2036,8 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(const cmGeneratorTarget* tgt) } void cmLocalUnixMakefileGenerator3::AddImplicitDepends( - const cmGeneratorTarget* tgt, const std::string& lang, const char* obj, - const char* src) + const cmGeneratorTarget* tgt, const std::string& lang, + const std::string& obj, const std::string& src) { this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src); } diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 5268e6b..1e1c59e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -84,7 +84,7 @@ public: void WriteDivider(std::ostream& os); /** used to create a recursive make call */ - std::string GetRecursiveMakeCall(const char* makefile, + std::string GetRecursiveMakeCall(const std::string& makefile, const std::string& tgt); // append flags to a string @@ -121,7 +121,7 @@ public: std::string const& targetDir, std::string const& relDir); - static std::string ConvertToQuotedOutputPath(const char* p, + static std::string ConvertToQuotedOutputPath(const std::string& p, bool useWatcomQuote); std::string CreateMakeVariable(const std::string& sin, @@ -129,7 +129,7 @@ public: /** Called from command-line hook to bring dependencies up to date for a target. */ - bool UpdateDependencies(const char* tgtInfo, bool verbose, + bool UpdateDependencies(const std::string& tgtInfo, bool verbose, bool color) override; /** Called from command-line hook to clear dependencies. */ @@ -159,8 +159,8 @@ public: cmGeneratorTarget const* tgt); void AddImplicitDepends(cmGeneratorTarget const* tgt, - const std::string& lang, const char* obj, - const char* src); + const std::string& lang, const std::string& obj, + const std::string& src); // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); @@ -201,9 +201,6 @@ protected: void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmGeneratorTarget* tgt); - // write the local help rule - void WriteHelpRule(std::ostream& ruleFileStream); - // this converts a file name that is relative to the StartOuputDirectory // into a full path std::string ConvertToFullPath(const std::string& localPath); @@ -212,15 +209,6 @@ protected: const std::string& realTarget, const std::string& helpTarget); - void WriteTargetDependRule(std::ostream& ruleFileStream, - cmGeneratorTarget* target); - void WriteTargetCleanRule(std::ostream& ruleFileStream, - cmGeneratorTarget* target, - const std::vector<std::string>& files); - void WriteTargetRequiresRule(std::ostream& ruleFileStream, - cmGeneratorTarget* target, - const std::vector<std::string>& objects); - void AppendRuleDepend(std::vector<std::string>& depends, const char* ruleFileName); void AppendRuleDepends(std::vector<std::string>& depends, @@ -285,7 +273,8 @@ private: std::map<std::string, LocalObjectInfo>& localObjectFiles); void WriteObjectConvenienceRule(std::ostream& ruleFileStream, - const char* comment, const char* output, + const char* comment, + const std::string& output, LocalObjectInfo const& info); std::vector<std::string> LocalHelp; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 677d033..9ea8c2e 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -97,7 +97,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force_commands.push_back(force_command); std::string no_main_dependency; std::string force = this->GetCurrentBinaryDirectory(); - force += cmake::GetCMakeFilesDirectory(); + force += "/CMakeFiles"; force += "/"; force += l->GetName(); force += "_force"; @@ -144,7 +144,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() // Touch a timestamp file used to determine when the project file is // out of date. std::string stampName = this->GetCurrentBinaryDirectory(); - stampName += cmake::GetCMakeFilesDirectory(); + stampName += "/CMakeFiles"; cmSystemTools::MakeDirectory(stampName.c_str()); stampName += "/"; stampName += "generate.stamp"; @@ -254,7 +254,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() std::string stampName = this->GetCurrentBinaryDirectory(); stampName += "/"; - stampName += cmake::GetCMakeFilesDirectoryPostSlash(); + stampName += "CMakeFiles/"; stampName += "generate.stamp"; cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 500776e..b59a733 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,6 +45,8 @@ #include "cm_sys_stat.h" #include "cmake.h" +#include "cmConfigure.h" // IWYU pragma: keep + #ifdef CMAKE_BUILD_WITH_CMAKE # include "cmVariableWatch.h" #endif @@ -83,6 +85,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->StateSnapshot = this->StateSnapshot.GetState()->CreatePolicyScopeSnapshot( this->StateSnapshot); + this->RecursionDepth = 0; // Enter a policy level for this directory. this->PushPolicy(); @@ -333,12 +336,14 @@ public: cmListFileContext const& lfc = cmListFileContext::FromCommandContext( cc, this->Makefile->StateSnapshot.GetExecutionListFile()); this->Makefile->Backtrace = this->Makefile->Backtrace.Push(lfc); + ++this->Makefile->RecursionDepth; this->Makefile->ExecutionStatusStack.push_back(&status); } ~cmMakefileCall() { this->Makefile->ExecutionStatusStack.pop_back(); + --this->Makefile->RecursionDepth; this->Makefile->Backtrace = this->Makefile->Backtrace.Pop(); } @@ -361,6 +366,24 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, cmMakefileCall stack_manager(this, lff, status); static_cast<void>(stack_manager); + // Check for maximum recursion depth. + int depth = CMake_DEFAULT_RECURSION_LIMIT; + const char* depthStr = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); + if (depthStr) { + std::istringstream s(depthStr); + int d; + if (s >> d) { + depth = d; + } + } + if (this->RecursionDepth > depth) { + std::ostringstream e; + e << "Maximum recursion depth of " << depth << " exceeded"; + this->IssueMessage(MessageType::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + // Lookup the command prototype. if (cmCommand* proto = this->GetState()->GetCommandByExactName(lff.Name.Lower)) { @@ -1128,7 +1151,7 @@ cmTarget* cmMakefile::AddUtilityCommand( // Create a target instance for this utility. cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); target->SetIsGeneratorProvided(origin == TargetOrigin::Generator); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } if (!comment) { @@ -1139,7 +1162,7 @@ cmTarget* cmMakefile::AddUtilityCommand( // Store the custom command in the target. if (!commandLines.empty() || !depends.empty()) { std::string force = this->GetCurrentBinaryDirectory(); - force += cmake::GetCMakeFilesDirectory(); + force += "/CMakeFiles"; force += "/"; force += utilityName; std::vector<std::string> forced; @@ -1369,6 +1392,9 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) // Imported targets. this->ImportedTargets = parent->ImportedTargets; + + // Recursion depth. + this->RecursionDepth = parent->RecursionDepth; } void cmMakefile::PushFunctionScope(std::string const& fileName, @@ -1493,7 +1519,7 @@ void cmMakefile::Configure() // make sure the CMakeFiles dir is there std::string filesDir = this->StateSnapshot.GetDirectory().GetCurrentBinary(); - filesDir += cmake::GetCMakeFilesDirectory(); + filesDir += "/CMakeFiles"; cmSystemTools::MakeDirectory(filesDir); assert(cmSystemTools::FileExists(currentStart, true)); @@ -1663,7 +1689,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); this->GetGlobalGenerator()->AddMakefile(subMf); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } @@ -1959,7 +1985,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname, // over changes in CMakeLists.txt, making the information stale and // hence useless. target->ClearDependencyInformation(*this); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); @@ -1972,7 +1998,7 @@ cmTarget* cmMakefile::AddExecutable(const std::string& exeName, bool excludeFromAll) { cmTarget* target = this->AddNewTarget(cmStateEnums::EXECUTABLE, exeName); - if (excludeFromAll) { + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); @@ -2721,8 +2747,17 @@ bool cmMakefile::IsProjectFile(const char* filename) const { return cmSystemTools::IsSubDirectory(filename, this->GetHomeDirectory()) || (cmSystemTools::IsSubDirectory(filename, this->GetHomeOutputDirectory()) && - !cmSystemTools::IsSubDirectory(filename, - cmake::GetCMakeFilesDirectory())); + !cmSystemTools::IsSubDirectory(filename, "/CMakeFiles")); +} + +int cmMakefile::GetRecursionDepth() const +{ + return this->RecursionDepth; +} + +void cmMakefile::SetRecursionDepth(int recursionDepth) +{ + this->RecursionDepth = recursionDepth; } MessageType cmMakefile::ExpandVariablesInStringNew( @@ -3388,6 +3423,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, this->IsSourceFileTryCompile = false; return 1; } + gg->RecursionDepth = this->RecursionDepth; cm.SetGlobalGenerator(gg); // do a configure @@ -3407,6 +3443,12 @@ int cmMakefile::TryCompile(const std::string& srcdir, cmStateEnums::STRING); } } + const char* recursionDepth = + this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); + if (recursionDepth) { + cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth, + "Maximum recursion depth", cmStateEnums::STRING); + } // if cmake args were provided then pass them in if (cmakeArgs) { // FIXME: Workaround to ignore unused CLI variables in try-compile. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e88bb0b..2bd44e2 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -870,6 +870,9 @@ public: const char* sourceFilename) const; bool IsProjectFile(const char* filename) const; + int GetRecursionDepth() const; + void SetRecursionDepth(int recursionDepth); + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(cmTarget& target); @@ -930,6 +933,7 @@ protected: private: cmStateSnapshot StateSnapshot; cmListFileBacktrace Backtrace; + int RecursionDepth; void ReadListFile(cmListFile const& listFile, const std::string& filenametoread); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 92eeb2e..e576b5f 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator( cmGeneratorTarget* target) @@ -317,7 +316,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string outpathImp; if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); - outpath += cmake::GetCMakeFilesDirectory(); + outpath += "/CMakeFiles"; outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 0c2d7b3..72181ab 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -25,7 +25,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( cmGeneratorTarget* target) @@ -499,7 +498,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( outpath += "/"; } else if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); - outpath += cmake::GetCMakeFilesDirectory(); + outpath += "/CMakeFiles"; outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1207646..0fad233 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -435,8 +435,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( objFullPath = cmSystemTools::CollapseFullPath(objFullPath); std::string srcFullPath = cmSystemTools::CollapseFullPath(source.GetFullPath()); - this->LocalGenerator->AddImplicitDepends( - this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str()); + this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang, + objFullPath, srcFullPath); } void cmMakefileTargetGenerator::WriteObjectBuildFile( @@ -1213,8 +1213,7 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile( std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]); std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second); this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first, - objFullPath.c_str(), - srcFullPath.c_str()); + objFullPath, srcFullPath); } } @@ -1222,7 +1221,7 @@ void cmMakefileTargetGenerator::MakeEchoProgress( cmLocalUnixMakefileGenerator3::EchoProgress& progress) const { progress.Dir = this->LocalGenerator->GetBinaryDirectory(); - progress.Dir += cmake::GetCMakeFilesDirectory(); + progress.Dir += "/CMakeFiles"; std::ostringstream progressArg; progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")"; progress.Arg = progressArg.str(); @@ -1249,7 +1248,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( *this->BuildFileStream << " " << lineContinue << "\n"; *this->BuildFileStream << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( - obj.c_str(), useWatcomQuote); + obj, useWatcomQuote); } *this->BuildFileStream << "\n"; @@ -1272,7 +1271,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( *this->BuildFileStream << " " << lineContinue << "\n"; *this->BuildFileStream << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( - obj.c_str(), useWatcomQuote); + obj, useWatcomQuote); } *this->BuildFileStream << "\n" << "\n"; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 8f6a23a..0d05782 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -31,7 +31,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" class cmCustomCommand; @@ -718,8 +717,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule()); const std::string rspfile = this->ConvertToNinjaPath( - std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + - genTarget.GetName() + ".rsp"); + std::string("CMakeFiles/") + genTarget.GetName() + ".rsp"); // Gather order-only dependencies. cmNinjaDeps orderOnlyDeps; @@ -1004,8 +1002,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } const std::string rspfile = this->ConvertToNinjaPath( - std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + gt.GetName() + - ".rsp"); + std::string("CMakeFiles/") + gt.GetName() + ".rsp"); // Gather order-only dependencies. cmNinjaDeps orderOnlyDeps; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c959a04..edb0ef3 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -919,7 +919,12 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } vars["SWIFT_AUXILIARY_SOURCES"] = aux_sources; - vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName(); + if (const char* name = + this->GeneratorTarget->GetProperty("SWIFT_MODULE_NAME")) { + vars["SWIFT_MODULE_NAME"] = name; + } else { + vars["SWIFT_MODULE_NAME"] = this->GeneratorTarget->GetName(); + } } if (!this->NeedDepTypeMSVC(language)) { diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index cc6d4b9..5057dc4 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -14,7 +14,6 @@ #include "cmSourceFile.h" #include "cmStateTypes.h" #include "cmSystemTools.h" -#include "cmake.h" #include <algorithm> #include <iterator> @@ -35,7 +34,7 @@ void cmNinjaUtilityTargetGenerator::Generate() { std::string utilCommandName = this->GetLocalGenerator()->GetCurrentBinaryDirectory(); - utilCommandName += cmake::GetCMakeFilesDirectory(); + utilCommandName += "/CMakeFiles"; utilCommandName += "/"; utilCommandName += this->GetTargetName() + ".util"; utilCommandName = this->ConvertToNinjaPath(utilCommandName); diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index ab1e699..ff1e027 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -194,7 +194,7 @@ protected: message += includeFile; message += " for file "; message += info->FullPath; - cmSystemTools::Error(message.c_str(), nullptr); + cmSystemTools::Error(message); } continue; } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 47f7d73..e0795d2 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -26,7 +26,6 @@ #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include "cmake.h" #include "cmsys/FStream.hxx" #include "cmsys/SystemInformation.hxx" @@ -111,7 +110,7 @@ static bool AddToSourceGroup(cmMakefile* makefile, std::string const& fileName, ost << ": " << property; ost << ": Could not find or create the source group "; ost << cmQtAutoGen::Quoted(groupName); - cmSystemTools::Error(ost.str().c_str()); + cmSystemTools::Error(ost.str()); return false; } } @@ -352,7 +351,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Info directory this->Dir.Info = cbd; - this->Dir.Info += cmake::GetCMakeFilesDirectory(); + this->Dir.Info += "/CMakeFiles"; this->Dir.Info += '/'; this->Dir.Info += this->Target->GetName(); this->Dir.Info += "_autogen"; @@ -941,7 +940,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (!qrc.Generated) { std::string error; if (!RccListInputs(qrc.QrcFile, qrc.Resources, error)) { - cmSystemTools::Error(error.c_str()); + cmSystemTools::Error(error); return false; } } @@ -1219,7 +1218,7 @@ bool cmQtAutoGenInitializer::SetupCustomTargets() if (!cmSystemTools::MakeDirectory(this->Dir.Info)) { std::string emsg = ("AutoGen: Could not create directory: "); emsg += Quoted(this->Dir.Info); - cmSystemTools::Error(emsg.c_str()); + cmSystemTools::Error(emsg); return false; } @@ -1307,7 +1306,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } else { std::string err = "AutoGen: Could not write file "; err += this->AutogenTarget.InfoFile; - cmSystemTools::Error(err.c_str()); + cmSystemTools::Error(err); return false; } @@ -1347,7 +1346,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() } else { std::string err = "AutoRcc: Could not write file "; err += qrc.InfoFile; - cmSystemTools::Error(err.c_str()); + cmSystemTools::Error(err); return false; } } @@ -1512,7 +1511,7 @@ std::pair<bool, std::string> GetQtExecutable( msg += target->GetName(); msg += "): "; msg += err; - cmSystemTools::Error(msg.c_str()); + cmSystemTools::Error(msg); return std::make_pair(false, ""); } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d4d3df5..fdd7b3d 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -545,10 +545,10 @@ const char* cmState::GetGlobalProperty(const std::string& prop) } #define STRING_LIST_ELEMENT(F) ";" #F if (prop == "CMAKE_C_KNOWN_FEATURES") { - return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1; + return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1]; } if (prop == "CMAKE_CXX_KNOWN_FEATURES") { - return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; + return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1]; } #undef STRING_LIST_ELEMENT return this->GlobalProperties.GetPropertyValue(prop); diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index a4305e6..63bec71 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -16,7 +16,6 @@ #include "cmStateDirectory.h" #include "cmStatePrivate.h" #include "cmVersion.h" -#include "cmake.h" #if !defined(_WIN32) # include <sys/utsname.h> @@ -348,8 +347,7 @@ void cmStateSnapshot::SetDefaultDefinitions() std::to_string(cmVersion::GetTweakVersion())); this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); - this->SetDefinition("CMAKE_FILES_DIRECTORY", - cmake::GetCMakeFilesDirectory()); + this->SetDefinition("CMAKE_FILES_DIRECTORY", "/CMakeFiles"); // Setup the default include file regular expression (match everything). this->Position->BuildSystemDirectory->Properties.SetProperty( diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9abc5f3..a16460f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -270,6 +270,13 @@ void cmSystemTools::Error(const char* m1, const char* m2, const char* m3, cmSystemTools::Message(message.c_str(), "Error"); } +void cmSystemTools::Error(const std::string& m) +{ + std::string message = "CMake Error: " + m; + cmSystemTools::s_ErrorOccured = true; + cmSystemTools::Message(message.c_str(), "Error"); +} + void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData) { s_InterruptCallback = f; @@ -338,7 +345,7 @@ void cmSystemTools::ReportLastSystemError(const char* msg) std::string m = msg; m += ": System Error: "; m += Superclass::GetLastSystemError(); - cmSystemTools::Error(m.c_str()); + cmSystemTools::Error(m); } bool cmSystemTools::IsInternallyOn(const char* val) @@ -549,7 +556,7 @@ std::vector<std::string> cmSystemTools::HandleResponseFile( error += cmSystemTools::GetLastSystemError(); error += "):\n "; error += arg.substr(1); - cmSystemTools::Error(error.c_str()); + cmSystemTools::Error(error); } else { std::string line; cmSystemTools::GetLineFromStream(responseFile, line); @@ -1028,7 +1035,8 @@ void cmSystemTools::InitializeLibUV() #endif } -bool cmSystemTools::RenameFile(const char* oldname, const char* newname) +bool cmSystemTools::RenameFile(const std::string& oldname, + const std::string& newname) { #ifdef _WIN32 # ifndef INVALID_FILE_ATTRIBUTES @@ -1066,7 +1074,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) return retry.Count > 0; #else /* On UNIX we have an OS-provided call to do this atomically. */ - return rename(oldname, newname) == 0; + return rename(oldname.c_str(), newname.c_str()) == 0; #endif } @@ -1651,7 +1659,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, e += outFileName; e += "\": "; e += cmSystemTools::GetLastSystemError(); - cmSystemTools::Error(e.c_str()); + cmSystemTools::Error(e); return false; } cmArchiveWrite::Compress compress = cmArchiveWrite::CompressNone; @@ -1684,7 +1692,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, } } if (!a) { - cmSystemTools::Error(a.GetError().c_str()); + cmSystemTools::Error(a.GetError()); return false; } return true; @@ -3120,7 +3128,7 @@ bool cmSystemTools::CreateSymlink(const std::string& origName, if (errorMessage) { *errorMessage = std::move(e); } else { - cmSystemTools::Error(e.c_str()); + cmSystemTools::Error(e); } return false; } @@ -3141,7 +3149,7 @@ bool cmSystemTools::CreateLink(const std::string& origName, if (errorMessage) { *errorMessage = std::move(e); } else { - cmSystemTools::Error(e.c_str()); + cmSystemTools::Error(e); } return false; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 7a209c6..b30e4f7 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -70,6 +70,7 @@ public: */ static void Error(const char* m, const char* m2 = nullptr, const char* m3 = nullptr, const char* m4 = nullptr); + static void Error(const std::string& m); /** * Display a message. @@ -179,7 +180,8 @@ public: /** Rename a file or directory within a single disk volume (atomic if possible). */ - static bool RenameFile(const char* oldname, const char* newname); + static bool RenameFile(const std::string& oldname, + const std::string& newname); ///! Compute the hash of a file static std::string ComputeFileHash(const std::string& source, diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 10a6d9a..c57aabd 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -121,7 +121,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, // now try running the command if it compiled if (!res) { if (this->OutputFile.empty()) { - cmSystemTools::Error(this->FindErrorMessage.c_str()); + cmSystemTools::Error(this->FindErrorMessage); } else { // "run" it and capture the output std::string runOutputContents; @@ -217,7 +217,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, // removed at the end of TRY_RUN and the user can run it manually // on the target platform. std::string copyDest = this->Makefile->GetHomeOutputDirectory(); - copyDest += cmake::GetCMakeFilesDirectory(); + copyDest += "/CMakeFiles"; copyDest += "/"; copyDest += cmSystemTools::GetFilenameWithoutExtension(this->OutputFile); copyDest += "-"; @@ -354,7 +354,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, errorMessage += " " + internalRunOutputName + " (advanced)\n"; } errorMessage += detailsString; - cmSystemTools::Error(errorMessage.c_str()); + cmSystemTools::Error(errorMessage); return; } diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 06ca53c..c02157a 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -57,7 +57,7 @@ bool cmVariableRequiresCommand::InitialPass( "One or more of the required variables is advanced." " To set the variable, you must turn on advanced mode in cmake."; } - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); } return true; diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 03e0059..975d6e4 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -60,7 +60,7 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable, error << "Error in cmake code at\nUnknown:0:\n" << "A command failed during the invocation of callback \"" << data->Command << "\"."; - cmSystemTools::Error(error.str().c_str()); + cmSystemTools::Error(error.str()); data->InCallback = false; return; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 914c3b0..744b8fc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -115,8 +115,10 @@ typedef std::unordered_map<std::string, Json::Value> JsonValueMapType; } // namespace -static bool cmakeCheckStampFile(const char* stampName, bool verbose = true); -static bool cmakeCheckStampList(const char* stampList, bool verbose = true); +static bool cmakeCheckStampFile(const std::string& stampName, + bool verbose = true); +static bool cmakeCheckStampList(const std::string& stampList, + bool verbose = true); void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, void* ctx, const char* /*unused*/, @@ -1172,7 +1174,7 @@ int cmake::DoPreConfigureChecks() } err << "Specify --help for usage, or press the help button on the CMake " "GUI."; - cmSystemTools::Error(err.str().c_str()); + cmSystemTools::Error(err.str()); return -2; } @@ -1190,7 +1192,7 @@ int cmake::DoPreConfigureChecks() message += cacheStart; message += "\" used to generate cache. "; message += "Re-run cmake with a different source directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1400,7 +1402,7 @@ int cmake::ActualConfigure() message += *genName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } @@ -1424,7 +1426,7 @@ int cmake::ActualConfigure() message += *instance; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1443,7 +1445,7 @@ int cmake::ActualConfigure() message += *platformName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1461,7 +1463,7 @@ int cmake::ActualConfigure() message += *tsName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; - cmSystemTools::Error(message.c_str()); + cmSystemTools::Error(message); return -2; } } else { @@ -1629,13 +1631,13 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) // If we are given a stamp list file check if it is really out of date. if (!this->CheckStampList.empty() && - cmakeCheckStampList(this->CheckStampList.c_str())) { + cmakeCheckStampList(this->CheckStampList)) { return 0; } // If we are given a stamp file check if it is really out of date. if (!this->CheckStampFile.empty() && - cmakeCheckStampFile(this->CheckStampFile.c_str())) { + cmakeCheckStampFile(this->CheckStampFile)) { return 0; } @@ -2416,7 +2418,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) return 0; } -static bool cmakeCheckStampFile(const char* stampName, bool verbose) +static bool cmakeCheckStampFile(const std::string& stampName, bool verbose) { // The stamp file does not exist. Use the stamp dependencies to // determine whether it is really out of date. This works in @@ -2461,12 +2463,11 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose) // by the VS IDE due to a "rebuild" request. Restore it atomically. std::ostringstream stampTempStream; stampTempStream << stampName << ".tmp" << cmSystemTools::RandomSeed(); - std::string stampTempString = stampTempStream.str(); - const char* stampTemp = stampTempString.c_str(); + std::string stampTemp = stampTempStream.str(); { // TODO: Teach cmGeneratedFileStream to use a random temp file (with // multiple tries in unlikely case of conflict) and use that here. - cmsys::ofstream stamp(stampTemp); + cmsys::ofstream stamp(stampTemp.c_str()); stamp << "# CMake generation timestamp file for this directory.\n"; } if (cmSystemTools::RenameFile(stampTemp, stampName)) { @@ -2480,11 +2481,11 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose) return true; } cmSystemTools::RemoveFile(stampTemp); - cmSystemTools::Error("Cannot restore timestamp ", stampName); + cmSystemTools::Error("Cannot restore timestamp ", stampName.c_str()); return false; } -static bool cmakeCheckStampList(const char* stampList, bool verbose) +static bool cmakeCheckStampList(const std::string& stampList, bool verbose) { // If the stamp list does not exist CMake must rerun to generate it. if (!cmSystemTools::FileExists(stampList)) { @@ -2492,7 +2493,7 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose) << "is missing.\n"; return false; } - cmsys::ifstream fin(stampList); + cmsys::ifstream fin(stampList.c_str()); if (!fin) { std::cout << "CMake is re-running because generate.stamp.list " << "could not be read.\n"; @@ -2502,7 +2503,7 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose) // Check each stamp. std::string stampName; while (cmSystemTools::GetLineFromStream(fin, stampName)) { - if (!cmakeCheckStampFile(stampName.c_str(), verbose)) { + if (!cmakeCheckStampFile(stampName, verbose)) { return false; } } @@ -2604,8 +2605,7 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target, // actually starting the build. If not done separately from the build // itself, there is the risk of building an out-of-date solution file due // to limitations of the underlying build system. - std::string const stampList = cachePath + "/" + - GetCMakeFilesDirectoryPostSlash() + + std::string const stampList = cachePath + "/" + "CMakeFiles/" + cmGlobalVisualStudio9Generator::GetGenerateStampList(); // Note that the stampList file only exists for VS generators. @@ -2615,15 +2615,15 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target, // the glob verification script before starting the build this->AddScriptingCommands(); if (this->GlobalGenerator->MatchesGeneratorName("Visual Studio 9 2008")) { - std::string const globVerifyScript = cachePath + "/" + - GetCMakeFilesDirectoryPostSlash() + "VerifyGlobs.cmake"; + std::string const globVerifyScript = + cachePath + "/" + "CMakeFiles/" + "VerifyGlobs.cmake"; if (cmSystemTools::FileExists(globVerifyScript)) { std::vector<std::string> args; this->ReadListFile(args, globVerifyScript.c_str()); } } - if (!cmakeCheckStampList(stampList.c_str(), false)) { + if (!cmakeCheckStampList(stampList, false)) { // Correctly initialize the home (=source) and home output (=binary) // directories, which is required for running the generation step. std::string homeOrig = this->GetHomeDirectory(); diff --git a/Source/cmake.h b/Source/cmake.h index 9478ad0e..0f53d28 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -125,12 +125,6 @@ public: #endif std::string ReportCapabilities(bool haveServerMode) const; - static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; } - static const char* GetCMakeFilesDirectoryPostSlash() - { - return "CMakeFiles/"; - } - //@{ /** * Set/Get the home directory (or output directory) in the project. The diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 26f7509..ce3691d 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -123,7 +123,7 @@ void CMakeCommandUsage(const char* program) ; /* clang-format on */ - cmSystemTools::Error(errorStream.str().c_str()); + cmSystemTools::Error(errorStream.str()); } static bool cmTarFilesFrom(std::string const& file, @@ -132,14 +132,14 @@ static bool cmTarFilesFrom(std::string const& file, if (cmSystemTools::FileIsDirectory(file)) { std::ostringstream e; e << "-E tar --files-from= file '" << file << "' is a directory"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } cmsys::ifstream fin(file.c_str()); if (!fin) { std::ostringstream e; e << "-E tar --files-from= file '" << file << "' not found"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } std::string line; @@ -153,7 +153,7 @@ static bool cmTarFilesFrom(std::string const& file, std::ostringstream e; e << "-E tar --files-from='" << file << "' file invalid line:\n" << line << "\n"; - cmSystemTools::Error(e.str().c_str()); + cmSystemTools::Error(e.str()); return false; } else { files.push_back(line); @@ -530,7 +530,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Rename a file or directory if (args[1] == "rename" && args.size() == 4) { - if (!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) { + if (!cmSystemTools::RenameFile(args[2], args[3])) { std::string e = cmSystemTools::GetLastSystemError(); std::cerr << "Error renaming from \"" << args[2] << "\" to \"" << args[3] << "\": " << e << "\n"; @@ -964,8 +964,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mf)); // Actually scan dependencies. - return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0 - : 2; + return lgd->UpdateDependencies(depInfo, verbose, color) ? 0 : 2; } return 1; } @@ -1173,7 +1172,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (server.Serve(&errorMessage)) { return 0; } - cmSystemTools::Error(errorMessage.c_str()); + cmSystemTools::Error(errorMessage); #else static_cast<void>(supportExperimental); static_cast<void>(isDebug); diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index a2fcc16..b33aa80 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -454,6 +454,10 @@ ELSE() SET(KWSYS_LIBRARY_TYPE STATIC) ENDIF() +if(NOT DEFINED KWSYS_BUILD_PIC) + set(KWSYS_BUILD_PIC 0) +endif() + #----------------------------------------------------------------------------- # Configure some implementation details. @@ -870,7 +874,7 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) SET(KWSYS_LINK_DEPENDENCY INTERFACE) ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) - IF(KWSYS_BUILD_SHARED) + IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC) SET_PROPERTY(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY POSITION_INDEPENDENT_CODE TRUE) ENDIF() @@ -965,7 +969,7 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) ${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK}) SET(KWSYS_LINK_DEPENDENCY INTERFACE) ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS}) - IF(KWSYS_BUILD_SHARED) + IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC) SET_PROPERTY(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY POSITION_INDEPENDENT_CODE TRUE) ENDIF() diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index c5160a9..cbdfe11 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2161,6 +2161,32 @@ bool SystemTools::FilesDiffer(const std::string& source, return false; } +bool SystemTools::TextFilesDiffer(const std::string& path1, + const std::string& path2) +{ + kwsys::ifstream if1(path1.c_str()); + kwsys::ifstream if2(path2.c_str()); + if (!if1 || !if2) { + return true; + } + + for (;;) { + std::string line1, line2; + bool hasData1 = GetLineFromStream(if1, line1); + bool hasData2 = GetLineFromStream(if2, line2); + if (hasData1 != hasData2) { + return true; + } + if (!hasData1) { + break; + } + if (line1 != line2) { + return true; + } + } + return false; +} + /** * Blockwise copy source to destination file */ @@ -2979,10 +3005,36 @@ bool SystemTools::FileIsDirectory(const std::string& inName) bool SystemTools::FileIsSymlink(const std::string& name) { #if defined(_WIN32) - DWORD attr = - GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str()); + std::wstring path = Encoding::ToWindowsExtendedPath(name); + DWORD attr = GetFileAttributesW(path.c_str()); if (attr != INVALID_FILE_ATTRIBUTES) { - return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { + // FILE_ATTRIBUTE_REPARSE_POINT means: + // * a file or directory that has an associated reparse point, or + // * a file that is a symbolic link. + HANDLE hFile = CreateFileW( + path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + return false; + } + byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + DWORD bytesReturned = 0; + if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer, + MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned, + NULL)) { + CloseHandle(hFile); + // Since FILE_ATTRIBUTE_REPARSE_POINT is set this file must be + // a symbolic link if it is not a reparse point. + return GetLastError() == ERROR_NOT_A_REPARSE_POINT; + } + CloseHandle(hFile); + ULONG reparseTag = + reinterpret_cast<PREPARSE_GUID_DATA_BUFFER>(&buffer[0])->ReparseTag; + return (reparseTag == IO_REPARSE_TAG_SYMLINK) || + (reparseTag == IO_REPARSE_TAG_MOUNT_POINT); + } + return false; } else { return false; } diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 8d1f78c..1967860 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -579,6 +579,13 @@ public: const std::string& destination); /** + * Compare the contents of two files, ignoring line ending differences. + * Return true if different + */ + static bool TextFilesDiffer(const std::string& path1, + const std::string& path2); + + /** * Return true if the two files are the same file */ static bool SameFile(const std::string& file1, const std::string& file2); diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 0477d59..9a40b53 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -984,6 +984,50 @@ static bool CheckGetLineFromStreamLongLine() return true; } +static bool writeFile(const char* fileName, const char* data) +{ + kwsys::ofstream out(fileName, std::ios::binary); + out << data; + if (!out) { + std::cerr << "Failed to write file: " << fileName << std::endl; + return false; + } + return true; +} + +static bool CheckTextFilesDiffer() +{ + struct + { + const char* a; + const char* b; + bool differ; + } test_cases[] = { { "one", "one", false }, + { "one", "two", true }, + { "", "", false }, + { "\n", "\r\n", false }, + { "one\n", "one\n", false }, + { "one\r\n", "one\n", false }, + { "one\n", "one", false }, + { "one\ntwo", "one\ntwo", false }, + { "one\ntwo", "one\r\ntwo", false } }; + const int num_test_cases = sizeof(test_cases) / sizeof(test_cases[0]); + for (int i = 0; i < num_test_cases; ++i) { + if (!writeFile("file_a", test_cases[i].a) || + !writeFile("file_b", test_cases[i].b)) { + return false; + } + if (kwsys::SystemTools::TextFilesDiffer("file_a", "file_b") != + test_cases[i].differ) { + std::cerr << "Incorrect TextFilesDiffer result for test case " << i + 1 + << "." << std::endl; + return false; + } + } + + return true; +} + int testSystemTools(int, char* []) { bool res = true; @@ -1027,5 +1071,7 @@ int testSystemTools(int, char* []) res &= CheckGetFilenameName(); + res &= CheckTextFilesDiffer(); + return res ? 0 : 1; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c1703cc..0c6eabc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1558,7 +1558,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindXercesC) endif() - if(CMake_TEST_FindPython) + if(CMake_TEST_FindPython OR CMake_TEST_FindPython_NumPy) add_subdirectory(FindPython) endif() diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index 639d29c..38211a4 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -1,69 +1,94 @@ -add_test(NAME FindPython.Python2 COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2" - ${build_generator_args} - --build-project TestPython2 - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) +if(CMake_TEST_FindPython) + add_test(NAME FindPython.Python2 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2" + ${build_generator_args} + --build-project TestPython2 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) -add_test(NAME FindPython.Python2Fail COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Fail" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2Fail" - ${build_generator_args} - --build-project TestPython2Fail - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -set_tests_properties(FindPython.Python2Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") + add_test(NAME FindPython.Python2Fail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Fail" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2Fail" + ${build_generator_args} + --build-project TestPython2Fail + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + set_tests_properties(FindPython.Python2Fail PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") -add_test(NAME FindPython.Python3 COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3" - ${build_generator_args} - --build-project TestPython3 - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) + add_test(NAME FindPython.Python3 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3" + ${build_generator_args} + --build-project TestPython3 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) -add_test(NAME FindPython.Python3Fail COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Fail" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3Fail" - ${build_generator_args} - --build-project TestPython3Fail - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -set_tests_properties(FindPython.Python3Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") + add_test(NAME FindPython.Python3Fail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Fail" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3Fail" + ${build_generator_args} + --build-project TestPython3Fail + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + set_tests_properties(FindPython.Python3Fail PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") -add_test(NAME FindPython.Python COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) + add_test(NAME FindPython.Python COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + add_test(NAME FindPython.MultiplePackages COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" + "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" + ${build_generator_args} + --build-project TestMultiplePackages + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +endif() -add_test(NAME FindPython.MultiplePackages COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" - "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" - ${build_generator_args} - --build-project TestMultiplePackages - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> +if(CMake_TEST_FindPython_NumPy) + add_test(NAME FindPython.NumPy COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/NumPy" + "${CMake_BINARY_DIR}/Tests/FindPython/NumPy" + ${build_generator_args} + --build-project TestNumPy + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.NumPyOnly COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/NumPyOnly" + "${CMake_BINARY_DIR}/Tests/FindPython/NumPyOnly" + ${build_generator_args} + --build-project TestNumPyOnly + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + endif() diff --git a/Tests/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake new file mode 100644 index 0000000..9450092 --- /dev/null +++ b/Tests/FindPython/FindPythonScript.cmake @@ -0,0 +1 @@ +find_package(${PYTHON_PACKAGE_NAME} REQUIRED QUIET) diff --git a/Tests/FindPython/NumPy/CMakeLists.txt b/Tests/FindPython/NumPy/CMakeLists.txt new file mode 100644 index 0000000..f557026 --- /dev/null +++ b/Tests/FindPython/NumPy/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestNumPy C) + +find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy) +find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy) + +Python2_add_library (arraytest2 MODULE arraytest.c) +target_compile_definitions (arraytest2 PRIVATE PYTHON2) +target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + +Python3_add_library (arraytest3 MODULE arraytest.c) +target_compile_definitions (arraytest3 PRIVATE PYTHON3) +target_link_libraries (arraytest3 PRIVATE Python3::NumPy) + +add_test (NAME python2_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>" + "${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));") + +add_test (NAME python3_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>" + "${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));") diff --git a/Tests/FindPython/NumPy/arraytest.c b/Tests/FindPython/NumPy/arraytest.c new file mode 100644 index 0000000..135877d --- /dev/null +++ b/Tests/FindPython/NumPy/arraytest.c @@ -0,0 +1,58 @@ +#include "Python.h" + +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include "arrayobject.h" + +#include <math.h> + +static PyObject* vecsq(PyObject* self, PyObject* args); + +static PyMethodDef arraytestMethods[] = { { "vecsq", vecsq, METH_VARARGS }, + { NULL, NULL } }; + +static PyObject* vecsq(PyObject* self, PyObject* args) +{ + PyArrayObject *vecin, *vecout; + npy_intp dims[2]; + double *cin, *cout; + int i, j, n, m; + + if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &vecin)) + return NULL; + + n = dims[0] = PyArray_NDIM(vecin); + vecout = (PyArrayObject*)PyArray_SimpleNew(1, dims, NPY_DOUBLE); + + cin = (double*)PyArray_DATA(vecin); + cout = (double*)PyArray_DATA(vecout); + + for (i = 0; i < n; i++) { + cout[i] = cin[i] * cin[i]; + } + return PyArray_Return(vecout); +} + +#if defined(PYTHON2) +PyMODINIT_FUNC init_C_arraytest(void) +{ + (void)Py_InitModule("arraytest2", arraytestMethods); + import_array(); +} +#endif + +#if defined(PYTHON3) +static struct PyModuleDef arraytestmodule = { + PyModuleDef_HEAD_INIT, "arraytest3", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + arraytestMethods +}; + +PyMODINIT_FUNC PyInit_C_arraytest(void) +{ + PyObject* po = PyModule_Create(&arraytestmodule); + import_array(); + return po; +} +#endif diff --git a/Tests/FindPython/NumPyOnly/CMakeLists.txt b/Tests/FindPython/NumPyOnly/CMakeLists.txt new file mode 100644 index 0000000..a5db603 --- /dev/null +++ b/Tests/FindPython/NumPyOnly/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestNumPyOnly C) + +find_package(Python2 REQUIRED COMPONENTS NumPy) +find_package(Python3 REQUIRED COMPONENTS NumPy) + +Python2_add_library (arraytest2 MODULE ../NumPy/arraytest.c) +target_compile_definitions (arraytest2 PRIVATE PYTHON2) +target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + +Python3_add_library (arraytest3 MODULE ../NumPy/arraytest.c) +target_compile_definitions (arraytest3 PRIVATE PYTHON3) +target_link_libraries (arraytest3 PRIVATE Python3::NumPy) diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt index bebd23f..f7fc243 100644 --- a/Tests/FindPython/Python/CMakeLists.txt +++ b/Tests/FindPython/Python/CMakeLists.txt @@ -9,9 +9,21 @@ if (NOT Python_FOUND) message (FATAL_ERROR "Fail to found Python 3") endif() +if(NOT TARGET Python::Interpreter) + message(SEND_ERROR "Python::Interpreter not found") +endif() + +if(NOT TARGET Python::Python) + message(SEND_ERROR "Python::Python not found") +endif() + Python_add_library (spam3 MODULE ../spam.c) target_compile_definitions (spam3 PRIVATE PYTHON3) add_test (NAME python_spam3 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" "${Python_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") + +add_test(NAME findpython_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python + -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt index 9622b6f..a0753f6 100644 --- a/Tests/FindPython/Python2/CMakeLists.txt +++ b/Tests/FindPython/Python2/CMakeLists.txt @@ -14,9 +14,21 @@ if (NOT Python2_FOUND) message (FATAL_ERROR "Fail to found Python 2") endif() +if(NOT TARGET Python2::Interpreter) + message(SEND_ERROR "Python2::Interpreter not found") +endif() + +if(NOT TARGET Python2::Python) + message(SEND_ERROR "Python2::Python not found") +endif() + Python2_add_library (spam2 MODULE ../spam.c) target_compile_definitions (spam2 PRIVATE PYTHON2) add_test (NAME python2_spam2 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>" "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") + +add_test(NAME findpython2_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python2 + -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt index cb86eae..65eea4c 100644 --- a/Tests/FindPython/Python3/CMakeLists.txt +++ b/Tests/FindPython/Python3/CMakeLists.txt @@ -14,9 +14,21 @@ if (NOT Python3_FOUND) message (FATAL_ERROR "Fail to found Python 3") endif() +if(NOT TARGET Python3::Interpreter) + message(SEND_ERROR "Python2::Interpreter not found") +endif() + +if(NOT TARGET Python3::Python) + message(SEND_ERROR "Python2::Python not found") +endif() + Python3_add_library (spam3 MODULE ../spam.c) target_compile_definitions (spam3 PRIVATE PYTHON3) add_test (NAME python3_spam3 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") + +add_test(NAME findpython3_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3 + -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index bf18efe..e6c90b4 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -215,6 +215,7 @@ endif() add_RunCMake_test(CompatibleInterface) add_RunCMake_test(Syntax) add_RunCMake_test(WorkingDirectory) +add_RunCMake_test(MaxRecursionDepth) add_RunCMake_test(add_custom_command) add_RunCMake_test(add_custom_target) diff --git a/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt new file mode 100644 index 0000000..d2cd86d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) +if(DEFINED CMAKE_GENERATOR) + project(${RunCMake_TEST} NONE) +endif() +include("${CMAKE_CURRENT_LIST_DIR}/${TEST_NAME}.cmake") diff --git a/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in new file mode 100644 index 0000000..fee3eda --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.12) +project(MaxRecursionDepth NONE) diff --git a/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake b/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake new file mode 100644 index 0000000..354bc7a --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +ctest_read_custom_files("${CMAKE_CURRENT_LIST_DIR}") diff --git a/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake b/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake new file mode 100644 index 0000000..3cbb99e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +find_package(RecursivePackage) diff --git a/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake b/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake new file mode 100644 index 0000000..c5a859d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake @@ -0,0 +1,49 @@ +include(RunCMake) +include(RunCTest) + +function(run_cmake_recursive name) + set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name}) + run_cmake(${name}-default) + unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) + run_cmake(${name}-var) + unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a) + run_cmake(${name}-invalid-var) + unset(RunCMake_TEST_OPTIONS) + + run_cmake_command(${name}-default-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt") + run_cmake_command(${name}-var-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10 -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt") + run_cmake_command(${name}-invalid-var-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt") +endfunction() + +function(run_ctest_recursive name) + run_ctest(${name}-default "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name}) + run_ctest(${name}-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) + run_ctest(${name}-invalid-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a) +endfunction() + +run_cmake_recursive(function) +run_cmake_recursive(macro) +run_cmake_recursive(include) +run_cmake_recursive(find_package) +run_cmake_recursive(variable_watch) + +# We run these tests separately and only with a small limit because they are +# taxing and slow. The "implicit" and "invalid" cases are already thoroughly +# covered by the other tests above. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=add_subdirectory -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) +run_cmake(add_subdirectory-var) +unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=try_compile -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) +run_cmake(try_compile-var) +unset(RunCMake_TEST_OPTIONS) + +run_ctest_recursive(ctest_read_custom_files) + +# We run the ctest_run_script() test separately and only with an explicit limit +# because ctest_run_script() is taxing and slow, and because the implicit +# recursion limit is hit by CTestScriptMode.cmake before we can test it +# properly. The "implicit" and "invalid" cases are already thoroughly covered +# by the other tests above. +run_ctest(ctest_run_script-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=ctest_run_script -DCMAKE_MAXIMUM_RECURSION_DEPTH=10) diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt new file mode 100644 index 0000000..23fb5c6 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt @@ -0,0 +1,10 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at add_subdirectory/CMakeLists\.txt:1 \(message\): + Maximum recursion depth of 10 exceeded$ diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake new file mode 100644 index 0000000..36c21f3 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake @@ -0,0 +1,2 @@ +set(x 3) +add_subdirectory(add_subdirectory) diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt new file mode 100644 index 0000000..a8244af --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +add_subdirectory(. dir) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt new file mode 100644 index 0000000..7dbbb3e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt new file mode 100644 index 0000000..7dbbb3e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt new file mode 100644 index 0000000..bc89703 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt @@ -0,0 +1,34 @@ +^2 +3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\) + .*/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var/test\.cmake:10 \(ctest_read_custom_files\) + + +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake +Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake$ diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt new file mode 100644 index 0000000..b10b26d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt @@ -0,0 +1,51 @@ +^2 +3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_11\.cmake:1 \(cmake_minimum_required\): + Maximum recursion depth of 10 exceeded + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_10\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_9\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_8\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_7\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_6\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_5\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_4\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_3\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_2\.cmake:13 \(message\): + Nested script failed + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var/test\.cmake:19 \(message\): + Nested script failed$ diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in new file mode 100644 index 0000000..d4f28c4 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.12) +set(CTEST_RUN_CURRENT_SCRIPT 0) + +message("@LEVEL_CURRENT@") + +set(CTEST_SOURCE_DIRECTORY "@CTEST_SOURCE_DIRECTORY@") +set(CTEST_BINARY_DIRECTORY "@CTEST_BINARY_DIRECTORY@") +set(CTEST_COMMAND "@CTEST_COMMAND@") + +ctest_run_script("${CMAKE_CURRENT_LIST_DIR}/ctest_run_script_@LEVEL_NEXT@.cmake" RETURN_VALUE val) + +if(NOT val EQUAL 0) + message(FATAL_ERROR "Nested script failed") +endif() diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt new file mode 100644 index 0000000..b8557ab --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt new file mode 100644 index 0000000..5d31e29 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt new file mode 100644 index 0000000..b8557ab --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt new file mode 100644 index 0000000..5d31e29 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + FindRecursivePackage\.cmake:3 \(find_package\) diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt new file mode 100644 index 0000000..5314551 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/FindRecursivePackage\.cmake:3 \(find_package\) + .*/find_package\.cmake:2 \(find_package\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt new file mode 100644 index 0000000..b47a13a --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at FindRecursivePackage\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + FindRecursivePackage\.cmake:3 \(find_package\) + find_package\.cmake:2 \(find_package\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package.cmake b/Tests/RunCMake/MaxRecursionDepth/find_package.cmake new file mode 100644 index 0000000..a235f7d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/find_package.cmake @@ -0,0 +1,2 @@ +set(x 3) +find_package(RecursivePackage) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt new file mode 100644 index 0000000..92de1fb --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt new file mode 100644 index 0000000..5c25c4b --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt new file mode 100644 index 0000000..92de1fb --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt new file mode 100644 index 0000000..5c25c4b --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at function\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + function\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt new file mode 100644 index 0000000..61304b1 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/function\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:4 \(recursive\) + .*/function\.cmake:7 \(recursive\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt new file mode 100644 index 0000000..54e72af --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at function\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:4 \(recursive\) + function\.cmake:7 \(recursive\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/function.cmake b/Tests/RunCMake/MaxRecursionDepth/function.cmake new file mode 100644 index 0000000..581cb89 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/function.cmake @@ -0,0 +1,7 @@ +function(recursive x) + message("${x}") + math(EXPR y "${x} + 1") + recursive(${y}) +endfunction() + +recursive(3) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt new file mode 100644 index 0000000..0510e7c --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt new file mode 100644 index 0000000..b1494a8 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt new file mode 100644 index 0000000..0510e7c --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt new file mode 100644 index 0000000..b1494a8 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at include_recursive\.cmake:1 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + include_recursive\.cmake:3 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt new file mode 100644 index 0000000..f55f505 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/include_recursive\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include_recursive\.cmake:3 \(include\) + .*/include\.cmake:2 \(include\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt new file mode 100644 index 0000000..ff33985 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at include_recursive\.cmake:1 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include_recursive\.cmake:3 \(include\) + include\.cmake:2 \(include\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/include.cmake b/Tests/RunCMake/MaxRecursionDepth/include.cmake new file mode 100644 index 0000000..5e86a40 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include.cmake @@ -0,0 +1,2 @@ +set(x 3) +include("${CMAKE_CURRENT_LIST_DIR}/include_recursive.cmake") diff --git a/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake b/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake new file mode 100644 index 0000000..b3f744e --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake @@ -0,0 +1,3 @@ +message("${x}") +math(EXPR x "${x} + 1") +include("${CMAKE_CURRENT_LIST_FILE}") diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt new file mode 100644 index 0000000..c67be57 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt new file mode 100644 index 0000000..0b27162 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt new file mode 100644 index 0000000..c67be57 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at .*/macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt new file mode 100644 index 0000000..0b27162 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt @@ -0,0 +1,5 @@ +[0-9]+ +CMake Error at macro\.cmake:2 \(message\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + macro\.cmake:4 \(recursive\) diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt new file mode 100644 index 0000000..142e068 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/macro\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:4 \(recursive\) + .*/macro\.cmake:7 \(recursive\) + .*/CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt new file mode 100644 index 0000000..71de553 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt @@ -0,0 +1,21 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at macro\.cmake:2 \(message\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:4 \(recursive\) + macro\.cmake:7 \(recursive\) + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/macro.cmake b/Tests/RunCMake/MaxRecursionDepth/macro.cmake new file mode 100644 index 0000000..a7cbfc2 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/macro.cmake @@ -0,0 +1,7 @@ +macro(recursive x) + message("${x}") + math(EXPR y "${x} + 1") + recursive(${y}) +endmacro() + +recursive(3) diff --git a/Tests/RunCMake/MaxRecursionDepth/test.cmake.in b/Tests/RunCMake/MaxRecursionDepth/test.cmake.in new file mode 100644 index 0000000..fd1fc10 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/test.cmake.in @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.12) +set(CTEST_RUN_CURRENT_SCRIPT 0) + +set(CTEST_SOURCE_DIRECTORY "@RunCMake_SOURCE_DIR@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@") +set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}") + +if(TEST_NAME STREQUAL "ctest_read_custom_files") + set(x 2) + ctest_read_custom_files("@RunCMake_SOURCE_DIR@") +elseif(TEST_NAME STREQUAL "ctest_run_script") + foreach(LEVEL_CURRENT RANGE 2 15) + math(EXPR LEVEL_NEXT "${LEVEL_CURRENT} + 1") + configure_file("@RunCMake_SOURCE_DIR@/ctest_run_script.cmake.in" "@RunCMake_BINARY_DIR@/ctest_run_script_${LEVEL_CURRENT}.cmake" @ONLY) + endforeach() + + ctest_run_script("@RunCMake_BINARY_DIR@/ctest_run_script_2.cmake" RETURN_VALUE val) + if(NOT val EQUAL 0) + message(FATAL_ERROR "Nested script failed") + endif() +endif() diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt new file mode 100644 index 0000000..130db34 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt @@ -0,0 +1,48 @@ +^3 +4 +5 +6 +7 +8 +9 +10 +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:1 \(cmake_minimum_required\): + Maximum recursion depth of 10 exceeded + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\): + Failed to configure test project build system\. + + +CMake Error at try_compile\.cmake:1 \(try_compile\): + Failed to configure test project build system\. +Call Stack \(most recent call first\): + CMakeLists\.txt:5 \(include\)$ diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake b/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake new file mode 100644 index 0000000..c40fb06 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake @@ -0,0 +1,6 @@ +try_compile(result + "${CMAKE_CURRENT_BINARY_DIR}/try_compile" + "${CMAKE_CURRENT_SOURCE_DIR}/try_compile" + try_compile + CMAKE_FLAGS -Dx:STRING=3 + ) diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt new file mode 100644 index 0000000..2271090 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.12) + +message("${x}") +math(EXPR x "${x} + 1") +try_compile(result + "${CMAKE_CURRENT_BINARY_DIR}/try_compile" + "${CMAKE_CURRENT_SOURCE_DIR}" + try_compile + CMAKE_FLAGS -Dx:STRING=${x} + ) + +# We put this last to avoid prematurely triggering the recursion limit +project(try_compile NONE) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt new file mode 100644 index 0000000..4dddc96 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt new file mode 100644 index 0000000..a8b4756 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt new file mode 100644 index 0000000..4dddc96 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt new file mode 100644 index 0000000..a8b4756 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt @@ -0,0 +1,6 @@ +[0-9]+ +CMake Error at variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of [0-9]+ exceeded +Call Stack \(most recent call first\): + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt new file mode 100644 index 0000000..00b2b3c --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt @@ -0,0 +1,22 @@ +^4 +6 +8 +10 +CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:5 \(set\) + .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:9 \(set\) + .*/CMakeLists\.txt:5 \(include\) + + +CMake Error: Error in cmake code at +Unknown:0: +A command failed during the invocation of callback "update_x"\.$ diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt new file mode 100644 index 0000000..8f27bf1 --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt @@ -0,0 +1,22 @@ +^4 +6 +8 +10 +CMake Error at variable_watch\.cmake:9999 \(update_x\): + Maximum recursion depth of 10 exceeded +Call Stack \(most recent call first\): + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:5 \(set\) + variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:9 \(set\) + CMakeLists\.txt:5 \(include\) + + +CMake Error: Error in cmake code at +Unknown:0: +A command failed during the invocation of callback "update_x"\.$ diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake b/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake new file mode 100644 index 0000000..b3c7b8d --- /dev/null +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake @@ -0,0 +1,9 @@ +function(update_x) + message("${x}") + math(EXPR y "${x} + 2") + variable_watch(x update_x) + set(x "${y}") +endfunction() + +variable_watch(x update_x) +set(x 4) diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt index b1df6b0..9e6462b 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -1,4 +1,20 @@ add_library(bar STATIC bar.cpp) add_library(foo STATIC foo.cpp) + +add_library(baz STATIC foo.cpp) +set_target_properties(baz PROPERTIES EXCLUDE_FROM_ALL OFF) + +file(GENERATE + OUTPUT "${CMAKE_BINARY_DIR}/main.txt" + CONTENT "$<TARGET_FILE_NAME:main>") + +file(GENERATE + OUTPUT "${CMAKE_BINARY_DIR}/bar.txt" + CONTENT "$<TARGET_FILE_NAME:bar>") + +file(GENERATE + OUTPUT "${CMAKE_BINARY_DIR}/baz.txt" + CONTENT "$<TARGET_FILE_NAME:baz>") + target_include_directories(foo PUBLIC .) diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake new file mode 100644 index 0000000..14ec482 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake @@ -0,0 +1,44 @@ +# Use globbing to check if exes / libs were built because determining +# exactly where these files will live inside a CMake -P script is +# pretty challenging. + +file(READ "${RunCMake_TEST_BINARY_DIR}/main.txt" main_exe) +file(READ "${RunCMake_TEST_BINARY_DIR}/bar.txt" bar_lib) +file(READ "${RunCMake_TEST_BINARY_DIR}/baz.txt" baz_lib) + +set(found_main FALSE) +file(GLOB_RECURSE files + LIST_DIRECTORIES FALSE + RELATIVE "${RunCMake_TEST_BINARY_DIR}" + "${RunCMake_TEST_BINARY_DIR}/*") +foreach (file IN LISTS files) + if (file MATCHES "${main_exe}") + set(found_main TRUE) + endif() +endforeach() +if (NOT found_main) + set(RunCMake_TEST_FAILED "'main' missing from ${RunCMake_TEST_BINARY_DIR}") +endif() + +set(found_bar FALSE) +set(found_baz FALSE) +file(GLOB_RECURSE files + LIST_DIRECTORIES FALSE + RELATIVE "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll" + "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll/*") +foreach (file IN LISTS files) + if (file MATCHES "${bar_lib}") + set(found_bar TRUE) + endif() + if (file MATCHES "${baz_lib}") + set(found_baz TRUE) + endif() +endforeach() +if (found_bar) + set(RunCMake_TEST_FAILED + "'bar' was not excluded from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") +endif() +if (NOT found_baz) + set(RunCMake_TEST_FAILED + "'baz' missing from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") +endif() diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index 343e65b..781e483 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -33,6 +33,7 @@ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(ExcludeFromAll) +set(RunCMake-check-file ExcludeFromAll/check.cmake) run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .) unset(RunCMake_TEST_BINARY_DIR) @@ -1312,6 +1312,7 @@ cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_versi cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\"" +cmake_report cmConfigure.h${_tmp} "#define CMake_DEFAULT_RECURSION_LIMIT 400" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP" |