Merge topic 'macos-bundle-content-dir' 6b3ec3fefb Ninja/Makefile: Add support for copying directories into Apple bundles Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !10508
diff --git a/Auxiliary/cmake.m4 b/Auxiliary/cmake.m4 index 205b0e4..19ead8f 100644 --- a/Auxiliary/cmake.m4 +++ b/Auxiliary/cmake.m4
@@ -1,6 +1,10 @@ dnl Distributed under the OSI-approved BSD 3-Clause License. See accompanying dnl file LICENSE.rst or https://cmake.org/licensing for details. +# CMAKE_FIND_BINARY +# ----------------- +# Finds the cmake command-line binary and sets its absolute path in the +# CMAKE_BINARY variable. AC_DEFUN([CMAKE_FIND_BINARY], [AC_ARG_VAR([CMAKE_BINARY], [path to the cmake binary])dnl @@ -9,13 +13,33 @@ fi ])dnl -# $1: package name -# $2: language (e.g. C/CXX/Fortran) -# $3: The compiler ID, defaults to GNU. -# Possible values are: GNU, Intel, Clang, SunPro, HP, XL, VisualAge, PGI, -# PathScale, Cray, SCO, MSVC, LCC -# $4: optional extra arguments to cmake, e.g. "-DCMAKE_SIZEOF_VOID_P=8" -# $5: optional path to cmake binary +# CMAKE_FIND_PACKAGE(package, lang, [compiler-id], [cmake-args], +# [action-if-found], [action-if-not-found]) +# -------------------------------------------------------------- +# Finds a package with CMake. +# +# package: +# The name of the package as called in CMake with find_package(package). +# +# lang: +# The programming language to use (e.g., C, CXX, Fortran). +# See https://cmake.org/cmake/help/latest/command/enable_language.html +# for a complete list of supported languages. +# +# compiler-id: +# (Optional) The compiler ID to use. Defaults to GNU. +# See https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html +# for possible values. +# +# cmake-args: +# (Optional) Additional arguments to pass to cmake command, e.g., +# -DCMAKE_SIZEOF_VOID_P=8. +# +# action-if-found: +# (Optional) Commands to execute if the package is found. +# +# action-if-not-found: +# (Optional) Commands to execute if the package is not found. AC_DEFUN([CMAKE_FIND_PACKAGE], [ AC_REQUIRE([CMAKE_FIND_BINARY])dnl
diff --git a/CMakeLists.txt b/CMakeLists.txt index 974b2c3..4c041d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -392,8 +392,8 @@ include(CTest) # Set up test-time configuration. -set_directory_properties(PROPERTIES - TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake") +set_property(DIRECTORY APPEND PROPERTY + TEST_INCLUDE_FILES "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake") if(NOT CMake_TEST_EXTERNAL_CMAKE) # where to write the resulting executables and libraries
diff --git a/Help/command/ctest_start.rst b/Help/command/ctest_start.rst index 2d68a37..9c4e3dc 100644 --- a/Help/command/ctest_start.rst +++ b/Help/command/ctest_start.rst
@@ -80,8 +80,8 @@ However, for the sake of readability, it is recommended that you order your parameters in the order listed at the top of this page. -If the :variable:`CTEST_CHECKOUT_COMMAND` variable (or the -:variable:`CTEST_CVS_CHECKOUT` variable) is set, its content is treated as +If the :variable:`CTEST_CHECKOUT_COMMAND` variable is set, its content is +treated as command-line. The command is invoked with the current working directory set to the parent of the source directory, even if the source directory already exists. This can be used to create the source tree from a version control
diff --git a/Help/command/execute_process.rst b/Help/command/execute_process.rst index c2c7fe3..a2f9036 100644 --- a/Help/command/execute_process.rst +++ b/Help/command/execute_process.rst
@@ -121,6 +121,10 @@ and standard error pipes, respectively. If the same variable is named for both pipes their output will be merged in the order produced. +``OUTPUT_STRIP_TRAILING_WHITESPACE``, ``ERROR_STRIP_TRAILING_WHITESPACE`` + Removes whitespace characters from the end of the values stored in the + corresponding ``OUTPUT_VARIABLE`` and ``ERROR_VARIABLE`` variables. + ``ECHO_OUTPUT_VARIABLE``, ``ECHO_ERROR_VARIABLE`` .. versionadded:: 3.18
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 7f61493..b5d04ea 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst
@@ -8,7 +8,7 @@ can be specified in the :variable:`CMAKE_MODULE_PATH` variable. Utility Modules -^^^^^^^^^^^^^^^ +=============== These modules are loaded using the :command:`include` command. @@ -95,7 +95,7 @@ /module/UsewxWidgets Find Modules -^^^^^^^^^^^^ +============ These modules search for third-party software. They are normally called through the :command:`find_package` command. @@ -132,7 +132,6 @@ /module/FindFontconfig /module/FindFreetype /module/FindGCCXML - /module/FindGDAL /module/FindGettext /module/FindGIF /module/FindGit @@ -256,10 +255,10 @@ /module/FindZLIB Deprecated Modules -^^^^^^^^^^^^^^^^^^^ +================== Deprecated Utility Modules -========================== +-------------------------- .. toctree:: :maxdepth: 1 @@ -285,7 +284,7 @@ /module/WriteCompilerDetectionHeader Deprecated Find Modules -======================= +----------------------- .. toctree:: :maxdepth: 1 @@ -293,6 +292,7 @@ /module/FindBoost /module/FindCUDA /module/FindDart + /module/FindGDAL /module/FindITK /module/FindPythonInterp /module/FindPythonLibs @@ -302,7 +302,7 @@ /module/FindwxWindows Legacy CPack Modules -==================== +-------------------- These modules used to be mistakenly exposed to the user, and have been moved out of user visibility. They are for CPack internal use, and should never be
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 735f11e..49e6f88 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst
@@ -31,7 +31,6 @@ /variable/CMAKE_CACHE_MINOR_VERSION /variable/CMAKE_CACHE_PATCH_VERSION /variable/CMAKE_CACHEFILE_DIR - /variable/CMAKE_CFG_INTDIR /variable/CMAKE_COMMAND /variable/CMAKE_CPACK_COMMAND /variable/CMAKE_CROSSCOMPILING @@ -829,6 +828,7 @@ .. toctree:: :maxdepth: 1 + /variable/CMAKE_CFG_INTDIR /variable/CMAKE_EXTRA_GENERATOR Deprecated Variables that Change Behavior
diff --git a/Help/prop_dir/TEST_INCLUDE_FILE.rst b/Help/prop_dir/TEST_INCLUDE_FILE.rst index 31b2382..883b124 100644 --- a/Help/prop_dir/TEST_INCLUDE_FILE.rst +++ b/Help/prop_dir/TEST_INCLUDE_FILE.rst
@@ -1,9 +1,14 @@ TEST_INCLUDE_FILE ----------------- -Deprecated. Use :prop_dir:`TEST_INCLUDE_FILES` instead. +.. deprecated:: 3.10 -A cmake file that will be included when ctest is run. + Use the :prop_dir:`TEST_INCLUDE_FILES` directory property instead, which + supports specifying multiple files. -If you specify ``TEST_INCLUDE_FILE``, that file will be included and -processed when ctest is run on the directory. +The ``TEST_INCLUDE_FILE`` directory property specifies a CMake script that is +included and processed when ``ctest`` is run on the directory. + +If both the ``TEST_INCLUDE_FILE`` and :prop_dir:`TEST_INCLUDE_FILES` directory +properties are set, the script specified in ``TEST_INCLUDE_FILE`` is included +first, followed by the scripts listed in ``TEST_INCLUDE_FILES``.
diff --git a/Help/prop_dir/TEST_INCLUDE_FILES.rst b/Help/prop_dir/TEST_INCLUDE_FILES.rst index f9a66f4..f1c583f 100644 --- a/Help/prop_dir/TEST_INCLUDE_FILES.rst +++ b/Help/prop_dir/TEST_INCLUDE_FILES.rst
@@ -3,7 +3,38 @@ .. versionadded:: 3.10 -A list of cmake files that will be included when ctest is run. +This directory property specifies a list of CMake scripts to be included and +processed when ``ctest`` runs on the directory. Use absolute paths, to avoid +ambiguity. Script files are included in the specified order. -If you specify ``TEST_INCLUDE_FILES``, those files will be included and -processed when ctest is run on the directory. +``TEST_INCLUDE_FILES`` scripts are processed when running ``ctest``, not during +the ``cmake`` configuration phase. These scripts should be written as if they +were CTest dashboard scripts. It is common to generate such scripts dynamically +since many variables and commands available during configuration are not +accessible at test phase. + +Examples +^^^^^^^^ + +Setting this directory property to append one or more CMake scripts: + +.. code-block:: cmake + :caption: CMakeLists.txt + + configure_file(script.cmake.in script.cmake) + + set_property( + DIRECTORY + APPEND + PROPERTY TEST_INCLUDE_FILES + ${CMAKE_CURRENT_BINARY_DIR}/script.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/foo.cmake + ${dir}/bar.cmake + ) + +.. code-block:: cmake + :caption: script.cmake.in + + execute_process( + COMMAND "@CMAKE_COMMAND@" -E echo "script.cmake executed during CTest" + )
diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst index b376894..221ef47 100644 --- a/Help/prop_tgt/AUTOMOC.rst +++ b/Help/prop_tgt/AUTOMOC.rst
@@ -5,7 +5,7 @@ ``AUTOMOC`` is a boolean specifying whether CMake will handle the Qt ``moc`` preprocessor automatically, i.e. without having to use commands like -:module:`QT4_WRAP_CPP() <FindQt4>`, `qt5_wrap_cpp()`_, etc. +:module:`qt4_wrap_cpp() <FindQt4>`, `qt5_wrap_cpp()`_, etc. Currently, Qt versions 4 to 6 are supported. .. _qt5_wrap_cpp(): https://doc.qt.io/qt-5/qtcore-cmake-qt5-wrap-cpp.html
diff --git a/Help/prop_tgt/AUTORCC.rst b/Help/prop_tgt/AUTORCC.rst index fea906c..eadffa3 100644 --- a/Help/prop_tgt/AUTORCC.rst +++ b/Help/prop_tgt/AUTORCC.rst
@@ -5,7 +5,7 @@ ``AUTORCC`` is a boolean specifying whether CMake will handle the Qt ``rcc`` code generator automatically, i.e. without having to use -commands like :module:`QT4_ADD_RESOURCES() <FindQt4>`, `qt5_add_resources()`_, +commands like :module:`qt4_add_resources() <FindQt4>`, `qt5_add_resources()`_, etc. Currently, Qt versions 4 to 6 are supported. .. _`qt5_add_resources()`: https://doc.qt.io/qt-5/qtcore-cmake-qt5-add-resources.html
diff --git a/Help/prop_tgt/AUTOUIC.rst b/Help/prop_tgt/AUTOUIC.rst index 5010220..4dce1b5 100644 --- a/Help/prop_tgt/AUTOUIC.rst +++ b/Help/prop_tgt/AUTOUIC.rst
@@ -5,7 +5,7 @@ ``AUTOUIC`` is a boolean specifying whether CMake will handle the Qt ``uic`` code generator automatically, i.e. without having to use -commands like :module:`QT4_WRAP_UI() <FindQt4>`, `qt5_wrap_ui()`_, etc. +commands like :module:`qt4_wrap_ui() <FindQt4>`, `qt5_wrap_ui()`_, etc. Currently, Qt versions 4 to 6 are supported. .. _`qt5_wrap_ui()`: https://doc.qt.io/qt-5/qtwidgets-cmake-qt5-wrap-ui.html
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index f46ac73..bed7dc2 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -41,6 +41,8 @@ ``OpenWatcom`` `Open Watcom`_ ``PGI`` The Portland Group ``PathScale`` PathScale +``QCC`` QNX C/C++ compiler +``SCO`` SCO OpenServer/UnixWare C/C++ Compiler ``SDCC`` `Small Device C Compiler`_ ``SunPro`` Oracle Developer Studio ``Tasking`` `Tasking Compiler Toolsets`_
diff --git a/Help/variable/CMAKE_PKG_CONFIG_PC_PATH.rst b/Help/variable/CMAKE_PKG_CONFIG_PC_PATH.rst index fd52c97..8e57b03 100644 --- a/Help/variable/CMAKE_PKG_CONFIG_PC_PATH.rst +++ b/Help/variable/CMAKE_PKG_CONFIG_PC_PATH.rst
@@ -5,4 +5,4 @@ :ref:`Semicolon-separated list <CMake Language Lists>` of supplementary paths which the :command:`cmake_pkg_config` command will search for package files by -efault. Also used to derive the ``pc_path`` package variable. +default. Also used to derive the ``pc_path`` package variable.
diff --git a/Help/variable/CTEST_CVS_CHECKOUT.rst b/Help/variable/CTEST_CVS_CHECKOUT.rst index 32cf9eb..442138f 100644 --- a/Help/variable/CTEST_CVS_CHECKOUT.rst +++ b/Help/variable/CTEST_CVS_CHECKOUT.rst
@@ -1,6 +1,6 @@ CTEST_CVS_CHECKOUT ------------------ -.. versionadded:: 3.1 +.. deprecated:: 3.1 -Deprecated. Use :variable:`CTEST_CHECKOUT_COMMAND` instead. + Use :variable:`CTEST_CHECKOUT_COMMAND` variable instead.
diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index 4491c96..b0e6c16 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake
@@ -48,7 +48,7 @@ # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see # if the compiler accepts it if(NOT CMAKE_TRY_ANSI_CXX_FLAGS STREQUAL "") - CHECK_CXX_ACCEPTS_FLAG(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS) + check_cxx_accepts_flag(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS) # if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS # to the flag if(CMAKE_CXX_ACCEPTS_FLAGS)
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 5198231..1cb91f0 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -70,7 +70,7 @@ # We determine the vendor to help with find the toolkit and use the right flags for detection right away. # The main compiler identification is still needed below to extract other information. list(APPEND CMAKE_CUDA_COMPILER_ID_VENDORS NVIDIA Clang) - set(CMAKE_CUDA_COMPILER_ID_VENDOR_REGEX_NVIDIA "nvcc: NVIDIA \\(R\\) Cuda compiler driver") + set(CMAKE_CUDA_COMPILER_ID_VENDOR_REGEX_NVIDIA "nvcc: [^\n]+ Cuda compiler driver") set(CMAKE_CUDA_COMPILER_ID_VENDOR_REGEX_Clang "(clang version)") CMAKE_DETERMINE_COMPILER_ID_VENDOR(CUDA "--version")
diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake index 041302a..c03fce8 100644 --- a/Modules/CMakeDetermineHIPCompiler.cmake +++ b/Modules/CMakeDetermineHIPCompiler.cmake
@@ -90,7 +90,7 @@ # We determine the vendor to use the right flags for detection right away. # The main compiler identification is still needed below to extract other information. list(APPEND CMAKE_HIP_COMPILER_ID_VENDORS NVIDIA Clang) - set(CMAKE_HIP_COMPILER_ID_VENDOR_REGEX_NVIDIA "nvcc: NVIDIA \\(R\\) Cuda compiler driver") + set(CMAKE_HIP_COMPILER_ID_VENDOR_REGEX_NVIDIA "nvcc: [^\n]+ Cuda compiler driver") set(CMAKE_HIP_COMPILER_ID_VENDOR_REGEX_Clang "(clang version)") CMAKE_DETERMINE_COMPILER_ID_VENDOR(HIP "--version")
diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake index 0a08b71..5a7232f 100644 --- a/Modules/CTestTargets.cmake +++ b/Modules/CTestTargets.cmake
@@ -44,6 +44,9 @@ ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in ${PROJECT_BINARY_DIR}/DartConfiguration.tcl ) endif() + configure_file( + ${CMAKE_ROOT}/Templates/CTestScript.cmake.in + ${PROJECT_BINARY_DIR}/CMakeFiles/CTestScript.cmake @ONLY) endblock() # @@ -73,7 +76,9 @@ # For all generators add basic testing targets. foreach(mode Experimental Nightly Continuous NightlyMemoryCheck) add_custom_target(${mode} - ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode} + COMMAND + ${CMAKE_CTEST_COMMAND} ${__conf_types} + -DMODEL=${mode} -S CMakeFiles/CTestScript.cmake -V USES_TERMINAL ) set_property(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "") @@ -89,7 +94,10 @@ # missing purify ) add_custom_target(${mode}${testtype} - ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype} + COMMAND + ${CMAKE_CTEST_COMMAND} ${__conf_types} + -DMODEL=${mode} -DACTIONS=${testtype} + -S CMakeFiles/CTestScript.cmake -V USES_TERMINAL ) set_property(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "")
diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake index 4798c34..d3387ea 100644 --- a/Modules/FindAVIFile.cmake +++ b/Modules/FindAVIFile.cmake
@@ -5,20 +5,41 @@ FindAVIFile ----------- -Locate `AVIFILE <https://avifile.sourceforge.net/>`_ -library and include paths. +Finds `AVIFile <https://avifile.sourceforge.net/>`_ library and include paths. -AVIFILE is a set of libraries for -i386 machines to use various AVI codecs. Support is limited beyond -Linux. Windows provides native AVI support, and so doesn't need this -library. This module defines +AVIFile is a set of libraries for i386 machines to use various AVI codecs. +Support is limited beyond Linux. Windows provides native AVI support, and so +doesn't need this library. -:: +Result Variables +^^^^^^^^^^^^^^^^ - AVIFILE_INCLUDE_DIR, where to find avifile.h , etc. - AVIFILE_LIBRARIES, the libraries to link against - AVIFILE_DEFINITIONS, definitions to use when compiling - AVIFILE_FOUND, If false, don't try to use AVIFILE +This module defines the following variables: + +``AVIFile_FOUND`` + True if AVIFile is found. For backward compatibility, the ``AVIFILE_FOUND`` + variable is also set to the same value. +``AVIFILE_LIBRARIES`` + The libraries to link against. +``AVIFILE_DEFINITIONS`` + Definitions to use when compiling. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may be also set: + +``AVIFILE_INCLUDE_DIR`` + Directory containing ``avifile.h`` and other AVIFile headers. + +Examples +^^^^^^^^ + +Finding AVIFile: + +.. code-block:: cmake + + find_package(AVIFile) #]=======================================================================] if (UNIX) @@ -31,7 +52,7 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(AVIFile DEFAULT_MSG AVIFILE_INCLUDE_DIR AVIFILE_AVIPLAY_LIBRARY) -if (AVIFILE_FOUND) +if (AVIFile_FOUND) set(AVIFILE_LIBRARIES ${AVIFILE_AVIPLAY_LIBRARY}) set(AVIFILE_DEFINITIONS "") endif()
diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index f9250ae..61a5fb3 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake
@@ -5,35 +5,39 @@ FindBullet ---------- -Try to find the Bullet physics engine +Finds the Bullet physics engine. +Result Variables +^^^^^^^^^^^^^^^^ +This module defines the following variables: -:: +``Bullet_FOUND`` + Boolean true if Bullet was found. For backward compatibility, the + ``BULLET_FOUND`` variable is also set to the same value. +``BULLET_INCLUDE_DIRS`` + The Bullet include directories. +``BULLET_LIBRARIES`` + Libraries needed to link to Bullet. By default, all Bullet components + (Dynamics, Collision, LinearMath, and SoftBody) are added. - This module defines the following variables +Hints +^^^^^ +This module accepts the following variables: +``BULLET_ROOT`` + Can be set to Bullet install path or Windows build path to specify where to + find Bullet. -:: +Examples +^^^^^^^^ - BULLET_FOUND - Was bullet found - BULLET_INCLUDE_DIRS - the Bullet include directories - BULLET_LIBRARIES - Link to this, by default it includes - all bullet components (Dynamics, - Collision, LinearMath, & SoftBody) +Finding Bullet: +.. code-block:: cmake - -:: - - This module accepts the following variables - - - -:: - - BULLET_ROOT - Can be set to bullet install path or Windows build path + find_package(Bullet) #]=======================================================================] macro(_FIND_BULLET_LIBRARY _var) @@ -85,7 +89,7 @@ BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR) set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR}) -if(BULLET_FOUND) +if(Bullet_FOUND) _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY) _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY) _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
diff --git a/Modules/FindCABLE.cmake b/Modules/FindCABLE.cmake index 4d72897..6e530c3 100644 --- a/Modules/FindCABLE.cmake +++ b/Modules/FindCABLE.cmake
@@ -5,23 +5,43 @@ FindCABLE --------- -Find CABLE +Finds the CABLE installation and determines its include paths and libraries. -This module finds if CABLE is installed and determines where the -include files and libraries are. This code sets the following -variables: +Package called CABLE (CABLE Automates Bindings for Language Extension) was +initially developed by Kitware to generate bindings to C++ classes for use in +interpreted languages, such as Tcl. It worked in conjunction with packages like +GCC-XML. The CABLE package has since been superseded by the ITK CableSwig +package. -:: +.. note:: - CABLE the path to the cable executable - CABLE_TCL_LIBRARY the path to the Tcl wrapper library - CABLE_INCLUDE_DIR the path to the include directory + When building wrappers for interpreted languages, these packages are no longer + necessary. The CastXML package now serves as the recommended tool for this + purpose and can be found directly using the :command:`find_program` command. +Cache Variables +^^^^^^^^^^^^^^^ +The following cache variables may be set when using this module: -To build Tcl wrappers, you should add shared library and link it to -${CABLE_TCL_LIBRARY}. You should also add ${CABLE_INCLUDE_DIR} as an -include directory. +``CABLE`` + Path to the ``cable`` executable. +``CABLE_INCLUDE_DIR`` + Path to the include directory. +``CABLE_TCL_LIBRARY`` + Path to the Tcl wrapper library. + +Examples +^^^^^^^^ + +Finding CABLE to build Tcl wrapper, by linking library and adding the include +directories: + +.. code-block:: cmake + + find_package(CABLE) + target_link_libraries(tcl_wrapper_target PRIVATE ${CABLE_TCL_LIBRARY}) + target_include_directories(tcl_wrapper_target PRIVATE ${CABLE_INCLUDE_DIR}) #]=======================================================================] if(NOT CABLE)
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 7df621e..aaa1246 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake
@@ -1321,7 +1321,9 @@ set(_cmake_cupti_extra_paths extras/CUPTI/lib64/ extras/CUPTI/lib/ ../extras/CUPTI/lib64/ - ../extras/CUPTI/lib/) + ../extras/CUPTI/lib/ + ../../../extras/CUPTI/lib64/ + ../../../extras/CUPTI/lib/) _CUDAToolkit_find_and_add_import_lib(cupti EXTRA_PATH_SUFFIXES ${_cmake_cupti_extra_paths} EXTRA_INCLUDE_DIRS "${CUDAToolkit_CUPTI_INCLUDE_DIR}")
diff --git a/Modules/FindCVS.cmake b/Modules/FindCVS.cmake index 9ae6d8c..d50a758 100644 --- a/Modules/FindCVS.cmake +++ b/Modules/FindCVS.cmake
@@ -5,23 +5,35 @@ FindCVS ------- -Find the Concurrent Versions System (CVS). +Finds the Concurrent Versions System (CVS). -The module defines the following variables: +Result Variables +^^^^^^^^^^^^^^^^ -:: +This module defines the following variables: - CVS_EXECUTABLE - path to cvs command line client - CVS_FOUND - true if the command line client was found +``CVS_FOUND`` + True if the command-line client was found. -Example usage: +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``CVS_EXECUTABLE`` + Path to ``cvs`` command-line client. + +Examples +^^^^^^^^ + +Finding CVS and executing it in a process: .. code-block:: cmake - find_package(CVS) - if(CVS_FOUND) - message("CVS found: ${CVS_EXECUTABLE}") - endif() + find_package(CVS) + if(CVS_FOUND) + execute_process(COMMAND ${CVS_EXECUTABLE} --help) + endif() #]=======================================================================] # CVSNT
diff --git a/Modules/FindCoin3D.cmake b/Modules/FindCoin3D.cmake index f517f3b..1d89c60 100644 --- a/Modules/FindCoin3D.cmake +++ b/Modules/FindCoin3D.cmake
@@ -5,18 +5,38 @@ FindCoin3D ---------- -Find Coin3D (Open Inventor) +Finds Coin3D (Open Inventor). Coin3D is an implementation of the Open Inventor API. It provides data structures and algorithms for 3D visualization. -This module defines the following variables +Result Variables +^^^^^^^^^^^^^^^^ -:: +This module defines the following variables: - COIN3D_FOUND - system has Coin3D - Open Inventor - COIN3D_INCLUDE_DIRS - where the Inventor include directory can be found - COIN3D_LIBRARIES - Link to this to use Coin3D +``Coin3D_FOUND`` + True if Coin3D, Open Inventor was found. For backward compatibility, the + ``COIN3D_FOUND`` variable is also set to the same value. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``COIN3D_INCLUDE_DIRS`` + Directory containing the Open Inventor header files (``Inventor/So.h``). +``COIN3D_LIBRARIES`` + Coin3D libraries required for linking. + +Examples +^^^^^^^^ + +Finding Coin3D: + +.. code-block:: cmake + + find_package(Coin3D) #]=======================================================================] if (WIN32)
diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake index 5714979..a3cd654 100644 --- a/Modules/FindGSL.cmake +++ b/Modules/FindGSL.cmake
@@ -7,7 +7,7 @@ .. versionadded:: 3.2 -Find the native GNU Scientific Library (GSL) includes and libraries. +Finds the native GNU Scientific Library (GSL) includes and libraries. The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. It is free software under the GNU General Public @@ -16,47 +16,71 @@ Imported Targets ^^^^^^^^^^^^^^^^ -If GSL is found, this module defines the following :prop_tgt:`IMPORTED` -targets:: +If GSL is found, this module defines the following :ref:`Imported Targets`: - GSL::gsl - The main GSL library. - GSL::gslcblas - The CBLAS support library used by GSL. +``GSL::gsl`` + The main GSL library that provides all usage requirements to use GSL. +``GSL::gslcblas`` + The CBLAS support library used by GSL. It is linked also into the + ``GSL::gsl`` target but provided separately for granularity. Result Variables ^^^^^^^^^^^^^^^^ -This module will set the following variables in your project:: +This module will set the following variables in the project: - GSL_FOUND - True if GSL found on the local system - GSL_INCLUDE_DIRS - Location of GSL header files. - GSL_LIBRARIES - The GSL libraries. - GSL_VERSION - The version of the discovered GSL install. +``GSL_FOUND`` + True if GSL is found on the local system. +``GSL_INCLUDE_DIRS`` + Directory containing GSL header files. +``GSL_LIBRARIES`` + The GSL libraries. +``GSL_VERSION`` + The version of the discovered GSL installation. Hints ^^^^^ -Set ``GSL_ROOT_DIR`` to a directory that contains a GSL installation. +``GSL_ROOT_DIR`` + Set this variable to a directory that contains a GSL installation. -This script expects to find libraries at ``$GSL_ROOT_DIR/lib`` and the GSL -headers at ``$GSL_ROOT_DIR/include/gsl``. The library directory may -optionally provide Release and Debug folders. If available, the libraries -named ``gsld``, ``gslblasd`` or ``cblasd`` are recognized as debug libraries. -For Unix-like systems, this script will use ``$GSL_ROOT_DIR/bin/gsl-config`` -(if found) to aid in the discovery of GSL. + If this variable is not set, this module will use pkg-config and default paths + to find GSL. If this variable is provided, then this module expects to find + libraries at ``${GSL_ROOT_DIR}/lib`` and the GSL headers at + ``${GSL_ROOT_DIR}/include/gsl``. + + The library directory may optionally provide Release and Debug folders. If + available, the libraries named ``gsld``, ``gslblasd`` or ``cblasd`` are + recognized as debug libraries. For Unix-like systems, this module will also + use ``gsl-config`` (if found) to aid in the discovery of GSL. Cache Variables ^^^^^^^^^^^^^^^ This module may set the following variables depending on platform and type of GSL installation discovered. These variables may optionally be set to -help this module find the correct files:: +help this module find the correct files: - GSL_CBLAS_LIBRARY - Location of the GSL CBLAS library. - GSL_CBLAS_LIBRARY_DEBUG - Location of the debug GSL CBLAS library (if any). - GSL_CONFIG_EXECUTABLE - Location of the ``gsl-config`` script (if any). - GSL_LIBRARY - Location of the GSL library. - GSL_LIBRARY_DEBUG - Location of the debug GSL library (if any). +``GSL_CBLAS_LIBRARY`` + Location of the GSL CBLAS library. +``GSL_CBLAS_LIBRARY_DEBUG`` + Location of the debug GSL CBLAS library (if any). +``GSL_CONFIG_EXECUTABLE`` + Location of the ``gsl-config`` script (if any). +``GSL_LIBRARY`` + Location of the GSL library. +``GSL_LIBRARY_DEBUG`` + Location of the debug GSL library (if any). +Examples +^^^^^^^^ + +Finding GSL and linking it to a project target: + +.. code-block:: cmake + + find_package(GSL) + target_link_libraries(project_target PRIVATE GSL::gsl) #]=======================================================================] cmake_policy(PUSH)
diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake index 851f193..abbb681 100644 --- a/Modules/FindGnuplot.cmake +++ b/Modules/FindGnuplot.cmake
@@ -5,21 +5,42 @@ FindGnuplot ----------- -This module looks for gnuplot. +Finds the Gnuplot command-line graphing utility for generating two- and +three-dimensional plots (``gnuplot``). Result Variables ^^^^^^^^^^^^^^^^ -``GNUPLOT_FOUND`` - System has Gnuplot. +This module sets the following variables: -``GNUPLOT_EXECUTABLE`` - The Gnuplot executable. +``Gnuplot_FOUND`` + Boolean indicating whether Gnuplot has been found. For backward + compatibility, the ``GNUPLOT_FOUND`` variable is also set to the same value. ``GNUPLOT_VERSION_STRING`` The version of Gnuplot found. - .. note:: Version string detection will not work for old versions like 3.7.1. + .. note:: + + Version detection is available only for Gnuplot 4 and later. Earlier + versions did not provide version output. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``GNUPLOT_EXECUTABLE`` + Absolute path to the ``gnuplot`` executable. + +Examples +^^^^^^^^ + +Finding Gnuplot: + +.. code-block:: cmake + + find_package(Gnuplot) #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
diff --git a/Modules/FindHTMLHelp.cmake b/Modules/FindHTMLHelp.cmake index c6ee4bc..76b3dcf 100644 --- a/Modules/FindHTMLHelp.cmake +++ b/Modules/FindHTMLHelp.cmake
@@ -5,15 +5,39 @@ FindHTMLHelp ------------ -This module looks for Microsoft HTML Help Compiler +This module finds the Microsoft HTML Help Compiler and its API. It is part of +the HTML Help Workshop. -It defines: +.. note:: -:: + HTML Help Workshop is in maintenance mode only and is considered deprecated. + For modern documentation, consider alternatives such as Microsoft Help Viewer + for producing ``.mshc`` files or web-based documentation tools. - HTML_HELP_COMPILER : full path to the Compiler (hhc.exe) - HTML_HELP_INCLUDE_PATH : include path to the API (htmlhelp.h) - HTML_HELP_LIBRARY : full path to the library (htmlhelp.lib) +Cache Variables +^^^^^^^^^^^^^^^ + +This module may set the following cache variables: + +``HTML_HELP_COMPILER`` + Full path to the HTML Help Compiler (``hhc.exe``), used to compile ``.chm`` + files. +``HTML_HELP_INCLUDE_PATH`` + Directory containing ``htmlhelp.h``, required for applications integrating the + HTML Help API. +``HTML_HELP_LIBRARY`` + Full path to ``htmlhelp.lib`` library, required for linking applications that + use the HTML Help API. + +Examples +^^^^^^^^ + +Finding HTML Help Compiler: + +.. code-block:: cmake + + find_package(HTMLHelp) + message(STATUS "HTML Help Compiler found at: ${HTML_HELP_COMPILER}") #]=======================================================================] if(WIN32)
diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake index a26e01f..c88a523 100644 --- a/Modules/FindHg.cmake +++ b/Modules/FindHg.cmake
@@ -5,42 +5,68 @@ FindHg ------ -Extract information from a mercurial working copy. +Finds the Mercurial command-line client executable (``hg``) and provides a +command for extracting information from a Mercurial working copy. -The module defines the following variables: +Result Variables +^^^^^^^^^^^^^^^^ -:: +This module sets the following variables: - HG_EXECUTABLE - path to mercurial command line client (hg) - HG_FOUND - true if the command line client was found - HG_VERSION_STRING - the version of mercurial found +``Hg_FOUND`` + Boolean indicating whether the Mercurial client was found. For backward + compatibility, the ``HG_FOUND`` variable is also set to the same value. -.. versionadded:: 3.1 - If the command line client executable is found the following macro is defined: +``HG_VERSION_STRING`` + The version of Mercurial found. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``HG_EXECUTABLE`` + Absolute path to the Mercurial command-line client (``hg``). + +Commands +^^^^^^^^ + +This module defines the following command when Mercurial client (``hg``) is +found: + +.. command:: Hg_WC_INFO + + .. versionadded:: 3.1 + + Extracts information of a Mercurial working copy: + + .. code-block:: cmake + + Hg_WC_INFO(<dir> <var-prefix>) + + This macro defines the following variables if running Mercurial client on + working copy located at a given location ``<dir>`` succeeds; otherwise a + ``SEND_ERROR`` message is generated: + + ``<var-prefix>_WC_CHANGESET`` + Current changeset. + ``<var-prefix>_WC_REVISION`` + Current revision. + +Examples +^^^^^^^^ + +Finding the Mercurial client and retrieving information about the current +project's working copy: .. code-block:: cmake - HG_WC_INFO(<dir> <var-prefix>) - -Hg_WC_INFO extracts information of a mercurial working copy -at a given location. This macro defines the following variables: - -:: - - <var-prefix>_WC_CHANGESET - current changeset - <var-prefix>_WC_REVISION - current revision - -Example usage: - -.. code-block:: cmake - - find_package(Hg) - if(HG_FOUND) - message("hg found: ${HG_EXECUTABLE}") - HG_WC_INFO(${PROJECT_SOURCE_DIR} Project) - message("Current revision is ${Project_WC_REVISION}") - message("Current changeset is ${Project_WC_CHANGESET}") - endif() + find_package(Hg) + if(Hg_FOUND) + Hg_WC_INFO(${PROJECT_SOURCE_DIR} Project) + message("Current revision is ${Project_WC_REVISION}") + message("Current changeset is ${Project_WC_CHANGESET}") + endif() #]=======================================================================] find_program(HG_EXECUTABLE
diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index 538b654..9072d95 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake
@@ -5,30 +5,50 @@ FindLibArchive -------------- -Find libarchive library and headers. -Libarchive is multi-format archive and compression library. +Finds the libarchive library and include directories. Libarchive is a +multi-format archive and compression library. -The module defines the following variables: +Import Targets +^^^^^^^^^^^^^^ -:: +This module defines the following :ref:`Imported Targets`: - LibArchive_FOUND - true if libarchive was found - LibArchive_INCLUDE_DIRS - include search path - LibArchive_LIBRARIES - libraries to link - LibArchive_VERSION - libarchive 3-component version number +``LibArchive::LibArchive`` + .. versionadded:: 3.17 -The module defines the following ``IMPORTED`` targets: + A target for linking against libarchive. -:: +Result Variables +^^^^^^^^^^^^^^^^ - LibArchive::LibArchive - target for linking against libarchive +This module defines the following variables: -.. versionadded:: 3.6 - Support for new libarchive 3.2 version string format. +``LibArchive_FOUND`` + Boolean indicating whether libarchive was found. +``LibArchive_INCLUDE_DIRS`` + Include search path for using libarchive. +``LibArchive_LIBRARIES`` + Libraries to link against libarchive. +``LibArchive_VERSION`` + A 3-component version string (``major.minor.patch``) of libarchive found. -.. versionadded:: 3.17 - Provides an imported target. + .. versionadded:: 3.6 + Support for a new libarchive version string format. Starting from + libarchive version 3.2, a different preprocessor macro is used in the header + to define the version. In CMake 3.5 and earlier, this variable will be set + only for libarchive versions 3.1 and earlier. In CMake 3.6 and newer, this + variable will be set for all libarchive versions. + +Examples +^^^^^^^^ + +Finding LibArchive and linking it to a project target: + +.. code-block:: cmake + + find_package(LibArchive) + target_link_libraries(project_target PRIVATE LibArchive::LibArchive) #]=======================================================================] cmake_policy(PUSH)
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index 52d137f..64b35b5 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake
@@ -5,47 +5,62 @@ FindPNG ------- -Find libpng, the official reference library for the PNG image format. +Finds libpng, the official reference library for the PNG image format. + +.. note:: + + The PNG library depends on the ZLib compression library, which must be found + for this module to succeed. Imported Targets ^^^^^^^^^^^^^^^^ .. versionadded:: 3.5 -This module defines the following :prop_tgt:`IMPORTED` target: +This module defines the following :ref:`Imported Targets`: ``PNG::PNG`` The libpng library, if found. -Result variables +Result Variables ^^^^^^^^^^^^^^^^ -This module will set the following variables in your project: +This module sets the following variables: ``PNG_INCLUDE_DIRS`` - where to find png.h, etc. + Directory containing the PNG headers (e.g., ``png.h``). ``PNG_LIBRARIES`` - the libraries to link against to use PNG. + PNG libraries required for linking. ``PNG_DEFINITIONS`` - You should add_definitions(${PNG_DEFINITIONS}) before compiling code - that includes png library files. + Compile definitions for using PNG, if any. They can be added with + :command:`target_compile_definitions` command when not using the ``PNG::PNG`` + imported target. ``PNG_FOUND`` - If false, do not try to use PNG. + True if PNG library is found. ``PNG_VERSION_STRING`` - the version of the PNG library found (since CMake 2.8.8) + .. versionadded:: 2.8.8 -Obsolete variables + The version of the PNG library found. + +Obsolete Variables ^^^^^^^^^^^^^^^^^^ -The following variables may also be set, for backwards compatibility: +The following variables may also be set for backward compatibility: ``PNG_LIBRARY`` - where to find the PNG library. + Path to the PNG library. ``PNG_INCLUDE_DIR`` - where to find the PNG headers (same as PNG_INCLUDE_DIRS) + Directory containing the PNG headers (same as ``PNG_INCLUDE_DIRS``). -Since PNG depends on the ZLib compression library, none of the above -will be defined unless ZLib can be found. +Examples +^^^^^^^^ + +Finding PNG library and using it in a project: + +.. code-block:: cmake + + find_package(PNG) + target_link_libraries(project_target PRIVATE PNG::PNG) #]=======================================================================] cmake_policy(PUSH)
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 231e57e..5595967 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake
@@ -79,6 +79,53 @@ endfunction() +function (_PYTHON_RESET_ARTIFACTS comp) + set(components ${comp}) + if (comp STREQUAL "Interpreter") + list (APPEND components Compiler Development NumPy) + endif() + if (comp STREQUAL "Development") + list (APPEND components NumPy) + endif() + set(find_components ${${_PYTHON_BASE}_FIND_COMPONENTS}) + list(TRANSFORM find_components REPLACE "^Development.*" "Development") + list(REMOVE_DUPLICATES find_components) + + foreach (component IN LISTS components) + if (NOT component IN_LIST find_components) + continue() + endif() + if (component STREQUAL "Interpreter") + unset(_${_PYTHON_PREFIX}_EXECUTABLE CACHE) + endif() + if (component STREQUAL "Compiler" + AND "IronPython" IN_LIST _${_PYTHON_PREFIX}_FIND_IMPLEMENTATIONS) + unset(_${_PYTHON_PREFIX}_COMPILER CACHE) + endif() + if (component STREQUAL "Development") + set(artifacts ${ARGN}) + if (NOT artifacts) + set(artifacts LIBRARY SABI_LIBRARY INCLUDE_DIR) + endif() + unset(_${_PYTHON_PREFIX}_CONFIG) + foreach (artifact IN LISTS artifacts) + if (artifact IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS) + if (artifact MATCHES "LIBRARY") + unset(_${_PYTHON_PREFIX}_${artifact}_RELEASE CACHE) + unset(_${_PYTHON_PREFIX}_${artifact}_DEBUG CACHE) + elseif(arifact STREQUAL "INCLUDE_DIR") + unset(_${_PYTHON_PREFIX}_${artifact} CACHE) + endif() + endif() + endforeach() + endif() + if (component STREQUAL "NumPy") + unset(_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR CACHE) + endif() + endforeach() +endfunction() + + macro (_PYTHON_SELECT_LIBRARY_CONFIGURATIONS _PYTHON_BASENAME) if(NOT DEFINED ${_PYTHON_BASENAME}_LIBRARY_RELEASE) set(${_PYTHON_BASENAME}_LIBRARY_RELEASE "${_PYTHON_BASENAME}_LIBRARY_RELEASE-NOTFOUND") @@ -1915,6 +1962,8 @@ if (NOT ${_PYTHON_PREFIX}_EXECUTABLE STREQUAL _${_PYTHON_PREFIX}_EXECUTABLE) # invalidate cache properties unset (_${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES CACHE) + # invalidate the previous results for any other requested components + _python_reset_artifacts(Interpreter) endif() set (_${_PYTHON_PREFIX}_EXECUTABLE "${${_PYTHON_PREFIX}_EXECUTABLE}" CACHE INTERNAL "") unset (_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG CACHE) @@ -2821,18 +2870,17 @@ if (DEFINED ${_PYTHON_PREFIX}_LIBRARY AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_LIBRARY}") + _python_reset_artifacts(Development) set (_${_PYTHON_PREFIX}_LIBRARY_RELEASE "${${_PYTHON_PREFIX}_LIBRARY}" CACHE INTERNAL "") - unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE) - unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE) endif() if (DEFINED ${_PYTHON_PREFIX}_SABI_LIBRARY AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_SABI_LIBRARY}") + _python_reset_artifacts(Development SABI_LIBRARY INCLUDE_DIR) set (_${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE "${${_PYTHON_PREFIX}_SABI_LIBRARY}" CACHE INTERNAL "") - unset (_${_PYTHON_PREFIX}_SABI_LIBRARY_DEBUG CACHE) - unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE) endif() if (DEFINED ${_PYTHON_PREFIX}_INCLUDE_DIR AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_INCLUDE_DIR}") + _python_reset_artifacts(Development INCLUDE_DIR) set (_${_PYTHON_PREFIX}_INCLUDE_DIR "${${_PYTHON_PREFIX}_INCLUDE_DIR}" CACHE INTERNAL "") endif()
diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 31d4c0b..98cd1e2 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake
@@ -6,35 +6,56 @@ ------ .. deprecated:: 3.14 - This module is available only if policy :policy:`CMP0084` is not set to ``NEW``. -Searches for all installed versions of Qt3 or Qt4. + This module is available only if policy :policy:`CMP0084` is not set to + ``NEW``. It supports only Qt3 and Qt4. For Qt5 or later versions see + :manual:`cmake-qt(7)`. -This module cannot handle Qt5 or any later versions. -For those, see :manual:`cmake-qt(7)`. +This module finds an installed version of Qt3 or Qt4. Qt is a cross-platform +application development framework for creating graphical user interfaces and +applications. -This module should only be used if your project can work with multiple -versions of Qt. If not, you should just directly use FindQt4 or -FindQt3. If multiple versions of Qt are found on the machine, then -The user must set the option DESIRED_QT_VERSION to the version they -want to use. If only one version of qt is found on the machine, then -the DESIRED_QT_VERSION is set to that version and the matching FindQt3 -or FindQt4 module is included. Once the user sets DESIRED_QT_VERSION, -then the FindQt3 or FindQt4 module is included. +Use this module only if the project can work with both Qt3 and Qt4 +versions. If a specific version is required, use :module:`FindQt4` or +:module:`FindQt3` module directly. -:: +Behavior: - QT_REQUIRED if this is set to TRUE then if CMake can - not find Qt4 or Qt3 an error is raised - and a message is sent to the user. +* If multiple Qt versions are found, the user must set the preferred major + Qt version with the ``DESIRED_QT_VERSION`` variable. +* If only one Qt version is found, then the ``DESIRED_QT_VERSION`` is set + automatically. +* Once the ``DESIRED_QT_VERSION`` variable is set, the corresponding + :module:`FindQt3` or :module:`FindQt4` module is included. +Result Variables +^^^^^^^^^^^^^^^^ +This module sets the following variables: -:: +``QT4_INSTALLED`` + ``TRUE`` if Qt4 is found. +``QT3_INSTALLED`` + ``TRUE`` if Qt3 is found. - DESIRED_QT_VERSION OPTION is created - QT4_INSTALLED is set to TRUE if qt4 is found. - QT3_INSTALLED is set to TRUE if qt3 is found. +Hints +^^^^^ + +``QT_REQUIRED`` + If this variable is set to ``TRUE`` before calling ``find_package(Qt)``, + CMake will raise an error if neither Qt3 nor Qt4 is found. +``DESIRED_QT_VERSION`` + Specifies the Qt major version to use. Can be either ``3``, ``4``, or empty, + to search for version automatically. + +Examples +^^^^^^^^ + +Finding Qt3 or Qt4 version: + +.. code-block:: cmake + + find_package(Qt) #]=======================================================================] if(_findqt_testing)
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 9e15e37..2c9e39f 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake
@@ -5,32 +5,26 @@ FindQt4 ------- -Finding and Using Qt4 -^^^^^^^^^^^^^^^^^^^^^ - -This module can be used to find Qt4. The most important issue is that -the Qt4 qmake is available via the system path. This qmake is then -used to detect basically everything else. This module defines a -number of :prop_tgt:`IMPORTED` targets, macros and variables. - -Typical usage could be something like: - -.. code-block:: cmake - - set(CMAKE_AUTOMOC ON) - set(CMAKE_INCLUDE_CURRENT_DIR ON) - find_package(Qt4 4.4.3 REQUIRED QtGui QtXml) - add_executable(myexe main.cpp) - target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) +This module finds Qt4, a cross-platform application development framework for +creating graphical user interfaces and applications. It defines a number of +imported targets, macros, and variables to use Qt4 in the project. .. note:: - When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is - automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>` - executables. To disable that globally, set the - ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that - for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target - property to ``TRUE`` on the executable. + This module is for Qt version 4. As of Qt version 5, the Qt upstream also + provides an exported configuration to find Qt. New code should follow the + :manual:`cmake-qt(7)` instead of using this module. + +To detect the Qt4 package, the Qt4 ``qmake`` tool is required and must be +available in the system path. + +.. note:: + + When using :ref:`Imported Targets`, the ``qtmain.lib`` static library is + automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>` + executables. To disable this globally, set the ``QT4_NO_LINK_QTMAIN`` + variable before finding Qt4. To disable this for a particular executable, + set the ``QT4_NO_LINK_QTMAIN`` target property to ``TRUE`` on that executable. Qt Build Tools ^^^^^^^^^^^^^^ @@ -41,264 +35,415 @@ automatically invoked by :manual:`cmake(1)` if the appropriate conditions are met. See :manual:`cmake-qt(7)` for more. -Qt Macros -^^^^^^^^^ - -In some cases it can be necessary or useful to invoke the Qt build tools in a -more-manual way. Several macros are available to add targets for such uses. - -:: - - macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...) - create moc code from a list of files containing Qt class with - the Q_OBJECT declaration. Per-directory preprocessor definitions - are also added. If the <tgt> is specified, the - INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from - the <tgt> are passed to moc. Options may be given to moc, such as - those found when executing "moc -help". - - -:: - - macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...) - create code from a list of Qt designer ui files. - Options may be given to uic, such as those found - when executing "uic -help" - - -:: - - macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...) - create code from a list of Qt resource files. - Options may be given to rcc, such as those found - when executing "rcc -help" - - -:: - - macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt]) - creates a rule to run moc on infile and create outfile. - Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g. - because you need a custom filename for the moc file or something - similar. If the <tgt> is specified, the - INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from - the <tgt> are passed to moc. - - -:: - - macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename) - Create the interface header and implementation files with the - given basename from the given interface xml file and add it to - the list of sources. - - You can pass additional parameters to the qdbusxml2cpp call by setting - properties on the input file: - - INCLUDE the given file will be included in the generate interface header - - CLASSNAME the generated class is named accordingly - - NO_NAMESPACE the generated class is not wrapped in a namespace - - -:: - - macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... ) - Create the interface header and implementation files - for all listed interface xml files. - The basename will be automatically determined from the name - of the xml file. - - The source file properties described for - QT4_ADD_DBUS_INTERFACE also apply here. - - -:: - - macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname - [basename] [classname]) - create a dbus adaptor (header and implementation file) from the xml file - describing the interface, and add it to the list of sources. The adaptor - forwards the calls to a parent class, defined in parentheader and named - parentclassname. The name of the generated files will be - <basename>adaptor.{cpp,h} where basename defaults to the basename of the - xml file. - If <classname> is provided, then it will be used as the classname of the - adaptor itself. - - -:: - - macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...) - generate the xml interface file from the given header. - If the optional argument interfacename is omitted, the name of the - interface file is constructed from the basename of the header with - the suffix .xml appended. - Options may be given to qdbuscpp2xml, such as those found when - executing "qdbuscpp2xml --help" - - -:: - - macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... - ts_files ... OPTIONS ...) - out: qm_files - in: directories sources ts_files - options: flags to pass to lupdate, such as -extensions to specify - extensions for a directory scan. - generates commands to create .ts (via lupdate) and .qm - (via lrelease) - files from directories and/or sources. The ts files are - created and/or updated in the source tree (unless given with full paths). - The qm files are generated in the build tree. - Updating the translations can be done by adding the qm_files - to the source list of your library/executable, so they are - always updated, or by adding a custom target to control when - they get updated/generated. - - -:: - - macro QT4_ADD_TRANSLATION( qm_files ts_files ... ) - out: qm_files - in: ts_files - generates commands to create .qm from .ts - files. The generated - filenames can be found in qm_files. The ts_files - must exist and are not updated in any way. - - -:: - - macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt]) - The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. - This macro is still experimental. - It can be used to have moc automatically handled. - So if you have the files foo.h and foo.cpp, and in foo.h a - a class uses the Q_OBJECT macro, moc has to run on it. If you don't - want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert - #include "foo.moc" - in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will - scan all listed files at cmake-time for such included moc files and if it - finds them cause a rule to be generated to run moc at build time on the - accompanying header file foo.h. - If a source file has the SKIP_AUTOMOC property set it will be ignored by - this macro. - If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and - INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc. - - -:: - - function QT4_USE_MODULES( target [link_type] modules...) - This function is obsolete. Use target_link_libraries with IMPORTED targets - instead. - Make <target> use the <modules> from Qt. Using a Qt module means - to link to the library, add the relevant include directories for the - module, and add the relevant compiler defines for using the module. - Modules are roughly equivalent to components of Qt4, so usage would be - something like: - qt4_use_modules(myexe Core Gui Declarative) - to use QtCore, QtGui and QtDeclarative. The optional <link_type> argument - can be specified as either LINK_PUBLIC or LINK_PRIVATE to specify the - same argument to the target_link_libraries call. - - Imported Targets ^^^^^^^^^^^^^^^^ -A particular Qt library may be used by using the corresponding -:prop_tgt:`IMPORTED` target with the :command:`target_link_libraries` -command: +Qt libraries can be linked using their corresponding +:ref:`IMPORTED target <Imported Targets>` with the +:command:`target_link_libraries` command: .. code-block:: cmake target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) -Using a target in this way causes :cmake(1)` to use the appropriate include -directories and compile definitions for the target when compiling ``myexe``. +Linking to an imported target automatically applies the correct include +directories and compile definitions when building ``myexe``. -Targets are aware of their dependencies, so for example it is not necessary -to list ``Qt4::QtCore`` if another Qt library is listed, and it is not -necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed. -Targets may be tested for existence in the usual way with the -:command:`if(TARGET)` command. +Imported targets also manage their dependencies, so listing ``Qt4::QtCore`` is +unnecessary if another Qt library depends on it. Likewise, ``Qt4::QtGui`` is +automatically included when linking ``Qt4::QtDeclarative``. Targets can be +checked for existence using :command:`if(TARGET)` command. -The Qt toolkit may contain both debug and release libraries. -:manual:`cmake(1)` will choose the appropriate version based on the build -configuration. +If both debug and release versions of a Qt toolkit library are available, CMake +selects the appropriate one based on the +:ref:`build configuration <Build Configurations>`. + +This module provides the following imported targets, if found: ``Qt4::QtCore`` - The QtCore target + The QtCore target ``Qt4::QtGui`` - The QtGui target + The QtGui target ``Qt4::Qt3Support`` - The Qt3Support target + The Qt3Support target ``Qt4::QtAssistant`` - The QtAssistant target + The QtAssistant target ``Qt4::QtAssistantClient`` - The QtAssistantClient target + The QtAssistantClient target ``Qt4::QAxContainer`` - The QAxContainer target (Windows only) + The QAxContainer target (Windows only) ``Qt4::QAxServer`` - The QAxServer target (Windows only) + The QAxServer target (Windows only) ``Qt4::QtDBus`` - The QtDBus target + The QtDBus target ``Qt4::QtDeclarative`` - The QtDeclarative target + The QtDeclarative target ``Qt4::QtDesigner`` - The QtDesigner target + The QtDesigner target ``Qt4::QtDesignerComponents`` - The QtDesignerComponents target + The QtDesignerComponents target ``Qt4::QtHelp`` - The QtHelp target + The QtHelp target ``Qt4::QtMotif`` - The QtMotif target + The QtMotif target ``Qt4::QtMultimedia`` - The QtMultimedia target + The QtMultimedia target ``Qt4::QtNetwork`` - The QtNetwork target -``Qt4::QtNsPLugin`` - The QtNsPLugin target + The QtNetwork target +``Qt4::QtNsPlugin`` + The QtNsPlugin target ``Qt4::QtOpenGL`` - The QtOpenGL target + The QtOpenGL target ``Qt4::QtScript`` - The QtScript target + The QtScript target ``Qt4::QtScriptTools`` - The QtScriptTools target + The QtScriptTools target ``Qt4::QtSql`` - The QtSql target + The QtSql target ``Qt4::QtSvg`` - The QtSvg target + The QtSvg target ``Qt4::QtTest`` - The QtTest target + The QtTest target ``Qt4::QtUiTools`` - The QtUiTools target + The QtUiTools target ``Qt4::QtWebKit`` - The QtWebKit target + The QtWebKit target ``Qt4::QtXml`` - The QtXml target + The QtXml target ``Qt4::QtXmlPatterns`` - The QtXmlPatterns target + The QtXmlPatterns target ``Qt4::phonon`` - The phonon target + The phonon target Result Variables ^^^^^^^^^^^^^^^^ - Below is a detailed list of variables that FindQt4.cmake sets. +This module sets the following variables: ``Qt4_FOUND`` - If false, don't try to use Qt 4. + Boolean whether Qt4 has been found. If false, don't try to use Qt4. ``QT_FOUND`` - If false, don't try to use Qt. This variable is for compatibility only. + Boolean whether Qt4 has been found. If false, don't try to use Qt4. This + variable is for compatibility with other Qt find modules. ``QT4_FOUND`` - If false, don't try to use Qt 4. This variable is for compatibility only. + Boolean whether Qt4 has been found. If false, don't try to use Qt4. This + variable is for backward compatibility only. ``QT_VERSION_MAJOR`` - The major version of Qt found. + The major version of Qt found. ``QT_VERSION_MINOR`` - The minor version of Qt found. + The minor version of Qt found. ``QT_VERSION_PATCH`` - The patch version of Qt found. + The patch version of Qt found. + +Hints +^^^^^ + +``QT4_NO_LINK_QTMAIN`` + If set to boolean true before finding Qt4, it globally disables linking + ``qtmain.lib`` static library on Windows. + +Macros +^^^^^^ + +In some cases it can be necessary or useful to invoke the Qt build tools in a +more-manual way. This module provides the following macros to add targets for +such uses: + +.. command:: qt4_wrap_cpp + + Creates build rules for running ``moc`` on a given list of input files: + + .. code-block:: cmake + + qt4_wrap_cpp(<variable> <files>... [TARGET <target>] [OPTIONS <options>...]) + + This macro creates build rules for processing a list of input files + ``<files>`` that contain Qt classes with the ``Q_OBJECT`` declaration. + Per-directory preprocessor definitions are also added. + + ``<variable>`` + Name of a variable where a list of generated output files is stored. + + ``<files>`` + One or more input source files. + + ``TARGET`` + If specified, the ``INTERFACE_INCLUDE_DIRECTORIES`` and + ``INTERFACE_COMPILE_DEFINITIONS`` target properties from the ``<target>`` + are passed to ``moc``. + + ``OPTIONS`` + Optional list of options given to ``moc``, such as those found when + executing ``moc -help``. + + .. note:: + + Instead of using ``qt4_wrap_cpp()``, the :variable:`CMAKE_AUTOMOC` variable + can be set to process source files with ``moc`` automatically. + +.. command:: qt4_wrap_ui + + Creates build rules for running ``uic`` on a given list of Qt designer ui + input files: + + .. code-block:: cmake + + qt4_wrap_ui(<variable> <files>... [OPTIONS <options>...]) + + ``<variable>`` + Name of a variable where a list of generated output filenames is stored. + + ``<files>`` + One or more Qt designer ui input source files. + + ``OPTIONS`` + Optional list of options given to ``uic``, such as those found when + executing ``uic -help``. + + .. note:: + + Instead of using ``qt4_wrap_ui()``, the :variable:`CMAKE_AUTOUIC` variable + can be set to process ui files with ``uic`` automatically. + +.. command:: qt4_add_resources + + Creates build rules for running ``rcc`` on a given list of input Qt resource + files: + + .. code-block:: cmake + + qt4_add_resources(<variable> <files>... [OPTIONS <options>...]) + + ``<variable>`` + Name of a variable where a list of generated output filenames is stored. + + ``<files>`` + One or more Qt resource input source files. + + ``OPTIONS`` + Optional list of options given to ``rcc``, such as those found when + executing ``rcc -help``. + + .. note:: + + Instead of using ``qt4_add_resources()``, the :variable:`CMAKE_AUTORCC` + variable can be set to process resource files with ``rcc`` automatically. + +.. command:: qt4_generate_moc + + Creates a build rule that generates output file by running ``moc`` on a given + input file. + + .. code-block:: cmake + + qt4_generate_moc(<input-file> <output-file> [TARGET <target>]) + + This macro creates a build rule for ``<input-file>`` to generate + ``<output-file>``. Use this if for some reason ``qt4_wrap_cpp()`` isn't + feasible, e.g. because a custom filename is needed for the moc file or + similar. + + ``TARGET`` + If specified, the ``INTERFACE_INCLUDE_DIRECTORIES`` and + ``INTERFACE_COMPILE_DEFINITIONS`` target properties from the ``<target>`` + are passed to ``moc``. + +.. command:: qt4_add_dbus_interface + + Creates the interface header and implementation files from an interface XML + file: + + .. code-block:: cmake + + qt4_add_dbus_interface(<variable> <interface-file> <basename>) + + This macro creates the interface header (``<basename>.h``) and implementation + files (``<basename>.{cpp,moc}``) from the given interface XML file + ``<interface-file>`` and adds it to the variable which contains a list of + sources (specified as variable name ``<variable>``). + + Additional parameters can be passed to the ``qdbusxml2cpp`` call by setting + the following source file properties on the input file ``<interface-file>``: + + ``INCLUDE`` + The given file will be included in the generate interface header. + + ``CLASSNAME`` + The name of the generated class. + + ``NO_NAMESPACE`` + The generated class will not be wrapped in a namespace. + +.. command:: qt4_add_dbus_interfaces + + Creates the interface header and implementation files from multiple interface + XML files: + + .. code-block:: cmake + + qt4_add_dbus_interfaces(<variable> <interface-files>...) + + This macro creates the interface header and implementation files for all + listed interface XML files ``<interface-files>``. The basename will be + automatically determined from the name of the XML file. The resulting output + files list is stored in a variable ``<variable>``. + + The source file properties described for ``qt4_add_dbus_interface()`` also + apply here. + +.. command:: qt4_add_dbus_adaptor + + Generates an adaptor class for a D-Bus interface: + + .. code-block:: cmake + + qt4_add_dbus_adaptor(<variable> <xmlfile> <parent-header> <parent-classname> + [<basename>] [<classname>]) + + Creates a D-Bus adaptor (header and implementation file) from the XML file + describing the interface, and adds it to the list of sources. The adaptor + forwards the calls to a parent class, defined in ``<parent-header>`` and named + ``<parent-classname>``. The generated filenames will be + ``<basename>adaptor.{cpp,h}`` where ``<basename>`` defaults to the basename of + the XML file if not given. If ``<classname>`` is provided, then it will be + used as the classname of the adaptor itself. Generated filenames are stored + in a variable ``<variable>``. + +.. command:: qt4_generate_dbus_interface + + Generates a D-Bus XML interface file from a given header file: + + .. code-block:: cmake + + qt4_generate_dbus_interface(<header> [<interface>] [OPTIONS <options>...]) + + This macro creates a build rule to extract declaration from the given + ``<header>`` file to generate a corresponding XML interface file. + + ``<header>`` + Path to header file from which XML interface file is generated. + + ``<interface>`` + Path to the generated XML interface file. If this optional argument is + omitted, the name of the interface file is constructed from the basename of + the header with the suffix ``.xml`` appended. A relative path is + interpreted as relative to :variable:`CMAKE_CURRENT_BINARY_DIR`. + + ``OPTIONS`` + A list of options that may be given to ``qdbuscpp2xml``, such as those found + when executing ``qdbuscpp2xml --help``. + +.. command:: qt4_create_translation + + Creates build rules for generating TS and QM files: + + .. code-block:: cmake + + qt4_create_translation(<qm-files-var> <directories>... <sources>... + <ts-files>... [OPTIONS <options>...]) + + This macro creates build rules to generate TS (Translation Source files + ``.ts``) files via ``lupdate`` and QM (Qt Message files ``.qm``) files via + ``lrelease`` from the given ``<directories>`` and/or ``<sources>``. The TS + files are created and/or updated in the source tree (unless given with full + paths). The QM files are generated in the build tree. + + ``<qm-files-var>`` + A list of generated QM files is stored in this variable. Updating the + translations can be done by adding the ``<qm-files-var>`` to the source list + of the project library/executable, so they are always updated, or by adding + a custom target to control when they get updated/generated. + + ``<directories>`` + A list of directories containing source files. + + ``<sources>`` + A list of source files. + + ``<ts-files>`` + A list of TS (Translation Source) files. + + ``OPTIONS`` + Optional list of flags passed to ``lupdate``, such as ``-extensions``, to + specify file extensions for directory scanning. + +.. command:: qt4_add_translation + + Creates build rules for generating QM files from the given TS files: + + .. code-block:: cmake + + qt4_add_translation(<qm-files-var> <ts-files>...) + + This macro creates build rules for generating QM files from the given TS files + and stores a list of generated filenames of QM files in the ``<qm-files-var>`` + variable. The ``<ts-files>`` must exist and are not updated in any way. + +.. command:: qt4_automoc + + .. deprecated:: 2.8.11 + + Use feature provided by the :variable:`CMAKE_AUTOMOC` variable instead. + + Runs ``moc`` on input files: + + .. code-block:: cmake + + qt4_automoc(<source-files>... [TARGET <target>]) + + This macro can be used to have ``moc`` automatically handled. For example, if + there are ``foo.h`` and ``foo.cpp`` files, and in ``foo.h`` a class uses the + ``Q_OBJECT`` preprocessor macro, ``moc`` has to run on it. If using + ``qt4_wrap_cpp()`` isn't wanted (however, it is reliable and mature), the + ``#include "foo.moc"`` can be inserted in ``foo.cpp`` and then ``foo.cpp`` + given as argument to ``qt4_automoc()``. This will scan all listed files + ``<source-files>`` at configuration phase for such included moc files and if + it finds them, a rule is generated to run moc at build time on the + accompanying header file ``foo.h``. If a source file has the + :prop_sf:`SKIP_AUTOMOC` property set, file will be ignored by this macro. + + ``TARGET`` + If specified, the ``INTERFACE_INCLUDE_DIRECTORIES`` and + ``INTERFACE_COMPILE_DEFINITIONS`` target properties from the ``<target>`` + are passed to ``moc``. + +.. command:: qt4_use_modules + + .. deprecated:: 2.8.11 + + Use :command:`target_link_libraries` with :ref:`Imported Targets` instead. + + Provides Qt modules to a project for linking them to a target: + + .. code-block:: cmake + + qt4_use_modules(<target> [<LINK_PUBLIC|LINK_PRIVATE>] <modules>...) + + This function makes ``<target>`` use the ``<modules>`` from Qt. Using a Qt + module means to link to the library, add the relevant include directories for + the module, and add the relevant compiler defines for using the module. + Modules are roughly equivalent to Qt4 components. + + ``LINK_PUBLIC`` or ``LINK_PRIVATE`` + Optional linking mode, used as the corresponding argument in the + ``target_link_libraries()`` call. + + For example, calling ``qt4_use_modules(myexe Core Gui Declarative)`` will use + the ``QtCore``, ``QtGui`` and ``QtDeclarative`` components on the project + target ``myexe``. + +Examples +^^^^^^^^ + +Typical usage to find Qt4, could be something like: + +.. code-block:: cmake + + set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + find_package(Qt4 4.4.3 REQUIRED QtGui QtXml) + add_executable(myexe main.cpp) + target_link_libraries(myexe PRIVATE Qt4::QtGui Qt4::QtXml) #]=======================================================================] # Use find_package( Qt4 COMPONENTS ... ) to enable modules
diff --git a/Modules/FindRTI.cmake b/Modules/FindRTI.cmake index 0431f09..6a1a024 100644 --- a/Modules/FindRTI.cmake +++ b/Modules/FindRTI.cmake
@@ -5,33 +5,43 @@ FindRTI ------- -Try to find M&S HLA RTI libraries +Finds HLA RTI standard libraries and their include directories. -This module finds if any HLA RTI is installed and locates the standard -RTI include files and libraries. +`RTI <https://en.wikipedia.org/wiki/Run-time_infrastructure_(simulation)>`_ +(Run-Time Infrastructure) is a simulation infrastructure standardized by IEEE +and SISO, required when implementing HLA (High Level Architecture). It provides +a well-defined C++ API, ensuring that M&S (Modeling and Simulation) applications +remain independent of a particular RTI implementation. -RTI is a simulation infrastructure standardized by IEEE and SISO. It -has a well defined C++ API that assures that simulation applications -are independent on a particular RTI implementation. +Result Variables +^^^^^^^^^^^^^^^^ -:: +This module defines the following variables: - http://en.wikipedia.org/wiki/Run-Time_Infrastructure_(simulation) +``RTI_FOUND`` + Set to FALSE if any HLA RTI was not found. +``RTI_LIBRARIES`` + The libraries to link against to use RTI. +``RTI_DEFINITIONS`` + Compile definitions for using RTI. Default value is set to + ``-DRTI_USES_STD_FSTREAM``. +Cache Variables +^^^^^^^^^^^^^^^ +The following cache variables may also be set: -This code sets the following variables: +``RTI_INCLUDE_DIR`` + Directory where RTI include files are found. -:: +Examples +^^^^^^^^ - RTI_INCLUDE_DIR = the directory where RTI includes file are found - RTI_LIBRARIES = The libraries to link against to use RTI - RTI_DEFINITIONS = -DRTI_USES_STD_FSTREAM - RTI_FOUND = Set to FALSE if any HLA RTI was not found +Finding RTI: +.. code-block:: cmake - -Report problems to <certi-devel@nongnu.org> + find_package(RTI) #]=======================================================================] macro(RTI_MESSAGE_QUIETLY QUIET TYPE MSG) @@ -43,8 +53,12 @@ set(RTI_DEFINITIONS "-DRTI_USES_STD_FSTREAM") # noqa: spellcheck off -# Detect the CERTI installation, http://www.cert.fr/CERTI -# Detect the MAK Technologies RTI installation, http://www.mak.com/products/rti.php +# Detect the CERTI installation: +# - https://www.nongnu.org/certi/ +# - Mailing list for reporting issues and development discussions: +# <certi-devel@nongnu.org> +# Detect the MAK Technologies RTI installation: +# - https://www.mak.com/mak-one/tools/mak-rti # note: the following list is ordered to find the most recent version first set(RTI_POSSIBLE_DIRS ENV CERTI_HOME @@ -100,5 +114,3 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(RTI DEFAULT_MSG RTI_LIBRARY RTI_INCLUDE_DIR) - -# $Id$
diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 294f415..32d28ce 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake
@@ -5,67 +5,111 @@ FindSubversion -------------- -Extract information from a subversion working copy +This module finds a Subversion command-line client executable (``svn``) and +provides macros for extracting information from a Subversion working copy. -The module defines the following variables: +Result Variables +^^^^^^^^^^^^^^^^ -:: +This module defines the following variables: - Subversion_SVN_EXECUTABLE - path to svn command line client - Subversion_VERSION_SVN - version of svn command line client - Subversion_FOUND - true if the command line client was found - SUBVERSION_FOUND - same as Subversion_FOUND, set for compatibility reasons +``Subversion_FOUND`` + True if the Subversion command-line client was found. For backward + compatibility, the ``SUBVERSION_FOUND`` variable is also set to the same + value. +``Subversion_VERSION_SVN`` + Version of the ``svn`` command-line client. +Cache Variables +^^^^^^^^^^^^^^^ -The minimum required version of Subversion can be specified using the -standard syntax, e.g. ``find_package(Subversion 1.4)``. +The following cache variables may also be set: -If the command line client executable is found two macros are defined: +``Subversion_SVN_EXECUTABLE`` + Path to the ``svn`` command-line client. -.. code-block:: cmake +Macros +^^^^^^ - Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE]) - Subversion_WC_LOG(<dir> <var-prefix>) +If the Subversion command-line client is found, the following macros are +defined: -``Subversion_WC_INFO`` extracts information of a subversion working copy at a -given location. This macro defines the following variables if running -Subversion's ``info`` command on ``<dir>`` succeeds; otherwise a -``SEND_ERROR`` message is generated. +.. command:: Subversion_WC_INFO -.. versionadded:: 3.13 - The error can be ignored by providing the - ``IGNORE_SVN_FAILURE`` option, which causes these variables to remain - undefined. + Extracts information from a Subversion working copy located at a specified + directory: -:: + .. code-block:: cmake - <var-prefix>_WC_URL - url of the repository (at <dir>) - <var-prefix>_WC_ROOT - root url of the repository - <var-prefix>_WC_REVISION - current revision - <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit - <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit - <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit - <var-prefix>_WC_INFO - output of command `svn info <dir>' + Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE]) -``Subversion_WC_LOG`` retrieves the log message of the base revision of a -subversion working copy at a given location. This macro defines the variable: + This macro defines the following variables if running Subversion's ``info`` + subcommand on ``<dir>`` succeeds; otherwise a ``SEND_ERROR`` message is + generated: -:: + ``<var-prefix>_WC_URL`` + URL of the repository (at ``<dir>``). + ``<var-prefix>_WC_ROOT`` + Root URL of the repository. + ``<var-prefix>_WC_REVISION`` + Current revision. + ``<var-prefix>_WC_LAST_CHANGED_AUTHOR`` + Author of last commit. + ``<var-prefix>_WC_LAST_CHANGED_DATE`` + Date of last commit. + ``<var-prefix>_WC_LAST_CHANGED_REV`` + Revision of last commit. + ``<var-prefix>_WC_INFO`` + Output of the command ``svn info <dir>`` - <var-prefix>_LAST_CHANGED_LOG - last log of base revision + The options are: + + ``IGNORE_SVN_FAILURE`` + .. versionadded:: 3.13 + + When specified, errors from Subversion operation will not trigger a + ``SEND_ERROR`` message. In case of an error, the ``<var-prefix>_*`` + variables remain undefined. + +.. command:: Subversion_WC_LOG + + Retrieves the log message of the base revision of a Subversion working copy at + a given location: + + .. code-block:: cmake + + Subversion_WC_LOG(<dir> <var-prefix>) + + This macro defines the following variable if running Subversion's ``log`` + subcommand on ``<dir>`` succeeds; otherwise a ``SEND_ERROR`` message is + generated: + + ``<var-prefix>_LAST_CHANGED_LOG`` + Last log of the base revision of a Subversion working copy located at + ``<dir>``. + +Examples +^^^^^^^^ Example usage: .. code-block:: cmake find_package(Subversion) - if(SUBVERSION_FOUND) + if(Subversion_FOUND) Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) message("Current revision is ${Project_WC_REVISION}") Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) message("Last changed log is ${Project_LAST_CHANGED_LOG}") endif() + +The minimum required version of Subversion can be specified using the standard +syntax: + +.. code-block:: cmake + + find_package(Subversion 1.4) #]=======================================================================] find_program(Subversion_SVN_EXECUTABLE svn
diff --git a/Modules/FindWish.cmake b/Modules/FindWish.cmake index 9e39d36..00b1201 100644 --- a/Modules/FindWish.cmake +++ b/Modules/FindWish.cmake
@@ -5,19 +5,32 @@ FindWish -------- -Find wish installation +Finds ``wish``, a simple windowing shell command-line executable. -This module finds if TCL is installed and determines where the include -files and libraries are. It also determines what the name of the -library is. This code sets the following variables: +This module is commonly used in conjunction with finding a TCL installation (see +the :module:`FindTCL` module). It helps determine where the TCL include paths +and libraries are, as well as identifying the name of the TCL library. -:: +If the :variable:`UNIX` variable is defined, the module will prioritize looking +for the Cygwin version of ``wish`` executable. - TK_WISH = the path to the wish executable +Cache Variables +^^^^^^^^^^^^^^^ +The following cache variables may be set: +``TK_WISH`` + The path to the ``wish`` executable. -if UNIX is defined, then it will look for the cygwin version first +Examples +^^^^^^^^ + +Finding ``wish``: + +.. code-block:: cmake + + find_package(Wish) + message(STATUS "Found wish at: ${TK_WISH}") #]=======================================================================] if(UNIX)
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index badd4df..fa2ad7b 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake
@@ -1061,8 +1061,8 @@ # # NOTE: This is a generic piece of code that should be renamed to # SPLIT_ARGUMENTS_ON and put in a file serving the same purpose as -# FindPackageStandardArgs.cmake. At the time of this writing -# FindQt4.cmake has a QT4_EXTRACT_OPTIONS, which I basically copied +# FindPackageHandleStandardArgs.cmake. At the time of this writing +# FindQt4.cmake has a qt4_extract_options(), which I basically copied # here a bit more generalized. So, there are already two find modules # using this approach. #
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 09d3bcf..8f44b97 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake
@@ -141,7 +141,7 @@ macro (QT4_GENERATE_MOC infile outfile ) # get include dirs and flags - QT4_GET_MOC_FLAGS(moc_flags) + qt4_get_moc_flags(moc_flags) get_filename_component(abs_infile ${infile} ABSOLUTE) set(_outfile "${outfile}") if(NOT IS_ABSOLUTE "${outfile}") @@ -151,23 +151,22 @@ if (${ARGC} GREATER 3 AND "x${ARGV2}" STREQUAL "xTARGET") set(moc_target ${ARGV3}) endif() - QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}") + qt4_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}") set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file endmacro () -# QT4_WRAP_CPP(outfiles inputfile ... ) - +# qt4_wrap_cpp(outfiles inputfile ... ) macro (QT4_WRAP_CPP outfiles ) # get include dirs - QT4_GET_MOC_FLAGS(moc_flags) - QT4_EXTRACT_OPTIONS(moc_files moc_options moc_target ${ARGN}) + qt4_get_moc_flags(moc_flags) + qt4_extract_options(moc_files moc_options moc_target ${ARGN}) foreach (it ${moc_files}) get_filename_component(it ${it} ABSOLUTE) - QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile) - QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}") + qt4_make_output_file(${it} moc_ cxx outfile) + qt4_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}") set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file set(${outfiles} ${${outfiles}} ${outfile}) @@ -176,10 +175,9 @@ endmacro () -# QT4_WRAP_UI(outfiles inputfile ... ) - +# qt4_wrap_ui(outfiles inputfile ... ) macro (QT4_WRAP_UI outfiles ) - QT4_EXTRACT_OPTIONS(ui_files ui_options ui_target ${ARGN}) + qt4_extract_options(ui_files ui_options ui_target ${ARGN}) foreach (it ${ui_files}) get_filename_component(outfile ${it} NAME_WE) @@ -197,10 +195,9 @@ endmacro () -# QT4_ADD_RESOURCES(outfiles inputfile ... ) - +# qt4_add_resources(outfiles inputfile ... ) macro (QT4_ADD_RESOURCES outfiles ) - QT4_EXTRACT_OPTIONS(rcc_files rcc_options rcc_target ${ARGN}) + qt4_extract_options(rcc_files rcc_options rcc_target ${ARGN}) foreach (it ${rcc_files}) get_filename_component(outfilename ${it} NAME_WE) @@ -226,7 +223,7 @@ # Since this cmake macro is doing the dependency scanning for these files, # let's make a configured file and add it as a dependency so cmake is run # again when dependencies need to be recomputed. - QT4_MAKE_OUTPUT_FILE("${infile}" "" "qrc.depends" out_depends) + qt4_make_output_file("${infile}" "" "qrc.depends" out_depends) configure_file("${infile}" "${out_depends}" COPYONLY) else() # The .qrc file does not exist (yet). Let's add a dependency and hope @@ -277,7 +274,7 @@ set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file - QT4_GENERATE_MOC("${_header}" "${_moc}") + qt4_generate_moc("${_header}" "${_moc}") list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}") set_property(SOURCE "${_impl}" APPEND PROPERTY OBJECT_DEPENDS "${_moc}") @@ -292,13 +289,13 @@ # get the part before the ".xml" suffix string(TOLOWER ${_basename} _basename) string(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename}) - QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface) + qt4_add_dbus_interface(${_sources} ${_infile} ${_basename}interface) endforeach () endmacro() macro(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options ) - QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options _qt4_dbus_target ${ARGN}) + qt4_extract_options(_customName _qt4_dbus_options _qt4_dbus_target ${ARGN}) get_filename_component(_in_file ${_header} ABSOLUTE) get_filename_component(_basename ${_header} NAME_WE) @@ -358,7 +355,7 @@ ) endif() - QT4_GENERATE_MOC("${_header}" "${_moc}") + qt4_generate_moc("${_header}" "${_moc}") set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file set_property(SOURCE "${_impl}" APPEND PROPERTY OBJECT_DEPENDS "${_moc}") @@ -371,7 +368,7 @@ if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11) message(DEPRECATION "The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead.") endif() - QT4_GET_MOC_FLAGS(_moc_INCS) + qt4_get_moc_flags(_moc_INCS) set(_matching_FILES ) foreach (_current_FILE ${ARGN}) @@ -404,7 +401,7 @@ set(_header ${_abs_PATH}/${_basename}.h) endif() set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) - QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "" "") + qt4_create_moc_command(${_header} ${_moc} "${_moc_INCS}" "" "") set_property(SOURCE "${_abs_FILE}" APPEND PROPERTY OBJECT_DEPENDS "${_moc}") endforeach () endif() @@ -414,7 +411,7 @@ macro(QT4_CREATE_TRANSLATION _qm_files) - QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options _lupdate_target ${ARGN}) + qt4_extract_options(_lupdate_files _lupdate_options _lupdate_target ${ARGN}) set(_my_sources) set(_my_dirs) set(_my_tsfiles) @@ -456,7 +453,7 @@ ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file} DEPENDS ${_my_sources} ${_ts_pro} VERBATIM) endforeach() - QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles}) + qt4_add_translation(${_qm_files} ${_my_tsfiles}) endmacro()
diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index 239db61..a39f8b3 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake
@@ -7,18 +7,49 @@ .. deprecated:: 3.0 - See :module:`CheckCXXCompilerFlag`. + This module should no longer be used. It has been superseded by the + :module:`CheckCXXCompilerFlag` module. As of CMake 3.19, the + :module:`CheckCompilerFlag` module is also available for checking flags across + multiple languages. -Check if the CXX compiler accepts a flag. +This module provides a macro to test whether the C++ (CXX) compiler supports +specific flags. + +Macros +^^^^^^ + +.. command:: check_cxx_accepts_flag + + Checks whether the CXX compiler accepts the specified flags: + + .. code-block:: cmake + + check_cxx_accepts_flag(<flags> <result-variable>) + + ``<flags>`` + One or more compiler flags to test. For multiple flags, provide them as a + space-separated string. + + ``<result-variable>`` + Name of an internal cache variable that stores the result. It is set to + boolean true if the compiler accepts the flags and false otherwise. + +Examples +^^^^^^^^ + +Checking if the C++ compiler supports specific flags: .. code-block:: cmake - CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>) + include(TestCXXAcceptsFlag) + check_cxx_accepts_flag("-fno-common -fstack-clash-protection" HAVE_FLAGS) -``<flags>`` - the flags to try -``<variable>`` - variable to store the result +Migrating to the :module:`CheckCompilerFlag` module: + +.. code-block:: cmake + + include(CheckCompilerFlag) + check_compiler_flag(CXX "-fno-common;-fstack-clash-protection" HAVE_FLAGS) #]=======================================================================] macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE)
diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index 3771db1..2c34c26 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake
@@ -6,18 +6,81 @@ ------------ .. deprecated:: 3.0 - Use :module:`FindPkgConfig` instead. + + This module should no longer be used. Instead, use the + :module:`FindPkgConfig` module or the :command:`cmake_pkg_config` command. + + This module provided a macro for finding external packages using + ``pkg-config`` command-line utility. It has been replaced by the more + convenient ``FindPkgConfig`` module, which is commonly used in + :ref:`Find Modules`. + + As of CMake 3.31, the built-in :command:`cmake_pkg_config` command provides + even more features to extract package information. + +Macros +^^^^^^ This module defines the following macro: -PKGCONFIG(package includedir libdir linkflags cflags) +.. command:: pkgconfig -Calling PKGCONFIG will fill the desired information into the 4 given -arguments, e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR -LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) if pkg-config was NOT -found or the specified software package doesn't exist, the variable -will be empty when the function returns, otherwise they will contain -the respective information + Finds external package using ``pkg-config`` and sets result variables: + + .. code-block:: cmake + + pkgconfig(<package> <includedir> <libdir> <linkflags> <cflags>) + + This macro invokes ``pkg-config`` command-line utility to retrieve the package + information into specified variables. If ``pkg-config`` or the specified + package ``<package>`` is NOT found, the result variables remain empty. + + The arguments are: + + ``<package>`` + Name of the package as defined in its PC metadata file (``<package>.pc``). + + ``<includedir>`` + Variable name to store the package's include directory. + + ``<libdir>`` + Variable name to store the directory containing the package library. + + ``<linkflags>`` + Variable name to store the linker flags for the package. + + ``<cflags>`` + Variable name to store the compiler flags for the package. + +Examples +^^^^^^^^ + +Using this module fills the desired information into the four given variables: + +.. code-block:: cmake + + include(UsePkgConfig) + pkgconfig( + libart-2.0 + LIBART_INCLUDEDIR + LIBART_LIBDIR + LIBART_LDFLAGS + LIBART_CFLAGS + ) + +Migrating to the :module:`FindPkgConfig` would look something like this: + +.. code-block:: cmake + + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + pkg_check_modules(LIBART QUIET libart-2.0) + endif() + + message(STATUS "LIBART_INCLUDEDIR=${LIBART_INCLUDEDIR}") + message(STATUS "LIBART_LIBDIR=${LIBART_LIBDIR}") + message(STATUS "LIBART_LDFLAGS=${LIBART_LDFLAGS}") + message(STATUS "LIBART_CFLAGS=${LIBART_CFLAGS}") #]=======================================================================] find_program(PKGCONFIG_EXECUTABLE NAMES pkg-config )
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 570d3ef..4af5239 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 4) set(CMake_VERSION_MINOR 0) -set(CMake_VERSION_PATCH 20250323) +set(CMake_VERSION_PATCH 20250327) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx index 0fc89e8..17dd47e 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
@@ -7,6 +7,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmMessenger.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -94,10 +95,12 @@ std::string err; if (!EmptyBinaryDirectory(args[0], err)) { - status.GetMakefile().IssueMessage( + cmMakefile& mf = status.GetMakefile(); + mf.GetMessenger()->DisplayMessage( MessageType::FATAL_ERROR, cmStrCat("Did not remove the binary directory:\n ", args[0], - "\nbecause:\n ", err)); + "\nbecause:\n ", err), + mf.GetBacktrace()); return true; }
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 48f0935..ca66f18 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -63,10 +63,7 @@ res |= this->RunConfigurationScript(this->ConfigurationScripts[i], this->ScriptProcessScope[i]); } - if (res) { - return -1; - } - return 0; + return res; } void cmCTestScriptHandler::UpdateElapsedTime() @@ -180,6 +177,8 @@ this->CMake->SetHomeOutputDirectory(""); this->CMake->GetCurrentSnapshot().SetDefaultDefinitions(); this->CMake->AddCMakePaths(); + this->CMake->SetWorkingMode(cmake::SCRIPT_MODE, + cmake::CommandFailureAction::EXIT_CODE); this->GlobalGenerator = cm::make_unique<cmGlobalGenerator>(this->CMake.get()); @@ -289,7 +288,7 @@ cmSystemTools::GetErrorOccurredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" << systemFile << "\n"); - return 2; + return -1; } // Add definitions of variables passed in on the command line: @@ -299,16 +298,20 @@ this->Makefile->AddDefinition(d.first, d.second); } + int res = 0; + // finally read in the script if (!this->Makefile->ReadListFile(script) || cmSystemTools::GetErrorOccurredFlag()) { // Reset the error flag so that it can run more than // one script with an error when you use ctest_run_script. cmSystemTools::ResetErrorOccurredFlag(); - return 2; + res = -1; } - return 0; + return this->CMake->HasScriptModeExitCode() + ? this->CMake->GetScriptModeExitCode() + : res; } // run a specific script
diff --git a/Source/cmCurl.h b/Source/cmCurl.h index 933a173..b588c5f 100644 --- a/Source/cmCurl.h +++ b/Source/cmCurl.h
@@ -11,6 +11,11 @@ #include <cm3p/curl/curl.h> +// curl versions before 7.87.0 did not provide CURL_WRITEFUNC_ERROR +#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x075700 +# define CURL_WRITEFUNC_ERROR 0xFFFFFFFF +#endif + void cmCurlInitOnce(); cm::optional<int> cmCurlParseTLSVersion(cm::string_view tls_version); cm::optional<std::string> cmCurlPrintTLSVersion(int curl_tls_version);
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index e9f234f..78dda57 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx
@@ -1703,7 +1703,9 @@ cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data); if (fout) { char const* chPtr = static_cast<char*>(ptr); - fout->write(chPtr, realsize); + if (!fout->write(chPtr, realsize)) { + return CURL_WRITEFUNC_ERROR; + } } return realsize; } @@ -2283,6 +2285,14 @@ g_curl.release(); ::curl_easy_cleanup(curl); + // Explicitly close the file so we can check for write errors. + if (!file.empty()) { + fout.close(); + if (!fout) { + res = CURLE_WRITE_ERROR; + } + } + if (!statusVar.empty()) { std::string m = curl_easy_strerror(res); if ((res == CURLE_SSL_CONNECT_ERROR || @@ -2306,13 +2316,6 @@ status.GetMakefile().AddDefinition(logVar, chunkDebug.data()); } - // Explicitly flush/close so we can measure the md5 accurately. - // - if (!file.empty()) { - fout.flush(); - fout.close(); - } - // Verify MD5 sum if requested: // if (hash) {
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 44dbaa6..7b2e6b1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx
@@ -525,7 +525,8 @@ this->IssueMessage(MessageType::FATAL_ERROR, error); } result = false; - if (this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) { + if (this->GetCMakeInstance()->GetCommandFailureAction() == + cmake::CommandFailureAction::FATAL_ERROR) { cmSystemTools::SetFatalErrorOccurred(); } }
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e1d621b..e1edf45 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx
@@ -659,7 +659,8 @@ GetProjectCommandsInScriptMode(state->GetState()); // Documented behavior of CMAKE{,_CURRENT}_{SOURCE,BINARY}_DIR is to be // set to $PWD for -P mode. - state->SetWorkingMode(SCRIPT_MODE); + state->SetWorkingMode(SCRIPT_MODE, + cmake::CommandFailureAction::FATAL_ERROR); state->SetHomeDirectory(cmSystemTools::GetLogicalWorkingDirectory()); state->SetHomeOutputDirectory(cmSystemTools::GetLogicalWorkingDirectory()); state->ReadListFile(args, path); @@ -1561,7 +1562,8 @@ presetsGraph.PrintAllPresets(); } - this->SetWorkingMode(WorkingMode::HELP_MODE); + this->SetWorkingMode(WorkingMode::HELP_MODE, + cmake::CommandFailureAction::FATAL_ERROR); return; }
diff --git a/Source/cmake.h b/Source/cmake.h index a9efeec..f338c13 100644 --- a/Source/cmake.h +++ b/Source/cmake.h
@@ -129,6 +129,16 @@ FIND_PACKAGE_MODE }; + enum class CommandFailureAction + { + // When a command fails to execute, treat it as a fatal error. + FATAL_ERROR, + + // When a command fails to execute, continue execution, but set the exit + // code accordingly. + EXIT_CODE, + }; + using TraceFormat = cmTraceEnums::TraceOutputFormat; struct GeneratorInfo @@ -441,8 +451,18 @@ //! Do all the checks before running configure int DoPreConfigureChecks(); - void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; } - WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; } + void SetWorkingMode(WorkingMode mode, CommandFailureAction policy) + { + this->CurrentWorkingMode = mode; + this->CurrentCommandFailureAction = policy; + } + + WorkingMode GetWorkingMode() const { return this->CurrentWorkingMode; } + + CommandFailureAction GetCommandFailureAction() const + { + return this->CurrentCommandFailureAction; + } //! Debug the try compile stuff by not deleting the files bool GetDebugTryCompile() const { return this->DebugTryCompile; } @@ -780,6 +800,8 @@ std::string CMakeWorkingDirectory; ProgressCallbackType ProgressCallback; WorkingMode CurrentWorkingMode = NORMAL_MODE; + CommandFailureAction CurrentCommandFailureAction = + CommandFailureAction::FATAL_ERROR; bool DebugOutput = false; bool DebugFindOutput = false; bool Trace = false;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index aaf266a..54a2c39 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx
@@ -396,6 +396,9 @@ mode = cmState::FindPackage; break; } + auto const failurePolicy = workingMode == cmake::NORMAL_MODE + ? cmake::CommandFailureAction::EXIT_CODE + : cmake::CommandFailureAction::FATAL_ERROR; cmake cm(role, mode); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); @@ -406,7 +409,7 @@ cm.SetProgressCallback([&cm](std::string const& msg, float prog) { cmakemainProgressCallback(msg, prog, &cm); }); - cm.SetWorkingMode(workingMode); + cm.SetWorkingMode(workingMode, failurePolicy); int res = cm.Run(parsedArgs, view_only); if (list_cached || list_all_cached) { @@ -988,7 +991,8 @@ cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cm.SetDebugOutputOn(verbose); - cm.SetWorkingMode(cmake::SCRIPT_MODE); + cm.SetWorkingMode(cmake::SCRIPT_MODE, + cmake::CommandFailureAction::FATAL_ERROR); ret_ = int(bool(cm.Run(cmd))); } }
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index d6d43f5..b66cbbd 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt
@@ -88,7 +88,7 @@ # any outside mailing list and no documentation of the change will be # written. -cmake_minimum_required(VERSION 3.9...3.22 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13...3.31 FATAL_ERROR) # Some configure checks depend upon the deployment target. Clear checks when # the deployment target changes. @@ -317,7 +317,7 @@ #----------------------------------------------------------------------------- # Adjust compiler flags for some platforms. -if(NOT CMAKE_COMPILER_IS_GNUCXX) +if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_SYSTEM MATCHES "OSF1-V.*") string(REGEX MATCH "-timplicit_local" KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL "${CMAKE_CXX_FLAGS}") @@ -1038,7 +1038,7 @@ if(CTEST_TEST_KWSYS) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake") - set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake") + set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake") endif() set(KWSYS_TEST_ARGS_testCommandLineArguments
diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake index 6c006bc..7cfdd6e 100644 --- a/Source/kwsys/kwsysPlatformTests.cmake +++ b/Source/kwsys/kwsysPlatformTests.cmake
@@ -171,51 +171,46 @@ # # Compile test named by ${var} and store INFO strings extracted from binary. macro(KWSYS_PLATFORM_INFO_TEST lang var description) - # We can implement this macro on CMake 2.6 and above. - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) - set(${var} "") - else() - # Choose a location for the result binary. - set(KWSYS_PLATFORM_INFO_FILE - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin) + # Choose a location for the result binary. + set(KWSYS_PLATFORM_INFO_FILE + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin) - # Compile the test binary. - if(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE}) - message(STATUS "${description}") - try_compile(${var}_COMPILED - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}} - COMPILE_DEFINITIONS -DTEST_${var} - ${KWSYS_PLATFORM_${lang}_TEST_DEFINES} - ${KWSYS_PLATFORM_${lang}_TEST_EXTRA_FLAGS} - OUTPUT_VARIABLE OUTPUT - COPY_FILE ${KWSYS_PLATFORM_INFO_FILE} - ) - if(CMAKE_VERSION VERSION_LESS 3.26) - if(${var}_COMPILED) - file(APPEND - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "${description} compiled with the following output:\n${OUTPUT}\n\n") - else() - file(APPEND - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "${description} failed to compile with the following output:\n${OUTPUT}\n\n") - endif() - endif() + # Compile the test binary. + if(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE}) + message(STATUS "${description}") + try_compile(${var}_COMPILED + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}} + COMPILE_DEFINITIONS -DTEST_${var} + ${KWSYS_PLATFORM_${lang}_TEST_DEFINES} + ${KWSYS_PLATFORM_${lang}_TEST_EXTRA_FLAGS} + OUTPUT_VARIABLE OUTPUT + COPY_FILE ${KWSYS_PLATFORM_INFO_FILE} + ) + if(CMAKE_VERSION VERSION_LESS 3.26) if(${var}_COMPILED) - message(STATUS "${description} - compiled") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${description} compiled with the following output:\n${OUTPUT}\n\n") else() - message(STATUS "${description} - failed") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${description} failed to compile with the following output:\n${OUTPUT}\n\n") endif() endif() - - # Parse info strings out of the compiled binary. if(${var}_COMPILED) - file(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]") + message(STATUS "${description} - compiled") else() - set(${var} "") + message(STATUS "${description} - failed") endif() - - set(KWSYS_PLATFORM_INFO_FILE) endif() + + # Parse info strings out of the compiled binary. + if(${var}_COMPILED) + file(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]") + else() + set(${var} "") + endif() + + set(KWSYS_PLATFORM_INFO_FILE) endmacro()
diff --git a/Templates/CTestScript.cmake.in b/Templates/CTestScript.cmake.in new file mode 100644 index 0000000..54bfda4 --- /dev/null +++ b/Templates/CTestScript.cmake.in
@@ -0,0 +1,167 @@ +# This file is configured by CMake automatically as CTestScript.cmake +# If you choose not to use CMake, this file may be hand configured, by +# filling in the required variables. + +cmake_minimum_required(VERSION @CMAKE_VERSION@) + +# CTest Start Step +set(CTEST_SOURCE_DIRECTORY "@PROJECT_SOURCE_DIR@") +set(CTEST_BINARY_DIRECTORY "@PROJECT_BINARY_DIR@") + +# CTest Update Step +set(CTEST_UPDATE_COMMAND "@UPDATE_COMMAND@") +set(CTEST_UPDATE_OPTIONS "@UPDATE_OPTIONS@") +set(CTEST_UPDATE_VERSION_ONLY "@CTEST_UPDATE_VERSION_ONLY@") +set(CTEST_NIGHTLY_START_TIME "@NIGHTLY_START_TIME@") + +# CVS options +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CVS_UPDATE_OPTIONS "@CVS_UPDATE_OPTIONS@") + +# Subversion options +set(CTEST_SVN_COMMAND "@SVNCOMMAND@") +set(CTEST_SVN_OPTIONS "@CTEST_SVN_OPTIONS@") +set(CTEST_SVN_UPDATE_OPTIONS "@SVN_UPDATE_OPTIONS@") + +# Git options +set(CTEST_GIT_COMMAND "@GITCOMMAND@") +set(CTEST_GIT_INIT_SUBMODULES "@CTEST_GIT_INIT_SUBMODULES@") +set(CTEST_GIT_UPDATE_CUSTOM "@CTEST_GIT_UPDATE_CUSTOM@") +set(CTEST_GIT_UPDATE_OPTIONS "@GIT_UPDATE_OPTIONS@") + +# Perforce options +set(CTEST_P4_COMMAND "@P4COMMAND@") +set(CTEST_P4_CLIENT "@CTEST_P4_CLIENT@") +set(CTEST_P4_OPTIONS "@CTEST_P4_OPTIONS@") +set(CTEST_P4_UPDATE_CUSTOM "@CTEST_P4_UPDATE_CUSTOM@") +set(CTEST_P4_UPDATE_OPTIONS "@CTEST_P4_UPDATE_OPTIONS@") + +# CTest Configure Step +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_LABELS_FOR_SUBPROJECTS "@CTEST_LABELS_FOR_SUBPROJECTS@") + +# CTest Build Step +set(CTEST_CONFIGURATION_TYPE "@DEFAULT_CTEST_CONFIGURATION_TYPE@") +set(CTEST_USE_LAUNCHERS "@CTEST_USE_LAUNCHERS@") + +# CTest Test Step +set(CTEST_RESOURCE_SPEC_FILE "@CTEST_RESOURCE_SPEC_FILE@") +set(CTEST_TEST_LOAD "@CTEST_TEST_LOAD@") +set(CTEST_TEST_TIMEOUT "@DART_TESTING_TIMEOUT@") + +# CTest Coverage Step +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_COVERAGE_EXTRA_FLAGS "@COVERAGE_EXTRA_FLAGS@") + +# CTest MemCheck Step +set(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +set(CTEST_MEMORYCHECK_TYPE "@MEMORYCHECK_TYPE@") +set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS "@MEMORYCHECK_SANITIZER_OPTIONS@") +set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") + +# CTest Submit Step +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "@BUILDNAME@") +set(CTEST_SUBMIT_URL "@SUBMIT_URL@") +set(CTEST_SUBMIT_INACTIVITY_TIMEOUT "@CTEST_SUBMIT_INACTIVITY_TIMEOUT@") +set(CTEST_TLS_VERIFY "@CTEST_TLS_VERIFY@") +set(CTEST_TLS_VERSION "@CTEST_TLS_VERSION@") + +################################################################################ + +if(NOT MODEL) + set(MODEL "Experimental") +endif() + +if(MODEL STREQUAL "NightlyMemoryCheck") + set(MODEL "Nightly") + set(ACTIONS "Start;Update;Configure;Build;MemCheck;Coverage;Submit") +endif() + +if(NOT ACTIONS) + if(MODEL STREQUAL "Experimental") + set(ACTIONS "Start;Configure;Build;Test;Coverage;Submit") + else() + set(ACTIONS "Start;Update;Configure;Build;Test;Coverage;Submit") + endif() +endif() + +################################################################################ + +set(_exit_code 0) + +if("Start" IN_LIST ACTIONS OR NOT EXISTS "${CTEST_BINARY_DIRECTORY}/Testing/TAG") + ctest_start("${MODEL}") +else() + ctest_start("${MODEL}" APPEND) +endif() + +if("Update" IN_LIST ACTIONS) + ctest_update(RETURN_VALUE update_count) + if(update_count LESS 0) + math(EXPR _exit_code "${_exit_code} | 0x01") + endif() + if(MODEL STREQUAL "Continuous" AND update_count EQUAL 0) + return() + endif() +endif() + +if("Configure" IN_LIST ACTIONS) + ctest_configure(RETURN_VALUE success) + if(success LESS 0) + math(EXPR _exit_code "${_exit_code} | 0x02") + endif() +endif() + +if("Build" IN_LIST ACTIONS) + ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + ctest_build(RETURN_VALUE success) + if(NOT success EQUAL 0) + math(EXPR _exit_code "${_exit_code} | 0x04") + endif() +endif() + +if("Test" IN_LIST ACTIONS) + ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + ctest_test(RETURN_VALUE success) + if(NOT success EQUAL 0) + math(EXPR _exit_code "${_exit_code} | 0x08") + endif() +endif() + +if("Coverage" IN_LIST ACTIONS) + ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + ctest_coverage(RETURN_VALUE success) + if(NOT success EQUAL 0) + math(EXPR _exit_code "${_exit_code} | 0x20") + endif() +endif() + +if("MemCheck" IN_LIST ACTIONS) + ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + ctest_memcheck(RETURN_VALUE success) + if(NOT success EQUAL 0) + math(EXPR _exit_code "${_exit_code} | 0x10") + endif() +endif() + +file(GLOB notes_files LIST_DIRECTORIES OFF + "${CTEST_BINARY_DIRECTORY}/Testing/Notes/*") +if(notes_files) + list(APPEND CTEST_NOTES_FILES "${notes_files}") +endif() + +if("Submit" IN_LIST ACTIONS) + ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + ctest_submit( + RETRY_COUNT "@CTEST_SUBMIT_RETRY_COUNT@" + RETRY_DELAY "@CTEST_SUBMIT_RETRY_DELAY@" + RETURN_VALUE success + ) + if(NOT success EQUAL 0) + math(EXPR _exit_code "${_exit_code} | 0x40") + endif() +endif() + +cmake_language(EXIT "${_exit_code}")
diff --git a/Tests/CTestTestChecksum/CMakeLists.txt b/Tests/CTestTestChecksum/CMakeLists.txt new file mode 100644 index 0000000..e76e746 --- /dev/null +++ b/Tests/CTestTestChecksum/CMakeLists.txt
@@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.10) +project(CTestTestChecksum NONE) +include(CTest)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 77956ef..87b27de 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt
@@ -672,6 +672,7 @@ add_RunCMake_test(ctest_upload) add_RunCMake_test(ctest_environment) add_RunCMake_test(ctest_empty_binary_directory) +add_RunCMake_test(ctest_exit) add_RunCMake_test(ctest_fixtures) if(CMAKE_GENERATOR MATCHES "Make|Ninja") add_RunCMake_test(ctest_instrumentation)
diff --git a/Tests/RunCMake/CTest/TestfileErrors.cmake b/Tests/RunCMake/CTest/TestfileErrors.cmake index 676eb47..68ab6f8 100644 --- a/Tests/RunCMake/CTest/TestfileErrors.cmake +++ b/Tests/RunCMake/CTest/TestfileErrors.cmake
@@ -1,3 +1,3 @@ include(CTest) add_test(NAME "unreachable" COMMAND ${CMAKE_COMMAND} -E true) -set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/TestfileErrors-Script.cmake) +set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/TestfileErrors-Script.cmake")
diff --git a/Tests/RunCMake/ctest_exit/3-result.txt b/Tests/RunCMake/ctest_exit/3-result.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/Tests/RunCMake/ctest_exit/3-result.txt
@@ -0,0 +1 @@ +3
diff --git a/Tests/RunCMake/ctest_exit/3-stderr.txt b/Tests/RunCMake/ctest_exit/3-stderr.txt new file mode 100644 index 0000000..8b4ca5db5 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/3-stderr.txt
@@ -0,0 +1,3 @@ +^CMake Error at [^ +]*/Tests/RunCMake/ctest_exit/exit1.cmake:2 \(message\): + send error$
diff --git a/Tests/RunCMake/ctest_exit/7-result.txt b/Tests/RunCMake/ctest_exit/7-result.txt new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/7-result.txt
@@ -0,0 +1 @@ +7
diff --git a/Tests/RunCMake/ctest_exit/7-stderr.txt b/Tests/RunCMake/ctest_exit/7-stderr.txt new file mode 100644 index 0000000..8b4ca5db5 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/7-stderr.txt
@@ -0,0 +1,3 @@ +^CMake Error at [^ +]*/Tests/RunCMake/ctest_exit/exit1.cmake:2 \(message\): + send error$
diff --git a/Tests/RunCMake/ctest_exit/RunCMakeTest.cmake b/Tests/RunCMake/ctest_exit/RunCMakeTest.cmake new file mode 100644 index 0000000..936772a --- /dev/null +++ b/Tests/RunCMake/ctest_exit/RunCMakeTest.cmake
@@ -0,0 +1,45 @@ +include(RunCMake) + +message(STATUS "Multiple -S options:") + +run_cmake_command(3 ${CMAKE_CTEST_COMMAND} -V + -S ${RunCMake_SOURCE_DIR}/exit1.cmake + -S ${RunCMake_SOURCE_DIR}/exit2.cmake + ) + +run_cmake_command(7 ${CMAKE_CTEST_COMMAND} -V + -S ${RunCMake_SOURCE_DIR}/exit4.cmake + -S ${RunCMake_SOURCE_DIR}/exit1.cmake + -S ${RunCMake_SOURCE_DIR}/exit2.cmake + ) + +message(STATUS "Multiple -SP options:") + +run_cmake_command(3 ${CMAKE_CTEST_COMMAND} -V + -SP ${RunCMake_SOURCE_DIR}/exit1.cmake + -SP ${RunCMake_SOURCE_DIR}/exit2.cmake + ) + +run_cmake_command(7 ${CMAKE_CTEST_COMMAND} -V + -SP ${RunCMake_SOURCE_DIR}/exit4.cmake + -SP ${RunCMake_SOURCE_DIR}/exit1.cmake + -SP ${RunCMake_SOURCE_DIR}/exit2.cmake + ) + +message(STATUS "Mixed -S and -SP options:") + +run_cmake_command(7 ${CMAKE_CTEST_COMMAND} -V + -S ${RunCMake_SOURCE_DIR}/exit4.cmake + -SP ${RunCMake_SOURCE_DIR}/exit1.cmake + -S ${RunCMake_SOURCE_DIR}/exit2.cmake + ) + +message(STATUS "ctest_run_script:") + +configure_file( + ${RunCMake_SOURCE_DIR}/test.cmake.in + ${RunCMake_BINARY_DIR}/test.cmake @ONLY) + +run_cmake_command(Script ${CMAKE_CTEST_COMMAND} -V + -S ${RunCMake_BINARY_DIR}/test.cmake + )
diff --git a/Tests/RunCMake/ctest_exit/Script-result.txt b/Tests/RunCMake/ctest_exit/Script-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_exit/Script-result.txt
@@ -0,0 +1 @@ +(-1|255)
diff --git a/Tests/RunCMake/ctest_exit/Script-stderr.txt b/Tests/RunCMake/ctest_exit/Script-stderr.txt new file mode 100644 index 0000000..546a394 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/Script-stderr.txt
@@ -0,0 +1,8 @@ +^CMake Error at [^ +]*/Tests/RunCMake/ctest_exit/exit1.cmake:2 \(message\): + send error + + +CMake Error at [^ +]*/Tests/RunCMake/ctest_exit/exit1.cmake:2 \(message\): + send error$
diff --git a/Tests/RunCMake/ctest_exit/exit1.cmake b/Tests/RunCMake/ctest_exit/exit1.cmake new file mode 100644 index 0000000..4997ed3 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/exit1.cmake
@@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.10) +message(SEND_ERROR "send error") +cmake_language(EXIT 1)
diff --git a/Tests/RunCMake/ctest_exit/exit2.cmake b/Tests/RunCMake/ctest_exit/exit2.cmake new file mode 100644 index 0000000..536ffd8 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/exit2.cmake
@@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.10) +cmake_language(EXIT 2)
diff --git a/Tests/RunCMake/ctest_exit/exit4.cmake b/Tests/RunCMake/ctest_exit/exit4.cmake new file mode 100644 index 0000000..696d014 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/exit4.cmake
@@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.10) +cmake_language(EXIT 4)
diff --git a/Tests/RunCMake/ctest_exit/test.cmake.in b/Tests/RunCMake/ctest_exit/test.cmake.in new file mode 100644 index 0000000..5a9cb19 --- /dev/null +++ b/Tests/RunCMake/ctest_exit/test.cmake.in
@@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.10) + +ctest_run_script( + "@RunCMake_SOURCE_DIR@/exit1.cmake" + "@RunCMake_SOURCE_DIR@/exit4.cmake" + RETURN_VALUE ret + ) + +if(NOT ret EQUAL 4) + message(FATAL_ERROR "Expected ret == 4, got ${ret}") +endif() + +unset(ret) + +ctest_run_script(NEW_PROCESS + "@RunCMake_SOURCE_DIR@/exit1.cmake" + "@RunCMake_SOURCE_DIR@/exit4.cmake" + RETURN_VALUE ret + ) + +if(NOT ret EQUAL 4) + message(FATAL_ERROR "Expected ret == 4, got ${ret}") +endif()
diff --git a/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake b/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake index 3fe2090..11fee2f 100644 --- a/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake +++ b/Tests/RunCMake/file-DOWNLOAD/RunCMakeTest.cmake
@@ -23,6 +23,13 @@ run_cmake(range) run_cmake(SHOW_PROGRESS) +foreach(file IN ITEMS /dev/full /dev/urandom) + if(IS_WRITABLE "${file}") + run_cmake_with_options(file-write-error -Dfile=${file}) + break() + endif() +endforeach() + if(NOT CMake_TEST_NO_NETWORK) run_cmake(bad-hostname) endif()
diff --git a/Tests/RunCMake/file-DOWNLOAD/common.cmake b/Tests/RunCMake/file-DOWNLOAD/common.cmake index 6aa2fe6..d90c4d2 100644 --- a/Tests/RunCMake/file-DOWNLOAD/common.cmake +++ b/Tests/RunCMake/file-DOWNLOAD/common.cmake
@@ -2,7 +2,9 @@ set(slash /) endif() set(url "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/input.png") -set(file ${CMAKE_CURRENT_BINARY_DIR}/output.png) +if (NOT file) + set(file ${CMAKE_CURRENT_BINARY_DIR}/output.png) +endif () function(file_download) file(DOWNLOAD "${url}"
diff --git a/Tests/RunCMake/file-DOWNLOAD/file-write-error-stdout.txt b/Tests/RunCMake/file-DOWNLOAD/file-write-error-stdout.txt new file mode 100644 index 0000000..7d92af2 --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/file-write-error-stdout.txt
@@ -0,0 +1 @@ +-- status='23;"Failed writing received data to disk/application"'
diff --git a/Tests/RunCMake/file-DOWNLOAD/file-write-error.cmake b/Tests/RunCMake/file-DOWNLOAD/file-write-error.cmake new file mode 100644 index 0000000..1fd931c --- /dev/null +++ b/Tests/RunCMake/file-DOWNLOAD/file-write-error.cmake
@@ -0,0 +1,3 @@ +include(common.cmake) + +file_download()