diff options
97 files changed, 421 insertions, 185 deletions
diff --git a/Help/command/LINK_OPTIONS_LINKER.txt b/Help/command/LINK_OPTIONS_LINKER.txt index 76927be..a723375 100644 --- a/Help/command/LINK_OPTIONS_LINKER.txt +++ b/Help/command/LINK_OPTIONS_LINKER.txt @@ -8,3 +8,15 @@ driver option and the rest of the option string defines linker arguments using For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for ``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``. + +The ``LINKER:`` prefix can be specified as part of a ``SHELL:`` prefix +expression. + +The ``LINKER:`` prefix supports, as alternate syntax, specification of +arguments using ``SHELL:`` prefix and space as separator. Previous example +becomes ``"LINKER:SHELL:-z defs"``. + +.. note:: + + Specifying ``SHELL:`` prefix elsewhere than at the beginning of the + ``LINKER:`` prefix is not supported. diff --git a/Help/command/add_compile_definitions.rst b/Help/command/add_compile_definitions.rst index 48815d4..8225da7 100644 --- a/Help/command/add_compile_definitions.rst +++ b/Help/command/add_compile_definitions.rst @@ -1,9 +1,9 @@ add_compile_definitions ----------------------- -Adds preprocessor definitions to the compilation of source files. +Add preprocessor definitions to the compilation of source files. -:: +.. code-block:: cmake add_compile_definitions(<definition> ...) diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst index 350a1c0..fcdcfd4 100644 --- a/Help/command/add_compile_options.rst +++ b/Help/command/add_compile_options.rst @@ -1,9 +1,9 @@ add_compile_options ------------------- -Adds options to the compilation of source files. +Add options to the compilation of source files. -:: +.. code-block:: cmake add_compile_options(<option> ...) diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index 71fe494..9bf0d87 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -8,7 +8,9 @@ There are two main signatures for ``add_custom_command``. Generating Files ^^^^^^^^^^^^^^^^ -The first signature is for adding a custom command to produce an output:: +The first signature is for adding a custom command to produce an output: + +.. code-block:: cmake add_custom_command(OUTPUT output1 [output2 ...] COMMAND command1 [ARGS] [args1...] @@ -200,7 +202,7 @@ before or after building the target. The command becomes part of the target and will only execute when the target itself is built. If the target is already built, the command will not execute. -:: +.. code-block:: cmake add_custom_command(TARGET <target> PRE_BUILD | PRE_LINK | POST_BUILD diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst index a6b2f77..c63dd23 100644 --- a/Help/command/add_custom_target.rst +++ b/Help/command/add_custom_target.rst @@ -3,7 +3,7 @@ add_custom_target Add a target with no output so it will always be built. -:: +.. code-block:: cmake add_custom_target(Name [ALL] [command1 [args1...]] [COMMAND command2 [args2...] ...] diff --git a/Help/command/add_definitions.rst b/Help/command/add_definitions.rst index 1da15a6..39a43f4 100644 --- a/Help/command/add_definitions.rst +++ b/Help/command/add_definitions.rst @@ -1,9 +1,9 @@ add_definitions --------------- -Adds -D define flags to the compilation of source files. +Add -D define flags to the compilation of source files. -:: +.. code-block:: cmake add_definitions(-DFOO -DBAR ...) diff --git a/Help/command/add_dependencies.rst b/Help/command/add_dependencies.rst index 7a66143..de219a5 100644 --- a/Help/command/add_dependencies.rst +++ b/Help/command/add_dependencies.rst @@ -3,11 +3,11 @@ add_dependencies Add a dependency between top-level targets. -:: +.. code-block:: cmake add_dependencies(<target> [<target-dependency>]...) -Make a top-level ``<target>`` depend on other top-level targets to +Makes a top-level ``<target>`` depend on other top-level targets to ensure that they build before ``<target>`` does. A top-level target is one created by one of the :command:`add_executable`, :command:`add_library`, or :command:`add_custom_target` commands diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst index c7a30d7..0a7d7e1 100644 --- a/Help/command/add_executable.rst +++ b/Help/command/add_executable.rst @@ -3,7 +3,7 @@ add_executable Add an executable to the project using the specified source files. -:: +.. code-block:: cmake add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] @@ -47,7 +47,7 @@ within IDE. -------------------------------------------------------------------------- -:: +.. code-block:: cmake add_executable(<name> IMPORTED [GLOBAL]) @@ -67,7 +67,7 @@ properties for more information. -------------------------------------------------------------------------- -:: +.. code-block:: cmake add_executable(<name> ALIAS <target>) diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index c4c512c..ec6cb9d 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -10,7 +10,7 @@ Add a library to the project using the specified source files. Normal Libraries ^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] @@ -67,7 +67,7 @@ within IDE. Imported Libraries ^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> <SHARED|STATIC|MODULE|OBJECT|UNKNOWN> IMPORTED [GLOBAL]) @@ -92,7 +92,7 @@ for more information. Object Libraries ^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> OBJECT <src>...) @@ -121,7 +121,7 @@ consider adding at least one real source file to any target that references Alias Libraries ^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> ALIAS <target>) @@ -141,7 +141,7 @@ installed or exported. Interface Libraries ^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> INTERFACE [IMPORTED [GLOBAL]]) diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst index 551d440..1b02bee 100644 --- a/Help/command/add_link_options.rst +++ b/Help/command/add_link_options.rst @@ -1,9 +1,9 @@ add_link_options ---------------- -Adds options to the link of shared library, module and executable targets. +Add options to the link of shared library, module and executable targets. -:: +.. code-block:: cmake add_link_options(<option> ...) @@ -21,6 +21,6 @@ the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. -.. include:: LINK_OPTIONS_LINKER.txt - .. include:: OPTIONS_SHELL.txt + +.. include:: LINK_OPTIONS_LINKER.txt diff --git a/Help/command/add_subdirectory.rst b/Help/command/add_subdirectory.rst index 012ded4..8dba986 100644 --- a/Help/command/add_subdirectory.rst +++ b/Help/command/add_subdirectory.rst @@ -3,12 +3,11 @@ add_subdirectory Add a subdirectory to the build. -:: +.. code-block:: cmake - add_subdirectory(source_dir [binary_dir] - [EXCLUDE_FROM_ALL]) + add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) -Add a subdirectory to the build. The source_dir specifies the +Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.txt and code files are located. If it is a relative path it will be evaluated with respect to the current directory (the typical usage), but it may also be an diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst index d8a96e9..a8c257d 100644 --- a/Help/command/add_test.rst +++ b/Help/command/add_test.rst @@ -3,13 +3,13 @@ add_test Add a test to the project to be run by :manual:`ctest(1)`. -:: +.. code-block:: cmake add_test(NAME <name> COMMAND <command> [<arg>...] [CONFIGURATIONS <config>...] [WORKING_DIRECTORY <dir>]) -Add a test called ``<name>``. The test name may not contain spaces, +Adds a test called ``<name>``. The test name may not contain spaces, quotes, or other characters special in CMake syntax. The options are: ``COMMAND`` @@ -39,7 +39,9 @@ The ``COMMAND`` and ``WORKING_DIRECTORY`` options may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. -Example usage:: +Example usage: + +.. code-block:: cmake add_test(NAME mytest COMMAND testDriver --config $<CONFIGURATION> @@ -57,7 +59,7 @@ file produced by target ``myexe``. --------------------------------------------------------------------- -:: +.. code-block:: cmake add_test(<name> <command> [<arg>...]) diff --git a/Help/command/aux_source_directory.rst b/Help/command/aux_source_directory.rst index dcd1cdf..e0af665 100644 --- a/Help/command/aux_source_directory.rst +++ b/Help/command/aux_source_directory.rst @@ -3,7 +3,7 @@ aux_source_directory Find all source files in a directory. -:: +.. code-block:: cmake aux_source_directory(<dir> <variable>) diff --git a/Help/command/build_name.rst b/Help/command/build_name.rst index f717db1..2a1fbae 100644 --- a/Help/command/build_name.rst +++ b/Help/command/build_name.rst @@ -1,7 +1,7 @@ build_name ---------- -Disallowed. See CMake Policy :policy:`CMP0036`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0036`. Use ``${CMAKE_SYSTEM}`` and ``${CMAKE_CXX_COMPILER}`` instead. diff --git a/Help/command/create_test_sourcelist.rst b/Help/command/create_test_sourcelist.rst index dde6812..77e37c5 100644 --- a/Help/command/create_test_sourcelist.rst +++ b/Help/command/create_test_sourcelist.rst @@ -3,7 +3,7 @@ create_test_sourcelist Create a test driver and source list for building test programs. -:: +.. code-block:: cmake create_test_sourcelist(sourceListName driverName test1 test2 test3 diff --git a/Help/command/define_property.rst b/Help/command/define_property.rst index da2631c..8f7439b 100644 --- a/Help/command/define_property.rst +++ b/Help/command/define_property.rst @@ -3,7 +3,7 @@ define_property Define and document custom properties. -:: +.. code-block:: cmake define_property(<GLOBAL | DIRECTORY | TARGET | SOURCE | TEST | VARIABLE | CACHED_VARIABLE> @@ -11,7 +11,7 @@ Define and document custom properties. BRIEF_DOCS <brief-doc> [docs...] FULL_DOCS <full-doc> [docs...]) -Define one property in a scope for use with the :command:`set_property` and +Defines one property in a scope for use with the :command:`set_property` and :command:`get_property` commands. This is primarily useful to associate documentation with property names that may be retrieved with the :command:`get_property` command. The first argument determines the kind of diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst index 61dfc03..fb49b44 100644 --- a/Help/command/enable_language.rst +++ b/Help/command/enable_language.rst @@ -3,12 +3,12 @@ enable_language Enable a language (CXX/C/Fortran/etc) -:: +.. code-block:: cmake enable_language(<lang> [OPTIONAL] ) -This command enables support for the named language in CMake. This is -the same as the project command but does not create any of the extra +Enables support for the named language in CMake. This is +the same as the :command:`project` command but does not create any of the extra variables that are created by the project command. Example languages are ``CXX``, ``C``, ``CUDA``, ``Fortran``, and ``ASM``. diff --git a/Help/command/enable_testing.rst b/Help/command/enable_testing.rst index 1e3e279..e2028d2 100644 --- a/Help/command/enable_testing.rst +++ b/Help/command/enable_testing.rst @@ -3,7 +3,7 @@ enable_testing Enable testing for current directory and below. -:: +.. code-block:: cmake enable_testing() diff --git a/Help/command/exec_program.rst b/Help/command/exec_program.rst index 6dfdad3..bc9b069 100644 --- a/Help/command/exec_program.rst +++ b/Help/command/exec_program.rst @@ -1,7 +1,9 @@ exec_program ------------ -Deprecated. Use the :command:`execute_process` command instead. +.. deprecated:: 3.0 + + Use the :command:`execute_process` command instead. Run an executable program during the processing of the CMakeList.txt file. diff --git a/Help/command/export.rst b/Help/command/export.rst index 8c49328..b255ee8 100644 --- a/Help/command/export.rst +++ b/Help/command/export.rst @@ -3,11 +3,11 @@ export Export targets from the build tree for use by outside projects. -:: +.. code-block:: cmake export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>]) -Create a file ``<filename>`` that may be included by outside projects to +Creates a file ``<filename>`` that may be included by outside projects to import targets from the current project's build tree. This is useful during cross-compiling to build utility executables that can run on the host platform in one project and then import them into another @@ -25,7 +25,7 @@ export targets from an installation tree. The properties set on the generated IMPORTED targets will have the same values as the final values of the input TARGETS. -:: +.. code-block:: cmake export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>] [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES]) @@ -49,7 +49,7 @@ unspecified. transitive usage requirements of other targets that link to the object libraries in their implementation. -:: +.. code-block:: cmake export(PACKAGE <PackageName>) @@ -65,7 +65,7 @@ wide installations, it is not desirable to write the user package registry. If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable is enabled, the ``export(PACKAGE)`` command will do nothing. -:: +.. code-block:: cmake export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>]) diff --git a/Help/command/export_library_dependencies.rst b/Help/command/export_library_dependencies.rst index 2cb437e..9753abf 100644 --- a/Help/command/export_library_dependencies.rst +++ b/Help/command/export_library_dependencies.rst @@ -1,7 +1,7 @@ export_library_dependencies --------------------------- -Disallowed. See CMake Policy :policy:`CMP0033`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0033`. Use :command:`install(EXPORT)` or :command:`export` command. diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 3ae9c2d..9395356 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -51,8 +51,9 @@ mode and "Config" mode. The above signature selects Module mode. If no module is found the command falls back to Config mode, described below. This fall back is disabled if the ``MODULE`` option is given. -In Module mode, CMake searches for a file called ``Find<PackageName>.cmake`` -in the :variable:`CMAKE_MODULE_PATH` followed by the CMake installation. +In Module mode, CMake searches for a file called ``Find<PackageName>.cmake``. +The file is first searched in the :variable:`CMAKE_MODULE_PATH`, +then among the :ref:`Find Modules` provided by the CMake installation. If the file is found, it is read and processed by CMake. It is responsible for finding the package, checking the version, and producing any needed messages. Some find-modules provide limited or no support for versioning; diff --git a/Help/command/fltk_wrap_ui.rst b/Help/command/fltk_wrap_ui.rst index 041e5a7..6675272 100644 --- a/Help/command/fltk_wrap_ui.rst +++ b/Help/command/fltk_wrap_ui.rst @@ -3,7 +3,7 @@ fltk_wrap_ui Create FLTK user interfaces Wrappers. -:: +.. code-block:: cmake fltk_wrap_ui(resultingLibraryName source1 source2 ... sourceN ) diff --git a/Help/command/get_source_file_property.rst b/Help/command/get_source_file_property.rst index 51fbd33..decec19 100644 --- a/Help/command/get_source_file_property.rst +++ b/Help/command/get_source_file_property.rst @@ -3,11 +3,11 @@ get_source_file_property Get a property for a source file. -:: +.. code-block:: cmake get_source_file_property(VAR file property) -Get a property from a source file. The value of the property is +Gets a property from a source file. The value of the property is stored in the variable ``VAR``. If the source property is not found, the behavior depends on whether it has been defined to be an ``INHERITED`` property or not (see :command:`define_property`). Non-inherited properties will set diff --git a/Help/command/get_target_property.rst b/Help/command/get_target_property.rst index 98e9db3..cbf4721 100644 --- a/Help/command/get_target_property.rst +++ b/Help/command/get_target_property.rst @@ -3,7 +3,7 @@ get_target_property Get a property from a target. -:: +.. code-block:: cmake get_target_property(VAR target property) diff --git a/Help/command/get_test_property.rst b/Help/command/get_test_property.rst index 555c3b2..e02b9bc 100644 --- a/Help/command/get_test_property.rst +++ b/Help/command/get_test_property.rst @@ -3,7 +3,7 @@ get_test_property Get a property of the test. -:: +.. code-block:: cmake get_test_property(test property VAR) diff --git a/Help/command/include_directories.rst b/Help/command/include_directories.rst index e797b5d..fe281c3 100644 --- a/Help/command/include_directories.rst +++ b/Help/command/include_directories.rst @@ -3,7 +3,7 @@ include_directories Add include directories to the build. -:: +.. code-block:: cmake include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...]) diff --git a/Help/command/include_external_msproject.rst b/Help/command/include_external_msproject.rst index 335282a..375baf2 100644 --- a/Help/command/include_external_msproject.rst +++ b/Help/command/include_external_msproject.rst @@ -3,7 +3,7 @@ include_external_msproject Include an external Microsoft project file in a workspace. -:: +.. code-block:: cmake include_external_msproject(projectname location [TYPE projectTypeGUID] diff --git a/Help/command/include_regular_expression.rst b/Help/command/include_regular_expression.rst index ab5a563..dde8378 100644 --- a/Help/command/include_regular_expression.rst +++ b/Help/command/include_regular_expression.rst @@ -3,11 +3,11 @@ include_regular_expression Set the regular expression used for dependency checking. -:: +.. code-block:: cmake include_regular_expression(regex_match [regex_complain]) -Set the regular expressions used in dependency checking. Only files +Sets the regular expressions used in dependency checking. Only files matching ``regex_match`` will be traced as dependencies. Only files matching ``regex_complain`` will generate warnings if they cannot be found (standard header paths are not searched). The defaults are: diff --git a/Help/command/install.rst b/Help/command/install.rst index 98074d0..4966df4 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -101,7 +101,7 @@ Installing Targets .. _TARGETS: -:: +.. code-block:: cmake install(TARGETS targets... [EXPORT <export-name>] [[ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE| @@ -305,7 +305,7 @@ Installing Files .. _FILES: .. _PROGRAMS: -:: +.. code-block:: cmake install(<FILES|PROGRAMS> files... DESTINATION <dir> [PERMISSIONS permissions...] @@ -340,7 +340,7 @@ Installing Directories .. _DIRECTORY: -:: +.. code-block:: cmake install(DIRECTORY dirs... DESTINATION <dir> [FILE_PERMISSIONS permissions...] @@ -424,7 +424,7 @@ Custom Installation Logic .. _CODE: .. _SCRIPT: -:: +.. code-block:: cmake install([[SCRIPT <file>] [CODE <code>]] [COMPONENT <component>] [EXCLUDE_FROM_ALL] [...]) @@ -447,7 +447,7 @@ Installing Exports .. _EXPORT: -:: +.. code-block:: cmake install(EXPORT <export-name> DESTINATION <dir> [NAMESPACE <namespace>] [[FILE <name>.cmake]| diff --git a/Help/command/install_files.rst b/Help/command/install_files.rst index 1850be6..f5fb46d 100644 --- a/Help/command/install_files.rst +++ b/Help/command/install_files.rst @@ -1,7 +1,9 @@ install_files ------------- -Deprecated. Use the :command:`install(FILES)` command instead. +.. deprecated:: 3.0 + + Use the :command:`install(FILES)` command instead. This command has been superceded by the :command:`install` command. It is provided for compatibility with older CMake code. The ``FILES`` form is diff --git a/Help/command/install_programs.rst b/Help/command/install_programs.rst index 79aa486..fab6482 100644 --- a/Help/command/install_programs.rst +++ b/Help/command/install_programs.rst @@ -1,7 +1,9 @@ install_programs ---------------- -Deprecated. Use the :command:`install(PROGRAMS)` command instead. +.. deprecated:: 3.0 + + Use the :command:`install(PROGRAMS)` command instead. This command has been superceded by the :command:`install` command. It is provided for compatibility with older CMake code. The ``FILES`` form is diff --git a/Help/command/install_targets.rst b/Help/command/install_targets.rst index 49ca696..c9efdce 100644 --- a/Help/command/install_targets.rst +++ b/Help/command/install_targets.rst @@ -1,7 +1,9 @@ install_targets --------------- -Deprecated. Use the :command:`install(TARGETS)` command instead. +.. deprecated:: 3.0 + + Use the :command:`install(TARGETS)` command instead. This command has been superceded by the :command:`install` command. It is provided for compatibility with older CMake code. diff --git a/Help/command/link_directories.rst b/Help/command/link_directories.rst index 1dce9a0..9cb8faa 100644 --- a/Help/command/link_directories.rst +++ b/Help/command/link_directories.rst @@ -3,11 +3,11 @@ link_directories Add directories in which the linker will look for libraries. -:: +.. code-block:: cmake link_directories([AFTER|BEFORE] directory1 [directory2 ...]) -Add the paths in which the linker should search for libraries. +Adds the paths in which the linker should search for libraries. Relative paths given to this command are interpreted as relative to the current source directory, see :policy:`CMP0015`. diff --git a/Help/command/link_libraries.rst b/Help/command/link_libraries.rst index fd5dc37..8665cb7 100644 --- a/Help/command/link_libraries.rst +++ b/Help/command/link_libraries.rst @@ -3,7 +3,7 @@ link_libraries Link libraries to all targets added later. -:: +.. code-block:: cmake link_libraries([item1 [item2 [...]]] [[debug|optimized|general] <item>] ...) diff --git a/Help/command/load_cache.rst b/Help/command/load_cache.rst index f113447..33625c4 100644 --- a/Help/command/load_cache.rst +++ b/Help/command/load_cache.rst @@ -3,21 +3,20 @@ load_cache Load in the values from another project's CMake cache. -:: +.. code-block:: cmake - load_cache(pathToCacheFile READ_WITH_PREFIX - prefix entry1...) + load_cache(pathToCacheFile READ_WITH_PREFIX prefix entry1...) -Read the cache and store the requested entries in variables with their +Reads the cache and store the requested entries in variables with their name prefixed with the given prefix. This only reads the values, and does not create entries in the local project's cache. -:: +.. code-block:: cmake load_cache(pathToCacheFile [EXCLUDE entry1...] [INCLUDE_INTERNALS entry1...]) -Load in the values from another cache and store them in the local +Loads in the values from another cache and store them in the local project's cache as internal entries. This is useful for a project that depends on another project built in a different tree. ``EXCLUDE`` option can be used to provide a list of entries to be excluded. diff --git a/Help/command/load_command.rst b/Help/command/load_command.rst index a1576e8..dc23599 100644 --- a/Help/command/load_command.rst +++ b/Help/command/load_command.rst @@ -1,7 +1,7 @@ load_command ------------ -Disallowed. See CMake Policy :policy:`CMP0031`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0031`. Load a command into a running CMake. diff --git a/Help/command/make_directory.rst b/Help/command/make_directory.rst index 27ecf51..8469b0a 100644 --- a/Help/command/make_directory.rst +++ b/Help/command/make_directory.rst @@ -1,7 +1,9 @@ make_directory -------------- -Deprecated. Use the :command:`file(MAKE_DIRECTORY)` command instead. +.. deprecated:: 3.0 + + Use the :command:`file(MAKE_DIRECTORY)` command instead. :: diff --git a/Help/command/output_required_files.rst b/Help/command/output_required_files.rst index 5e13557..8bc6a73 100644 --- a/Help/command/output_required_files.rst +++ b/Help/command/output_required_files.rst @@ -1,7 +1,7 @@ output_required_files --------------------- -Disallowed. See CMake Policy :policy:`CMP0032`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0032`. Approximate C preprocessor dependency scanning. diff --git a/Help/command/qt_wrap_cpp.rst b/Help/command/qt_wrap_cpp.rst index 3843bf5..c04c7a6 100644 --- a/Help/command/qt_wrap_cpp.rst +++ b/Help/command/qt_wrap_cpp.rst @@ -3,10 +3,9 @@ qt_wrap_cpp Create Qt Wrappers. -:: +.. code-block:: cmake - qt_wrap_cpp(resultingLibraryName DestName - SourceLists ...) + qt_wrap_cpp(resultingLibraryName DestName SourceLists ...) -Produce moc files for all the .h files listed in the SourceLists. The +Produces moc files for all the .h files listed in the SourceLists. The moc files will be added to the library using the ``DestName`` source list. diff --git a/Help/command/qt_wrap_ui.rst b/Help/command/qt_wrap_ui.rst index f731ed9..9a8863d 100644 --- a/Help/command/qt_wrap_ui.rst +++ b/Help/command/qt_wrap_ui.rst @@ -3,12 +3,12 @@ qt_wrap_ui Create Qt user interfaces Wrappers. -:: +.. code-block:: cmake qt_wrap_ui(resultingLibraryName HeadersDestName SourcesDestName SourceLists ...) -Produce .h and .cxx files for all the .ui files listed in the +Produces .h and .cxx files for all the .ui files listed in the ``SourceLists``. The .h files will be added to the library using the ``HeadersDestNamesource`` list. The .cxx files will be added to the library using the ``SourcesDestNamesource`` list. diff --git a/Help/command/remove.rst b/Help/command/remove.rst index 4628277..543d016 100644 --- a/Help/command/remove.rst +++ b/Help/command/remove.rst @@ -1,7 +1,9 @@ remove ------ -Deprecated. Use the :command:`list(REMOVE_ITEM)` command instead. +.. deprecated:: 3.0 + + Use the :command:`list(REMOVE_ITEM)` command instead. :: diff --git a/Help/command/remove_definitions.rst b/Help/command/remove_definitions.rst index ea18918..faad16d 100644 --- a/Help/command/remove_definitions.rst +++ b/Help/command/remove_definitions.rst @@ -1,9 +1,9 @@ remove_definitions ------------------ -Removes -D define flags added by :command:`add_definitions`. +Remove -D define flags added by :command:`add_definitions`. -:: +.. code-block:: cmake remove_definitions(-DFOO -DBAR ...) diff --git a/Help/command/set_source_files_properties.rst b/Help/command/set_source_files_properties.rst index b4904e8..8538a1e 100644 --- a/Help/command/set_source_files_properties.rst +++ b/Help/command/set_source_files_properties.rst @@ -3,13 +3,13 @@ set_source_files_properties Source files can have properties that affect how they are built. -:: +.. code-block:: cmake set_source_files_properties([file1 [file2 [...]]] PROPERTIES prop1 value1 [prop2 value2 [...]]) -Set properties associated with source files using a key/value paired +Sets properties associated with source files using a key/value paired list. See :ref:`Source File Properties` for the list of properties known to CMake. Source file properties are visible only to targets added in the same directory (CMakeLists.txt). diff --git a/Help/command/set_target_properties.rst b/Help/command/set_target_properties.rst index 7db952d..597be23 100644 --- a/Help/command/set_target_properties.rst +++ b/Help/command/set_target_properties.rst @@ -3,13 +3,13 @@ set_target_properties Targets can have properties that affect how they are built. -:: +.. code-block:: cmake set_target_properties(target1 target2 ... PROPERTIES prop1 value1 prop2 value2 ...) -Set properties on targets. The syntax for the command is to list all +Sets properties on targets. The syntax for the command is to list all the targets you want to change, and then provide the values you want to set next. You can use any prop value pair you want and extract it later with the :command:`get_property` or :command:`get_target_property` diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst index 3efb165..55fd635 100644 --- a/Help/command/set_tests_properties.rst +++ b/Help/command/set_tests_properties.rst @@ -3,11 +3,11 @@ set_tests_properties Set a property of the tests. -:: +.. code-block:: cmake set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2) -Set a property for the tests. If the test is not found, CMake +Sets a property for the tests. If the test is not found, CMake will report an error. :manual:`Generator expressions <cmake-generator-expressions(7)>` will be expanded the same as supported by the test's :command:`add_test` call. See diff --git a/Help/command/source_group.rst b/Help/command/source_group.rst index 938ca40..6623c98 100644 --- a/Help/command/source_group.rst +++ b/Help/command/source_group.rst @@ -4,7 +4,7 @@ source_group Define a grouping for source files in IDE project generation. There are two different signatures to create source groups. -:: +.. code-block:: cmake source_group(<name> [FILES <src>...] [REGULAR_EXPRESSION <regex>]) source_group(TREE <root> [PREFIX <prefix>] [FILES <src>...]) diff --git a/Help/command/subdir_depends.rst b/Help/command/subdir_depends.rst index 5676c8f..0c1b3c1 100644 --- a/Help/command/subdir_depends.rst +++ b/Help/command/subdir_depends.rst @@ -1,7 +1,7 @@ subdir_depends -------------- -Disallowed. See CMake Policy :policy:`CMP0029`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0029`. Does nothing. diff --git a/Help/command/subdirs.rst b/Help/command/subdirs.rst index 43b87d4..530951b 100644 --- a/Help/command/subdirs.rst +++ b/Help/command/subdirs.rst @@ -1,7 +1,9 @@ subdirs ------- -Deprecated. Use the :command:`add_subdirectory` command instead. +.. deprecated:: 3.0 + + Use the :command:`add_subdirectory` command instead. Add a list of subdirectories to the build. diff --git a/Help/command/target_compile_definitions.rst b/Help/command/target_compile_definitions.rst index a740117..9e9c690 100644 --- a/Help/command/target_compile_definitions.rst +++ b/Help/command/target_compile_definitions.rst @@ -3,13 +3,13 @@ target_compile_definitions Add compile definitions to a target. -:: +.. code-block:: cmake target_compile_definitions(<target> <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify compile definitions to use when compiling a given ``<target>``. The +Specifies compile definitions to use when compiling a given ``<target>``. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst index bf413bf..9271cd5 100644 --- a/Help/command/target_compile_features.rst +++ b/Help/command/target_compile_features.rst @@ -3,11 +3,11 @@ target_compile_features Add expected compiler features to a target. -:: +.. code-block:: cmake target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...]) -Specify compiler features required when compiling a given target. If the +Specifies compiler features required when compiling a given target. If the feature is not listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable or :variable:`CMAKE_CXX_COMPILE_FEATURES` variable, then an error will be reported by CMake. If the use of the feature requires diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst index 88b7f15..c26c926 100644 --- a/Help/command/target_compile_options.rst +++ b/Help/command/target_compile_options.rst @@ -3,13 +3,13 @@ target_compile_options Add compile options to a target. -:: +.. code-block:: cmake target_compile_options(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify compile options to use when compiling a given target. The +Specifies compile options to use when compiling a given target. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. diff --git a/Help/command/target_include_directories.rst b/Help/command/target_include_directories.rst index e71be64..660e15c 100644 --- a/Help/command/target_include_directories.rst +++ b/Help/command/target_include_directories.rst @@ -3,13 +3,13 @@ target_include_directories Add include directories to a target. -:: +.. code-block:: cmake target_include_directories(<target> [SYSTEM] [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify include directories to use when compiling a given target. +Specifies include directories to use when compiling a given target. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. diff --git a/Help/command/target_link_directories.rst b/Help/command/target_link_directories.rst index b46aac0..76da94d 100644 --- a/Help/command/target_link_directories.rst +++ b/Help/command/target_link_directories.rst @@ -3,13 +3,13 @@ target_link_directories Add link directories to a target. -:: +.. code-block:: cmake target_link_directories(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify the paths in which the linker should search for libraries when +Specifies the paths in which the linker should search for libraries when linking a given target. Each item can be an absolute or relative path, with the latter being interpreted as relative to the current source directory. These items will be added to the link command. diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst index 58f312e..76c0d28 100644 --- a/Help/command/target_link_libraries.rst +++ b/Help/command/target_link_libraries.rst @@ -14,7 +14,9 @@ Overview ^^^^^^^^ This command has several signatures as detailed in subsections below. -All of them have the general form:: +All of them have the general form + +.. code-block:: cmake target_link_libraries(<target> ... <item>... ...) @@ -128,7 +130,7 @@ buildsystem properties. Libraries for a Target and/or its Dependents ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> <item>... @@ -145,7 +147,7 @@ used for linking ``<target>``. Libraries for both a Target and its Dependents ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> <item>...) @@ -163,7 +165,7 @@ exclusively by this signature private. Libraries for a Target and/or its Dependents (Legacy) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> <LINK_PRIVATE|LINK_PUBLIC> <lib>... @@ -185,7 +187,7 @@ made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`. If policy Libraries for Dependents Only (Legacy) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> LINK_INTERFACE_LIBRARIES <item>...) diff --git a/Help/command/target_link_options.rst b/Help/command/target_link_options.rst index 8f47180..285455a 100644 --- a/Help/command/target_link_options.rst +++ b/Help/command/target_link_options.rst @@ -3,13 +3,13 @@ target_link_options Add link options to a target. -:: +.. code-block:: cmake target_link_options(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify link options to use when linking a given target. The +Specifies link options to use when linking a given target. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. @@ -37,6 +37,6 @@ with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. -.. include:: LINK_OPTIONS_LINKER.txt - .. include:: OPTIONS_SHELL.txt + +.. include:: LINK_OPTIONS_LINKER.txt diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst index 5dd8d86..27e737b 100644 --- a/Help/command/target_sources.rst +++ b/Help/command/target_sources.rst @@ -3,13 +3,13 @@ target_sources Add sources to a target. -:: +.. code-block:: cmake target_sources(<target> <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify sources to use when compiling a given target. Relative +Specifies sources to use when compiling a given target. Relative source file paths are interpreted as being relative to the current source directory (i.e. :variable:`CMAKE_CURRENT_SOURCE_DIR`). The named ``<target>`` must have been created by a command such as diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 66ea3d7..28caa7c 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -10,7 +10,7 @@ Try building some code. Try Compiling Whole Projects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake try_compile(RESULT_VAR <bindir> <srcdir> <projectName> [<targetName>] [CMAKE_FLAGS <flags>...] @@ -28,7 +28,7 @@ below for the meaning of other options. Try Compiling Source Files ^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake try_compile(RESULT_VAR <bindir> <srcfile|SOURCES srcfile...> [CMAKE_FLAGS <flags>...] @@ -47,7 +47,9 @@ returned in ``RESULT_VAR``. In this form the user need only supply one or more source files that include a definition for ``main``. CMake will create a ``CMakeLists.txt`` file to build -the source(s) as an executable that looks something like this:: +the source(s) as an executable that looks something like this: + +.. code-block:: cmake add_definitions(<expanded COMPILE_DEFINITIONS from caller>) include_directories(${INCLUDE_DIRECTORIES}) diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst index e3bd57d..dfa0bf9 100644 --- a/Help/command/try_run.rst +++ b/Help/command/try_run.rst @@ -10,7 +10,7 @@ Try compiling and then running some code. Try Compiling and Running Source Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR bindir srcfile [CMAKE_FLAGS <flags>...] diff --git a/Help/command/use_mangled_mesa.rst b/Help/command/use_mangled_mesa.rst index 6f4d7ac..4d9e12b 100644 --- a/Help/command/use_mangled_mesa.rst +++ b/Help/command/use_mangled_mesa.rst @@ -1,7 +1,7 @@ use_mangled_mesa ---------------- -Disallowed. See CMake Policy :policy:`CMP0030`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0030`. Copy mesa headers for use in combination with system GL. diff --git a/Help/command/utility_source.rst b/Help/command/utility_source.rst index ee34492..94d6a4e 100644 --- a/Help/command/utility_source.rst +++ b/Help/command/utility_source.rst @@ -1,7 +1,7 @@ utility_source -------------- -Disallowed. See CMake Policy :policy:`CMP0034`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0034`. Specify the source tree of a third-party utility. diff --git a/Help/command/variable_requires.rst b/Help/command/variable_requires.rst index 9cf9f3f..b4742a5 100644 --- a/Help/command/variable_requires.rst +++ b/Help/command/variable_requires.rst @@ -1,7 +1,7 @@ variable_requires ----------------- -Disallowed. See CMake Policy :policy:`CMP0035`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0035`. Use the :command:`if` command instead. diff --git a/Help/command/write_file.rst b/Help/command/write_file.rst index 40e7557..4d476bd 100644 --- a/Help/command/write_file.rst +++ b/Help/command/write_file.rst @@ -1,7 +1,9 @@ write_file ---------- -Deprecated. Use the :command:`file(WRITE)` command instead. +.. deprecated:: 3.0 + + Use the :command:`file(WRITE)` command instead. :: diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index 0cc5fca..aec9ba5 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -145,8 +145,9 @@ These commands are available only in CTest scripts. Deprecated Commands =================== -These commands are available only for compatibility with older -versions of CMake. Do not use them in new code. +These commands are deprecated since CMake version 3.0. +They are available only for backward compatibility. +Do not use them in new code. .. toctree:: :maxdepth: 1 diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 76fd3d9..0826ce0 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -31,7 +31,9 @@ Logical Expressions Logical expressions are used to create conditional output. The basic expressions are the ``0`` and ``1`` expressions. Because other logical expressions evaluate to either ``0`` or ``1``, they can be composed to -create conditional output:: +create conditional output: + +.. code-block:: cmake $<$<CONFIG:Debug>:DEBUG_MODE> @@ -151,14 +153,18 @@ Informational Expressions ========================= These expressions expand to some information. The information may be used -directly, eg:: +directly, eg: + +.. code-block:: cmake include_directories(/usr/include/$<CXX_COMPILER_ID>/) expands to ``/usr/include/GNU/`` or ``/usr/include/Clang/`` etc, depending on the Id of the compiler. -These expressions may also may be combined with logical expressions:: +These expressions may also may be combined with logical expressions: + +.. code-block:: cmake $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,4.2.0>:OLD_COMPILER> @@ -246,18 +252,24 @@ Output Expressions These expressions generate output, in some cases depending on an input. These expressions may be combined with other expressions for information or logical -comparison:: +comparison: + +.. code-block:: cmake -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I> generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target property with each entry preceded by ``-I``. Note that a more-complete use in this situation would require first checking if the INCLUDE_DIRECTORIES -property is non-empty:: +property is non-empty: + +.. code-block:: cmake $<$<BOOL:${prop}>:-I$<JOIN:${prop}, -I>> -where ``${prop}`` refers to a helper variable:: +where ``${prop}`` refers to a helper variable: + +.. code-block:: cmake set(prop "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>") diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index 8740d97..630a86b 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -257,27 +257,31 @@ invocation as exactly one argument. .. No code-block syntax highlighting in the following example (escape \" not supported by our cmake.py) -For example:: +For example: - message("This is a quoted argument containing multiple lines. - This is always one argument even though it contains a ; character. - Both \\-escape sequences and ${variable} references are evaluated. - The text does not end on an escaped double-quote like \". - It does end in an unescaped double quote. - ") +.. code-block:: cmake + + message("This is a quoted argument containing multiple lines. + This is always one argument even though it contains a ; character. + Both \\-escape sequences and ${variable} references are evaluated. + The text does not end on an escaped double-quote like \". + It does end in an unescaped double quote. + ") .. No code-block syntax highlighting in the following example (for conformity with the two above examples) The final ``\`` on any line ending in an odd number of backslashes is treated as a line continuation and ignored along with the -immediately following newline character. For example:: +immediately following newline character. For example: + +.. code-block:: cmake - message("\ - This is the first line of a quoted argument. \ - In fact it is the only line but since it is long \ - the source code uses line continuation.\ - ") + message("\ + This is the first line of a quoted argument. \ + In fact it is the only line but since it is long \ + the source code uses line continuation.\ + ") .. note:: CMake versions prior to 3.0 do not support continuation with ``\``. diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 5c3eb81..1651114 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -138,6 +138,7 @@ Properties on Targets /prop_tgt/AUTORCC_OPTIONS /prop_tgt/BINARY_DIR /prop_tgt/BUILD_RPATH + /prop_tgt/BUILD_RPATH_USE_ORIGIN /prop_tgt/BUILD_WITH_INSTALL_NAME_DIR /prop_tgt/BUILD_WITH_INSTALL_RPATH /prop_tgt/BUNDLE_EXTENSION diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9dd36ed..b88c661 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -322,6 +322,7 @@ Variables that Control the Build /variable/CMAKE_AUTOUIC_OPTIONS /variable/CMAKE_AUTOUIC_SEARCH_PATHS /variable/CMAKE_BUILD_RPATH + /variable/CMAKE_BUILD_RPATH_USE_ORIGIN /variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR /variable/CMAKE_BUILD_WITH_INSTALL_RPATH /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY diff --git a/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst new file mode 100644 index 0000000..511de7a --- /dev/null +++ b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst @@ -0,0 +1,24 @@ +BUILD_RPATH_USE_ORIGIN +---------------------- + +Whether to use relative paths for the build ``RPATH``. + +This property is initialized by the value of the variable +:variable:`CMAKE_BUILD_RPATH_USE_ORIGIN`. + +On platforms that support runtime paths (``RPATH``) with the +``$ORIGIN`` token, setting this property to ``TRUE`` enables relative +paths in the build ``RPATH`` for executables that point to shared +libraries in the same build tree. + +Normally the build ``RPATH`` of an executable contains absolute paths +to the directory of shared libraries. Directories contained within the +build tree can be made relative to enable relocatable builds and to +help achieving reproducible builds by omitting the build directory +from the build environment. + +This property has no effect on platforms that do not support the +``$ORIGIN`` token in ``RPATH``, or when the :variable:`CMAKE_SKIP_RPATH` +variable is set. The runtime path set through the +:prop_tgt:`BUILD_RPATH` target property is also unaffected by this +property. diff --git a/Help/release/dev/relative-rpath.rst b/Help/release/dev/relative-rpath.rst new file mode 100644 index 0000000..5c62b10 --- /dev/null +++ b/Help/release/dev/relative-rpath.rst @@ -0,0 +1,8 @@ +relative-rpath +-------------- + +* A :variable:`CMAKE_BUILD_RPATH_USE_ORIGIN` variable and corresponding + :prop_tgt:`BUILD_RPATH_USE_ORIGIN` target property were added to + enable use of relative runtime paths (RPATHs). This helps achieving + relocatable and reproducible builds that are invariant of the build + directory. diff --git a/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst b/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst new file mode 100644 index 0000000..e34ede6 --- /dev/null +++ b/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst @@ -0,0 +1,7 @@ +CMAKE_BUILD_RPATH_USE_ORIGIN +---------------------------- + +Whether to use relative paths for the build ``RPATH``. + +This is used to initialize the :prop_tgt:`BUILD_RPATH_USE_ORIGIN` target +property for all targets, see that property for more details. diff --git a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst index 0e52282..321f97e 100644 --- a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst +++ b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst @@ -17,7 +17,7 @@ For example, for ``Clang`` we have: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Xlinker" " ") -Specifying ``"LINKER:-z defs"`` will be transformed in +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Xlinker -z -Xlinker defs``. For ``GNU GCC``: @@ -27,7 +27,7 @@ For ``GNU GCC``: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,") set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") -Specifying ``"LINKER:-z defs"`` will be transformed in ``-Wl,-z,defs``. +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Wl,-z,defs``. And for ``SunPro``: @@ -36,4 +36,4 @@ And for ``SunPro``: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ") set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") -Specifying ``"LINKER:-z defs"`` will be transformed in ``-Qoption ld -z,defs``. +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Qoption ld -z,defs``. diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index b0911b4..9edc309 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -5,7 +5,9 @@ CMakeDetermineVSServicePack --------------------------- -Deprecated. Do not use. +.. deprecated:: 3.0 + + Do not use. The functionality of this module has been superseded by the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable that contains @@ -170,4 +172,3 @@ function(DetermineVSServicePack _pack) endif() endif() endfunction() - diff --git a/Modules/CMakeExpandImportedTargets.cmake b/Modules/CMakeExpandImportedTargets.cmake index 4b97c37..ae26cc2 100644 --- a/Modules/CMakeExpandImportedTargets.cmake +++ b/Modules/CMakeExpandImportedTargets.cmake @@ -5,7 +5,9 @@ CMakeExpandImportedTargets -------------------------- -Deprecated. Do not use. +.. deprecated:: 3.4 + + Do not use. This module was once needed to expand imported targets to the underlying libraries they reference on disk for use with the :command:`try_compile` diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index ec17c2e..7ac09dc 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -5,7 +5,9 @@ CMakeForceCompiler ------------------ -Deprecated. Do not use. +.. deprecated:: 3.6 + + Do not use. The macros provided by this module were once intended for use by cross-compiling toolchain files when CMake was not able to automatically diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 2c8dd81..0f5cab4 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -2,19 +2,22 @@ FindCUDA -------- -.. note:: - - The FindCUDA module has been superseded by first-class support - for the CUDA language in CMake. It is no longer necessary to - use this module or call ``find_package(CUDA)``. This module - now exists only for compatibility with projects that have not - been ported. - - Instead, list ``CUDA`` among the languages named in the top-level - call to the :command:`project` command, or call the - :command:`enable_language` command with ``CUDA``. - Then one can add CUDA (``.cu``) sources to programs directly - in calls to :command:`add_library` and :command:`add_executable`. +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)``. +Instead, list ``CUDA`` among the languages named in the top-level +call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Tools for building CUDA C files: libraries and build dependencies. diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 90c5592..8c45a8c 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1132,7 +1132,12 @@ macro(_MPI_create_imported_target LANG) add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) endif() - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + # When this is consumed for compiling CUDA, use '-Xcompiler' to wrap '-pthread'. + string(REPLACE "-pthread" "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler >-pthread" + _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}") + unset(_MPI_${LANG}_COMPILE_OPTIONS) + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 6a47c15..d1f7b31 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -5,12 +5,12 @@ FindPythonInterp ---------------- -Find python interpreter - .. deprecated:: 3.12 Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. +Find python interpreter + This module finds if Python interpreter is installed and determines where the executables are. This code sets the following variables: diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 2be5d71..1d62ac4 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -5,12 +5,12 @@ FindPythonLibs -------------- -Find python libraries - .. deprecated:: 3.12 Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. +Find python libraries + This module finds if Python 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: diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake index 7f25671..35840f5 100644 --- a/Modules/FindwxWindows.cmake +++ b/Modules/FindwxWindows.cmake @@ -5,13 +5,15 @@ FindwxWindows ------------- +.. deprecated:: 3.0 + + Replaced by :module:`FindwxWidgets`. + Find wxWindows (wxWidgets) installation This module finds if wxWindows/wxWidgets is installed and determines where the include files and libraries are. It also determines what -the name of the library is. Please note this file is DEPRECATED and -replaced by FindwxWidgets.cmake. This code sets the following -variables: +the name of the library is. This code sets the following variables: :: diff --git a/Modules/Platform/DragonFly.cmake b/Modules/Platform/DragonFly.cmake index c22677b..12e5f3c 100644 --- a/Modules/Platform/DragonFly.cmake +++ b/Modules/Platform/DragonFly.cmake @@ -3,3 +3,7 @@ # see http://archive.netbsd.se/?ml=dfbsd-users&a=2007-07&m=4678361 include(Platform/FreeBSD) + +# DragonFly BSD requires -z origin to enable $ORIGIN expansion in RPATH. +# This is not required for FreeBSD since 10.2-RELEASE. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,") diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index ce4d3ce..082e9f6 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -6,6 +6,8 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +# Does not require -z origin since 10.2-RELEASE +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index dfc2664..7e0af61 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -11,6 +11,7 @@ set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index 1f8c1b4..b5d5464 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -1,6 +1,7 @@ set(CMAKE_DL_LIBS "dl") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index 1004eb3..a8f4cc8 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -6,6 +6,7 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index 6466a0a..97e2a6a 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -15,6 +15,10 @@ if(NOT CMAKE_PLATFORM_RUNTIME_PATH) "${LDCONFIG_HINTS}") endif() +# OpenBSD requires -z origin to enable $ORIGIN expansion in RPATH. +# This is not required for NetBSD. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1) # OpenBSD has no multilib diff --git a/Modules/Platform/SunOS-GNU.cmake b/Modules/Platform/SunOS-GNU.cmake index 485f235..47334d6 100644 --- a/Modules/Platform/SunOS-GNU.cmake +++ b/Modules/Platform/SunOS-GNU.cmake @@ -11,6 +11,7 @@ set(__SUNOS_COMPILER_GNU 1) macro(__sunos_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-R") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-h") # Initialize C link type selection flags. These flags are used when diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index 75f1fc3..92a362e 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -5,7 +5,9 @@ TestCXXAcceptsFlag ------------------ -Deprecated. See :module:`CheckCXXCompilerFlag`. +.. deprecated:: 3.0 + + See :module:`CheckCXXCompilerFlag`. Check if the CXX compiler accepts a flag. diff --git a/Modules/Use_wxWindows.cmake b/Modules/Use_wxWindows.cmake index f25ae89..782874c 100644 --- a/Modules/Use_wxWindows.cmake +++ b/Modules/Use_wxWindows.cmake @@ -5,9 +5,9 @@ Use_wxWindows ------------- -Deprecated. Use ``find_package(wxWidgets)`` and -``include(${wxWidgets_USE_FILE})`` instead. +.. deprecated:: 2.8.10 + Use ``find_package(wxWidgets)`` and ``include(${wxWidgets_USE_FILE})`` instead. This convenience include finds if wxWindows is installed and set the appropriate libs, incdirs, flags etc. author Jan Woetzel <jw -at- @@ -67,4 +67,3 @@ if(WXWINDOWS_FOUND) else() message(SEND_ERROR "wxWindows not found by Use_wxWindows.cmake") endif() - diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index 0ccb6b2..1f13096 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -5,7 +5,10 @@ WriteBasicConfigVersionFile --------------------------- +.. deprecated:: 3.0 + Use the identical command :command:`write_basic_package_version_file()` + from module :module:`CMakePackageConfigHelpers`. :: @@ -15,8 +18,6 @@ WriteBasicConfigVersionFile ) - -Deprecated, see WRITE_BASIC_PACKAGE_VERSION_FILE(), it is identical. #]=======================================================================] function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index befdadd..2c106b6 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 13) -set(CMake_VERSION_PATCH 20181025) +set(CMake_VERSION_PATCH 20181029) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0e48ca8..27b8599 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -421,7 +421,8 @@ std::string cmComputeLinkInformation::GetRPathLinkString() const return ""; } - // Construct the linker runtime search path. + // Construct the linker runtime search path. These MUST NOT contain tokens + // such as $ORIGIN, see https://sourceware.org/bugzilla/show_bug.cgi?id=16936 return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":"); } @@ -1702,6 +1703,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + // Select whether to use $ORIGIN in RPATHs for artifacts in the build tree. + std::string const& originToken = this->Makefile->GetSafeDefinition( + "CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN"); + std::string targetOutputDir = this->Target->GetDirectory(this->Config); + bool use_relative_build_rpath = + this->Target->GetPropertyAsBool("BUILD_RPATH_USE_ORIGIN") && + !originToken.empty() && !targetOutputDir.empty(); + // Construct the RPATH. std::set<std::string> emitted; if (use_install_rpath) { @@ -1711,6 +1720,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, if (use_build_rpath) { // Add directories explicitly specified by user if (const char* build_rpath = this->Target->GetProperty("BUILD_RPATH")) { + // This will not resolve entries to use $ORIGIN, the user is expected to + // do that if necessary. cmCLI_ExpandListUnique(build_rpath, runtimeDirs, emitted); } } @@ -1728,6 +1739,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); + std::string const& topBinaryDir = + this->CMakeInstance->GetHomeOutputDirectory(); for (std::string const& ri : rdirs) { // Put this directory in the rpath if using build-tree rpath // support or if using the link path as an rpath. @@ -1741,6 +1754,18 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, d += "/"; d += suffix; cmSystemTools::ConvertToUnixSlashes(d); + } else if (use_relative_build_rpath) { + // If expansion of the $ORIGIN token is supported and permitted per + // policy, use relative paths in the RPATH. + if (cmSystemTools::ComparePath(d, topBinaryDir) || + cmSystemTools::IsSubDirectory(d, topBinaryDir)) { + d = cmSystemTools::RelativePath(targetOutputDir, d); + if (!d.empty()) { + d = originToken + "/" + d; + } else { + d = originToken; + } + } } if (emitted.insert(d).second) { runtimeDirs.push_back(std::move(d)); @@ -1749,8 +1774,6 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // Do not add any path inside the source or build tree. std::string const& topSourceDir = this->CMakeInstance->GetHomeDirectory(); - std::string const& topBinaryDir = - this->CMakeInstance->GetHomeOutputDirectory(); if (!cmSystemTools::ComparePath(ri, topSourceDir) && !cmSystemTools::ComparePath(ri, topBinaryDir) && !cmSystemTools::IsSubDirectory(ri, topSourceDir) && diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1458f01..987bdb3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -218,6 +218,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", nullptr); this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", nullptr); this->SetPropertyDefault("BUILD_RPATH", nullptr); + this->SetPropertyDefault("BUILD_RPATH_USE_ORIGIN", nullptr); this->SetPropertyDefault("INSTALL_NAME_DIR", nullptr); this->SetPropertyDefault("INSTALL_RPATH", ""); this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); diff --git a/Tests/RunCMake/RuntimePath/Relative.cmake b/Tests/RunCMake/RuntimePath/Relative.cmake new file mode 100644 index 0000000..203241f --- /dev/null +++ b/Tests/RunCMake/RuntimePath/Relative.cmake @@ -0,0 +1,69 @@ +enable_language(C) + +if(NOT CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN) + if(CMAKE_C_PLATFORM_ID STREQUAL "Linux") + # Sanity check for platform that is definitely known to support $ORIGIN. + message(FATAL_ERROR "Platform fails to report relative RPATH support") + else() + message(STATUS "Platform does not support relative RPATHs, skipping") + endif() + return() +endif() +set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) + +function(CheckRpath target rpath) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -Dfile=$<TARGET_FILE:${target}> -Drpath=${rpath} + -P "${CMAKE_CURRENT_SOURCE_DIR}/RelativeCheck.cmake" + VERBATIM + ) +endfunction() + +if(CMAKE_C_COMPILER_ID STREQUAL "XL" AND CMAKE_BINARY_DIR MATCHES " ") + # XL 16.1.0.0 fails building the library if the output path contains a space. + set(externDir) + message(STATUS "Skipping external library test because of a toolchain bug") +else() + get_filename_component(externDir "${CMAKE_BINARY_DIR}" DIRECTORY) + set(externDir "${externDir}/Relative-extern") +endif() + +add_library(utils SHARED A.c) +add_library(utils-sub SHARED A.c) +set_property(TARGET utils-sub PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs) +if(externDir) + add_library(utils-extern SHARED A.c) + set_property(TARGET utils-extern PROPERTY LIBRARY_OUTPUT_DIRECTORY ${externDir}) +endif() + +add_executable(main main.c) +target_link_libraries(main utils) +CheckRpath(main "\$ORIGIN") + +add_executable(main-norel main.c) +target_link_libraries(main-norel utils) +set_property(TARGET main-norel PROPERTY BUILD_RPATH_USE_ORIGIN OFF) +CheckRpath(main-norel "${CMAKE_CURRENT_BINARY_DIR}") + +add_executable(mainsub main.c) +target_link_libraries(mainsub utils) +set_property(TARGET mainsub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +CheckRpath(mainsub "\$ORIGIN/../") + +add_executable(main-sub main.c) +target_link_libraries(main-sub utils-sub) +CheckRpath(main-sub "\$ORIGIN/libs") + +add_executable(mainsub-sub main.c) +target_link_libraries(mainsub-sub utils-sub) +set_property(TARGET mainsub-sub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +CheckRpath(mainsub-sub "\$ORIGIN/../libs") + +if(externDir) + # Binaries linking to libraries outside the build tree should have an absolute RPATH. + add_executable(main-extern main.c) + target_link_libraries(main-extern utils-extern) + CheckRpath(main-extern "${externDir}") +endif() diff --git a/Tests/RunCMake/RuntimePath/RelativeCheck.cmake b/Tests/RunCMake/RuntimePath/RelativeCheck.cmake new file mode 100644 index 0000000..9ee403f --- /dev/null +++ b/Tests/RunCMake/RuntimePath/RelativeCheck.cmake @@ -0,0 +1,4 @@ +file(RPATH_CHECK FILE "${file}" RPATH "${rpath}") +if(NOT EXISTS "${file}") + message(FATAL_ERROR "RPATH for ${file} did not contain the expected value") +endif() diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake index 3f238f2..6f1baa1 100644 --- a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake +++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake @@ -16,3 +16,17 @@ function(run_SymlinkImplicit) ${CMAKE_COMMAND} -Ddir=${RunCMake_TEST_BINARY_DIR} -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake) endfunction() run_SymlinkImplicit() + +function(run_Relative) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Relative-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(Relative) + run_cmake_command(Relative-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() +run_Relative() diff --git a/Tests/RunCMake/RuntimePath/main.c b/Tests/RunCMake/RuntimePath/main.c index 8488f4e..181cd09 100644 --- a/Tests/RunCMake/RuntimePath/main.c +++ b/Tests/RunCMake/RuntimePath/main.c @@ -1,4 +1,6 @@ +extern int libA(void); + int main(void) { - return 0; + return libA(); } |