diff options
91 files changed, 1044 insertions, 333 deletions
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 31ec1d0..0676f7e 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -221,6 +221,7 @@ syn keyword cmakeProperty contained \ JOB_POOLS \ JOB_POOL_COMPILE \ JOB_POOL_LINK + \ JOB_POOL_PRECOMPILE_HEADER \ KEEP_EXTENSION \ LABELS \ LANGUAGE @@ -1066,6 +1067,7 @@ syn keyword cmakeVariable contained \ CMAKE_JOB_POOLS \ CMAKE_JOB_POOL_COMPILE \ CMAKE_JOB_POOL_LINK + \ CMAKE_JOB_POOL_PRECOMPILE_HEADER \ CMAKE_Java \ CMAKE_Java_ANDROID_TOOLCHAIN_MACHINE \ CMAKE_Java_ANDROID_TOOLCHAIN_PREFIX @@ -2864,6 +2866,11 @@ syn keyword cmakeKWtarget_link_options contained \ _LINKER_WRAPPER_FLAG \ _LINKER_WRAPPER_FLAG_SEP +syn keyword cmakeKWtarget_precompile_headers contained + \ INTERFACE + \ PRIVATE + \ PUBLIC + syn keyword cmakeKWtarget_sources contained \ ALIAS \ IMPORTED @@ -3168,6 +3175,7 @@ syn keyword cmakeCommand \ target_link_directories \ target_link_libraries \ target_link_options + \ target_precompile_headers \ target_sources \ try_compile \ try_run @@ -3324,6 +3332,7 @@ hi def link cmakeKWtarget_include_directories ModeMsg hi def link cmakeKWtarget_link_directories ModeMsg hi def link cmakeKWtarget_link_libraries ModeMsg hi def link cmakeKWtarget_link_options ModeMsg +hi def link cmakeKWtarget_precompile_headers ModeMsg hi def link cmakeKWtarget_sources ModeMsg hi def link cmakeKWtry_compile ModeMsg hi def link cmakeKWtry_run ModeMsg diff --git a/CMakeLists.txt b/CMakeLists.txt index da99a6e..6f4c111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -671,10 +671,6 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL "Where to put the libraries for CMake") - # The CMake executables usually do not need any rpath to run in the build or - # install tree. - set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") - # Load install destinations. include(Source/CMakeInstallDestinations.cmake) @@ -714,19 +710,6 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) # build the utilities (a macro defined in this file) CMAKE_BUILD_UTILITIES() - # On NetBSD ncurses is required, since curses doesn't have the wsyncup() - # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib, - # which isn't in the default linker search path. So without RPATH ccmake - # doesn't run and the build doesn't succeed since ccmake is executed for - # generating the documentation. - if(BUILD_CursesDialog) - get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH) - set(CURSES_NEED_RPATH FALSE) - if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64") - set(CURSES_NEED_RPATH TRUE) - endif() - endif() - if(BUILD_QtDialog) if(APPLE) set(CMAKE_BUNDLE_VERSION @@ -739,28 +722,15 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") endif() - - set(QT_NEED_RPATH FALSE) - if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64") - set(QT_NEED_RPATH TRUE) - endif() endif() - - # The same might be true on other systems for other libraries. - # Then only enable RPATH if we have are building at least with cmake 2.4, - # since this one has much better RPATH features than cmake 2.2. - # The executables are then built with the RPATH for the libraries outside - # the build tree, which is both the build and the install RPATH. - if (UNIX) - if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB - OR CMAKE_USE_SYSTEM_EXPAT OR CURSES_NEED_RPATH OR QT_NEED_RPATH) - set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - endif() - endif () - + if(UNIX) + # Install executables with the RPATH set for libraries outside the build tree. + # This is also suitable for binaries in the build tree. Avoid re-link on install. + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON CACHE BOOL "Install with RPATH set to find custom-built libraries.") + set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Build with RPATH set to match install-tree RPATH.") + mark_as_advanced(CMAKE_INSTALL_RPATH_USE_LINK_PATH CMAKE_BUILD_WITH_INSTALL_RPATH) + endif() # add the uninstall support configure_file( diff --git a/Help/cpack_gen/dmg.rst b/Help/cpack_gen/dmg.rst index 1e37889..35320c2 100644 --- a/Help/cpack_gen/dmg.rst +++ b/Help/cpack_gen/dmg.rst @@ -81,6 +81,13 @@ on macOS: ``<language>.menu.txt`` and ``<language>.license.txt`` in the directory specified by the :variable:`CPACK_DMG_SLA_DIR` variable. +.. variable:: CPACK_DMG_<component>_FILE_NAME + + File name when packaging ``<component>`` as its own DMG + (``CPACK_COMPONENTS_GROUPING`` set to IGNORE). + + - Default: ``CPACK_PACKAGE_FILE_NAME-<component>`` + .. variable:: CPACK_COMMAND_HDIUTIL Path to the ``hdiutil(1)`` command used to operate on disk image files on diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst index 92ca760..248eb05 100644 --- a/Help/generator/Ninja Multi-Config.rst +++ b/Help/generator/Ninja Multi-Config.rst @@ -19,8 +19,8 @@ the desired ``build-<Config>.ninja`` file with ``ninja -f``. Running ``build-<Config>.ninja`` as the ``-f`` file and ``<target>`` as the build target. -If :variable:`CMAKE_NINJA_CROSS_CONFIG_ENABLE` is turned on, executables and -libraries of any configuration can be built regardless of which +If :variable:`CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE` is turned on, executables +and libraries of any configuration can be built regardless of which ``build-<Config>.ninja`` file is used, simply by specifying ``<target>:<OtherConfig>`` as the Ninja target. You can also specify ``<target>:all`` to build a target in all configurations. Each @@ -31,8 +31,8 @@ targets will always use the configuration specified in Ninja for the same file to be output with different commands in the same build graph. -If :variable:`CMAKE_NINJA_CROSS_CONFIG_ENABLE` is not enabled, you can still -build any target in ``build-<Config>.ninja`` by specifying +If :variable:`CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE` is not enabled, you can +still build any target in ``build-<Config>.ninja`` by specifying ``<target>:<Config>`` or ``<target>``, but not ``<target>:<OtherConfig>`` or ``<target>:all``. @@ -60,8 +60,8 @@ This would build the ``Debug`` configuration of ``generator``, which would be used to generate ``generated.c``, which would be used to build the ``Debug`` configuration of ``generated``. -But if :variable:`CMAKE_NINJA_CROSS_CONFIG_ENABLE` is enabled, and you run the -following instead: +But if :variable:`CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE` is enabled, and you +run the following instead: .. code-block:: shell diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index b3802d1..393735e 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -253,6 +253,7 @@ Properties on Targets /prop_tgt/IOS_INSTALL_COMBINED /prop_tgt/JOB_POOL_COMPILE /prop_tgt/JOB_POOL_LINK + /prop_tgt/JOB_POOL_PRECOMPILE_HEADER /prop_tgt/LABELS /prop_tgt/LANG_CLANG_TIDY /prop_tgt/LANG_COMPILER_LAUNCHER diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 862e854..a8fbc09 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -65,6 +65,7 @@ Variables that Provide Information /variable/CMAKE_IMPORT_LIBRARY_SUFFIX /variable/CMAKE_JOB_POOL_COMPILE /variable/CMAKE_JOB_POOL_LINK + /variable/CMAKE_JOB_POOL_PRECOMPILE_HEADER /variable/CMAKE_JOB_POOLS /variable/CMAKE_LANG_COMPILER_AR /variable/CMAKE_LANG_COMPILER_RANLIB @@ -215,7 +216,6 @@ Variables that Change Behavior /variable/CMAKE_MESSAGE_INDENT /variable/CMAKE_MESSAGE_LOG_LEVEL /variable/CMAKE_MODULE_PATH - /variable/CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE /variable/CMAKE_POLICY_DEFAULT_CMPNNNN /variable/CMAKE_POLICY_WARNING_CMPNNNN /variable/CMAKE_PREFIX_PATH @@ -424,7 +424,8 @@ Variables that Control the Build /variable/CMAKE_MODULE_LINKER_FLAGS_INIT /variable/CMAKE_MSVCIDE_RUN_PATH /variable/CMAKE_MSVC_RUNTIME_LIBRARY - /variable/CMAKE_NINJA_CROSS_CONFIG_ENABLE + /variable/CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE + /variable/CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE /variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX /variable/CMAKE_NO_BUILTIN_CHRPATH /variable/CMAKE_NO_SYSTEM_FROM_IMPORTED diff --git a/Help/prop_tgt/JOB_POOL_PRECOMPILE_HEADER.rst b/Help/prop_tgt/JOB_POOL_PRECOMPILE_HEADER.rst new file mode 100644 index 0000000..ece28a4 --- /dev/null +++ b/Help/prop_tgt/JOB_POOL_PRECOMPILE_HEADER.rst @@ -0,0 +1,21 @@ +JOB_POOL_PRECOMPILE_HEADER +-------------------------- + +Ninja only: Pool used for generating pre-compiled headers. + +The number of parallel compile processes could be limited by defining +pools with the global :prop_gbl:`JOB_POOLS` +property and then specifying here the pool name. + +For instance: + +.. code-block:: cmake + + set_property(TARGET myexe PROPERTY JOB_POOL_PRECOMPILE_HEADER two_jobs) + +This property is initialized by the value of +:variable:`CMAKE_JOB_POOL_PRECOMPILE_HEADER`. + +If neither :prop_tgt:`JOB_POOL_PRECOMPILE_HEADER` nor +:variable:`CMAKE_JOB_POOL_PRECOMPILE_HEADER` are set then +:prop_tgt:`JOB_POOL_COMPILE` will be used for this task. diff --git a/Help/release/dev/custom-dmg-names.rst b/Help/release/dev/custom-dmg-names.rst new file mode 100644 index 0000000..73a70a1 --- /dev/null +++ b/Help/release/dev/custom-dmg-names.rst @@ -0,0 +1,7 @@ +custom-dmg-names +---------------- + +* The :cpack_gen:`CPack DragNDrop Generator` learned to use + the :variable:`CPACK_DMG_<component>_FILE_NAME` variable + to set a custom filename when packaging components into + their own DMGs. diff --git a/Help/variable/CMAKE_JOB_POOL_PRECOMPILE_HEADER.rst b/Help/variable/CMAKE_JOB_POOL_PRECOMPILE_HEADER.rst new file mode 100644 index 0000000..f9467b3 --- /dev/null +++ b/Help/variable/CMAKE_JOB_POOL_PRECOMPILE_HEADER.rst @@ -0,0 +1,6 @@ +CMAKE_JOB_POOL_PRECOMPILE_HEADER +-------------------------------- + +This variable is used to initialize the :prop_tgt:`JOB_POOL_PRECOMPILE_HEADER` +property on all the targets. See :prop_tgt:`JOB_POOL_PRECOMPILE_HEADER` +for additional information. diff --git a/Help/variable/CMAKE_NINJA_CROSS_CONFIG_ENABLE.rst b/Help/variable/CMAKE_NINJA_CROSS_CONFIG_ENABLE.rst deleted file mode 100644 index 5c9c1aa..0000000 --- a/Help/variable/CMAKE_NINJA_CROSS_CONFIG_ENABLE.rst +++ /dev/null @@ -1,6 +0,0 @@ -CMAKE_NINJA_CROSS_CONFIG_ENABLE -------------------------------- - -If this variable is enabled, cross-configuration building is enabled in the -:generator:`Ninja Multi-Config` generator. See the generator's description for -more details. diff --git a/Help/variable/CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE.rst b/Help/variable/CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE.rst new file mode 100644 index 0000000..0571d52 --- /dev/null +++ b/Help/variable/CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE.rst @@ -0,0 +1,10 @@ +CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE +------------------------------------- + +If this variable is enabled, cross-configuration building is enabled in the +:generator:`Ninja Multi-Config` generator. See the generator's description for +more details. This variable is ``OFF`` by default. + +This variable is meant to be set from the command line (via +``-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE:BOOL=ON``) and should not be set from +project code. diff --git a/Modules/CMakeCSharpInformation.cmake b/Modules/CMakeCSharpInformation.cmake index 48e1a1e..41cd449 100644 --- a/Modules/CMakeCSharpInformation.cmake +++ b/Modules/CMakeCSharpInformation.cmake @@ -10,7 +10,7 @@ get_filename_component(CMAKE_BASE_NAME "${CMAKE_CSharp_COMPILER}" NAME_WE) set(CMAKE_BUILD_TYPE_INIT Debug) -set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE /langversion:3") +set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE") set(CMAKE_CSharp_FLAGS_DEBUG_INIT "/debug:full /optimize- /warn:3 /errorreport:prompt /define:DEBUG") set(CMAKE_CSharp_FLAGS_RELEASE_INIT "/debug:none /optimize /warn:1 /errorreport:queue") set(CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT "/debug:full /optimize-") diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index c54ab9d..2111c65 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -28,6 +28,8 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED) endif() endif() +set(CMAKE_Fortran_SUBMODULE_SEP ".") +set(CMAKE_Fortran_SUBMODULE_EXT ".sub") set(CMAKE_Fortran_MODDIR_FLAG "-mdir ") set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 1837694..f7f68ca 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -122,7 +122,6 @@ CUDA Runtime Library The CUDA Runtime library (cudart) are what most applications will typically need to link against to make any calls such as `cudaMalloc`, and `cudaFree`. -They are an explicit dependency of almost every library. Targets Created: @@ -708,9 +707,13 @@ if(CUDAToolkit_FOUND) endfunction() function(add_cuda_link_dependency lib_name) - foreach(dependency IN LISTS ${ARGN}) - target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dependency}) - endforeach() + if(TARGET CUDA::${lib_name}) + foreach(dependency IN LISTS ARGN) + if(TARGET CUDA::${dependency}) + target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dependency}) + endif() + endforeach() + endif() endfunction() add_library(CUDA::toolkit IMPORTED INTERFACE) @@ -725,10 +728,8 @@ if(CUDAToolkit_FOUND) foreach (cuda_lib cublas cufft cufftw curand cusolver cusparse nvgraph nvjpeg) find_and_add_cuda_import_lib(${cuda_lib}) - add_cuda_link_dependency(${cuda_lib} cudart) find_and_add_cuda_import_lib(${cuda_lib}_static) - add_cuda_link_dependency(${cuda_lib}_static cudart_static) endforeach() # cuSOLVER depends on cuBLAS, and cuSPARSE @@ -742,9 +743,6 @@ if(CUDAToolkit_FOUND) find_and_add_cuda_import_lib(nppc) find_and_add_cuda_import_lib(nppc_static) - add_cuda_link_dependency(nppc cudart) - add_cuda_link_dependency(nppc_static cudart_static culibos) - # Process the majority of the NPP libraries. foreach (cuda_lib nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu) find_and_add_cuda_import_lib(${cuda_lib}) @@ -771,13 +769,11 @@ if(CUDAToolkit_FOUND) endif() find_and_add_cuda_import_lib(nvToolsExt nvToolsExt nvToolsExt64) - add_cuda_link_dependency(nvToolsExt cudart) - find_and_add_cuda_import_lib(OpenCL) find_and_add_cuda_import_lib(culibos) if(TARGET CUDA::culibos) - foreach (cuda_lib cublas cufft cusparse curand nvjpeg) + foreach (cuda_lib cublas cufft cusparse curand nppc nvjpeg) add_cuda_link_dependency(${cuda_lib}_static culibos) endforeach() endif() diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 7c20512..7483d72 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -23,7 +23,7 @@ if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 3) - set(_${_PYTHON_PREFIX}_VERSIONS 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) + set(_${_PYTHON_PREFIX}_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 2) set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) else() diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index ccc7d5b..1e01a99 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -54,7 +54,7 @@ unset(_Python_NAMES) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonInterp_FIND_VERSION) if(PythonInterp_FIND_VERSION_COUNT GREATER 1) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 1d62ac4..d3ec7be 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -79,7 +79,7 @@ set(CMAKE_FIND_FRAMEWORK LAST) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonLibs_FIND_VERSION) if(PythonLibs_FIND_VERSION_COUNT GREATER 1) diff --git a/Modules/Platform/Windows-PGI.cmake b/Modules/Platform/Windows-PGI.cmake index ad77e8a..8166240 100644 --- a/Modules/Platform/Windows-PGI.cmake +++ b/Modules/Platform/Windows-PGI.cmake @@ -9,9 +9,10 @@ endif() set(__WINDOWS_COMPILER_PGI 1) # PGI on Windows doesn't support parallel compile processes -if(NOT DEFINED CMAKE_JOB_POOL_LINK OR NOT DEFINED CMAKE_JOB_POOL_COMPILE) +if(NOT DEFINED CMAKE_JOB_POOL_LINK OR NOT DEFINED CMAKE_JOB_POOL_COMPILE OR NOT DEFINED CMAKE_JOB_POOL_PRECOMPILE_HEADER) set(CMAKE_JOB_POOL_LINK PGITaskPool) set(CMAKE_JOB_POOL_COMPILE PGITaskPool) + set(CMAKE_JOB_POOL_PRECOMPILE_HEADER PGITaskPool) get_property(_pgijp GLOBAL PROPERTY JOB_POOLS) if(NOT _pgijp MATCHES "PGITaskPool=") set_property(GLOBAL APPEND PROPERTY JOB_POOLS PGITaskPool=1) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 985303c..721e823 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 16) -set(CMake_VERSION_PATCH 20200114) +set(CMake_VERSION_PATCH 20200117) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index ea71007..3516235 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -775,6 +775,11 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix( } } + std::string componentFileName = + "CPACK_DMG_" + cmSystemTools::UpperCase(componentName) + "_FILE_NAME"; + if (this->IsSet(componentFileName)) { + return this->GetOption(componentFileName); + } return GetComponentPackageFileName(package_file_name, componentName, false); } diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index 2ec9622..cdf899c 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -278,9 +278,6 @@ void cmProcess::OnTimeoutCB(uv_timer_t* timer) void cmProcess::OnTimeout() { - if (this->ProcessState != cmProcess::State::Executing) { - return; - } this->ProcessState = cmProcess::State::Expired; bool const was_still_reading = !this->ReadHandleClosed; if (!this->ReadHandleClosed) { diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 995088c..5deba8b 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -215,7 +215,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, } if (cmSystemTools::FileIsFullPath(filename)) { - filename = cmSystemTools::CollapseFullPath(filename); + filename = cmSystemTools::CollapseFullPath( + filename, status.GetMakefile().GetHomeOutputDirectory()); } switch (doing) { case doing_depfile: diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 6a1a514..35eabaf 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -53,7 +53,8 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args, status.SetError(error); return false; } - srcPath = cmSystemTools::CollapseFullPath(srcPath); + srcPath = + cmSystemTools::CollapseFullPath(srcPath, mf.GetHomeOutputDirectory()); // Compute the full path to the binary directory. std::string binPath; diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 8942113..205c1c7 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddTestCommand.h" +#include <cm/memory> + #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" @@ -44,7 +46,7 @@ bool cmAddTestCommand(std::vector<std::string> const& args, } else { test = mf.CreateTest(args[0]); test->SetOldStyle(true); - mf.AddTestGenerator(new cmTestGenerator(test)); + mf.AddTestGenerator(cm::make_unique<cmTestGenerator>(test)); } test->SetCommand(command); @@ -141,7 +143,7 @@ bool cmAddTestCommandHandleNameMode(std::vector<std::string> const& args, test->SetProperty("WORKING_DIRECTORY", working_directory.c_str()); } test->SetCommandExpandLists(command_expand_lists); - mf.AddTestGenerator(new cmTestGenerator(test, configurations)); + mf.AddTestGenerator(cm::make_unique<cmTestGenerator>(test, configurations)); return true; } diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 3b0a223..19da2a0 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -67,40 +67,6 @@ bool cmContains(Range const& range, Key const& key) namespace ContainerAlgorithms { -template <typename T> -struct cmIsPair -{ - enum - { - value = false - }; -}; - -template <typename K, typename V> -struct cmIsPair<std::pair<K, V>> -{ - enum - { - value = true - }; -}; - -template <typename Range, - bool valueTypeIsPair = cmIsPair<typename Range::value_type>::value> -struct DefaultDeleter -{ - void operator()(typename Range::value_type value) const { delete value; } -}; - -template <typename Range> -struct DefaultDeleter<Range, /* valueTypeIsPair = */ true> -{ - void operator()(typename Range::value_type value) const - { - delete value.second; - } -}; - template <typename FwdIt> FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n) { @@ -133,13 +99,6 @@ using cmBacktraceRange = cmRange<std::vector<cmListFileBacktrace>::const_iterator>; template <typename Range> -void cmDeleteAll(Range const& r) -{ - std::for_each(r.begin(), r.end(), - ContainerAlgorithms::DefaultDeleter<Range>()); -} - -template <typename Range> typename Range::const_iterator cmRemoveN(Range& r, size_t n) { return ContainerAlgorithms::RemoveN(r.begin(), r.end(), n); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index c568253..a595007 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -34,7 +34,8 @@ void AppendPaths(const std::vector<std::string>& inputs, it = cmStrCat(lg->GetMakefile()->GetCurrentBinaryDirectory(), '/', it); } if (cmSystemTools::FileIsFullPath(it)) { - it = cmSystemTools::CollapseFullPath(it); + it = cmSystemTools::CollapseFullPath( + it, lg->GetMakefile()->GetHomeOutputDirectory()); } } cm::append(output, result); diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index ee43587..3692202 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -33,6 +33,8 @@ static void cmFortranModuleAppendUpperLower(std::string const& mod, ext_len = 4; } else if (cmHasLiteralSuffix(mod, ".smod")) { ext_len = 5; + } else if (cmHasLiteralSuffix(mod, ".sub")) { + ext_len = 4; } std::string const& name = mod.substr(0, mod.size() - ext_len); std::string const& ext = mod.substr(mod.size() - ext_len); @@ -284,7 +286,8 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin, if (doing_provides) { std::string mod = line; if (!cmHasLiteralSuffix(mod, ".mod") && - !cmHasLiteralSuffix(mod, ".smod")) { + !cmHasLiteralSuffix(mod, ".smod") && + !cmHasLiteralSuffix(mod, ".sub")) { // Support fortran.internal files left by older versions of CMake. // They do not include the ".mod" extension. mod += ".mod"; @@ -470,7 +473,8 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) if (args.size() >= 5) { compilerId = args[4]; } - if (!cmHasLiteralSuffix(mod, ".mod") && !cmHasLiteralSuffix(mod, ".smod")) { + if (!cmHasLiteralSuffix(mod, ".mod") && !cmHasLiteralSuffix(mod, ".smod") && + !cmHasLiteralSuffix(mod, ".sub")) { // Support depend.make files left by older versions of CMake. // They do not include the ".mod" extension. mod += ".mod"; diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index e463420..3a22846 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -246,8 +246,7 @@ std::string cmExtraKateGenerator::GenerateFilesString( } } - const std::vector<cmSourceFile*>& sources = makefile->GetSourceFiles(); - for (cmSourceFile* sf : sources) { + for (const auto& sf : makefile->GetSourceFiles()) { if (sf->GetIsGenerated()) { continue; } diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index d13e8ec..955195f 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -493,8 +493,9 @@ void CodemodelConfig::ProcessDirectories() Directory& d = *di; // Accumulate the presence of install rules on the way up. - for (auto gen : d.LocalGenerator->GetMakefile()->GetInstallGenerators()) { - if (!dynamic_cast<cmInstallSubdirectoryGenerator*>(gen)) { + for (const auto& gen : + d.LocalGenerator->GetMakefile()->GetInstallGenerators()) { + if (!dynamic_cast<cmInstallSubdirectoryGenerator*>(gen.get())) { d.HasInstallRule = true; break; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 1fdfa87..d1775a7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1707,7 +1707,8 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, // as we receive downloaded bits from curl... // std::string dir = cmSystemTools::GetFilenamePath(file); - if (!cmSystemTools::FileExists(dir) && !cmSystemTools::MakeDirectory(dir)) { + if (!dir.empty() && !cmSystemTools::FileExists(dir) && + !cmSystemTools::MakeDirectory(dir)) { std::string errstring = "DOWNLOAD error: cannot create directory '" + dir + "' - Specify file by full path name and verify that you " "have directory creation and file write privileges."; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 523083a..b3fb132 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3086,7 +3086,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories( cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config); for (cmLinkImplItem const& lib : impl->Libraries) { - std::string libDir = cmSystemTools::CollapseFullPath(lib.AsStr()); + std::string libDir = cmSystemTools::CollapseFullPath( + lib.AsStr(), this->Makefile->GetHomeOutputDirectory()); static cmsys::RegularExpression frameworkCheck( "(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 7686def..b3eb8e4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1412,7 +1412,7 @@ bool cmGlobalGenerator::Compute() for (const auto& localGen : this->LocalGenerators) { cmMakefile* mf = localGen->GetMakefile(); - for (cmInstallGenerator* g : mf->GetInstallGenerators()) { + for (const auto& g : mf->GetInstallGenerators()) { if (!g->Compute(localGen.get())) { return false; } @@ -1687,10 +1687,10 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes) std::map<cmTarget*, cmGeneratorTarget*> importedMap; for (unsigned int i = 0; i < this->Makefiles.size(); ++i) { auto& mf = this->Makefiles[i]; - for (cmTarget* ownedImpTgt : mf->GetOwnedImportedTargets()) { + for (const auto& ownedImpTgt : mf->GetOwnedImportedTargets()) { cmLocalGenerator* lg = this->LocalGenerators[i].get(); - auto gt = cm::make_unique<cmGeneratorTarget>(ownedImpTgt, lg); - importedMap[ownedImpTgt] = gt.get(); + auto gt = cm::make_unique<cmGeneratorTarget>(ownedImpTgt.get(), lg); + importedMap[ownedImpTgt.get()] = gt.get(); lg->AddOwnedImportedGeneratorTarget(std::move(gt)); } } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 922beb7..0487ad1 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1336,8 +1336,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) knownDependencies.insert(this->ConvertToNinjaPath(j)); } } - for (cmGeneratorExpressionEvaluationFile* li : - lg->GetMakefile()->GetEvaluationFiles()) { + for (const auto& li : lg->GetMakefile()->GetEvaluationFiles()) { // get all the files created by generator expressions and convert them // to ninja paths for (std::string const& evaluationFile : li->GetFiles()) { @@ -2204,7 +2203,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( bool cmGlobalNinjaGenerator::EnableCrossConfigBuild() const { return this->IsMultiConfig() && - this->Makefiles.front()->IsOn("CMAKE_NINJA_CROSS_CONFIG_ENABLE"); + this->Makefiles.front()->IsOn("CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE"); } int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 0c52cc5..54b85cd 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -85,7 +85,7 @@ public: std::string DefaultComponentName; }; -cmInstallTargetGenerator* CreateInstallTargetGenerator( +std::unique_ptr<cmInstallTargetGenerator> CreateInstallTargetGenerator( cmTarget& target, const cmInstallCommandArguments& args, bool impLib, cmListFileBacktrace const& backtrace, const std::string& destination, bool forceOpt = false, bool namelink = false) @@ -95,16 +95,16 @@ cmInstallTargetGenerator* CreateInstallTargetGenerator( target.SetHaveInstallRule(true); const char* component = namelink ? args.GetNamelinkComponent().c_str() : args.GetComponent().c_str(); - auto g = new cmInstallTargetGenerator( + auto g = cm::make_unique<cmInstallTargetGenerator>( target.GetName(), destination.c_str(), impLib, args.GetPermissions().c_str(), args.GetConfigurations(), component, message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt, backtrace); - target.AddInstallGenerator(g); + target.AddInstallGenerator(g.get()); return g; } -cmInstallTargetGenerator* CreateInstallTargetGenerator( +std::unique_ptr<cmInstallTargetGenerator> CreateInstallTargetGenerator( cmTarget& target, const cmInstallCommandArguments& args, bool impLib, cmListFileBacktrace const& backtrace, bool forceOpt = false, bool namelink = false) @@ -114,20 +114,20 @@ cmInstallTargetGenerator* CreateInstallTargetGenerator( namelink); } -cmInstallFilesGenerator* CreateInstallFilesGenerator( +std::unique_ptr<cmInstallFilesGenerator> CreateInstallFilesGenerator( cmMakefile* mf, const std::vector<std::string>& absFiles, const cmInstallCommandArguments& args, bool programs, const std::string& destination) { cmInstallGenerator::MessageLevel message = cmInstallGenerator::SelectMessageLevel(mf); - return new cmInstallFilesGenerator( + return cm::make_unique<cmInstallFilesGenerator>( absFiles, destination.c_str(), programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, args.GetExcludeFromAll(), args.GetRename().c_str(), args.GetOptional()); } -cmInstallFilesGenerator* CreateInstallFilesGenerator( +std::unique_ptr<cmInstallFilesGenerator> CreateInstallFilesGenerator( cmMakefile* mf, const std::vector<std::string>& absFiles, const cmInstallCommandArguments& args, bool programs) { @@ -196,13 +196,15 @@ bool HandleScriptMode(std::vector<std::string> const& args, status.SetError("given a directory as value of SCRIPT argument."); return false; } - helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator( - script.c_str(), false, component.c_str(), exclude_from_all)); + helper.Makefile->AddInstallGenerator( + cm::make_unique<cmInstallScriptGenerator>( + script.c_str(), false, component.c_str(), exclude_from_all)); } else if (doing_code) { doing_code = false; std::string const& code = arg; - helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator( - code.c_str(), true, component.c_str(), exclude_from_all)); + helper.Makefile->AddInstallGenerator( + cm::make_unique<cmInstallScriptGenerator>( + code.c_str(), true, component.c_str(), exclude_from_all)); } } @@ -449,16 +451,16 @@ bool HandleTargetsMode(std::vector<std::string> const& args, for (cmTarget* ti : targets) { // Handle each target type. cmTarget& target = *ti; - cmInstallTargetGenerator* archiveGenerator = nullptr; - cmInstallTargetGenerator* libraryGenerator = nullptr; - cmInstallTargetGenerator* namelinkGenerator = nullptr; - cmInstallTargetGenerator* runtimeGenerator = nullptr; - cmInstallTargetGenerator* objectGenerator = nullptr; - cmInstallTargetGenerator* frameworkGenerator = nullptr; - cmInstallTargetGenerator* bundleGenerator = nullptr; - cmInstallFilesGenerator* privateHeaderGenerator = nullptr; - cmInstallFilesGenerator* publicHeaderGenerator = nullptr; - cmInstallFilesGenerator* resourceGenerator = nullptr; + std::unique_ptr<cmInstallTargetGenerator> archiveGenerator; + std::unique_ptr<cmInstallTargetGenerator> libraryGenerator; + std::unique_ptr<cmInstallTargetGenerator> namelinkGenerator; + std::unique_ptr<cmInstallTargetGenerator> runtimeGenerator; + std::unique_ptr<cmInstallTargetGenerator> objectGenerator; + std::unique_ptr<cmInstallTargetGenerator> frameworkGenerator; + std::unique_ptr<cmInstallTargetGenerator> bundleGenerator; + std::unique_ptr<cmInstallFilesGenerator> privateHeaderGenerator; + std::unique_ptr<cmInstallFilesGenerator> publicHeaderGenerator; + std::unique_ptr<cmInstallFilesGenerator> resourceGenerator; // Track whether this is a namelink-only rule. bool namelinkOnly = false; @@ -485,7 +487,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, runtimeGenerator = CreateInstallTargetGenerator( target, runtimeArgs, false, helper.Makefile->GetBacktrace()); } - if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) { + if (!archiveGenerator && !runtimeGenerator) { archiveGenerator = CreateInstallTargetGenerator( target, archiveArgs, true, helper.Makefile->GetBacktrace(), helper.GetArchiveDestination(nullptr)); @@ -712,43 +714,18 @@ bool HandleTargetsMode(std::vector<std::string> const& args, } } - // Keep track of whether we're installing anything in each category - installsArchive = installsArchive || archiveGenerator != nullptr; - installsLibrary = installsLibrary || libraryGenerator != nullptr; - installsNamelink = installsNamelink || namelinkGenerator != nullptr; - installsRuntime = installsRuntime || runtimeGenerator != nullptr; - installsObject = installsObject || objectGenerator != nullptr; - installsFramework = installsFramework || frameworkGenerator != nullptr; - installsBundle = installsBundle || bundleGenerator != nullptr; - installsPrivateHeader = - installsPrivateHeader || privateHeaderGenerator != nullptr; - installsPublicHeader = - installsPublicHeader || publicHeaderGenerator != nullptr; - installsResource = installsResource || resourceGenerator; - - helper.Makefile->AddInstallGenerator(archiveGenerator); - helper.Makefile->AddInstallGenerator(libraryGenerator); - helper.Makefile->AddInstallGenerator(namelinkGenerator); - helper.Makefile->AddInstallGenerator(runtimeGenerator); - helper.Makefile->AddInstallGenerator(objectGenerator); - helper.Makefile->AddInstallGenerator(frameworkGenerator); - helper.Makefile->AddInstallGenerator(bundleGenerator); - helper.Makefile->AddInstallGenerator(privateHeaderGenerator); - helper.Makefile->AddInstallGenerator(publicHeaderGenerator); - helper.Makefile->AddInstallGenerator(resourceGenerator); - // Add this install rule to an export if one was specified and // this is not a namelink-only rule. if (!exports.empty() && !namelinkOnly) { auto te = cm::make_unique<cmTargetExport>(); te->TargetName = target.GetName(); - te->ArchiveGenerator = archiveGenerator; - te->BundleGenerator = bundleGenerator; - te->FrameworkGenerator = frameworkGenerator; - te->HeaderGenerator = publicHeaderGenerator; - te->LibraryGenerator = libraryGenerator; - te->RuntimeGenerator = runtimeGenerator; - te->ObjectsGenerator = objectGenerator; + te->ArchiveGenerator = archiveGenerator.get(); + te->BundleGenerator = bundleGenerator.get(); + te->FrameworkGenerator = frameworkGenerator.get(); + te->HeaderGenerator = publicHeaderGenerator.get(); + te->LibraryGenerator = libraryGenerator.get(); + te->RuntimeGenerator = runtimeGenerator.get(); + te->ObjectsGenerator = objectGenerator.get(); te->InterfaceIncludeDirectories = cmJoin(includesArgs.GetIncludeDirs(), ";"); @@ -756,6 +733,29 @@ bool HandleTargetsMode(std::vector<std::string> const& args, ->GetExportSets()[exports] .AddTargetExport(std::move(te)); } + + // Keep track of whether we're installing anything in each category + installsArchive = installsArchive || archiveGenerator; + installsLibrary = installsLibrary || libraryGenerator; + installsNamelink = installsNamelink || namelinkGenerator; + installsRuntime = installsRuntime || runtimeGenerator; + installsObject = installsObject || objectGenerator; + installsFramework = installsFramework || frameworkGenerator; + installsBundle = installsBundle || bundleGenerator; + installsPrivateHeader = installsPrivateHeader || privateHeaderGenerator; + installsPublicHeader = installsPublicHeader || publicHeaderGenerator; + installsResource = installsResource || resourceGenerator; + + helper.Makefile->AddInstallGenerator(std::move(archiveGenerator)); + helper.Makefile->AddInstallGenerator(std::move(libraryGenerator)); + helper.Makefile->AddInstallGenerator(std::move(namelinkGenerator)); + helper.Makefile->AddInstallGenerator(std::move(runtimeGenerator)); + helper.Makefile->AddInstallGenerator(std::move(objectGenerator)); + helper.Makefile->AddInstallGenerator(std::move(frameworkGenerator)); + helper.Makefile->AddInstallGenerator(std::move(bundleGenerator)); + helper.Makefile->AddInstallGenerator(std::move(privateHeaderGenerator)); + helper.Makefile->AddInstallGenerator(std::move(publicHeaderGenerator)); + helper.Makefile->AddInstallGenerator(std::move(resourceGenerator)); } // Tell the global generator about any installation component names @@ -1200,10 +1200,11 @@ bool HandleDirectoryMode(std::vector<std::string> const& args, cmInstallGenerator::SelectMessageLevel(helper.Makefile, message_never); // Create the directory install generator. - helper.Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator( - dirs, destination, permissions_file.c_str(), permissions_dir.c_str(), - configurations, component.c_str(), message, exclude_from_all, - literal_args.c_str(), optional)); + helper.Makefile->AddInstallGenerator( + cm::make_unique<cmInstallDirectoryGenerator>( + dirs, destination, permissions_file.c_str(), permissions_dir.c_str(), + configurations, component.c_str(), message, exclude_from_all, + literal_args.c_str(), optional)); // Tell the global generator about any installation component names // specified. @@ -1291,12 +1292,12 @@ bool HandleExportAndroidMKMode(std::vector<std::string> const& args, cmInstallGenerator::SelectMessageLevel(helper.Makefile); // Create the export install generator. - cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( - &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), - ica.GetConfigurations(), ica.GetComponent().c_str(), message, - ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, - true); - helper.Makefile->AddInstallGenerator(exportGenerator); + helper.Makefile->AddInstallGenerator( + cm::make_unique<cmInstallExportGenerator>( + &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), + ica.GetConfigurations(), ica.GetComponent().c_str(), message, + ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, + true)); return true; #else @@ -1405,12 +1406,12 @@ bool HandleExportMode(std::vector<std::string> const& args, cmInstallGenerator::SelectMessageLevel(helper.Makefile); // Create the export install generator. - cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( - &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), - ica.GetConfigurations(), ica.GetComponent().c_str(), message, - ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, - false); - helper.Makefile->AddInstallGenerator(exportGenerator); + helper.Makefile->AddInstallGenerator( + cm::make_unique<cmInstallExportGenerator>( + &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), + ica.GetConfigurations(), ica.GetComponent().c_str(), message, + ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, + false)); return true; } diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index efbcb98..bfc7359 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallFilesCommand.h" +#include <cm/memory> + #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" @@ -121,7 +123,7 @@ static void CreateInstallGenerator(cmMakefile& makefile, std::vector<std::string> no_configurations; cmInstallGenerator::MessageLevel message = cmInstallGenerator::SelectMessageLevel(&makefile); - makefile.AddInstallGenerator(new cmInstallFilesGenerator( + makefile.AddInstallGenerator(cm::make_unique<cmInstallFilesGenerator>( files, destination.c_str(), false, no_permissions, no_configurations, no_component.c_str(), message, no_exclude_from_all, no_rename)); } diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 2088eae..2fd9bad 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallProgramsCommand.h" +#include <cm/memory> + #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" @@ -95,7 +97,7 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, std::vector<std::string> no_configurations; cmInstallGenerator::MessageLevel message = cmInstallGenerator::SelectMessageLevel(&makefile); - makefile.AddInstallGenerator(new cmInstallFilesGenerator( + makefile.AddInstallGenerator(cm::make_unique<cmInstallFilesGenerator>( files, destination.c_str(), true, no_permissions, no_configurations, no_component.c_str(), message, no_exclude_from_all, no_rename)); } diff --git a/Source/cmInstallSubdirectoryGenerator.cxx b/Source/cmInstallSubdirectoryGenerator.cxx index 8a0fefa..5405b7c 100644 --- a/Source/cmInstallSubdirectoryGenerator.cxx +++ b/Source/cmInstallSubdirectoryGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallSubdirectoryGenerator.h" +#include <memory> #include <sstream> #include <vector> @@ -24,7 +25,7 @@ cmInstallSubdirectoryGenerator::~cmInstallSubdirectoryGenerator() = default; bool cmInstallSubdirectoryGenerator::HaveInstall() { - for (auto generator : this->Makefile->GetInstallGenerators()) { + for (const auto& generator : this->Makefile->GetInstallGenerators()) { if (generator->HaveInstall()) { return true; } diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 54edabc..dd36386 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -487,10 +487,10 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, result[kHAS_INSTALL_RULE] = true; Json::Value installPaths = Json::arrayValue; - auto targetGenerators = target->Makefile->GetInstallGenerators(); - for (auto installGenerator : targetGenerators) { + for (const auto& installGenerator : + target->Makefile->GetInstallGenerators()) { auto installTargetGenerator = - dynamic_cast<cmInstallTargetGenerator*>(installGenerator); + dynamic_cast<cmInstallTargetGenerator*>(installGenerator.get()); if (installTargetGenerator != nullptr && installTargetGenerator->GetTarget()->Target == target->Target) { auto dest = installTargetGenerator->GetDestination(config); @@ -643,9 +643,9 @@ static Json::Value DumpProjectList(const cmake* cm, std::string const& config) // associated generators. bool hasInstallRule = false; for (const auto generator : projectIt.second) { - for (const auto installGen : + for (const auto& installGen : generator->GetMakefile()->GetInstallGenerators()) { - if (!dynamic_cast<cmInstallSubdirectoryGenerator*>(installGen)) { + if (!dynamic_cast<cmInstallSubdirectoryGenerator*>(installGen.get())) { hasInstallRule = true; break; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4969d55..18f82dd 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -315,9 +315,7 @@ void cmLocalGenerator::GenerateTestFiles() } // Ask each test generator to write its code. - std::vector<cmTestGenerator*> const& testers = - this->Makefile->GetTestGenerators(); - for (cmTestGenerator* tester : testers) { + for (const auto& tester : this->Makefile->GetTestGenerators()) { tester->Compute(this); tester->Generate(fout, config, configurationTypes); } @@ -363,9 +361,7 @@ void cmLocalGenerator::CreateEvaluationFileOutputs() void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) { - std::vector<cmGeneratorExpressionEvaluationFile*> ef = - this->Makefile->GetEvaluationFiles(); - for (cmGeneratorExpressionEvaluationFile* geef : ef) { + for (const auto& geef : this->Makefile->GetEvaluationFiles()) { geef->CreateOutputFile(this, config); } } @@ -373,8 +369,7 @@ void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) void cmLocalGenerator::ProcessEvaluationFiles( std::vector<std::string>& generatedFiles) { - for (cmGeneratorExpressionEvaluationFile* geef : - this->Makefile->GetEvaluationFiles()) { + for (const auto& geef : this->Makefile->GetEvaluationFiles()) { geef->Generate(this); if (cmSystemTools::GetFatalErrorOccured()) { return; @@ -557,18 +552,17 @@ void cmLocalGenerator::GenerateInstallRules() // Ask each install generator to write its code. cmPolicies::PolicyStatus status = this->GetPolicyStatus(cmPolicies::CMP0082); - std::vector<cmInstallGenerator*> const& installers = - this->Makefile->GetInstallGenerators(); + auto const& installers = this->Makefile->GetInstallGenerators(); bool haveSubdirectoryInstall = false; bool haveInstallAfterSubdirectory = false; if (status == cmPolicies::WARN) { - for (cmInstallGenerator* installer : installers) { + for (const auto& installer : installers) { installer->CheckCMP0082(haveSubdirectoryInstall, haveInstallAfterSubdirectory); installer->Generate(fout, config, configurationTypes); } } else { - for (cmInstallGenerator* installer : installers) { + for (const auto& installer : installers) { installer->Generate(fout, config, configurationTypes); } } @@ -2633,7 +2627,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) chunk = std::min(itemsLeft, batchSize); std::string filename = cmStrCat(filename_base, "unity_", batch, - (lang == "C") ? ".c" : ".cxx"); + (lang == "C") ? "_c.c" : "_cxx.cxx"); const std::string filename_tmp = cmStrCat(filename, ".tmp"); { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7435e47..dc741d3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -124,15 +124,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, #endif } -cmMakefile::~cmMakefile() -{ - cmDeleteAll(this->InstallGenerators); - cmDeleteAll(this->TestGenerators); - cmDeleteAll(this->SourceFiles); - cmDeleteAll(this->Tests); - cmDeleteAll(this->ImportedTargetsOwned); - cmDeleteAll(this->EvaluationFiles); -} +cmMakefile::~cmMakefile() = default; cmDirectoryId cmMakefile::GetDirectoryId() const { @@ -774,12 +766,13 @@ void cmMakefile::AddEvaluationFile( std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent) { - this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile( - inputFile, std::move(outputName), std::move(condition), inputIsContent, - this->GetPolicyStatus(cmPolicies::CMP0070))); + this->EvaluationFiles.push_back( + cm::make_unique<cmGeneratorExpressionEvaluationFile>( + inputFile, std::move(outputName), std::move(condition), inputIsContent, + this->GetPolicyStatus(cmPolicies::CMP0070))); } -std::vector<cmGeneratorExpressionEvaluationFile*> +const std::vector<std::unique_ptr<cmGeneratorExpressionEvaluationFile>>& cmMakefile::GetEvaluationFiles() const { return this->EvaluationFiles; @@ -1425,6 +1418,20 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) this->RecursionDepth = parent->RecursionDepth; } +void cmMakefile::AddInstallGenerator(std::unique_ptr<cmInstallGenerator> g) +{ + if (g) { + this->InstallGenerators.push_back(std::move(g)); + } +} + +void cmMakefile::AddTestGenerator(std::unique_ptr<cmTestGenerator> g) +{ + if (g) { + this->TestGenerators.push_back(std::move(g)); + } +} + void cmMakefile::PushFunctionScope(std::string const& fileName, const cmPolicies::PolicyMap& pm) { @@ -1740,7 +1747,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->UnConfiguredDirectories.push_back(subMf); } - this->AddInstallGenerator(new cmInstallSubdirectoryGenerator( + this->AddInstallGenerator(cm::make_unique<cmInstallSubdirectoryGenerator>( subMf, binPath.c_str(), excludeFromAll)); } @@ -2104,18 +2111,18 @@ cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput( // Look through all the source files that have custom commands and see if the // custom command has the passed source file as an output. - for (cmSourceFile* src : this->SourceFiles) { + for (const auto& src : this->SourceFiles) { // Does this source file have a custom command? if (src->GetCustomCommand()) { // Does the output of the custom command match the source file name? if (AnyOutputMatches(name, src->GetCustomCommand()->GetOutputs())) { // Return the first matching output. - return src; + return src.get(); } if (kind == cmSourceOutputKind::OutputOrByproduct) { if (AnyOutputMatches(name, src->GetCustomCommand()->GetByproducts())) { // Do not return the source yet as there might be a matching output. - fallback = src; + fallback = src.get(); } } } @@ -3473,24 +3480,25 @@ cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName, bool generated, cmSourceFileLocationKind kind) { - cmSourceFile* sf = new cmSourceFile(this, sourceName, kind); + auto sf = cm::make_unique<cmSourceFile>(this, sourceName, kind); if (generated) { sf->SetProperty("GENERATED", "1"); } - this->SourceFiles.push_back(sf); auto name = this->GetCMakeInstance()->StripExtension(sf->GetLocation().GetName()); #if defined(_WIN32) || defined(__APPLE__) name = cmSystemTools::LowerCase(name); #endif - this->SourceFileSearchIndex[name].push_back(sf); + this->SourceFileSearchIndex[name].push_back(sf.get()); // for "Known" paths add direct lookup (used for faster lookup in GetSource) if (kind == cmSourceFileLocationKind::Known) { - this->KnownFileSearchIndex[sourceName] = sf; + this->KnownFileSearchIndex[sourceName] = sf.get(); } - return sf; + this->SourceFiles.push_back(std::move(sf)); + + return this->SourceFiles.back().get(); } cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, @@ -4084,9 +4092,10 @@ cmTest* cmMakefile::CreateTest(const std::string& testName) if (test) { return test; } - test = new cmTest(this); - test->SetName(testName); - this->Tests[testName] = test; + auto newTest = cm::make_unique<cmTest>(this); + test = newTest.get(); + newTest->SetName(testName); + this->Tests[testName] = std::move(newTest); return test; } @@ -4094,7 +4103,7 @@ cmTest* cmMakefile::GetTest(const std::string& testName) const { auto mi = this->Tests.find(testName); if (mi != this->Tests.end()) { - return mi->second; + return mi->second.get(); } return nullptr; } @@ -4102,7 +4111,7 @@ cmTest* cmMakefile::GetTest(const std::string& testName) const void cmMakefile::GetTests(const std::string& config, std::vector<cmTest*>& tests) { - for (auto generator : this->GetTestGenerators()) { + for (const auto& generator : this->GetTestGenerators()) { if (generator->TestsForConfig(config)) { tests.push_back(generator->GetTest()); } @@ -4215,8 +4224,8 @@ cmTarget* cmMakefile::AddImportedTarget(const std::string& name, this->GetGlobalGenerator()->IndexTarget(target.get()); // Transfer ownership to this cmMakefile object. - this->ImportedTargetsOwned.push_back(target.get()); - return target.release(); + this->ImportedTargetsOwned.push_back(std::move(target)); + return this->ImportedTargetsOwned.back().get(); } cmTarget* cmMakefile::FindTargetToUse(const std::string& name, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 085c1d6..b13716b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -431,7 +431,7 @@ public: /** Get the target map - const version */ cmTargetMap const& GetTargets() const { return this->Targets; } - const std::vector<cmTarget*>& GetOwnedImportedTargets() const + const std::vector<std::unique_ptr<cmTarget>>& GetOwnedImportedTargets() const { return this->ImportedTargetsOwned; } @@ -727,7 +727,7 @@ public: /** * Get all the source files this makefile knows about */ - const std::vector<cmSourceFile*>& GetSourceFiles() const + const std::vector<std::unique_ptr<cmSourceFile>>& GetSourceFiles() const { return this->SourceFiles; } @@ -794,28 +794,22 @@ public: //! Initialize a makefile from its parent void InitializeFromParent(cmMakefile* parent); - void AddInstallGenerator(cmInstallGenerator* g) - { - if (g) { - this->InstallGenerators.push_back(g); - } - } - std::vector<cmInstallGenerator*>& GetInstallGenerators() + void AddInstallGenerator(std::unique_ptr<cmInstallGenerator> g); + + std::vector<std::unique_ptr<cmInstallGenerator>>& GetInstallGenerators() { return this->InstallGenerators; } - const std::vector<cmInstallGenerator*>& GetInstallGenerators() const + const std::vector<std::unique_ptr<cmInstallGenerator>>& + GetInstallGenerators() const { return this->InstallGenerators; } - void AddTestGenerator(cmTestGenerator* g) - { - if (g) { - this->TestGenerators.push_back(g); - } - } - const std::vector<cmTestGenerator*>& GetTestGenerators() const + void AddTestGenerator(std::unique_ptr<cmTestGenerator> g); + + const std::vector<std::unique_ptr<cmTestGenerator>>& GetTestGenerators() + const { return this->TestGenerators; } @@ -948,7 +942,8 @@ public: std::unique_ptr<cmCompiledGeneratorExpression> outputName, std::unique_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent); - std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const; + const std::vector<std::unique_ptr<cmGeneratorExpressionEvaluationFile>>& + GetEvaluationFiles() const; std::vector<cmExportBuildFileGenerator*> GetExportBuildFileGenerators() const; @@ -983,8 +978,7 @@ protected: using TargetsVec = std::vector<cmTarget*>; TargetsVec OrderedTargets; - using SourceFileVec = std::vector<cmSourceFile*>; - SourceFileVec SourceFiles; + std::vector<std::unique_ptr<cmSourceFile>> SourceFiles; // Because cmSourceFile names are compared in a fuzzy way (see // cmSourceFileLocation::Match()) we can't have a straight mapping from @@ -992,14 +986,15 @@ protected: // Name portion of the cmSourceFileLocation and then compare on the list of // cmSourceFiles that might match that name. Note that on platforms which // have a case-insensitive filesystem we store the key in all lowercase. - using SourceFileMap = std::unordered_map<std::string, SourceFileVec>; + using SourceFileMap = + std::unordered_map<std::string, std::vector<cmSourceFile*>>; SourceFileMap SourceFileSearchIndex; // For "Known" paths we can store a direct filename to cmSourceFile map std::unordered_map<std::string, cmSourceFile*> KnownFileSearchIndex; // Tests - std::map<std::string, cmTest*> Tests; + std::map<std::string, std::unique_ptr<cmTest>> Tests; // The set of include directories that are marked as system include // directories. @@ -1008,8 +1003,8 @@ protected: std::vector<std::string> ListFiles; std::vector<std::string> OutputFiles; - std::vector<cmInstallGenerator*> InstallGenerators; - std::vector<cmTestGenerator*> TestGenerators; + std::vector<std::unique_ptr<cmInstallGenerator>> InstallGenerators; + std::vector<std::unique_ptr<cmTestGenerator>> TestGenerators; std::string ComplainFileRegularExpression; std::string DefineFlags; @@ -1060,13 +1055,14 @@ private: std::vector<cmMakefile*> UnConfiguredDirectories; std::vector<cmExportBuildFileGenerator*> ExportBuildFileGenerators; - std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles; + std::vector<std::unique_ptr<cmGeneratorExpressionEvaluationFile>> + EvaluationFiles; std::vector<cmExecutionStatus*> ExecutionStatusStack; friend class cmMakefileCall; friend class cmParseFileScope; - std::vector<cmTarget*> ImportedTargetsOwned; + std::vector<std::unique_ptr<cmTarget>> ImportedTargetsOwned; using TargetMap = std::unordered_map<std::string, cmTarget*>; TargetMap ImportedTargets; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index bd19b28..5a8c144 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1196,6 +1196,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(), vars); + if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { + if (source->GetFullPath() == pchSource) { + this->addPoolNinjaVariable("JOB_POOL_PRECOMPILE_HEADER", + this->GetGeneratorTarget(), vars); + } + } + this->SetMsvcTargetPdbVariable(vars, config); objBuild.RspFile = objectFileName + ".rsp"; diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 46f1716..2edff25 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -883,7 +883,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // The reason is that their file names might be discovered from source files // at generation time. if (this->MocOrUicEnabled()) { - for (cmSourceFile* sf : this->Makefile->GetSourceFiles()) { + for (const auto& sf : this->Makefile->GetSourceFiles()) { // sf->GetExtension() is only valid after sf->ResolveFullPath() ... // Since we're iterating over source files that might be not in the // target we need to check for path errors (not existing files). @@ -896,15 +896,15 @@ bool cmQtAutoGenInitializer::InitScanFiles() cmSystemTools::LowerCase(sf->GetExtension()); if (cm->IsHeaderExtension(extLower)) { - if (!cmContains(this->AutogenTarget.Headers, sf)) { - auto muf = makeMUFile(sf, fullPath, false); + if (!cmContains(this->AutogenTarget.Headers, sf.get())) { + auto muf = makeMUFile(sf.get(), fullPath, false); if (muf->SkipMoc || muf->SkipUic) { addMUHeader(std::move(muf), extLower); } } } else if (cm->IsSourceExtension(extLower)) { - if (!cmContains(this->AutogenTarget.Sources, sf)) { - auto muf = makeMUFile(sf, fullPath, false); + if (!cmContains(this->AutogenTarget.Sources, sf.get())) { + auto muf = makeMUFile(sf.get(), fullPath, false); if (muf->SkipMoc || muf->SkipUic) { addMUSource(std::move(muf)); } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 2a345eb..60adf7f 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -128,7 +128,7 @@ bool cmSourceFile::FindFullPath(std::string* error) // The file is not generated. It must exist on disk. cmMakefile const* makefile = this->Location.GetMakefile(); // Location path - std::string const lPath = this->Location.GetFullPath(); + std::string const& lPath = this->Location.GetFullPath(); // List of extension lists std::array<std::vector<std::string> const*, 2> const extsLists = { { &makefile->GetCMakeInstance()->GetSourceExtensions(), @@ -145,7 +145,7 @@ bool cmSourceFile::FindFullPath(std::string* error) return true; } // Try full path with extension - for (auto exts : extsLists) { + for (auto& exts : extsLists) { for (std::string const& ext : *exts) { if (!ext.empty()) { std::string extPath = cmStrCat(fullPath, '.', ext); diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index df702b0..5f807b8 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -31,7 +31,8 @@ cmSourceFileLocation::cmSourceFileLocation(cmMakefile const* mf, this->AmbiguousExtension = true; this->Directory = cmSystemTools::GetFilenamePath(name); if (cmSystemTools::FileIsFullPath(this->Directory)) { - this->Directory = cmSystemTools::CollapseFullPath(this->Directory); + this->Directory = cmSystemTools::CollapseFullPath( + this->Directory, mf->GetHomeOutputDirectory()); } this->Name = cmSystemTools::GetFilenameName(name); if (kind == cmSourceFileLocationKind::Known) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9563321..ae1393f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -513,6 +513,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->GetType() != cmStateEnums::UTILITY) { initProp("JOB_POOL_COMPILE"); initProp("JOB_POOL_LINK"); + initProp("JOB_POOL_PRECOMPILE_HEADER"); } if (impl->TargetType <= cmStateEnums::UTILITY) { @@ -1562,8 +1563,12 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, static void cmTargetCheckIMPORTED_GLOBAL(const cmTarget* target, cmMakefile* context) { - std::vector<cmTarget*> targets = context->GetOwnedImportedTargets(); - auto it = std::find(targets.begin(), targets.end(), target); + const auto& targets = context->GetOwnedImportedTargets(); + auto it = + std::find_if(targets.begin(), targets.end(), + [&](const std::unique_ptr<cmTarget>& importTarget) -> bool { + return target == importTarget.get(); + }); if (it == targets.end()) { std::ostringstream e; e << "Attempt to promote imported target \"" << target->GetName() diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index ad59748..1d9ecc2 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -3,6 +3,7 @@ #include "cmTargetLinkLibrariesCommand.h" #include <cstring> +#include <memory> #include <sstream> #include "cmExecutionStatus.h" @@ -64,11 +65,9 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args, cmTarget* target = mf.GetCMakeInstance()->GetGlobalGenerator()->FindTarget(args[0]); if (!target) { - const std::vector<cmTarget*>& importedTargets = - mf.GetOwnedImportedTargets(); - for (cmTarget* importedTarget : importedTargets) { + for (const auto& importedTarget : mf.GetOwnedImportedTargets()) { if (importedTarget->GetName() == args[0]) { - target = importedTarget; + target = importedTarget.get(); break; } } diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 1619081..e32d693 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -33,8 +33,9 @@ AddCMakeTest(While "") AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") -set_property(TEST CMake.FileDownload PROPERTY +set_tests_properties(CMake.FileDownload PROPERTIES PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" + FAIL_REGULAR_EXPRESSION "Unexpected status" ) AddCMakeTest(FileDownloadBadHash "") set_property(TEST CMake.FileDownloadBadHash PROPERTY diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 3935449..5bd3803 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -1,23 +1,50 @@ +# We do not contact any real URLs, but do try a bogus one. +# Remove any proxy configuration that may change behavior. +unset(ENV{http_proxy}) +unset(ENV{https_proxy}) + +set(timeout 4) + if(NOT "@CMAKE_CURRENT_SOURCE_DIR@" MATCHES "^/") set(slash /) endif() set(url "file://${slash}@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") set(dir "@CMAKE_CURRENT_BINARY_DIR@/downloads") +# Beware Windows asynchronous file/directory removal, rename and then +# remove the renamed dir so we can be certain the dir isn't there when +# we get to the file() commands below +if(EXISTS "${dir}") + file(RENAME ${dir} "${dir}_beingRemoved") + file(REMOVE_RECURSE "${dir}_beingRemoved") +endif() + +function(__reportIfWrongStatus statusPair expectedStatusCode) + list(GET statusPair 0 statusCode) + if(NOT statusCode EQUAL expectedStatusCode) + message(SEND_ERROR + "Unexpected status: ${statusCode}, expected: ${expectedStatusCode}") + endif() +endfunction() + message(STATUS "FileDownload:1") file(DOWNLOAD ${url} ${dir}/file1.png - TIMEOUT 2 + TIMEOUT ${timeout} + STATUS status ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:2") file(DOWNLOAD ${url} ${dir}/file2.png - TIMEOUT 2 + TIMEOUT ${timeout} + STATUS status SHOW_PROGRESS ) +__reportIfWrongStatus("${status}" 0) # Two calls in a row, exactly the same arguments. # Since downloaded file should exist already for 2nd call, @@ -31,82 +58,108 @@ message(STATUS "FileDownload:3") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} + STATUS status EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:4") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA1=67eee17f79d9ac557284fc0b8ad19f25723fb578 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:5") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA224=ba283726bbb602776818b463943189afd91836cb7ee5dd6e2c7b5ae4 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:6") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA256=cf3334b1275071e1da6e8c396ccb72cf1b2388d8c937526f3af26230affb9423 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:7") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA384=43a5d13978d97c660db44481aee0604cb4ff6ca0775cd5c2cd68cd8000e107e507c4caf6c228941231041e282ffb8950 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:8") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA512=6984e0909a1018030ccaa418e3be1654223cdccff0fe6adc745f9aea7e377f178be53b9fc7d54a6f81c2b62ef9ddcd38ba1978fedf4c5e7139baaf355eefad5b ) +__reportIfWrongStatus("${status}" 0) + message(STATUS "FileDownload:9") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH MD5=dbd330d52f4dbd60115d4191904ded92 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:10") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) +__reportIfWrongStatus("${status}" 0) +# Print status because we check its message too message(STATUS "${status}") message(STATUS "FileDownload:11") file(DOWNLOAD badhostname.png ${dir}/file11.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status ) message(STATUS "${status}") -list(GET status 0 status_code) -if(NOT ${status_code} EQUAL 6) - message(SEND_ERROR "error: expected status code 6 for bad host name, got: ${status_code}") +__reportIfWrongStatus("${status}" 6) # 6 corresponds to an unresolvable host name + +message(STATUS "FileDownload:12") +set(absFile "@CMAKE_CURRENT_BINARY_DIR@/file12.png") +if(EXISTS "${absFile}") + file(RENAME ${absFile} "${absFile}_beingRemoved") + file(REMOVE "${absFile}_beingRemoved") +endif() +file(DOWNLOAD + ${url} + file12.png + TIMEOUT ${timeout} + EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 + STATUS status + ) +__reportIfWrongStatus("${status}" 0) +if(NOT EXISTS file12.png) + message(SEND_ERROR "file12.png not downloaded: ${status}") endif() diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake index 9a43569..145f28a 100644 --- a/Tests/CMakeTests/FileTestScript.cmake +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -183,7 +183,7 @@ elseif(testname STREQUAL to_native_path) # pass elseif(testname STREQUAL download_wrong_number_of_args) # fail file(DOWNLOAD zzzz://bogus/ffff) -elseif(testname STREQUAL download_file_with_no_path) # fail +elseif(testname STREQUAL download_file_with_no_path) # pass file(DOWNLOAD zzzz://bogus/ffff ffff) elseif(testname STREQUAL download_missing_time) # fail diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake index f70cd24..01b37c5 100644 --- a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake @@ -27,7 +27,7 @@ else () message(STATUS "CPack_output=${CPack_output}") endif() -set(expected_file_mask "${CPackNSISGenerator_BINARY_DIR}/_CPack_Packages/win32/NSIS/*.nsi") +set(expected_file_mask "${CPackNSISGenerator_BINARY_DIR}/_CPack_Packages/*/NSIS/*.nsi") file(GLOB project_file "${expected_file_mask}") message(STATUS "project_file='${project_file}'") diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 5ba82d8..58b9b03 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -14,4 +14,12 @@ ADD_TEST_MACRO(Cuda.Toolkit Toolkit) ADD_TEST_MACRO(Cuda.IncludePathNoToolkit IncludePathNoToolkit) ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries) ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) +ADD_TEST_MACRO(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) + +# The CUDA only ships the shared version of the toolkit libraries +# on windows +if(NOT WIN32) + ADD_TEST_MACRO(Cuda.StaticRuntimePlusToolkit StaticRuntimePlusToolkit) +endif() + ADD_TEST_MACRO(Cuda.WithC CudaWithC) diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt new file mode 100644 index 0000000..48df558 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.15) +project(SharedRuntimePlusToolkit CXX) + +#Goal for this example: +# Validate that with c++ we can use some components of the CUDA toolkit, and +# specify the cuda runtime +find_package(CUDAToolkit REQUIRED) + +add_library(Common OBJECT curand.cpp nppif.cpp) +target_link_libraries(Common PRIVATE CUDA::toolkit) +set_target_properties(Common PROPERTIES POSITION_INDEPENDENT_CODE ON) + +#shared runtime with shared toolkit libraries +add_library(SharedToolkit SHARED shared.cpp) +target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::nppif) +target_link_libraries(SharedToolkit PUBLIC CUDA::cudart) + +# The CUDA only ships the shared version of the toolkit libraries +# on windows +if(NOT WIN32) + #shared runtime with static toolkit libraries + add_library(StaticToolkit SHARED static.cpp) + target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) + target_link_libraries(StaticToolkit PUBLIC CUDA::cudart) + + #static runtime with mixed toolkit libraries + add_library(MixedToolkit SHARED mixed.cpp) + target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand_static CUDA::nppif) + target_link_libraries(MixedToolkit PUBLIC CUDA::cudart) +endif() + +add_executable(SharedRuntimePlusToolkit main.cpp) +target_link_libraries(SharedRuntimePlusToolkit PRIVATE SharedToolkit + $<TARGET_NAME_IF_EXISTS:StaticToolkit> + $<TARGET_NAME_IF_EXISTS:MixedToolkit>) diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/curand.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/curand.cpp new file mode 100644 index 0000000..fdd7b53 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/curand.cpp @@ -0,0 +1,65 @@ +// Comes from: +// https://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-example + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +/* + * This program uses the host CURAND API to generate 100 + * pseudorandom floats. + */ +#include <cuda.h> +#include <curand.h> +#include <stdio.h> +#include <stdlib.h> + +#define CUDA_CALL(x) \ + do { \ + if ((x) != cudaSuccess) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) +#define CURAND_CALL(x) \ + do { \ + if ((x) != CURAND_STATUS_SUCCESS) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) + +EXPORT int curand_main() +{ + size_t n = 100; + size_t i; + curandGenerator_t gen; + float *devData, *hostData; + + /* Allocate n floats on host */ + hostData = (float*)calloc(n, sizeof(float)); + + /* Allocate n floats on device */ + CUDA_CALL(cudaMalloc((void**)&devData, n * sizeof(float))); + + /* Create pseudo-random number generator */ + CURAND_CALL(curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT)); + + /* Set seed */ + CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL)); + + /* Generate n floats on device */ + CURAND_CALL(curandGenerateUniform(gen, devData, n)); + + /* Copy device memory to host */ + CUDA_CALL( + cudaMemcpy(hostData, devData, n * sizeof(float), cudaMemcpyDeviceToHost)); + + /* Cleanup */ + CURAND_CALL(curandDestroyGenerator(gen)); + CUDA_CALL(cudaFree(devData)); + free(hostData); + return EXIT_SUCCESS; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp new file mode 100644 index 0000000..2a4da22 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp @@ -0,0 +1,23 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +IMPORT int shared_version(); +int static_version() +{ + return 0; +} +int mixed_version() +{ + return 0; +} +#else +int shared_version(); +int static_version(); +int mixed_version(); +#endif + +int main() +{ + return mixed_version() == 0 && shared_version() == 0 && + static_version() == 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/mixed.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/mixed.cpp new file mode 100644 index 0000000..6de6886 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/mixed.cpp @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int mixed_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/nppif.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/nppif.cpp new file mode 100644 index 0000000..ac5341c --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/nppif.cpp @@ -0,0 +1,92 @@ +// Comes from +// https://devtalk.nvidia.com/default/topic/1037482/gpu-accelerated-libraries/help-me-help-you-with-modern-cmake-and-cuda-mwe-for-npp/post/5271066/#5271066 + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +#include <cstdio> +#include <iostream> + +#include <assert.h> +#include <cuda_runtime_api.h> +#include <nppi_filtering_functions.h> + +EXPORT int nppif_main() +{ + /** + * 8-bit unsigned single-channel 1D row convolution. + */ + const int simgrows = 32; + const int simgcols = 32; + Npp8u *d_pSrc, *d_pDst; + const int nMaskSize = 3; + NppiSize oROI; + oROI.width = simgcols - nMaskSize; + oROI.height = simgrows; + const int simgsize = simgrows * simgcols * sizeof(d_pSrc[0]); + const int dimgsize = oROI.width * oROI.height * sizeof(d_pSrc[0]); + const int simgpix = simgrows * simgcols; + const int dimgpix = oROI.width * oROI.height; + const int nSrcStep = simgcols * sizeof(d_pSrc[0]); + const int nDstStep = oROI.width * sizeof(d_pDst[0]); + const int pixval = 1; + const int nDivisor = 1; + const Npp32s h_pKernel[nMaskSize] = { pixval, pixval, pixval }; + Npp32s* d_pKernel; + const Npp32s nAnchor = 2; + cudaError_t err = cudaMalloc((void**)&d_pSrc, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pDst, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pKernel, nMaskSize * sizeof(d_pKernel[0])); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // set image to pixval initially + err = cudaMemset(d_pSrc, pixval, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemset(d_pDst, 0, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemcpy(d_pKernel, h_pKernel, nMaskSize * sizeof(d_pKernel[0]), + cudaMemcpyHostToDevice); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // copy src to dst + NppStatus ret = + nppiFilterRow_8u_C1R(d_pSrc, nSrcStep, d_pDst, nDstStep, oROI, d_pKernel, + nMaskSize, nAnchor, nDivisor); + assert(ret == NPP_NO_ERROR); + Npp8u* h_imgres = new Npp8u[dimgpix]; + err = cudaMemcpy(h_imgres, d_pDst, dimgsize, cudaMemcpyDeviceToHost); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // test for filtering + for (int i = 0; i < dimgpix; i++) { + if (h_imgres[i] != (pixval * pixval * nMaskSize)) { + fprintf(stderr, "h_imgres at index %d failed to match\n", i); + return 1; + } + } + + return 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/shared.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/shared.cpp new file mode 100644 index 0000000..f3c3dbc --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/shared.cpp @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +int curand_main(); +int nppif_main(); + +EXPORT int shared_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/static.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/static.cpp new file mode 100644 index 0000000..6932fa3 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/static.cpp @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int static_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt b/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt new file mode 100644 index 0000000..df6c392 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15) +project(StaticRuntimePlusToolkit CXX) + +#Goal for this example: +# Validate that with c++ we can use some components of the CUDA toolkit, and +# specify the cuda runtime +find_package(CUDAToolkit REQUIRED) + +add_library(Common OBJECT curand.cpp nppif.cpp) +target_link_libraries(Common PRIVATE CUDA::toolkit) +set_target_properties(Common PROPERTIES POSITION_INDEPENDENT_CODE ON) + +#static runtime with shared toolkit libraries +add_library(SharedToolkit SHARED shared.cpp) +target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::nppif) +target_link_libraries(SharedToolkit PUBLIC CUDA::cudart_static) + +#static runtime with static toolkit libraries +add_library(StaticToolkit SHARED static.cpp) +target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) +target_link_libraries(StaticToolkit PUBLIC CUDA::cudart_static) + +#static runtime with mixed toolkit libraries +add_library(MixedToolkit SHARED mixed.cpp) +target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand CUDA::nppif_static) +target_link_libraries(MixedToolkit PUBLIC CUDA::cudart_static) + +add_executable(StaticRuntimePlusToolkit main.cpp) +target_link_libraries(StaticRuntimePlusToolkit PRIVATE SharedToolkit StaticToolkit MixedToolkit) diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp new file mode 100644 index 0000000..95872f0 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp @@ -0,0 +1,59 @@ +// Comes from: +// https://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-example + +/* + * This program uses the host CURAND API to generate 100 + * pseudorandom floats. + */ +#include <cuda.h> +#include <curand.h> +#include <stdio.h> +#include <stdlib.h> + +#define CUDA_CALL(x) \ + do { \ + if ((x) != cudaSuccess) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) +#define CURAND_CALL(x) \ + do { \ + if ((x) != CURAND_STATUS_SUCCESS) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) + +int curand_main() +{ + size_t n = 100; + size_t i; + curandGenerator_t gen; + float *devData, *hostData; + + /* Allocate n floats on host */ + hostData = (float*)calloc(n, sizeof(float)); + + /* Allocate n floats on device */ + CUDA_CALL(cudaMalloc((void**)&devData, n * sizeof(float))); + + /* Create pseudo-random number generator */ + CURAND_CALL(curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT)); + + /* Set seed */ + CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL)); + + /* Generate n floats on device */ + CURAND_CALL(curandGenerateUniform(gen, devData, n)); + + /* Copy device memory to host */ + CUDA_CALL( + cudaMemcpy(hostData, devData, n * sizeof(float), cudaMemcpyDeviceToHost)); + + /* Cleanup */ + CURAND_CALL(curandDestroyGenerator(gen)); + CUDA_CALL(cudaFree(devData)); + free(hostData); + return EXIT_SUCCESS; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp new file mode 100644 index 0000000..5a09f8e --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp @@ -0,0 +1,11 @@ + + +int shared_version(); +int static_version(); +int mixed_version(); + +int main() +{ + return mixed_version() == 0 && shared_version() == 0 && + static_version() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp new file mode 100644 index 0000000..a05140d --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int mixed_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp new file mode 100644 index 0000000..2871090 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp @@ -0,0 +1,86 @@ +// Comes from +// https://devtalk.nvidia.com/default/topic/1037482/gpu-accelerated-libraries/help-me-help-you-with-modern-cmake-and-cuda-mwe-for-npp/post/5271066/#5271066 + +#include <cstdio> +#include <iostream> + +#include <assert.h> +#include <cuda_runtime_api.h> +#include <nppi_filtering_functions.h> + +int nppif_main() +{ + /** + * 8-bit unsigned single-channel 1D row convolution. + */ + const int simgrows = 32; + const int simgcols = 32; + Npp8u *d_pSrc, *d_pDst; + const int nMaskSize = 3; + NppiSize oROI; + oROI.width = simgcols - nMaskSize; + oROI.height = simgrows; + const int simgsize = simgrows * simgcols * sizeof(d_pSrc[0]); + const int dimgsize = oROI.width * oROI.height * sizeof(d_pSrc[0]); + const int simgpix = simgrows * simgcols; + const int dimgpix = oROI.width * oROI.height; + const int nSrcStep = simgcols * sizeof(d_pSrc[0]); + const int nDstStep = oROI.width * sizeof(d_pDst[0]); + const int pixval = 1; + const int nDivisor = 1; + const Npp32s h_pKernel[nMaskSize] = { pixval, pixval, pixval }; + Npp32s* d_pKernel; + const Npp32s nAnchor = 2; + cudaError_t err = cudaMalloc((void**)&d_pSrc, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pDst, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pKernel, nMaskSize * sizeof(d_pKernel[0])); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // set image to pixval initially + err = cudaMemset(d_pSrc, pixval, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemset(d_pDst, 0, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemcpy(d_pKernel, h_pKernel, nMaskSize * sizeof(d_pKernel[0]), + cudaMemcpyHostToDevice); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // copy src to dst + NppStatus ret = + nppiFilterRow_8u_C1R(d_pSrc, nSrcStep, d_pDst, nDstStep, oROI, d_pKernel, + nMaskSize, nAnchor, nDivisor); + assert(ret == NPP_NO_ERROR); + Npp8u* h_imgres = new Npp8u[dimgpix]; + err = cudaMemcpy(h_imgres, d_pDst, dimgsize, cudaMemcpyDeviceToHost); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // test for filtering + for (int i = 0; i < dimgpix; i++) { + if (h_imgres[i] != (pixval * pixval * nMaskSize)) { + fprintf(stderr, "h_imgres at index %d failed to match\n", i); + return 1; + } + } + + return 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp new file mode 100644 index 0000000..9967b66 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int shared_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp new file mode 100644 index 0000000..ca7eb4c --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int static_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0534974..d302fe3 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -352,6 +352,7 @@ add_RunCMake_test(alias_targets) add_RunCMake_test(interface_library) add_RunCMake_test(no_install_prefix) add_RunCMake_test(configure_file) +add_RunCMake_test(CTestTimeout -DTIMEOUT=${CTestTestTimeout_TIME}) add_RunCMake_test(CTestTimeoutAfterMatch) # ctresalloc links against CMakeLib and CTestLib, which means it can't be built @@ -603,6 +604,9 @@ set(cpack_tests STGZ External ) +if(APPLE) + list(APPEND cpack_tests DragNDrop) +endif() add_RunCMake_test_group(CPack "${cpack_tests}") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used diff --git a/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake b/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake new file mode 100644 index 0000000..023e597 --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake @@ -0,0 +1,54 @@ +set(ALL_FILES_GLOB "*.dmg") + +function(getPackageContent FILE RESULT_VAR) + get_filename_component(path_ "${FILE}" DIRECTORY) + file(REMOVE_RECURSE "${path_}/content") + file(MAKE_DIRECTORY "${path_}/content") + execute_process(COMMAND ${HDIUTIL_EXECUTABLE} attach -mountroot ${path_}/content -nobrowse ${FILE} + RESULT_VARIABLE attach_result_ + ERROR_VARIABLE attach_error_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(attach_result_) + message(FATAL_ERROR "Failed to attach DMG: '${attach_result_}';" + " '${attach_error_}'.") + endif() + + file(GLOB_RECURSE package_content_ LIST_DIRECTORIES true RELATIVE + "${path_}/content" "${path_}/content/*") + # Some versions of macOS have .Trashes, others do not. + list(FILTER package_content_ EXCLUDE REGEX "/.Trashes$") + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) + + execute_process(COMMAND ${HDIUTIL_EXECUTABLE} detach ${path_}/content/volume-name + RESULT_VARIABLE detach_result_ + ERROR_VARIABLE detach_error_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(detach_result_) + message(FATAL_ERROR "Failed to detach DMG: '${detach_result_}';" + " '${detach_error_}'.") + endif() +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} "${NAME}-${VERSION}-Darwin${COMPONENT}.dmg" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + getPackageContent("${FILE}" package_content_) + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + set(prefix_ "volume-name") + list(TRANSFORM ${CONTENT_VAR} PREPEND "${prefix_}" OUTPUT_VARIABLE prepared_) + list(APPEND prepared_ "${prefix_}") + + set(${CONTENT_VAR} "${prepared_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/DragNDrop/Prerequirements.cmake b/Tests/RunCMake/CPack/DragNDrop/Prerequirements.cmake new file mode 100644 index 0000000..f0aaf2c --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/Prerequirements.cmake @@ -0,0 +1,8 @@ +function(get_test_prerequirements found_var config_file) + find_program(HDIUTIL_EXECUTABLE hdiutil) + + if(HDIUTIL_EXECUTABLE) + file(WRITE "${config_file}" "set(HDIUTIL_EXECUTABLE \"${HDIUTIL_EXECUTABLE}\")") + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DragNDrop/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/DragNDrop/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..aa6c8ff --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/packaging_COMPONENT_default.cmake @@ -0,0 +1,3 @@ +set(CPACK_COMPONENTS_GROUPING "IGNORE") +set(CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK ON) +set(CPACK_DMG_VOLUME_NAME "volume-name") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 6e413aa..0fb0cc4 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -5,7 +5,7 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") # run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM.CUSTOM_BINARY_SPEC_FILE" false "MONOLITHIC;COMPONENT") -run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ" true "COMPONENT") +run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ;DragNDrop" true "COMPONENT") run_cpack_test(DEBUGINFO "RPM.DEBUGINFO;DEB.DEBUGINFO" true "COMPONENT") run_cpack_test_subtests(DEFAULT_PERMISSIONS "CMAKE_var_set;CPACK_var_set;both_set;invalid_CMAKE_var;invalid_CPACK_var" "RPM.DEFAULT_PERMISSIONS;DEB.DEFAULT_PERMISSIONS" false "MONOLITHIC;COMPONENT") run_cpack_test(DEPENDENCIES "RPM.DEPENDENCIES;DEB.DEPENDENCIES" true "COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake index 07226df..9ac19e2 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake @@ -12,4 +12,7 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") elseif(GENERATOR_TYPE STREQUAL "TGZ") set(EXPECTED_FILE_2 "second.tar.gz") set(EXPECTED_FILE_3 "pkg_3_abc.tar.gz") +elseif(GENERATOR_TYPE STREQUAL "DragNDrop") + set(EXPECTED_FILE_2 "second.dmg") + set(EXPECTED_FILE_3 "pkg_3_abc.dmg") endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake index 4c20e41..899258e 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake @@ -10,6 +10,9 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") elseif(GENERATOR_TYPE STREQUAL "TGZ") set(CPACK_ARCHIVE_PKG_2_FILE_NAME "second") set(CPACK_ARCHIVE_PKG_3_FILE_NAME "pkg_3_abc") +elseif(GENERATOR_TYPE STREQUAL "DragNDrop") + set(CPACK_DMG_PKG_2_FILE_NAME "second") + set(CPACK_DMG_PKG_3_FILE_NAME "pkg_3_abc") endif() install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) diff --git a/Tests/RunCMake/CTestTimeout/Basic-stdout.txt b/Tests/RunCMake/CTestTimeout/Basic-stdout.txt new file mode 100644 index 0000000..30ed178 --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/Basic-stdout.txt @@ -0,0 +1,6 @@ +Test project [^ +]*/Tests/RunCMake/CTestTimeout/Basic-build + Start 1: TestTimeout +1/1 Test #1: TestTimeout ......................\*\*\*Timeout +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 diff --git a/Tests/RunCMake/CTestTimeout/CMakeLists.txt.in b/Tests/RunCMake/CTestTimeout/CMakeLists.txt.in new file mode 100644 index 0000000..20faa94 --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/CMakeLists.txt.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.16) +project(CTestTest@CASE_NAME@ C) +include(CTest) + +add_executable(TestTimeout TestTimeout.c) + +if(NOT TIMEOUT) + set(TIMEOUT 4) +endif() +target_compile_definitions(TestTimeout PRIVATE TIMEOUT=${TIMEOUT}) + +add_test(NAME TestTimeout COMMAND TestTimeout) +set_property(TEST TestTimeout PROPERTY TIMEOUT ${TIMEOUT}) + +@CASE_CMAKELISTS_SUFFIX_CODE@ diff --git a/Tests/RunCMake/CTestTimeout/Fork-stdout.txt b/Tests/RunCMake/CTestTimeout/Fork-stdout.txt new file mode 100644 index 0000000..284e4b1 --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/Fork-stdout.txt @@ -0,0 +1,6 @@ +Test project [^ +]*/Tests/RunCMake/CTestTimeout/Fork-build + Start 1: TestTimeout +1/1 Test #1: TestTimeout ......................\*\*\*Timeout +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 diff --git a/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake b/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake new file mode 100644 index 0000000..7e96b6d --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake @@ -0,0 +1,22 @@ +include(RunCTest) + +if(NOT TIMEOUT) + # Give the process time to load and start running. + set(TIMEOUT 4) +endif() + +function(run_ctest_timeout CASE_NAME) + configure_file(${RunCMake_SOURCE_DIR}/TestTimeout.c + ${RunCMake_BINARY_DIR}/${CASE_NAME}/TestTimeout.c COPYONLY) + run_ctest(${CASE_NAME}) +endfunction() + +run_ctest_timeout(Basic) + +if(UNIX) + string(CONCAT CASE_CMAKELISTS_SUFFIX_CODE [[ + target_compile_definitions(TestTimeout PRIVATE FORK) +]]) + run_ctest_timeout(Fork) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endif() diff --git a/Tests/RunCMake/CTestTimeout/TestTimeout.c b/Tests/RunCMake/CTestTimeout/TestTimeout.c new file mode 100644 index 0000000..5a008a7 --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/TestTimeout.c @@ -0,0 +1,24 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +#include <stdio.h> + +int main(void) +{ +#ifdef FORK + pid_t pid = fork(); + if (pid != 0) { + return 0; + } +#endif + +#if defined(_WIN32) + Sleep((TIMEOUT + 4) * 1000); +#else + sleep((TIMEOUT + 4)); +#endif + return 0; +} diff --git a/Tests/RunCMake/CTestTimeout/test.cmake.in b/Tests/RunCMake/CTestTimeout/test.cmake.in new file mode 100644 index 0000000..be2625b --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/test.cmake.in @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.16) +@CASE_TEST_PREFIX_CODE@ + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +ctest_start(Experimental) +ctest_configure(OPTIONS "-DTIMEOUT=@TIMEOUT@") +ctest_build() +ctest_test() diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 4b9d3ed..f3208ed 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -76,7 +76,7 @@ endfunction() set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Simple-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE=RelWithDebInfo;-DCMAKE_NINJA_CROSS_CONFIG_ENABLE=ON") +set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE=RelWithDebInfo;-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON") run_cmake_configure(Simple) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -117,7 +117,7 @@ run_ninja(SimpleNoCross all-all build-Debug.ninja all:all) run_cmake_build(SimpleNoCross all-clean Debug clean:all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandGenerator-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_CROSS_CONFIG_ENABLE=ON") +set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON") run_cmake_configure(CustomCommandGenerator) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -134,7 +134,7 @@ run_ninja(CustomCommandGenerator release-in-debug-graph build-Debug.ninja genera run_cmake_command(CustomCommandGenerator-release-in-debug-graph-generated "${TARGET_FILE_generated_Release}") set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandsAndTargets-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_CROSS_CONFIG_ENABLE=ON") +set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON") run_cmake_configure(CustomCommandsAndTargets) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -150,7 +150,7 @@ run_cmake_build(CustomCommandsAndTargets debug-targetpostbuild Debug TopTargetPo run_ninja(CustomCommandsAndTargets release-targetpostbuild build-Release.ninja SubdirTargetPostBuild) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PostfixAndLocation-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NINJA_CROSS_CONFIG_ENABLE=ON") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON") run_cmake_configure(PostfixAndLocation) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -165,14 +165,14 @@ run_ninja(Clean release-notall build-Release.ninja exenotall) run_cmake_build(Clean release-clean Release clean) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AdditionalCleanFiles-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_CROSS_CONFIG_ENABLE=ON") +set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON") run_cmake_configure(AdditionalCleanFiles) unset(RunCMake_TEST_OPTIONS) run_cmake_build(AdditionalCleanFiles release-clean Release clean) run_ninja(AdditionalCleanFiles all-clean build-Debug.ninja clean:all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Install-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_NINJA_CROSS_CONFIG_ENABLE=ON") +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON") run_cmake_configure(Install) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -194,7 +194,7 @@ endif() if(CMake_TEST_Qt5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5-build) - set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_CROSS_CONFIG_ENABLE=ON") + set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON") run_cmake_configure(Qt5) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake index 32bb8e7..72cc2b9 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake @@ -1,5 +1,5 @@ -set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") -set(unitybuild_c1 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_1.c") +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") +set(unitybuild_c1 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_1_c.c") if(NOT EXISTS "${unitybuild_c0}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.") return() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake index c980df0..024286d 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") if(NOT EXISTS "${unitybuild_c}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} does not exist.") return() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake index 32c2992..269d545 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake @@ -1,10 +1,10 @@ -set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") if(NOT EXISTS "${unitybuild_c}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} does not exist.") return() endif() -set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.cxx") +set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_cxx.cxx") if(NOT EXISTS "${unitybuild_cxx}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_cxx} does not exist.") return() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake index cb71ea3..22d2fc6 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") if(EXISTS "${unitybuild_c}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} should not exist.") return() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake index 8fcb18f..e0935c7 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") file(STRINGS ${unitybuild_c} unitybuild_c_strings) string(REGEX MATCH "#define NOMINMAX.*#include.*s1.c.*#undef NOMINMAX" matched_code ${unitybuild_c_strings}) if(NOT matched_code) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake index 89a037a..9ef4c21 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.cxx") +set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_cxx.cxx") if(NOT EXISTS "${unitybuild_cxx}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_cxx} does not exist.") return() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake index 7dfc007..9d39a70 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") file(STRINGS ${unitybuild_c0} unitybuild_c_strings REGEX "/s[0-9]+.c\"$" ) list(LENGTH unitybuild_c_strings number_of_includes) if(NOT number_of_includes EQUAL 8) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake index 533a89c..f26ec2e 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") file(STRINGS ${unitybuild_c} unitybuild_c_strings) string(REGEX MATCH ".*#include.*s3.c.*#include.*s1.c.*#include.*s2.c.*" matched_code ${unitybuild_c_strings}) if(NOT matched_code) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake index fdd45bc..e94ad72 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") file(STRINGS ${unitybuild_c} unitybuild_c_strings) string(REGEX MATCH "\\/s[1-6].c" matched_files_1_6 ${unitybuild_c_strings}) diff --git a/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake index 87f247d..693dcd9 100644 --- a/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake +++ b/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") if(NOT EXISTS "${unitybuild_c0}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.") return() @@ -32,7 +32,7 @@ if (NOT have_unity_support) endif() string(REPLACE "\\" "/" unity_source_line "${unity_source_line}") -string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0.c" unity_source_file_position) +string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0_c.c" unity_source_file_position) if (unity_source_file_position EQUAL "-1") set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.") return() diff --git a/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake index 1c6bab8..17e7b46 100644 --- a/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake +++ b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake @@ -1,4 +1,4 @@ -set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c") if(NOT EXISTS "${unitybuild_c0}") set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.") return() @@ -28,7 +28,7 @@ foreach(line IN LISTS tgt_projects_strings) endforeach() string(REPLACE "\\" "/" unity_source_line ${unity_source_line}) -string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0.c" unity_source_file_position) +string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0_c.c" unity_source_file_position) if (unity_source_file_position EQUAL "-1") set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.") return() |