This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, master has been updated via 66efdbd21a46b63572f5de677ed126a68e524e7a (commit) via 0064edf4173fad72749da2c66753387e9a671223 (commit) via ac0411f1662f64fe1320e22e5a8906b8a40d6677 (commit) via 7063ed271e5343adafa485e82614f844a8e31d24 (commit) via 359e2d401d72f36eb297d0aa52ff255fdaef2af7 (commit) via b5bf369ec68a60bf71297e941bcc742904aae148 (commit) via 4e2ce0a67ae3c4355c696b018da28e23853f991f (commit) via dfa24355eacbf99cf98bbf4027b8188c13ac7154 (commit) via 338994d65d35e08e5ac4c71eee662c1b38aee53a (commit) via c11f089d7381747d9e2eac88c00621e2ec32e4b7 (commit) via 012d599e26392312266e96d5ff6d0b905e7e2647 (commit) via 890a1b9dc34820b73f77221f68e04cf1ae811234 (commit) via 7b23001f20440d6c631d9fd6df4ec0092efce4f5 (commit) via d745df4b01f860c16fd65494a9735d1c73cfde04 (commit) via 124ec11720ba116fcec73c2397b43fb040d8b173 (commit) via 43640fc80aaff645ba0d2897667cd2b4a85add03 (commit) via 7c8c18b1e61ca717941214c2365ce5c5056bad14 (commit) via 9f76961de87d8911d13867d469c38087e47a0b60 (commit) from 6faa69047fc393219ec56627e15ebce039c45171 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=66efdbd21a46b63572f5de677ed126a68e524e7a commit 66efdbd21a46b63572f5de677ed126a68e524e7a Merge: 0064edf b5bf369 Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed May 15 13:21:59 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Wed May 15 09:22:18 2019 -0400 Merge topic 'additional_clean_files' b5bf369ec6 Release notes: Add release notes for ADDITIONAL_CLEAN_FILES properties 4e2ce0a67a Doc: Update and deprecate ADDITIONAL_MAKE_CLEAN_FILES directory property 338994d65d Doc: Add documentation for ADDITIONAL_CLEAN_FILES properties c11f089d73 Tests: Extend MakeClean test to cover ADDITIONAL_CLEAN_FILES 012d599e26 Ninja: Add support for ADDITIONAL_CLEAN_FILES target property 890a1b9dc3 Ninja: Add support for ADDITIONAL_CLEAN_FILES directory property 7b23001f20 Ninja: Add support for additional clean files d745df4b01 Makefiles: Add support for ADDITIONAL_CLEAN_FILES target property ... Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3318 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0064edf4173fad72749da2c66753387e9a671223 commit 0064edf4173fad72749da2c66753387e9a671223 Merge: ac0411f 9f76961 Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed May 15 13:20:24 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Wed May 15 09:21:08 2019 -0400 Merge topic 'ninja-pool-custom-command' 9f76961de8 Support job pools in custom commands and targets Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3308 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac0411f1662f64fe1320e22e5a8906b8a40d6677 commit ac0411f1662f64fe1320e22e5a8906b8a40d6677 Merge: 7063ed2 dfa2435 Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed May 15 13:19:27 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Wed May 15 09:19:43 2019 -0400 Merge topic 'cmuvprocesschain-iterator-fix' dfa24355ea cmUVProcessChain: Add assert() for static analysis tools Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3322 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7063ed271e5343adafa485e82614f844a8e31d24 commit 7063ed271e5343adafa485e82614f844a8e31d24 Merge: 6faa690 359e2d4 Author: Craig Scott <craig.sc...@crascit.com> AuthorDate: Wed May 15 13:18:28 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Wed May 15 09:18:40 2019 -0400 Merge topic 'refactor_docs_use_java' 359e2d401d UseJava: Refactor documentation for better formatting Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3303 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=359e2d401d72f36eb297d0aa52ff255fdaef2af7 commit 359e2d401d72f36eb297d0aa52ff255fdaef2af7 Author: Robert Maynard <robert.mayn...@kitware.com> AuthorDate: Fri May 10 10:24:16 2019 -0400 Commit: Craig Scott <craig.sc...@crascit.com> CommitDate: Wed May 15 22:54:15 2019 +1000 UseJava: Refactor documentation for better formatting Co-Authored-By: Craig Scott <craig.sc...@crascit.com> diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 5600b4c..b0315b2 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -8,289 +8,234 @@ UseJava Use Module for Java This file provides functions for Java. It is assumed that -FindJava.cmake has already been loaded. See FindJava.cmake for +:module:`FindJava` has already been loaded. See :module:`FindJava` for information on how to load Java into your CMake project. -:: +Creating And Installing JARs +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: cmake + + add_jar(<target_name> + [SOURCES] <source1> [<source2>...] [<resource1>...] + [INCLUDE_JARS <jar1> [<jar2>...]] + [ENTRY_POINT <entry>] + [VERSION <version>] + [OUTPUT_NAME <name>] + [OUTPUT_DIR <dir>] + [GENERATE_NATIVE_HEADERS <target> [DESTINATION <dir>]] + ) - add_jar(target_name - [SOURCES] source1 [source2 ...] [resource1 ...] - [INCLUDE_JARS jar1 [jar2 ...]] - [ENTRY_POINT entry] - [VERSION version] - [OUTPUT_NAME name] - [OUTPUT_DIR dir] - [GENERATE_NATIVE_HEADERS target [DESTINATION dir]] - ) - -This command creates a <target_name>.jar. It compiles the given -source files (source) and adds the given resource files (resource) to +This command creates a ``<target_name>.jar``. It compiles the given +``<source>`` files and adds the given ``<resource>`` files to the jar file. Source files can be java files or listing files -(prefixed by '@'). If only resource files are given then just a jar file -is created. The list of include jars are added to the classpath when +(prefixed by ``@``). If only resource files are given then just a jar file +is created. The list of ``INCLUDE_JARS`` are added to the classpath when compiling the java sources and also to the dependencies of the target. -INCLUDE_JARS also accepts other target names created by add_jar. For -backwards compatibility, jar files listed as sources are ignored (as +``INCLUDE_JARS`` also accepts other target names created by ``add_jar()``. +For backwards compatibility, jar files listed as sources are ignored (as they have been since the first version of this module). -The default OUTPUT_DIR can also be changed by setting the variable -CMAKE_JAVA_TARGET_OUTPUT_DIR. +The default ``OUTPUT_DIR`` can also be changed by setting the variable +``CMAKE_JAVA_TARGET_OUTPUT_DIR``. -Optionally, using option GENERATE_NATIVE_HEADERS, native header files can be generated -for methods declared as native. These files provide the connective glue that allow your -Java and C code to interact. An INTERFACE target will be created for an easy usage -of generated files. Sub-option DESTINATION can be used to specify output directory for -generated header files. +Optionally, using option ``GENERATE_NATIVE_HEADERS``, native header files can +be generated for methods declared as native. These files provide the +connective glue that allow your Java and C code to interact. An INTERFACE +target will be created for an easy usage of generated files. Sub-option +``DESTINATION`` can be used to specify the output directory for generated +header files. -GENERATE_NATIVE_HEADERS option requires, at least, version 1.8 of the JDK. +``GENERATE_NATIVE_HEADERS`` option requires, at least, version 1.8 of the JDK. -Additional instructions: +The ``add_jar()`` function sets the following target properties on +``<target_name>``: -:: - - To add compile flags to the target you can set these flags with - the following variable: +``INSTALL_FILES`` + The files which should be installed. This is used by ``install_jar()``. +``JNI_SYMLINK`` + The JNI symlink which should be installed. This is used by + ``install_jni_symlink()``. +``JAR_FILE`` + The location of the jar file so that you can include it. +``CLASSDIR`` + The directory where the class files can be found. For example to use them + with ``javah``. +.. code-block:: cmake + install_jar(<target_name> <destination>) + install_jar(<target_name> DESTINATION <destination> [COMPONENT <component>]) -:: - - set(CMAKE_JAVA_COMPILE_FLAGS -nowarn) +This command installs the ``<target_name>`` files to the given +``<destination>``. It should be called in the same scope as ``add_jar()`` or +it will fail. +The ``install_jar()`` function sets the ``INSTALL_DESTINATION`` target +property on jars so installed. This property holds the ``<destination>`` as +described above, and is used by ``install_jar_exports()``. You can get this +information with :command:`get_property` and the ``INSTALL_DESTINATION`` +property key. +.. code-block:: cmake -:: - - To add a path or a jar file to the class path you can do this - with the CMAKE_JAVA_INCLUDE_PATH variable. - - - -:: - - set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar) - - - -:: - - To use a different output name for the target you can set it with: - - - -:: - - add_jar(foobar foobar.java OUTPUT_NAME shibboleet.jar) - - - -:: + install_jni_symlink(<target_name> <destination>) + install_jni_symlink(<target_name> DESTINATION <destination> [COMPONENT <component>]) - To use a different output directory than CMAKE_CURRENT_BINARY_DIR - you can set it with: +This command installs the ``<target_name>`` JNI symlinks to the given +``<destination>``. It should be called in the same scope as ``add_jar()`` or +it will fail. +.. code-block:: cmake + install_jar_exports(TARGETS <jars>... + [NAMESPACE <namespace>] + FILE <filename> + DESTINATION <destination> [COMPONENT <component>]) -:: - - add_jar(foobar foobar.java OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin) - - - -:: - - To define an entry point in your jar you can set it with the ENTRY_POINT - named argument: - - - -:: - - add_jar(example ENTRY_POINT com/examples/MyProject/Main) - - - -:: - - To define a custom manifest for the jar, you can set it with the manifest - named argument: - - - -:: - - add_jar(example MANIFEST /path/to/manifest) - - - -:: - - To add a VERSION to the target output name you can set it using - the VERSION named argument to add_jar. This will create a jar file with the - name shibboleet-1.0.0.jar and will create a symlink shibboleet.jar - pointing to the jar with the version information. +This command installs a target export file ``<filename>`` for the named jar +targets to the given ``<destination>`` directory. Its function is similar to +that of :command:`install(EXPORTS)`. +.. code-block:: cmake + export_jars(TARGETS <jars>... + [NAMESPACE <namespace>] + FILE <filename>) -:: +This command writes a target export file ``<filename>`` for the named ``<jars>`` +targets. Its function is similar to that of :command:`export`. - add_jar(shibboleet shibbotleet.java VERSION 1.2.0) +Examples +"""""""" +To add compile flags to the target you can set these flags with the following +variable: -:: +.. code-block:: cmake - If the target is a JNI library, utilize the following commands to - create a JNI symbolic link: + set(CMAKE_JAVA_COMPILE_FLAGS -nowarn) +To add a path or a jar file to the class path you can do this with the +``CMAKE_JAVA_INCLUDE_PATH`` variable. -:: +.. code-block:: cmake - set(CMAKE_JNI_TARGET TRUE) - add_jar(shibboleet shibbotleet.java VERSION 1.2.0) - install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet) - install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR}) + set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar) +To use a different output name for the target you can set it with: +.. code-block:: cmake -:: + add_jar(foobar foobar.java OUTPUT_NAME shibboleet.jar) - If a single target needs to produce more than one jar from its - java source code, to prevent the accumulation of duplicate class - files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior - to calling the add_jar() function: +To use a different output directory than ``CMAKE_CURRENT_BINARY_DIR`` you can +set it with: +.. code-block:: cmake + add_jar(foobar foobar.java OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin) -:: +To define an entry point in your jar you can set it with the ``ENTRY_POINT`` +named argument: - set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo) - add_jar(foo foo.java) +.. code-block:: cmake + add_jar(example ENTRY_POINT com/examples/MyProject/Main) +To define a custom manifest for the jar, you can set it with the ``MANIFEST`` +named argument: -:: +.. code-block:: cmake - set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar) - add_jar(bar bar.java) + add_jar(example MANIFEST /path/to/manifest) +To add a version to the target output name you can set it using the ``VERSION`` +named argument to ``add_jar()``. The following example will create a jar file +with the name ``shibboleet-1.0.0.jar`` and will create a symlink +``shibboleet.jar`` pointing to the jar with the version information. +.. code-block:: cmake -:: + add_jar(shibboleet shibbotleet.java VERSION 1.2.0) - For an optimum usage of option GENERATE_NATIVE_HEADERS, it is recommended to - include module JNI before any call to add_jar. The produced target for native - headers can then be used to compile C/C++ sources with command - target_link_libraries. +If the target is a JNI library, utilize the following commands to +create a JNI symbolic link: +.. code-block:: cmake -:: + set(CMAKE_JNI_TARGET TRUE) + add_jar(shibboleet shibbotleet.java VERSION 1.2.0) + install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet) + install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR}) - find_package(JNI) - add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native) - add_library(bar bar.cpp) - target_link_libraries(bar PRIVATE foo-native) +If a single target needs to produce more than one jar from its +java source code, to prevent the accumulation of duplicate class +files in subsequent jars, set/reset ``CMAKE_JAR_CLASSES_PREFIX`` prior +to calling the ``add_jar()`` function: +.. code-block:: cmake -Target Properties: + set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo) + add_jar(foo foo.java) -:: + set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar) + add_jar(bar bar.java) - The add_jar() function sets some target properties. You can get these - properties with the - get_property(TARGET <target_name> PROPERTY <propery_name>) - command. +For an optimum usage of option ``GENERATE_NATIVE_HEADERS``, it is recommended to +include module JNI before any call to ``add_jar()``. The produced target for +native headers can then be used to compile C/C++ sources with the +:command:`target_link_libraries` command. +.. code-block:: cmake + find_package(JNI) + add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native) + add_library(bar bar.cpp) + target_link_libraries(bar PRIVATE foo-native) -:: - INSTALL_FILES The files which should be installed. This is used by - install_jar(). - JNI_SYMLINK The JNI symlink which should be installed. - This is used by install_jni_symlink(). - JAR_FILE The location of the jar file so that you can include - it. - CLASSDIR The directory where the class files can be found. For - example to use them with javah. +Finding JARs +^^^^^^^^^^^^ -:: +.. code-block:: cmake - find_jar(<VAR> - name | NAMES name1 [name2 ...] - [PATHS path1 [path2 ... ENV var]] - [VERSIONS version1 [version2]] - [DOC "cache documentation string"] + find_jar(<VAR> + <name> | NAMES <name1> [<name2>...] + [PATHS <path1> [<path2>... ENV <var>]] + [VERSIONS <version1> [<version2>]] + [DOC "cache documentation string"] ) This command is used to find a full path to the named jar. A cache -entry named by <VAR> is created to stor the result of this command. +entry named by ``<VAR>`` is created to store the result of this command. If the full path to a jar is found the result is stored in the variable and the search will not repeated unless the variable is -cleared. If nothing is found, the result will be <VAR>-NOTFOUND, and -the search will be attempted again next time find_jar is invoked with +cleared. If nothing is found, the result will be ``<VAR>-NOTFOUND``, and +the search will be attempted again next time ``find_jar()`` is invoked with the same variable. The name of the full path to a file that is -searched for is specified by the names listed after NAMES argument. -Additional search locations can be specified after the PATHS argument. +searched for is specified by the names listed after ``NAMES`` argument. +Additional search locations can be specified after the ``PATHS`` argument. If you require special a version of a jar file you can specify it with -the VERSIONS argument. The argument after DOC will be used for the +the ``VERSIONS`` argument. The argument after ``DOC`` will be used for the documentation string in the cache. -:: - - install_jar(target_name destination) - install_jar(target_name DESTINATION destination [COMPONENT component]) - -This command installs the TARGET_NAME files to the given DESTINATION. -It should be called in the same scope as add_jar() or it will fail. - -Target Properties: - -:: - - The install_jar() function sets the INSTALL_DESTINATION target property - on jars so installed. This property holds the DESTINATION as described - above, and is used by install_jar_exports(). You can get this property - with the - get_property(TARGET <target_name> PROPERTY INSTALL_DESTINATION) - command. +Javadoc +^^^^^^^ +The ``create_javadoc()`` command can be used to create java documentation +based on files or packages. For more details please read the javadoc manpage. -:: - - install_jni_symlink(target_name destination) - install_jni_symlink(target_name DESTINATION destination [COMPONENT component]) +There are two main signatures for ``create_javadoc()``. The first signature +works with package names on a path with source files. -This command installs the TARGET_NAME JNI symlinks to the given -DESTINATION. It should be called in the same scope as add_jar() or it -will fail. - -:: - - install_jar_exports(TARGETS jars... - [NAMESPACE <namespace>] - FILE <filename> - DESTINATION <dir> [COMPONENT <component>]) - -This command installs a target export file ``<filename>`` for the named jar -targets to the given ``DESTINATION``. Its function is similar to that of -:command:`install(EXPORTS ...)`. - -:: - - export_jars(TARGETS jars... - [NAMESPACE <namespace>] - FILE <filename>) - -This command writes a target export file ``<filename>`` for the named jar -targets. Its function is similar to that of :command:`export(...)`. - -:: +.. code-block:: cmake create_javadoc(<VAR> - PACKAGES pkg1 [pkg2 ...] + PACKAGES <pkg1> [<pkg2>...] [SOURCEPATH <sourcepath>] [CLASSPATH <classpath>] [INSTALLPATH <install path>] @@ -301,80 +246,70 @@ targets. Its function is similar to that of :command:`export(...)`. [VERSION TRUE|FALSE] ) -Create java documentation based on files or packages. For more -details please read the javadoc manpage. - -There are two main signatures for create_javadoc. The first signature -works with package names on a path with source files: - -:: - - Example: - create_javadoc(my_example_doc - PACKAGES com.example.foo com.example.bar - SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}" - CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} - WINDOWTITLE "My example" - DOCTITLE "<h1>My example</h1>" - AUTHOR TRUE - USE TRUE - VERSION TRUE - ) +For example: +.. code-block:: cmake + create_javadoc(my_example_doc + PACKAGES com.example.foo com.example.bar + SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}" + CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} + WINDOWTITLE "My example" + DOCTITLE "<h1>My example</h1>" + AUTHOR TRUE + USE TRUE + VERSION TRUE + ) -The second signature for create_javadoc works on a given list of +The second signature for ``create_javadoc()`` works on a given list of files. -:: - - create_javadoc(<VAR> - FILES file1 [file2 ...] - [CLASSPATH <classpath>] - [INSTALLPATH <install path>] - [DOCTITLE "the documentation title"] - [WINDOWTITLE "the title of the document"] - [AUTHOR TRUE|FALSE] - [USE TRUE|FALSE] - [VERSION TRUE|FALSE] - ) - - - -Example: - -:: +.. code-block:: cmake + + create_javadoc(<VAR> + FILES <file1> [<file2>...] + [CLASSPATH <classpath>] + [INSTALLPATH <install path>] + [DOCTITLE "the documentation title"] + [WINDOWTITLE "the title of the document"] + [AUTHOR TRUE|FALSE] + [USE TRUE|FALSE] + [VERSION TRUE|FALSE] + ) - create_javadoc(my_example_doc - FILES ${example_SRCS} - CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} - WINDOWTITLE "My example" - DOCTITLE "<h1>My example</h1>" - AUTHOR TRUE - USE TRUE - VERSION TRUE - ) +For example: +.. code-block:: cmake + create_javadoc(my_example_doc + FILES ${example_SRCS} + CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} + WINDOWTITLE "My example" + DOCTITLE "<h1>My example</h1>" + AUTHOR TRUE + USE TRUE + VERSION TRUE + ) Both signatures share most of the options. These options are the same as what you can find in the javadoc manpage. Please look at the -manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and VERSION. +manpage for ``CLASSPATH``, ``DOCTITLE``, ``WINDOWTITLE``, ``AUTHOR``, ``USE`` +and ``VERSION``. -The documentation will be by default installed to +If you don't set the ``INSTALLPATH``, then by default the documentation will +be installed to : :: ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR> +Header Generation +^^^^^^^^^^^^^^^^^ -if you don't set the INSTALLPATH. - -:: +.. code-block:: cmake - create_javah(TARGET <target> - GENERATED_FILES <VAR> + create_javah(TARGET <target> | GENERATED_FILES <VAR> CLASSES <class>... [CLASSPATH <classpath>...] [DEPENDS <depend>...] @@ -384,55 +319,55 @@ if you don't set the INSTALLPATH. Create C header files from java classes. These files provide the connective glue that allow your Java and C code to interact. -This command will no longer be supported starting with version 10 of the JDK due -to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_. -Command ``add_jar(GENERATE_NATIVE_HEADERS)`` must be used instead. +.. deprecated:: 3.11 -There are two main signatures for create_javah. The first signature -returns generated files through variable specified by GENERATED_FILES option: +.. note:: -:: + This command will no longer be supported starting with version 10 of the JDK + due to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_. + The ``add_jar(GENERATE_NATIVE_HEADERS)`` command should be used instead. - Example: - Create_javah(GENERATED_FILES files_headers - CLASSES org.cmake.HelloWorld - CLASSPATH hello.jar - ) +There are two main signatures for ``create_javah()``. The first signature +returns generated files through variable specified by the ``GENERATED_FILES`` +option. For example: +.. code-block:: cmake + create_javah(GENERATED_FILES files_headers + CLASSES org.cmake.HelloWorld + CLASSPATH hello.jar + ) -The second signature for create_javah creates a target which encapsulates -header files generation. - -:: - - Example: - Create_javah(TARGET target_headers - CLASSES org.cmake.HelloWorld - CLASSPATH hello.jar - ) +The second signature for ``create_javah()`` creates a target which encapsulates +header files generation. E.g. +.. code-block:: cmake + create_javah(TARGET target_headers + CLASSES org.cmake.HelloWorld + CLASSPATH hello.jar + ) Both signatures share same options. - ``CLASSES <class>...`` - Specifies Java classes used to generate headers. +``CLASSES <class>...`` + Specifies Java classes used to generate headers. - ``CLASSPATH <classpath>...`` - Specifies various paths to look up classes. Here .class files, jar files or targets - created by command add_jar can be used. +``CLASSPATH <classpath>...`` + Specifies various paths to look up classes. Here .class files, jar files or + targets created by command add_jar can be used. - ``DEPENDS <depend>...`` - Targets on which the javah target depends +``DEPENDS <depend>...`` + Targets on which the javah target depends. - ``OUTPUT_NAME <path>`` - Concatenates the resulting header files for all the classes listed by option CLASSES - into <path>. Same behavior as option '-o' of javah tool. +``OUTPUT_NAME <path>`` + Concatenates the resulting header files for all the classes listed by option + ``CLASSES`` into ``<path>``. Same behavior as option ``-o`` of javah tool. - ``OUTPUT_DIR <path>`` - Sets the directory where the header files will be generated. Same behavior as option - '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. +``OUTPUT_DIR <path>`` + Sets the directory where the header files will be generated. Same behavior + as option ``-d`` of javah tool. If not specified, + :variable:`CMAKE_CURRENT_BINARY_DIR` is used as the output directory. #]=======================================================================] function (__java_copy_file src dest comment) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5bf369ec68a60bf71297e941bcc742904aae148 commit b5bf369ec68a60bf71297e941bcc742904aae148 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Tue May 14 12:22:21 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 21:32:12 2019 +0200 Release notes: Add release notes for ADDITIONAL_CLEAN_FILES properties This adds release notes for the `ADDITIONAL_CLEAN_FILES` target and directory properties. It also adds a deprecation release note for the `ADDITIONAL_MAKE_CLEAN_FILES` directory property. diff --git a/Help/release/dev/additional_clean_files.rst b/Help/release/dev/additional_clean_files.rst new file mode 100644 index 0000000..9b56642 --- /dev/null +++ b/Help/release/dev/additional_clean_files.rst @@ -0,0 +1,10 @@ +additional_clean_files +---------------------- + +* New target property :prop_tgt:`ADDITIONAL_CLEAN_FILES` and directory property + :prop_dir:`ADDITIONAL_CLEAN_FILES` were added. They allow to register + additional files that should be removed during the clean stage. + +* Directory property :prop_dir:`ADDITIONAL_MAKE_CLEAN_FILES` was marked + deprecated. The new directory property :prop_dir:`ADDITIONAL_CLEAN_FILES` + should be used instead. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4e2ce0a67ae3c4355c696b018da28e23853f991f commit 4e2ce0a67ae3c4355c696b018da28e23853f991f Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Tue May 14 12:00:15 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 21:32:12 2019 +0200 Doc: Update and deprecate ADDITIONAL_MAKE_CLEAN_FILES directory property This extends the :prop_dir:`ADDITIONAL_MAKE_CLEAN_FILES` directory property documentation and marks it as deprecated. The new directory property :prop_dir:`ADDITIONAL_CLEAN_FILES` should be used instead. diff --git a/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst b/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst index 986ea5b..893a298 100644 --- a/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst +++ b/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst @@ -1,7 +1,17 @@ ADDITIONAL_MAKE_CLEAN_FILES --------------------------- -Additional files to clean during the make clean stage. +.. deprecated:: 3.15 -A list of files that will be cleaned as a part of the ``make clean`` -stage. + Use :prop_dir:`ADDITIONAL_CLEAN_FILES` instead. + +Additional files to remove during the clean stage. + +A :ref:`;-list <CMake Language Lists>` of files that will be removed as a +part of the ``make clean`` target. + +Arguments to :prop_dir:`ADDITIONAL_MAKE_CLEAN_FILES` may use +:manual:`generator expressions <cmake-generator-expressions(7)>`. + +This property only works for the the Makefile generators. +It is ignored on other generators. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dfa24355eacbf99cf98bbf4027b8188c13ac7154 commit dfa24355eacbf99cf98bbf4027b8188c13ac7154 Author: Kyle Edwards <kyle.edwa...@kitware.com> AuthorDate: Tue May 14 12:23:41 2019 -0400 Commit: Kyle Edwards <kyle.edwa...@kitware.com> CommitDate: Tue May 14 14:00:13 2019 -0400 cmUVProcessChain: Add assert() for static analysis tools Some static analysis tools throw a false positive for an out-of-bounds item that is being dereferenced. This out-of-bounds error will never actually happen because of how cmUVProcessChain::InternalData::AddCommand() is being called. Nevertheless, this change adds an assert() to help static analysis tools be absolutely certain that the referenced item is within the vector's bounds. This change also changes the item access to use an index rather than an iterator. diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index c4e30d4..90ece0b 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -8,6 +8,8 @@ #include "cmUVStreambuf.h" #include "cm_uv.h" +#include <assert.h> + #include <iterator> #include <memory> #include <utility> @@ -250,7 +252,8 @@ bool cmUVProcessChain::InternalData::AddCommand( if (first) { stdio[0].flags = UV_IGNORE; } else { - auto& prev = **std::prev(this->Processes.end(), 2); + assert(this->Processes.size() >= 2); + auto& prev = *this->Processes[this->Processes.size() - 2]; stdio[0].flags = UV_INHERIT_STREAM; stdio[0].data.stream = prev.OutputPipe; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=338994d65d35e08e5ac4c71eee662c1b38aee53a commit 338994d65d35e08e5ac4c71eee662c1b38aee53a Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Tue May 14 11:51:52 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Doc: Add documentation for ADDITIONAL_CLEAN_FILES properties diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index c11496c..28c2883 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -61,6 +61,7 @@ Properties on Directories .. toctree:: :maxdepth: 1 + /prop_dir/ADDITIONAL_CLEAN_FILES /prop_dir/ADDITIONAL_MAKE_CLEAN_FILES /prop_dir/BINARY_DIR /prop_dir/BUILDSYSTEM_TARGETS @@ -102,6 +103,7 @@ Properties on Targets .. toctree:: :maxdepth: 1 + /prop_tgt/ADDITIONAL_CLEAN_FILES /prop_tgt/ALIASED_TARGET /prop_tgt/ANDROID_ANT_ADDITIONAL_OPTIONS /prop_tgt/ANDROID_API diff --git a/Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst b/Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst new file mode 100644 index 0000000..54a78ef --- /dev/null +++ b/Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst @@ -0,0 +1,16 @@ +ADDITIONAL_CLEAN_FILES +---------------------- + +Additional files to remove during the clean stage. + +A :ref:`;-list <CMake Language Lists>` of files that will be removed as a +part of the ``clean`` target. + +Relative paths are allowed and are interpreted relative to the +current binary directory. + +Arguments to :prop_dir:`ADDITIONAL_CLEAN_FILES` may use +:manual:`generator expressions <cmake-generator-expressions(7)>`. + +This property only works for the :generator:`Ninja` and the Makefile +generators. It is ignored on other generators. diff --git a/Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst b/Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst new file mode 100644 index 0000000..856bb38 --- /dev/null +++ b/Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst @@ -0,0 +1,16 @@ +ADDITIONAL_CLEAN_FILES +---------------------- + +Additional files to remove during the clean stage. + +A :ref:`;-list <CMake Language Lists>` of files that will be removed as a +part of the ``clean`` target. + +Relative paths are allowed and are interpreted relative to the +current binary directory. + +Arguments to :prop_tgt:`ADDITIONAL_CLEAN_FILES` may use +:manual:`generator expressions <cmake-generator-expressions(7)>`. + +This property only works for the :generator:`Ninja` and the Makefile +generators. It is ignored on other generators. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c11f089d7381747d9e2eac88c00621e2ec32e4b7 commit c11f089d7381747d9e2eac88c00621e2ec32e4b7 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Sat May 11 12:55:58 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Tests: Extend MakeClean test to cover ADDITIONAL_CLEAN_FILES This extends the MakeClean test to cover the - ADDITIONAL_CLEAN_FILES directory property and the - ADDITIONAL_CLEAN_FILES target property as well. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index bc4812b..d992986 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2007,7 +2007,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) - if("${CMAKE_GENERATOR}" MATCHES "Makefile") + if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR + "${CMAKE_GENERATOR}" MATCHES "Ninja") add_test(MakeClean ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MakeClean" diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt index d0e24ce..5d84e6c 100644 --- a/Tests/MakeClean/ToClean/CMakeLists.txt +++ b/Tests/MakeClean/ToClean/CMakeLists.txt @@ -1,42 +1,98 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.14) project(ToClean) -# Build a simple project. -add_executable(toclean toclean.cxx) +# Utility variables +set(TSD ${ToClean_SOURCE_DIR}) +set(TBD ${ToClean_BINARY_DIR}) +set(CLEAN_FILE_CONTENT "File registered for cleaning.\n") -# List some build-time-generated files. -set(TOCLEAN_FILES ${TOCLEAN_FILES} - "${ToClean_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") +# Lists build-time-generated files that should be cleaned away +set(TOCLEAN_FILES) -# Create a file that must be registered for cleaning. -file(WRITE "${ToClean_BINARY_DIR}/Registered.txt" - "File registered for cleaning.\n") -set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${ToClean_BINARY_DIR}/Registered.txt") -set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/Registered.txt") +# Build a simple project whose compiled objects should be cleaned. +add_executable(toclean toclean.cxx) +list(APPEND TOCLEAN_FILES + "${TBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") # Create a custom command whose output should be cleaned. -add_custom_command(OUTPUT ${ToClean_BINARY_DIR}/generated.txt - DEPENDS ${ToClean_SOURCE_DIR}/toclean.cxx +set(CustomCommandFile "${TBD}/CustomCommandFile.txt") +add_custom_command(OUTPUT ${CustomCommandFile} + DEPENDS ${TSD}/toclean.cxx COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${ToClean_SOURCE_DIR}/toclean.cxx - ${ToClean_BINARY_DIR}/generated.txt - ) -add_custom_target(generate ALL DEPENDS ${ToClean_BINARY_DIR}/generated.txt) -set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/generated.txt") + ARGS -E copy ${TSD}/toclean.cxx ${CustomCommandFile}) +add_custom_target(generate ALL DEPENDS ${CustomCommandFile}) +list(APPEND TOCLEAN_FILES ${CustomCommandFile}) + + +### Tests ADDITIONAL_MAKE_CLEAN_FILES directory property +if("${CMAKE_GENERATOR}" MATCHES "Makefile") + # Create a file that must be registered for cleaning. + set(MakeDirPropFile "${TBD}/MakeDirPropFile.txt") + file(WRITE "${MakeDirPropFile}" ${CLEAN_FILE_CONTENT}) + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MakeDirPropFile}") + list(APPEND TOCLEAN_FILES "${MakeDirPropFile}") + + # Create a custom command whose output should be cleaned, but whose name + # is not known until generate-time + set(MakeDirPropExpFileRel "MakeDirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") + set(MakeDirPropExpFile "$<TARGET_FILE_DIR:toclean>/${MakeDirPropExpFileRel}") + add_custom_command(TARGET toclean POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy $<TARGET_FILE:toclean> ${MakeDirPropExpFile}) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MakeDirPropExpFile}) + list(APPEND TOCLEAN_FILES "${TBD}/${MakeDirPropExpFileRel}") +endif() + + +### Tests ADDITIONAL_CLEAN_FILES directory property + +# Register a file path relative to the build directory +set(DirPropFileRel "DirPropFileRel.txt") +file(WRITE "${TBD}/${DirPropFileRel}" ${CLEAN_FILE_CONTENT}) +set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel}) +list(APPEND TOCLEAN_FILES "${TBD}/${DirPropFileRel}") + +# Register an absolute file path +set(DirPropFileAbs "${TBD}/DirPropFileAbs.txt") +file(WRITE "${DirPropFileAbs}" ${CLEAN_FILE_CONTENT}) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs}) +list(APPEND TOCLEAN_FILES "${DirPropFileAbs}") # Create a custom command whose output should be cleaned, but whose name # is not known until generate-time -set(copied_exe "$<TARGET_FILE_DIR:toclean>/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}") +set(DirPropExpFileRel "DirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") +set(DirPropExpFile "$<TARGET_FILE_DIR:toclean>/${DirPropExpFileRel}") add_custom_command(TARGET toclean POST_BUILD COMMAND ${CMAKE_COMMAND} - ARGS -E copy $<TARGET_FILE:toclean> - ${copied_exe} - ) -set_property(DIRECTORY APPEND PROPERTY - ADDITIONAL_MAKE_CLEAN_FILES ${copied_exe}) -list(APPEND TOCLEAN_FILES "${ToClean_BINARY_DIR}/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}") + ARGS -E copy $<TARGET_FILE:toclean> ${DirPropExpFile}) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropExpFile}) +list(APPEND TOCLEAN_FILES "${TBD}/${DirPropExpFileRel}") + + +### Tests ADDITIONAL_CLEAN_FILES target property + +# Register a file path relative to the build directory +set(TgtPropFileRel "TargetPropFileRel.txt") +file(WRITE "${TBD}/${TgtPropFileRel}" ${CLEAN_FILE_CONTENT}) +set_target_properties(toclean PROPERTIES ADDITIONAL_CLEAN_FILES ${TgtPropFileRel}) +list(APPEND TOCLEAN_FILES "${TBD}/${TgtPropFileRel}") + +# Register an absolute file path +set(TgtPropFileAbs "${TBD}/TargetPropFileAbs.txt") +file(WRITE "${TgtPropFileAbs}" ${CLEAN_FILE_CONTENT}) +set_property(TARGET toclean APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropFileAbs}) +list(APPEND TOCLEAN_FILES "${TgtPropFileAbs}") + +# Create a custom command whose output should be cleaned, but whose name +# is not known until generate-time +set(TgtPropExpFileRel "TgtProp_copy${CMAKE_EXECUTABLE_SUFFIX}") +set(TgtPropExpFile "$<TARGET_FILE_DIR:toclean>/${TgtPropExpFileRel}") +add_custom_command(TARGET toclean POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy $<TARGET_FILE:toclean> ${TgtPropExpFile}) +set_property(TARGET toclean APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropExpFile}) +list(APPEND TOCLEAN_FILES "${TBD}/${TgtPropExpFileRel}") + # Configure a file listing these build-time-generated files. -configure_file(${ToClean_SOURCE_DIR}/ToCleanFiles.cmake.in - ${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY) +configure_file(${TSD}/ToCleanFiles.cmake.in ${TBD}/ToCleanFiles.cmake @ONLY) diff --git a/Tests/MakeClean/check_clean.c.in b/Tests/MakeClean/check_clean.c.in index 5bc4ab8..e5a7945 100644 --- a/Tests/MakeClean/check_clean.c.in +++ b/Tests/MakeClean/check_clean.c.in @@ -18,7 +18,7 @@ int main() if(pf) { fclose(pf); - fprintf(stderr, "File \"%s\" exists!", *f); + fprintf(stderr, "File \"%s\" still exists!\n", *f); result = 1; } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=012d599e26392312266e96d5ff6d0b905e7e2647 commit 012d599e26392312266e96d5ff6d0b905e7e2647 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon May 13 17:58:06 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Ninja: Add support for ADDITIONAL_CLEAN_FILES target property diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index ebb7c15..680f881 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -83,6 +83,8 @@ void cmNinjaNormalTargetGenerator::Generate() this->WriteDeviceLinkStatement(); this->WriteLinkStatement(); } + + this->AdditionalCleanFiles(); } void cmNinjaNormalTargetGenerator::WriteLanguagesRules() diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 506711a..8afac70 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1310,6 +1310,31 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine, sourceFileName); } +void cmNinjaTargetGenerator::AdditionalCleanFiles() +{ + if (const char* prop_value = + this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { + cmLocalNinjaGenerator* lg = this->LocalGenerator; + std::vector<std::string> cleanFiles; + { + cmGeneratorExpression ge; + auto cge = ge.Parse(prop_value); + cmSystemTools::ExpandListArgument( + cge->Evaluate(lg, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"), + false, this->GeneratorTarget, nullptr, nullptr), + cleanFiles); + } + std::string const& binaryDir = lg->GetCurrentBinaryDirectory(); + cmGlobalNinjaGenerator* gg = lg->GetGlobalNinjaGenerator(); + for (std::string const& cleanFile : cleanFiles) { + // Support relative paths + gg->AddAdditionalCleanFile( + cmSystemTools::CollapseFullPath(cleanFile, binaryDir)); + } + } +} + void cmNinjaTargetGenerator::EnsureDirectoryExists( const std::string& path) const { diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 3dbc1b5..235c60c 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -134,6 +134,8 @@ protected: std::string const& objectFileDir, std::string const& flags, std::string const& defines, std::string const& includes); + void AdditionalCleanFiles(); + cmNinjaDeps GetObjects() const { return this->Objects; } void EnsureDirectoryExists(const std::string& dir) const; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=890a1b9dc34820b73f77221f68e04cf1ae811234 commit 890a1b9dc34820b73f77221f68e04cf1ae811234 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon May 13 16:42:46 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Ninja: Add support for ADDITIONAL_CLEAN_FILES directory property diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index e6d4457..7fc5776 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -14,6 +14,7 @@ #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratedFileStream.h" +#include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmGlobalNinjaGenerator.h" @@ -94,6 +95,7 @@ void cmLocalNinjaGenerator::Generate() } this->WriteCustomCommandBuildStatements(); + this->AdditionalCleanFiles(); } // TODO: Picked up from cmLocalUnixMakefileGenerator3. Refactor it. @@ -598,3 +600,26 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( return launcher; } + +void cmLocalNinjaGenerator::AdditionalCleanFiles() +{ + if (const char* prop_value = + this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { + std::vector<std::string> cleanFiles; + { + cmGeneratorExpression ge; + auto cge = ge.Parse(prop_value); + cmSystemTools::ExpandListArgument( + cge->Evaluate(this, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), + cleanFiles); + } + std::string const& binaryDir = this->GetCurrentBinaryDirectory(); + cmGlobalNinjaGenerator* gg = this->GetGlobalNinjaGenerator(); + for (std::string const& cleanFile : cleanFiles) { + // Support relative paths + gg->AddAdditionalCleanFile( + cmSystemTools::CollapseFullPath(cleanFile, binaryDir)); + } + } +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index f772fb0..3a30bbb 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -105,6 +105,8 @@ private: std::string const& customStep, cmGeneratorTarget const* target) const; + void AdditionalCleanFiles(); + std::string HomeRelativeOutputPath; typedef std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*>> https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b23001f20440d6c631d9fd6df4ec0092efce4f5 commit 7b23001f20440d6c631d9fd6df4ec0092efce4f5 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon May 13 16:42:06 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Ninja: Add support for additional clean files Additional clean files for the Ninja generator can be registered via the new method `cmGlobalNinjaGenerator::AddAdditionalCleanFile`. If there are additional clean files, a new rule `CLEAN_ADDITIONAL` and a new build target `CMakeFiles/clean.additional` get generated. The `clean` target will depend on `CMakeFiles/clean.additional`, if the target exists. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 1b973e0..5d4f6db 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -852,6 +852,11 @@ std::string const& cmGlobalNinjaGenerator::ConvertToNinjaPath( .first->second; } +void cmGlobalNinjaGenerator::AddAdditionalCleanFile(std::string fileName) +{ + this->AdditionalCleanFiles.emplace(std::move(fileName)); +} + void cmGlobalNinjaGenerator::AddCXXCompileCommand( const std::string& commandLine, const std::string& sourceFile) { @@ -1464,8 +1469,80 @@ bool cmGlobalNinjaGenerator::SupportsMultilineDepfile() const return this->NinjaSupportsMultilineDepfile; } +bool cmGlobalNinjaGenerator::WriteTargetCleanAdditional(std::ostream& os) +{ + cmLocalGenerator* lgr = this->LocalGenerators.at(0); + std::string cleanScriptRel = "CMakeFiles/clean_additional.cmake"; + std::string cleanScriptAbs = lgr->GetBinaryDirectory(); + cleanScriptAbs += '/'; + cleanScriptAbs += cleanScriptRel; + + // Check if there are additional files to clean + if (this->AdditionalCleanFiles.empty()) { + // Remove cmake clean script file if it exists + cmSystemTools::RemoveFile(cleanScriptAbs); + return false; + } + + // Write cmake clean script file + { + cmGeneratedFileStream fout(cleanScriptAbs); + if (!fout) { + return false; + } + fout << "# Additional clean files\n\n"; + fout << "file(REMOVE_RECURSE\n"; + for (std::string const& acf : this->AdditionalCleanFiles) { + fout << " " + << cmOutputConverter::EscapeForCMake(ConvertToNinjaPath(acf)) + << '\n'; + } + fout << ")\n"; + } + // Register clean script file + lgr->GetMakefile()->AddCMakeOutputFile(cleanScriptAbs); + + // Write rule + { + std::string cmd = CMakeCmd(); + cmd += " -P "; + cmd += lgr->ConvertToOutputFormat(this->NinjaOutputPath(cleanScriptRel), + cmOutputConverter::SHELL); + WriteRule(*this->RulesFileStream, "CLEAN_ADDITIONAL", cmd, + "Cleaning additional files...", + "Rule for cleaning additional files.", + /*depfile=*/"", + /*deptype=*/"", + /*rspfile=*/"", + /*rspcontent*/ "", + /*restat=*/"", + /*generator=*/false); + } + + // Write build + { + cmNinjaDeps outputs; + outputs.emplace_back( + this->NinjaOutputPath(this->GetAdditionalCleanTargetName())); + WriteBuild(os, "Clean additional files.", "CLEAN_ADDITIONAL", + /*outputs=*/outputs, + /*implicitOuts=*/cmNinjaDeps(), + /*explicitDeps=*/cmNinjaDeps(), + /*implicitDeps=*/cmNinjaDeps(), + /*orderOnlyDeps=*/cmNinjaDeps(), + /*variables=*/cmNinjaVars()); + } + // Return success + return true; +} + void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) { + // -- Additional clean target + bool additionalFiles = WriteTargetCleanAdditional(os); + + // -- Default clean target + // Write rule WriteRule(*this->RulesFileStream, "CLEAN", NinjaCmd() + " -t clean", "Cleaning all built files...", "Rule for cleaning all built files.", @@ -1475,13 +1552,24 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) /*rspcontent*/ "", /*restat=*/"", /*generator=*/false); - WriteBuild(os, "Clean all the built files.", "CLEAN", - /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("clean")), - /*implicitOuts=*/cmNinjaDeps(), - /*explicitDeps=*/cmNinjaDeps(), - /*implicitDeps=*/cmNinjaDeps(), - /*orderOnlyDeps=*/cmNinjaDeps(), - /*variables=*/cmNinjaVars()); + + // Write build + { + cmNinjaDeps explicitDeps; + if (additionalFiles) { + explicitDeps.emplace_back( + this->NinjaOutputPath(this->GetAdditionalCleanTargetName())); + } + cmNinjaDeps outputs; + outputs.emplace_back(this->NinjaOutputPath(this->GetCleanTargetName())); + WriteBuild(os, "Clean all the built files.", "CLEAN", + /*outputs=*/outputs, + /*implicitOuts=*/cmNinjaDeps(), + /*explicitDeps=*/explicitDeps, + /*implicitDeps=*/cmNinjaDeps(), + /*orderOnlyDeps=*/cmNinjaDeps(), + /*variables=*/cmNinjaVars()); + } } void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ffcea60..0f90b30 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -257,6 +257,13 @@ public: }; MapToNinjaPathImpl MapToNinjaPath() { return MapToNinjaPathImpl(this); } + // -- Additional clean files + void AddAdditionalCleanFile(std::string fileName); + const char* GetAdditionalCleanTargetName() const + { + return "CMakeFiles/clean.additional"; + } + void AddCXXCompileCommand(const std::string& commandLine, const std::string& sourceFile); @@ -398,6 +405,7 @@ private: void WriteBuiltinTargets(std::ostream& os); void WriteTargetAll(std::ostream& os); void WriteTargetRebuildManifest(std::ostream& os); + bool WriteTargetCleanAdditional(std::ostream& os); void WriteTargetClean(std::ostream& os); void WriteTargetHelp(std::ostream& os); @@ -470,6 +478,7 @@ private: std::string OutputPathPrefix; std::string TargetAll; std::string CMakeCacheFile; + std::set<std::string> AdditionalCleanFiles; }; #endif // ! cmGlobalNinjaGenerator_h https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d745df4b01f860c16fd65494a9735d1c73cfde04 commit d745df4b01f860c16fd65494a9735d1c73cfde04 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon May 13 19:55:33 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Makefiles: Add support for ADDITIONAL_CLEAN_FILES target property diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3f97ad0..a751b24 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -184,6 +184,18 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } + // Look for additional files registered for cleaning in this target. + if (const char* prop_value = + this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { + std::vector<std::string> const files = evaluatedFiles(prop_value); + // For relative path support + std::string const& binaryDir = + this->LocalGenerator->GetCurrentBinaryDirectory(); + for (std::string const& cfl : files) { + this->CleanFiles.insert(cmSystemTools::CollapseFullPath(cfl, binaryDir)); + } + } + // add custom commands to the clean rules? const char* clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM"); bool clean = cmSystemTools::IsOff(clean_no_custom); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=124ec11720ba116fcec73c2397b43fb040d8b173 commit 124ec11720ba116fcec73c2397b43fb040d8b173 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon May 13 19:52:10 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Makefiles: Add support for ADDITIONAL_CLEAN_FILES directory property diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2e945ce..3f97ad0 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -172,6 +172,18 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->CleanFiles.insert(files.begin(), files.end()); } + // Look for additional files registered for cleaning in this directory. + if (const char* prop_value = + this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { + std::vector<std::string> const files = evaluatedFiles(prop_value); + // For relative path support + std::string const& binaryDir = + this->LocalGenerator->GetCurrentBinaryDirectory(); + for (std::string const& cfl : files) { + this->CleanFiles.insert(cmSystemTools::CollapseFullPath(cfl, binaryDir)); + } + } + // add custom commands to the clean rules? const char* clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM"); bool clean = cmSystemTools::IsOff(clean_no_custom); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=43640fc80aaff645ba0d2897667cd2b4a85add03 commit 43640fc80aaff645ba0d2897667cd2b4a85add03 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon May 13 19:43:00 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:14 2019 +0200 Makefiles: Move ADDITIONAL_MAKE_CLEAN_FILES evaluation to lambda diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2ea6682..2e945ce 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -147,23 +147,29 @@ void cmMakefileTargetGenerator::CreateRuleFile() void cmMakefileTargetGenerator::WriteTargetBuildRules() { + // -- Write the custom commands for this target + const std::string& config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - // write the custom commands for this target - // Look for files registered for cleaning in this directory. - if (const char* additional_clean_files = - this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) { + // Evaluates generator expressions and expands prop_value + auto evaluatedFiles = + [this, &config](const char* prop_value) -> std::vector<std::string> { + std::vector<std::string> files; cmGeneratorExpression ge; - std::unique_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(additional_clean_files); - - std::vector<std::string> additionalFiles; + std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop_value); cmSystemTools::ExpandListArgument( cge->Evaluate(this->LocalGenerator, config, false, this->GeneratorTarget, nullptr, nullptr), - additionalFiles); - this->CleanFiles.insert(additionalFiles.begin(), additionalFiles.end()); + files); + return files; + }; + + // Look for additional files registered for cleaning in this directory. + if (const char* prop_value = + this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) { + std::vector<std::string> const files = evaluatedFiles(prop_value); + this->CleanFiles.insert(files.begin(), files.end()); } // add custom commands to the clean rules? https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c8c18b1e61ca717941214c2365ce5c5056bad14 commit 7c8c18b1e61ca717941214c2365ce5c5056bad14 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon May 13 12:54:45 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Tue May 14 17:50:13 2019 +0200 Makefiles: Sort clean files by using a std::set<std::string> container By using a `std::set<std::string>` container instead of a `std::vector<std::string>` container, the clean files list becomes sorted and unique. The clean target in Makefiles beomes nicer and better readable this way. Also double clean entries won't appear anymore. diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index bece12e..88966c8 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1040,7 +1040,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( } void cmLocalUnixMakefileGenerator3::AppendCleanCommand( - std::vector<std::string>& commands, const std::vector<std::string>& files, + std::vector<std::string>& commands, const std::set<std::string>& files, cmGeneratorTarget* target, const char* filename) { std::string currentBinDir = this->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 7a0ea98..fed25e1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -224,7 +224,7 @@ protected: bool echo_comment = false, std::ostream* content = nullptr); void AppendCleanCommand(std::vector<std::string>& commands, - const std::vector<std::string>& files, + const std::set<std::string>& files, cmGeneratorTarget* target, const char* filename = nullptr); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index ebf5fc2..beabf91 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -4,6 +4,7 @@ #include <algorithm> #include <memory> // IWYU pragma: keep +#include <set> #include <sstream> #include <string> #include <utility> @@ -291,8 +292,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( this->WriteTargetDriverRule(targetOutputReal, relink); // Clean all the possible executable names and symlinks. - this->CleanFiles.insert(this->CleanFiles.end(), exeCleanFiles.begin(), - exeCleanFiles.end()); + this->CleanFiles.insert(exeCleanFiles.begin(), exeCleanFiles.end()); #else static_cast<void>(relink); #endif @@ -480,7 +480,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // List the PDB for cleaning only when the whole target is // cleaned. We do not want to delete the .pdb file just before // linking the target. - this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + this->CleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB)); // Add the pre-build and pre-link rules building but not when relinking. @@ -695,6 +695,5 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->WriteTargetDriverRule(targetFullPath, relink); // Clean all the possible executable names and symlinks. - this->CleanFiles.insert(this->CleanFiles.end(), exeCleanFiles.begin(), - exeCleanFiles.end()); + this->CleanFiles.insert(exeCleanFiles.begin(), exeCleanFiles.end()); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 0393e22..f5d1fc9 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -4,6 +4,7 @@ #include <algorithm> #include <memory> // IWYU pragma: keep +#include <set> #include <sstream> #include <stddef.h> #include <utility> @@ -304,8 +305,8 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress); } // Clean files associated with this library. - std::vector<std::string> libCleanFiles; - libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + std::set<std::string> libCleanFiles; + libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetOutputReal)); // Determine whether a link script will be used. @@ -412,8 +413,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( this->LocalGenerator->SetLinkScriptShell(false); // Clean all the possible library names and symlinks. - this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(), - libCleanFiles.end()); + this->CleanFiles.insert(libCleanFiles.begin(), libCleanFiles.end()); } std::vector<std::string> commands1; @@ -593,8 +593,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Clean files associated with this library. - std::vector<std::string> libCleanFiles; - libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + std::set<std::string> libCleanFiles; + libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal)); std::vector<std::string> commands1; @@ -611,22 +611,22 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } if (this->TargetNames.Output != this->TargetNames.Real) { - libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath)); } if (this->TargetNames.SharedObject != this->TargetNames.Real && this->TargetNames.SharedObject != this->TargetNames.Output) { - libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO)); } if (!this->TargetNames.ImportLibrary.empty()) { - libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport)); std::string implib; if (this->GeneratorTarget->GetImplibGNUtoMS( this->ConfigName, targetFullPathImport, implib)) { - libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), implib)); } } @@ -634,14 +634,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // List the PDB for cleaning only when the whole target is // cleaned. We do not want to delete the .pdb file just before // linking the target. - this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + this->CleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB)); #ifdef _WIN32 // There may be a manifest file for this target. Add it to the // clean set just in case. if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { - libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( + libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath + ".manifest")); } @@ -992,6 +992,5 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->WriteTargetDriverRule(targetFullPath, relink); // Clean all the possible library names and symlinks. - this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(), - libCleanFiles.end()); + this->CleanFiles.insert(libCleanFiles.begin(), libCleanFiles.end()); } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 340e405..2ea6682 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -158,10 +158,12 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(additional_clean_files); + std::vector<std::string> additionalFiles; cmSystemTools::ExpandListArgument( cge->Evaluate(this->LocalGenerator, config, false, this->GeneratorTarget, nullptr, nullptr), - this->CleanFiles); + additionalFiles); + this->CleanFiles.insert(additionalFiles.begin(), additionalFiles.end()); } // add custom commands to the clean rules? @@ -181,13 +183,13 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() if (clean) { const std::vector<std::string>& outputs = ccg.GetOutputs(); for (std::string const& output : outputs) { - this->CleanFiles.push_back( + this->CleanFiles.insert( this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, output)); } const std::vector<std::string>& byproducts = ccg.GetByproducts(); for (std::string const& byproduct : byproducts) { - this->CleanFiles.push_back( + this->CleanFiles.insert( this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, byproduct)); } @@ -211,7 +213,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() for (const auto& be : buildEventCommands) { const std::vector<std::string>& byproducts = be.GetByproducts(); for (std::string const& byproduct : byproducts) { - this->CleanFiles.push_back( + this->CleanFiles.insert( this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, byproduct)); } @@ -350,7 +352,7 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()( std::string output = macdir; output += "/"; output += cmSystemTools::GetFilenameName(input); - this->Generator->CleanFiles.push_back( + this->Generator->CleanFiles.insert( this->Generator->LocalGenerator->MaybeConvertToRelativePath( this->Generator->LocalGenerator->GetCurrentBinaryDirectory(), output)); output = this->Generator->LocalGenerator->MaybeConvertToRelativePath( @@ -415,7 +417,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Save this in the target's list of object files. this->Objects.push_back(obj); - this->CleanFiles.push_back(obj); + this->CleanFiles.insert(obj); // TODO: Remove // std::string relativeObj @@ -804,8 +806,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( if (const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { // Register these as extra files to clean. cmSystemTools::ExpandListArgument(extra_outputs_str, outputs); - this->CleanFiles.insert(this->CleanFiles.end(), outputs.begin() + 1, - outputs.end()); + this->CleanFiles.insert(outputs.begin() + 1, outputs.end()); } // Write the rule. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index ec58d17..c570a7c 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -210,7 +210,7 @@ protected: cmGeneratedFileStream* InfoFileStream; // files to clean - std::vector<std::string> CleanFiles; + std::set<std::string> CleanFiles; // objects used by this target std::vector<std::string> Objects; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f76961de87d8911d13867d469c38087e47a0b60 commit 9f76961de87d8911d13867d469c38087e47a0b60 Author: Rosen Matev <r.ma...@gmail.com> AuthorDate: Fri May 10 14:37:39 2019 +0200 Commit: Rosen Matev <r.ma...@gmail.com> CommitDate: Tue May 14 15:58:00 2019 +0200 Support job pools in custom commands and targets Provide a way for custom commands and targets to set the pool variable of the ninja build statement. Setting `JOB_POOL` is not compatible with `USES_TERMINAL`, which implies the `console` pool. The option is silently ignored with other generators. Closes: #18483 diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index 9bf0d87..ed321fc 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -23,6 +23,7 @@ The first signature is for adding a custom command to produce an output: [WORKING_DIRECTORY dir] [COMMENT comment] [DEPFILE depfile] + [JOB_POOL job_pool] [VERBATIM] [APPEND] [USES_TERMINAL] [COMMAND_EXPAND_LISTS]) @@ -144,6 +145,13 @@ The options are: Note that the ``IMPLICIT_DEPENDS`` option is currently supported only for Makefile generators and will be ignored by other generators. +``JOB_POOL`` + Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja` + generator. Incompatible with ``USES_TERMINAL``, which implies + the ``console`` pool. + Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes + an error by ninja at build time. + ``MAIN_DEPENDENCY`` Specify the primary input source file to the command. This is treated just like any value given to the ``DEPENDS`` option diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst index c63dd23..08b9516 100644 --- a/Help/command/add_custom_target.rst +++ b/Help/command/add_custom_target.rst @@ -11,6 +11,7 @@ Add a target with no output so it will always be built. [BYPRODUCTS [files...]] [WORKING_DIRECTORY dir] [COMMENT comment] + [JOB_POOL job_pool] [VERBATIM] [USES_TERMINAL] [COMMAND_EXPAND_LISTS] [SOURCES src1 [src2...]]) @@ -97,6 +98,13 @@ The options are: ``${CC} "-I$<JOIN:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>,;-I>" foo.cc`` to be properly expanded. +``JOB_POOL`` + Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja` + generator. Incompatible with ``USES_TERMINAL``, which implies + the ``console`` pool. + Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes + an error by ninja at build time. + ``SOURCES`` Specify additional source files to be included in the custom target. Specified source files will be added to IDE project files for diff --git a/Help/prop_gbl/JOB_POOLS.rst b/Help/prop_gbl/JOB_POOLS.rst index b904f7a..21da466 100644 --- a/Help/prop_gbl/JOB_POOLS.rst +++ b/Help/prop_gbl/JOB_POOLS.rst @@ -18,6 +18,11 @@ Defined pools could be used globally by setting :variable:`CMAKE_JOB_POOL_COMPILE` and :variable:`CMAKE_JOB_POOL_LINK` or per target by setting the target properties :prop_tgt:`JOB_POOL_COMPILE` and :prop_tgt:`JOB_POOL_LINK`. +:command:`Custom commands <add_custom_command>` and +:command:`custom targets <add_custom_target>` can specify pools using the +option ``JOB_POOL``. +Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes +an error by ninja at build time. If not set, this property uses the value of the :variable:`CMAKE_JOB_POOLS` variable. diff --git a/Help/release/dev/ninja-add_custom_command-pool.rst b/Help/release/dev/ninja-add_custom_command-pool.rst new file mode 100644 index 0000000..f5a2db9 --- /dev/null +++ b/Help/release/dev/ninja-add_custom_command-pool.rst @@ -0,0 +1,6 @@ +ninja-add_custom_command-pool +-------------------------------- + +* The commands :command:`add_custom_command` and :command:`add_custom_target` + gained a new ``JOB_POOL`` option that works with the :generator:`Ninja` + generator to set the pool variable on the build statement. diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index a840f17..0be3c85 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -31,7 +31,7 @@ bool cmAddCustomCommandCommand::InitialPass( return false; } - std::string source, target, main_dependency, working, depfile; + std::string source, target, main_dependency, working, depfile, job_pool; std::string comment_buffer; const char* comment = nullptr; std::vector<std::string> depends, outputs, output, byproducts; @@ -65,6 +65,7 @@ bool cmAddCustomCommandCommand::InitialPass( doing_comment, doing_working_directory, doing_depfile, + doing_job_pool, doing_nothing }; @@ -81,6 +82,7 @@ bool cmAddCustomCommandCommand::InitialPass( MAKE_STATIC_KEYWORD(DEPENDS); MAKE_STATIC_KEYWORD(DEPFILE); MAKE_STATIC_KEYWORD(IMPLICIT_DEPENDS); + MAKE_STATIC_KEYWORD(JOB_POOL); MAKE_STATIC_KEYWORD(MAIN_DEPENDENCY); MAKE_STATIC_KEYWORD(OUTPUT); MAKE_STATIC_KEYWORD(OUTPUTS); @@ -104,6 +106,7 @@ bool cmAddCustomCommandCommand::InitialPass( keywords.insert(keyDEPENDS); keywords.insert(keyDEPFILE); keywords.insert(keyIMPLICIT_DEPENDS); + keywords.insert(keyJOB_POOL); keywords.insert(keyMAIN_DEPENDENCY); keywords.insert(keyOUTPUT); keywords.insert(keyOUTPUTS); @@ -170,6 +173,8 @@ bool cmAddCustomCommandCommand::InitialPass( this->Makefile->GetGlobalGenerator()->GetName()); return false; } + } else if (copy == keyJOB_POOL) { + doing = doing_job_pool; } } else { std::string filename; @@ -211,6 +216,9 @@ bool cmAddCustomCommandCommand::InitialPass( case doing_depfile: depfile = copy; break; + case doing_job_pool: + job_pool = copy; + break; case doing_working_directory: working = copy; break; @@ -318,6 +326,11 @@ bool cmAddCustomCommandCommand::InitialPass( return false; } + if (uses_terminal && !job_pool.empty()) { + this->SetError("JOB_POOL is shadowed by USES_TERMINAL."); + return false; + } + // Choose which mode of the command to use. bool escapeOldStyle = !verbatim; if (source.empty() && output.empty()) { @@ -325,14 +338,14 @@ bool cmAddCustomCommandCommand::InitialPass( std::vector<std::string> no_depends; this->Makefile->AddCustomCommandToTarget( target, byproducts, no_depends, commandLines, cctype, comment, - working.c_str(), escapeOldStyle, uses_terminal, depfile, + working.c_str(), escapeOldStyle, uses_terminal, depfile, job_pool, command_expand_lists); } else if (target.empty()) { // Target is empty, use the output. this->Makefile->AddCustomCommandToOutput( output, byproducts, depends, main_dependency, commandLines, comment, working.c_str(), false, escapeOldStyle, uses_terminal, - command_expand_lists, depfile); + command_expand_lists, depfile, job_pool); // Add implicit dependency scanning requests if any were given. if (!implicit_depends.empty()) { diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 8240d3e..0ecd5f5 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -52,6 +52,7 @@ bool cmAddCustomTargetCommand::InitialPass( std::string comment_buffer; const char* comment = nullptr; std::vector<std::string> sources; + std::string job_pool; // Keep track of parser state. enum tdoing @@ -62,6 +63,7 @@ bool cmAddCustomTargetCommand::InitialPass( doing_working_directory, doing_comment, doing_source, + doing_job_pool, doing_nothing }; tdoing doing = doing_command; @@ -97,6 +99,8 @@ bool cmAddCustomTargetCommand::InitialPass( command_expand_lists = true; } else if (copy == "COMMENT") { doing = doing_comment; + } else if (copy == "JOB_POOL") { + doing = doing_job_pool; } else if (copy == "COMMAND") { doing = doing_command; @@ -137,6 +141,9 @@ bool cmAddCustomTargetCommand::InitialPass( case doing_source: sources.push_back(copy); break; + case doing_job_pool: + job_pool = copy; + break; default: this->SetError("Wrong syntax. Unknown type of argument."); return false; @@ -200,12 +207,17 @@ bool cmAddCustomTargetCommand::InitialPass( return true; } + if (uses_terminal && !job_pool.empty()) { + this->SetError("JOB_POOL is shadowed by USES_TERMINAL."); + return false; + } + // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = this->Makefile->AddUtilityCommand( targetName, cmMakefile::TargetOrigin::Project, excludeFromAll, working_directory.c_str(), byproducts, depends, commandLines, - escapeOldStyle, comment, uses_terminal, command_expand_lists); + escapeOldStyle, comment, uses_terminal, command_expand_lists, job_pool); // Add additional user-specified source files to the target. target->AddSources(sources); diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 242ceaa..ad8c9b9 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -134,3 +134,13 @@ void cmCustomCommand::SetDepfile(const std::string& depfile) { this->Depfile = depfile; } + +const std::string& cmCustomCommand::GetJobPool() const +{ + return this->JobPool; +} + +void cmCustomCommand::SetJobPool(const std::string& job_pool) +{ + this->JobPool = job_pool; +} diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 50f15a4..9a6f239 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -89,6 +89,10 @@ public: const std::string& GetDepfile() const; void SetDepfile(const std::string& depfile); + /** Set/Get the job_pool (used by the Ninja generator) */ + const std::string& GetJobPool() const; + void SetJobPool(const std::string& job_pool); + private: std::vector<std::string> Outputs; std::vector<std::string> Byproducts; @@ -99,6 +103,7 @@ private: std::string Comment; std::string WorkingDirectory; std::string Depfile; + std::string JobPool; bool HaveComment = false; bool EscapeAllowMakeVars = false; bool EscapeOldStyle = true; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4fa6ee6..522ffe6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -252,8 +252,9 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule() void cmGlobalNinjaGenerator::WriteCustomCommandBuild( const std::string& command, const std::string& description, - const std::string& comment, const std::string& depfile, bool uses_terminal, - bool restat, const cmNinjaDeps& outputs, const cmNinjaDeps& deps, + const std::string& comment, const std::string& depfile, + const std::string& job_pool, bool uses_terminal, bool restat, + const cmNinjaDeps& outputs, const cmNinjaDeps& deps, const cmNinjaDeps& orderOnly) { std::string cmd = command; // NOLINT(*) @@ -273,6 +274,8 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( } if (uses_terminal && SupportsConsolePool()) { vars["pool"] = "console"; + } else if (!job_pool.empty()) { + vars["pool"] = job_pool; } if (!depfile.empty()) { vars["depfile"] = depfile; @@ -951,7 +954,8 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() std::back_inserter(orderOnlyDeps)); WriteCustomCommandBuild(/*command=*/"", /*description=*/"", "Assume dependencies for generated source file.", - /*depfile*/ "", /*uses_terminal*/ false, + /*depfile*/ "", /*job_pool*/ "", + /*uses_terminal*/ false, /*restat*/ true, cmNinjaDeps(1, asd.first), cmNinjaDeps(), orderOnlyDeps); } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index efd1d8f..3ab4171 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -129,7 +129,8 @@ public: void WriteCustomCommandBuild(const std::string& command, const std::string& description, const std::string& comment, - const std::string& depfile, bool uses_terminal, + const std::string& depfile, + const std::string& pool, bool uses_terminal, bool restat, const cmNinjaDeps& outputs, const cmNinjaDeps& deps = cmNinjaDeps(), const cmNinjaDeps& orderOnly = cmNinjaDeps()); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index db673bb..69cf2b7 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -568,7 +568,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( gen->GetMakefile()->AddCustomCommandToTarget( target->GetName(), no_byproducts, no_depends, commandLines, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true, - false, "", false, cmMakefile::AcceptObjectLibraryCommands); + false, "", "", false, cmMakefile::AcceptObjectLibraryCommands); } if (!this->IsExcluded(target)) { diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index f4e3ed8..3704864 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -509,7 +509,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild( this->BuildCommandLine(cmdLines, customStep), this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0], - cc->GetDepfile(), cc->GetUsesTerminal(), + cc->GetDepfile(), cc->GetJobPool(), cc->GetUsesTerminal(), /*restat*/ !symbolic || !byproducts.empty(), ninjaOutputs, ninjaDeps, orderOnlyDeps); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6c390f7..ca5f009 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -814,8 +814,8 @@ void cmMakefile::AddCustomCommandToTarget( const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, - bool uses_terminal, const std::string& depfile, bool command_expand_lists, - ObjectLibraryCommands objLibraryCommands) + bool uses_terminal, const std::string& depfile, const std::string& job_pool, + bool command_expand_lists, ObjectLibraryCommands objLibraryCommands) { // Find the target to which to add the custom command. cmTargets::iterator ti = this->Targets.find(target); @@ -890,6 +890,7 @@ void cmMakefile::AddCustomCommandToTarget( cc.SetUsesTerminal(uses_terminal); cc.SetCommandExpandLists(command_expand_lists); cc.SetDepfile(depfile); + cc.SetJobPool(job_pool); switch (type) { case cmTarget::PRE_BUILD: t.AddPreBuildCommand(cc); @@ -909,7 +910,8 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( const std::vector<std::string>& depends, const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, - bool uses_terminal, bool command_expand_lists, const std::string& depfile) + bool uses_terminal, bool command_expand_lists, const std::string& depfile, + const std::string& job_pool) { // Make sure there is at least one output. if (outputs.empty()) { @@ -1003,6 +1005,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( cc->SetUsesTerminal(uses_terminal); cc->SetCommandExpandLists(command_expand_lists); cc->SetDepfile(depfile); + cc->SetJobPool(job_pool); file->SetCustomCommand(cc); this->UpdateOutputToSourceMap(outputs, file); } @@ -1040,7 +1043,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, - const std::string& depfile) + const std::string& depfile, const std::string& job_pool) { std::vector<std::string> outputs; outputs.push_back(output); @@ -1048,7 +1051,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( return this->AddCustomCommandToOutput( outputs, no_byproducts, depends, main_dependency, commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, command_expand_lists, - depfile); + depfile, job_pool); } void cmMakefile::AddCustomCommandOldStyle( @@ -1142,13 +1145,14 @@ cmTarget* cmMakefile::AddUtilityCommand( const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, - const char* comment, bool uses_terminal, bool command_expand_lists) + const char* comment, bool uses_terminal, bool command_expand_lists, + const std::string& job_pool) { std::vector<std::string> no_byproducts; - return this->AddUtilityCommand(utilityName, origin, excludeFromAll, - workingDirectory, no_byproducts, depends, - commandLines, escapeOldStyle, comment, - uses_terminal, command_expand_lists); + return this->AddUtilityCommand( + utilityName, origin, excludeFromAll, workingDirectory, no_byproducts, + depends, commandLines, escapeOldStyle, comment, uses_terminal, + command_expand_lists, job_pool); } cmTarget* cmMakefile::AddUtilityCommand( @@ -1156,7 +1160,8 @@ cmTarget* cmMakefile::AddUtilityCommand( const char* workingDirectory, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, - const char* comment, bool uses_terminal, bool command_expand_lists) + const char* comment, bool uses_terminal, bool command_expand_lists, + const std::string& job_pool) { // Create a target instance for this utility. cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); @@ -1182,7 +1187,7 @@ cmTarget* cmMakefile::AddUtilityCommand( this->AddCustomCommandToOutput( forced, byproducts, depends, no_main_dependency, commandLines, comment, workingDirectory, no_replace, escapeOldStyle, uses_terminal, - command_expand_lists); + command_expand_lists, /*depfile=*/"", job_pool); cmSourceFile* sf = target->AddSourceCMP0049(force); // The output is not actually created so mark it symbolic. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 8cc14f3..be1ac5a 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -150,7 +150,7 @@ public: const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", - bool command_expand_lists = false, + const std::string& job_pool = "", bool command_expand_lists = false, ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands); cmSourceFile* AddCustomCommandToOutput( const std::vector<std::string>& outputs, @@ -160,14 +160,14 @@ public: const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = ""); + const std::string& depfile = "", const std::string& job_pool = ""); cmSourceFile* AddCustomCommandToOutput( const std::string& output, const std::vector<std::string>& depends, const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = ""); + const std::string& depfile = "", const std::string& job_pool = ""); void AddCustomCommandOldStyle(const std::string& target, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, @@ -223,14 +223,14 @@ public: const char* workingDirectory, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false); + bool command_expand_lists = false, const std::string& job_pool = ""); cmTarget* AddUtilityCommand( const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false); + bool command_expand_lists = false, const std::string& job_pool = ""); /** * Add a subdirectory to the build. diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 95fcf66..ab777c8 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -132,7 +132,7 @@ void cmNinjaUtilityTargetGenerator::Generate() this->GetGlobalGenerator()->WriteCustomCommandBuild( command, desc, "Utility command for " + this->GetTargetName(), - /*depfile*/ "", uses_terminal, + /*depfile*/ "", /*job_pool*/ "", uses_terminal, /*restat*/ true, util_outputs, deps); this->GetGlobalGenerator()->WritePhonyBuild( diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake new file mode 100644 index 0000000..7f7fa33 --- /dev/null +++ b/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake @@ -0,0 +1,8 @@ +set(log "${RunCMake_BINARY_DIR}/CustomCommandJobPool-build/build.ninja") +file(READ "${log}" build_file) +if(NOT "${build_file}" MATCHES "pool = custom_command_pool") + set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: pool = custom_command_pool") +endif() +if(NOT "${build_file}" MATCHES "pool = custom_target_pool") + set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: pool = custom_target_pool") +endif() diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake new file mode 100644 index 0000000..1e36e65 --- /dev/null +++ b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake @@ -0,0 +1,17 @@ +add_custom_command( + OUTPUT hello.copy.c + COMMAND "${CMAKE_COMMAND}" -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/hello.c" + hello.copy.c + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + JOB_POOL "custom_command_pool" + ) +add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hello.copy.c") + +add_custom_target( + hello.echo + COMMAND echo + JOB_POOL "custom_target_pool" +) + +include(CheckNoPrefixSubDir.cmake) diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt new file mode 100644 index 0000000..45975ca --- /dev/null +++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at JobPoolUsesTerminal.cmake:1 \(add_custom_command\): + add_custom_command JOB_POOL is shadowed by USES_TERMINAL. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at JobPoolUsesTerminal.cmake:2 \(add_custom_target\): + add_custom_target JOB_POOL is shadowed by USES_TERMINAL. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake b/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake new file mode 100644 index 0000000..b7e440c --- /dev/null +++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake @@ -0,0 +1,2 @@ +add_custom_command(OUTPUT x COMMAND y USES_TERMINAL JOB_POOL z) +add_custom_target(CustomTarget COMMAND y USES_TERMINAL JOB_POOL z) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 8fa650a..808a872 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -57,6 +57,8 @@ run_CMP0058(NEW-no) run_CMP0058(NEW-by) run_cmake(CustomCommandDepfile) +run_cmake(CustomCommandJobPool) +run_cmake(JobPoolUsesTerminal) run_cmake(RspFileC) run_cmake(RspFileCXX) ----------------------------------------------------------------------- Summary of changes: Help/command/add_custom_command.rst | 8 + Help/command/add_custom_target.rst | 8 + Help/manual/cmake-properties.7.rst | 2 + Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst | 16 + Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst | 16 +- Help/prop_gbl/JOB_POOLS.rst | 5 + Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst | 16 + Help/release/dev/additional_clean_files.rst | 10 + Help/release/dev/ninja-add_custom_command-pool.rst | 6 + Modules/UseJava.cmake | 523 +++++++++------------ Source/cmAddCustomCommandCommand.cxx | 19 +- Source/cmAddCustomTargetCommand.cxx | 14 +- Source/cmCustomCommand.cxx | 10 + Source/cmCustomCommand.h | 5 + Source/cmGlobalNinjaGenerator.cxx | 112 ++++- Source/cmGlobalNinjaGenerator.h | 12 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmLocalNinjaGenerator.cxx | 27 +- Source/cmLocalNinjaGenerator.h | 2 + Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.h | 2 +- Source/cmMakefile.cxx | 29 +- Source/cmMakefile.h | 10 +- Source/cmMakefileExecutableTargetGenerator.cxx | 9 +- Source/cmMakefileLibraryTargetGenerator.cxx | 27 +- Source/cmMakefileTargetGenerator.cxx | 61 ++- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 + Source/cmNinjaTargetGenerator.cxx | 25 + Source/cmNinjaTargetGenerator.h | 2 + Source/cmNinjaUtilityTargetGenerator.cxx | 2 +- Source/cmUVProcessChain.cxx | 5 +- Tests/CMakeLists.txt | 3 +- Tests/MakeClean/ToClean/CMakeLists.txt | 112 +++-- Tests/MakeClean/check_clean.c.in | 2 +- .../Ninja/CustomCommandJobPool-check.cmake | 8 + ...gDirectory.cmake => CustomCommandJobPool.cmake} | 10 +- .../JobPoolUsesTerminal-result.txt} | 0 .../RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt | 9 + Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake | 2 + Tests/RunCMake/Ninja/RunCMakeTest.cmake | 2 + 41 files changed, 736 insertions(+), 403 deletions(-) create mode 100644 Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst create mode 100644 Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst create mode 100644 Help/release/dev/additional_clean_files.rst create mode 100644 Help/release/dev/ninja-add_custom_command-pool.rst create mode 100644 Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake copy Tests/RunCMake/Ninja/{CustomCommandWorkingDirectory.cmake => CustomCommandJobPool.cmake} (73%) copy Tests/RunCMake/{while/MissingArgument-result.txt => Ninja/JobPoolUsesTerminal-result.txt} (100%) create mode 100644 Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt create mode 100644 Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org https://cmake.org/mailman/listinfo/cmake-commits