diff options
532 files changed, 9531 insertions, 4634 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 6feed94..79d2319 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -230,26 +230,13 @@ the indentation. Otherwise it retains the same position on the line" ;; (defvar cmake-tab-width 2) -;; -;; Keymap. -;; -(defvar cmake-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-ch" 'cmake-help-command) - (define-key map "\C-cl" 'cmake-help-list-commands) - (define-key map "\C-cu" 'unscreamify-cmake-buffer) - map) - "Keymap used in cmake-mode buffers.") - ;------------------------------------------------------------------------------ ;; ;; CMake mode startup function. ;; (defun cmake-mode () - "Major mode for editing CMake listfiles. - -\\{cmake-mode-map}" + "Major mode for editing CMake listfiles." (interactive) (kill-all-local-variables) (setq major-mode 'cmake-mode) @@ -276,9 +263,6 @@ the indentation. Otherwise it retains the same position on the line" (make-local-variable 'comment-start) (setq comment-start "#") - ; Setup keymap. - (use-local-map cmake-mode-map) - ; Run user hooks. (run-hooks 'cmake-mode-hook)) diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake index 2495c44..fb55bfc 100644 --- a/CMakeCPack.cmake +++ b/CMakeCPack.cmake @@ -29,27 +29,23 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") set(CPACK_PACKAGE_VENDOR "Kitware") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") + set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") set(CPACK_PACKAGE_VERSION "${CMake_VERSION}") - set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-${CMake_VERSION}") - # Make this explicit here, rather than accepting the CPack default value, - # so we can refer to it: - set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") - # Installers for 32- vs. 64-bit CMake: # - Root install directory (displayed to end user at installer-run time) # - "NSIS package/display name" (text used in the installer GUI) # - Registry key used to store info about the installation if(CMAKE_CL_64) set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") - set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} (Win64)") - set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)") + set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)") else() set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") - set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") - set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") + set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") endif() + set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_NSIS_PACKAGE_NAME}") if(NOT DEFINED CPACK_SYSTEM_NAME) # make sure package is not Cygwin-unknown, for Cygwin just diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in index 008a102..3ff0188 100644 --- a/CMakeCPackOptions.cmake.in +++ b/CMakeCPackOptions.cmake.in @@ -13,14 +13,7 @@ if(CPACK_GENERATOR MATCHES "NSIS") set(CPACK_PACKAGE_ICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeInstall.bmp") # tell cpack to create links to the doc files set(CPACK_NSIS_MENU_LINKS - "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-gui.html" "cmake-gui Help" - "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html" "CMake Help" - "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-properties.html" - "CMake Properties and Variables Help" - "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/ctest.html" "CTest Help" - "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-modules.html" "CMake Modules Help" - "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-commands.html" "CMake Commands Help" - "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cpack.html" "CPack Help" + "@CMAKE_DOC_DIR@/html/index.html" "CMake Documentation" "http://www.cmake.org" "CMake Web Site" ) # Use the icon from cmake-gui for add-remove programs diff --git a/CMakeLists.txt b/CMakeLists.txt index 25cd576..a13afa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,10 +113,6 @@ endif() # for testing. Simply to improve readability of the main script. #----------------------------------------------------------------------- macro(CMAKE_SETUP_TESTING) - if (NOT DART_ROOT) - set(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM}) - endif () - if(BUILD_TESTING) set(CMAKE_TEST_GENERATOR "" CACHE STRING "Generator used when running tests") @@ -125,7 +121,6 @@ macro(CMAKE_SETUP_TESTING) if(NOT CMAKE_TEST_GENERATOR) set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}") set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") - set(CMAKE_TEST_MAKEPROGRAM "${MAKEPROGRAM}") else() set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE) set(CMAKE_TEST_GENERATOR_TOOLSET "") @@ -484,7 +479,6 @@ if(BUILD_QtDialog) if(APPLE) set(CMAKE_BUNDLE_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") - set(CMAKE_BUNDLE_NAME "CMake ${CMAKE_BUNDLE_VERSION}") set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") # make sure CMAKE_INSTALL_PREFIX ends in / string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN) @@ -494,7 +488,7 @@ if(BUILD_QtDialog) set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") endif() set(CMAKE_INSTALL_PREFIX - "${CMAKE_INSTALL_PREFIX}${CMAKE_BUNDLE_NAME}.app/Contents") + "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") endif() set(QT_NEED_RPATH FALSE) diff --git a/ChangeLog.manual b/ChangeLog.manual index 0e84fb6..5d2dc8b 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,29 @@ +Changes in CMake 2.8.12.1 (since 2.8.12) +---------------------------------------- +Brad King (9): + MSVC: Add /FS flag for cl >= 18 to allow parallel compilation (#14492) + Genex: Reject $<TARGET_FILE:...> for object libraries (#14532) + Check for OBJECT_LIBRARY source files at start of generation + CMP0022: Plain target_link_libraries must populate link interface + Do not export INTERFACE_LINK_LIBRARIES from non-linkable targets + CMP0022: Warn about a given target at most once + Fix summary documentation of INTERFACE_LINK_LIBRARIES + file(GENERATE): Clear internal records between configures + cmake: Validate -E cmake_automoc argument count (#14545) + +Modestas Vainius (1): + Fix spelling in INTERFACE_LINK_LIBRARIES documentation (#14542) + +Stephen Kelly (5): + CMP0022: Output link interface mismatch for static library warning + Don't add invalid content to static lib INTERFACE_LINK_LIBRARIES. + CMP0022: Add unit test for null pointer check and message. + CMP0022: Add test for target_link_libraries plain signature + Automoc: Add directory-level COMPILE_DEFINITIONS to command line (#14535) + +Vladislav Vinogradov (1): + FindCUDA: Fix NPP library search for CUDA 5.5 + Changes in CMake 2.8.12 (since 2.8.12-rc4) ------------------------------------------ Brad King (4): diff --git a/Copyright.txt b/Copyright.txt index 83a2482..9342249 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -1,5 +1,6 @@ CMake - Cross Platform Makefile Generator -Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +Copyright 2000-2013 Kitware, Inc. +Copyright 2000-2011 Insight Software Consortium All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Help/command/FIND_XXX_ROOT.txt b/Help/command/FIND_XXX_ROOT.txt index 407375a..7f80dcb 100644 --- a/Help/command/FIND_XXX_ROOT.txt +++ b/Help/command/FIND_XXX_ROOT.txt @@ -1,10 +1,17 @@ The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more directories to be prepended to all other search directories. This effectively "re-roots" the entire search under given locations. By -default it is empty. It is especially useful when cross-compiling to +default it is empty. + +The :variable:`CMAKE_SYSROOT` variable can also be used to specify exactly one +directory to use as a prefix. Setting :variable:`CMAKE_SYSROOT` also has other +effects. See the documentation for that variable for more. + +These variables are especially useful when cross-compiling to point to the root directory of the target environment and CMake will search there too. By default at first the directories listed in -CMAKE_FIND_ROOT_PATH and then the non-rooted directories will be +CMAKE_FIND_ROOT_PATH are searched, then the :variable:`CMAKE_SYSROOT` directory is +searched, and then the non-rooted directories will be searched. The default behavior can be adjusted by setting |CMAKE_FIND_ROOT_PATH_MODE_XXX|. This behavior can be manually overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH diff --git a/Help/command/build_command.rst b/Help/command/build_command.rst index f4a56f0..82a9a42 100644 --- a/Help/command/build_command.rst +++ b/Help/command/build_command.rst @@ -1,37 +1,44 @@ build_command ------------- -Get the command line to build this project. +Get a command line to build the current project. +This is mainly intended for internal use by the :module:`CTest` module. -:: +.. code-block:: cmake build_command(<variable> [CONFIGURATION <config>] - [PROJECT_NAME <projname>] - [TARGET <target>]) + [TARGET <target>] + [PROJECT_NAME <projname>] # legacy, causes warning + ) -Sets the given <variable> to a string containing the command line for -building one configuration of a target in a project using the build -tool appropriate for the current CMAKE_GENERATOR. +Sets the given ``<variable>`` to a command-line string of the form:: -If CONFIGURATION is omitted, CMake chooses a reasonable default value -for multi-configuration generators. CONFIGURATION is ignored for -single-configuration generators. + <cmake> --build . [--config <config>] [--target <target>] [-- -i] -If PROJECT_NAME is omitted, the resulting command line will build the -top level PROJECT in the current build tree. +where ``<cmake>`` is the location of the :manual:`cmake(1)` command-line +tool, and ``<config>`` and ``<target>`` are the values provided to the +``CONFIGURATION`` and ``TARGET`` options, if any. The trailing ``-- -i`` +option is added for Makefile generators. -If TARGET is omitted, the resulting command line will build -everything, effectively using build target 'all' or 'ALL_BUILD'. +When invoked, this ``cmake --build`` command line will launch the +underlying build system tool. -:: +.. code-block:: cmake build_command(<cachevariable> <makecommand>) This second signature is deprecated, but still available for backwards compatibility. Use the first signature instead. -Sets the given <cachevariable> to a string containing the command to -build this project from the root of the build tree using the build -tool given by <makecommand>. <makecommand> should be the full path to -msdev, devenv, nmake, make or one of the end user build tools. +It sets the given ``<cachevariable>`` to a command-line string as +above but without the ``--config`` or ``--target`` options. +The ``<makecommand>`` is ignored but should be the full path to +msdev, devenv, nmake, make or one of the end user build tools +for legacy invocations. + +.. note:: + In CMake versions prior to 3.0 this command returned a command + line that directly invokes the native build tool for the current + generator. Their implementation of the ``PROJECT_NAME`` option + had no useful effects, so CMake now warns on use of the option. diff --git a/Help/command/ctest_submit.rst b/Help/command/ctest_submit.rst index 29d2f5d..ed801bb 100644 --- a/Help/command/ctest_submit.rst +++ b/Help/command/ctest_submit.rst @@ -22,6 +22,7 @@ Valid part names are: MemCheck = ctest_memcheck results, in DynamicAnalysis.xml Notes = Files listed by CTEST_NOTES_FILES, in Notes.xml ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES + Upload = Files prepared for upload by ctest_upload(), in Upload.xml Submit = nothing The FILES option explicitly lists specific files to be submitted. diff --git a/Help/command/execute_process.rst b/Help/command/execute_process.rst index 3f0ccc2..478b30e 100644 --- a/Help/command/execute_process.rst +++ b/Help/command/execute_process.rst @@ -3,7 +3,7 @@ execute_process Execute one or more child processes. -:: +.. code-block:: cmake execute_process(COMMAND <cmd1> [args1...]] [COMMAND <cmd2> [args2...] [...]] @@ -21,28 +21,55 @@ Execute one or more child processes. [ERROR_STRIP_TRAILING_WHITESPACE]) Runs the given sequence of one or more commands with the standard -output of each process piped to the standard input of the next. A -single standard error pipe is used for all processes. If -WORKING_DIRECTORY is given the named directory will be set as the -current working directory of the child processes. If TIMEOUT is given -the child processes will be terminated if they do not finish in the -specified number of seconds (fractions are allowed). If -RESULT_VARIABLE is given the variable will be set to contain the -result of running the processes. This will be an integer return code -from the last child or a string describing an error condition. If -OUTPUT_VARIABLE or ERROR_VARIABLE are given the variable named will be -set with the contents of the standard output and standard error pipes -respectively. If the same variable is named for both pipes their -output will be merged in the order produced. If INPUT_FILE, -OUTPUT_FILE, or ERROR_FILE is given the file named will be attached to -the standard input of the first process, standard output of the last -process, or standard error of all processes respectively. If -OUTPUT_QUIET or ERROR_QUIET is given then the standard output or -standard error results will be quietly ignored. If more than one -OUTPUT_* or ERROR_* option is given for the same pipe the precedence -is not specified. If no OUTPUT_* or ERROR_* options are given the -output will be shared with the corresponding pipes of the CMake -process itself. - -The execute_process command is a newer more powerful version of -exec_program, but the old command has been kept for compatibility. +output of each process piped to the standard input of the next. +A single standard error pipe is used for all processes. + +Options: + +COMMAND + A child process command line. + + CMake executes the child process using operating system APIs directly. + All arguments are passed VERBATIM to the child process. + No intermediate shell is used, so shell operators such as ``>`` + are treated as normal arguments. + (Use the ``INPUT_*``, ``OUTPUT_*``, and ``ERROR_*`` options to + redirect stdin, stdout, and stderr.) + +WORKING_DIRECTORY + The named directory will be set as the current working directory of + the child processes. + +TIMEOUT + The child processes will be terminated if they do not finish in the + specified number of seconds (fractions are allowed). + +RESULT_VARIABLE + The variable will be set to contain the result of running the processes. + This will be an integer return code from the last child or a string + describing an error condition. + +OUTPUT_VARIABLE, ERROR_VARIABLE + The variable named will be set with the contents of the standard output + and standard error pipes, respectively. If the same variable is named + for both pipes their output will be merged in the order produced. + +INPUT_FILE, OUTPUT_FILE, ERROR_FILE + The file named will be attached to the standard input of the first + process, standard output of the last process, or standard error of + all processes, respectively. + +OUTPUT_QUIET, ERROR_QUIET + The standard output or standard error results will be quietly ignored. + +If more than one ``OUTPUT_*`` or ``ERROR_*`` option is given for the +same pipe the precedence is not specified. +If no ``OUTPUT_*`` or ``ERROR_*`` options are given the output will +be shared with the corresponding pipes of the CMake process itself. + +The :command:`execute_process` command is a newer more powerful version of +:command:`exec_program`, but the old command has been kept for compatibility. +Both commands run while CMake is processing the project prior to build +system generation. Use :command:`add_custom_target` and +:command:`add_custom_command` to create custom commands that run at +build time. diff --git a/Help/command/foreach.rst b/Help/command/foreach.rst index 8f9710c..348ebd8 100644 --- a/Help/command/foreach.rst +++ b/Help/command/foreach.rst @@ -42,5 +42,6 @@ three types of this iteration: Iterates over a precise list of items. The LISTS option names list-valued variables to be traversed, including empty elements (an -empty string is a zero-length list). The ITEMS option ends argument +empty string is a zero-length list). (Note macro +arguments are not variables.) The ITEMS option ends argument parsing and includes all arguments following it in the iteration. diff --git a/Help/command/if.rst b/Help/command/if.rst index b879ae1..0279be7 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -166,7 +166,8 @@ major[.minor[.patch[.tweak]]]). if(DEFINED <variable>) True if the given variable is defined. It does not matter if the -variable is true or false just if it has been set. +variable is true or false just if it has been set. (Note macro +arguments are not variables.) :: diff --git a/Help/command/include_directories.rst b/Help/command/include_directories.rst index 6744427..3e0c7a0 100644 --- a/Help/command/include_directories.rst +++ b/Help/command/include_directories.rst @@ -19,7 +19,7 @@ used by the generators. By default the directories are appended onto the current list of directories. This default behavior can be changed by setting -CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. By using AFTER or BEFORE +:variable:`CMAKE_INCLUDE_DIRECTORIES_BEFORE` to ON. By using AFTER or BEFORE explicitly, you can select between appending and prepending, independent of the default. diff --git a/Help/command/list.rst b/Help/command/list.rst index f044dba..aeb1e94 100644 --- a/Help/command/list.rst +++ b/Help/command/list.rst @@ -50,7 +50,8 @@ propagation. NOTES: A list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set(var a b c d e) creates a list with a;b;c;d;e, and set(var "a b c d e") creates a -string or a list with one item in it. +string or a list with one item in it. (Note macro arguments are not +variables, and therefore cannot be used in LIST commands.) When specifying index values, if <element index> is 0 or greater, it is indexed from the beginning of the list, with 0 representing the diff --git a/Help/command/macro.rst b/Help/command/macro.rst index aa16352..258dc50 100644 --- a/Help/command/macro.rst +++ b/Help/command/macro.rst @@ -15,19 +15,53 @@ Define a macro named <name> that takes arguments named arg1 arg2 arg3 (...). Commands listed after macro, but before the matching endmacro, are not invoked until the macro is invoked. When it is invoked, the commands recorded in the macro are first modified by replacing formal -parameters (${arg1}) with the arguments passed, and then invoked as +parameters (``${arg1}``) with the arguments passed, and then invoked as normal commands. In addition to referencing the formal parameters you -can reference the values ${ARGC} which will be set to the number of -arguments passed into the function as well as ${ARGV0} ${ARGV1} -${ARGV2} ... which will have the actual values of the arguments +can reference the values ``${ARGC}`` which will be set to the number of +arguments passed into the function as well as ``${ARGV0}`` ``${ARGV1}`` +``${ARGV2}`` ... which will have the actual values of the arguments passed in. This facilitates creating macros with optional arguments. -Additionally ${ARGV} holds the list of all arguments given to the -macro and ${ARGN} holds the list of arguments past the last expected -argument. Note that the parameters to a macro and values such as ARGN -are not variables in the usual CMake sense. They are string -replacements much like the C preprocessor would do with a macro. If -you want true CMake variables and/or better CMake scope control you -should look at the function command. +Additionally ``${ARGV}`` holds the list of all arguments given to the +macro and ``${ARGN}`` holds the list of arguments past the last expected +argument. See the cmake_policy() command documentation for the behavior of policies inside macros. + +Macro Argument Caveats +^^^^^^^^^^^^^^^^^^^^^^ + +Note that the parameters to a macro and values such as ``ARGN`` are +not variables in the usual CMake sense. They are string +replacements much like the C preprocessor would do with a macro. +Therefore you will NOT be able to use commands like:: + + if(ARGV1) # ARGV1 is not a variable + foreach(loop_var IN LISTS ARGN) # ARGN is not a variable + +In the first case you can use ``if(${ARGV1})``, in the second case, you can +use ``foreach(loop_var ${ARGN})`` but this will skip empty arguments. +If you need to include them, you can use:: + + set(list_var "${ARGN}") + foreach(loop_var IN LISTS list_var) + +Note that if you have a variable with the same name in the scope from +which the macro is called, using unreferenced names will use the +existing variable instead of the arguments. For example:: + + macro(_BAR) + foreach(arg IN LISTS ARGN) + [...] + endforeach() + endmacro() + + function(_FOO) + _bar(x y z) + endfunction() + + _foo(a b c) + +Will loop over ``a;b;c`` and not over ``x;y;z`` as one might be expecting. +If you want true CMake variables and/or better CMake scope control you +should look at the function command. diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst index 41265fd..c2d2dc6 100644 --- a/Help/command/target_link_libraries.rst +++ b/Help/command/target_link_libraries.rst @@ -32,13 +32,16 @@ per-configuration rules by creating and linking to IMPORTED library targets. See the IMPORTED mode of the add_library command for more information. -Library dependencies are transitive by default. When this target is -linked into another target then the libraries linked to this target -will appear on the link line for the other target too. See the -INTERFACE_LINK_LIBRARIES target property to override the set of -transitive link dependencies for a target. Calls to other signatures -of this command may set the property making any libraries linked -exclusively by this signature private. +Library dependencies are transitive by default with this signature. +When this target is linked into another target then the libraries +linked to this target will appear on the link line for the other +target too. This transitive "link interface" is stored in the +INTERFACE_LINK_LIBRARIES target property when policy CMP0022 is set to +NEW and may be overridden by setting the property directly. +(When CMP0022 is not set to NEW, transitive linking is builtin but may +be overridden by the LINK_INTERFACE_LIBRARIES property. Calls to other +signatures of this command may set the property making any libraries +linked exclusively by this signature private.) CMake will also propagate "usage requirements" from linked library targets. Usage requirements affect compilation of sources in the diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst new file mode 100644 index 0000000..000677a --- /dev/null +++ b/Help/generator/Visual Studio 10 2010.rst @@ -0,0 +1,12 @@ +Visual Studio 10 2010 +--------------------- + +Generates Visual Studio 10 (VS 2010) project files. + +It is possible to append a space followed by the platform name to +create project files for a specific target platform. E.g. +"Visual Studio 10 2010 Win64" will create project files for the +x64 processor; "Visual Studio 10 2010 IA64" for Itanium. + +For compatibility with CMake versions prior to 3.0, one may specify this +generator using the name "Visual Studio 10" without the year component. diff --git a/Help/generator/Visual Studio 10.rst b/Help/generator/Visual Studio 10.rst deleted file mode 100644 index 9ea7970..0000000 --- a/Help/generator/Visual Studio 10.rst +++ /dev/null @@ -1,9 +0,0 @@ -Visual Studio 10 ----------------- - -Generates Visual Studio 10 (2010) project files. - -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. "Visual -Studio 10 Win64" will create project files for the x64 processor; -"Visual Studio 10 IA64" for Itanium. diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst new file mode 100644 index 0000000..42f6f91 --- /dev/null +++ b/Help/generator/Visual Studio 11 2012.rst @@ -0,0 +1,12 @@ +Visual Studio 11 2012 +--------------------- + +Generates Visual Studio 11 (VS 2012) project files. + +It is possible to append a space followed by the platform name to +create project files for a specific target platform. E.g. +"Visual Studio 11 2012 Win64" will create project files for the +x64 processor; "Visual Studio 11 2012 ARM" for ARM. + +For compatibility with CMake versions prior to 3.0, one may specify this +generator using the name "Visual Studio 11" without the year component. diff --git a/Help/generator/Visual Studio 11.rst b/Help/generator/Visual Studio 11.rst deleted file mode 100644 index 4115c8d..0000000 --- a/Help/generator/Visual Studio 11.rst +++ /dev/null @@ -1,9 +0,0 @@ -Visual Studio 11 ----------------- - -Generates Visual Studio 11 (2012) project files. - -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. "Visual -Studio 11 Win64" will create project files for the x64 processor; -"Visual Studio 11 ARM" for ARM. diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst new file mode 100644 index 0000000..d2f4912 --- /dev/null +++ b/Help/generator/Visual Studio 12 2013.rst @@ -0,0 +1,12 @@ +Visual Studio 12 2013 +--------------------- + +Generates Visual Studio 12 (VS 2013) project files. + +It is possible to append a space followed by the platform name to +create project files for a specific target platform. E.g. +"Visual Studio 12 2013 Win64" will create project files for the +x64 processor; "Visual Studio 12 2013 ARM" for ARM. + +For compatibility with CMake versions prior to 3.0, one may specify this +generator using the name "Visual Studio 12" without the year component. diff --git a/Help/generator/Visual Studio 12.rst b/Help/generator/Visual Studio 12.rst deleted file mode 100644 index 51bcab7..0000000 --- a/Help/generator/Visual Studio 12.rst +++ /dev/null @@ -1,9 +0,0 @@ -Visual Studio 12 ----------------- - -Generates Visual Studio 12 (2013) project files. - -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. "Visual -Studio 12 Win64" will create project files for the x64 processor; -"Visual Studio 12 ARM" for ARM. diff --git a/Help/index.rst b/Help/index.rst index 850660e..0d33825 100644 --- a/Help/index.rst +++ b/Help/index.rst @@ -1,30 +1,51 @@ -CMake Reference Documentation -############################# +.. title:: CMake Reference Documentation -.. only:: html - - Reference Manuals: +Command-Line Tools +################## .. toctree:: :maxdepth: 1 - /manual/ccmake.1 /manual/cmake.1 - /manual/cmake-gui.1 - /manual/cpack.1 /manual/ctest.1 + /manual/cpack.1 + +Interactive Dialogs +################### + +.. toctree:: + :maxdepth: 1 + + /manual/cmake-gui.1 + /manual/ccmake.1 + +Reference Manuals +################# + +.. toctree:: + :maxdepth: 1 + /manual/cmake-commands.7 /manual/cmake-generators.7 /manual/cmake-modules.7 /manual/cmake-policies.7 /manual/cmake-properties.7 /manual/cmake-variables.7 - /manual/cmake-generator-expressions.7 + +Other Manuals +############# + +.. toctree:: + :maxdepth: 1 + /manual/cmake-developer.7 + /manual/cmake-generator-expressions.7 + /manual/cmake-language.7 .. only:: html - Index and Search: + Index and Search + ################ * :ref:`genindex` * :ref:`search` diff --git a/Help/manual/LINKS.txt b/Help/manual/LINKS.txt index fcd8533..f6f707d 100644 --- a/Help/manual/LINKS.txt +++ b/Help/manual/LINKS.txt @@ -1,21 +1,25 @@ The following resources are available to get help using CMake: -* ``Home Page``: http://www.cmake.org +Home Page + http://www.cmake.org - The primary starting point for learning about CMake. + The primary starting point for learning about CMake. -* ``Frequently Asked Questions``: http://www.cmake.org/Wiki/CMake_FAQ +Frequently Asked Questions + http://www.cmake.org/Wiki/CMake_FAQ - A Wiki is provided containing answers to frequently asked questions. + A Wiki is provided containing answers to frequently asked questions. -* ``Online Documentation``: http://www.cmake.org/HTML/Documentation.html +Online Documentation + http://www.cmake.org/HTML/Documentation.html - Links to available documentation may be found on this web page. + Links to available documentation may be found on this web page. -* ``Mailing List``: http://www.cmake.org/HTML/MailingLists.html +Mailing List + http://www.cmake.org/HTML/MailingLists.html - For help and discussion about using cmake, a mailing list is - provided at cmake@cmake.org. The list is member-post-only but one - may sign up on the CMake web page. Please first read the full - documentation at http://www.cmake.org before posting questions to - the list. + For help and discussion about using cmake, a mailing list is + provided at cmake@cmake.org. The list is member-post-only but one + may sign up on the CMake web page. Please first read the full + documentation at http://www.cmake.org before posting questions to + the list. diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index 3aded5c..2079c44 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -1,57 +1,64 @@ -* ``-C <initial-cache>``: Pre-load a script to populate the cache. +``-C <initial-cache>`` + Pre-load a script to populate the cache. - When cmake is first run in an empty build tree, it creates a - CMakeCache.txt file and populates it with customizable settings for - the project. This option may be used to specify a file from which - to load cache entries before the first pass through the project's - cmake listfiles. The loaded entries take priority over the - project's default values. The given file should be a CMake script - containing SET commands that use the CACHE option, not a - cache-format file. + When cmake is first run in an empty build tree, it creates a + CMakeCache.txt file and populates it with customizable settings for + the project. This option may be used to specify a file from which + to load cache entries before the first pass through the project's + cmake listfiles. The loaded entries take priority over the + project's default values. The given file should be a CMake script + containing SET commands that use the CACHE option, not a + cache-format file. -* ``-D <var>:<type>=<value>``: Create a cmake cache entry. +``-D <var>:<type>=<value>`` + Create a cmake cache entry. - When cmake is first run in an empty build tree, it creates a - CMakeCache.txt file and populates it with customizable settings for - the project. This option may be used to specify a setting that - takes priority over the project's default value. The option may be - repeated for as many cache entries as desired. + When cmake is first run in an empty build tree, it creates a + CMakeCache.txt file and populates it with customizable settings for + the project. This option may be used to specify a setting that + takes priority over the project's default value. The option may be + repeated for as many cache entries as desired. -* ``-U <globbing_expr>``: Remove matching entries from CMake cache. +``-U <globbing_expr>`` + Remove matching entries from CMake cache. - This option may be used to remove one or more variables from the - CMakeCache.txt file, globbing expressions using * and ? are - supported. The option may be repeated for as many cache entries as - desired. + This option may be used to remove one or more variables from the + CMakeCache.txt file, globbing expressions using * and ? are + supported. The option may be repeated for as many cache entries as + desired. - Use with care, you can make your CMakeCache.txt non-working. + Use with care, you can make your CMakeCache.txt non-working. -* ``-G <generator-name>``: Specify a build system generator. +``-G <generator-name>`` + Specify a build system generator. - CMake may support multiple native build systems on certain - platforms. A generator is responsible for generating a particular - build system. Possible generator names are specified in the - Generators section. + CMake may support multiple native build systems on certain + platforms. A generator is responsible for generating a particular + build system. Possible generator names are specified in the + Generators section. -* ``-T <toolset-name>``: Specify toolset name if supported by generator. +``-T <toolset-name>`` + Specify toolset name if supported by generator. - Some CMake generators support a toolset name to be given to the - native build system to choose a compiler. This is supported only on - specific generators: + Some CMake generators support a toolset name to be given to the + native build system to choose a compiler. This is supported only on + specific generators: - :: + :: - Visual Studio >= 10 - Xcode >= 3.0 + Visual Studio >= 10 + Xcode >= 3.0 - See native build system documentation for allowed toolset names. + See native build system documentation for allowed toolset names. -* ``-Wno-dev``: Suppress developer warnings. +``-Wno-dev`` + Suppress developer warnings. - Suppress warnings that are meant for the author of the - CMakeLists.txt files. + Suppress warnings that are meant for the author of the + CMakeLists.txt files. -* ``-Wdev``: Enable developer warnings. +``-Wdev`` + Enable developer warnings. - Enable warnings that are meant for the author of the CMakeLists.txt - files. + Enable warnings that are meant for the author of the CMakeLists.txt + files. diff --git a/Help/manual/OPTIONS_HELP.txt b/Help/manual/OPTIONS_HELP.txt index baaab0f..631dfef 100644 --- a/Help/manual/OPTIONS_HELP.txt +++ b/Help/manual/OPTIONS_HELP.txt @@ -1,111 +1,130 @@ .. |file| replace:: The help is printed to a named <f>ile if given. -* ``--help,-help,-usage,-h,-H,/?``: Print usage information and exit. +``--help,-help,-usage,-h,-H,/?`` + Print usage information and exit. - Usage describes the basic command line interface and its options. + Usage describes the basic command line interface and its options. -* ``--version,-version,/V [<f>]``: Show program name/version banner and exit. +``--version,-version,/V [<f>]`` + Show program name/version banner and exit. - If a file is specified, the version is written into it. - |file| + If a file is specified, the version is written into it. + |file| -* ``--help-manual <man> [<f>]``: Print one help manual and exit. +``--help-manual <man> [<f>]`` + Print one help manual and exit. - The specified manual is printed in a human-readable text format. - |file| + The specified manual is printed in a human-readable text format. + |file| -* ``--help-manual-list [<f>]``: List help manuals available and exit. +``--help-manual-list [<f>]`` + List help manuals available and exit. - The list contains all manuals for which help may be obtained by - using the ``--help-manual`` option followed by a manual name. - |file| + The list contains all manuals for which help may be obtained by + using the ``--help-manual`` option followed by a manual name. + |file| -* ``--help-command <cmd> [<f>]``: Print help for one command and exit. +``--help-command <cmd> [<f>]`` + Print help for one command and exit. - The :manual:`cmake-commands(7)` manual entry for ``<cmd>`` is - printed in a human-readable text format. - |file| + The :manual:`cmake-commands(7)` manual entry for ``<cmd>`` is + printed in a human-readable text format. + |file| -* ``--help-command-list [<f>]``: List commands with help available and exit. +``--help-command-list [<f>]`` + List commands with help available and exit. - The list contains all commands for which help may be obtained by - using the ``--help-command`` option followed by a command name. - |file| + The list contains all commands for which help may be obtained by + using the ``--help-command`` option followed by a command name. + |file| -* ``--help-commands [<f>]``: Print cmake-commands manual and exit. +``--help-commands [<f>]`` + Print cmake-commands manual and exit. - The :manual:`cmake-commands(7)` manual is printed in a - human-readable text format. - |file| + The :manual:`cmake-commands(7)` manual is printed in a + human-readable text format. + |file| -* ``--help-module <mod> [<f>]``: Print help for one module and exit. +``--help-module <mod> [<f>]`` + Print help for one module and exit. - The :manual:`cmake-modules(7)` manual entry for ``<mod>`` is printed - in a human-readable text format. - |file| + The :manual:`cmake-modules(7)` manual entry for ``<mod>`` is printed + in a human-readable text format. + |file| -* ``--help-module-list [<f>]``: List modules with help available and exit. +``--help-module-list [<f>]`` + List modules with help available and exit. - The list contains all modules for which help may be obtained by - using the ``--help-module`` option followed by a module name. - |file| + The list contains all modules for which help may be obtained by + using the ``--help-module`` option followed by a module name. + |file| -* ``--help-modules [<f>]``: Print cmake-modules manual and exit. +``--help-modules [<f>]`` + Print cmake-modules manual and exit. - The :manual:`cmake-modules(7)` manual is printed in a human-readable - text format. - |file| + The :manual:`cmake-modules(7)` manual is printed in a human-readable + text format. + |file| -* ``--help-policy <cmp> [<f>]``: Print help for one policy and exit. +``--help-policy <cmp> [<f>]`` + Print help for one policy and exit. - The :manual:`cmake-policies(7)` manual entry for ``<cmp>`` is - printed in a human-readable text format. - |file| + The :manual:`cmake-policies(7)` manual entry for ``<cmp>`` is + printed in a human-readable text format. + |file| -* ``--help-policy-list [<f>]``: List policies with help available and exit. +``--help-policy-list [<f>]`` + List policies with help available and exit. - The list contains all policies for which help may be obtained by - using the ``--help-policy`` option followed by a policy name. - |file| + The list contains all policies for which help may be obtained by + using the ``--help-policy`` option followed by a policy name. + |file| -* ``--help-policies [<f>]``: Print cmake-policies manual and exit. +``--help-policies [<f>]`` + Print cmake-policies manual and exit. - The :manual:`cmake-policies(7)` manual is printed in a - human-readable text format. - |file| + The :manual:`cmake-policies(7)` manual is printed in a + human-readable text format. + |file| -* ``--help-property <prop> [<f>]``: Print help for one property and exit. +``--help-property <prop> [<f>]`` + Print help for one property and exit. - The :manual:`cmake-properties(7)` manual entries for ``<prop>`` are - printed in a human-readable text format. - |file| + The :manual:`cmake-properties(7)` manual entries for ``<prop>`` are + printed in a human-readable text format. + |file| -* ``--help-property-list [<f>]``: List properties with help available and exit. +``--help-property-list [<f>]`` + List properties with help available and exit. - The list contains all properties for which help may be obtained by - using the ``--help-property`` option followed by a property name. - |file| + The list contains all properties for which help may be obtained by + using the ``--help-property`` option followed by a property name. + |file| -* ``--help-properties [<f>]``: Print cmake-properties manual and exit. +``--help-properties [<f>]`` + Print cmake-properties manual and exit. - The :manual:`cmake-properties(7)` manual is printed in a - human-readable text format. - |file| + The :manual:`cmake-properties(7)` manual is printed in a + human-readable text format. + |file| -* ``--help-variable <var> [<f>]``: Print help for one variable and exit. +``--help-variable <var> [<f>]`` + Print help for one variable and exit. - The :manual:`cmake-variables(7)` manual entry for ``<var>`` is - printed in a human-readable text format. - |file| + The :manual:`cmake-variables(7)` manual entry for ``<var>`` is + printed in a human-readable text format. + |file| -* ``--help-variable-list [<f>]``: List variables with help available and exit. +``--help-variable-list [<f>]`` + List variables with help available and exit. - The list contains all variables for which help may be obtained by - using the ``--help-variable`` option followed by a variable name. - |file| + The list contains all variables for which help may be obtained by + using the ``--help-variable`` option followed by a variable name. + |file| -* ``--help-variables [<f>]``: Print cmake-variables manual and exit. +``--help-variables [<f>]`` + Print cmake-variables manual and exit. - The :manual:`cmake-variables(7)` manual is printed in a - human-readable text format. - |file| + The :manual:`cmake-variables(7)` manual is printed in a + human-readable text format. + |file| diff --git a/Help/manual/ccmake.1.rst b/Help/manual/ccmake.1.rst index 62a7dcf..a5fe191 100644 --- a/Help/manual/ccmake.1.rst +++ b/Help/manual/ccmake.1.rst @@ -1,13 +1,14 @@ +.. cmake-manual-description: CMake Curses Dialog Command-Line Reference + ccmake(1) ********* Synopsis ======== -:: +.. parsed-literal:: - ccmake <path-to-source> - ccmake <path-to-existing-build> + ccmake [<options>] (<path-to-source> | <path-to-existing-build>) Description =========== @@ -23,6 +24,9 @@ in each directory of a source tree with the name CMakeLists.txt. Users build a project by using CMake to generate a build system for a native tool on their platform. +Options +======= + .. include:: OPTIONS_BUILD.txt .. include:: OPTIONS_HELP.txt diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index 71d7375..fb0d2b5 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Language Command Reference + cmake-commands(7) ***************** @@ -11,6 +13,8 @@ Normal Commands These commands may be used freely in CMake projects. .. toctree:: + :maxdepth: 1 + /command/add_compile_options /command/add_custom_command /command/add_custom_target @@ -103,6 +107,8 @@ These commands are available only for compatibility with older versions of CMake. Do not use them in new code. .. toctree:: + :maxdepth: 1 + /command/build_name /command/exec_program /command/export_library_dependencies @@ -126,6 +132,8 @@ CTest Commands These commands are available only in ctest scripts. .. toctree:: + :maxdepth: 1 + /command/ctest_build /command/ctest_configure /command/ctest_coverage diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 198a240..5857acf 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Developer Reference + cmake-developer(7) ****************** @@ -66,11 +68,21 @@ literal block after ``::`` space. We prefer the ``::`` to appear at the end of a paragraph line instead of as its own line. +``note`` directive + Call out a side note. The command-line help processor prints the + block content as if the lines were normal paragraph text with + interpretation. + ``parsed-literal`` directive Add a literal block with markup interpretation. The command-line help processor prints the block content without the leading directive line and with common indentation replaced by one space. +``productionlist`` directive + Render context-free grammar productions. The command-line help + processor prints the block content as if the lines were normal + paragraph text with interpretation. + ``replace`` directive Define a ``|substitution|`` replacement. The command-line help processor requires a substitution replacement @@ -243,7 +255,8 @@ containing just the line:: The ``cmake-module`` directive will scan the module file to extract reStructuredText markup from comment blocks that start in ``.rst:``. -Add to the top of ``Modules/<module-name>.cmake`` a #-comment of the form: +Add to the top of ``Modules/<module-name>.cmake`` a +:ref:`Line Comment` block of the form: .. code-block:: cmake @@ -253,7 +266,7 @@ Add to the top of ``Modules/<module-name>.cmake`` a #-comment of the form: # # <reStructuredText documentation of module> -or a bracket-comment of the form: +or a :ref:`Bracket Comment` of the form: .. code-block:: cmake diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 849ee36..ddde183 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Generator Expressions + cmake-generator-expressions(7) ****************************** diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index c73d587..ec1f58a 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Generators Reference + cmake-generators(7) ******************* @@ -9,6 +11,8 @@ All Generators ============== .. toctree:: + :maxdepth: 1 + /generator/Borland Makefiles /generator/CodeBlocks - MinGW Makefiles /generator/CodeBlocks - Ninja @@ -30,9 +34,9 @@ All Generators /generator/Sublime Text 2 - NMake Makefiles /generator/Sublime Text 2 - Unix Makefiles /generator/Unix Makefiles - /generator/Visual Studio 10 - /generator/Visual Studio 11 - /generator/Visual Studio 12 + /generator/Visual Studio 10 2010 + /generator/Visual Studio 11 2012 + /generator/Visual Studio 12 2013 /generator/Visual Studio 6 /generator/Visual Studio 7 .NET 2003 /generator/Visual Studio 7 diff --git a/Help/manual/cmake-gui.1.rst b/Help/manual/cmake-gui.1.rst index e773ee1..032b51f 100644 --- a/Help/manual/cmake-gui.1.rst +++ b/Help/manual/cmake-gui.1.rst @@ -1,14 +1,15 @@ +.. cmake-manual-description: CMake GUI Command-Line Reference + cmake-gui(1) ************ Synopsis ======== -:: +.. parsed-literal:: - cmake-gui [options] - cmake-gui [options] <path-to-source> - cmake-gui [options] <path-to-existing-build> + cmake-gui [<options>] + cmake-gui [<options>] (<path-to-source> | <path-to-existing-build>) Description =========== @@ -23,6 +24,9 @@ in each directory of a source tree with the name CMakeLists.txt. Users build a project by using CMake to generate a build system for a native tool on their platform. +Options +======= + .. include:: OPTIONS_HELP.txt See Also diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst new file mode 100644 index 0000000..7285897 --- /dev/null +++ b/Help/manual/cmake-language.7.rst @@ -0,0 +1,470 @@ +.. cmake-manual-description: CMake Language Reference + +cmake-language(7) +***************** + +.. only:: html or latex + + .. contents:: + +Organization +============ + +CMake input files are written in the "CMake Language" in source files +named ``CMakeLists.txt`` or ending in a ``.cmake`` file name extension. + +CMake Language source files in a project are organized into: + +* `Directories`_ (``CMakeLists.txt``), +* `Scripts`_ (``<script>.cmake``), and +* `Modules`_ (``<module>.cmake``). + +Directories +----------- + +When CMake processes a project source tree, the entry point is +a source file called ``CMakeLists.txt`` in the top-level source +directory. This file may contain the entire build specification +or use the :command:`add_subdirectory` command to add subdirectories +to the build. Each subdirectory added by the command must also +contain a ``CMakeLists.txt`` file as the entry point to that +directory. For each source directory whose ``CMakeLists.txt`` file +is processed CMake generates a corresponding directory in the build +tree to act as the default working and output directory. + +Scripts +------- + +An individual ``<script>.cmake`` source file may be processed +in *script mode* by using the :manual:`cmake(1)` command-line tool +with the ``-P`` option. Script mode simply runs the commands in +the given CMake Language source file and does not generate a +build system. It does not allow CMake commands that define build +targets or actions. + +Modules +------- + +CMake Language code in either `Directories`_ or `Scripts`_ may +use the :command:`include` command to load a ``<module>.cmake`` +source file in the scope of the including context. +See the :manual:`cmake-modules(7)` manual page for documentation +of modules included with the CMake distribution. +Project source trees may also provide their own modules and +specify their location(s) in the :variable:`CMAKE_MODULE_PATH` +variable. + +Syntax +====== + +Encoding +-------- + +A CMake Language source file must be written in 7-bit ASCII text +to be portable across all supported platforms. Newlines may be +encoded as either ``\n`` or ``\r\n`` but will be converted to ``\n`` +as input files are read. + +Note that the implementation is 8-bit clean so source files may +be encoded as UTF-8 on platforms with system APIs supporting this +encoding. Furthermore, CMake 3.0 and above allow a leading UTF-8 +`Byte-Order Mark`_ in source files. + +.. _`Byte-Order Mark`: http://en.wikipedia.org/wiki/Byte_order_mark + +Source Files +------------ + +A CMake Language source file consists of zero or more +`Command Invocations`_ separated by newlines and optionally +spaces and `Comments`_: + +.. productionlist:: + file: `file_element`* + file_element: `command_invocation` `line_ending` | + : (`bracket_comment`|`space`)* `line_ending` + line_ending: `line_comment`? `newline` + space: <match '[ \t]+'> + newline: <match '\n'> + +Note that any source file line not inside `Command Arguments`_ or +a `Bracket Comment`_ can end in a `Line Comment`_. + +.. _`Command Invocations`: + +Command Invocations +------------------- + +A *command invocation* is a name followed by paren-enclosed arguments +separated by whitespace: + +.. productionlist:: + command_invocation: `space`* `identifier` `space`* '(' `arguments` ')' + identifier: <match '[A-Za-z_][A-Za-z0-9_]*'> + arguments: `argument`? `separated_arguments`* + separated_arguments: `separation`+ `argument`? | + : `separation`* '(' `arguments` ')' + separation: `space` | `line_ending` + +For example: + +.. code-block:: cmake + + add_executable(hello world.c) + +Command names are case-insensitive. +Nested unquoted parentheses in the arguments must balance. +Each ``(`` or ``)`` is given to the command invocation as +a literal `Unquoted Argument`_. This may be used in calls +to the :command:`if` command to enclose conditions. +For example: + +.. code-block:: cmake + + if(FALSE AND (FALSE OR TRUE)) # evaluates to FALSE + +.. note:: + CMake versions prior to 3.0 require command name identifiers + to be at least 2 characters. + + CMake versions prior to 2.8.12 silently accept an `Unquoted Argument`_ + or a `Quoted Argument`_ immediately following a `Quoted Argument`_ and + not separated by any whitespace. For compatibility, CMake 2.8.12 and + higher accept such code but produce a warning. + +Command Arguments +----------------- + +There are three types of arguments within `Command Invocations`_: + +.. productionlist:: + argument: `bracket_argument` | `quoted_argument` | `unquoted_argument` + +Bracket Argument +^^^^^^^^^^^^^^^^ + +A *bracket argument*, inspired by `Lua`_ long bracket syntax, +encloses content between opening and closing "brackets" of the +same length: + +.. productionlist:: + bracket_argument: `bracket_open` `bracket_content` `bracket_close` + bracket_open: '[' '='{len} '[' + bracket_content: <any text not containing a `bracket_close` + : of the same {len} as the `bracket_open`> + bracket_close: ']' '='{len} ']' + +An opening bracket of length *len >= 0* is written ``[`` followed +by *len* ``=`` followed by ``[`` and the corresponding closing +bracket is written ``]`` followed by *len* ``=`` followed by ``]``. +Brackets do not nest. A unique length may always be chosen +for the opening and closing brackets to contain closing brackets +of other lengths. + +Bracket argument content consists of all text between the opening +and closing brackets, except that one newline immediately following +the opening bracket, if any, is ignored. No evaluation of the +enclosed content, such as `Escape Sequences`_ or `Variable References`_, +is performed. A bracket argument is always given to the command +invocation as exactly one argument. + +For example: + +.. code-block:: cmake + + message([=[ + This is the first line in a bracket argument with bracket length 1. + No \-escape sequences or ${variable} references are evaluated. + This is always one argument even though it contains a ; character. + The text does not end on a closing bracket of length 0 like ]]. + It does end in a closing bracket of length 1. + ]=]) + +.. note:: + CMake versions prior to 3.0 do not support bracket arguments. + They interpret the opening bracket as the start of an + `Unquoted Argument`_. + +.. _`Lua`: http://www.lua.org/ + +Quoted Argument +^^^^^^^^^^^^^^^ + +A *quoted argument* encloses content between opening and closing +double-quote characters: + +.. productionlist:: + quoted_argument: '"' `quoted_element`* '"' + quoted_element: <any character except '\' or '"'> | + : `escape_sequence` | + : `quoted_continuation` + quoted_continuation: '\' `newline` + +Quoted argument content consists of all text between opening and +closing quotes. Both `Escape Sequences`_ and `Variable References`_ +are evaluated. A quoted argument is always given to the command +invocation as exactly one argument. + +For example: + +.. 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. + ") + +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: + +.. 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.\ + ") + +.. note:: + CMake versions prior to 3.0 do not support continuation with ``\``. + They report errors in quoted arguments containing lines ending in + an odd number of ``\`` characters. + +Unquoted Argument +^^^^^^^^^^^^^^^^^ + +An *unquoted argument* is not enclosed by any quoting syntax. +It may not contain any whitespace, ``(``, ``)``, ``#``, ``"``, or ``\`` +except when escaped by a backslash: + +.. productionlist:: + unquoted_argument: `unquoted_element`+ | `unquoted_legacy` + unquoted_element: <any character except whitespace or one of '()#"\'> | + : `escape_sequence` + unquoted_legacy: <see note in text> + +Unquoted argument content consists of all text in a contiguous block +of allowed or escaped characters. Both `Escape Sequences`_ and +`Variable References`_ are evaluated. The resulting value is divided +in the same way `Lists`_ divide into elements. Each non-empty element +is given to the command invocation as an argument. Therefore an +unquoted argument may be given to a command invocation as zero or +more arguments. + +For example: + +.. code-block:: cmake + + foreach(arg + NoSpace + Escaped\ Space + This;Divides;Into;Five;Arguments + Escaped\;Semicolon + ) + message("${arg}") + endforeach() + +.. note:: + To support legacy CMake code, unquoted arguments may also contain + double-quoted strings (``"..."``, possibly enclosing horizontal + whitespace), and make-style variable references (``$(MAKEVAR)``). + Unescaped double-quotes must balance, may not appear at the + beginning of an unquoted argument, and are treated as part of the + content. For example, the unquoted arguments ``-Da="b c"``, + ``-Da=$(v)``, and ``a" "b"c"d`` are each interpreted literally. + + The above "unquoted_legacy" production represents such arguments. + We do not recommend using legacy unquoted arguments in new code. + Instead use a `Quoted Argument`_ or a `Bracket Argument`_ to + represent the content. + +Escape Sequences +---------------- + +An *escape sequence* is a ``\`` followed by one character: + +.. productionlist:: + escape_sequence: `escape_identity` | `escape_encoded` | `escape_semicolon` + escape_identity: '\(' | '\)' | '\#' | '\"' | '\ ' | + : '\\' | '\$' | '\@' | '\^' + escape_encoded: '\t' | '\r' | '\n' + escape_semicolon: '\;' + +A ``\`` followed by one of ``()#" \#@^`` simply encodes the literal +character without interpreting it as syntax. A ``\t``, ``\r``, or ``\n`` +encodes a tab, carriage return, or newline character, respectively. +A ``\;`` encodes itself but may be used in an `Unquoted Argument`_ +to encode the ``;`` without dividing the argument value on it. + +Variable References +------------------- + +A *variable reference* has the form ``${variable_name}`` and is +evaluated inside a `Quoted Argument`_ or an `Unquoted Argument`_. +A variable reference is replaced by the value of the variable, +or by the empty string if the variable is not set. +Variable references can nest and are evaluated from the +inside out, e.g. ``${outer_${inner_variable}_variable}``. + +The `Variables`_ section documents the scope of variable names +and how their values are set. + +Comments +-------- + +A comment starts with a ``#`` character that is not inside a +`Bracket Argument`_, `Quoted Argument`_, or escaped with ``\`` +as part of an `Unquoted Argument`_. There are two types of +comments: a `Bracket Comment`_ and a `Line Comment`_. + +.. _`Bracket Comment`: + +Bracket Comment +^^^^^^^^^^^^^^^ + +A ``#`` immediately followed by a `Bracket Argument`_ forms a +*bracket comment* consisting of the entire bracket enclosure: + +.. productionlist:: + bracket_comment: '#' `bracket_argument` + +For example: + +.. code-block:: cmake + + #[[This is a bracket comment. + It runs until the close bracket.]] + message("First Argument\n" #[[Bracket Comment]] "Second Argument") + +.. note:: + CMake versions prior to 3.0 do not support bracket comments. + They interpret the opening ``#`` as the start of a `Line Comment`_. + +.. _`Line Comment`: + +Line Comment +^^^^^^^^^^^^ + +A ``#`` not immediately followed by a `Bracket Argument`_ forms a +*line comment* that runs until the end of the line: + +.. productionlist:: + line_comment: '#' <any text not starting in a `bracket_argument` + : and not containing a `newline`> + +For example: + +.. code-block:: cmake + + # This is a line comment. + message("First Argument\n" # This is a line comment :) + "Second Argument") # This is a line comment. + +Control Structures +================== + +Conditional Blocks +------------------ + +The :command:`if`/:command:`elseif`/:command:`else`/:command:`endif` +commands delimit code blocks to be executed conditionally. + +Loops +----- + +The :command:`foreach`/:command:`endforeach` and +:command:`while`/:command:`endwhile` commands delimit code +blocks to be executed in a loop. The :command:`break` command +may be used inside such blocks to terminate the loop early. + +Command Definitions +------------------- + +The :command:`macro`/:command:`endmacro`, and +:command:`function`/:command:`endfunction` commands delimit +code blocks to be recorded for later invocation as commands. + +Variables +========= + +Variables are the basic unit of storage in the CMake Language. +Their values are always of string type, though some commands may +interpret the strings as values of other types. +The :command:`set` and :command:`unset` commands explicitly +set or unset a variable, but other commands have semantics +that modify variables as well. +Variable names are case-sensitive and may consist of almost +any text, but we recommend sticking to names consisting only +of alphanumeric characters plus ``_`` and ``-``. + +Variables have dynamic scope. Each variable "set" or "unset" +creates a binding in the current scope: + +Function Scope + `Command Definitions`_ created by the :command:`function` command + create commands that, when invoked, process the recorded commands + in a new variable binding scope. A variable "set" or "unset" + binds in this scope and is visible for the current function and + any nested calls, but not after the function returns. + +Directory Scope + Each of the `Directories`_ in a source tree has its own variable + bindings. Before processing the ``CMakeLists.txt`` file for a + directory, CMake copies all variable bindings currently defined + in the parent directory, if any, to initialize the new directory + scope. CMake `Scripts`_, when processed with ``cmake -P``, bind + variables in one "directory" scope. + + A variable "set" or "unset" not inside a function call binds + to the current directory scope. + +Persistent Cache + CMake stores a separate set of "cache" variables, or "cache entries", + whose values persist across multiple runs within a project build + tree. Cache entries have an isolated binding scope modified only + by explicit request, such as by the ``CACHE`` option of the + :command:`set` and :command:`unset` commands. + +When evaluating `Variable References`_, CMake first searches the +function call stack, if any, for a binding and then falls back +to the binding in the current directory scope, if any. If a +"set" binding is found, its value is used. If an "unset" binding +is found, or no binding is found, CMake then searches for a +cache entry. If a cache entry is found, its value is used. +Otherwise, the variable reference evaluates to an empty string. + +The :manual:`cmake-variables(7)` manual documents many variables +that are provided by CMake or have meaning to CMake when set +by project code. + +Lists +===== + +Although all values in CMake are stored as strings, a string +may be treated as a list in certain contexts, such as during +evaluation of an `Unquoted Argument`_. In such contexts, a string +is divided into list elements by splitting on ``;`` characters not +following an unequal number of ``[`` and ``]`` characters and not +immediately preceded by a ``\``. The sequence ``\;`` does not +divide a value but is replaced by ``;`` in the resulting element. + +A list of elements is represented as a string by concatenating +the elements separated by ``;``. For example, the :command:`set` +command stores multiple values into the destination variable +as a list: + +.. code-block:: cmake + + set(srcs a.c b.c c.c) # sets "srcs" to "a.c;b.c;c.c" + +Lists are meant for simple use cases such as a list of source +files and should not be used for complex data processing tasks. +Most commands that construct lists do not escape ``;`` characters +in list elements, thus flattening nested lists: + +.. code-block:: cmake + + set(x a "b;c") # sets "x" to "a;b;c", not "a;b\;c" diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index da518d3..01efcf7 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Modules Reference + cmake-modules(7) **************** @@ -9,6 +11,8 @@ All Modules =========== .. toctree:: + :maxdepth: 1 + /module/AddFileDependencies /module/BundleUtilities /module/CheckCCompilerFlag diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index fcbccba..2430ee9 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Policies Reference + cmake-policies(7) ***************** @@ -29,6 +31,8 @@ All Policies ============ .. toctree:: + :maxdepth: 1 + /policy/CMP0000 /policy/CMP0001 /policy/CMP0002 @@ -66,3 +70,6 @@ All Policies /policy/CMP0034 /policy/CMP0035 /policy/CMP0036 + /policy/CMP0037 + /policy/CMP0038 + /policy/CMP0039 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index bb3acff..d6d42ad 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Properties Reference + cmake-properties(7) ******************* @@ -9,7 +11,10 @@ Properties of Global Scope ========================== .. toctree:: + :maxdepth: 1 + /prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS + /prop_gbl/AUTOGEN_TARGETS_FOLDER /prop_gbl/AUTOMOC_TARGETS_FOLDER /prop_gbl/DEBUG_CONFIGURATIONS /prop_gbl/DISABLED_FEATURES @@ -36,6 +41,8 @@ Properties on Directories ========================= .. toctree:: + :maxdepth: 1 + /prop_dir/ADDITIONAL_MAKE_CLEAN_FILES /prop_dir/CACHE_VARIABLES /prop_dir/CLEAN_NO_CUSTOM @@ -65,6 +72,8 @@ Properties on Targets ===================== .. toctree:: + :maxdepth: 1 + /prop_tgt/ALIASED_TARGET /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY @@ -72,10 +81,16 @@ Properties on Targets /prop_tgt/ARCHIVE_OUTPUT_NAME /prop_tgt/AUTOMOC_MOC_OPTIONS /prop_tgt/AUTOMOC + /prop_tgt/AUTOUIC + /prop_tgt/AUTOUIC_OPTIONS + /prop_tgt/AUTORCC + /prop_tgt/AUTORCC_OPTIONS /prop_tgt/BUILD_WITH_INSTALL_RPATH /prop_tgt/BUNDLE_EXTENSION /prop_tgt/BUNDLE /prop_tgt/COMPATIBLE_INTERFACE_BOOL + /prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX + /prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN /prop_tgt/COMPATIBLE_INTERFACE_STRING /prop_tgt/COMPILE_DEFINITIONS_CONFIG /prop_tgt/COMPILE_DEFINITIONS @@ -211,6 +226,8 @@ Properties on Tests =================== .. toctree:: + :maxdepth: 1 + /prop_test/ATTACHED_FILES_ON_FAIL /prop_test/ATTACHED_FILES /prop_test/COST @@ -232,7 +249,11 @@ Properties on Source Files ========================== .. toctree:: + :maxdepth: 1 + /prop_sf/ABSTRACT + /prop_sf/AUTOUIC_OPTIONS + /prop_sf/AUTORCC_OPTIONS /prop_sf/COMPILE_DEFINITIONS_CONFIG /prop_sf/COMPILE_DEFINITIONS /prop_sf/COMPILE_FLAGS @@ -254,6 +275,8 @@ Properties on Cache Entries =========================== .. toctree:: + :maxdepth: 1 + /prop_cache/ADVANCED /prop_cache/HELPSTRING /prop_cache/MODIFIED diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 2311ac8..dd82b40 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Variables Reference + cmake-variables(7) ****************** @@ -9,6 +11,8 @@ Variables that Provide Information ================================== .. toctree:: + :maxdepth: 1 + /variable/CMAKE_ARGC /variable/CMAKE_ARGV0 /variable/CMAKE_AR @@ -74,6 +78,8 @@ Variables that Change Behavior ============================== .. toctree:: + :maxdepth: 1 + /variable/BUILD_SHARED_LIBS /variable/CMAKE_ABSOLUTE_DESTINATION_FILES /variable/CMAKE_AUTOMOC_RELAXED_MODE @@ -85,11 +91,15 @@ Variables that Change Behavior /variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName /variable/CMAKE_ERROR_DEPRECATED /variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION + /variable/CMAKE_SYSROOT /variable/CMAKE_FIND_LIBRARY_PREFIXES /variable/CMAKE_FIND_LIBRARY_SUFFIXES /variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE + /variable/CMAKE_FIND_NO_INSTALL_PREFIX /variable/CMAKE_IGNORE_PATH /variable/CMAKE_INCLUDE_PATH + /variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE + /variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE /variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME /variable/CMAKE_INSTALL_PREFIX /variable/CMAKE_LIBRARY_PATH @@ -113,6 +123,8 @@ Variables that Describe the System ================================== .. toctree:: + :maxdepth: 1 + /variable/APPLE /variable/BORLAND /variable/CMAKE_CL_64 @@ -152,9 +164,15 @@ Variables that Control the Build ================================ .. toctree:: + :maxdepth: 1 + /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY /variable/CMAKE_AUTOMOC_MOC_OPTIONS /variable/CMAKE_AUTOMOC + /variable/CMAKE_AUTORCC + /variable/CMAKE_AUTORCC_OPTIONS + /variable/CMAKE_AUTOUIC + /variable/CMAKE_AUTOUIC_OPTIONS /variable/CMAKE_BUILD_WITH_INSTALL_RPATH /variable/CMAKE_CONFIG_POSTFIX /variable/CMAKE_DEBUG_POSTFIX @@ -202,6 +220,8 @@ Variables for Languages ======================= .. toctree:: + :maxdepth: 1 + /variable/CMAKE_COMPILER_IS_GNULANG /variable/CMAKE_Fortran_MODDIR_DEFAULT /variable/CMAKE_Fortran_MODDIR_FLAG @@ -215,6 +235,8 @@ Variables for Languages /variable/CMAKE_LANG_COMPILER_ID /variable/CMAKE_LANG_COMPILER_LOADED /variable/CMAKE_LANG_COMPILER + /variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN + /variable/CMAKE_LANG_COMPILER_TARGET /variable/CMAKE_LANG_COMPILER_VERSION /variable/CMAKE_LANG_CREATE_SHARED_LIBRARY /variable/CMAKE_LANG_CREATE_SHARED_MODULE @@ -245,6 +267,8 @@ Variables for CPack =================== .. toctree:: + :maxdepth: 1 + /variable/CPACK_ABSOLUTE_DESTINATION_FILES /variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY /variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index d2a45aa..d209b8b 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -1,21 +1,25 @@ +.. cmake-manual-description: CMake Command-Line Reference + cmake(1) ******** Synopsis ======== -:: +.. parsed-literal:: - cmake [options] <path-to-source> - cmake [options] <path-to-existing-build> + cmake [<options>] (<path-to-source> | <path-to-existing-build>) + cmake [(-D<var>=<value>)...] -P <cmake-script-file> + cmake --build <dir> [<options>] [-- <build-tool-options>...] + cmake -E <command> [<options>] + cmake --find-package <options>... Description =========== The "cmake" executable is the CMake command-line interface. It may be used to configure projects in scripts. Project configuration settings -may be specified on the command line with the -D option. The -i -option will cause cmake to interactively prompt for such settings. +may be specified on the command line with the -D option. CMake is a cross-platform build system generator. Projects specify their build process with platform-independent CMake listfiles included @@ -23,114 +27,132 @@ in each directory of a source tree with the name CMakeLists.txt. Users build a project by using CMake to generate a build system for a native tool on their platform. +Options +======= + .. include:: OPTIONS_BUILD.txt -* ``-E``: CMake command mode. +``-E`` + CMake command mode. - For true platform independence, CMake provides a list of commands - that can be used on all systems. Run with -E help for the usage - information. Commands available are: chdir, compare_files, copy, - copy_directory, copy_if_different, echo, echo_append, environment, - make_directory, md5sum, remove, remove_directory, rename, tar, time, - touch, touch_nocreate. In addition, some platform specific commands - are available. On Windows: delete_regv, write_regv. On - UNIX: create_symlink. + For true platform independence, CMake provides a list of commands + that can be used on all systems. Run with -E help for the usage + information. Commands available are: chdir, compare_files, copy, + copy_directory, copy_if_different, echo, echo_append, environment, + make_directory, md5sum, remove, remove_directory, rename, tar, time, + touch, touch_nocreate. In addition, some platform specific commands + are available. On Windows: delete_regv, write_regv. On + UNIX: create_symlink. -* ``-L[A][H]``: List non-advanced cached variables. +``-L[A][H]`` + List non-advanced cached variables. - List cache variables will run CMake and list all the variables from - the CMake cache that are not marked as INTERNAL or ADVANCED. This - will effectively display current CMake settings, which can then be - changed with -D option. Changing some of the variables may result - in more variables being created. If A is specified, then it will - display also advanced variables. If H is specified, it will also - display help for each variable. + List cache variables will run CMake and list all the variables from + the CMake cache that are not marked as INTERNAL or ADVANCED. This + will effectively display current CMake settings, which can then be + changed with -D option. Changing some of the variables may result + in more variables being created. If A is specified, then it will + display also advanced variables. If H is specified, it will also + display help for each variable. -* ``--build <dir>``: Build a CMake-generated project binary tree. +``--build <dir>`` + Build a CMake-generated project binary tree. - This abstracts a native build tool's command-line interface with the - following options: + This abstracts a native build tool's command-line interface with the + following options: - :: + :: - <dir> = Project binary directory to be built. - --target <tgt> = Build <tgt> instead of default targets. - --config <cfg> = For multi-configuration tools, choose <cfg>. - --clean-first = Build target 'clean' first, then build. - (To clean only, use --target 'clean'.) - --use-stderr = Ignored. Behavior is default in CMake >= 3.0. - -- = Pass remaining options to the native tool. + <dir> = Project binary directory to be built. + --target <tgt> = Build <tgt> instead of default targets. + --config <cfg> = For multi-configuration tools, choose <cfg>. + --clean-first = Build target 'clean' first, then build. + (To clean only, use --target 'clean'.) + --use-stderr = Ignored. Behavior is default in CMake >= 3.0. + -- = Pass remaining options to the native tool. - Run cmake --build with no options for quick help. + Run cmake --build with no options for quick help. -* ``-N``: View mode only. +``-N`` + View mode only. - Only load the cache. Do not actually run configure and generate - steps. + Only load the cache. Do not actually run configure and generate + steps. -* ``-P <file>``: Process script mode. +``-P <file>`` + Process script mode. - Process the given cmake file as a script written in the CMake - language. No configure or generate step is performed and the cache - is not modified. If variables are defined using -D, this must be - done before the -P argument. + Process the given cmake file as a script written in the CMake + language. No configure or generate step is performed and the cache + is not modified. If variables are defined using -D, this must be + done before the -P argument. -* ``--find-package``: Run in pkg-config like mode. +``--find-package`` + Run in pkg-config like mode. - Search a package using find_package() and print the resulting flags - to stdout. This can be used to use cmake instead of pkg-config to - find installed libraries in plain Makefile-based projects or in - autoconf-based projects (via share/aclocal/cmake.m4). + Search a package using find_package() and print the resulting flags + to stdout. This can be used to use cmake instead of pkg-config to + find installed libraries in plain Makefile-based projects or in + autoconf-based projects (via share/aclocal/cmake.m4). -* ``--graphviz=[file]``: Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more. +``--graphviz=[file]`` + Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more. - Generate a graphviz input file that will contain all the library and - executable dependencies in the project. See the documentation for - CMakeGraphVizOptions.cmake for more details. + Generate a graphviz input file that will contain all the library and + executable dependencies in the project. See the documentation for + CMakeGraphVizOptions.cmake for more details. -* ``--system-information [file]``: Dump information about this system. +``--system-information [file]`` + Dump information about this system. - Dump a wide range of information about the current system. If run - from the top of a binary tree for a CMake project it will dump - additional information such as the cache, log files etc. + Dump a wide range of information about the current system. If run + from the top of a binary tree for a CMake project it will dump + additional information such as the cache, log files etc. -* ``--debug-trycompile``: Do not delete the try_compile build tree. Only useful on one try_compile at a time. +``--debug-trycompile`` + Do not delete the try_compile build tree. Only useful on one try_compile at a time. - Do not delete the files and directories created for try_compile - calls. This is useful in debugging failed try_compiles. It may - however change the results of the try-compiles as old junk from a - previous try-compile may cause a different test to either pass or - fail incorrectly. This option is best used for one try-compile at a - time, and only when debugging. + Do not delete the files and directories created for try_compile + calls. This is useful in debugging failed try_compiles. It may + however change the results of the try-compiles as old junk from a + previous try-compile may cause a different test to either pass or + fail incorrectly. This option is best used for one try-compile at a + time, and only when debugging. -* ``--debug-output``: Put cmake in a debug mode. +``--debug-output`` + Put cmake in a debug mode. - Print extra stuff during the cmake run like stack traces with - message(send_error ) calls. + Print extra stuff during the cmake run like stack traces with + message(send_error ) calls. -* ``--trace``: Put cmake in trace mode. +``--trace`` + Put cmake in trace mode. - Print a trace of all calls made and from where with - message(send_error ) calls. + Print a trace of all calls made and from where with + message(send_error ) calls. -* ``--warn-uninitialized``: Warn about uninitialized values. +``--warn-uninitialized`` + Warn about uninitialized values. - Print a warning when an uninitialized variable is used. + Print a warning when an uninitialized variable is used. -* ``--warn-unused-vars``: Warn about unused variables. +``--warn-unused-vars`` + Warn about unused variables. - Find variables that are declared or set, but not used. + Find variables that are declared or set, but not used. -* ``--no-warn-unused-cli``: Don't warn about command line options. +``--no-warn-unused-cli`` + Don't warn about command line options. - Don't find variables that are declared on the command line, but not - used. + Don't find variables that are declared on the command line, but not + used. -* ``--check-system-vars``: Find problems with variable usage in system files. +``--check-system-vars`` + Find problems with variable usage in system files. - Normally, unused and uninitialized variables are searched for only - in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to - warn about other files as well. + Normally, unused and uninitialized variables are searched for only + in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to + warn about other files as well. .. include:: OPTIONS_HELP.txt diff --git a/Help/manual/cpack.1.rst b/Help/manual/cpack.1.rst index 5c6567c..ba2086e 100644 --- a/Help/manual/cpack.1.rst +++ b/Help/manual/cpack.1.rst @@ -1,12 +1,14 @@ +.. cmake-manual-description: CPack Command-Line Reference + cpack(1) ******** Synopsis ======== -:: +.. parsed-literal:: - cpack -G <generator> [options] + cpack -G <generator> [<options>] Description =========== @@ -22,58 +24,70 @@ in each directory of a source tree with the name CMakeLists.txt. Users build a project by using CMake to generate a build system for a native tool on their platform. +Options +======= -* ``-G <generator>``: Use the specified generator to generate package. +``-G <generator>`` + Use the specified generator to generate package. - CPack may support multiple native packaging systems on certain - platforms. A generator is responsible for generating input files - for particular system and invoking that systems. Possible generator - names are specified in the Generators section. + CPack may support multiple native packaging systems on certain + platforms. A generator is responsible for generating input files + for particular system and invoking that systems. Possible generator + names are specified in the Generators section. -* ``-C <Configuration>``: Specify the project configuration +``-C <Configuration>`` + Specify the project configuration - This option specifies the configuration that the project was build - with, for example 'Debug', 'Release'. + This option specifies the configuration that the project was build + with, for example 'Debug', 'Release'. -* ``-D <var>=<value>``: Set a CPack variable. +``-D <var>=<value>`` + Set a CPack variable. - Set a variable that can be used by the generator. + Set a variable that can be used by the generator. -* ``--config <config file>``: Specify the config file. +``--config <config file>`` + Specify the config file. - Specify the config file to use to create the package. By default - CPackConfig.cmake in the current directory will be used. + Specify the config file to use to create the package. By default + CPackConfig.cmake in the current directory will be used. -* ``--verbose,-V``: enable verbose output +``--verbose,-V`` + enable verbose output - Run cpack with verbose output. + Run cpack with verbose output. -* ``--debug``: enable debug output (for CPack developers) +``--debug`` + enable debug output (for CPack developers) - Run cpack with debug output (for CPack developers). + Run cpack with debug output (for CPack developers). -* ``-P <package name>``: override/define CPACK_PACKAGE_NAME +``-P <package name>`` + override/define CPACK_PACKAGE_NAME - If the package name is not specified on cpack commmand line - thenCPack.cmake defines it as CMAKE_PROJECT_NAME + If the package name is not specified on cpack commmand line + thenCPack.cmake defines it as CMAKE_PROJECT_NAME -* ``-R <package version>``: override/define CPACK_PACKAGE_VERSION +``-R <package version>`` + override/define CPACK_PACKAGE_VERSION - If version is not specified on cpack command line thenCPack.cmake - defines it from CPACK_PACKAGE_VERSION_[MAJOR|MINOR|PATCH]look into - CPack.cmake for detail + If version is not specified on cpack command line thenCPack.cmake + defines it from CPACK_PACKAGE_VERSION_[MAJOR|MINOR|PATCH]look into + CPack.cmake for detail -* ``-B <package directory>``: override/define CPACK_PACKAGE_DIRECTORY +``-B <package directory>`` + override/define CPACK_PACKAGE_DIRECTORY - The directory where CPack will be doing its packaging work.The - resulting package will be found there. Inside this directoryCPack - creates '_CPack_Packages' sub-directory which is theCPack temporary - directory. + The directory where CPack will be doing its packaging work.The + resulting package will be found there. Inside this directoryCPack + creates '_CPack_Packages' sub-directory which is theCPack temporary + directory. -* ``--vendor <vendor name>``: override/define CPACK_PACKAGE_VENDOR +``--vendor <vendor name>`` + override/define CPACK_PACKAGE_VENDOR - If vendor is not specified on cpack command line (or inside - CMakeLists.txt) thenCPack.cmake defines it with a default value + If vendor is not specified on cpack command line (or inside + CMakeLists.txt) thenCPack.cmake defines it with a default value .. include:: OPTIONS_HELP.txt diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index 43fb961..60d08dd 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -1,12 +1,14 @@ +.. cmake-manual-description: CTest Command-Line Reference + ctest(1) ******** Synopsis ======== -:: +.. parsed-literal:: - ctest [options] + ctest [<options>] Description =========== @@ -16,293 +18,350 @@ CMake-generated build trees created for projects that use the ENABLE_TESTING and ADD_TEST commands have testing support. This program will run the tests and report results. +Options +======= -* ``-C <cfg>, --build-config <cfg>``: Choose configuration to test. +``-C <cfg>, --build-config <cfg>`` + Choose configuration to test. - Some CMake-generated build trees can have multiple build - configurations in the same tree. This option can be used to specify - which one should be tested. Example configurations are "Debug" and - "Release". + Some CMake-generated build trees can have multiple build + configurations in the same tree. This option can be used to specify + which one should be tested. Example configurations are "Debug" and + "Release". -* ``-V,--verbose``: Enable verbose output from tests. +``-V,--verbose`` + Enable verbose output from tests. - Test output is normally suppressed and only summary information is - displayed. This option will show all test output. + Test output is normally suppressed and only summary information is + displayed. This option will show all test output. -* ``-VV,--extra-verbose``: Enable more verbose output from tests. +``-VV,--extra-verbose`` + Enable more verbose output from tests. - Test output is normally suppressed and only summary information is - displayed. This option will show even more test output. + Test output is normally suppressed and only summary information is + displayed. This option will show even more test output. -* ``--debug``: Displaying more verbose internals of CTest. +``--debug`` + Displaying more verbose internals of CTest. - This feature will result in a large number of output that is mostly - useful for debugging dashboard problems. + This feature will result in a large number of output that is mostly + useful for debugging dashboard problems. -* ``--output-on-failure``: Output anything outputted by the test program if the test should fail. This option can also be enabled by setting the environment variable CTEST_OUTPUT_ON_FAILURE +``--output-on-failure`` + Output anything outputted by the test program if the test should fail. This option can also be enabled by setting the environment variable CTEST_OUTPUT_ON_FAILURE -* ``-F``: Enable failover. +``-F`` + Enable failover. - This option allows ctest to resume a test set execution that was - previously interrupted. If no interruption occurred, the -F option - will have no effect. + This option allows ctest to resume a test set execution that was + previously interrupted. If no interruption occurred, the -F option + will have no effect. -* ``-j <jobs>, --parallel <jobs>``: Run the tests in parallel using thegiven number of jobs. +``-j <jobs>, --parallel <jobs>`` + Run the tests in parallel using thegiven number of jobs. - This option tells ctest to run the tests in parallel using given - number of jobs. This option can also be set by setting the - environment variable CTEST_PARALLEL_LEVEL. + This option tells ctest to run the tests in parallel using given + number of jobs. This option can also be set by setting the + environment variable CTEST_PARALLEL_LEVEL. -* ``-Q,--quiet``: Make ctest quiet. +``-Q,--quiet`` + Make ctest quiet. - This option will suppress all the output. The output log file will - still be generated if the --output-log is specified. Options such - as --verbose, --extra-verbose, and --debug are ignored if --quiet is - specified. + This option will suppress all the output. The output log file will + still be generated if the --output-log is specified. Options such + as --verbose, --extra-verbose, and --debug are ignored if --quiet is + specified. -* ``-O <file>, --output-log <file>``: Output to log file +``-O <file>, --output-log <file>`` + Output to log file - This option tells ctest to write all its output to a log file. + This option tells ctest to write all its output to a log file. -* ``-N,--show-only``: Disable actual execution of tests. +``-N,--show-only`` + Disable actual execution of tests. - This option tells ctest to list the tests that would be run but not - actually run them. Useful in conjunction with the -R and -E - options. + This option tells ctest to list the tests that would be run but not + actually run them. Useful in conjunction with the -R and -E + options. -* ``-L <regex>, --label-regex <regex>``: Run tests with labels matching regular expression. +``-L <regex>, --label-regex <regex>`` + Run tests with labels matching regular expression. - This option tells ctest to run only the tests whose labels match the - given regular expression. + This option tells ctest to run only the tests whose labels match the + given regular expression. -* ``-R <regex>, --tests-regex <regex>``: Run tests matching regular expression. +``-R <regex>, --tests-regex <regex>`` + Run tests matching regular expression. - This option tells ctest to run only the tests whose names match the - given regular expression. + This option tells ctest to run only the tests whose names match the + given regular expression. -* ``-E <regex>, --exclude-regex <regex>``: Exclude tests matching regular expression. +``-E <regex>, --exclude-regex <regex>`` + Exclude tests matching regular expression. - This option tells ctest to NOT run the tests whose names match the - given regular expression. + This option tells ctest to NOT run the tests whose names match the + given regular expression. -* ``-LE <regex>, --label-exclude <regex>``: Exclude tests with labels matching regular expression. +``-LE <regex>, --label-exclude <regex>`` + Exclude tests with labels matching regular expression. - This option tells ctest to NOT run the tests whose labels match the - given regular expression. + This option tells ctest to NOT run the tests whose labels match the + given regular expression. -* ``-D <dashboard>, --dashboard <dashboard>``: Execute dashboard test +``-D <dashboard>, --dashboard <dashboard>`` + Execute dashboard test - This option tells ctest to act as a Dart client and perform a - dashboard test. All tests are <Mode><Test>, where Mode can be - Experimental, Nightly, and Continuous, and Test can be Start, - Update, Configure, Build, Test, Coverage, and Submit. + This option tells ctest to act as a Dart client and perform a + dashboard test. All tests are <Mode><Test>, where Mode can be + Experimental, Nightly, and Continuous, and Test can be Start, + Update, Configure, Build, Test, Coverage, and Submit. -* ``-D <var>:<type>=<value>``: Define a variable for script mode +``-D <var>:<type>=<value>`` + Define a variable for script mode - Pass in variable values on the command line. Use in conjunction - with -S to pass variable values to a dashboard script. Parsing -D - arguments as variable values is only attempted if the value - following -D does not match any of the known dashboard types. + Pass in variable values on the command line. Use in conjunction + with -S to pass variable values to a dashboard script. Parsing -D + arguments as variable values is only attempted if the value + following -D does not match any of the known dashboard types. -* ``-M <model>, --test-model <model>``: Sets the model for a dashboard +``-M <model>, --test-model <model>`` + Sets the model for a dashboard - This option tells ctest to act as a Dart client where the TestModel - can be Experimental, Nightly, and Continuous. Combining -M and -T - is similar to -D + This option tells ctest to act as a Dart client where the TestModel + can be Experimental, Nightly, and Continuous. Combining -M and -T + is similar to -D -* ``-T <action>, --test-action <action>``: Sets the dashboard action to perform +``-T <action>, --test-action <action>`` + Sets the dashboard action to perform - This option tells ctest to act as a Dart client and perform some - action such as start, build, test etc. Combining -M and -T is - similar to -D + This option tells ctest to act as a Dart client and perform some + action such as start, build, test etc. Combining -M and -T is + similar to -D -* ``--track <track>``: Specify the track to submit dashboard to +``--track <track>`` + Specify the track to submit dashboard to - Submit dashboard to specified track instead of default one. By - default, the dashboard is submitted to Nightly, Experimental, or - Continuous track, but by specifying this option, the track can be - arbitrary. + Submit dashboard to specified track instead of default one. By + default, the dashboard is submitted to Nightly, Experimental, or + Continuous track, but by specifying this option, the track can be + arbitrary. -* ``-S <script>, --script <script>``: Execute a dashboard for a configuration +``-S <script>, --script <script>`` + Execute a dashboard for a configuration - This option tells ctest to load in a configuration script which sets - a number of parameters such as the binary and source directories. - Then ctest will do what is required to create and run a dashboard. - This option basically sets up a dashboard and then runs ctest -D - with the appropriate options. + This option tells ctest to load in a configuration script which sets + a number of parameters such as the binary and source directories. + Then ctest will do what is required to create and run a dashboard. + This option basically sets up a dashboard and then runs ctest -D + with the appropriate options. -* ``-SP <script>, --script-new-process <script>``: Execute a dashboard for a configuration +``-SP <script>, --script-new-process <script>`` + Execute a dashboard for a configuration - This option does the same operations as -S but it will do them in a - separate process. This is primarily useful in cases where the - script may modify the environment and you do not want the modified - environment to impact other -S scripts. + This option does the same operations as -S but it will do them in a + separate process. This is primarily useful in cases where the + script may modify the environment and you do not want the modified + environment to impact other -S scripts. -* ``-A <file>, --add-notes <file>``: Add a notes file with submission +``-A <file>, --add-notes <file>`` + Add a notes file with submission - This option tells ctest to include a notes file when submitting - dashboard. + This option tells ctest to include a notes file when submitting + dashboard. -* ``-I [Start,End,Stride,test#,test#|Test file], --tests-information``: Run a specific number of tests by number. +``-I [Start,End,Stride,test#,test#|Test file], --tests-information`` + Run a specific number of tests by number. - This option causes ctest to run tests starting at number Start, - ending at number End, and incrementing by Stride. Any additional - numbers after Stride are considered individual test numbers. Start, - End,or stride can be empty. Optionally a file can be given that - contains the same syntax as the command line. + This option causes ctest to run tests starting at number Start, + ending at number End, and incrementing by Stride. Any additional + numbers after Stride are considered individual test numbers. Start, + End,or stride can be empty. Optionally a file can be given that + contains the same syntax as the command line. -* ``-U, --union``: Take the Union of -I and -R +``-U, --union`` + Take the Union of -I and -R - When both -R and -I are specified by default the intersection of - tests are run. By specifying -U the union of tests is run instead. + When both -R and -I are specified by default the intersection of + tests are run. By specifying -U the union of tests is run instead. -* ``--rerun-failed``: Run only the tests that failed previously +``--rerun-failed`` + Run only the tests that failed previously - This option tells ctest to perform only the tests that failed during - its previous run. When this option is specified, ctest ignores all - other options intended to modify the list of tests to run (-L, -R, - -E, -LE, -I, etc). In the event that CTest runs and no tests fail, - subsequent calls to ctest with the --rerun-failed option will run - the set of tests that most recently failed (if any). + This option tells ctest to perform only the tests that failed during + its previous run. When this option is specified, ctest ignores all + other options intended to modify the list of tests to run (-L, -R, + -E, -LE, -I, etc). In the event that CTest runs and no tests fail, + subsequent calls to ctest with the --rerun-failed option will run + the set of tests that most recently failed (if any). -* ``--max-width <width>``: Set the max width for a test name to output +``--max-width <width>`` + Set the max width for a test name to output - Set the maximum width for each test name to show in the output. - This allows the user to widen the output to avoid clipping the test - name which can be very annoying. + Set the maximum width for each test name to show in the output. + This allows the user to widen the output to avoid clipping the test + name which can be very annoying. -* ``--interactive-debug-mode [0|1]``: Set the interactive mode to 0 or 1. +``--interactive-debug-mode [0|1]`` + Set the interactive mode to 0 or 1. - This option causes ctest to run tests in either an interactive mode - or a non-interactive mode. On Windows this means that in - non-interactive mode, all system debug pop up windows are blocked. - In dashboard mode (Experimental, Nightly, Continuous), the default - is non-interactive. When just running tests not for a dashboard the - default is to allow popups and interactive debugging. + This option causes ctest to run tests in either an interactive mode + or a non-interactive mode. On Windows this means that in + non-interactive mode, all system debug pop up windows are blocked. + In dashboard mode (Experimental, Nightly, Continuous), the default + is non-interactive. When just running tests not for a dashboard the + default is to allow popups and interactive debugging. -* ``--no-label-summary``: Disable timing summary information for labels. +``--no-label-summary`` + Disable timing summary information for labels. - This option tells ctest not to print summary information for each - label associated with the tests run. If there are no labels on the - tests, nothing extra is printed. + This option tells ctest not to print summary information for each + label associated with the tests run. If there are no labels on the + tests, nothing extra is printed. -* ``--build-and-test``: Configure, build and run a test. +``--build-and-test`` + Configure, build and run a test. - This option tells ctest to configure (i.e. run cmake on), build, - and or execute a test. The configure and test steps are optional. - The arguments to this command line are the source and binary - directories. By default this will run CMake on the Source/Bin - directories specified unless --build-nocmake is specified. Both - --build-makeprogram and --build-generator MUST be provided to use - --build-and-test. If --test-command is specified then that will be - run after the build is complete. Other options that affect this - mode are --build-target --build-nocmake, --build-run-dir, - --build-two-config, --build-exe-dir, - --build-project,--build-noclean, --build-options + This option tells ctest to configure (i.e. run cmake on), build, + and or execute a test. The configure and test steps are optional. + The arguments to this command line are the source and binary + directories. By default this will run CMake on the Source/Bin + directories specified unless --build-nocmake is specified. + The --build-generator option *must* be provided to use + --build-and-test. If --test-command is specified then that will be + run after the build is complete. Other options that affect this + mode are --build-target --build-nocmake, --build-run-dir, + --build-two-config, --build-exe-dir, + --build-project,--build-noclean, --build-options -* ``--build-target``: Specify a specific target to build. +``--build-target`` + Specify a specific target to build. - This option goes with the --build-and-test option, if left out the - all target is built. + This option goes with the --build-and-test option, if left out the + all target is built. -* ``--build-nocmake``: Run the build without running cmake first. +``--build-nocmake`` + Run the build without running cmake first. - Skip the cmake step. + Skip the cmake step. -* ``--build-run-dir``: Specify directory to run programs from. +``--build-run-dir`` + Specify directory to run programs from. - Directory where programs will be after it has been compiled. + Directory where programs will be after it has been compiled. -* ``--build-two-config``: Run CMake twice +``--build-two-config`` + Run CMake twice -* ``--build-exe-dir``: Specify the directory for the executable. +``--build-exe-dir`` + Specify the directory for the executable. -* ``--build-generator``: Specify the generator to use. +``--build-generator`` + Specify the generator to use. -* ``--build-generator-toolset``: Specify the generator-specific toolset. +``--build-generator-toolset`` + Specify the generator-specific toolset. -* ``--build-project``: Specify the name of the project to build. +``--build-project`` + Specify the name of the project to build. -* ``--build-makeprogram``: Specify the make program to use. +``--build-makeprogram`` + Override the make program chosen by CTest with a given one. -* ``--build-noclean``: Skip the make clean step. +``--build-noclean`` + Skip the make clean step. -* ``--build-config-sample``: A sample executable to use to determine the configuration +``--build-config-sample`` + A sample executable to use to determine the configuration - A sample executable to use to determine the configuration that - should be used. e.g. Debug/Release/etc + A sample executable to use to determine the configuration that + should be used. e.g. Debug/Release/etc -* ``--build-options``: Add extra options to the build step. +``--build-options`` + Add extra options to the build step. - This option must be the last option with the exception of - --test-command + This option must be the last option with the exception of + --test-command -* ``--test-command``: The test to run with the --build-and-test option. +``--test-command`` + The test to run with the --build-and-test option. -* ``--test-timeout``: The time limit in seconds, internal use only. +``--test-timeout`` + The time limit in seconds, internal use only. -* ``--tomorrow-tag``: Nightly or experimental starts with next day tag. +``--tomorrow-tag`` + Nightly or experimental starts with next day tag. - This is useful if the build will not finish in one day. + This is useful if the build will not finish in one day. -* ``--ctest-config``: The configuration file used to initialize CTest state when submitting dashboards. +``--ctest-config`` + The configuration file used to initialize CTest state when submitting dashboards. - This option tells CTest to use different initialization file instead - of CTestConfiguration.tcl. This way multiple initialization files - can be used for example to submit to multiple dashboards. + This option tells CTest to use different initialization file instead + of CTestConfiguration.tcl. This way multiple initialization files + can be used for example to submit to multiple dashboards. -* ``--overwrite``: Overwrite CTest configuration option. +``--overwrite`` + Overwrite CTest configuration option. - By default ctest uses configuration options from configuration file. - This option will overwrite the configuration option. + By default ctest uses configuration options from configuration file. + This option will overwrite the configuration option. -* ``--extra-submit <file>[;<file>]``: Submit extra files to the dashboard. +``--extra-submit <file>[;<file>]`` + Submit extra files to the dashboard. - This option will submit extra files to the dashboard. + This option will submit extra files to the dashboard. -* ``--force-new-ctest-process``: Run child CTest instances as new processes +``--force-new-ctest-process`` + Run child CTest instances as new processes - By default CTest will run child CTest instances within the same - process. If this behavior is not desired, this argument will - enforce new processes for child CTest processes. + By default CTest will run child CTest instances within the same + process. If this behavior is not desired, this argument will + enforce new processes for child CTest processes. -* ``--schedule-random``: Use a random order for scheduling tests +``--schedule-random`` + Use a random order for scheduling tests - This option will run the tests in a random order. It is commonly - used to detect implicit dependencies in a test suite. + This option will run the tests in a random order. It is commonly + used to detect implicit dependencies in a test suite. -* ``--submit-index``: Submit individual dashboard tests with specific index +``--submit-index`` + Submit individual dashboard tests with specific index - This option allows performing the same CTest action (such as test) - multiple times and submit all stages to the same dashboard (Dart2 - required). Each execution requires different index. + This option allows performing the same CTest action (such as test) + multiple times and submit all stages to the same dashboard (Dart2 + required). Each execution requires different index. -* ``--timeout <seconds>``: Set a global timeout on all tests. +``--timeout <seconds>`` + Set a global timeout on all tests. - This option will set a global timeout on all tests that do not - already have a timeout set on them. + This option will set a global timeout on all tests that do not + already have a timeout set on them. -* ``--stop-time <time>``: Set a time at which all tests should stop running. +``--stop-time <time>`` + Set a time at which all tests should stop running. - Set a real time of day at which all tests should timeout. Example: - 7:00:00 -0400. Any time format understood by the curl date parser - is accepted. Local time is assumed if no timezone is specified. + Set a real time of day at which all tests should timeout. Example: + 7:00:00 -0400. Any time format understood by the curl date parser + is accepted. Local time is assumed if no timezone is specified. -* ``--http1.0``: Submit using HTTP 1.0. +``--http1.0`` + Submit using HTTP 1.0. - This option will force CTest to use HTTP 1.0 to submit files to the - dashboard, instead of HTTP 1.1. + This option will force CTest to use HTTP 1.0 to submit files to the + dashboard, instead of HTTP 1.1. -* ``--no-compress-output``: Do not compress test output when submitting. +``--no-compress-output`` + Do not compress test output when submitting. - This flag will turn off automatic compression of test output. Use - this to maintain compatibility with an older version of CDash which - doesn't support compressed test output. + This flag will turn off automatic compression of test output. Use + this to maintain compatibility with an older version of CDash which + doesn't support compressed test output. -* ``--print-labels``: Print all available test labels. +``--print-labels`` + Print all available test labels. - This option will not run any tests, it will simply print the list of - all labels associated with the test set. + This option will not run any tests, it will simply print the list of + all labels associated with the test set. .. include:: OPTIONS_HELP.txt diff --git a/Help/policy/CMP0037.rst b/Help/policy/CMP0037.rst new file mode 100644 index 0000000..059b2e6 --- /dev/null +++ b/Help/policy/CMP0037.rst @@ -0,0 +1,26 @@ +CMP0037 +------- + +Target names should not be reserved and should match a validity pattern. + +CMake 2.8.12 and lower allowed creating targets using :command:`add_library`, +:command:`add_executable` and :command:`add_custom_target` with unrestricted +choice for the target name. Newer cmake features such +as :manual:`cmake-generator-expressions(7)` and some +diagnostics expect target names to match a restricted pattern. + +Target names may contain upper and lower case letters, numbers, the underscore +character (_), dot(.), plus(+) and minus(-). As a special case, ALIAS +targets and INTERFACE library targets may contain two consequtive colons. + +Target names reserved by one or more CMake generators are not allowed. +Among others these include "all", "help" and "test". + +The OLD behavior for this policy is to allow creating targets with +reserved names or which do not match the validity pattern. +The NEW behavior for this policy is to report an error +if an add_* command is used with an invalid target name. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/policy/CMP0038.rst b/Help/policy/CMP0038.rst new file mode 100644 index 0000000..e680780 --- /dev/null +++ b/Help/policy/CMP0038.rst @@ -0,0 +1,16 @@ +CMP0038 +------- + +Targets may not link directly to themselves. + +CMake 2.8.12 and lower allowed a build target to link to itself directly with +a :command:`target_link_libraries` call. This is an indicator of a bug in +user code. + +The OLD behavior for this policy is to ignore targets which list themselves +in their own link implementation. The NEW behavior for this policy is to +report an error if a target attempts to link to itself. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/policy/CMP0039.rst b/Help/policy/CMP0039.rst new file mode 100644 index 0000000..fb62eea --- /dev/null +++ b/Help/policy/CMP0039.rst @@ -0,0 +1,17 @@ +CMP0039 +------- + +Utility targets may not have link dependencies. + +CMake 2.8.12 and lower allowed using utility targets in the left hand side +position of the :command:`target_link_libraries` command. This is an indicator +of a bug in user code. + +The OLD behavior for this policy is to ignore attempts to set the link +libraries of utility targets. The NEW behavior for this policy is to +report an error if an attempt is made to set the link libraries of a +utility target. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst b/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst new file mode 100644 index 0000000..48cc8a1 --- /dev/null +++ b/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst @@ -0,0 +1,8 @@ +AUTOGEN_TARGETS_FOLDER +---------------------- + +Name of FOLDER for ``*_automoc`` targets that are added automatically by CMake for targets for which AUTOMOC is enabled. + +If not set, CMake uses the FOLDER property of the parent target as a +default value for this property. See also the documentation for the +FOLDER target property and the AUTOMOC target property. diff --git a/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst b/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst index c83fb8b..185e0ec 100644 --- a/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst +++ b/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst @@ -3,6 +3,8 @@ AUTOMOC_TARGETS_FOLDER Name of FOLDER for ``*_automoc`` targets that are added automatically by CMake for targets for which AUTOMOC is enabled. +This property is obsolete. Use AUTOGEN_TARGETS_FOLDER instead. + If not set, CMake uses the FOLDER property of the parent target as a default value for this property. See also the documentation for the FOLDER target property and the AUTOMOC target property. diff --git a/Help/prop_sf/AUTORCC_OPTIONS.rst b/Help/prop_sf/AUTORCC_OPTIONS.rst new file mode 100644 index 0000000..4b6bb10 --- /dev/null +++ b/Help/prop_sf/AUTORCC_OPTIONS.rst @@ -0,0 +1,14 @@ +AUTORCC_OPTIONS +--------------- + +Additional options for rcc when using autorcc (see the :prop_tgt:`AUTORCC` target +property) + +This property holds additional command line options which will be used when +rcc is executed during the build via autorcc, i.e. it is equivalent to the +optional OPTIONS argument of the qt4_add_resources() macro. + +By default it is empty. + +The options set on the .qrc source file may override :prop_tgt:`AUTORCC_OPTIONS` set +on the target. diff --git a/Help/prop_sf/AUTOUIC_OPTIONS.rst b/Help/prop_sf/AUTOUIC_OPTIONS.rst new file mode 100644 index 0000000..a38b2f8 --- /dev/null +++ b/Help/prop_sf/AUTOUIC_OPTIONS.rst @@ -0,0 +1,14 @@ +AUTOUIC_OPTIONS +--------------- + +Additional options for uic when using autouic (see the :prop_tgt:`AUTOUIC` target property) + +This property holds additional command line options +which will be used when uic is executed during the build via autouic, +i.e. it is equivalent to the optional OPTIONS argument of the +qt4_wrap_ui() macro. + +By default it is empty. + +The options set on the .ui source file may override :prop_tgt:`AUTOUIC_OPTIONS` set +on the target. diff --git a/Help/prop_tgt/AUTORCC.rst b/Help/prop_tgt/AUTORCC.rst new file mode 100644 index 0000000..ef2c9c8 --- /dev/null +++ b/Help/prop_tgt/AUTORCC.rst @@ -0,0 +1,21 @@ + +AUTORCC +------- + +Should the target be processed with autorcc (for Qt projects). + +AUTORCC is a boolean specifying whether CMake will handle +the Qt rcc code generator automatically, i.e. without having to use +the QT4_ADD_RESOURCES() or QT5_ADD_RESOURCES() macro. Currently Qt4 and Qt5 are +supported. + +When this property is set to TRUE, CMake will handle .qrc files added +as target sources at build time and invoke rcc accordingly. +This property is initialized by the value of the :variable:`CMAKE_AUTORCC` +variable if it is set when a target is created. + +Additional command line options for rcc can be set via the +:prop_sf:`AUTORCC_OPTIONS` source file property on the .qrc file. + +The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the +autouic targets together in an IDE, e.g. in MSVS. diff --git a/Help/prop_tgt/AUTORCC_OPTIONS.rst b/Help/prop_tgt/AUTORCC_OPTIONS.rst new file mode 100644 index 0000000..489e277 --- /dev/null +++ b/Help/prop_tgt/AUTORCC_OPTIONS.rst @@ -0,0 +1,17 @@ +AUTORCC_OPTIONS +--------------- + +Additional options for rcc when using autorcc (see the :prop_tgt:`AUTORCC` target property) + +This property holds additional command line options +which will be used when rcc is executed during the build via autorcc, +i.e. it is equivalent to the optional OPTIONS argument of the +qt4_add_resources() macro. + +By default it is empty. + +This property is initialized by the value of the variable +:variable:`CMAKE_AUTORCC` if it is set when a target is created. + +The options set on the target may be overridden by :prop_sf:`AUTORCC_OPTIONS` set +on the .qrc source file. diff --git a/Help/prop_tgt/AUTOUIC.rst b/Help/prop_tgt/AUTOUIC.rst new file mode 100644 index 0000000..548c259 --- /dev/null +++ b/Help/prop_tgt/AUTOUIC.rst @@ -0,0 +1,22 @@ +AUTOUIC +------- + +Should the target be processed with autouic (for Qt projects). + +AUTOUIC is a boolean specifying whether CMake will handle +the Qt uic code generator automatically, i.e. without having to use +the QT4_WRAP_UI() or QT5_WRAP_UI() macro. Currently Qt4 and Qt5 are +supported. + +When this property is set to TRUE, CMake will scan the source files +at build time and invoke uic accordingly. +If an #include statement like #include "ui_foo.h" is found in +foo.cpp, a foo.ui file is expected next to foo.cpp, and uic is +run on the foo.ui file. +This property is initialized by the value of the :variable:`CMAKE_AUTOUIC` +variable if it is set when a target is created. + +Additional command line options for uic can be set via the +:prop_sf:`AUTOUIC_OPTIONS` source file property on the foo.ui file. +The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the +autouic targets together in an IDE, e.g. in MSVS. diff --git a/Help/prop_tgt/AUTOUIC_OPTIONS.rst b/Help/prop_tgt/AUTOUIC_OPTIONS.rst new file mode 100644 index 0000000..c6cf885 --- /dev/null +++ b/Help/prop_tgt/AUTOUIC_OPTIONS.rst @@ -0,0 +1,17 @@ +AUTOUIC_OPTIONS +--------------- + +Additional options for uic when using autouic (see the :prop_tgt:`AUTOUIC` target property) + +This property holds additional command line options +which will be used when uic is executed during the build via autouic, +i.e. it is equivalent to the optional OPTIONS argument of the +qt4_wrap_ui() macro. + +By default it is empty. + +This property is initialized by the value of the variable +:variable:`CMAKE_AUTOUIC` if it is set when a target is created. + +The options set on the target may be overridden by :prop_sf:`AUTOUIC_OPTIONS` set +on the .ui source file. diff --git a/Help/prop_tgt/COMPATIBLE_INTERFACE_BOOL.rst b/Help/prop_tgt/COMPATIBLE_INTERFACE_BOOL.rst index f259940..6cf9d0a 100644 --- a/Help/prop_tgt/COMPATIBLE_INTERFACE_BOOL.rst +++ b/Help/prop_tgt/COMPATIBLE_INTERFACE_BOOL.rst @@ -14,4 +14,6 @@ property is set, then it must have the same boolean value as all others, and if the property is not set, then it is ignored. Note that for each dependee, the set of properties from this property must not intersect with the set of properties from the -COMPATIBLE_INTERFACE_STRING property. +:prop_tgt:`COMPATIBLE_INTERFACE_STRING`, +:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MIN` or +:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MAX` property. diff --git a/Help/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX.rst b/Help/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX.rst new file mode 100644 index 0000000..2fe748e --- /dev/null +++ b/Help/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX.rst @@ -0,0 +1,17 @@ +COMPATIBLE_INTERFACE_NUMBER_MAX +------------------------------- + +Properties whose maximum value from the link interface will be used. + +The COMPATIBLE_INTERFACE_NUMBER_MAX property may contain a list of +properties for this target whose maximum value may be read at generate time +when evaluated in the INTERFACE of all linked dependees. For example, if a +property "FOO" appears in the list, then for each dependee, the +"INTERFACE_FOO" property content in all of its dependencies will be compared +with each other and with the "FOO" property in the depender. When reading +the FOO property at generate time, the maximum value will be returned. +If the property is not set, then it is ignored. Note that for each +dependee, the set of properties from this property must not intersect +with the set of properties from the :prop_tgt:`COMPATIBLE_INTERFACE_BOOL`, +:prop_tgt:`COMPATIBLE_INTERFACE_STRING` or +:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MIN` property. diff --git a/Help/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN.rst b/Help/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN.rst new file mode 100644 index 0000000..7fe384b --- /dev/null +++ b/Help/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN.rst @@ -0,0 +1,17 @@ +COMPATIBLE_INTERFACE_NUMBER_MIN +------------------------------- + +Properties whose maximum value from the link interface will be used. + +The COMPATIBLE_INTERFACE_NUMBER_MIN property may contain a list of +properties for this target whose minimum value may be read at generate time +when evaluated in the INTERFACE of all linked dependees. For example, if a +property "FOO" appears in the list, then for each dependee, the +"INTERFACE_FOO" property content in all of its dependencies will be compared +with each other and with the "FOO" property in the depender. When reading +the FOO property at generate time, the minimum value will be returned. +If the property is not set, then it is ignored. Note that for each +dependee, the set of properties from this property must not intersect +with the set of properties from the :prop_tgt:`COMPATIBLE_INTERFACE_BOOL`, +:prop_tgt:`COMPATIBLE_INTERFACE_STRING` or +:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MAX` property. diff --git a/Help/prop_tgt/COMPATIBLE_INTERFACE_STRING.rst b/Help/prop_tgt/COMPATIBLE_INTERFACE_STRING.rst index 68de2e2..1794d87 100644 --- a/Help/prop_tgt/COMPATIBLE_INTERFACE_STRING.rst +++ b/Help/prop_tgt/COMPATIBLE_INTERFACE_STRING.rst @@ -11,5 +11,6 @@ property "FOO" appears in the list, then for each dependee, the equal with each other, and with the "FOO" property in the depender. If the property is not set, then it is ignored. Note that for each dependee, the set of properties from this property must not intersect -with the set of properties from the COMPATIBLE_INTERFACE_BOOL -property. +with the set of properties from the :prop_tgt:`COMPATIBLE_INTERFACE_BOOL`, +:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MIN` or +:prop_tgt:`COMPATIBLE_INTERFACE_NUMBER_MAX` property. diff --git a/Help/prop_tgt/INCLUDE_DIRECTORIES.rst b/Help/prop_tgt/INCLUDE_DIRECTORIES.rst index 40709a4..cf358b3 100644 --- a/Help/prop_tgt/INCLUDE_DIRECTORIES.rst +++ b/Help/prop_tgt/INCLUDE_DIRECTORIES.rst @@ -5,17 +5,20 @@ List of preprocessor include file search directories. This property specifies the list of directories given so far to the include_directories command. This property exists on directories and -targets. In addition to accepting values from the include_directories +targets. In addition to accepting values from the :command:`include_directories` command, values may be set directly on any directory or any target -using the set_property command. A target gets its initial value for +using the :command:`set_property` command. A target gets its initial value for this property from the value of the directory property. A directory gets its initial value from its parent directory if it has one. Both directory and target property values are adjusted by calls to the -include_directories command. +:command:`include_directories` command. The target property values are used by the generators to set the -include paths for the compiler. See also the include_directories -command. +include paths for the compiler. See also the :command:`include_directories` +and :command:`target_include_directories` commands. + +Relative paths should not be added to this property directly. Use one of +the commands above instead to handle relative paths. Contents of INCLUDE_DIRECTORIES may use "generator expressions" with the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)` manual for diff --git a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst index 24c2441..64ac46e 100644 --- a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst +++ b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst @@ -1,12 +1,12 @@ INTERFACE_LINK_LIBRARIES ------------------------ -List public interface libraries for a shared library or executable. +List public interface libraries for a library. This property contains the list of transitive link dependencies. When the target is linked into another target the libraries listed (and recursively their link interface libraries) will be provided to the -other target also. This property is overriden by the +other target also. This property is overridden by the LINK_INTERFACE_LIBRARIES or LINK_INTERFACE_LIBRARIES_<CONFIG> property if policy CMP0022 is OLD or unset. diff --git a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst index 75c2a31..435e25e 100644 --- a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst +++ b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst @@ -16,7 +16,7 @@ the default set is non-empty. This property is initialized by the value of the variable CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is created. This property is ignored for STATIC libraries. -This property is overriden by the INTERFACE_LINK_LIBRARIES property if +This property is overridden by the INTERFACE_LINK_LIBRARIES property if policy CMP0022 is NEW. This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead. diff --git a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst index 1a7a941..08bd650 100644 --- a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst +++ b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst @@ -7,7 +7,7 @@ This is the configuration-specific version of LINK_INTERFACE_LIBRARIES. If set, this property completely overrides the generic property for the named configuration. -This property is overriden by the INTERFACE_LINK_LIBRARIES property if +This property is overridden by the INTERFACE_LINK_LIBRARIES property if policy CMP0022 is NEW. This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead. diff --git a/Help/variable/CMAKE_AUTORCC.rst b/Help/variable/CMAKE_AUTORCC.rst new file mode 100644 index 0000000..d213993 --- /dev/null +++ b/Help/variable/CMAKE_AUTORCC.rst @@ -0,0 +1,7 @@ +CMAKE_AUTORCC +------------- + +Whether to handle rcc automatically for Qt targets. + +This variable is used to initialize the :prop_tgt:`AUTORCC` property on all the targets. +See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTORCC_OPTIONS.rst b/Help/variable/CMAKE_AUTORCC_OPTIONS.rst new file mode 100644 index 0000000..5efbfa3 --- /dev/null +++ b/Help/variable/CMAKE_AUTORCC_OPTIONS.rst @@ -0,0 +1,7 @@ +CMAKE_AUTORCC_OPTIONS +--------------------- + +Whether to handle rcc automatically for Qt targets. + +This variable is used to initialize the :prop_tgt:`AUTORCC_OPTIONS` property on +all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOUIC.rst b/Help/variable/CMAKE_AUTOUIC.rst new file mode 100644 index 0000000..3b016b0 --- /dev/null +++ b/Help/variable/CMAKE_AUTOUIC.rst @@ -0,0 +1,7 @@ +CMAKE_AUTOUIC +------------- + +Whether to handle uic automatically for Qt targets. + +This variable is used to initialize the :prop_tgt:`AUTOUIC` property on all the targets. +See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst b/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst new file mode 100644 index 0000000..6a88669 --- /dev/null +++ b/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst @@ -0,0 +1,7 @@ +CMAKE_AUTOUIC_OPTIONS +--------------------- + +Whether to handle uic automatically for Qt targets. + +This variable is used to initialize the :prop_tgt:`AUTOUIC_OPTIONS` property on +all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst b/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst index 4015739..05c366a 100644 --- a/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst +++ b/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst @@ -1,11 +1,4 @@ CMAKE_BACKWARDS_COMPATIBILITY ----------------------------- -Version of cmake required to build project - -From the point of view of backwards compatibility, this specifies what -version of CMake should be supported. By default this value is the -version number of CMake that you are running. You can set this to an -older version of CMake to support deprecated commands of CMake in -projects that were written to use older versions of CMake. This can -be set by the user or set at the beginning of a CMakeLists file. +Deprecated. See CMake Policy :policy:`CMP0001` documentation. diff --git a/Help/variable/CMAKE_BUILD_TOOL.rst b/Help/variable/CMAKE_BUILD_TOOL.rst index f0bc938..6133491 100644 --- a/Help/variable/CMAKE_BUILD_TOOL.rst +++ b/Help/variable/CMAKE_BUILD_TOOL.rst @@ -1,11 +1,6 @@ CMAKE_BUILD_TOOL ---------------- -Tool used for the actual build process. - -This variable is set to the program that will be needed to build the -output of CMake. If the generator selected was Visual Studio 6, the -CMAKE_BUILD_TOOL will be set to msdev, for Unix Makefiles it will be -set to make or gmake, and for Visual Studio 7 it set to devenv. For -NMake Makefiles the value is nmake. This can be useful for adding -special flags and commands based on the final build environment. +This variable exists only for backwards compatibility. +It contains the same value as :variable:`CMAKE_MAKE_PROGRAM`. +Use that variable instead. diff --git a/Help/variable/CMAKE_EDIT_COMMAND.rst b/Help/variable/CMAKE_EDIT_COMMAND.rst index 24d26b5..562aa0b 100644 --- a/Help/variable/CMAKE_EDIT_COMMAND.rst +++ b/Help/variable/CMAKE_EDIT_COMMAND.rst @@ -1,7 +1,8 @@ CMAKE_EDIT_COMMAND ------------------ -Full path to cmake-gui or ccmake. +Full path to cmake-gui or ccmake. Defined only for Makefile generators +when not using an "extra" generator for an IDE. This is the full path to the CMake executable that can graphically -edit the cache. For example, cmake-gui, ccmake, or cmake -i. +edit the cache. For example, cmake-gui or ccmake. diff --git a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst new file mode 100644 index 0000000..91231b0 --- /dev/null +++ b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst @@ -0,0 +1,13 @@ +CMAKE_FIND_NO_INSTALL_PREFIX +---------------------------- + +Ignore the :variable:`CMAKE_INSTALL_PREFIX` when searching for assets. + +CMake adds the :variable:`CMAKE_INSTALL_PREFIX` to the +:variable:`CMAKE_SYSTEM_PREFIX_PATH` by default. This variable may be set +on the command line to control that behavior. + +Set :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` to TRUE to tell find_package not +to search in the :variable:`CMAKE_INSTALL_PREFIX` by default. Note that the +prefix may still be searched for other reasons, such as being the same prefix +as the CMake installation, or for being a built-in system prefix. diff --git a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst new file mode 100644 index 0000000..3c1fbcf --- /dev/null +++ b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE.rst @@ -0,0 +1,8 @@ +CMAKE_INCLUDE_DIRECTORIES_BEFORE +-------------------------------- + +Whether to append or prepend directories by default in :command:`include_directories`. + +This variable affects the default behavior of the :command:`include_directories` +command. Setting this variable to 'ON' is equivalent to using the BEFORE option +in all uses of that command. diff --git a/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst new file mode 100644 index 0000000..cbd04d7 --- /dev/null +++ b/Help/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE.rst @@ -0,0 +1,8 @@ +CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE +---------------------------------------- + +Whether to force prepending of project include directories. + +This variable affects the order of include directories generated in compiler +command lines. If set to 'ON', it causes the :variable:`CMAKE_SOURCE_DIR` and +the :variable:`CMAKE_BINARY_DIR` to appear first. diff --git a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst new file mode 100644 index 0000000..86c0b0e --- /dev/null +++ b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst @@ -0,0 +1,13 @@ +CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN +---------------------------------------- + +The external toolchain for cross-compiling, if supported. + +Some compiler toolchains do not ship their own auxilliary utilities such as +archivers and linkers. The compiler driver may support a command-line argument +to specify the location of such tools. CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN +may be set to a path to a path to the external toolchain and will be passed +to the compiler driver if supported. + +This variable may only be set in a toolchain file specified by +the ``CMAKE_TOOLCHAIN_FILE`` variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst b/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst new file mode 100644 index 0000000..7c8efee --- /dev/null +++ b/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst @@ -0,0 +1,11 @@ +CMAKE_<LANG>_COMPILER_TARGET +---------------------------- + +The target for cross-compiling, if supported. + +Some compiler drivers are inherently cross-compilers, such as clang and +QNX qcc. These compiler drivers support a command-line argument to specify +the target to cross-compile for. + +This variable may only be set in a toolchain file specified by +the ``CMAKE_TOOLCHAIN_FILE`` variable. diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst index 8307bc6..0c851ad 100644 --- a/Help/variable/CMAKE_MAKE_PROGRAM.rst +++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst @@ -1,7 +1,51 @@ CMAKE_MAKE_PROGRAM ------------------ -See CMAKE_BUILD_TOOL. +Tool that can launch the native build system. +The value may be the full path to an executable or just the tool +name if it is expected to be in the ``PATH``. -This variable is around for backwards compatibility, see -CMAKE_BUILD_TOOL. +The tool selected depends on the :variable:`CMAKE_GENERATOR` used +to configure the project: + +* The Makefile generators set this to ``make``, ``gmake``, or + a generator-specific tool (e.g. ``nmake`` for "NMake Makefiles"). + + These generators store ``CMAKE_MAKE_PROGRAM`` in the CMake cache + so that it may be edited by the user. + +* The Ninja generator sets this to ``ninja``. + + This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache + so that it may be edited by the user. + +* The Xcode generator sets this to ``xcodebuild`` (or possibly an + otherwise undocumented ``cmakexbuild`` wrapper implementing some + workarounds). + + This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache + so that it may be edited by the user. + +* The Visual Studio generators set this to the full path to + ``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9), + ``VCExpress.exe`` (VS Express 8,9), or ``msdev.exe`` (VS 6). + + These generators prefer to lookup the build tool at build time + rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache + ahead of time. This is because the tools are version-specific + and can be located using the Windows Registry. It is also + necessary because the proper build tool may depend on the + project content (e.g. the Intel Fortran plugin to VS 10 and 11 + requires ``devenv.com`` to build its ``.vfproj`` project files + even though ``MSBuild.exe`` is normally preferred to support + the :variable:`CMAKE_GENERATOR_TOOLSET`). + + For compatibility with versions of CMake prior to 3.0, if + a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to + the CMake cache then CMake will use the specified value if + possible. + +The ``CMAKE_MAKE_PROGRAM`` variable is set for use by project code. +The value is also used by the :manual:`cmake(1)` ``--build`` and +:manual:`ctest(1)` ``--build-and-test`` tools to launch the native +build process. diff --git a/Help/variable/CMAKE_SYSROOT.rst b/Help/variable/CMAKE_SYSROOT.rst new file mode 100644 index 0000000..e42e63a --- /dev/null +++ b/Help/variable/CMAKE_SYSROOT.rst @@ -0,0 +1,12 @@ +CMAKE_SYSROOT +------------- + +Path to pass to the compiler in the ``--sysroot`` flag. + +The ``CMAKE_SYSROOT`` content is passed to the compiler in the ``--sysroot`` +flag, if supported. The path is also stripped from the RPATH/RUNPATH if +necessary on installation. The ``CMAKE_SYSROOT`` is also used to prefix +paths searched by the ``find_*`` commands. + +This variable may only be set in a toolchain file specified by +the ``CMAKE_TOOLCHAIN_FILE`` variable. diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutogenInfo.cmake.in index 9cff735..7554213 100644 --- a/Modules/AutomocInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -1,4 +1,7 @@ set(AM_SOURCES @_moc_files@ ) +set(AM_RCC_SOURCES @_rcc_files@ ) +set(AM_SKIP_MOC @_skip_moc@ ) +set(AM_SKIP_UIC @_skip_uic@ ) set(AM_HEADERS @_moc_headers@ ) set(AM_MOC_COMPILE_DEFINITIONS @_moc_compile_defs@) set(AM_MOC_INCLUDES @_moc_incs@) @@ -7,8 +10,15 @@ set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJ set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/") set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/") set(AM_QT_MOC_EXECUTABLE "@_qt_moc_executable@") +set(AM_QT_UIC_EXECUTABLE "@_qt_uic_executable@") +set(AM_QT_RCC_EXECUTABLE "@_qt_rcc_executable@") set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") set(AM_QT_VERSION_MAJOR "@_target_qt_version@") set(AM_TARGET_NAME @_moc_target_name@) set(AM_RELAXED_MODE "@_moc_relaxed_mode@") +set(AM_UIC_TARGET_OPTIONS @_uic_target_options@) +set(AM_UIC_OPTIONS_FILES @_qt_uic_options_files@) +set(AM_UIC_OPTIONS_OPTIONS @_qt_uic_options_options@) +set(AM_RCC_OPTIONS_FILES @_qt_rcc_options_files@) +set(AM_RCC_OPTIONS_OPTIONS @_qt_rcc_options_options@) diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 3e8d4ff..804cce2 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -55,4 +55,4 @@ set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") @SET_CMAKE_CMCLDEPS_EXECUTABLE@ -@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@ +@SET_CMAKE_CL_SHOWINCLUDES_PREFIX@ diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 871cccd..d53247a 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -228,6 +228,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@ +@CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@ /*--------------------------------------------------------------------------*/ diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 777f007..35aa6c4 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -56,4 +56,4 @@ set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") @SET_CMAKE_CMCLDEPS_EXECUTABLE@ -@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@ +@SET_CMAKE_CL_SHOWINCLUDES_PREFIX@ diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index f32fee0..b5d498d 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -221,6 +221,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@ +@CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST@ /*--------------------------------------------------------------------------*/ diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 45ec95a..9cf3489 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -287,7 +287,6 @@ if(NOT CMAKE_CXX_LINK_EXECUTABLE) endif() mark_as_advanced( -CMAKE_BUILD_TOOL CMAKE_VERBOSE_MAKEFILE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE diff --git a/Modules/CMakeClDeps.cmake b/Modules/CMakeClDeps.cmake index 0214ead..b46e7c2 100644 --- a/Modules/CMakeClDeps.cmake +++ b/Modules/CMakeClDeps.cmake @@ -20,7 +20,7 @@ # in front of each include path, so it can remove it. # -if(MSVC_C_ARCHITECTURE_ID AND CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND) +if(CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND) string(REPLACE "cmake.exe" "cmcldeps.exe" CMAKE_CMCLDEPS_EXECUTABLE ${CMAKE_COMMAND}) set(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes) file(WRITE ${showdir}/foo.h "\n") @@ -30,5 +30,5 @@ if(MSVC_C_ARCHITECTURE_ID AND CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPIL string(REGEX MATCH "\n([^:]*:[^:]*:[ \t]*)" tmp "${outLine}") set(localizedPrefix "${CMAKE_MATCH_1}") set(SET_CMAKE_CMCLDEPS_EXECUTABLE "set(CMAKE_CMCLDEPS_EXECUTABLE \"${CMAKE_CMCLDEPS_EXECUTABLE}\")") - set(SET_CMAKE_CL_SHOWINCLUDE_PREFIX "set(CMAKE_CL_SHOWINCLUDE_PREFIX \"${localizedPrefix}\")") + set(SET_CMAKE_CL_SHOWINCLUDES_PREFIX "set(CMAKE_CL_SHOWINCLUDES_PREFIX \"${localizedPrefix}\")") endif() diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index e945aa7..38a6d35 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -94,12 +94,10 @@ set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS_INIT}" CACHE STRING "Flags used by the linker during the creation of static libraries.") -set(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL - "What is the target build tool cmake is generating for.") - +# Alias the build tool variable for backward compatibility. +set(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM}) mark_as_advanced( -CMAKE_BUILD_TOOL CMAKE_VERBOSE_MAKEFILE CMAKE_EXE_LINKER_FLAGS diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 0fecb5d..247de6f 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -59,10 +59,10 @@ else() get_filename_component(_CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH) if(NOT _CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH) find_program(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER}) - mark_as_advanced(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH) if(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH) set(CMAKE_ASM${ASM_DIALECT}_COMPILER ${CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH} CACHE FILEPATH "Assembler" FORCE) endif() + unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_WITH_PATH CACHE) endif() endif() mark_as_advanced(CMAKE_ASM${ASM_DIALECT}_COMPILER) @@ -167,7 +167,7 @@ set(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}") # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeASM${ASM_DIALECT}Compiler.cmake IMMEDIATE @ONLY) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeASM${ASM_DIALECT}Compiler.cmake @ONLY) set(_CMAKE_ASM_COMPILER) set(_CMAKE_ASM_COMPILER_ARG1) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 8769c66..438a98a 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -92,10 +92,10 @@ else() get_filename_component(_CMAKE_USER_C_COMPILER_PATH "${CMAKE_C_COMPILER}" PATH) if(NOT _CMAKE_USER_C_COMPILER_PATH) find_program(CMAKE_C_COMPILER_WITH_PATH NAMES ${CMAKE_C_COMPILER}) - mark_as_advanced(CMAKE_C_COMPILER_WITH_PATH) if(CMAKE_C_COMPILER_WITH_PATH) set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_WITH_PATH} CACHE STRING "C compiler" FORCE) endif() + unset(CMAKE_C_COMPILER_WITH_PATH CACHE) endif() endif() mark_as_advanced(CMAKE_C_COMPILER) @@ -154,10 +154,16 @@ endif () # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) - if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") + if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang") get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) - if (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-) + elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$") + if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$") + set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) + endif() endif () # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils @@ -176,15 +182,16 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () -include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake) include(CMakeFindBinUtils) if(MSVC_C_ARCHITECTURE_ID) + include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake) set(SET_MSVC_C_ARCHITECTURE_ID "set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})") endif() + # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + @ONLY ) set(CMAKE_C_COMPILER_ENV_VAR "CC") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index c79ba89..5f9d9bf 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -91,10 +91,10 @@ else() get_filename_component(_CMAKE_USER_CXX_COMPILER_PATH "${CMAKE_CXX_COMPILER}" PATH) if(NOT _CMAKE_USER_CXX_COMPILER_PATH) find_program(CMAKE_CXX_COMPILER_WITH_PATH NAMES ${CMAKE_CXX_COMPILER}) - mark_as_advanced(CMAKE_CXX_COMPILER_WITH_PATH) if(CMAKE_CXX_COMPILER_WITH_PATH) set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_WITH_PATH} CACHE STRING "CXX compiler" FORCE) endif() + unset(CMAKE_CXX_COMPILER_WITH_PATH CACHE) endif() endif() mark_as_advanced(CMAKE_CXX_COMPILER) @@ -152,10 +152,16 @@ endif () if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) - if (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-) + elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$") + if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$") + set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) + endif() endif () # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils @@ -175,16 +181,17 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () -include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake) include(CMakeFindBinUtils) if(MSVC_CXX_ARCHITECTURE_ID) + include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake) set(SET_MSVC_CXX_ARCHITECTURE_ID "set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})") endif() + # configure all variables set in this file configure_file(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + @ONLY ) set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 6fccb16..efb06c0 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -67,12 +67,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() # Check if compiler id detection gave us the compiler tool. - if(NOT CMAKE_${lang}_COMPILER) - if(CMAKE_${lang}_COMPILER_ID_TOOL) - set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE) - else() - set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE) - endif() + if(CMAKE_${lang}_COMPILER_ID_TOOL) + set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE) + elseif(NOT CMAKE_${lang}_COMPILER) + set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE) endif() set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) @@ -87,7 +85,9 @@ endfunction() #----------------------------------------------------------------------------- # Function to write the compiler id source file. function(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src) - file(READ ${CMAKE_ROOT}/Modules/${src}.in ID_CONTENT_IN) + find_file(src_in ${src}.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + file(READ ${src_in} ID_CONTENT_IN) + unset(src_in CACHE) string(CONFIGURE "${ID_CONTENT_IN}" ID_CONTENT_OUT @ONLY) file(WRITE ${CMAKE_${lang}_COMPILER_ID_DIR}/${src} "${ID_CONTENT_OUT}") endfunction() @@ -164,7 +164,7 @@ Id flags: ${testflags} set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) get_filename_component(id_src "${src}" NAME) configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in - ${id_dir}/CompilerId${lang}.${ext} @ONLY IMMEDIATE) + ${id_dir}/CompilerId${lang}.${ext} @ONLY) execute_process( COMMAND ${CMAKE_MAKE_PROGRAM} CompilerId${lang}.${ext} ${build} WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} @@ -202,7 +202,7 @@ Id flags: ${testflags} set(ext xcode) endif() configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in - ${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY IMMEDIATE) + ${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY) unset(_ENV_MACOSX_DEPLOYMENT_TARGET) if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET}) set(_ENV_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}") diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 13cfb00..8e2065d 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -109,11 +109,11 @@ else() get_filename_component(_CMAKE_USER_Fortran_COMPILER_PATH "${CMAKE_Fortran_COMPILER}" PATH) if(NOT _CMAKE_USER_Fortran_COMPILER_PATH) find_program(CMAKE_Fortran_COMPILER_WITH_PATH NAMES ${CMAKE_Fortran_COMPILER}) - mark_as_advanced(CMAKE_Fortran_COMPILER_WITH_PATH) if(CMAKE_Fortran_COMPILER_WITH_PATH) set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER_WITH_PATH} CACHE STRING "Fortran compiler" FORCE) endif() + unset(CMAKE_Fortran_COMPILER_WITH_PATH CACHE) endif() endif() mark_as_advanced(CMAKE_Fortran_COMPILER) @@ -222,6 +222,6 @@ endif() # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + @ONLY ) set(CMAKE_Fortran_COMPILER_ENV_VAR "FC") diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index ae9f5fc..7ae7856 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -100,5 +100,5 @@ mark_as_advanced(CMAKE_Java_COMPILER) # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeJavaCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeJavaCompiler.cmake IMMEDIATE @ONLY) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeJavaCompiler.cmake @ONLY) set(CMAKE_Java_COMPILER_ENV_VAR "JAVA_COMPILER") diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index c4600c7..f23846e 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -63,5 +63,5 @@ endif() # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeRCCompiler.cmake IMMEDIATE) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeRCCompiler.cmake) set(CMAKE_RC_COMPILER_ENV_VAR "RC") diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 3a95d2a..7756273 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -181,6 +181,6 @@ if(CMAKE_BINARY_DIR) # configure variables set in this file for fast reload, the template file is defined at the top of this file configure_file(${CMAKE_ROOT}/Modules/CMakeSystem.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeSystem.cmake - IMMEDIATE @ONLY) + @ONLY) endif() diff --git a/Modules/CMakeExportBuildSettings.cmake b/Modules/CMakeExportBuildSettings.cmake index a18f950..90a7a89 100644 --- a/Modules/CMakeExportBuildSettings.cmake +++ b/Modules/CMakeExportBuildSettings.cmake @@ -29,7 +29,7 @@ endif() macro(CMAKE_EXPORT_BUILD_SETTINGS SETTINGS_FILE) if(${SETTINGS_FILE} MATCHES ".+") configure_file(${CMAKE_ROOT}/Modules/CMakeBuildSettings.cmake.in - ${SETTINGS_FILE} @ONLY IMMEDIATE) + ${SETTINGS_FILE} @ONLY) else() message(SEND_ERROR "CMAKE_EXPORT_BUILD_SETTINGS called with no argument.") endif() diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 315d57e..829b6ff 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -43,7 +43,12 @@ if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC" # in all other cases search for ar, ranlib, etc. else() - + if(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN) + set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}/bin) + endif() + if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) + set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}/bin) + endif() find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 2c75147..d133042 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -78,7 +78,7 @@ else() configure_file( ${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + @ONLY ) include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index a5cdf56..a06c92a 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -71,7 +71,7 @@ else() configure_file( ${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + @ONLY ) include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index b9e77c5..b50e832 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -98,7 +98,7 @@ else() configure_file( ${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + @ONLY ) include(${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake) diff --git a/Modules/CMakeVS10FindMake.cmake b/Modules/CMakeVS10FindMake.cmake deleted file mode 100644 index 189b626..0000000 --- a/Modules/CMakeVS10FindMake.cmake +++ /dev/null @@ -1,54 +0,0 @@ - -#============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Look for devenv as a build program. We need to use this to support -# Intel Fortran integration into VS. MSBuild can not be used for that case -# since Intel Fortran uses the older devenv file format. -find_program(CMAKE_MAKE_PROGRAM - NAMES devenv - HINTS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;EnvironmentDirectory] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup;Dbghelp_path] - "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio10.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio 10/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio10/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 10.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio10.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 10/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio10/Common7/IDE" - "/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/" - "/Program Files/Microsoft Visual Studio 10/Common7/IDE/" - ) - -# if devenv is not found, then use MSBuild. -# it is expected that if devenv is not found, then we are -# dealing with Visual Studio Express. VCExpress has random -# failures when being run as a command line build tool which -# causes the compiler checks and try-compile stuff to fail. MSbuild -# is a better choice for this. However, VCExpress does not support -# cross compiling needed for Win CE. -if(NOT CMAKE_CROSSCOMPILING) - find_program(CMAKE_MAKE_PROGRAM - NAMES MSBuild - HINTS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;ProductDir] - "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" - "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" - "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0;CLR Version]/") -endif() - -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC10 1) -set(MSVC_VERSION 1600) diff --git a/Modules/CMakeVS11FindMake.cmake b/Modules/CMakeVS11FindMake.cmake deleted file mode 100644 index 2df015d..0000000 --- a/Modules/CMakeVS11FindMake.cmake +++ /dev/null @@ -1,53 +0,0 @@ - -#============================================================================= -# Copyright 2007-2011 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Look for devenv as a build program. We need to use this to support -# Intel Fortran integration into VS. MSBuild can not be used for that case -# since Intel Fortran uses the older devenv file format. -find_program(CMAKE_MAKE_PROGRAM - NAMES devenv - HINTS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;EnvironmentDirectory] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup;Dbghelp_path] - "$ENV{ProgramFiles}/Microsoft Visual Studio 11.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio11.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio 11/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio11/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 11.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio11.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 11/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio11/Common7/IDE" - "/Program Files/Microsoft Visual Studio 11.0/Common7/IDE/" - "/Program Files/Microsoft Visual Studio 11/Common7/IDE/" - ) - -# if devenv is not found, then use MSBuild. -# it is expected that if devenv is not found, then we are -# dealing with Visual Studio Express. -if(NOT CMAKE_CROSSCOMPILING) - set(_FDIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;FrameworkDir32]") - set(_FVER "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;FrameworkVer32]") - find_program(CMAKE_MAKE_PROGRAM - NAMES MSBuild - HINTS - ${_FDIR}/${_FVER} - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] - "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;CLR Version]/" - "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;CLR Version]/" - "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0;CLR Version]/") -endif() - -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC11 1) -set(MSVC_VERSION 1700) diff --git a/Modules/CMakeVS12FindMake.cmake b/Modules/CMakeVS12FindMake.cmake deleted file mode 100644 index 338d9a2..0000000 --- a/Modules/CMakeVS12FindMake.cmake +++ /dev/null @@ -1,27 +0,0 @@ - -#============================================================================= -# Copyright 2007-2013 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Always use MSBuild because: -# - devenv treats command-line builds as recently-loaded projects in the IDE -# - devenv does not appear to support non-standard platform toolsets -# If we need devenv for Intel Fortran in the future we should add -# a special case when Fortran is enabled. -find_program(CMAKE_MAKE_PROGRAM - NAMES MSBuild - HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\12.0;MSBuildToolsPath]" - ) - -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC12 1) -set(MSVC_VERSION 1800) diff --git a/Modules/CMakeVS6FindMake.cmake b/Modules/CMakeVS6FindMake.cmake deleted file mode 100644 index 40bf5b1..0000000 --- a/Modules/CMakeVS6FindMake.cmake +++ /dev/null @@ -1,25 +0,0 @@ - -#============================================================================= -# Copyright 2002-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_program(CMAKE_MAKE_PROGRAM - NAMES msdev - PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup;VsCommonDir]/MSDev98/Bin - "c:/Program Files/Microsoft Visual Studio/Common/MSDev98/Bin" - "c:/Program Files/Microsoft Visual Studio/Common/MSDev98/Bin" - "/Program Files/Microsoft Visual Studio/Common/MSDev98/Bin" - ) -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC60 1) -set(MSVC_VERSION 1200) diff --git a/Modules/CMakeVS71FindMake.cmake b/Modules/CMakeVS71FindMake.cmake deleted file mode 100644 index 945c3fa..0000000 --- a/Modules/CMakeVS71FindMake.cmake +++ /dev/null @@ -1,26 +0,0 @@ - -#============================================================================= -# Copyright 2003-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_program(CMAKE_MAKE_PROGRAM - NAMES devenv - PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VS;EnvironmentDirectory] - "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE" - "c:/Program Files/Microsoft Visual Studio .NET/Common7/IDE" - "c:/Program Files/Microsoft Visual Studio.NET/Common7/IDE" - "/Program Files/Microsoft Visual Studio .NET/Common7/IDE/" - ) -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC71 1) -set(MSVC_VERSION 1310) diff --git a/Modules/CMakeVS7FindMake.cmake b/Modules/CMakeVS7FindMake.cmake deleted file mode 100644 index 218c5f2..0000000 --- a/Modules/CMakeVS7FindMake.cmake +++ /dev/null @@ -1,25 +0,0 @@ - -#============================================================================= -# Copyright 2002-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_program(CMAKE_MAKE_PROGRAM - NAMES devenv - PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0\\Setup\\VS;EnvironmentDirectory] - "c:/Program Files/Microsoft Visual Studio .NET/Common7/IDE" - "c:/Program Files/Microsoft Visual Studio.NET/Common7/IDE" - "/Program Files/Microsoft Visual Studio .NET/Common7/IDE/" - ) -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC70 1) -set(MSVC_VERSION 1300) diff --git a/Modules/CMakeVS8FindMake.cmake b/Modules/CMakeVS8FindMake.cmake deleted file mode 100644 index 31df026..0000000 --- a/Modules/CMakeVS8FindMake.cmake +++ /dev/null @@ -1,34 +0,0 @@ - -#============================================================================= -# Copyright 2004-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# VCExpress does not support cross compiling, which is necessary for Win CE -set( _CMAKE_MAKE_PROGRAM_NAMES devenv) -if(NOT CMAKE_CROSSCOMPILING) - set( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress) -endif() - -find_program(CMAKE_MAKE_PROGRAM - NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} - HINTS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VS;EnvironmentDirectory] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path] - "$ENV{ProgramFiles}/Microsoft Visual Studio 8/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio8/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 8/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio8/Common7/IDE" - "/Program Files/Microsoft Visual Studio 8/Common7/IDE/" - ) -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC80 1) -set(MSVC_VERSION 1400) diff --git a/Modules/CMakeVS9FindMake.cmake b/Modules/CMakeVS9FindMake.cmake deleted file mode 100644 index 35e9f98..0000000 --- a/Modules/CMakeVS9FindMake.cmake +++ /dev/null @@ -1,39 +0,0 @@ - -#============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# VCExpress does not support cross compiling, which is necessary for Win CE -set( _CMAKE_MAKE_PROGRAM_NAMES devenv) -if(NOT CMAKE_CROSSCOMPILING) - set( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress) -endif() - -find_program(CMAKE_MAKE_PROGRAM - NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} - HINTS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VS;EnvironmentDirectory] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup;Dbghelp_path] - "$ENV{ProgramFiles}/Microsoft Visual Studio 9.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio9.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio 9/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio9/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 9.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio9.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 9/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio9/Common7/IDE" - "/Program Files/Microsoft Visual Studio 9.0/Common7/IDE/" - "/Program Files/Microsoft Visual Studio 9/Common7/IDE/" - ) -mark_as_advanced(CMAKE_MAKE_PROGRAM) -set(MSVC90 1) -set(MSVC_VERSION 1500) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index da6b2e0..ccc36eb 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -416,7 +416,7 @@ if(NOT CPACK_GENERATOR) if(APPLE) option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF) option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF) - option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON) + option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF) option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF) else() option(CPACK_BINARY_TZ "Enable to build TZ packages" ON) @@ -519,6 +519,11 @@ cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "") # WiX specific variables cpack_set_if_not_set(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}") +# set sysroot so SDK tools can be used +if(CMAKE_OSX_SYSROOT) + cpack_set_if_not_set(CPACK_OSX_SYSROOT "${CMAKE_OSX_SYSROOT}") +endif() + if(DEFINED CPACK_COMPONENTS_ALL) if(CPACK_MONOLITHIC_INSTALL) message("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.") @@ -553,7 +558,7 @@ set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE) set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE) cpack_encode_variables() -configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE) +configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY) # Generate source file cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES @@ -573,4 +578,4 @@ set(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}") cpack_encode_variables() configure_file("${cpack_source_input_file}" - "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE) + "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY) diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake index a55a01e..aff8764 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -375,17 +375,17 @@ endmacro() # Macro that adds a component to the CPack installer macro(cpack_add_component compname) - string(TOUPPER ${compname} CPACK_ADDCOMP_UNAME) - cpack_parse_arguments(CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME} + string(TOUPPER ${compname} _CPACK_ADDCOMP_UNAME) + cpack_parse_arguments(CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME} "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE" "HIDDEN;REQUIRED;DISABLED;DOWNLOADED" ${ARGN} ) - if (CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED) - set(CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n") + if (CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DOWNLOADED) + set(_CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n") else () - set(CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n") + set(_CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n") endif () if(NOT CPACK_MONOLITHIC_INSTALL) @@ -394,51 +394,51 @@ macro(cpack_add_component compname) # take care of any components that have been added after the CPack # moduled was included. if(NOT CPACK_COMPONENTS_ALL_SET_BY_USER) - get_cmake_property(CPACK_ADDCOMP_COMPONENTS COMPONENTS) - set(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL") - foreach(COMP ${CPACK_ADDCOMP_COMPONENTS}) - set(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR} ${COMP}") + get_cmake_property(_CPACK_ADDCOMP_COMPONENTS COMPONENTS) + set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL") + foreach(COMP ${_CPACK_ADDCOMP_COMPONENTS}) + set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR} ${COMP}") endforeach() - set(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR})\n") + set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR})\n") endif() endif() cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISPLAY_NAME - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DISPLAY_NAME + _CPACK_ADDCOMP_STR) cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DESCRIPTION - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DESCRIPTION + _CPACK_ADDCOMP_STR) cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_GROUP - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_GROUP + _CPACK_ADDCOMP_STR) cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DEPENDS - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DEPENDS + _CPACK_ADDCOMP_STR) cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_INSTALL_TYPES - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_INSTALL_TYPES + _CPACK_ADDCOMP_STR) cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_HIDDEN - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_HIDDEN + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_REQUIRED - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_REQUIRED + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISABLED - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DISABLED + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DOWNLOADED + _CPACK_ADDCOMP_STR) # Backward compatibility issue. # Write to config iff the macros is used after CPack.cmake has been # included, other it's not necessary because the variables # will be encoded by cpack_encode_variables. if(CPack_CMake_INCLUDED) - file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDCOMP_STR}") + file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_ADDCOMP_STR}") endif() endmacro() diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index f4fcf6a..3f0978d 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -123,9 +123,31 @@ # This variable provides an optional list of extra WiX object (.wixobj) # and/or WiX library (.wixlib) files. The full path to objects and libraries # is required. +# +# .. variable:: CPACK_WIX_EXTENSIONS +# +# This variable provides a list of additional extensions for the WiX +# tools light and candle. +# +# .. variable:: CPACK_WIX_<TOOL>_EXTENSIONS +# +# This is the tool specific version of CPACK_WIX_EXTENSIONS. +# ``<TOOL>`` can be either LIGHT or CANDLE. +# +# .. variable:: CPACK_WIX_<TOOL>_EXTRA_FLAGS +# +# This list variable allows you to pass additional +# flags to the WiX tool ``<TOOL>``. +# +# Use it at your own risk. +# Future versions of CPack may generate flags which may be in conflict +# with your own flags. +# +# ``<TOOL>`` can be either LIGHT or CANDLE. +# #============================================================================= -# Copyright 2012 Kitware, Inc. +# Copyright 2013 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 643cd29..7759ead 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -149,6 +149,7 @@ if(BUILD_TESTING) find_program(BZRCOMMAND bzr) find_program(HGCOMMAND hg) find_program(GITCOMMAND git) + find_program(P4COMMAND p4) if(NOT UPDATE_TYPE) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CVS") @@ -180,6 +181,9 @@ if(BUILD_TESTING) elseif("${_update_type}" STREQUAL "git") set(UPDATE_COMMAND "${GITCOMMAND}") set(UPDATE_OPTIONS "${GIT_UPDATE_OPTIONS}") + elseif("${_update_type}" STREQUAL "p4") + set(UPDATE_COMMAND "${P4COMMAND}") + set(UPDATE_OPTIONS "${P4_UPDATE_OPTIONS}") endif() set(DART_TESTING_TIMEOUT 1500 CACHE STRING @@ -240,7 +244,7 @@ if(BUILD_TESTING) "${CMAKE_CXX_COMPILER}" ${DART_NAME_COMPONENT}) else() get_filename_component(DART_CXX_NAME - "${CMAKE_BUILD_TOOL}" ${DART_NAME_COMPONENT}) + "${CMAKE_MAKE_PROGRAM}" ${DART_NAME_COMPONENT}) endif() if(DART_CXX_NAME MATCHES "msdev") set(DART_CXX_NAME "vs60") @@ -275,6 +279,7 @@ if(BUILD_TESTING) CVS_UPDATE_OPTIONS DART_TESTING_TIMEOUT GITCOMMAND + P4COMMAND HGCOMMAND MAKECOMMAND MEMORYCHECK_COMMAND diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 2d0edf9..9dc1648 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -48,7 +48,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c IMMEDIATE) + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c) message(STATUS "Looking for ${INCLUDE}") if(${ARGC} EQUAL 3) set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS}) diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index 7a86be5..fa36a3f 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -52,7 +52,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx IMMEDIATE) + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) message(STATUS "Looking for C++ include ${INCLUDE}") if(${ARGC} EQUAL 3) set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 75bf27c..182067f 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -54,7 +54,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) set(CMAKE_CONFIGURABLE_FILE_CONTENT "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n\nint main(){return 0;}\n") configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c" @ONLY IMMEDIATE) + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c" @ONLY) set(_INCLUDE ${INCLUDE}) # remove empty elements if("${_INCLUDE}" MATCHES "^([^;]+);.+;([^;]+)$") diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index eeac4c9..e1ca412 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -72,7 +72,7 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n") configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${SOURCEFILE}" @ONLY IMMEDIATE) + "${SOURCEFILE}" @ONLY) message(STATUS "Looking for ${SYMBOL}") try_compile(${VARIABLE} diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 7d7be5c..055aad6 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -30,5 +30,7 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") + set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "-gcc-toolchain ") endmacro() endif() diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 504704d..f01255c 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -30,6 +30,7 @@ macro(__compiler_gnu lang) endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=") # Older versions of gcc (< 4.5) contain a bug causing them to report a missing # header file as a warning if depfiles are enabled, causing check_header_file diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 5b43db9..7d98f03 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -6,6 +6,8 @@ set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") +set(CMAKE_DEPFILE_FLAGS_C "-MMD -MT <OBJECT> -MF <DEPFILE>") + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") endif() diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 35bb3ec..36a838d 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -6,6 +6,8 @@ set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") +set(CMAKE_DEPFILE_FLAGS_CXX "-MMD -MT <OBJECT> -MF <DEPFILE>") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") endif() diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 9e49ac7..68fadf6 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -52,6 +52,13 @@ GITCommand: @GITCOMMAND@ GITUpdateOptions: @GIT_UPDATE_OPTIONS@ GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@ +# Perforce options +P4Command: @P4COMMAND@ +P4Client: @CTEST_P4_CLIENT@ +P4Options: @CTEST_P4_OPTIONS@ +P4UpdateOptions: @CTEST_P4_UPDATE_OPTIONS@ +P4UpdateCustom: @CTEST_P4_UPDATE_CUSTOM@ + # Generic update command UpdateCommand: @UPDATE_COMMAND@ UpdateOptions: @UPDATE_OPTIONS@ diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 86a42ae..1e2698c 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -7,186 +7,178 @@ # Use this module to unambiguously reference data files stored outside # the source tree and fetch them at build time from arbitrary local and # remote content-addressed locations. Functions provided by this module -# recognize arguments with the syntax "DATA{<name>}" as references to +# recognize arguments with the syntax ``DATA{<name>}`` as references to # external data, replace them with full paths to local copies of those # data, and create build rules to fetch and update the local copies. # -# The DATA{} syntax is literal and the <name> is a full or relative path +# The ``DATA{}`` syntax is literal and the ``<name>`` is a full or relative path # within the source tree. The source tree must contain either a real -# data file at <name> or a "content link" at <name><ext> containing a -# hash of the real file using a hash algorithm corresponding to <ext>. -# For example, the argument "DATA{img.png}" may be satisfied by either a -# real "img.png" file in the current source directory or a "img.png.md5" +# data file at ``<name>`` or a "content link" at ``<name><ext>`` containing a +# hash of the real file using a hash algorithm corresponding to ``<ext>``. +# For example, the argument ``DATA{img.png}`` may be satisfied by either a +# real ``img.png`` file in the current source directory or a ``img.png.md5`` # file containing its MD5 sum. # -# The 'ExternalData_Expand_Arguments' function evaluates DATA{} +# The ``ExternalData_Expand_Arguments`` function evaluates ``DATA{}`` # references in its arguments and constructs a new list of arguments: # -# :: +# .. code-block:: cmake # -# ExternalData_Expand_Arguments( -# <target> # Name of data management target -# <outVar> # Output variable -# [args...] # Input arguments, DATA{} allowed -# ) +# ExternalData_Expand_Arguments( +# <target> # Name of data management target +# <outVar> # Output variable +# [args...] # Input arguments, DATA{} allowed +# ) # -# It replaces each DATA{} reference in an argument with the full path of -# a real data file on disk that will exist after the <target> builds. +# It replaces each ``DATA{}`` reference in an argument with the full path of +# a real data file on disk that will exist after the ``<target>`` builds. # -# The 'ExternalData_Add_Test' function wraps around the CMake add_test() -# command but supports DATA{} references in its arguments: +# The ``ExternalData_Add_Test`` function wraps around the CMake +# :command:`add_test` command but supports ``DATA{}`` references in +# its arguments: # -# :: +# .. code-block:: cmake # -# ExternalData_Add_Test( -# <target> # Name of data management target -# ... # Arguments of add_test(), DATA{} allowed -# ) +# ExternalData_Add_Test( +# <target> # Name of data management target +# ... # Arguments of add_test(), DATA{} allowed +# ) # -# It passes its arguments through ExternalData_Expand_Arguments and then -# invokes add_test() using the results. +# It passes its arguments through ``ExternalData_Expand_Arguments`` and then +# invokes the :command:`add_test` command using the results. # -# The 'ExternalData_Add_Target' function creates a custom target to +# The ``ExternalData_Add_Target`` function creates a custom target to # manage local instances of data files stored externally: # -# :: +# .. code-block:: cmake # -# ExternalData_Add_Target( -# <target> # Name of data management target -# ) +# ExternalData_Add_Target( +# <target> # Name of data management target +# ) # # It creates custom commands in the target as necessary to make data -# files available for each DATA{} reference previously evaluated by -# other functions provided by this module. A list of URL templates must -# be provided in the variable ExternalData_URL_TEMPLATES using the -# placeholders "%(algo)" and "%(hash)" in each template. Data fetch +# files available for each ``DATA{}`` reference previously evaluated by +# other functions provided by this module. A list of URL templates may +# be provided in the variable ``ExternalData_URL_TEMPLATES`` using the +# placeholders ``%(algo)`` and ``%(hash)`` in each template. Data fetch # rules try each URL template in order by substituting the hash -# algorithm name for "%(algo)" and the hash value for "%(hash)". +# algorithm name for ``%(algo)`` and the hash value for ``%(hash)``. # -# The following hash algorithms are supported: +# The following hash algorithms are supported:: # -# :: -# -# %(algo) <ext> Description -# ------- ----- ----------- -# MD5 .md5 Message-Digest Algorithm 5, RFC 1321 -# SHA1 .sha1 US Secure Hash Algorithm 1, RFC 3174 -# SHA224 .sha224 US Secure Hash Algorithms, RFC 4634 -# SHA256 .sha256 US Secure Hash Algorithms, RFC 4634 -# SHA384 .sha384 US Secure Hash Algorithms, RFC 4634 -# SHA512 .sha512 US Secure Hash Algorithms, RFC 4634 +# %(algo) <ext> Description +# ------- ----- ----------- +# MD5 .md5 Message-Digest Algorithm 5, RFC 1321 +# SHA1 .sha1 US Secure Hash Algorithm 1, RFC 3174 +# SHA224 .sha224 US Secure Hash Algorithms, RFC 4634 +# SHA256 .sha256 US Secure Hash Algorithms, RFC 4634 +# SHA384 .sha384 US Secure Hash Algorithms, RFC 4634 +# SHA512 .sha512 US Secure Hash Algorithms, RFC 4634 # # Note that the hashes are used only for unique data identification and # download verification. This is not security software. # # Example usage: # -# :: +# .. code-block:: cmake # -# include(ExternalData) -# set(ExternalData_URL_TEMPLATES "file:///local/%(algo)/%(hash)" -# "http://data.org/%(algo)/%(hash)") -# ExternalData_Add_Test(MyData -# NAME MyTest -# COMMAND MyExe DATA{MyInput.png} -# ) -# ExternalData_Add_Target(MyData) +# include(ExternalData) +# set(ExternalData_URL_TEMPLATES "file:///local/%(algo)/%(hash)" +# "file:////host/share/%(algo)/%(hash)" +# "http://data.org/%(algo)/%(hash)") +# ExternalData_Add_Test(MyData +# NAME MyTest +# COMMAND MyExe DATA{MyInput.png} +# ) +# ExternalData_Add_Target(MyData) # -# When test "MyTest" runs the "DATA{MyInput.png}" argument will be +# When test ``MyTest`` runs the ``DATA{MyInput.png}`` argument will be # replaced by the full path to a real instance of the data file -# "MyInput.png" on disk. If the source tree contains a content link -# such as "MyInput.png.md5" then the "MyData" target creates a real -# "MyInput.png" in the build tree. +# ``MyInput.png`` on disk. If the source tree contains a content link +# such as ``MyInput.png.md5`` then the ``MyData`` target creates a real +# ``MyInput.png`` in the build tree. # -# The DATA{} syntax can be told to fetch a file series using the form -# "DATA{<name>,:}", where the ":" is literal. If the source tree +# The ``DATA{}`` syntax can be told to fetch a file series using the form +# ``DATA{<name>,:}``, where the ``:`` is literal. If the source tree # contains a group of files or content links named like a series then a # reference to one member adds rules to fetch all of them. Although all # members of a series are fetched, only the file originally named by the -# DATA{} argument is substituted for it. The default configuration -# recognizes file series names ending with "#.ext", "_#.ext", ".#.ext", -# or "-#.ext" where "#" is a sequence of decimal digits and ".ext" is -# any single extension. Configure it with a regex that parses <number> -# and <suffix> parts from the end of <name>: -# -# :: +# ``DATA{}`` argument is substituted for it. The default configuration +# recognizes file series names ending with ``#.ext``, ``_#.ext``, ``.#.ext``, +# or ``-#.ext`` where ``#`` is a sequence of decimal digits and ``.ext`` is +# any single extension. Configure it with a regex that parses ``<number>`` +# and ``<suffix>`` parts from the end of ``<name>``:: # -# ExternalData_SERIES_PARSE = regex of the form (<number>)(<suffix>)$ +# ExternalData_SERIES_PARSE = regex of the form (<number>)(<suffix>)$ # -# For more complicated cases set: +# For more complicated cases set:: # -# :: -# -# ExternalData_SERIES_PARSE = regex with at least two () groups -# ExternalData_SERIES_PARSE_PREFIX = <prefix> regex group number, if any -# ExternalData_SERIES_PARSE_NUMBER = <number> regex group number -# ExternalData_SERIES_PARSE_SUFFIX = <suffix> regex group number +# ExternalData_SERIES_PARSE = regex with at least two () groups +# ExternalData_SERIES_PARSE_PREFIX = <prefix> regex group number, if any +# ExternalData_SERIES_PARSE_NUMBER = <number> regex group number +# ExternalData_SERIES_PARSE_SUFFIX = <suffix> regex group number # # Configure series number matching with a regex that matches the -# <number> part of series members named <prefix><number><suffix>: -# -# :: +# ``<number>`` part of series members named ``<prefix><number><suffix>``:: # -# ExternalData_SERIES_MATCH = regex matching <number> in all series members +# ExternalData_SERIES_MATCH = regex matching <number> in all series members # -# Note that the <suffix> of a series does not include a hash-algorithm +# Note that the ``<suffix>`` of a series does not include a hash-algorithm # extension. # -# The DATA{} syntax can alternatively match files associated with the +# The ``DATA{}`` syntax can alternatively match files associated with the # named file and contained in the same directory. Associated files may # be specified by options using the syntax -# DATA{<name>,<opt1>,<opt2>,...}. Each option may specify one file by +# ``DATA{<name>,<opt1>,<opt2>,...}``. Each option may specify one file by # name or specify a regular expression to match file names using the -# syntax REGEX:<regex>. For example, the arguments +# syntax ``REGEX:<regex>``. For example, the arguments:: # -# :: +# DATA{MyData/MyInput.mhd,MyInput.img} # File pair +# DATA{MyData/MyFrames00.png,REGEX:MyFrames[0-9]+\\.png} # Series # -# DATA{MyData/MyInput.mhd,MyInput.img} # File pair -# DATA{MyData/MyFrames00.png,REGEX:MyFrames[0-9]+\\.png} # Series -# -# will pass MyInput.mha and MyFrames00.png on the command line but +# will pass ``MyInput.mha`` and ``MyFrames00.png`` on the command line but # ensure that the associated files are present next to them. # -# The DATA{} syntax may reference a directory using a trailing slash and -# a list of associated files. The form DATA{<name>/,<opt1>,<opt2>,...} +# The ``DATA{}`` syntax may reference a directory using a trailing slash and +# a list of associated files. The form ``DATA{<name>/,<opt1>,<opt2>,...}`` # adds rules to fetch any files in the directory that match one of the # associated file options. For example, the argument -# DATA{MyDataDir/,REGEX:.*} will pass the full path to a MyDataDir +# ``DATA{MyDataDir/,REGEX:.*}`` will pass the full path to a ``MyDataDir`` # directory on the command line and ensure that the directory contains -# files corresponding to every file or content link in the MyDataDir +# files corresponding to every file or content link in the ``MyDataDir`` # source directory. # -# The variable ExternalData_LINK_CONTENT may be set to the name of a +# The variable ``ExternalData_LINK_CONTENT`` may be set to the name of a # supported hash algorithm to enable automatic conversion of real data -# files referenced by the DATA{} syntax into content links. For each -# such <file> a content link named "<file><ext>" is created. The -# original file is renamed to the form ".ExternalData_<algo>_<hash>" to +# files referenced by the ``DATA{}`` syntax into content links. For each +# such ``<file>`` a content link named ``<file><ext>`` is created. The +# original file is renamed to the form ``.ExternalData_<algo>_<hash>`` to # stage it for future transmission to one of the locations in the list # of URL templates (by means outside the scope of this module). The # data fetch rule created for the content link will use the staged # object if it cannot be found using any URL template. # -# The variable ExternalData_OBJECT_STORES may be set to a list of local -# directories that store objects using the layout <dir>/%(algo)/%(hash). +# The variable ``ExternalData_OBJECT_STORES`` may be set to a list of local +# directories that store objects using the layout ``<dir>/%(algo)/%(hash)``. # These directories will be searched first for a needed object. If the # object is not available in any store then it will be fetched remotely # using the URL templates and added to the first local store listed. If # no stores are specified the default is a location inside the build # tree. # -# The variable ExternalData_SOURCE_ROOT may be set to the highest source -# directory containing any path named by a DATA{} reference. The -# default is CMAKE_SOURCE_DIR. ExternalData_SOURCE_ROOT and -# CMAKE_SOURCE_DIR must refer to directories within a single source +# The variable ``ExternalData_SOURCE_ROOT`` may be set to the highest source +# directory containing any path named by a ``DATA{}`` reference. The +# default is ``CMAKE_SOURCE_DIR``. ``ExternalData_SOURCE_ROOT`` and +# ``CMAKE_SOURCE_DIR`` must refer to directories within a single source # distribution (e.g. they come together in one tarball). # -# The variable ExternalData_BINARY_ROOT may be set to the directory to -# hold the real data files named by expanded DATA{} references. The -# default is CMAKE_BINARY_DIR. The directory layout will mirror that of -# content links under ExternalData_SOURCE_ROOT. +# The variable ``ExternalData_BINARY_ROOT`` may be set to the directory to +# hold the real data files named by expanded ``DATA{}`` references. The +# default is ``CMAKE_BINARY_DIR``. The directory layout will mirror that of +# content links under ``ExternalData_SOURCE_ROOT``. # -# Variables ExternalData_TIMEOUT_INACTIVITY and -# ExternalData_TIMEOUT_ABSOLUTE set the download inactivity and absolute +# Variables ``ExternalData_TIMEOUT_INACTIVITY`` and +# ``ExternalData_TIMEOUT_ABSOLUTE`` set the download inactivity and absolute # timeouts, in seconds. The defaults are 60 seconds and 300 seconds, # respectively. Set either timeout to 0 seconds to disable enforcement. @@ -210,8 +202,9 @@ function(ExternalData_add_test target) endfunction() function(ExternalData_add_target target) - if(NOT ExternalData_URL_TEMPLATES) - message(FATAL_ERROR "ExternalData_URL_TEMPLATES is not set!") + if(NOT ExternalData_URL_TEMPLATES AND NOT ExternalData_OBJECT_STORES) + message(FATAL_ERROR + "Neither ExternalData_URL_TEMPLATES nor ExternalData_OBJECT_STORES is set!") endif() if(NOT ExternalData_OBJECT_STORES) set(ExternalData_OBJECT_STORES ${CMAKE_BINARY_DIR}/ExternalData/Objects) @@ -633,8 +626,9 @@ endif() if(ExternalData_CONFIG) include(${ExternalData_CONFIG}) endif() -if(NOT ExternalData_URL_TEMPLATES) - message(FATAL_ERROR "No ExternalData_URL_TEMPLATES set!") +if(NOT ExternalData_URL_TEMPLATES AND NOT ExternalData_OBJECT_STORES) + message(FATAL_ERROR + "Neither ExternalData_URL_TEMPLATES nor ExternalData_OBJECT_STORES is set!") endif() function(_ExternalData_link_or_copy src dst) @@ -762,6 +756,9 @@ function(_ExternalData_download_object name hash algo var_obj) set(obj "${staged}") message(STATUS "Staged object: \"${obj}\"") else() + if(NOT tried) + set(tried "\n (No ExternalData_URL_TEMPLATES given)") + endif() message(FATAL_ERROR "Object ${algo}=${hash} not found at:${tried}") endif() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 84fa613..63f1180 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -4,11 +4,11 @@ # # Create custom targets to build projects in external trees # -# The 'ExternalProject_Add' function creates a custom target to drive +# The ``ExternalProject_Add`` function creates a custom target to drive # download, update/patch, configure, build, install and test steps of an # external project: # -# :: +# .. code-block:: cmake # # ExternalProject_Add(<name> # Name for custom target # [DEPENDS projects...] # Targets on which the project depends @@ -72,46 +72,42 @@ # ) # # The ``*_DIR`` options specify directories for the project, with default -# directories computed as follows. If the PREFIX option is given to -# ExternalProject_Add() or the EP_PREFIX directory property is set, then -# an external project is built and installed under the specified prefix: +# directories computed as follows. If the ``PREFIX`` option is given to +# ``ExternalProject_Add()`` or the ``EP_PREFIX`` directory property is set, +# then an external project is built and installed under the specified prefix:: # -# :: +# TMP_DIR = <prefix>/tmp +# STAMP_DIR = <prefix>/src/<name>-stamp +# DOWNLOAD_DIR = <prefix>/src +# SOURCE_DIR = <prefix>/src/<name> +# BINARY_DIR = <prefix>/src/<name>-build +# INSTALL_DIR = <prefix> # -# TMP_DIR = <prefix>/tmp -# STAMP_DIR = <prefix>/src/<name>-stamp -# DOWNLOAD_DIR = <prefix>/src -# SOURCE_DIR = <prefix>/src/<name> -# BINARY_DIR = <prefix>/src/<name>-build -# INSTALL_DIR = <prefix> +# Otherwise, if the ``EP_BASE`` directory property is set then components +# of an external project are stored under the specified base:: # -# Otherwise, if the EP_BASE directory property is set then components of -# an external project are stored under the specified base: +# TMP_DIR = <base>/tmp/<name> +# STAMP_DIR = <base>/Stamp/<name> +# DOWNLOAD_DIR = <base>/Download/<name> +# SOURCE_DIR = <base>/Source/<name> +# BINARY_DIR = <base>/Build/<name> +# INSTALL_DIR = <base>/Install/<name> # -# :: +# If no ``PREFIX``, ``EP_PREFIX``, or ``EP_BASE`` is specified then the +# default is to set ``PREFIX`` to ``<name>-prefix``. Relative paths are +# interpreted with respect to the build directory corresponding to the +# source directory in which ``ExternalProject_Add`` is invoked. # -# TMP_DIR = <base>/tmp/<name> -# STAMP_DIR = <base>/Stamp/<name> -# DOWNLOAD_DIR = <base>/Download/<name> -# SOURCE_DIR = <base>/Source/<name> -# BINARY_DIR = <base>/Build/<name> -# INSTALL_DIR = <base>/Install/<name> -# -# If no PREFIX, EP_PREFIX, or EP_BASE is specified then the default is -# to set PREFIX to "<name>-prefix". Relative paths are interpreted with -# respect to the build directory corresponding to the source directory -# in which ExternalProject_Add is invoked. -# -# If SOURCE_DIR is explicitly set to an existing directory the project +# If ``SOURCE_DIR`` is explicitly set to an existing directory the project # will be built from it. Otherwise a download step must be specified -# using one of the DOWNLOAD_COMMAND, CVS_*, SVN_*, or URL options. The -# URL option may refer locally to a directory or source tarball, or -# refer to a remote tarball (e.g. http://.../src.tgz). +# using one of the ``DOWNLOAD_COMMAND``, ``CVS_*``, ``SVN_*``, or ``URL`` +# options. The ``URL`` option may refer locally to a directory or source +# tarball, or refer to a remote tarball (e.g. ``http://.../src.tgz``). # -# The 'ExternalProject_Add_Step' function adds a custom step to an +# The ``ExternalProject_Add_Step`` function adds a custom step to an # external project: # -# :: +# .. code-block:: cmake # # ExternalProject_Add_Step(<name> <step> # Names of project and custom step # [COMMAND cmd...] # Command line invoked by this step @@ -125,51 +121,45 @@ # ) # # The command line, comment, and working directory of every standard and -# custom step is processed to replace tokens <SOURCE_DIR>, <BINARY_DIR>, -# <INSTALL_DIR>, and <TMP_DIR> with corresponding property values. +# custom step is processed to replace tokens ``<SOURCE_DIR>``, +# ``<BINARY_DIR>``, ``<INSTALL_DIR>``, and ``<TMP_DIR>`` with +# corresponding property values. # -# Any builtin step that specifies a "<step>_COMMAND cmd..." or custom -# step that specifies a "COMMAND cmd..." may specify additional command -# lines using the form "COMMAND cmd...". At build time the commands -# will be executed in order and aborted if any one fails. For example: +# Any builtin step that specifies a ``<step>_COMMAND cmd...`` or custom +# step that specifies a ``COMMAND cmd...`` may specify additional command +# lines using the form ``COMMAND cmd...``. At build time the commands +# will be executed in order and aborted if any one fails. For example:: # -# :: +# ... BUILD_COMMAND make COMMAND echo done ... # -# ... BUILD_COMMAND make COMMAND echo done ... -# -# specifies to run "make" and then "echo done" during the build step. +# specifies to run ``make`` and then ``echo done`` during the build step. # Whether the current working directory is preserved between commands is -# not defined. Behavior of shell operators like "&&" is not defined. -# -# The 'ExternalProject_Get_Property' function retrieves external project -# target properties: +# not defined. Behavior of shell operators like ``&&`` is not defined. # -# :: +# The ``ExternalProject_Get_Property`` function retrieves external project +# target properties:: # -# ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]]) +# ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]]) # # It stores property values in variables of the same name. Property # names correspond to the keyword argument names of -# 'ExternalProject_Add'. +# ``ExternalProject_Add``. # -# The 'ExternalProject_Add_StepTargets' function generates custom -# targets for the steps listed: +# The ``ExternalProject_Add_StepTargets`` function generates custom +# targets for the steps listed:: # -# :: +# ExternalProject_Add_StepTargets(<name> [step1 [step2 [...]]]) # -# ExternalProject_Add_StepTargets(<name> [step1 [step2 [...]]]) -# -# -# -# If STEP_TARGETS is set then ExternalProject_Add_StepTargets is +# If ``STEP_TARGETS`` is set then ``ExternalProject_Add_StepTargets`` is # automatically called at the end of matching calls to -# ExternalProject_Add_Step. Pass STEP_TARGETS explicitly to individual -# ExternalProject_Add calls, or implicitly to all ExternalProject_Add -# calls by setting the directory property EP_STEP_TARGETS. +# ``ExternalProject_Add_Step``. Pass ``STEP_TARGETS`` explicitly to +# individual ``ExternalProject_Add`` calls, or implicitly to all +# ``ExternalProject_Add`` calls by setting the directory property +# ``EP_STEP_TARGETS``. # -# If STEP_TARGETS is not set, clients may still manually call -# ExternalProject_Add_StepTargets after calling ExternalProject_Add or -# ExternalProject_Add_Step. +# If ``STEP_TARGETS`` is not set, clients may still manually call +# ``ExternalProject_Add_StepTargets`` after calling +# ``ExternalProject_Add`` or ``ExternalProject_Add_Step``. # # This functionality is provided to make it easy to drive the steps # independently of each other by specifying targets on build command @@ -181,15 +171,14 @@ # will also run to ensure everything is up to date. # # For example, to drive configure, build and test steps independently -# for each ExternalProject_Add call in your project, write the following -# line prior to any ExternalProject_Add calls in your CMakeLists file: -# -# :: +# for each ``ExternalProject_Add`` call in your project, write the following +# line prior to any ``ExternalProject_Add`` calls in your ``CMakeLists.txt`` +# file:: # -# set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) +# set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) #============================================================================= -# Copyright 2008-2012 Kitware, Inc. +# Copyright 2008-2013 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 6e1c926..51a3d77 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -4,9 +4,7 @@ # # Find Boost include dirs and libraries # -# Use this module by invoking find_package with the form: -# -# :: +# Use this module by invoking find_package with the form:: # # find_package(Boost # [version] [EXACT] # Minimum or EXACT version e.g. 1.36.0 @@ -17,9 +15,7 @@ # This module finds headers and requested component libraries OR a CMake # package configuration file provided by a "Boost CMake" build. For the # latter case skip to the "Boost CMake" section below. For the former -# case results are reported in variables: -# -# :: +# case results are reported in variables:: # # Boost_FOUND - True if headers and requested libraries were found # Boost_INCLUDE_DIRS - Boost include directories @@ -38,11 +34,7 @@ # information about Boost's automatic linking # displayed during compilation # -# -# -# This module reads hints about search locations from variables: -# -# :: +# This module reads hints about search locations from variables:: # # BOOST_ROOT - Preferred installation prefix # (or BOOSTROOT) @@ -54,9 +46,7 @@ # - List of Boost versions not known to this module # (Boost install locations may contain the version) # -# and saves search results persistently in CMake cache entries: -# -# :: +# and saves search results persistently in CMake cache entries:: # # Boost_INCLUDE_DIR - Directory containing Boost headers # Boost_LIBRARY_DIR - Directory containing Boost libraries @@ -83,9 +73,7 @@ # # Boost libraries come in many variants encoded in their file name. # Users or projects may tell this module which variant to find by -# setting variables: -# -# :: +# setting variables:: # # Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded # libraries ('mt' tag). Default is ON. @@ -109,9 +97,7 @@ # such as "pthread" or "win32". Names with # and without this suffix will both be tried. # -# Other variables one may set to control this module are: -# -# :: +# Other variables one may set to control this module are:: # # Boost_DEBUG - Set to ON to enable debug output from FindBoost. # Please enable this before filing any bug report. @@ -132,17 +118,13 @@ # to be linked explicitly or available in the link library search path. # In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve # dynamic linking. Boost automatic linking typically requests static -# libraries with a few exceptions (such as Boost.Python). Use -# -# :: +# libraries with a few exceptions (such as Boost.Python). Use:: # # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) # # to ask Boost to report information about automatic linking requests. # -# Example to find Boost headers only: -# -# :: +# Example to find Boost headers only:: # # find_package(Boost 1.36.0) # if(Boost_FOUND) @@ -150,11 +132,9 @@ # add_executable(foo foo.cc) # endif() # -# Example to find Boost headers and some libraries: +# Example to find Boost headers and some *static* libraries:: # -# :: -# -# set(Boost_USE_STATIC_LIBS ON) +# set(Boost_USE_STATIC_LIBS ON) # only find static libs # set(Boost_USE_MULTITHREADED ON) # set(Boost_USE_STATIC_RUNTIME OFF) # find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...) @@ -164,9 +144,8 @@ # target_link_libraries(foo ${Boost_LIBRARIES}) # endif() # -# -# -# Boost CMake ---------------------------------------------------------- +# Boost CMake +# ^^^^^^^^^^^ # # If Boost was built using the boost-cmake project it provides a package # configuration file for use with find_package's Config mode. This diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 5dca820..05f38eb 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -649,19 +649,15 @@ endforeach() ############################################################################### ############################################################################### -# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, -# if they have then clear the cache variables, so that will be detected again. -if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") - unset(CUDA_NVCC_EXECUTABLE CACHE) +macro(cuda_unset_include_and_libraries) unset(CUDA_TOOLKIT_INCLUDE CACHE) unset(CUDA_CUDART_LIBRARY CACHE) + unset(CUDA_CUDA_LIBRARY CACHE) # Make sure you run this before you unset CUDA_VERSION. if(CUDA_VERSION VERSION_EQUAL "3.0") # This only existed in the 3.0 version of the CUDA toolkit unset(CUDA_CUDARTEMU_LIBRARY CACHE) endif() - unset(CUDA_VERSION CACHE) - unset(CUDA_CUDA_LIBRARY CACHE) unset(CUDA_cupti_LIBRARY CACHE) unset(CUDA_cublas_LIBRARY CACHE) unset(CUDA_cublasemu_LIBRARY CACHE) @@ -675,6 +671,19 @@ if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") unset(CUDA_npps_LIBRARY CACHE) unset(CUDA_nvcuvenc_LIBRARY CACHE) unset(CUDA_nvcuvid_LIBRARY CACHE) +endmacro() + +# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, +# if they have then clear the cache variables, so that will be detected again. +if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") + unset(CUDA_TOOLKIT_TARGET_DIR CACHE) + unset(CUDA_NVCC_EXECUTABLE CACHE) + unset(CUDA_VERSION CACHE) + cuda_unset_include_and_libraries() +endif() + +if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") + cuda_unset_include_and_libraries() endif() if(NOT "${CUDA_SDK_ROOT_DIR}" STREQUAL "${CUDA_SDK_ROOT_DIR_INTERNAL}") @@ -749,10 +758,27 @@ endif() # Always set this convenience variable set(CUDA_VERSION_STRING "${CUDA_VERSION}") +# Support for arm cross compilation with CUDA 5.5 +if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf" CACHE PATH "Toolkit target location.") +else() + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT_DIR}" CACHE PATH "Toolkit target location.") +endif() +mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + +# Target CPU architecture +if(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") + set(_cuda_target_cpu_arch_initial "ARM") +else() + set(_cuda_target_cpu_arch_initial "") +endif() +set(CUDA_TARGET_CPU_ARCH ${_cuda_target_cpu_arch_initial} CACHE STRING "Specify the name of the class of CPU architecture for which the input files must be compiled.") +mark_as_advanced(CUDA_TARGET_CPU_ARCH) + # CUDA_TOOLKIT_INCLUDE find_path(CUDA_TOOLKIT_INCLUDE device_functions.h # Header included in toolkit - PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}" ENV CUDA_PATH ENV CUDA_INC_PATH PATH_SUFFIXES include @@ -776,7 +802,7 @@ macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) # (lib/Win32) and the old path (lib). find_library(${_var} NAMES ${_names} - PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}" ENV CUDA_PATH ENV CUDA_LIB_PATH PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" @@ -967,6 +993,8 @@ set(CUDA_FOUND TRUE) set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) +set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) @@ -1191,6 +1219,10 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) set(nvcc_flags ${nvcc_flags} -m32) endif() + if(CUDA_TARGET_CPU_ARCH) + set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") + endif() + # This needs to be passed in at this stage, because VS needs to fill out the # value of VCInstallDir from within VS. Note that CCBIN is only used if # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 1780a8e..29a247d 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -39,7 +39,7 @@ macro(java_append_library_directories _var) # 1.6.0_18 + icedtea patches. However, it would be much better to base the # guess on the first part of the GNU config.guess platform triplet. if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - set(_java_libarch "amd64") + set(_java_libarch "amd64" "i386") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") set(_java_libarch "i386") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") @@ -52,7 +52,7 @@ macro(java_append_library_directories _var) # endianess of the underlying system. set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") - set(_java_libarch "ppc64") + set(_java_libarch "ppc64" "ppc") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") set(_java_libarch "ppc") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc") diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index ba03f25..fead4a6 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -42,6 +42,8 @@ set(_OPENMP_REQUIRED_VARS) function(_OPENMP_FLAG_CANDIDATES LANG) set(OpenMP_FLAG_CANDIDATES + #Empty, if compiler automatically accepts openmp + " " #GNU "-fopenmp" #Microsoft Visual Studio @@ -50,8 +52,6 @@ function(_OPENMP_FLAG_CANDIDATES LANG) "-Qopenmp" #PathScale, Intel "-openmp" - #Empty, if compiler automatically accepts openmp - " " #Sun "-xopenmp" #HP @@ -75,6 +75,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG) set(OMP_FLAG_PGI "-mp") set(OMP_FLAG_SunPro "-xopenmp") set(OMP_FLAG_XL "-qsmp") + set(OMP_FLAG_Cray " ") # Move the flag that matches the compiler to the head of the list, # this is faster and doesn't clutter the output that much. If that @@ -111,7 +112,7 @@ if(CMAKE_C_COMPILER_LOADED) include(${CMAKE_CURRENT_LIST_DIR}/CheckCSourceCompiles.cmake) endif() - foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES}) + foreach(FLAG IN LISTS OpenMP_C_FLAG_CANDIDATES) set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${FLAG}") unset(OpenMP_FLAG_DETECTED CACHE) @@ -145,7 +146,7 @@ if(CMAKE_CXX_COMPILER_LOADED) set(OpenMP_CXX_TEST_SOURCE ${OpenMP_C_TEST_SOURCE}) endif() - foreach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES}) + foreach(FLAG IN LISTS OpenMP_CXX_FLAG_CANDIDATES) set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${FLAG}") unset(OpenMP_FLAG_DETECTED CACHE) diff --git a/Modules/FindPHP4.cmake b/Modules/FindPHP4.cmake index 51a89f3..25fff8c 100644 --- a/Modules/FindPHP4.cmake +++ b/Modules/FindPHP4.cmake @@ -46,7 +46,7 @@ if(PHP4_FOUND_INCLUDE_PATH) foreach(php4_path Zend main TSRM) set(php4_paths ${php4_paths} "${PHP4_FOUND_INCLUDE_PATH}/${php4_path}") endforeach() - set(PHP4_INCLUDE_PATH "${php4_paths}" INTERNAL "PHP4 include paths") + set(PHP4_INCLUDE_PATH "${php4_paths}") endif() find_program(PHP4_EXECUTABLE NAMES php4 php ) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 6126a48..8da848c 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -72,8 +72,6 @@ else() set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) endif() -message(STATUS "names ${_Python_NAMES}") -message(STATUS "other versions ${_PYTHON_FIND_OTHER_VERSIONS}") list(APPEND _Python_NAMES python) # Search for the current active python version first diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index bd899e2..ac649e9 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -738,9 +738,11 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "ldd") set(old_ld_env "$ENV{LD_LIBRARY_PATH}") - foreach(dir ${exepath} ${dirs}) - set(ENV{LD_LIBRARY_PATH} "${dir}:$ENV{LD_LIBRARY_PATH}") + set(new_ld_env "${exepath}") + foreach(dir ${dirs}) + set(new_ld_env "${new_ld_env}:${dir}") endforeach() + set(ENV{LD_LIBRARY_PATH} "${new_ld_env}:$ENV{LD_LIBRARY_PATH}") endif() diff --git a/Modules/Platform/Darwin-icc.cmake b/Modules/Platform/Darwin-icc.cmake index 6a46f8e..0fab9a1 100644 --- a/Modules/Platform/Darwin-icc.cmake +++ b/Modules/Platform/Darwin-icc.cmake @@ -60,12 +60,6 @@ if(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) CACHE STRING "Build architectures for OSX") endif() - -if("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$") - set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS - "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress") -endif() - if(NOT XCODE) # Enable shared library versioning. This flag is not actually referenced # but the fact that the setting exists will cause the generators to support diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 8ab3e2c..f3ec441 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -223,11 +223,6 @@ if(CMAKE_OSX_DEPLOYMENT_TARGET) endif() endif() -if("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$") - set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS - "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress") -endif() - # Enable shared library versioning. set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") diff --git a/Modules/Platform/Linux-Intel-Fortran.cmake b/Modules/Platform/Linux-Intel-Fortran.cmake index bb671ee..0c9523c 100644 --- a/Modules/Platform/Linux-Intel-Fortran.cmake +++ b/Modules/Platform/Linux-Intel-Fortran.cmake @@ -1,4 +1,4 @@ include(Platform/Linux-Intel) __linux_compiler_intel(Fortran) -set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS} -i_dynamic -nofor_main") -set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-i_dynamic") +set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS} -nofor_main") +set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "") diff --git a/Modules/Platform/QNX.cmake b/Modules/Platform/QNX.cmake index 2598411..9afde05 100644 --- a/Modules/Platform/QNX.cmake +++ b/Modules/Platform/QNX.cmake @@ -3,6 +3,9 @@ set(QNXNTO 1) # The QNX GCC does not seem to have -isystem so remove the flag. set(CMAKE_INCLUDE_SYSTEM_FLAG_C) set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) +# ... Nor does the driver support appropriate flags to create depfiles. +set(CMAKE_DEPFILE_FLAGS_C) +set(CMAKE_DEPFILE_FLAGS_CXX) set(CMAKE_DL_LIBS "") set(CMAKE_SHARED_LIBRARY_C_FLAGS "") @@ -13,6 +16,9 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") 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") +# http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples +set(CMAKE_C_COMPILE_OPTIONS_TARGET "-V") +set(CMAKE_CXX_COMPILE_OPTIONS_TARGET "-V") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index ccb2663..7a424c4 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -37,10 +37,13 @@ list(APPEND CMAKE_SYSTEM_PREFIX_PATH # CMake install location "${_CMAKE_INSTALL_DIR}" - - # Project install destination. - "${CMAKE_INSTALL_PREFIX}" ) +if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH + # Project install destination. + "${CMAKE_INSTALL_PREFIX}" + ) +endif() # List common include file locations not under the common prefixes. list(APPEND CMAKE_SYSTEM_INCLUDE_PATH diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake index fc921d7..c231495 100644 --- a/Modules/Platform/WindowsPaths.cmake +++ b/Modules/Platform/WindowsPaths.cmake @@ -73,11 +73,13 @@ get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH) get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH) list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${_CMAKE_INSTALL_DIR}") -# Add other locations. -list(APPEND CMAKE_SYSTEM_PREFIX_PATH - # Project install destination. - "${CMAKE_INSTALL_PREFIX}" - ) +if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) + # Add other locations. + list(APPEND CMAKE_SYSTEM_PREFIX_PATH + # Project install destination. + "${CMAKE_INSTALL_PREFIX}" + ) +endif() if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") # MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set) @@ -88,8 +90,12 @@ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH ) # mingw can also link against dlls which can also be in /bin, so list this too +if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) + list(APPEND CMAKE_SYSTEM_LIBRARY_PATH + "${CMAKE_INSTALL_PREFIX}/bin" + ) +endif() list(APPEND CMAKE_SYSTEM_LIBRARY_PATH - "${CMAKE_INSTALL_PREFIX}/bin" "${_CMAKE_INSTALL_DIR}/bin" /bin ) diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index 675aaa3..6f32b08 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -58,7 +58,7 @@ macro(TEST_BIG_ENDIAN VARIABLE) configure_file("${CMAKE_ROOT}/Modules/TestEndianess.c.in" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c" - IMMEDIATE @ONLY) + @ONLY) file(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c" TEST_ENDIANESS_FILE_CONTENT) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 35090fc..aa036b7 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -63,7 +63,7 @@ endif () # list dependent modules, so dependent libraries are added set(QT_QT3SUPPORT_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE) -set(QT_QTSVG_MODULE_DEPENDS QTGUI QTXML QTCORE) +set(QT_QTSVG_MODULE_DEPENDS QTGUI QTCORE) set(QT_QTUITOOLS_MODULE_DEPENDS QTGUI QTXML QTCORE) set(QT_QTHELP_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE) if(QT_QTDBUS_FOUND) diff --git a/Source/CMakeInstallDestinations.cmake b/Source/CMakeInstallDestinations.cmake index 33e8ce8..3e93d41 100644 --- a/Source/CMakeInstallDestinations.cmake +++ b/Source/CMakeInstallDestinations.cmake @@ -1,13 +1,15 @@ # Keep formatting here consistent with bootstrap script expectations. -set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION}") # OTHER if(BEOS) + set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # HAIKU set(CMAKE_MAN_DIR_DEFAULT "documentation/man") # HAIKU - set(CMAKE_DOC_DIR_DEFAULT "documentation/doc/cmake-${CMake_VERSION}") # HAIKU + set(CMAKE_DOC_DIR_DEFAULT "documentation/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # HAIKU elseif(CYGWIN) + set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION}") # CYGWIN set(CMAKE_DOC_DIR_DEFAULT "share/doc/cmake-${CMake_VERSION}") # CYGWIN set(CMAKE_MAN_DIR_DEFAULT "share/man") # CYGWIN else() - set(CMAKE_DOC_DIR_DEFAULT "doc/cmake-${CMake_VERSION}") # OTHER + set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # OTHER + set(CMAKE_DOC_DIR_DEFAULT "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # OTHER set(CMAKE_MAN_DIR_DEFAULT "man") # OTHER endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 01e4f88..570b7e2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -38,6 +38,12 @@ configure_file( "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h" ) +# Tell CMake executable in the build tree where to find the source tree. +configure_file( + "${CMake_SOURCE_DIR}/Source/CMakeSourceDir.txt.in" + "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" @ONLY + ) + # add the include path to find the .h include_directories( "${CMake_BINARY_DIR}/Source" @@ -250,8 +256,8 @@ set(SRCS cmPropertyDefinitionMap.h cmPropertyMap.cxx cmPropertyMap.h - cmQtAutomoc.cxx - cmQtAutomoc.h + cmQtAutoGenerators.cxx + cmQtAutoGenerators.h cmRST.cxx cmRST.h cmScriptGenerator.h @@ -465,6 +471,8 @@ set(CTEST_SRCS cmCTest.cxx CTest/cmCTestGIT.h CTest/cmCTestHG.cxx CTest/cmCTestHG.h + CTest/cmCTestP4.cxx + CTest/cmCTestP4.h ) # Build CTestLib diff --git a/Source/CMakeSourceDir.txt.in b/Source/CMakeSourceDir.txt.in new file mode 100644 index 0000000..5e6a988 --- /dev/null +++ b/Source/CMakeSourceDir.txt.in @@ -0,0 +1 @@ +@CMake_SOURCE_DIR@ diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 341a925..9ec279e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 12) -set(CMake_VERSION_TWEAK 20131024) +set(CMake_VERSION_TWEAK 20131120) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 725810b..1d7681b 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -83,6 +83,15 @@ bool cmCPackWIXGenerator::RunCandleCommand( command << " -nologo"; command << " -arch " << GetArchitecture(); command << " -out " << QuotePath(objectFile); + + for(extension_set_t::const_iterator i = candleExtensions.begin(); + i != candleExtensions.end(); ++i) + { + command << " -ext " << QuotePath(*i); + } + + AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command); + command << " " << QuotePath(sourceFile); return RunWiXCommand(command.str()); @@ -100,12 +109,21 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) command << QuotePath(executable); command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); - command << " -ext WixUIExtension"; + + for(extension_set_t::const_iterator i = lightExtensions.begin(); + i != lightExtensions.end(); ++i) + { + command << " -ext " << QuotePath(*i); + } + const char* const cultures = GetOption("CPACK_WIX_CULTURES"); if(cultures) { command << " -cultures:" << cultures; } + + AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command); + command << " " << objectFiles; return RunWiXCommand(command.str()); @@ -170,6 +188,23 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() } } + if(GetOption("CPACK_PACKAGE_VENDOR") == 0) + { + std::string defaultVendor = "Humanity"; + SetOption("CPACK_PACKAGE_VENDOR", defaultVendor.c_str()); + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "CPACK_PACKAGE_VENDOR implicitly set to " << defaultVendor << " . " + << std::endl); + } + + CollectExtensions("CPACK_WIX_EXTENSIONS", candleExtensions); + CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", candleExtensions); + + lightExtensions.insert("WixUIExtension"); + CollectExtensions("CPACK_WIX_EXTENSIONS", lightExtensions); + CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", lightExtensions); + return true; } @@ -368,117 +403,49 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() featureDefinitions.AddAttribute("Id", "ProductFeature"); featureDefinitions.AddAttribute("Title", Name); featureDefinitions.AddAttribute("Level", "1"); - featureDefinitions.EndElement(); + featureDefinitions.EndElement("Feature"); featureDefinitions.BeginElement("FeatureRef"); featureDefinitions.AddAttribute("Id", "ProductFeature"); + std::vector<std::string> cpackPackageExecutablesList; const char *cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); - std::vector<std::string> cpackPkgExecutables; - std::string regKey; - if ( cpackPackageExecutables ) + if(cpackPackageExecutables) { - cmSystemTools::ExpandListArgument(cpackPackageExecutables, - cpackPkgExecutables); - if ( cpackPkgExecutables.size() % 2 != 0 ) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and " - "<icon name>." << std::endl); - cpackPkgExecutables.clear(); - } - - const char *cpackVendor = GetOption("CPACK_PACKAGE_VENDOR"); - const char *cpackPkgName = GetOption("CPACK_PACKAGE_NAME"); - if (!cpackVendor || !cpackPkgName) - { - cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_PACKAGE_VENDOR and " - "CPACK_PACKAGE_NAME must be defined for shortcut creation" - << std::endl); - cpackPkgExecutables.clear(); - } - else - { - regKey = std::string("Software/") + cpackVendor + "/" + cpackPkgName; - } + cmSystemTools::ExpandListArgument(cpackPackageExecutables, + cpackPackageExecutablesList); + if(cpackPackageExecutablesList.size() % 2 != 0 ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and " + "<text label>." << std::endl); + return false; + } } - std::vector<std::string> dirIdExecutables; AddDirectoryAndFileDefinitons( toplevel, "INSTALL_ROOT", directoryDefinitions, fileDefinitions, featureDefinitions, - cpackPkgExecutables, dirIdExecutables); - - directoryDefinitions.EndElement(); - directoryDefinitions.EndElement(); + cpackPackageExecutablesList); - if (dirIdExecutables.size() > 0 && dirIdExecutables.size() % 3 == 0) + if(!CreateStartMenuShortcuts( + directoryDefinitions, fileDefinitions, featureDefinitions)) { - fileDefinitions.BeginElement("DirectoryRef"); - fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - fileDefinitions.BeginElement("Component"); - fileDefinitions.AddAttribute("Id", "SHORTCUT"); - fileDefinitions.AddAttribute("Guid", "*"); + return false; + } - std::vector<std::string>::iterator it; - for ( it = dirIdExecutables.begin() ; - it != dirIdExecutables.end(); - ++it) - { - std::string fileName = *it++; - std::string iconName = *it++; - std::string directoryId = *it; - - fileDefinitions.BeginElement("Shortcut"); - - // the iconName is more likely to contain blanks early on - std::string shortcutName = fileName; - - std::string::size_type const dotPos = shortcutName.find('.'); - if(std::string::npos == dotPos) - { shortcutName = shortcutName.substr(0, dotPos); } - fileDefinitions.AddAttribute("Id", "SHORTCUT_" + shortcutName); - fileDefinitions.AddAttribute("Name", iconName); - std::string target = "[" + directoryId + "]" + fileName; - fileDefinitions.AddAttribute("Target", target); - fileDefinitions.AddAttribute("WorkingDirectory", directoryId); - fileDefinitions.EndElement(); - } - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", "UNINSTALL"); - std::string pkgName = GetOption("CPACK_PACKAGE_NAME"); - fileDefinitions.AddAttribute("Name", "Uninstall " + pkgName); - fileDefinitions.AddAttribute("Description", "Uninstalls " + pkgName); - fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe"); - fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]"); - fileDefinitions.EndElement(); - fileDefinitions.BeginElement("RemoveFolder"); - fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - fileDefinitions.AddAttribute("On", "uninstall"); - fileDefinitions.EndElement(); - fileDefinitions.BeginElement("RegistryValue"); - fileDefinitions.AddAttribute("Root", "HKCU"); - fileDefinitions.AddAttribute("Key", regKey); - fileDefinitions.AddAttribute("Name", "installed"); - fileDefinitions.AddAttribute("Type", "integer"); - fileDefinitions.AddAttribute("Value", "1"); - fileDefinitions.AddAttribute("KeyPath", "yes"); - - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", "SHORTCUT"); - featureDefinitions.EndElement(); - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); - directoryDefinitions.AddAttribute("Name", startMenuFolder); - } + featureDefinitions.EndElement("FeatureRef"); + featureDefinitions.EndElement("Fragment"); + fileDefinitions.EndElement("Fragment"); + + for(size_t i = 1; i < install_root.size(); ++i) + { + directoryDefinitions.EndElement("Directory"); + } - featureDefinitions.EndElement(); - featureDefinitions.EndElement(); - fileDefinitions.EndElement(); - directoryDefinitions.EndElement(); + directoryDefinitions.EndElement("Directory"); + directoryDefinitions.EndElement("Directory"); + directoryDefinitions.EndElement("Fragment"); std::string wixTemplate = FindTemplate("WIX.template.in"); if(GetOption("CPACK_WIX_TEMPLATE") != 0) @@ -508,6 +475,106 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return true; } +bool cmCPackWIXGenerator::CreateStartMenuShortcuts( + cmWIXSourceWriter& directoryDefinitions, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions) +{ + if(shortcutMap.empty()) + { + return true; + } + + std::string cpackVendor; + if(!RequireOption("CPACK_PACKAGE_VENDOR", cpackVendor)) + { + return false; + } + + std::string cpackPackageName; + if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) + { + return false; + } + + fileDefinitions.BeginElement("DirectoryRef"); + fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + fileDefinitions.BeginElement("Component"); + fileDefinitions.AddAttribute("Id", "SHORTCUT"); + fileDefinitions.AddAttribute("Guid", "*"); + + for(shortcut_map_t::const_iterator + i = shortcutMap.begin(); i != shortcutMap.end(); ++i) + { + std::string const& id = i->first; + cmWIXShortcut const& shortcut = i->second; + + std::string shortcutId = std::string("CM_S") + id; + std::string fileId = std::string("CM_F") + id; + + fileDefinitions.BeginElement("Shortcut"); + fileDefinitions.AddAttribute("Id", shortcutId); + fileDefinitions.AddAttribute("Name", shortcut.textLabel); + std::string target = "[#" + fileId + "]"; + fileDefinitions.AddAttribute("Target", target); + fileDefinitions.AddAttribute("WorkingDirectory", + shortcut.workingDirectoryId); + fileDefinitions.EndElement("Shortcut"); + } + + CreateUninstallShortcut(cpackPackageName, fileDefinitions); + + fileDefinitions.BeginElement("RemoveFolder"); + fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + fileDefinitions.AddAttribute("On", "uninstall"); + fileDefinitions.EndElement("RemoveFolder"); + + std::string registryKey = + std::string("Software/") + cpackVendor + "/" + cpackPackageName; + + fileDefinitions.BeginElement("RegistryValue"); + fileDefinitions.AddAttribute("Root", "HKCU"); + fileDefinitions.AddAttribute("Key", registryKey); + fileDefinitions.AddAttribute("Name", "installed"); + fileDefinitions.AddAttribute("Type", "integer"); + fileDefinitions.AddAttribute("Value", "1"); + fileDefinitions.AddAttribute("KeyPath", "yes"); + fileDefinitions.EndElement("RegistryValue"); + + fileDefinitions.EndElement("Component"); + fileDefinitions.EndElement("DirectoryRef"); + + featureDefinitions.BeginElement("ComponentRef"); + featureDefinitions.AddAttribute("Id", "SHORTCUT"); + featureDefinitions.EndElement("ComponentRef"); + + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); + + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); + directoryDefinitions.AddAttribute("Name", startMenuFolder); + directoryDefinitions.EndElement("Directory"); + + directoryDefinitions.EndElement("Directory"); + + return true; +} + +void cmCPackWIXGenerator::CreateUninstallShortcut( + std::string const& packageName, + cmWIXSourceWriter& fileDefinitions) +{ + fileDefinitions.BeginElement("Shortcut"); + fileDefinitions.AddAttribute("Id", "UNINSTALL"); + fileDefinitions.AddAttribute("Name", "Uninstall " + packageName); + fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName); + fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe"); + fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]"); + fileDefinitions.EndElement("Shortcut"); +} + bool cmCPackWIXGenerator::CreateLicenseFile() { std::string licenseSourceFilename; @@ -561,8 +628,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions, - const std::vector<std::string>& pkgExecutables, - std::vector<std::string>& dirIdExecutables) + const std::vector<std::string>& packageExecutables) { cmsys::Directory dir; dir.Load(topdir.c_str()); @@ -596,9 +662,9 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( directoryDefinitions, fileDefinitions, featureDefinitions, - pkgExecutables, - dirIdExecutables); - directoryDefinitions.EndElement(); + packageExecutables); + + directoryDefinitions.EndElement("Directory"); } else { @@ -617,28 +683,25 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( fileDefinitions.AddAttribute("Source", fullPath); fileDefinitions.AddAttribute("KeyPath", "yes"); - fileDefinitions.EndElement(); - fileDefinitions.EndElement(); - fileDefinitions.EndElement(); + fileDefinitions.EndElement("File"); + fileDefinitions.EndElement("Component"); + fileDefinitions.EndElement("DirectoryRef"); featureDefinitions.BeginElement("ComponentRef"); featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement(); + featureDefinitions.EndElement("ComponentRef"); - std::vector<std::string>::const_iterator it; - for (it = pkgExecutables.begin() ; - it != pkgExecutables.end() ; - ++it) + for(size_t j = 0; j < packageExecutables.size(); ++j) { - std::string execName = *it++; - std::string iconName = *it; + std::string const& executableName = packageExecutables[j++]; + std::string const& textLabel = packageExecutables[j]; - if (cmSystemTools::LowerCase(fileName) == - cmSystemTools::LowerCase(execName) + ".exe") + if(cmSystemTools::LowerCase(fileName) == + cmSystemTools::LowerCase(executableName) + ".exe") { - dirIdExecutables.push_back(fileName); - dirIdExecutables.push_back(iconName); - dirIdExecutables.push_back(directoryId); + cmWIXShortcut &shortcut = shortcutMap[id]; + shortcut.textLabel= textLabel; + shortcut.workingDirectoryId = directoryId; } } } @@ -827,3 +890,35 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c) (c >= 'A' && c <= 'Z') || c == '_' || c == '.'; } + +void cmCPackWIXGenerator::CollectExtensions( + const std::string& variableName, extension_set_t& extensions) +{ + const char *variableContent = GetOption(variableName.c_str()); + if(!variableContent) return; + + std::vector<std::string> list; + cmSystemTools::ExpandListArgument(variableContent, list); + + for(std::vector<std::string>::const_iterator i = list.begin(); + i != list.end(); ++i) + { + extensions.insert(*i); + } +} + +void cmCPackWIXGenerator::AddCustomFlags( + const std::string& variableName, std::ostream& stream) +{ + const char *variableContent = GetOption(variableName.c_str()); + if(!variableContent) return; + + std::vector<std::string> list; + cmSystemTools::ExpandListArgument(variableContent, list); + + for(std::vector<std::string>::const_iterator i = list.begin(); + i != list.end(); ++i) + { + stream << " " << QuotePath(*i); + } +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index eac69fe..481a07d 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -18,6 +18,12 @@ #include <string> #include <map> +struct cmWIXShortcut +{ + std::string textLabel; + std::string workingDirectoryId; +}; + class cmWIXSourceWriter; /** \class cmCPackWIXGenerator @@ -56,6 +62,8 @@ protected: private: typedef std::map<std::string, std::string> id_map_t; typedef std::map<std::string, size_t> ambiguity_map_t; + typedef std::map<std::string, cmWIXShortcut> shortcut_map_t; + typedef std::set<std::string> extension_set_t; bool InitializeWiXConfiguration(); @@ -71,6 +79,15 @@ private: bool CreateWiXSourceFiles(); + bool CreateStartMenuShortcuts( + cmWIXSourceWriter& directoryDefinitions, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions); + + void CreateUninstallShortcut( + std::string const& packageName, + cmWIXSourceWriter& fileDefinitions); + void AppendUserSuppliedExtraSources(); void AppendUserSuppliedExtraObjects(std::ostream& stream); @@ -89,9 +106,7 @@ private: cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions, - const std::vector<std::string>& pkgExecutables, - std::vector<std::string>& dirIdExecutables - ); + const std::vector<std::string>& pkgExecutables); bool RequireOption(const std::string& name, std::string& value) const; @@ -115,9 +130,19 @@ private: static bool IsLegalIdCharacter(char c); + void CollectExtensions( + const std::string& variableName, extension_set_t& extensions); + + void AddCustomFlags( + const std::string& variableName, std::ostream& stream); + std::vector<std::string> wixSources; id_map_t pathToIdMap; ambiguity_map_t idAmbiguityCounter; + shortcut_map_t shortcutMap; + + extension_set_t candleExtensions; + extension_set_t lightExtensions; }; #endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index af7ba80..214b8ac 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -21,7 +21,8 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, bool isIncludeFile): Logger(logger), file(filename.c_str()), - state(DEFAULT) + state(DEFAULT), + sourceFilename(filename) { WriteXMLDeclaration(); @@ -39,10 +40,15 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, cmWIXSourceWriter::~cmWIXSourceWriter() { - while(elements.size()) + if(elements.size() > 1) { - EndElement(); + cmCPackLogger(cmCPackLog::LOG_ERROR, + elements.size() - 1 << " WiX elements were still open when closing '" << + sourceFilename << "'" << std::endl); + return; } + + EndElement(elements.back()); } void cmWIXSourceWriter::BeginElement(const std::string& name) @@ -60,12 +66,22 @@ void cmWIXSourceWriter::BeginElement(const std::string& name) state = BEGIN; } -void cmWIXSourceWriter::EndElement() +void cmWIXSourceWriter::EndElement(std::string const& name) { if(elements.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "can not end WiX element with no open elements" << std::endl); + "can not end WiX element with no open elements in '" << + sourceFilename << "'" << std::endl); + return; + } + + if(elements.back() != name) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "WiX element <" << elements.back() << + "> can not be closed by </" << name << "> in '" << + sourceFilename << "'" << std::endl); return; } @@ -173,6 +189,9 @@ std::string cmWIXSourceWriter::EscapeAttributeValue( case '<': result += "<"; break; + case '>': + result += ">"; + break; case '&': result +="&"; break; diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 1dafc1f..0c7803c 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -32,7 +32,7 @@ public: void BeginElement(const std::string& name); - void EndElement(); + void EndElement(const std::string& name); void AddProcessingInstruction( const std::string& target, const std::string& content); @@ -62,6 +62,8 @@ private: State state; std::vector<std::string> elements; + + std::string sourceFilename; }; #endif diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index d973c01..dfb2f15 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -474,7 +474,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); udco_image_command << " convert \"" << temp_image << "\""; udco_image_command << " -format UDCO"; - udco_image_command << " -o \"" << temp_udco << "\""; + udco_image_command << " -ov -o \"" << temp_udco << "\""; std::string error; if(!this->RunCommand(udco_image_command, &error)) @@ -504,6 +504,11 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Rez the SLA cmOStringStream embed_sla_command; embed_sla_command << this->GetOption("CPACK_COMMAND_REZ"); + const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT"); + if(sysroot && sysroot[0] != '\0') + { + embed_sla_command << " -isysroot \"" << sysroot << "\""; + } embed_sla_command << " \"" << sla_r << "\""; embed_sla_command << " -a -o "; embed_sla_command << "\"" << temp_udco << "\""; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 63a7596..5475c2f 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -637,19 +637,21 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( globalGenerator->FindMakeProgram(this->MakefileMap); const char* cmakeMakeProgram = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM"); - std::string buildCommand - = globalGenerator->GenerateBuildCommand(cmakeMakeProgram, - installProjectName.c_str(), 0, 0, + std::vector<std::string> buildCommand; + globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram, + installProjectName.c_str(), installDirectory.c_str(), globalGenerator->GetPreinstallTargetName(), - buildConfig, false, false); + buildConfig, false); + std::string buildCommandStr = + cmSystemTools::PrintSingleCommand(buildCommand); cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Install command: " << buildCommand << std::endl); + "- Install command: " << buildCommandStr << std::endl); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: " << installProjectName << std::endl); std::string output; int retVal = 1; bool resB = - cmSystemTools::RunSingleCommand(buildCommand.c_str(), + cmSystemTools::RunSingleCommand(buildCommand, &output, &retVal, installDirectory.c_str(), @@ -659,12 +661,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << buildCommand.c_str() << std::endl + ofs << "# Run command: " << buildCommandStr.c_str() << std::endl << "# Directory: " << installDirectory.c_str() << std::endl << "# Output:" << std::endl << output.c_str() << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << buildCommand.c_str() + "Problem running install command: " << buildCommandStr.c_str() << std::endl << "Please check " << tmpFile.c_str() << " for errors" << std::endl); @@ -1143,12 +1145,6 @@ int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; - if ( !this->SetCMakeRoot() ) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot initialize the generator" << std::endl); - return 0; - } // set the running generator name this->SetOption("CPACK_GENERATOR", this->Name.c_str()); // Load the project specific config file @@ -1205,32 +1201,6 @@ const char* cmCPackGenerator::GetOption(const char* op) const } //---------------------------------------------------------------------- -int cmCPackGenerator::SetCMakeRoot() -{ - // use the CMAKE_ROOT from cmake which should have been - // found by now - const char* root= - this->MakefileMap->GetDefinition("CMAKE_ROOT"); - - if(root) - { - this->CMakeRoot = root; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << this->CMakeRoot.c_str() << std::endl); - this->SetOption("CMAKE_ROOT", this->CMakeRoot.c_str()); - return 1; - } - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Could not find CMAKE_ROOT !!!" - << std::endl - << "CMake has most likely not been installed correctly." - << std::endl - <<"Modules directory not found in" - << std::endl); - return 0; -} - -//---------------------------------------------------------------------- int cmCPackGenerator::PackageFiles() { return 0; diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 5cb2280..bb33aa0 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -105,9 +105,6 @@ public: bool IsSet(const char* name) const; bool IsOn(const char* name) const; - //! Set all the variables - int SetCMakeRoot(); - //! Set the logger void SetLogger(cmCPackLog* log) { this->Logger = log; } @@ -285,10 +282,6 @@ protected: */ std::vector<std::string> files; - std::string CPackSelf; - std::string CMakeSelf; - std::string CMakeRoot; - std::map<std::string, cmCPackInstallationType> InstallationTypes; /** * The set of components. diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 9f8cc14..438b16d 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -99,7 +99,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, // this is CPack. int main (int argc, char *argv[]) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); cmCPackLog log; log.SetErrorPrefix("CPack Error: "); @@ -228,7 +228,6 @@ int main (int argc, char *argv[]) // This part is used for cpack documentation lookup as well. cminst.AddCMakePaths(); - doc.SetCMakeRoot(cminst.GetCacheDefinition("CMAKE_ROOT")); if ( parsed && !help ) { diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 4fa3c53..0fac136 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -18,6 +18,7 @@ #include "cmGlobalGenerator.h" #include <cmsys/Process.h> #include "cmCTestTestHandler.h" +#include "cmCacheManager.h" //---------------------------------------------------------------------- cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() @@ -59,7 +60,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, { unsigned int k; std::vector<std::string> args; - args.push_back(this->CTest->GetCMakeExecutable()); + args.push_back(cmSystemTools::GetCMakeCommand()); args.push_back(this->SourceDir); if(this->BuildGenerator.size()) { @@ -184,14 +185,14 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cmOStringStream out; // if the generator and make program are not specified then it is an error - if (!this->BuildGenerator.size() || !this->BuildMakeProgram.size()) + if (!this->BuildGenerator.size()) { if(outstring) { *outstring = - "--build-and-test requires that both the generator and makeprogram " - "be provided using the --build-generator and --build-makeprogram " - "command line options. "; + "--build-and-test requires that the generator " + "be provided using the --build-generator " + "command line option. "; } return 1; } @@ -238,9 +239,13 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) if(this->BuildNoCMake) { + // Make the generator available for the Build call below. cm.SetGlobalGenerator(cm.CreateGlobalGenerator( this->BuildGenerator.c_str())); cm.SetGeneratorToolset(this->BuildGeneratorToolset); + + // Load the cache to make CMAKE_MAKE_PROGRAM available. + cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str()); } else { @@ -508,23 +513,14 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( { this->BuildNoClean = true; } - if(currentArg.find("--build-options",0) == 0 && idx < allArgs.size() - 1) + if(currentArg.find("--build-options",0) == 0) { - ++idx; - bool done = false; - while(idx < allArgs.size() && !done) + while(idx+1 < allArgs.size() && + allArgs[idx+1] != "--build-target" && + allArgs[idx+1] != "--test-command") { + ++idx; this->BuildOptions.push_back(allArgs[idx]); - if(idx+1 < allArgs.size() - && (allArgs[idx+1] == "--build-target" || - allArgs[idx+1] == "--test-command")) - { - done = true; - } - else - { - ++idx; - } } } if(currentArg.find("--test-command",0) == 0 && idx < allArgs.size() - 1) diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 1f63185..12ff718 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -114,9 +114,6 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( cmakeGeneratorName); } - this->GlobalGenerator->FindMakeProgram(this->Makefile); - const char* cmakeMakeProgram - = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); if(strlen(cmakeBuildConfiguration) == 0) { const char* config = 0; @@ -133,10 +130,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = this->GlobalGenerator-> - GenerateBuildCommand(cmakeMakeProgram, - cmakeProjectName, dir.c_str(), - cmakeBuildAdditionalFlags, cmakeBuildTarget, - cmakeBuildConfiguration, true, false); + GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration, + cmakeBuildAdditionalFlags, true); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand.c_str() << "\n"); diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index db33cb6..5eed409 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -86,7 +86,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } std::string cmakeConfigureCommand = "\""; - cmakeConfigureCommand += this->CTest->GetCMakeExecutable(); + cmakeConfigureCommand += cmSystemTools::GetCMakeCommand(); cmakeConfigureCommand += "\""; std::vector<std::string>::const_iterator it; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index ef071b9..33b084e 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -142,6 +142,7 @@ void cmCTestCoverageHandler::Initialize() this->Superclass::Initialize(); this->CustomCoverageExclude.clear(); this->SourceLabels.clear(); + this->TargetDirs.clear(); this->LabelIdMap.clear(); this->Labels.clear(); this->LabelFilter.clear(); diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 76ddeea..4c39d10 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -41,6 +41,7 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler() this->Completed = 0; this->RunningCount = 0; this->StopTimePassed = false; + this->HasCycles = false; } cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler() @@ -65,6 +66,11 @@ cmCTestMultiProcessHandler::SetTests(TestMap& tests, if(!this->CTest->GetShowOnly()) { this->ReadCostData(); + this->HasCycles = !this->CheckCycles(); + if(this->HasCycles) + { + return; + } this->CreateTestCostList(); } } @@ -79,7 +85,7 @@ void cmCTestMultiProcessHandler::SetParallelLevel(size_t level) void cmCTestMultiProcessHandler::RunTests() { this->CheckResume(); - if(!this->CheckCycles()) + if(this->HasCycles) { return; } @@ -205,37 +211,8 @@ bool cmCTestMultiProcessHandler::StartTest(int test) } } - // copy the depend tests locally because when - // a test is finished it will be removed from the depend list - // and we don't want to be iterating a list while removing from it - TestSet depends = this->Tests[test]; - size_t totalDepends = depends.size(); - if(totalDepends) - { - for(TestSet::const_iterator i = depends.begin(); - i != depends.end(); ++i) - { - // if the test is not already running then start it - if(!this->TestRunningMap[*i]) - { - // this test might be finished, but since - // this is a copy of the depend map we might - // still have it - if(!this->TestFinishMap[*i]) - { - // only start one test in this function - return this->StartTest(*i); - } - else - { - // the depend has been and finished - totalDepends--; - } - } - } - } // if there are no depends left then run this test - if(totalDepends == 0) + if(this->Tests[test].empty()) { this->StartTestProcess(test); return true; @@ -262,25 +239,17 @@ void cmCTestMultiProcessHandler::StartNextTests() TestList copy = this->SortedTests; for(TestList::iterator test = copy.begin(); test != copy.end(); ++test) { - //in case this test has already been started due to dependency - if(this->TestRunningMap[*test] || this->TestFinishMap[*test]) - { - continue; - } size_t processors = GetProcessorsUsed(*test); - if(processors > numToStart) - { - return; - } - if(this->StartTest(*test)) + + if(processors <= numToStart && this->StartTest(*test)) { - if(this->StopTimePassed) - { - return; - } - numToStart -= processors; + if(this->StopTimePassed) + { + return; + } + numToStart -= processors; } - if(numToStart == 0) + else if(numToStart == 0) { return; } @@ -472,24 +441,88 @@ int cmCTestMultiProcessHandler::SearchByName(std::string name) //--------------------------------------------------------- void cmCTestMultiProcessHandler::CreateTestCostList() { - for(TestMap::iterator i = this->Tests.begin(); - i != this->Tests.end(); ++i) - { - SortedTests.push_back(i->first); + TestSet alreadySortedTests; + + std::list<TestSet> priorityStack; + priorityStack.push_back(TestSet()); + TestSet &topLevel = priorityStack.back(); - //If the test failed last time, it should be run first, so max the cost. - //Only do this for parallel runs; in non-parallel runs, avoid clobbering - //the test's explicitly set cost. + // In parallel test runs add previously failed tests to the front + // of the cost list and queue other tests for further sorting + for(TestMap::const_iterator i = this->Tests.begin(); + i != this->Tests.end(); ++i) + { if(this->ParallelLevel > 1 && std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(), this->Properties[i->first]->Name) != this->LastTestsFailed.end()) { - this->Properties[i->first]->Cost = FLT_MAX; + //If the test failed last time, it should be run first. + this->SortedTests.push_back(i->first); + alreadySortedTests.insert(i->first); + } + else + { + topLevel.insert(i->first); + } + } + + // Repeatedly move dependencies of the tests on the current dependency level + // to the next level until no further dependencies exist. + while(priorityStack.back().size()) + { + TestSet &previousSet = priorityStack.back(); + priorityStack.push_back(TestSet()); + TestSet ¤tSet = priorityStack.back(); + + for(TestSet::const_iterator i = previousSet.begin(); + i != previousSet.end(); ++i) + { + TestSet const& dependencies = this->Tests[*i]; + for(TestSet::const_iterator j = dependencies.begin(); + j != dependencies.end(); ++j) + { + currentSet.insert(*j); + } + } + + for(TestSet::const_iterator i = currentSet.begin(); + i != currentSet.end(); ++i) + { + previousSet.erase(*i); } } - TestComparator comp(this); - std::stable_sort(SortedTests.begin(), SortedTests.end(), comp); + // Remove the empty dependency level + priorityStack.pop_back(); + + // Reverse iterate over the different dependency levels (deepest first). + // Sort tests within each level by COST and append them to the cost list. + for(std::list<TestSet>::reverse_iterator i = priorityStack.rbegin(); + i != priorityStack.rend(); ++i) + { + TestSet const& currentSet = *i; + TestComparator comp(this); + + TestList sortedCopy; + + for(TestSet::const_iterator j = currentSet.begin(); + j != currentSet.end(); ++j) + { + sortedCopy.push_back(*j); + } + + std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp); + + for(TestList::const_iterator j = sortedCopy.begin(); + j != sortedCopy.end(); ++j) + { + if(alreadySortedTests.find(*j) == alreadySortedTests.end()) + { + this->SortedTests.push_back(*j); + alreadySortedTests.insert(*j); + } + } + } } //--------------------------------------------------------- diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index cd21d91..439a8f3 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -111,6 +111,7 @@ protected: std::set<cmCTestRunTest*> RunningTests; // current running tests cmCTestTestHandler * TestHandler; cmCTest* CTest; + bool HasCycles; }; #endif diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx new file mode 100644 index 0000000..0058721 --- /dev/null +++ b/Source/CTest/cmCTestP4.cxx @@ -0,0 +1,559 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmCTestP4.h" + +#include "cmCTest.h" +#include "cmSystemTools.h" +#include "cmXMLSafe.h" + +#include <cmsys/RegularExpression.hxx> +#include <cmsys/ios/sstream> +#include <cmsys/Process.h> + +#include <sys/types.h> +#include <time.h> +#include <ctype.h> + +//---------------------------------------------------------------------------- +cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log): + cmCTestGlobalVC(ct, log) +{ + this->PriorRev = this->Unknown; +} + +//---------------------------------------------------------------------------- +cmCTestP4::~cmCTestP4() +{ +} + +//---------------------------------------------------------------------------- +class cmCTestP4::IdentifyParser: public cmCTestVC::LineParser +{ +public: + IdentifyParser(cmCTestP4* p4, const char* prefix, + std::string& rev): Rev(rev) + { + this->SetLog(&p4->Log, prefix); + this->RegexIdentify.compile("^Change ([0-9]+) on"); + } +private: + std::string& Rev; + cmsys::RegularExpression RegexIdentify; + + bool ProcessLine() + { + if(this->RegexIdentify.find(this->Line)) + { + this->Rev = this->RegexIdentify.match(1); + return false; + } + return true; + } +}; + +//---------------------------------------------------------------------------- +class cmCTestP4::ChangesParser: public cmCTestVC::LineParser +{ +public: + ChangesParser(cmCTestP4* p4, const char* prefix) : P4(p4) + { + this->SetLog(&P4->Log, prefix); + this->RegexIdentify.compile("^Change ([0-9]+) on"); + } +private: + cmsys::RegularExpression RegexIdentify; + cmCTestP4* P4; + + bool ProcessLine() + { + if(this->RegexIdentify.find(this->Line)) + { + P4->ChangeLists.push_back(this->RegexIdentify.match(1)); + } + return true; + } +}; + +//---------------------------------------------------------------------------- +class cmCTestP4::UserParser: public cmCTestVC::LineParser +{ +public: + UserParser(cmCTestP4* p4, const char* prefix) : P4(p4) + { + this->SetLog(&P4->Log, prefix); + this->RegexUser.compile("^(.+) <(.*)> \\((.*)\\) accessed (.*)$"); + } +private: + cmsys::RegularExpression RegexUser; + cmCTestP4* P4; + + bool ProcessLine() + { + if(this->RegexUser.find(this->Line)) + { + User NewUser; + + NewUser.UserName = this->RegexUser.match(1); + NewUser.EMail = this->RegexUser.match(2); + NewUser.Name = this->RegexUser.match(3); + NewUser.AccessTime = this->RegexUser.match(4); + P4->Users[this->RegexUser.match(1)] = NewUser; + + return false; + } + return true; + } +}; + +//---------------------------------------------------------------------------- +/* Diff format: +==== //depot/file#rev - /absolute/path/to/file ==== +(diff data) +==== //depot/file2#rev - /absolute/path/to/file2 ==== +(diff data) +==== //depot/file3#rev - /absolute/path/to/file3 ==== +==== //depot/file4#rev - /absolute/path/to/file4 ==== +(diff data) +*/ +class cmCTestP4::DiffParser: public cmCTestVC::LineParser +{ +public: + DiffParser(cmCTestP4* p4, const char* prefix) + : P4(p4), AlreadyNotified(false) + { + this->SetLog(&P4->Log, prefix); + this->RegexDiff.compile("^==== (.*)#[0-9]+ - (.*)"); + } +private: + cmCTestP4* P4; + bool AlreadyNotified; + std::string CurrentPath; + cmsys::RegularExpression RegexDiff; + + bool ProcessLine() + { + if(!this->Line.empty() && this->Line[0] == '=' + && this->RegexDiff.find(this->Line)) + { + CurrentPath = this->RegexDiff.match(1); + AlreadyNotified = false; + } + else + { + if(!AlreadyNotified) + { + P4->DoModification(PathModified, CurrentPath); + AlreadyNotified = true; + } + } + return true; + } +}; + +//---------------------------------------------------------------------------- +cmCTestP4::User cmCTestP4::GetUserData(const std::string& username) +{ + std::map<std::string, cmCTestP4::User>::const_iterator it = + Users.find(username); + + if(it == Users.end()) + { + std::vector<char const*> p4_users; + SetP4Options(p4_users); + p4_users.push_back("users"); + p4_users.push_back("-m"); + p4_users.push_back("1"); + p4_users.push_back(username.c_str()); + p4_users.push_back(0); + + UserParser out(this, "users-out> "); + OutputLogger err(this->Log, "users-err> "); + RunChild(&p4_users[0], &out, &err); + + // The user should now be added to the map. Search again. + it = Users.find(username); + if(it == Users.end()) + { + return cmCTestP4::User(); + } + } + + return it->second; +} + +//---------------------------------------------------------------------------- +/* Commit format: + +Change 1111111 by user@client on 2013/09/26 11:50:36 + + text + text + +Affected files ... + +... //path/to/file#rev edit +... //path/to/file#rev add +... //path/to/file#rev delete +... //path/to/file#rev integrate +*/ +class cmCTestP4::DescribeParser: public cmCTestVC::LineParser +{ +public: + DescribeParser(cmCTestP4* p4, const char* prefix): + LineParser('\n', false), P4(p4), Section(SectionHeader) + { + this->SetLog(&P4->Log, prefix); + this->RegexHeader.compile("^Change ([0-9]+) by (.+)@(.+) on (.*)$"); + this->RegexDiff.compile("^\\.\\.\\. (.*)#[0-9]+ ([^ ]+)$"); + } +private: + cmsys::RegularExpression RegexHeader; + cmsys::RegularExpression RegexDiff; + cmCTestP4* P4; + + typedef cmCTestP4::Revision Revision; + typedef cmCTestP4::Change Change; + std::vector<Change> Changes; + enum SectionType { SectionHeader, SectionBody, SectionDiffHeader, + SectionDiff, SectionCount }; + SectionType Section; + Revision Rev; + + virtual bool ProcessLine() + { + if(this->Line.empty()) + { + this->NextSection(); + } + else + { + switch(this->Section) + { + case SectionHeader: this->DoHeaderLine(); break; + case SectionBody: this->DoBodyLine(); break; + case SectionDiffHeader: break; // nothing to do + case SectionDiff: this->DoDiffLine(); break; + case SectionCount: break; // never happens + } + } + return true; + } + + void NextSection() + { + if(this->Section == SectionDiff) + { + this->P4->DoRevision(this->Rev, this->Changes); + this->Rev = Revision(); + } + + this->Section = SectionType((this->Section+1) % SectionCount); + } + + void DoHeaderLine() + { + if(this->RegexHeader.find(this->Line)) + { + this->Rev.Rev = this->RegexHeader.match(1); + this->Rev.Date = this->RegexHeader.match(4); + + cmCTestP4::User user = P4->GetUserData(this->RegexHeader.match(2)); + this->Rev.Author = user.Name; + this->Rev.EMail = user.EMail; + + this->Rev.Committer = this->Rev.Author; + this->Rev.CommitterEMail = this->Rev.EMail; + this->Rev.CommitDate = this->Rev.Date; + } + } + + void DoBodyLine() + { + if(this->Line[0] == '\t') + { + this->Rev.Log += this->Line.substr(1); + } + this->Rev.Log += "\n"; + } + + void DoDiffLine() + { + if(this->RegexDiff.find(this->Line)) + { + Change change; + std::string Path = this->RegexDiff.match(1); + if(Path.length() > 2 && Path[0] == '/' && Path[1] == '/') + { + size_t found = Path.find('/', 2); + if(found != std::string::npos) + { + Path = Path.substr(found + 1); + } + } + + change.Path = Path; + std::string action = this->RegexDiff.match(2); + + if(action == "add") + { + change.Action = 'A'; + } + else if(action == "delete") + { + change.Action = 'D'; + } + else if(action == "edit" || action == "integrate") + { + change.Action = 'M'; + } + + Changes.push_back(change); + } + } +}; + +//---------------------------------------------------------------------------- +void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions) +{ + if(P4Options.size() == 0) + { + const char* p4 = this->CommandLineTool.c_str(); + P4Options.push_back(p4); + + //The CTEST_P4_CLIENT variable sets the P4 client used when issuing + //Perforce commands, if it's different from the default one. + std::string client = this->CTest->GetCTestConfiguration("P4Client"); + if(!client.empty()) + { + P4Options.push_back("-c"); + P4Options.push_back(client); + } + + //Set the message language to be English, in case the P4 admin + //has localized them + P4Options.push_back("-L"); + P4Options.push_back("en"); + + //The CTEST_P4_OPTIONS variable adds additional Perforce command line + //options before the main command + std::string opts = this->CTest->GetCTestConfiguration("P4Options"); + std::vector<cmStdString> args = + cmSystemTools::ParseArguments(opts.c_str()); + + for(std::vector<cmStdString>::const_iterator ai = args.begin(); + ai != args.end(); ++ai) + { + P4Options.push_back(ai->c_str()); + } + } + + CommandOptions.clear(); + for(std::vector<std::string>::iterator i = P4Options.begin(); + i != P4Options.end(); ++i) + { + CommandOptions.push_back(i->c_str()); + } +} + +//---------------------------------------------------------------------------- +std::string cmCTestP4::GetWorkingRevision() +{ + std::vector<char const*> p4_identify; + SetP4Options(p4_identify); + + p4_identify.push_back("changes"); + p4_identify.push_back("-m"); + p4_identify.push_back("1"); + p4_identify.push_back("-t"); + + std::string source = this->SourceDirectory + "/...#have"; + p4_identify.push_back(source.c_str()); + p4_identify.push_back(0); + + std::string rev; + IdentifyParser out(this, "rev-out> ", rev); + OutputLogger err(this->Log, "rev-err> "); + + RunChild(&p4_identify[0], &out, &err); + + if(rev.empty()) + { + return "0"; + } + else + { + return rev; + } +} + +//---------------------------------------------------------------------------- +void cmCTestP4::NoteOldRevision() +{ + this->OldRevision = this->GetWorkingRevision(); + + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: " + << this->OldRevision << "\n"); + this->PriorRev.Rev = this->OldRevision; +} + +//---------------------------------------------------------------------------- +void cmCTestP4::NoteNewRevision() +{ + this->NewRevision = this->GetWorkingRevision(); + + cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: " + << this->NewRevision << "\n"); +} + +//---------------------------------------------------------------------------- +void cmCTestP4::LoadRevisions() +{ + std::vector<char const*> p4_changes; + SetP4Options(p4_changes); + + // Use 'p4 changes ...@old,new' to get a list of changelists + std::string range = this->SourceDirectory + "/..."; + + if(this->OldRevision != "0") + { + range.append("@").append(this->OldRevision); + } + + if(this->NewRevision != "0") + { + if(this->OldRevision != "0") + { + range.append(",").append(this->NewRevision); + } + else + { + range.append("@").append(this->NewRevision); + } + } + + p4_changes.push_back("changes"); + p4_changes.push_back(range.c_str()); + p4_changes.push_back(0); + + ChangesParser out(this, "changes-out> "); + OutputLogger err(this->Log, "changes-err> "); + + ChangeLists.clear(); + this->RunChild(&p4_changes[0], &out, &err); + + if(ChangeLists.size() == 0) + return; + + //p4 describe -s ...@1111111,2222222 + std::vector<char const*> p4_describe; + for(std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin(); + i != ChangeLists.rend(); ++i) + { + SetP4Options(p4_describe); + p4_describe.push_back("describe"); + p4_describe.push_back("-s"); + p4_describe.push_back(i->c_str()); + p4_describe.push_back(0); + + DescribeParser outDescribe(this, "describe-out> "); + OutputLogger errDescribe(this->Log, "describe-err> "); + this->RunChild(&p4_describe[0], &outDescribe, &errDescribe); + } +} + +//---------------------------------------------------------------------------- +void cmCTestP4::LoadModifications() +{ + std::vector<char const*> p4_diff; + SetP4Options(p4_diff); + + p4_diff.push_back("diff"); + + //Ideally we would use -Od but not all clients support it + p4_diff.push_back("-dn"); + std::string source = this->SourceDirectory + "/..."; + p4_diff.push_back(source.c_str()); + p4_diff.push_back(0); + + DiffParser out(this, "diff-out> "); + OutputLogger err(this->Log, "diff-err> "); + this->RunChild(&p4_diff[0], &out, &err); +} + +//---------------------------------------------------------------------------- +bool cmCTestP4::UpdateCustom(const std::string& custom) +{ + std::vector<std::string> p4_custom_command; + cmSystemTools::ExpandListArgument(custom, p4_custom_command, true); + + std::vector<char const*> p4_custom; + for(std::vector<std::string>::const_iterator + i = p4_custom_command.begin(); i != p4_custom_command.end(); ++i) + { + p4_custom.push_back(i->c_str()); + } + p4_custom.push_back(0); + + OutputLogger custom_out(this->Log, "custom-out> "); + OutputLogger custom_err(this->Log, "custom-err> "); + + return this->RunUpdateCommand(&p4_custom[0], &custom_out, &custom_err); +} + +//---------------------------------------------------------------------------- +bool cmCTestP4::UpdateImpl() +{ + std::string custom = this->CTest->GetCTestConfiguration("P4UpdateCustom"); + if(!custom.empty()) + { + return this->UpdateCustom(custom); + } + + std::vector<char const*> p4_sync; + SetP4Options(p4_sync); + + p4_sync.push_back("sync"); + + // Get user-specified update options. + std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); + if(opts.empty()) + { + opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); + } + std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector<cmStdString>::const_iterator ai = args.begin(); + ai != args.end(); ++ai) + { + p4_sync.push_back(ai->c_str()); + } + + std::string source = this->SourceDirectory + "/..."; + + // Specify the start time for nightly testing. + if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) + { + std::string date = this->GetNightlyTime(); + //CTest reports the date as YYYY-MM-DD, Perforce needs it as YYYY/MM/DD + std::replace(date.begin(), date.end(), '-', '/'); + + //Revision specification: /...@"YYYY/MM/DD HH:MM:SS" + source.append("@\"").append(date).append("\""); + } + + p4_sync.push_back(source.c_str()); + p4_sync.push_back(0); + + OutputLogger out(this->Log, "sync-out> "); + OutputLogger err(this->Log, "sync-err> "); + + return this->RunUpdateCommand(&p4_sync[0], &out, &err); +} diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h new file mode 100644 index 0000000..7a53475 --- /dev/null +++ b/Source/CTest/cmCTestP4.h @@ -0,0 +1,71 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmCTestP4_h +#define cmCTestP4_h + +#include "cmCTestGlobalVC.h" +#include <vector> +#include <map> + +/** \class cmCTestP4 + * \brief Interaction with the Perforce command-line tool + * + */ +class cmCTestP4: public cmCTestGlobalVC +{ +public: + /** Construct with a CTest instance and update log stream. */ + cmCTestP4(cmCTest* ctest, std::ostream& log); + + virtual ~cmCTestP4(); + +private: + std::vector<std::string> ChangeLists; + + struct User + { + std::string UserName; + std::string Name; + std::string EMail; + std::string AccessTime; + + User(): UserName(), Name(), EMail(), AccessTime() {} + }; + std::map<std::string, User> Users; + std::vector<std::string> P4Options; + + User GetUserData(const std::string& username); + void SetP4Options(std::vector<char const*> &options); + + std::string GetWorkingRevision(); + virtual void NoteOldRevision(); + virtual void NoteNewRevision(); + virtual bool UpdateImpl(); + bool UpdateCustom(const std::string& custom); + + void LoadRevisions(); + void LoadModifications(); + + // Parsing helper classes. + class IdentifyParser; + class ChangesParser; + class UserParser; + class DescribeParser; + class DiffParser; + friend class IdentifyParser; + friend class ChangesParser; + friend class UserParser; + friend class DescribeParser; + friend class DiffParser; +}; + +#endif diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 64bcd59..00a0a09 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -22,6 +22,7 @@ //#include <cmsys/RegularExpression.hxx> #include <cmsys/Process.h> +#include <cmsys/Directory.hxx> // used for sleep #ifdef _WIN32 @@ -221,13 +222,13 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) // execute the script passing in the arguments to the script as well as the // arguments from this invocation of cmake std::vector<const char*> argv; - argv.push_back(this->CTest->GetCTestExecutable()); + argv.push_back(cmSystemTools::GetCTestCommand().c_str()); argv.push_back("-SR"); argv.push_back(total_script_arg.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Executable for CTest is: " << - this->CTest->GetCTestExecutable() << "\n"); + cmSystemTools::GetCTestCommand() << "\n"); // now pass through all the other arguments std::vector<cmStdString> &initArgs = @@ -396,9 +397,9 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) this->Makefile->AddDefinition("CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str()); this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME", - this->CTest->GetCTestExecutable()); + cmSystemTools::GetCTestCommand().c_str()); this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME", - this->CTest->GetCMakeExecutable()); + cmSystemTools::GetCMakeCommand().c_str()); this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); this->UpdateElapsedTime(); @@ -1056,15 +1057,71 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname) return false; } + // consider non existing target directory a success + if(!cmSystemTools::FileExists(sname)) + { + return true; + } + // try to avoid deleting directories that we shouldn't std::string check = sname; check += "/CMakeCache.txt"; - if(cmSystemTools::FileExists(check.c_str()) && - !cmSystemTools::RemoveADirectory(sname)) + + if(!cmSystemTools::FileExists(check.c_str())) { return false; } - return true; + + for(int i = 0; i < 5; ++i) + { + if(TryToRemoveBinaryDirectoryOnce(sname)) + { + return true; + } + cmSystemTools::Delay(100); + } + + return false; +} + +//------------------------------------------------------------------------- +bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( + const std::string& directoryPath) +{ + cmsys::Directory directory; + directory.Load(directoryPath.c_str()); + + for(unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i) + { + std::string path = directory.GetFile(i); + + if(path == "." || path == ".." || path == "CMakeCache.txt") + { + continue; + } + + std::string fullPath = directoryPath + std::string("/") + path; + + bool isDirectory = cmSystemTools::FileIsDirectory(fullPath.c_str()) && + !cmSystemTools::FileIsSymlink(fullPath.c_str()); + + if(isDirectory) + { + if(!cmSystemTools::RemoveADirectory(fullPath.c_str())) + { + return false; + } + } + else + { + if(!cmSystemTools::RemoveFile(fullPath.c_str())) + { + return false; + } + } + } + + return cmSystemTools::RemoveADirectory(directoryPath.c_str()); } //------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 80d5831..44e9dd0 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -135,6 +135,9 @@ private: // Add ctest command void AddCTestCommand(cmCTestCommand* command); + // Try to remove the binary directory once + static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath); + std::vector<cmStdString> ConfigurationScripts; std::vector<bool> ScriptProcessScope; diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 2ca9f6c..5408a8a 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -59,6 +59,14 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() "HGCommand", "CTEST_HG_COMMAND"); this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4Command", "CTEST_P4_COMMAND"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4Client", "CTEST_P4_CLIENT"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4Options", "CTEST_P4_OPTIONS"); cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("update"); diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 9eae3f3..11474ec 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -28,6 +28,7 @@ #include "cmCTestBZR.h" #include "cmCTestGIT.h" #include "cmCTestHG.h" +#include "cmCTestP4.h" #include <cmsys/auto_ptr.hxx> @@ -51,7 +52,8 @@ static const char* cmCTestUpdateHandlerUpdateStrings[] = "SVN", "BZR", "GIT", - "HG" + "HG", + "P4" }; static const char* cmCTestUpdateHandlerUpdateToString(int type) @@ -146,6 +148,10 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) { return cmCTestUpdateHandler::e_HG; } + if ( stype.find("p4") != std::string::npos ) + { + return cmCTestUpdateHandler::e_P4; + } } else { @@ -172,6 +178,10 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) { return cmCTestUpdateHandler::e_HG; } + if ( stype.find("p4") != std::string::npos ) + { + return cmCTestUpdateHandler::e_P4; + } } return cmCTestUpdateHandler::e_UNKNOWN; } @@ -223,6 +233,7 @@ int cmCTestUpdateHandler::ProcessHandler() case e_BZR: vc.reset(new cmCTestBZR(this->CTest, ofs)); break; case e_GIT: vc.reset(new cmCTestGIT(this->CTest, ofs)); break; case e_HG: vc.reset(new cmCTestHG(this->CTest, ofs)); break; + case e_P4: vc.reset(new cmCTestP4(this->CTest, ofs)); break; default: vc.reset(new cmCTestVC(this->CTest, ofs)); break; } vc->SetCommandLineTool(this->UpdateCommand); @@ -350,6 +361,18 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir) { return cmCTestUpdateHandler::e_HG; } + sourceDirectory = dir; + sourceDirectory += "/.p4"; + if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) + { + return cmCTestUpdateHandler::e_P4; + } + sourceDirectory = dir; + sourceDirectory += "/.p4config"; + if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) + { + return cmCTestUpdateHandler::e_P4; + } return cmCTestUpdateHandler::e_UNKNOWN; } @@ -380,6 +403,7 @@ bool cmCTestUpdateHandler::SelectVCS() case e_BZR: key = "BZRCommand"; break; case e_GIT: key = "GITCommand"; break; case e_HG: key = "HGCommand"; break; + case e_P4: key = "P4Command"; break; default: break; } if (key) diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h index 55ec974..954c024 100644 --- a/Source/CTest/cmCTestUpdateHandler.h +++ b/Source/CTest/cmCTestUpdateHandler.h @@ -44,6 +44,7 @@ public: e_BZR, e_GIT, e_HG, + e_P4, e_LAST }; diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index fdfe331..ce50845 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -80,14 +80,13 @@ void CMakeErrorHandler(const char* message, const char* title, bool&, void* clie int main(int argc, char** argv) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); cmDocumentation doc; doc.addCMakeStandardDocSections(); if(doc.CheckOptions(argc, argv)) { cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); std::vector<cmDocumentationEntry> generators; hcm.GetGeneratorDocumentation(generators); doc.SetName("ccmake"); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 4fee0bb..d94cd37 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -43,14 +43,14 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, this->HelpMessage.push_back(""); this->HelpMessage.push_back(s_ConstHelpMessage); this->CMakeInstance = new cmake; - this->CMakeInstance->SetCMakeEditCommand("ccmake"); + this->CMakeInstance->SetCMakeEditCommand( + cmSystemTools::GetCMakeCursesCommand()); // create the arguments for the cmake object std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0].c_str()); whereCMake += "/cmake"; this->Args[0] = whereCMake; this->CMakeInstance->SetArgs(this->Args); - this->CMakeInstance->SetCMakeCommand(whereCMake.c_str()); this->SearchString = ""; this->OldSearchString = ""; this->SearchMode = false; diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 15f9ef1..f1f4649 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -111,12 +111,22 @@ if(Qt_BIN_DIR) endif() if(APPLE) + file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line + LIMIT_COUNT 1 REGEX "^Copyright 2000-20[0-9][0-9] Kitware") + set_target_properties(cmake-gui PROPERTIES - OUTPUT_NAME ${CMAKE_BUNDLE_NAME} + OUTPUT_NAME CMake MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" MACOSX_BUNDLE_SHORT_VERSION_STRING "${CMAKE_BUNDLE_VERSION}" # TBD: MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_BUNDLE_VERSION}" - MACOSX_BUNDLE_COPYRIGHT "Copyright 2000-2013 Kitware, Inc." + MACOSX_BUNDLE_COPYRIGHT "${copyright_line}" + ) + + # Create a symlink in the build tree to provide a "cmake-gui" next + # to the "cmake" executable that refers to the application bundle. + add_custom_command(TARGET cmake-gui POST_BUILD + COMMAND ln -sf CMake.app/Contents/MacOS/CMake + $<TARGET_FILE_DIR:cmake>/cmake-gui ) endif() set(CMAKE_INSTALL_DESTINATION_ARGS @@ -141,7 +151,7 @@ if(APPLE) "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh") configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in" "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh") - install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui + install(CODE "execute_process(COMMAND ln -s \"../MacOS/CMake\" cmake-gui WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)") endif() @@ -150,7 +160,7 @@ if(APPLE OR WIN32) # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}") if(APPLE) - set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}") + set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/CMake") endif() install(CODE " include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\") diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 095aeb6..408bb4c 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -48,7 +48,7 @@ static const char * cmDocumentationOptions[][2] = int main(int argc, char** argv) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); // check docs first so that X is not need to get docs // do docs, if args were given cmDocumentation doc; @@ -58,7 +58,6 @@ int main(int argc, char** argv) // Construct and print requested documentation. cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); std::vector<cmDocumentationEntry> generators; hcm.GetGeneratorDocumentation(generators); diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index a4dfdc9..a7665c8 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -1230,7 +1230,7 @@ void CMakeSetupDialog::doOutputFindNext(bool directionForward) QString search = this->FindHistory.front(); - QTextCursor cursor = this->Output->textCursor(); + QTextCursor textCursor = this->Output->textCursor(); QTextDocument* document = this->Output->document(); QTextDocument::FindFlags flags; if (!directionForward) @@ -1238,67 +1238,67 @@ void CMakeSetupDialog::doOutputFindNext(bool directionForward) flags |= QTextDocument::FindBackward; } - cursor = document->find(search, cursor, flags); + textCursor = document->find(search, textCursor, flags); - if (cursor.isNull()) + if (textCursor.isNull()) { // first search found nothing, wrap around and search again - cursor = this->Output->textCursor(); - cursor.movePosition(directionForward ? QTextCursor::Start - : QTextCursor::End); - cursor = document->find(search, cursor, flags); + textCursor = this->Output->textCursor(); + textCursor.movePosition(directionForward ? QTextCursor::Start + : QTextCursor::End); + textCursor = document->find(search, textCursor, flags); } - if (cursor.hasSelection()) + if (textCursor.hasSelection()) { - this->Output->setTextCursor(cursor); + this->Output->setTextCursor(textCursor); } } void CMakeSetupDialog::doOutputErrorNext() { - QTextCursor cursor = this->Output->textCursor(); + QTextCursor textCursor = this->Output->textCursor(); bool atEnd = false; // move cursor out of current error-block - if (cursor.blockCharFormat() == this->ErrorFormat) + if (textCursor.blockCharFormat() == this->ErrorFormat) { - atEnd = !cursor.movePosition(QTextCursor::NextBlock); + atEnd = !textCursor.movePosition(QTextCursor::NextBlock); } // move cursor to next error-block - while (cursor.blockCharFormat() != this->ErrorFormat && !atEnd) + while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) { - atEnd = !cursor.movePosition(QTextCursor::NextBlock); + atEnd = !textCursor.movePosition(QTextCursor::NextBlock); } if (atEnd) { // first search found nothing, wrap around and search again - atEnd = !cursor.movePosition(QTextCursor::Start); + atEnd = !textCursor.movePosition(QTextCursor::Start); // move cursor to next error-block - while (cursor.blockCharFormat() != this->ErrorFormat && !atEnd) + while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) { - atEnd = !cursor.movePosition(QTextCursor::NextBlock); + atEnd = !textCursor.movePosition(QTextCursor::NextBlock); } } if (!atEnd) { - cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + textCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); QTextCharFormat selectionFormat; selectionFormat.setBackground(Qt::yellow); - QTextEdit::ExtraSelection extraSelection = {cursor, selectionFormat}; + QTextEdit::ExtraSelection extraSelection = {textCursor, selectionFormat}; this->Output->setExtraSelections(QList<QTextEdit::ExtraSelection>() << extraSelection); // make the whole error-block visible - this->Output->setTextCursor(cursor); + this->Output->setTextCursor(textCursor); // remove the selection to see the extraSelection - cursor.setPosition(cursor.anchor()); - this->Output->setTextCursor(cursor); + textCursor.setPosition(textCursor.anchor()); + this->Output->setTextCursor(textCursor); } } diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0d01181..0fe5f8c 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -33,34 +33,13 @@ QCMake::QCMake(QObject* p) qRegisterMetaType<QCMakeProperty>(); qRegisterMetaType<QCMakePropertyList>(); - QDir execDir(QCoreApplication::applicationDirPath()); - -#if defined(Q_OS_MAC) - if(execDir.exists("../bin/cmake")) - { - execDir.cd("../bin"); - } - else - { - execDir.cd("../../../"); // path to cmake in build directory (need to fix for deployment) - } -#endif - - QString cmakeCommand = QString("cmake")+QString::fromLocal8Bit(cmSystemTools::GetExecutableExtension()); - cmakeCommand = execDir.filePath(cmakeCommand); - cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetErrorCallback(QCMake::errorCallback, this); - cmSystemTools::FindExecutableDirectory(cmakeCommand.toLocal8Bit().data()); this->CMakeInstance = new cmake; - this->CMakeInstance->SetCMakeCommand(cmakeCommand.toLocal8Bit().data()); -#if defined(Q_OS_MAC) - this->CMakeInstance->SetCMakeEditCommand("cmake-gui.app/Contents/MacOS/cmake-gui"); -#else - this->CMakeInstance->SetCMakeEditCommand("cmake-gui"); -#endif + this->CMakeInstance->SetCMakeEditCommand( + cmSystemTools::GetCMakeGUICommand()); this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this); diff --git a/Source/QtDialog/postflight.sh.in b/Source/QtDialog/postflight.sh.in index 33be352..0b96889 100755 --- a/Source/QtDialog/postflight.sh.in +++ b/Source/QtDialog/postflight.sh.in @@ -1,3 +1,3 @@ #!/bin/bash -"$2@CMAKE_INSTALL_SUBDIR@/@CMAKE_BUNDLE_NAME@.app/Contents/MacOS/@CMAKE_BUNDLE_NAME@" --mac-install +"$2@CMAKE_INSTALL_SUBDIR@/CMake.app/Contents/MacOS/CMake" --mac-install exit 0 diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 4eba886..ef62523 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -11,6 +11,9 @@ ============================================================================*/ #include "cmAddCustomTargetCommand.h" +#include "cmGeneratorExpression.h" +#include "cmGlobalGenerator.h" + // cmAddCustomTargetCommand bool cmAddCustomTargetCommand ::InitialPass(std::vector<std::string> const& args, @@ -22,20 +25,17 @@ bool cmAddCustomTargetCommand return false; } + std::string targetName = args[0]; + // Check the target name. - if(args[0].find_first_of("/\\") != args[0].npos) + if(targetName.find_first_of("/\\") != targetName.npos) { - if(!this->Makefile->NeedBackwardsCompatibility(2,2)) - { - cmOStringStream e; - e << "called with invalid target name \"" << args[0] - << "\". Target names may not contain a slash. " - << "Use ADD_CUSTOM_COMMAND to generate files. " - << "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 " - << "or lower to skip this check."; - this->SetError(e.str().c_str()); - return false; - } + cmOStringStream e; + e << "called with invalid target name \"" << targetName + << "\". Target names may not contain a slash. " + << "Use ADD_CUSTOM_COMMAND to generate files."; + this->SetError(e.str().c_str()); + return false; } // Accumulate one command line at a time. @@ -143,16 +143,59 @@ bool cmAddCustomTargetCommand } } - std::string::size_type pos = args[0].find_first_of("#<>"); - if(pos != args[0].npos) + std::string::size_type pos = targetName.find_first_of("#<>"); + if(pos != targetName.npos) { cmOStringStream msg; - msg << "called with target name containing a \"" << args[0][pos] + msg << "called with target name containing a \"" << targetName[pos] << "\". This character is not allowed."; this->SetError(msg.str().c_str()); return false; } + // Some requirements on custom target names already exist + // and have been checked at this point. + // The following restrictions overlap but depend on policy CMP0037. + bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) && + !cmGlobalGenerator::IsReservedTarget(targetName); + if (nameOk) + { + nameOk = targetName.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << targetName << + "\" is reserved or not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // Store the last command line finished. if(!currentLine.empty()) { @@ -163,7 +206,7 @@ bool cmAddCustomTargetCommand // Enforce name uniqueness. { std::string msg; - if(!this->Makefile->EnforceUniqueName(args[0], msg, true)) + if(!this->Makefile->EnforceUniqueName(targetName, msg, true)) { this->SetError(msg.c_str()); return false; @@ -181,7 +224,7 @@ bool cmAddCustomTargetCommand // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = - this->Makefile->AddUtilityCommand(args[0].c_str(), excludeFromAll, + this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll, working_directory.c_str(), depends, commandLines, escapeOldStyle, comment); diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 5785259..a352be0 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -69,6 +69,47 @@ bool cmAddExecutableCommand } } + bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) && + !cmGlobalGenerator::IsReservedTarget(exename); + + if (nameOk && !importTarget && !isAlias) + { + nameOk = exename.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << exename << + "\" is reserved or not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // Special modifiers are not allowed with IMPORTED signature. if(importTarget && (use_win32 || use_macbundle || excludeFromAll)) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 0e61c99..0f98f35 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -108,6 +108,48 @@ bool cmAddLibraryCommand break; } } + + bool nameOk = cmGeneratorExpression::IsValidTargetName(libName) && + !cmGlobalGenerator::IsReservedTarget(libName); + + if (nameOk && !importTarget && !isAlias) + { + nameOk = libName.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = type != cmTarget::INTERFACE_LIBRARY; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << libName << + "\" is reserved or not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + if (isAlias) { if(!cmGeneratorExpression::IsValidTargetName(libName.c_str())) @@ -190,6 +232,7 @@ bool cmAddLibraryCommand yet its linker language. */ if ((type != cmTarget::STATIC_LIBRARY) && (type != cmTarget::OBJECT_LIBRARY) && + (type != cmTarget::INTERFACE_LIBRARY) && (this->Makefile->GetCMakeInstance()->GetPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index b6e2569..c06b8ad 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -85,18 +85,7 @@ bool cmBuildCommand } } - const char* makeprogram - = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); - if(!makeprogram) - { - this->Makefile->IssueMessage( - cmake::FATAL_ERROR, - "build_command() requires CMAKE_MAKE_PROGRAM to be defined. " - "Call project() or enable_language() first."); - return true; - } - - // If null/empty CONFIGURATION argument, GenerateBuildCommand uses 'Debug' + // If null/empty CONFIGURATION argument, cmake --build uses 'Debug' // in the currently implemented multi-configuration global generators... // so we put this code here to end up with the same default configuration // as the original 2-arg build_command signature: @@ -110,19 +99,15 @@ bool cmBuildCommand configuration = "Release"; } - // If null/empty PROJECT_NAME argument, use the Makefile's project name: - // - if(!project_name || !*project_name) + if(project_name && *project_name) { - project_name = this->Makefile->GetProjectName(); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + "Ignoring PROJECT_NAME option because it has no effect."); } - // If null/empty TARGET argument, GenerateBuildCommand omits any mention - // of a target name on the build command line... - // std::string makecommand = this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GenerateBuildCommand - (makeprogram, project_name, 0, 0, target, configuration, true, false); + ->GetGlobalGenerator()->GenerateCMakeBuildCommand(target, configuration, + 0, true); this->Makefile->AddDefinition(variable, makecommand.c_str()); @@ -142,7 +127,6 @@ bool cmBuildCommand const char* define = args[0].c_str(); const char* cacheValue = this->Makefile->GetDefinition(define); - std::string makeprogram = args[1]; std::string configType = "Release"; const char* cfg = getenv("CMAKE_CONFIG_TYPE"); @@ -152,9 +136,8 @@ bool cmBuildCommand } std::string makecommand = this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GenerateBuildCommand - (makeprogram.c_str(), this->Makefile->GetProjectName(), 0, 0, - 0, configType.c_str(), true, false); + ->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(), + 0, true); if(cacheValue) { diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index 49c585f..6e2ca64 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -114,6 +114,9 @@ bool cmCMakeMinimumRequired if (required_major < 2 || (required_major == 2 && required_minor < 4)) { + this->Makefile->IssueMessage( + cmake::AUTHOR_WARNING, + "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0."); this->Makefile->SetPolicyVersion("2.4"); } else diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 98f19cc..bfabc9f 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1298,7 +1298,8 @@ int cmCTest::RunTest(std::vector<const char*> argv, } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Test timeout computed to be: " << timeout << "\n"); - if(cmSystemTools::SameFile(argv[0], this->CTestSelf.c_str()) && + if(cmSystemTools::SameFile( + argv[0], cmSystemTools::GetCTestCommand().c_str()) && !this->ForceNewCTestProcess) { cmCTest inst; @@ -2257,7 +2258,6 @@ bool cmCTest::AddVariableDefinition(const std::string &arg) // the main entry point of ctest, called from main int cmCTest::Run(std::vector<std::string> &args, std::string* output) { - this->FindRunningCMake(); const char* ctestExec = "ctest"; bool cmakeAndTest = false; bool executeTests = true; @@ -2498,29 +2498,6 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) } //---------------------------------------------------------------------- -void cmCTest::FindRunningCMake() -{ - // Find our own executable. - this->CTestSelf = cmSystemTools::GetExecutableDirectory(); - this->CTestSelf += "/ctest"; - this->CTestSelf += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(this->CTestSelf.c_str())) - { - cmSystemTools::Error("CTest executable cannot be found at ", - this->CTestSelf.c_str()); - } - - this->CMakeSelf = cmSystemTools::GetExecutableDirectory(); - this->CMakeSelf += "/cmake"; - this->CMakeSelf += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(this->CMakeSelf.c_str())) - { - cmSystemTools::Error("CMake executable cannot be found at ", - this->CMakeSelf.c_str()); - } -} - -//---------------------------------------------------------------------- void cmCTest::SetNotesFiles(const char* notes) { if ( !notes ) diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 5dd35ce..c0a06c5 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -287,10 +287,6 @@ public: //source directory, it will become /.../relative/path/to/file std::string GetShortPathToFile(const char* fname); - //! Get the path to CTest - const char* GetCTestExecutable() { return this->CTestSelf.c_str(); } - const char* GetCMakeExecutable() { return this->CMakeSelf.c_str(); } - enum { EXPERIMENTAL, NIGHTLY, @@ -490,8 +486,6 @@ private: int CompatibilityMode; // information for the --build-and-test options - std::string CMakeSelf; - std::string CTestSelf; std::string BinaryDir; std::string NotesFiles; @@ -546,9 +540,6 @@ private: int GenerateCTestNotesOutput(std::ostream& os, const VectorOfStrings& files); - ///! Find the running cmake - void FindRunningCMake(); - //! Check if the argument is the one specified bool CheckArgument(const std::string& arg, const char* varg1, const char* varg2 = 0); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index a2f3f7d..31cc393 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -172,7 +172,8 @@ satisfy dependencies. //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget* target, const char* config, cmTarget* head) +::cmComputeLinkDepends(cmTarget const* target, const char* config, + cmTarget const* head) { // Store context information. this->Target = target; diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 1d5d1b9..b86c9b2 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -32,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget* target, const char* config, cmTarget *head); + cmComputeLinkDepends(cmTarget const* target, const char* config, + cmTarget const* head); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -58,8 +59,8 @@ public: private: // Context information. - cmTarget* Target; - cmTarget* HeadTarget; + cmTarget const* Target; + cmTarget const* HeadTarget; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; cmGlobalGenerator* GlobalGenerator; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index d3b28ed..3152c2a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -239,8 +239,8 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget* target, const char* config, - cmTarget *headTarget) +::cmComputeLinkInformation(cmTarget const* target, const char* config, + cmTarget const* headTarget) { // Store context information. this->Target = target; @@ -1901,6 +1901,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, } if(use_build_rpath || use_link_rpath) { + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); for(std::vector<std::string>::const_iterator ri = rdirs.begin(); ri != rdirs.end(); ++ri) @@ -1909,9 +1911,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // support or if using the link path as an rpath. if(use_build_rpath) { - if(emitted.insert(*ri).second) + std::string d = *ri; + if (!rootPath.empty() && d.find(rootPath) == 0) { - runtimeDirs.push_back(*ri); + d = d.substr(rootPath.size()); + } + if(emitted.insert(d).second) + { + runtimeDirs.push_back(d); } } else if(use_link_rpath) @@ -1924,9 +1931,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - if(emitted.insert(*ri).second) + std::string d = *ri; + if (!rootPath.empty() && d.find(rootPath) == 0) + { + d = d.substr(rootPath.size()); + } + if(emitted.insert(d).second) { - runtimeDirs.push_back(*ri); + runtimeDirs.push_back(d); } } } diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index e6ee871..1da5495 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,8 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget* target, const char* config, - cmTarget* headTarget); + cmComputeLinkInformation(cmTarget const* target, const char* config, + cmTarget const* headTarget); ~cmComputeLinkInformation(); bool Compute(); @@ -74,8 +74,8 @@ private: std::set<cmTarget*> SharedLibrariesLinked; // Context information. - cmTarget* Target; - cmTarget* HeadTarget; + cmTarget const* Target; + cmTarget const* HeadTarget; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; cmGlobalGenerator* GlobalGenerator; diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 348f5d3..c5e95d0 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -16,6 +16,4 @@ #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER -#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}" -#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index e52ddef..f8ec642 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -74,10 +74,6 @@ bool cmConfigureFileCommand this->CopyOnly = false; this->EscapeQuotes = false; - // for CMake 2.0 and earlier CONFIGURE_FILE defaults to the FinalPass, - // after 2.0 it only does InitialPass - this->Immediate = !this->Makefile->NeedBackwardsCompatibility(2,0); - this->AtOnly = false; for(unsigned int i=2;i < args.size();++i) { @@ -101,32 +97,19 @@ bool cmConfigureFileCommand } else if(args[i] == "IMMEDIATE") { - this->Immediate = true; + /* Ignore legacy option. */ } } - // If we were told to copy the file immediately, then do it on the - // first pass (now). - if(this->Immediate) + if ( !this->ConfigureFile() ) { - if ( !this->ConfigureFile() ) - { - this->SetError("Problem configuring file"); - return false; - } + this->SetError("Problem configuring file"); + return false; } return true; } -void cmConfigureFileCommand::FinalPass() -{ - if(!this->Immediate) - { - this->ConfigureFile(); - } -} - int cmConfigureFileCommand::ConfigureFile() { return this->Makefile->ConfigureFile( diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 605b58b..86de92c 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -41,9 +41,6 @@ public: */ virtual bool IsScriptable() const { return true; } - virtual void FinalPass(); - virtual bool HasFinalPass() const { return !this->Immediate; } - private: int ConfigureFile(); @@ -53,7 +50,6 @@ private: std::string OutputFile; bool CopyOnly; bool EscapeQuotes; - bool Immediate; bool AtOnly; }; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 0ac969b..bbfc427 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -34,7 +34,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::string outputVariable; std::string copyFile; std::string copyFileError; - std::vector<cmTarget*> targets; + std::vector<cmTarget const*> targets; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; @@ -405,6 +405,41 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); cmakeFlags.push_back(flag); } + if (const char *cxxDef + = this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET")) + { + std::string flag="-DCMAKE_CXX_COMPILER_TARGET="; + flag += cxxDef; + cmakeFlags.push_back(flag); + } + if (const char *cDef + = this->Makefile->GetDefinition("CMAKE_C_COMPILER_TARGET")) + { + std::string flag="-DCMAKE_C_COMPILER_TARGET="; + flag += cDef; + cmakeFlags.push_back(flag); + } + if (const char *tcxxDef = this->Makefile->GetDefinition( + "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN")) + { + std::string flag="-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN="; + flag += tcxxDef; + cmakeFlags.push_back(flag); + } + if (const char *tcDef = this->Makefile->GetDefinition( + "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN")) + { + std::string flag="-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN="; + flag += tcDef; + cmakeFlags.push_back(flag); + } + if (const char *rootDef + = this->Makefile->GetDefinition("CMAKE_SYSROOT")) + { + std::string flag="-DCMAKE_SYSROOT="; + flag += rootDef; + cmakeFlags.push_back(flag); + } if(this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE")!=0) { fprintf(fout, "set(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n"); diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 682478e..8029577 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -605,7 +605,8 @@ void cmDocumentation::GlobHelp(std::vector<std::string>& files, std::string const& pattern) { cmsys::Glob gl; - std::string findExpr = this->CMakeRoot + "/Help/" + pattern + ".rst"; + std::string findExpr = + cmSystemTools::GetCMakeRoot() + "/Help/" + pattern + ".rst"; if(gl.FindFiles(findExpr)) { files = gl.GetFiles(); @@ -649,7 +650,7 @@ bool cmDocumentation::PrintFiles(std::ostream& os, std::vector<std::string> files; this->GlobHelp(files, pattern); std::sort(files.begin(), files.end()); - cmRST r(os, this->CMakeRoot + "/Help"); + cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help"); for (std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 07e614d..209cc27 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -83,9 +83,6 @@ public: void AppendSection(const char *sectionName, cmDocumentationEntry &docs); - /** Set cmake root so we can find installed files */ - void SetCMakeRoot(const char* root) { this->CMakeRoot = root? root:"";} - /** Add common (to all tools) documentation section(s) */ void addCommonStandardDocSections(); @@ -127,7 +124,6 @@ private: std::string NameString; std::map<std::string,cmDocumentationSection*> AllSections; - std::string CMakeRoot; std::string CurrentArgument; struct RequestedHelpItem diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index b01e499..fdc075e 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -191,6 +191,10 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { + if(!target->IsLinkable()) + { + return false; + } const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES"); if (input) { @@ -411,6 +415,12 @@ void getCompatibleInterfaceProperties(cmTarget *target, getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MIN", + ifaceProperties); + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MAX", + ifaceProperties); } } @@ -423,11 +433,19 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", target, properties); + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", + target, properties); + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", + target, properties); std::set<std::string> ifaceProperties; getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); + getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN", + ifaceProperties); + getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX", + ifaceProperties); getCompatibleInterfaceProperties(target, ifaceProperties, 0); @@ -449,7 +467,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( } //---------------------------------------------------------------------------- -void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, +void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties) { @@ -640,6 +658,7 @@ cmExportFileGenerator if (iface->ImplementationIsInterface) { + // Policy CMP0022 must not be NEW. this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LIBRARIES", iface->Libraries, properties, missingTargets); @@ -871,7 +890,7 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportTargetCode(std::ostream& os, cmTarget* target) +::GenerateImportTargetCode(std::ostream& os, cmTarget const* target) { // Construct the imported target name. std::string targetName = this->Namespace; @@ -937,7 +956,7 @@ cmExportFileGenerator void cmExportFileGenerator ::GenerateImportPropertyCode(std::ostream& os, const char* config, - cmTarget* target, + cmTarget const* target, ImportPropertyMap const& properties) { // Construct the imported target name. diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index f3d0807..6fd23b0 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -60,9 +60,9 @@ protected: void GenerateImportHeaderCode(std::ostream& os, const char* config = 0); void GenerateImportFooterCode(std::ostream& os); void GenerateImportVersionCode(std::ostream& os); - void GenerateImportTargetCode(std::ostream& os, cmTarget* target); + void GenerateImportTargetCode(std::ostream& os, cmTarget const* target); void GenerateImportPropertyCode(std::ostream& os, const char* config, - cmTarget* target, + cmTarget const* target, ImportPropertyMap const& properties); void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, ImportPropertyMap const& properties, @@ -115,7 +115,7 @@ protected: ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmTarget *target, ImportPropertyMap &properties); - void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, + void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); void PopulateIncludeDirectoriesInterface( cmTargetExport *target, diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx index 96fdb3e..5174118 100644 --- a/Source/cmExportSetMap.cxx +++ b/Source/cmExportSetMap.cxx @@ -23,7 +23,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string &name) return it->second; } -cmExportSetMap::~cmExportSetMap() +void cmExportSetMap::clear() { for(std::map<std::string, cmExportSet*>::iterator it = this->begin(); it != this->end(); @@ -31,4 +31,10 @@ cmExportSetMap::~cmExportSetMap() { delete it->second; } + this->derived::clear(); +} + +cmExportSetMap::~cmExportSetMap() +{ + this->clear(); } diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h index 4663c55..965046c 100644 --- a/Source/cmExportSetMap.h +++ b/Source/cmExportSetMap.h @@ -18,6 +18,7 @@ class cmExportSet; /// A name -> cmExportSet map with overloaded operator[]. class cmExportSetMap : public std::map<std::string, cmExportSet*> { + typedef std::map<std::string, cmExportSet*> derived; public: /** \brief Overloaded operator[]. * @@ -26,6 +27,8 @@ public: */ cmExportSet* operator[](const std::string &name); + void clear(); + /// Overloaded destructor deletes all member export sets. ~cmExportSetMap(); }; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 819ac37..d9bc04c 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -18,11 +18,11 @@ //---------------------------------------------------------------------------- bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) { - std::set<cmTarget*> emitted; - std::set<cmTarget*> emittedDeps; + std::set<cmTarget const*> emitted; + std::set<cmTarget const*> emittedDeps; while(!this->Exports.empty()) { - cmTarget* te = this->Exports.back(); + cmTarget const* te = this->Exports.back(); this->Exports.pop_back(); if (emitted.insert(te).second) { @@ -32,7 +32,7 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; #define FIND_TARGETS(PROPERTY) \ - this->FindTargets(#PROPERTY, te, emittedDeps); + this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps); CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) @@ -45,8 +45,8 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) } std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, - cmTarget *tgt, - std::set<cmTarget*> &emitted) + cmTarget const* tgt, + std::set<cmTarget const*> &emitted) { const char *prop = tgt->GetProperty(propName); if(!prop) @@ -70,8 +70,8 @@ std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, std::string result = cge->Evaluate(tgt->GetMakefile(), this->Config, false, &dummyHead, tgt, &dagChecker); - const std::set<cmTarget*> &allTargets = cge->GetAllTargetsSeen(); - for(std::set<cmTarget*>::const_iterator li = allTargets.begin(); + const std::set<cmTarget const*> &allTargets = cge->GetAllTargetsSeen(); + for(std::set<cmTarget const*>::const_iterator li = allTargets.begin(); li != allTargets.end(); ++li) { if(emitted.insert(*li).second) @@ -84,9 +84,9 @@ std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, //---------------------------------------------------------------------------- void -cmExportTryCompileFileGenerator::PopulateProperties(cmTarget* target, +cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, ImportPropertyMap& properties, - std::set<cmTarget*> &emitted) + std::set<cmTarget const*> &emitted) { cmPropertyMap props = target->GetProperties(); for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 91b4a61..71ac0dd 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -21,7 +21,7 @@ class cmExportTryCompileFileGenerator: public cmExportFileGenerator { public: /** Set the list of targets to export. */ - void SetExports(const std::vector<cmTarget*> &exports) + void SetExports(const std::vector<cmTarget const*> &exports) { this->Exports = exports; } void SetConfig(const char *config) { this->Config = config; } protected: @@ -39,18 +39,18 @@ protected: cmTarget*, cmTarget*) {} - void PopulateProperties(cmTarget* target, + void PopulateProperties(cmTarget const* target, ImportPropertyMap& properties, - std::set<cmTarget*> &emitted); + std::set<cmTarget const*> &emitted); std::string InstallNameDir(cmTarget* target, const std::string& config); private: - std::string FindTargets(const char *prop, cmTarget *tgt, - std::set<cmTarget*> &emitted); + std::string FindTargets(const char *prop, cmTarget const* tgt, + std::set<cmTarget const*> &emitted); - std::vector<cmTarget*> Exports; + std::vector<cmTarget const*> Exports; const char *Config; }; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 1e799b8..fce1284 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -329,31 +329,11 @@ void cmExtraCodeBlocksGenerator { case cmTarget::GLOBAL_TARGET: { - bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - insertTarget = true; - // only add the "edit_cache" target if it's not ccmake, because - // this will not work within the IDE - if (ti->first == "edit_cache") - { - const char* editCommand = makefile->GetDefinition - ("CMAKE_EDIT_COMMAND"); - if (editCommand == 0) - { - insertTarget = false; - } - else if (strstr(editCommand, "ccmake")!=NULL) - { - insertTarget = false; - } - } - } - if (insertTarget) - { this->AppendTarget(fout, ti->first.c_str(), 0, make.c_str(), makefile, compiler.c_str()); } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index a2dd903..676d4ed 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -995,30 +995,10 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const { case cmTarget::GLOBAL_TARGET: { - bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (subdir.empty()) { - insertTarget = true; - // only add the "edit_cache" target if it's not ccmake, because - // this will not work within the IDE - if (ti->first == "edit_cache") - { - const char* editCommand = makefile->GetDefinition - ("CMAKE_EDIT_COMMAND"); - if (editCommand == 0) - { - insertTarget = false; - } - else if (strstr(editCommand, "ccmake")!=NULL) - { - insertTarget = false; - } - } - } - if (insertTarget) - { this->AppendTarget(fout, ti->first, make, makeArgs, subdir, ": "); } } diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index baed733..9cbdd7c 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -172,31 +172,11 @@ void cmExtraSublimeTextGenerator:: { case cmTarget::GLOBAL_TARGET: { - bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - insertTarget = true; - // only add the "edit_cache" target if it's not ccmake, because - // this will not work within the IDE - if (ti->first == "edit_cache") - { - const char* editCommand = makefile->GetDefinition - ("CMAKE_EDIT_COMMAND"); - if (editCommand == 0) - { - insertTarget = false; - } - else if (strstr(editCommand, "ccmake")!=NULL) - { - insertTarget = false; - } - } - } - if (insertTarget) - { this->AppendTarget(fout, ti->first.c_str(), *lg, 0, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index c1e7b1e..ae15ee7 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -28,11 +28,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) return false; } - // CMake versions below 2.3 did not search all these extra - // locations. Preserve compatibility unless a modern argument is - // passed. - bool compatibility = this->Makefile->NeedBackwardsCompatibility(2,3); - // copy argsIn into args so it can be modified, // in the process extract the DOC "documentation" size_t size = argsIn.size(); @@ -112,7 +107,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) else if (args[j] == "PATH_SUFFIXES") { doing = DoingPathSuffixes; - compatibility = false; newStyle = true; } else if (args[j] == "NAMES_PER_DIR") @@ -136,7 +130,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) else if (this->CheckCommonArgument(args[j])) { doing = DoingNone; - compatibility = false; // Some common arguments were accidentally supported by CMake // 2.4 and 2.6.0 in the short-hand form of the command, so we // must support it even though it is not documented. @@ -159,17 +152,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) } } - // Now that arguments have been parsed check the compatibility - // setting. If we need to be compatible with CMake 2.2 and earlier - // do not add the CMake system paths. It is safe to add the CMake - // environment paths and system environment paths because that - // existed in 2.2. It is safe to add the CMake user variable paths - // because the user or project has explicitly set them. - if(compatibility) - { - this->NoCMakeSystemPath = true; - } - if(this->VariableDocumentation.size() == 0) { this->VariableDocumentation = "Where can "; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 7beeda0..8c42811 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -138,16 +138,27 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) { return; } + const char* sysroot = + this->Makefile->GetDefinition("CMAKE_SYSROOT"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - if((rootPath == 0) || (strlen(rootPath) == 0)) + const bool noSysroot = !sysroot || !*sysroot; + const bool noRootPath = !rootPath || !*rootPath; + if(noSysroot && noRootPath) { return; } // Construct the list of path roots with no trailing slashes. std::vector<std::string> roots; - cmSystemTools::ExpandListArgument(rootPath, roots); + if (rootPath) + { + cmSystemTools::ExpandListArgument(rootPath, roots); + } + if (sysroot) + { + roots.push_back(sysroot); + } for(std::vector<std::string>::iterator ri = roots.begin(); ri != roots.end(); ++ri) { diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index aeca39a..12f04d6 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -24,32 +24,6 @@ #include <StorageDefs.h> #endif -void cmFindPackageNeedBackwardsCompatibility(const std::string& variable, - int access_type, void*, const char* newValue, - const cmMakefile*) -{ - (void)newValue; -#ifdef CMAKE_BUILD_WITH_CMAKE - if(access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS) - { - std::string message = "An attempt was made to access a variable: "; - message += variable; - message += - " that has not been defined. This variable is created by the " - "FIND_PACKAGE command. CMake version 1.6 always converted the " - "variable name to upper-case, but this behavior is no longer the " - "case. To fix this you might need to set the cache value of " - "CMAKE_BACKWARDS_COMPATIBILITY to 1.6 or less. If you are writing a " - "CMake listfile, you should change the variable reference to use " - "the case of the argument to FIND_PACKAGE."; - cmSystemTools::Error(message.c_str()); - } -#else - (void)variable; - (void)access_type; -#endif -} - //---------------------------------------------------------------------------- cmFindPackageCommand::cmFindPackageCommand() { @@ -128,11 +102,6 @@ bool cmFindPackageCommand std::set<std::string> requiredComponents; std::set<std::string> optionalComponents; - // Check ancient compatibility. - this->Compatibility_1_6 = - this->Makefile->GetLocalGenerator() - ->NeedBackwardsCompatibility(1, 6); - // Always search directly in a generated path. this->SearchPathSuffixes.push_back(""); @@ -154,7 +123,6 @@ bool cmFindPackageCommand else if(args[i] == "EXACT") { this->VersionExact = true; - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "MODULE") @@ -179,75 +147,63 @@ bool cmFindPackageCommand } else if(args[i] == "COMPONENTS") { - this->Compatibility_1_6 = false; doing = DoingComponents; } else if(args[i] == "OPTIONAL_COMPONENTS") { - this->Compatibility_1_6 = false; doing = DoingOptionalComponents; } else if(args[i] == "NAMES") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNames; } else if(args[i] == "PATHS") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingPaths; } else if(args[i] == "HINTS") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingHints; } else if(args[i] == "PATH_SUFFIXES") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingPathSuffixes; } else if(args[i] == "CONFIGS") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingConfigs; } else if(args[i] == "NO_POLICY_SCOPE") { this->PolicyScope = false; - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "NO_CMAKE_PACKAGE_REGISTRY") { this->NoUserRegistry = true; configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY") { this->NoSystemRegistry = true; configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "NO_CMAKE_BUILDS_PATH") { this->NoBuilds = true; configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if(this->CheckCommonArgument(args[i])) { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if((doing == DoingComponents) || (doing == DoingOptionalComponents)) @@ -642,24 +598,9 @@ bool cmFindPackageCommand::HandlePackageMode() std::string upperFound = cmSystemTools::UpperCase(this->Name); upperDir += "_DIR"; upperFound += "_FOUND"; - if(upperDir == this->Variable) - { - this->Compatibility_1_6 = false; - } // Try to find the config file. const char* def = this->Makefile->GetDefinition(this->Variable.c_str()); - if(this->Compatibility_1_6 && cmSystemTools::IsOff(def)) - { - // Use the setting of the old name of the variable to provide the - // value of the new. - const char* oldDef = this->Makefile->GetDefinition(upperDir.c_str()); - if(!cmSystemTools::IsOff(oldDef)) - { - this->Makefile->AddDefinition(this->Variable.c_str(), oldDef); - def = this->Makefile->GetDefinition(this->Variable.c_str()); - } - } // Try to load the config file if the directory is known bool fileFound = false; @@ -881,43 +822,6 @@ bool cmFindPackageCommand::HandlePackageMode() this->Makefile->RemoveDefinition(fileVar.c_str()); } - // Handle some ancient compatibility stuff. - if(this->Compatibility_1_6) - { - // Listfiles will be looking for the capitalized version of the - // name. Provide it. - this->Makefile->AddDefinition - (upperDir.c_str(), - this->Makefile->GetDefinition(this->Variable.c_str())); - this->Makefile->AddDefinition - (upperFound.c_str(), - this->Makefile->GetDefinition(foundVar.c_str())); - } - -#ifdef CMAKE_BUILD_WITH_CMAKE - if(!(upperDir == this->Variable)) - { - if(this->Compatibility_1_6) - { - // Listfiles may use the capitalized version of the name. - // Remove any previously added watch. - this->Makefile->GetVariableWatch()->RemoveWatch( - upperDir.c_str(), - cmFindPackageNeedBackwardsCompatibility - ); - } - else - { - // Listfiles should not be using the capitalized version of the - // name. Add a watch to warn the user. - this->Makefile->GetVariableWatch()->AddWatch( - upperDir.c_str(), - cmFindPackageNeedBackwardsCompatibility - ); - } - } -#endif - std::string consideredConfigsVar = this->Name; consideredConfigsVar += "_CONSIDERED_CONFIGS"; std::string consideredVersionsVar = this->Name; diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 1ed0710..7ceebb2 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -117,7 +117,6 @@ private: unsigned int RequiredCMakeVersion; bool Quiet; bool Required; - bool Compatibility_1_6; bool UseConfigFiles; bool UseFindModules; bool NoUserRegistry; diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 97853f3..f34a35b 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -53,7 +53,7 @@ cmGeneratorExpression::~cmGeneratorExpression() //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( cmMakefile* mf, const char* config, bool quiet, - cmTarget *headTarget, + cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const { return this->Evaluate(mf, @@ -67,8 +67,8 @@ const char *cmCompiledGeneratorExpression::Evaluate( //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( cmMakefile* mf, const char* config, bool quiet, - cmTarget *headTarget, - cmTarget *currentTarget, + cmTarget const* headTarget, + cmTarget const* currentTarget, cmGeneratorExpressionDAGChecker *dagChecker) const { if (!this->NeedsEvaluation) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index bc0f6c2..4992e93 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -80,12 +80,12 @@ class cmCompiledGeneratorExpression public: const char* Evaluate(cmMakefile* mf, const char* config, bool quiet = false, - cmTarget *headTarget = 0, - cmTarget *currentTarget = 0, + cmTarget const* headTarget = 0, + cmTarget const* currentTarget = 0, cmGeneratorExpressionDAGChecker *dagChecker = 0) const; const char* Evaluate(cmMakefile* mf, const char* config, bool quiet, - cmTarget *headTarget, + cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const; /** Get set of targets found during evaluations. */ @@ -95,7 +95,7 @@ public: std::set<cmStdString> const& GetSeenTargetProperties() const { return this->SeenTargetProperties; } - std::set<cmTarget*> const& GetAllTargetsSeen() const + std::set<cmTarget const*> const& GetAllTargetsSeen() const { return this->AllTargetsSeen; } ~cmCompiledGeneratorExpression(); @@ -129,7 +129,7 @@ private: bool NeedsEvaluation; mutable std::set<cmTarget*> DependTargets; - mutable std::set<cmTarget*> AllTargetsSeen; + mutable std::set<cmTarget const*> AllTargetsSeen; mutable std::set<cmStdString> SeenTargetProperties; mutable std::string Output; mutable bool HadContextSensitiveCondition; diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 0b7ef02..c8594e7 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -23,10 +23,10 @@ F(EvaluatingCompileOptions) #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ - F(INTERFACE_INCLUDE_DIRECTORIES) \ - F(INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) \ - F(INTERFACE_COMPILE_DEFINITIONS) \ - F(INTERFACE_COMPILE_OPTIONS) + F(INCLUDE_DIRECTORIES) \ + F(SYSTEM_INCLUDE_DIRECTORIES) \ + F(COMPILE_DEFINITIONS) \ + F(COMPILE_OPTIONS) //---------------------------------------------------------------------------- struct cmGeneratorExpressionDAGChecker diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 33863f4..2ae5a22 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -652,7 +652,7 @@ static const struct JoinNode : public cmGeneratorExpressionNode } joinNode; #define TRANSITIVE_PROPERTY_NAME(PROPERTY) \ - , #PROPERTY + , "INTERFACE_" #PROPERTY //---------------------------------------------------------------------------- static const char* targetPropertyTransitiveWhitelist[] = { @@ -661,8 +661,8 @@ static const char* targetPropertyTransitiveWhitelist[] = { }; std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, - cmTarget *target, - cmTarget *headTarget, + cmTarget const* target, + cmTarget const* headTarget, cmGeneratorExpressionContext *context, cmGeneratorExpressionDAGChecker *dagChecker, const std::string &interfacePropertyName) @@ -726,7 +726,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode cmsys::RegularExpression propertyNameValidator; propertyNameValidator.compile("^[A-Za-z0-9_]+$"); - cmTarget* target = context->HeadTarget; + cmTarget const* target = context->HeadTarget; std::string propertyName = *parameters.begin(); if (!target && parameters.size() == 1) @@ -893,28 +893,24 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode std::string interfacePropertyName; - if (propertyName == "INTERFACE_INCLUDE_DIRECTORIES" - || propertyName == "INCLUDE_DIRECTORIES") - { - interfacePropertyName = "INTERFACE_INCLUDE_DIRECTORIES"; - } - else if (propertyName == "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") - { - interfacePropertyName = "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"; - } - else if (propertyName == "INTERFACE_COMPILE_DEFINITIONS" - || propertyName == "COMPILE_DEFINITIONS" - || strncmp(propertyName.c_str(), "COMPILE_DEFINITIONS_", 20) == 0) +#define POPULATE_INTERFACE_PROPERTY_NAME(prop) \ + if (propertyName == #prop || propertyName == "INTERFACE_" #prop) \ + { \ + interfacePropertyName = "INTERFACE_" #prop; \ + } \ + else + + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME) + // Note that the above macro terminates with an else + /* else */ if (strncmp(propertyName.c_str(), + "COMPILE_DEFINITIONS_", 20) == 0) { interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; } - else if (propertyName == "INTERFACE_COMPILE_OPTIONS" - || propertyName == "COMPILE_OPTIONS") - { - interfacePropertyName = "INTERFACE_COMPILE_OPTIONS"; - } +#undef POPULATE_INTERFACE_PROPERTY_NAME - cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target; + cmTarget const* headTarget = context->HeadTarget + ? context->HeadTarget : target; const char * const *transBegin = cmArrayBegin(targetPropertyTransitiveWhitelist) + 1; @@ -980,10 +976,54 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMinProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMaxProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } return linkedTargetsContent; } + if (!target->IsImported() + && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) + { + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMinProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMaxProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } + } for (size_t i = 1; i < cmArraySize(targetPropertyTransitiveWhitelist); ++i) @@ -1047,7 +1087,8 @@ static const char* targetPolicyWhitelist[] = { #undef TARGET_POLICY_STRING }; -cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) +cmPolicies::PolicyStatus statusForTarget(cmTarget const* tgt, + const char *policy) { #define RETURN_POLICY(POLICY) \ if (strcmp(policy, #POLICY) == 0) \ @@ -1295,7 +1336,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "No target \"" + name + "\""); return std::string(); } - if(target->GetType() >= cmTarget::UTILITY && + if(target->GetType() >= cmTarget::OBJECT_LIBRARY && target->GetType() != cmTarget::UNKNOWN_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 343e18b..49e52df 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -24,13 +24,13 @@ struct cmGeneratorExpressionContext { cmListFileBacktrace Backtrace; std::set<cmTarget*> DependTargets; - std::set<cmTarget*> AllTargets; + std::set<cmTarget const*> AllTargets; std::set<cmStdString> SeenTargetProperties; cmMakefile *Makefile; const char *Config; - cmTarget *HeadTarget; // The target whose property is being evaluated. - cmTarget *CurrentTarget; // The dependent of HeadTarget which appears - // directly or indirectly in the property. + cmTarget const* HeadTarget; // The target whose property is being evaluated. + cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears + // directly or indirectly in the property. bool Quiet; bool HadError; bool HadContextSensitiveCondition; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 62ac263..b964f71 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -19,14 +19,14 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" +#include <queue> + //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = this->Makefile->GetLocalGenerator(); this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); - this->ClassifySources(); - this->LookupObjectLibraries(); } //---------------------------------------------------------------------------- @@ -42,14 +42,26 @@ const char *cmGeneratorTarget::GetName() const } //---------------------------------------------------------------------------- -const char *cmGeneratorTarget::GetProperty(const char *prop) +const char *cmGeneratorTarget::GetProperty(const char *prop) const { return this->Target->GetProperty(prop); } //---------------------------------------------------------------------------- +std::vector<cmSourceFile*> const* +cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const +{ + SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); + if(i != this->SourceEntries.end()) + { + return &i->second.Depends; + } + return 0; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, - const char *config) + const char *config) const { std::string config_upper; if(config && *config) @@ -58,7 +70,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } typedef std::map<std::string, std::vector<std::string> > IncludeCacheType; - IncludeCacheType::iterator iter = + IncludeCacheType::const_iterator iter = this->SystemIncludesCache.find(config_upper); if (iter == this->SystemIncludesCache.end()) @@ -99,13 +111,13 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } //---------------------------------------------------------------------------- -bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) +bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const { return this->Target->GetPropertyAsBool(prop); } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles() +std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles() const { return this->Target->GetSourceFiles(); } @@ -114,7 +126,10 @@ std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles() void cmGeneratorTarget::ClassifySources() { cmsys::RegularExpression header(CM_HEADER_REGEX); - bool isObjLib = this->Target->GetType() == cmTarget::OBJECT_LIBRARY; + + cmTarget::TargetType targetType = this->Target->GetType(); + bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY; + std::vector<cmSourceFile*> badObjLib; std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); @@ -126,6 +141,10 @@ void cmGeneratorTarget::ClassifySources() { this->CustomCommands.push_back(sf); } + else if(targetType == cmTarget::UTILITY) + { + this->ExtraSources.push_back(sf); + } else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY")) { this->HeaderSources.push_back(sf); @@ -251,7 +270,8 @@ void cmGeneratorTarget::LookupObjectLibraries() } //---------------------------------------------------------------------------- -void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) +void +cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const { for(std::vector<cmTarget*>::const_iterator ti = this->ObjectLibraries.begin(); @@ -272,8 +292,287 @@ void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) } //---------------------------------------------------------------------------- +class cmTargetTraceDependencies +{ +public: + cmTargetTraceDependencies(cmGeneratorTarget* target); + void Trace(); +private: + cmTarget* Target; + cmGeneratorTarget* GeneratorTarget; + cmMakefile* Makefile; + cmGlobalGenerator* GlobalGenerator; + typedef cmGeneratorTarget::SourceEntry SourceEntry; + SourceEntry* CurrentEntry; + std::queue<cmSourceFile*> SourceQueue; + std::set<cmSourceFile*> SourcesQueued; + typedef std::map<cmStdString, cmSourceFile*> NameMapType; + NameMapType NameMap; + + void QueueSource(cmSourceFile* sf); + void FollowName(std::string const& name); + void FollowNames(std::vector<std::string> const& names); + bool IsUtility(std::string const& dep); + void CheckCustomCommand(cmCustomCommand const& cc); + void CheckCustomCommands(const std::vector<cmCustomCommand>& commands); +}; + +//---------------------------------------------------------------------------- +cmTargetTraceDependencies +::cmTargetTraceDependencies(cmGeneratorTarget* target): + Target(target->Target), GeneratorTarget(target) +{ + // Convenience. + this->Makefile = this->Target->GetMakefile(); + this->GlobalGenerator = + this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); + this->CurrentEntry = 0; + + // Queue all the source files already specified for the target. + std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); + for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); + si != sources.end(); ++si) + { + this->QueueSource(*si); + } + + // Queue pre-build, pre-link, and post-build rule dependencies. + this->CheckCustomCommands(this->Target->GetPreBuildCommands()); + this->CheckCustomCommands(this->Target->GetPreLinkCommands()); + this->CheckCustomCommands(this->Target->GetPostBuildCommands()); +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::Trace() +{ + // Process one dependency at a time until the queue is empty. + while(!this->SourceQueue.empty()) + { + // Get the next source from the queue. + cmSourceFile* sf = this->SourceQueue.front(); + this->SourceQueue.pop(); + this->CurrentEntry = &this->GeneratorTarget->SourceEntries[sf]; + + // Queue dependencies added explicitly by the user. + if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) + { + std::vector<std::string> objDeps; + cmSystemTools::ExpandListArgument(additionalDeps, objDeps); + this->FollowNames(objDeps); + } + + // Queue the source needed to generate this file, if any. + this->FollowName(sf->GetFullPath()); + + // Queue dependencies added programatically by commands. + this->FollowNames(sf->GetDepends()); + + // Queue custom command dependencies. + if(cmCustomCommand const* cc = sf->GetCustomCommand()) + { + this->CheckCustomCommand(*cc); + } + } + this->CurrentEntry = 0; +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) +{ + if(this->SourcesQueued.insert(sf).second) + { + this->SourceQueue.push(sf); + + // Make sure this file is in the target. + this->Target->AddSourceFile(sf); + } +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::FollowName(std::string const& name) +{ + NameMapType::iterator i = this->NameMap.find(name); + if(i == this->NameMap.end()) + { + // Check if we know how to generate this file. + cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str()); + NameMapType::value_type entry(name, sf); + i = this->NameMap.insert(entry).first; + } + if(cmSourceFile* sf = i->second) + { + // Record the dependency we just followed. + if(this->CurrentEntry) + { + this->CurrentEntry->Depends.push_back(sf); + } + + this->QueueSource(sf); + } +} + +//---------------------------------------------------------------------------- +void +cmTargetTraceDependencies::FollowNames(std::vector<std::string> const& names) +{ + for(std::vector<std::string>::const_iterator i = names.begin(); + i != names.end(); ++i) + { + this->FollowName(*i); + } +} + +//---------------------------------------------------------------------------- +bool cmTargetTraceDependencies::IsUtility(std::string const& dep) +{ + // Dependencies on targets (utilities) are supposed to be named by + // just the target name. However for compatibility we support + // naming the output file generated by the target (assuming there is + // no output-name property which old code would not have set). In + // that case the target name will be the file basename of the + // dependency. + std::string util = cmSystemTools::GetFilenameName(dep); + if(cmSystemTools::GetFilenameLastExtension(util) == ".exe") + { + util = cmSystemTools::GetFilenameWithoutLastExtension(util); + } + + // Check for a target with this name. + if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str())) + { + // If we find the target and the dep was given as a full path, + // then make sure it was not a full path to something else, and + // the fact that the name matched a target was just a coincidence. + if(cmSystemTools::FileIsFullPath(dep.c_str())) + { + if(t->GetType() >= cmTarget::EXECUTABLE && + t->GetType() <= cmTarget::MODULE_LIBRARY) + { + // This is really only for compatibility so we do not need to + // worry about configuration names and output names. + std::string tLocation = t->GetLocation(0); + tLocation = cmSystemTools::GetFilenamePath(tLocation); + std::string depLocation = cmSystemTools::GetFilenamePath(dep); + depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); + tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); + if(depLocation == tLocation) + { + this->Target->AddUtility(util.c_str()); + return true; + } + } + } + else + { + // The original name of the dependency was not a full path. It + // must name a target, so add the target-level dependency. + this->Target->AddUtility(util.c_str()); + return true; + } + } + + // The dependency does not name a target built in this project. + return false; +} + +//---------------------------------------------------------------------------- +void +cmTargetTraceDependencies +::CheckCustomCommand(cmCustomCommand const& cc) +{ + // Transform command names that reference targets built in this + // project to corresponding target-level dependencies. + cmGeneratorExpression ge(cc.GetBacktrace()); + + // Add target-level dependencies referenced by generator expressions. + std::set<cmTarget*> targets; + + for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin(); + cit != cc.GetCommandLines().end(); ++cit) + { + std::string const& command = *cit->begin(); + // Check for a target with this name. + if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str())) + { + if(t->GetType() == cmTarget::EXECUTABLE) + { + // The command refers to an executable target built in + // this project. Add the target-level dependency to make + // sure the executable is up to date before this custom + // command possibly runs. + this->Target->AddUtility(command.c_str()); + } + } + + // Check for target references in generator expressions. + for(cmCustomCommandLine::const_iterator cli = cit->begin(); + cli != cit->end(); ++cli) + { + const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge + = ge.Parse(*cli); + cge->Evaluate(this->Makefile, 0, true); + std::set<cmTarget*> geTargets = cge->GetTargets(); + for(std::set<cmTarget*>::const_iterator it = geTargets.begin(); + it != geTargets.end(); ++it) + { + targets.insert(*it); + } + } + } + + for(std::set<cmTarget*>::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + this->Target->AddUtility((*ti)->GetName()); + } + + // Queue the custom command dependencies. + std::vector<std::string> const& depends = cc.GetDepends(); + for(std::vector<std::string>::const_iterator di = depends.begin(); + di != depends.end(); ++di) + { + std::string const& dep = *di; + if(!this->IsUtility(dep)) + { + // The dependency does not name a target and may be a file we + // know how to generate. Queue it. + this->FollowName(dep); + } + } +} + +//---------------------------------------------------------------------------- +void +cmTargetTraceDependencies +::CheckCustomCommands(const std::vector<cmCustomCommand>& commands) +{ + for(std::vector<cmCustomCommand>::const_iterator cli = commands.begin(); + cli != commands.end(); ++cli) + { + this->CheckCustomCommand(*cli); + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::TraceDependencies() +{ + // CMake-generated targets have no dependencies to trace. Normally tracing + // would find nothing anyway, but when building CMake itself the "install" + // target command ends up referencing the "cmake" target but we do not + // really want the dependency because "install" depend on "all" anyway. + if(this->GetType() == cmTarget::GLOBAL_TARGET) + { + return; + } + + // Use a helper object to trace the dependencies. + cmTargetTraceDependencies tracer(this); + tracer.Trace(); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const char* config, - std::vector<std::string>& archVec) + std::vector<std::string>& archVec) const { const char* archs = 0; if(config && *config) @@ -293,7 +592,7 @@ void cmGeneratorTarget::GetAppleArchs(const char* config, } //---------------------------------------------------------------------------- -const char* cmGeneratorTarget::GetCreateRuleVariable() +const char* cmGeneratorTarget::GetCreateRuleVariable() const { switch(this->GetType()) { @@ -317,3 +616,79 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( { return this->Target->GetIncludeDirectories(config); } + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GenerateTargetManifest(const char* config) const +{ + if (this->Target->IsImported()) + { + return; + } + cmMakefile* mf = this->Target->GetMakefile(); + cmLocalGenerator* lg = mf->GetLocalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); + + // Get the names. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + if(this->GetType() == cmTarget::EXECUTABLE) + { + this->Target->GetExecutableNames(name, realName, impName, pdbName, + config); + } + else if(this->GetType() == cmTarget::STATIC_LIBRARY || + this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + config); + } + else + { + return; + } + + // Get the directory. + std::string dir = this->Target->GetDirectory(config, false); + + // Add each name. + std::string f; + if(!name.empty()) + { + f = dir; + f += "/"; + f += name; + gg->AddToManifest(config? config:"", f); + } + if(!soName.empty()) + { + f = dir; + f += "/"; + f += soName; + gg->AddToManifest(config? config:"", f); + } + if(!realName.empty()) + { + f = dir; + f += "/"; + f += realName; + gg->AddToManifest(config? config:"", f); + } + if(!pdbName.empty()) + { + f = dir; + f += "/"; + f += pdbName; + gg->AddToManifest(config? config:"", f); + } + if(!impName.empty()) + { + f = this->Target->GetDirectory(config, true); + f += "/"; + f += impName; + gg->AddToManifest(config? config:"", f); + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index dedfa60..177bc25 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -28,9 +28,9 @@ public: int GetType() const; const char *GetName() const; - const char *GetProperty(const char *prop); - bool GetPropertyAsBool(const char *prop); - std::vector<cmSourceFile*> const& GetSourceFiles(); + const char *GetProperty(const char *prop) const; + bool GetPropertyAsBool(const char *prop) const; + std::vector<cmSourceFile*> const& GetSourceFiles() const; cmTarget* Target; cmMakefile* Makefile; @@ -60,25 +60,41 @@ public: std::vector<cmTarget*> ObjectLibraries; - void UseObjectLibraries(std::vector<std::string>& objs); + void UseObjectLibraries(std::vector<std::string>& objs) const; void GetAppleArchs(const char* config, - std::vector<std::string>& archVec); + std::vector<std::string>& archVec) const; ///! Return the rule variable used to create this type of target, // need to add CMAKE_(LANG) for full name. - const char* GetCreateRuleVariable(); + const char* GetCreateRuleVariable() const; /** Get the include directories for this target. */ std::vector<std::string> GetIncludeDirectories(const char *config); - bool IsSystemIncludeDirectory(const char *dir, const char *config); + bool IsSystemIncludeDirectory(const char *dir, const char *config) const; + + /** Add the target output files to the global generator manifest. */ + void GenerateTargetManifest(const char* config) const; + + /** + * Trace through the source files in this target and add al source files + * that they depend on, used by all generators + */ + void TraceDependencies(); -private: void ClassifySources(); void LookupObjectLibraries(); - std::map<std::string, std::vector<std::string> > SystemIncludesCache; + /** Get sources that must be built before the given source. */ + std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const; + + struct SourceEntry { std::vector<cmSourceFile*> Depends; }; + typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; + SourceEntriesType SourceEntries; + +private: + mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache; cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fb205be..65a7118 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -18,7 +18,7 @@ #include "cmExternalMakefileProjectGenerator.h" #include "cmake.h" #include "cmMakefile.h" -#include "cmQtAutomoc.h" +#include "cmQtAutoGenerators.h" #include "cmSourceFile.h" #include "cmVersion.h" #include "cmTargetExport.h" @@ -66,32 +66,12 @@ cmGlobalGenerator::cmGlobalGenerator() cmGlobalGenerator::~cmGlobalGenerator() { - // Delete any existing cmLocalGenerators - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) - { - delete this->LocalGenerators[i]; - } - for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) - { - delete *li; - } - for(std::map<std::string, cmExportBuildFileGenerator*>::iterator - i = this->BuildExportSets.begin(); - i != this->BuildExportSets.end(); ++i) - { - delete i->second; - } - this->LocalGenerators.clear(); + this->ClearGeneratorMembers(); if (this->ExtraGenerator) { delete this->ExtraGenerator; } - - this->ClearGeneratorTargets(); } bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) @@ -108,6 +88,26 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) return false; } +std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, + std::string makeDefault) +{ + if(cmSystemTools::IsOff(makeProgram)) + { + makeProgram = + this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); + if(cmSystemTools::IsOff(makeProgram)) + { + makeProgram = makeDefault.c_str(); + } + if(cmSystemTools::IsOff(makeProgram) && + !(makeProgram && *makeProgram)) + { + makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND"; + } + } + return makeProgram; +} + void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, bool optional) @@ -138,15 +138,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) && (optional==false)) { - std::string message = "your "; - message += lang; - message += " compiler: \""; - message += name; - message += "\" was not found. Please set "; - message += langComp; - message += " to a valid compiler path or name."; - cmSystemTools::Error(message.c_str()); - path = name; + return; } std::string doc = lang; doc += " compiler."; @@ -334,7 +326,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) void cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *mf, bool) + cmMakefile *mf, bool optional) { if(languages.size() == 0) { @@ -370,6 +362,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, } } + bool fatalError = false; + mf->AddDefinition("RUN_CONFIGURE", true); std::string rootBin = mf->GetHomeOutputDirectory(); rootBin += cmake::GetCMakeFilesDirectory(); @@ -556,6 +550,65 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, this->SetLanguageEnabled("NONE", mf); continue; } + + // Check that the compiler was found. + std::string compilerName = "CMAKE_"; + compilerName += lang; + compilerName += "_COMPILER"; + std::string compilerEnv = "CMAKE_"; + compilerEnv += lang; + compilerEnv += "_COMPILER_ENV_VAR"; + cmOStringStream noCompiler; + const char* compilerFile = mf->GetDefinition(compilerName.c_str()); + if(!compilerFile || !*compilerFile || + cmSystemTools::IsNOTFOUND(compilerFile)) + { + noCompiler << + "No " << compilerName << " could be found.\n" + ; + } + else if(strcmp(lang, "RC") != 0) + { + if(!cmSystemTools::FileIsFullPath(compilerFile)) + { + noCompiler << + "The " << compilerName << ":\n" + " " << compilerFile << "\n" + "is not a full path and was not found in the PATH.\n" + ; + } + else if(!cmSystemTools::FileExists(compilerFile)) + { + noCompiler << + "The " << compilerName << ":\n" + " " << compilerFile << "\n" + "is not a full path to an existing compiler tool.\n" + ; + } + } + if(!noCompiler.str().empty()) + { + // Skip testing this language since the compiler is not found. + needTestLanguage[lang] = false; + if(!optional) + { + // The compiler was not found and it is not optional. Remove + // CMake(LANG)Compiler.cmake so we try again next time CMake runs. + std::string compilerLangFile = rootBin; + compilerLangFile += "/CMake"; + compilerLangFile += lang; + compilerLangFile += "Compiler.cmake"; + cmSystemTools::RemoveFile(compilerLangFile.c_str()); + if(!this->CMakeInstance->GetIsInTryCompile()) + { + this->PrintCompilerAdvice(noCompiler, lang, + mf->GetDefinition(compilerEnv.c_str())); + mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str()); + fatalError = true; + } + } + } + std::string langLoadedVar = "CMAKE_"; langLoadedVar += lang; langLoadedVar += "_INFORMATION_LOADED"; @@ -582,26 +635,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, } this->LanguagesReady.insert(lang); - std::string compilerName = "CMAKE_"; - compilerName += lang; - compilerName += "_COMPILER"; - std::string compilerLangFile = rootBin; - compilerLangFile += "/CMake"; - compilerLangFile += lang; - compilerLangFile += "Compiler.cmake"; // Test the compiler for the language just setup // (but only if a compiler has been actually found) // At this point we should have enough info for a try compile // which is used in the backward stuff // If the language is untested then test it now with a try compile. - if (!mf->IsSet(compilerName.c_str())) - { - // if the compiler did not work, then remove the - // CMake(LANG)Compiler.cmake file so that it will get tested the - // next time cmake is run - cmSystemTools::RemoveFile(compilerLangFile.c_str()); - } - else if(needTestLanguage[lang]) + if(needTestLanguage[lang]) { if (!this->CMakeInstance->GetIsInTryCompile()) { @@ -622,31 +661,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, // next time cmake is run if(!mf->IsOn(compilerWorks.c_str())) { + std::string compilerLangFile = rootBin; + compilerLangFile += "/CMake"; + compilerLangFile += lang; + compilerLangFile += "Compiler.cmake"; cmSystemTools::RemoveFile(compilerLangFile.c_str()); } - else - { - // load backwards compatibility stuff for C and CXX - // for old versions of CMake ListFiles C and CXX had some - // backwards compatibility files they have to load - // These files have a bunch of try compiles in them so - // should only be done - if (mf->NeedBackwardsCompatibility(1,4)) - { - if(strcmp(lang, "C") == 0) - { - ifpath = - mf->GetModulesFile("CMakeBackwardCompatibilityC.cmake"); - mf->ReadListFile(0,ifpath.c_str()); - } - if(strcmp(lang, "CXX") == 0) - { - ifpath = - mf->GetModulesFile("CMakeBackwardCompatibilityCXX.cmake"); - mf->ReadListFile(0,ifpath.c_str()); - } - } - } } // end if in try compile } // end need test language // Store the shared library flags so that we can satisfy CMP0018 @@ -675,6 +695,33 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { mf->ReadListFile(0,projectCompatibility.c_str()); } + + if(fatalError) + { + cmSystemTools::SetFatalErrorOccured(); + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, + std::string lang, + const char* envVar) +{ + // Subclasses override this method if they do not support this advice. + os << + "Tell CMake where to find the compiler by setting " + ; + if(envVar) + { + os << + "either the environment variable \"" << envVar << "\" or " + ; + } + os << + "the CMake cache entry CMAKE_" << lang << "_COMPILER " + "to the full path to the compiler, or to the compiler name " + "if it is in the PATH." + ; } //---------------------------------------------------------------------------- @@ -923,23 +970,7 @@ bool cmGlobalGenerator::IsDependedOn(const char* project, void cmGlobalGenerator::Configure() { this->FirstTimeProgress = 0.0f; - this->ClearGeneratorTargets(); - this->ExportSets.clear(); - // Delete any existing cmLocalGenerators - unsigned int i; - for (i = 0; i < this->LocalGenerators.size(); ++i) - { - delete this->LocalGenerators[i]; - } - this->LocalGenerators.clear(); - this->TargetDependencies.clear(); - this->TotalTargets.clear(); - this->ImportedTargets.clear(); - this->LocalGeneratorToTargetMap.clear(); - this->ProjectMap.clear(); - this->RuleHashes.clear(); - this->DirectoryContentMap.clear(); - this->BinaryDirectories.clear(); + this->ClearGeneratorMembers(); // start with this directory cmLocalGenerator *lg = this->CreateLocalGenerator(); @@ -1048,9 +1079,14 @@ void cmGlobalGenerator::Generate() return; } + this->FinalizeTargetCompileInfo(); + +#ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have - // the AUTOMOC property set - this->CreateAutomocTargets(); + // the AUTOMOC, AUTOUIC or AUTORCC property set + AutogensType autogens; + this->CreateQtAutoGeneratorsTargets(autogens); +#endif // For each existing cmLocalGenerator unsigned int i; @@ -1068,11 +1104,6 @@ void cmGlobalGenerator::Generate() (*targets)[tit->first] = tit->second; (*targets)[tit->first].SetMakefile(mf); } - - for ( tit = targets->begin(); tit != targets->end(); ++ tit ) - { - tit->second.AppendBuildInterfaceIncludes(); - } } // Add generator specific helper commands @@ -1081,6 +1112,17 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->AddHelperCommands(); } + // Create per-target generator information. + this->CreateGeneratorTargets(); + +#ifdef CMAKE_BUILD_WITH_CMAKE + for (AutogensType::iterator it = autogens.begin(); it != autogens.end(); + ++it) + { + it->first.SetupAutoGenerateTarget(it->second); + } +#endif + // Trace the dependencies, after that no custom commands should be added // because their dependencies might not be handled correctly for (i = 0; i < this->LocalGenerators.size(); ++i) @@ -1094,8 +1136,7 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->GenerateTargetManifest(); } - // Create per-target generator information. - this->CreateGeneratorTargets(); + this->ComputeGeneratorTargetObjects(); this->ProcessEvaluationFiles(); @@ -1193,6 +1234,7 @@ bool cmGlobalGenerator::CheckTargets() target.GetType() == cmTarget::STATIC_LIBRARY || target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY || + target.GetType() == cmTarget::OBJECT_LIBRARY || target.GetType() == cmTarget::UTILITY) { if(!target.FindSourceFiles()) @@ -1206,11 +1248,9 @@ bool cmGlobalGenerator::CheckTargets() } //---------------------------------------------------------------------------- -void cmGlobalGenerator::CreateAutomocTargets() +void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) { #ifdef CMAKE_BUILD_WITH_CMAKE - typedef std::vector<std::pair<cmQtAutomoc, cmTarget*> > Automocs; - Automocs automocs; for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { cmTargets& targets = @@ -1225,33 +1265,31 @@ void cmGlobalGenerator::CreateAutomocTargets() target.GetType() == cmTarget::MODULE_LIBRARY || target.GetType() == cmTarget::OBJECT_LIBRARY) { - if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported()) + if((target.GetPropertyAsBool("AUTOMOC") + || target.GetPropertyAsBool("AUTOUIC") + || target.GetPropertyAsBool("AUTORCC")) + && !target.IsImported()) { - cmQtAutomoc automoc; - if(automoc.InitializeMocSourceFile(&target)) + cmQtAutoGenerators autogen; + if(autogen.InitializeAutogenTarget(&target)) { - automocs.push_back(std::make_pair(automoc, &target)); + autogens.push_back(std::make_pair(autogen, &target)); } } } } } - for (Automocs::iterator it = automocs.begin(); it != automocs.end(); - ++it) - { - it->first.SetupAutomocTarget(it->second); - } +#else + (void)autogens; #endif } //---------------------------------------------------------------------------- -void cmGlobalGenerator::CreateGeneratorTargets() +void cmGlobalGenerator::FinalizeTargetCompileInfo() { // Construct per-target generator information. for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { - cmGeneratorTargetsType generatorTargets; - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); const std::vector<cmValueWithOrigin> noconfig_compile_definitions = @@ -1266,7 +1304,8 @@ void cmGlobalGenerator::CreateGeneratorTargets() { cmTarget* t = &ti->second; - { + t->AppendBuildInterfaceIncludes(); + for (std::vector<cmValueWithOrigin>::const_iterator it = noconfig_compile_definitions.begin(); it != noconfig_compile_definitions.end(); ++it) @@ -1283,10 +1322,26 @@ void cmGlobalGenerator::CreateGeneratorTargets() mf->GetProperty(defPropName.c_str())); } } + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateGeneratorTargets() +{ + // Construct per-target generator information. + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + cmGeneratorTargetsType generatorTargets; + cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); + + cmTargets& targets = mf->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmTarget* t = &ti->second; cmGeneratorTarget* gt = new cmGeneratorTarget(t); this->GeneratorTargets[t] = gt; - this->ComputeTargetObjects(gt); generatorTargets[t] = gt; } @@ -1304,7 +1359,26 @@ void cmGlobalGenerator::CreateGeneratorTargets() } //---------------------------------------------------------------------------- -void cmGlobalGenerator::ClearGeneratorTargets() +void cmGlobalGenerator::ComputeGeneratorTargetObjects() +{ + // Construct per-target generator information. + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); + cmGeneratorTargetsType targets = mf->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmGeneratorTarget* gt = ti->second; + gt->ClassifySources(); + gt->LookupObjectLibraries(); + this->ComputeTargetObjects(gt); + } + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ClearGeneratorMembers() { for(cmGeneratorTargetsType::iterator i = this->GeneratorTargets.begin(); i != this->GeneratorTargets.end(); ++i) @@ -1312,6 +1386,39 @@ void cmGlobalGenerator::ClearGeneratorTargets() delete i->second; } this->GeneratorTargets.clear(); + + for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator + li = this->EvaluationFiles.begin(); + li != this->EvaluationFiles.end(); + ++li) + { + delete *li; + } + this->EvaluationFiles.clear(); + + for(std::map<std::string, cmExportBuildFileGenerator*>::iterator + i = this->BuildExportSets.begin(); + i != this->BuildExportSets.end(); ++i) + { + delete i->second; + } + this->BuildExportSets.clear(); + + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + { + delete this->LocalGenerators[i]; + } + this->LocalGenerators.clear(); + + this->ExportSets.clear(); + this->TargetDependencies.clear(); + this->TotalTargets.clear(); + this->ImportedTargets.clear(); + this->LocalGeneratorToTargetMap.clear(); + this->ProjectMap.clear(); + this->RuleHashes.clear(); + this->DirectoryContentMap.clear(); + this->BinaryDirectories.clear(); } //---------------------------------------------------------------------------- @@ -1455,15 +1562,6 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, this->FirstTimeProgress); } - std::string makeCommand = this->CMakeInstance-> - GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM"); - if(makeCommand.size() == 0) - { - cmSystemTools::Error( - "Generator cannot find the appropriate make command."); - return 1; - } - std::string newTarget; if (target && strlen(target)) { @@ -1483,45 +1581,16 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); return this->Build(srcdir,bindir,projectName, newTarget.c_str(), - output,makeCommand.c_str(),config,false,fast, + output,0,config,false,fast, this->TryCompileTimeout); } -std::string cmGlobalGenerator -::GenerateBuildCommand(const char* makeProgram, const char *projectName, - const char *projectDir, const char* additionalOptions, - const char *targetName, const char* config, - bool ignoreErrors, bool) +void cmGlobalGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, const char*, const char*, const char*, + const char*, const char*, bool, std::vector<std::string> const&) { - // Project name & dir and config are not used yet. - (void)projectName; - (void)projectDir; - (void)config; - - std::string makeCommand = - cmSystemTools::ConvertToUnixOutputPath(makeProgram); - - // Since we have full control over the invocation of nmake, let us - // make it quiet. - if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) - { - makeCommand += " /NOLOGO "; - } - if ( ignoreErrors ) - { - makeCommand += " -i"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; - } - if ( targetName ) - { - makeCommand += " "; - makeCommand += targetName; - } - return makeCommand; + makeCommand.push_back( + "cmGlobalGenerator::GenerateBuildCommand not implemented"); } int cmGlobalGenerator::Build( @@ -1533,7 +1602,6 @@ int cmGlobalGenerator::Build( bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag, - const char* extraOptions, std::vector<std::string> const& nativeOptions) { /** @@ -1561,17 +1629,17 @@ int cmGlobalGenerator::Build( // should we do a clean first? if (clean) { - std::string cleanCommand = - this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, - 0, "clean", config, false, fast); + std::vector<std::string> cleanCommand; + this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName, + bindir, "clean", config, fast); if(output) { *output += "\nRun Clean Command:"; - *output += cleanCommand; + *output += cmSystemTools::PrintSingleCommand(cleanCommand); *output += "\n"; } - if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr, + if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); @@ -1593,37 +1661,29 @@ int cmGlobalGenerator::Build( } // now build - std::string makeCommand = - this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, - extraOptions, target, - config, false, fast); + std::vector<std::string> makeCommand; + this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName, + bindir, target, config, fast, nativeOptions); + std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand); if(output) { *output += "\nRun Build Command:"; - *output += makeCommand; + *output += makeCommandStr; *output += "\n"; } - std::vector<cmStdString> command = - cmSystemTools::ParseArguments(makeCommand.c_str()); - for(std::vector<std::string>::const_iterator ni = nativeOptions.begin(); - ni != nativeOptions.end(); ++ni) - { - command.push_back(*ni); - } - - if (!cmSystemTools::RunSingleCommand(command, outputPtr, + if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error ("Generator: execution of make failed. Make command was: ", - makeCommand.c_str()); + makeCommandStr.c_str()); if (output) { *output += *outputPtr; *output += "\nGenerator: execution of make failed. Make command was: " - + makeCommand + "\n"; + + makeCommandStr + "\n"; } // return to the original directory @@ -1648,6 +1708,46 @@ int cmGlobalGenerator::Build( return retVal; } +//---------------------------------------------------------------------------- +std::string cmGlobalGenerator::GenerateCMakeBuildCommand( + const char* target, const char* config, const char* native, + bool ignoreErrors) +{ + std::string makeCommand = cmSystemTools::GetCMakeCommand(); + makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); + makeCommand += " --build ."; + if(config && *config) + { + makeCommand += " --config \""; + makeCommand += config; + makeCommand += "\""; + } + if(target && *target) + { + makeCommand += " --target \""; + makeCommand += target; + makeCommand += "\""; + } + const char* sep = " -- "; + if(ignoreErrors) + { + const char* iflag = this->GetBuildIgnoreErrorsFlag(); + if(iflag && *iflag) + { + makeCommand += sep; + makeCommand += iflag; + sep = " "; + } + } + if(native && *native) + { + makeCommand += sep; + makeCommand += native; + } + return makeCommand; +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) { this->LocalGenerators.push_back(lg); @@ -1978,7 +2078,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cmCustomCommandLines cpackCommandLines; std::vector<std::string> depends; cmCustomCommandLine singleLine; - singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); + singleLine.push_back(cmSystemTools::GetCPackCommand()); if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) { singleLine.push_back("-C"); @@ -2019,7 +2119,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); + singleLine.push_back(cmSystemTools::GetCPackCommand()); singleLine.push_back("--config"); configFile = mf->GetStartOutputDirectory();; configFile += "/CPackSourceConfig.cmake"; @@ -2045,7 +2145,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - singleLine.push_back(this->GetCMakeInstance()->GetCTestCommand()); + singleLine.push_back(cmSystemTools::GetCTestCommand()); singleLine.push_back("--force-new-ctest-process"); if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { @@ -2071,11 +2171,11 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - // Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined. - // Otherwise default to the interactive command-line interface. - if(mf->GetDefinition("CMAKE_EDIT_COMMAND")) + // Use generator preference for the edit_cache rule if it is defined. + std::string edit_cmd = this->GetEditCacheCommand(); + if (!edit_cmd.empty()) { - singleLine.push_back(mf->GetDefinition("CMAKE_EDIT_COMMAND")); + singleLine.push_back(edit_cmd); singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); cpackCommandLines.push_back(singleLine); @@ -2087,13 +2187,14 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) else { singleLine.push_back(cmakeCommand); - singleLine.push_back("-i"); - singleLine.push_back("."); + singleLine.push_back("-E"); + singleLine.push_back("echo"); + singleLine.push_back("No interactive CMake dialog available."); cpackCommandLines.push_back(singleLine); (*targets)[editCacheTargetName] = this->CreateGlobalTarget( editCacheTargetName, - "Running interactive CMake command-line interface...", + "No interactive CMake dialog available...", &cpackCommandLines, depends, 0); } } @@ -2378,6 +2479,37 @@ void cmGlobalGenerator::AddTarget(cmTarget* t) } } +bool cmGlobalGenerator::IsReservedTarget(std::string const& name) +{ + // The following is a list of targets reserved + // by one or more of the cmake generators. + + // Adding additional targets to this list will require a policy! + const char* reservedTargets[] = + { + "all", "ALL_BUILD", + "help", + "install", "INSTALL", + "preinstall", + "clean", + "edit_cache", + "rebuild_cache", + "test", "RUN_TESTS", + "package", "PACKAGE", + "package_source", + "ZERO_CHECK", + 0 + }; + + for(const char** reservedTarget = reservedTargets; + *reservedTarget; ++reservedTarget) + { + if(name == *reservedTarget) return true; + } + + return false; +} + void cmGlobalGenerator::SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator *extraGenerator) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index c930b2b..ae139ed 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -32,6 +32,7 @@ class cmTarget; class cmInstallTargetGenerator; class cmInstallFilesGenerator; class cmExportBuildFileGenerator; +class cmQtAutoGenerators; /** \class cmGlobalGenerator * \brief Responable for overseeing the generation process for the entire tree @@ -52,6 +53,10 @@ public: ///! Get the name for this generator virtual const char *GetName() const { return "Generic"; }; + /** Check whether the given name matches the current generator. */ + virtual bool MatchesGeneratorName(const char* name) const + { return strcmp(this->GetName(), name) == 0; } + /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ virtual bool SetGeneratorToolset(std::string const& ts); @@ -118,24 +123,28 @@ public: bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE, - const char* extraOptions = 0, std::vector<std::string> const& nativeOptions = std::vector<std::string>()); - virtual std::string GenerateBuildCommand( + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const char* makeProgram, const char *projectName, const char *projectDir, - const char* additionalOptions, - const char *targetName, const char* config, - bool ignoreErrors, bool fast); + const char *targetName, const char* config, bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); + /** Generate a "cmake --build" call for a given target and config. */ + std::string GenerateCMakeBuildCommand(const char* target, + const char* config, + const char* native, + bool ignoreErrors); ///! Set the CMake instance void SetCMakeInstance(cmake *cm); ///! Get the CMake instance - cmake *GetCMakeInstance() { return this->CMakeInstance; } - const cmake *GetCMakeInstance() const { return this->CMakeInstance; } + cmake *GetCMakeInstance() const { return this->CMakeInstance; } void SetConfiguredFilesPath(cmGlobalGenerator* gen); const std::vector<cmLocalGenerator *>& GetLocalGenerators() const { @@ -194,7 +203,7 @@ public: /* * Determine what program to use for building the project. */ - void FindMakeProgram(cmMakefile*); + virtual void FindMakeProgram(cmMakefile*); ///! Find a target by name by searching the local generators. cmTarget* FindTarget(const char* project, const char* name, @@ -235,6 +244,8 @@ public: void AddTarget(cmTarget* t); + static bool IsReservedTarget(std::string const& name); + virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } virtual const char* GetInstallTargetName() const { return "INSTALL"; } virtual const char* GetInstallLocalTargetName() const { return 0; } @@ -247,6 +258,9 @@ public: virtual const char* GetRebuildCacheTargetName() const { return 0; } virtual const char* GetCleanTargetName() const { return 0; } + // Lookup edit_cache target command preferred by this generator. + virtual std::string GetEditCacheCommand() const { return ""; } + // Class to track a set of dependencies. typedef cmTargetDependSet TargetDependSet; @@ -319,8 +333,11 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); - void CreateAutomocTargets(); + typedef std::vector<std::pair<cmQtAutoGenerators, cmTarget*> > AutogensType; + void CreateQtAutoGeneratorsTargets(AutogensType& autogens); + std::string SelectMakeProgram(const char* makeProgram, + std::string makeDefault = ""); // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. @@ -391,7 +408,10 @@ private: void WriteSummary(); void WriteSummary(cmTarget* target); + void FinalizeTargetCompileInfo(); + virtual void PrintCompilerAdvice(std::ostream& os, std::string lang, + const char* envVar); void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang); cmExternalMakefileProjectGenerator* ExtraGenerator; @@ -406,9 +426,13 @@ private: // Per-target generator information. cmGeneratorTargetsType GeneratorTargets; void CreateGeneratorTargets(); - void ClearGeneratorTargets(); + void ComputeGeneratorTargetObjects(); virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void ClearGeneratorMembers(); + + virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; } + // Cache directory content and target files to be built. struct DirectoryContent: public std::set<cmStdString> { diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index e7c857e..273d4bb 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -462,7 +462,7 @@ void cmGlobalKdevelopGenerator " <numberofjobs>1</numberofjobs>\n" " <dontact>false</dontact>\n" " <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]-> - GetMakefile()->GetRequiredDefinition("CMAKE_BUILD_TOOL") + GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM") << " </makebin>\n" " <selectedenvironment>default</selectedenvironment>\n" " <environments>\n" diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index bdc08b3..77571b2 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -102,6 +102,13 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path) return EncodeLiteral(result); } +std::string cmGlobalNinjaGenerator::EncodeDepfileSpace(const std::string &path) +{ + std::string result = path; + cmSystemTools::ReplaceString(result, " ", "\\ "); + return result; +} + void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, const std::string& comment, const std::string& rule, @@ -236,9 +243,11 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule() "$DESC", "Rule for running custom commands.", /*depfile*/ "", + /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ true); + /*restat*/ true, + /*generator*/ false); } void @@ -247,7 +256,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, const std::string& comment, const cmNinjaDeps& outputs, const cmNinjaDeps& deps, - const cmNinjaDeps& orderOnlyDeps) + const cmNinjaDeps& orderOnly) { std::string cmd = command; #ifdef _WIN32 @@ -268,7 +277,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, outputs, deps, cmNinjaDeps(), - orderOnlyDeps, + orderOnly, vars); } @@ -287,9 +296,13 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule() this->AddRule("COPY_OSX_CONTENT", cmd.str(), "Copying OS X Content $out", - "Rule for copying OS X bundle content file." + "Rule for copying OS X bundle content file.", /*depfile*/ "", - /*rspfile*/ ""); + /*deptype*/ "", + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); } void @@ -320,6 +333,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, bool restat, @@ -355,6 +369,13 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, os << "depfile = " << depfile << "\n"; } + // Write the deptype if any. + if (!deptype.empty()) + { + cmGlobalNinjaGenerator::Indent(os, 1); + os << "deps = " << deptype << "\n"; + } + // Write the command. cmGlobalNinjaGenerator::Indent(os, 1); os << "command = " << command << "\n"; @@ -528,47 +549,34 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false; // cmGlobalXCodeGenerator // Called by: // cmGlobalGenerator::Build() -std::string cmGlobalNinjaGenerator -::GenerateBuildCommand(const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* additionalOptions, +void cmGlobalNinjaGenerator +::GenerateBuildCommand(std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* /*projectName*/, + const char* /*projectDir*/, const char* targetName, - const char* config, - bool ignoreErrors, - bool fast) + const char* /*config*/, + bool /*fast*/, + std::vector<std::string> const& makeOptions) { - // Project name & dir and config are not used yet. - (void)projectName; - (void)projectDir; - (void)config; - // Ninja does not have -i equivalent option yet. - (void)ignoreErrors; - // We do not handle fast build yet. - (void)fast; - - std::string makeCommand = - cmSystemTools::ConvertToUnixOutputPath(makeProgram); - - if(additionalOptions) - { - makeCommand += " "; - makeCommand += additionalOptions; - } - if(targetName) + makeCommand.push_back( + this->SelectMakeProgram(makeProgram) + ); + + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); + if(targetName && *targetName) { if(strcmp(targetName, "clean") == 0) { - makeCommand += " -t clean"; + makeCommand.push_back("-t"); + makeCommand.push_back("clean"); } else { - makeCommand += " "; - makeCommand += targetName; + makeCommand.push_back(targetName); } } - - return makeCommand; } //---------------------------------------------------------------------------- @@ -579,6 +587,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, bool restat, @@ -597,6 +606,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, description, comment, depfile, + deptype, rspfile, rspcontent, restat, @@ -614,6 +624,13 @@ bool cmGlobalNinjaGenerator::HasRule(const std::string &name) //---------------------------------------------------------------------------- // Private virtual overrides +std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const +{ + // Ninja by design does not run interactive tools in the terminal, + // so our only choice is cmake-gui. + return cmSystemTools::GetCMakeGUICommand(); +} + // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { @@ -1085,6 +1102,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) "Re-running CMake...", "Rule for re-running cmake.", /*depfile=*/ "", + /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", /*restat=*/ false, @@ -1138,6 +1156,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) "Cleaning all built files...", "Rule for cleaning all built files.", /*depfile=*/ "", + /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", /*restat=*/ false, @@ -1160,6 +1179,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) "All primary targets available:", "Rule for printing all primary targets available.", /*depfile=*/ "", + /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", /*restat=*/ false, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index e046c7c..4fd0d5c 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -64,6 +64,7 @@ public: static std::string EncodeIdent(const std::string &ident, std::ostream &vars); static std::string EncodeLiteral(const std::string &lit); static std::string EncodePath(const std::string &path); + static std::string EncodeDepfileSpace(const std::string &path); /** * Write the given @a comment to the output stream @a os. It @@ -104,7 +105,7 @@ public: const std::string& comment, const cmNinjaDeps& outputs, const cmNinjaDeps& deps = cmNinjaDeps(), - const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps()); + const cmNinjaDeps& orderOnly = cmNinjaDeps()); void WriteMacOSXContentBuild(const std::string& input, const std::string& output); @@ -120,6 +121,7 @@ public: const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, bool restat, @@ -189,14 +191,16 @@ public: bool optional); /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* additionalOptions, - const char* targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); // Setup target names virtual const char* GetAllTargetName() const { return "all"; } @@ -239,11 +243,12 @@ public: const std::string& command, const std::string& description, const std::string& comment, - const std::string& depfile = "", - const std::string& rspfile = "", - const std::string& rspcontent = "", - bool restat = false, - bool generator = false); + const std::string& depfile, + const std::string& deptype, + const std::string& rspfile, + const std::string& rspcontent, + bool restat, + bool generator); bool HasRule(const std::string& name); @@ -303,6 +308,7 @@ protected: private: + virtual std::string GetEditCacheCommand() const; /// @see cmGlobalGenerator::ComputeTargetObjects virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ce95c08..e1af2f9 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -68,6 +68,42 @@ void cmGlobalUnixMakefileGenerator3 } //---------------------------------------------------------------------------- +std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const +{ + // If generating for an extra IDE, the edit_cache target cannot + // launch a terminal-interactive tool, so always use cmake-gui. + if(this->GetExtraGeneratorName()) + { + return cmSystemTools::GetCMakeGUICommand(); + } + + // Use an internal cache entry to track the latest dialog used + // to edit the cache, and use that for the edit_cache target. + cmake* cm = this->GetCMakeInstance(); + std::string editCacheCommand = cm->GetCMakeEditCommand(); + if(!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") || + !editCacheCommand.empty()) + { + if(editCacheCommand.empty()) + { + editCacheCommand = cmSystemTools::GetCMakeCursesCommand(); + } + if(editCacheCommand.empty()) + { + editCacheCommand = cmSystemTools::GetCMakeGUICommand(); + } + if(!editCacheCommand.empty()) + { + cm->AddCacheEntry + ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), + "Path to cache edit program executable.", cmCacheManager::INTERNAL); + } + } + const char* edit_cmd = cm->GetCacheDefinition("CMAKE_EDIT_COMMAND"); + return edit_cmd? edit_cmd : ""; +} + +//---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjects(cmGeneratorTarget* gt) const @@ -99,6 +135,14 @@ cmGlobalUnixMakefileGenerator3 } } +void cmGlobalUnixMakefileGenerator3::Configure() +{ + // Initialize CMAKE_EDIT_COMMAND cache entry. + this->GetEditCacheCommand(); + + this->cmGlobalGenerator::Configure(); +} + void cmGlobalUnixMakefileGenerator3::Generate() { // first do superclass method @@ -511,36 +555,29 @@ cmGlobalUnixMakefileGenerator3 this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true); } - -std::string cmGlobalUnixMakefileGenerator3 -::GenerateBuildCommand(const char* makeProgram, const char *projectName, - const char *projectDir, const char* additionalOptions, - const char *targetName, const char* config, - bool ignoreErrors, bool fast) +//---------------------------------------------------------------------------- +void cmGlobalUnixMakefileGenerator3 +::GenerateBuildCommand(std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* /*projectName*/, + const char* /*projectDir*/, + const char* targetName, + const char* /*config*/, + bool fast, + std::vector<std::string> const& makeOptions) { - // Project name & dir and config are not used yet. - (void)projectName; - (void)projectDir; - (void)config; - - std::string makeCommand = - cmSystemTools::ConvertToUnixOutputPath(makeProgram); + makeCommand.push_back( + this->SelectMakeProgram(makeProgram) + ); // Since we have full control over the invocation of nmake, let us // make it quiet. if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) { - makeCommand += " /NOLOGO "; - } - if ( ignoreErrors ) - { - makeCommand += " -i"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + makeCommand.push_back("/NOLOGO"); } + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); if ( targetName && strlen(targetName)) { cmLocalUnixMakefileGenerator3 *lg; @@ -561,22 +598,19 @@ std::string cmGlobalUnixMakefileGenerator3 lg->GetMakefile()->MakeStartDirectoriesCurrent(); } - makeCommand += " \""; std::string tname = targetName; if(fast) { tname += "/fast"; } - tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); - makeCommand += tname.c_str(); - makeCommand += "\""; + tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT); + cmSystemTools::ConvertToOutputSlashes(tname); + makeCommand.push_back(tname); if (!this->LocalGenerators.size()) { delete lg; } } - return makeCommand; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 5e9dce3..284f5d1 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -77,6 +77,8 @@ public: virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + virtual void Configure(); + /** * Generate the all required files for building this project/tree. This * basically creates a series of LocalGenerators for each directory and @@ -105,12 +107,16 @@ public: std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; } // change the build command for speed - virtual std::string GenerateBuildCommand - (const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, bool ignoreErrors, bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** Record per-target progress information. */ void RecordTargetProgress(cmMakefileTargetGenerator* tg); @@ -186,6 +192,8 @@ protected: cmGeneratedFileStream *CommandDatabase; private: + virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } + virtual std::string GetEditCacheCommand() const; virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; }; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 07ccc33..29401c6 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -18,42 +18,65 @@ #include "cmVisualStudioSlnParser.h" #include "cmake.h" -static const char vs10Win32generatorName[] = "Visual Studio 10"; -static const char vs10Win64generatorName[] = "Visual Studio 10 Win64"; -static const char vs10IA64generatorName[] = "Visual Studio 10 IA64"; +static const char vs10generatorName[] = "Visual Studio 10 2010"; + +// Map generator name without year to name with year. +static const char* cmVS10GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs10generatorName) - 6; + if(strncmp(p, " 2010", 5) == 0) + { + p += 5; + } + genName = std::string(vs10generatorName) + p; + return p; +} class cmGlobalVisualStudio10Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(!strcmp(name, vs10Win32generatorName)) + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS10GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio10Generator( name, NULL, NULL); } - if(!strcmp(name, vs10Win64generatorName)) + if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio10Generator( name, "x64", "CMAKE_FORCE_WIN64"); } - if(!strcmp(name, vs10IA64generatorName)) + if(strcmp(p, " IA64") == 0) { return new cmGlobalVisualStudio10Generator( name, "Itanium", "CMAKE_FORCE_IA64"); } return 0; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 10"; - entry.Brief = "Generates Visual Studio 10 (2010) project files."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs10generatorName; + entry.Brief = "Generates Visual Studio 10 (VS 2010) project files."; + } - virtual void GetGenerators(std::vector<std::string>& names) const { - names.push_back(vs10Win32generatorName); - names.push_back(vs10Win64generatorName); - names.push_back(vs10IA64generatorName); } + virtual void GetGenerators(std::vector<std::string>& names) const + { + names.push_back(vs10generatorName); + names.push_back(vs10generatorName + std::string(" IA64")); + names.push_back(vs10generatorName + std::string(" Win64")); + } }; //---------------------------------------------------------------------------- @@ -69,12 +92,24 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; std::string vc10Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;" "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32); this->MasmEnabled = false; + this->MSBuildCommandInitialized = false; +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS10GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; } //---------------------------------------------------------------------------- @@ -220,50 +255,121 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase() return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros"; } +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand() +{ + if(!this->MSBuildCommandInitialized) + { + this->MSBuildCommandInitialized = true; + this->MSBuildCommand = this->FindMSBuildCommand(); + } + return this->MSBuildCommand; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand() +{ + std::string msbuild; + std::string mskey = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\"; + mskey += this->GetToolsVersion(); + mskey += ";MSBuildToolsPath"; + if(cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(msbuild); + msbuild += "/"; + } + msbuild += "MSBuild.exe"; + return msbuild; +} -std::string cmGlobalVisualStudio10Generator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, const char *targetName, - const char* config, bool ignoreErrors, bool fast) +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() { - // now build the test - std::string makeCommand - = cmSystemTools::ConvertToOutputPath(makeProgram); - std::string lowerCaseCommand = makeCommand; - cmSystemTools::LowerCase(lowerCaseCommand); - - // If makeProgram is devenv, parent class knows how to generate command: - if (lowerCaseCommand.find("devenv") != std::string::npos || - lowerCaseCommand.find("VCExpress") != std::string::npos) + if(this->ExpressEdition) { - return cmGlobalVisualStudio7Generator::GenerateBuildCommand(makeProgram, - projectName, projectDir, additionalOptions, targetName, config, - ignoreErrors, fast); + // Visual Studio Express >= 10 do not have "devenv.com" or + // "VCExpress.exe" that we can use to build reliably. + // Tell the caller it needs to use MSBuild instead. + return ""; } + // Skip over the cmGlobalVisualStudio8Generator implementation because + // we expect a real devenv and do not want to look for VCExpress. + return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand(); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10Generator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions) +{ + // Select the caller- or user-preferred make program, else MSBuild. + std::string makeProgramSelected = + this->SelectMakeProgram(makeProgram, this->GetMSBuildCommand()); - // Otherwise, assume MSBuild command line, and construct accordingly. + // Check if the caller explicitly requested a devenv tool. + std::string makeProgramLower = makeProgramSelected; + cmSystemTools::LowerCase(makeProgramLower); + bool useDevEnv = + (makeProgramLower.find("devenv") != std::string::npos || + makeProgramLower.find("vcexpress") != std::string::npos); - // if there are spaces in the makeCommand, assume a full path - // and convert it to a path with no spaces in it as the - // RunSingleCommand does not like spaces - if(makeCommand.find(' ') != std::string::npos) + // MSBuild is preferred (and required for VS Express), but if the .sln has + // an Intel Fortran .vfproj then we have to use devenv. Parse it to find out. + cmSlnData slnData; + { + std::string slnFile; + if(projectDir && *projectDir) + { + slnFile = projectDir; + slnFile += "/"; + } + slnFile += projectName; + slnFile += ".sln"; + cmVisualStudioSlnParser parser; + if(parser.ParseFile(slnFile, slnData, + cmVisualStudioSlnParser::DataGroupProjects)) + { + std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects(); + for(std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin(); + !useDevEnv && i != slnProjects.end(); ++i) + { + std::string proj = i->GetRelativePath(); + if(proj.size() > 7 && + proj.substr(proj.size()-7) == ".vfproj") + { + useDevEnv = true; + } + } + } + } + if(useDevEnv) { - cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand); + // Use devenv to build solutions containing Intel Fortran projects. + cmGlobalVisualStudio7Generator::GenerateBuildCommand( + makeCommand, makeProgram, projectName, projectDir, + targetName, config, fast, makeOptions); + return; } + + makeCommand.push_back(makeProgramSelected); + // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD if(!targetName || strlen(targetName) == 0) { targetName = "ALL_BUILD"; } - bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) { - clean = true; - makeCommand += " "; - makeCommand += projectName; - makeCommand += ".sln "; - makeCommand += "/t:Clean "; + makeCommand.push_back(std::string(projectName)+".sln"); + makeCommand.push_back("/t:Clean"); } else { @@ -272,51 +378,29 @@ std::string cmGlobalVisualStudio10Generator if (targetProject.find('/') == std::string::npos) { // it might be in a subdir - cmVisualStudioSlnParser parser; - cmSlnData slnData; - std::string slnFile; - if (projectDir && *projectDir) - { - slnFile = projectDir; - slnFile += '/'; - slnFile += projectName; - } - else + if (cmSlnProjectEntry const* proj = + slnData.GetProjectByName(targetName)) { - slnFile = projectName; - } - if (parser.ParseFile(slnFile + ".sln", slnData, - cmVisualStudioSlnParser::DataGroupProjects)) - { - if (cmSlnProjectEntry const* proj = - slnData.GetProjectByName(targetName)) - { - targetProject = proj->GetRelativePath(); - cmSystemTools::ConvertToUnixSlashes(targetProject); - } + targetProject = proj->GetRelativePath(); + cmSystemTools::ConvertToUnixSlashes(targetProject); } } - makeCommand += " "; - makeCommand += targetProject; - makeCommand += " "; + makeCommand.push_back(targetProject); } - makeCommand += "/p:Configuration="; + std::string configArg = "/p:Configuration="; if(config && strlen(config)) { - makeCommand += config; + configArg += config; } else { - makeCommand += "Debug"; - } - makeCommand += " /p:VisualStudioVersion="; - makeCommand += this->GetIDEVersion(); - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + configArg += "Debug"; } - return makeCommand; + makeCommand.push_back(configArg); + makeCommand.push_back(std::string("/p:VisualStudioVersion=")+ + this->GetIDEVersion()); + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 31e122e..66440ea 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -28,13 +28,20 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual bool SetGeneratorToolset(std::string const& ts); - virtual std::string - GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, const char *targetName, - const char* config, bool ignoreErrors, bool); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); virtual void AddPlatformDefinitions(cmMakefile* mf); @@ -87,6 +94,8 @@ public: protected: virtual const char* GetIDEVersion() { return "10.0"; } + std::string const& GetMSBuildCommand(); + std::string PlatformToolset; bool ExpressEdition; bool MasmEnabled; @@ -104,5 +113,11 @@ private: std::string SourceRel; }; LongestSourcePath LongestSource; + + std::string MSBuildCommand; + bool MSBuildCommandInitialized; + virtual std::string FindMSBuildCommand(); + virtual std::string FindDevEnvCommand(); + virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); } }; #endif diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 41a349e..f1d7312 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -13,42 +13,54 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" -static const char vs11generatorName[] = "Visual Studio 11"; +static const char vs11generatorName[] = "Visual Studio 11 2012"; + +// Map generator name without year to name with year. +static const char* cmVS11GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs11generatorName) - 6; + if(strncmp(p, " 2012", 5) == 0) + { + p += 5; + } + genName = std::string(vs11generatorName) + p; + return p; +} class cmGlobalVisualStudio11Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs11generatorName) != name) - { - return 0; - } - - const char* p = name + sizeof(vs11generatorName) - 1; - if(p[0] == '\0') + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS11GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio11Generator( name, NULL, NULL); } - - if(p[0] != ' ') + if(strcmp(p, " Win64") == 0) { - return 0; + return new cmGlobalVisualStudio11Generator( + name, "x64", "CMAKE_FORCE_WIN64"); } - - ++p; - - if(!strcmp(p, "ARM")) + if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio11Generator( name, "ARM", NULL); } - if(!strcmp(p, "Win64")) + if(*p++ != ' ') { - return new cmGlobalVisualStudio11Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + return 0; } std::set<std::string> installedSDKs = @@ -63,14 +75,16 @@ public: new cmGlobalVisualStudio11Generator(name, p, NULL); ret->WindowsCEVersion = "8.00"; return ret; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 11"; - entry.Brief = "Generates Visual Studio 11 (2012) project files."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs11generatorName; + entry.Brief = "Generates Visual Studio 11 (VS 2012) project files."; + } - virtual void GetGenerators(std::vector<std::string>& names) const { + virtual void GetGenerators(std::vector<std::string>& names) const + { names.push_back(vs11generatorName); names.push_back(vs11generatorName + std::string(" ARM")); names.push_back(vs11generatorName + std::string(" Win64")); @@ -80,9 +94,9 @@ public: for(std::set<std::string>::const_iterator i = installedSDKs.begin(); i != installedSDKs.end(); ++i) { - names.push_back("Visual Studio 11 " + *i); + names.push_back(std::string(vs11generatorName) + " " + *i); } - } + } }; //---------------------------------------------------------------------------- @@ -98,7 +112,6 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( : cmGlobalVisualStudio10Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; std::string vc11Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;" @@ -107,6 +120,18 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( } //---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS11GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 7cc7e69..7ef77e7 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -24,6 +24,8 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual void WriteSLNHeader(std::ostream& fout); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index c2cdc0b..edd5567 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -13,42 +13,65 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" -static const char vs12Win32generatorName[] = "Visual Studio 12"; -static const char vs12Win64generatorName[] = "Visual Studio 12 Win64"; -static const char vs12ARMgeneratorName[] = "Visual Studio 12 ARM"; +static const char vs12generatorName[] = "Visual Studio 12 2013"; + +// Map generator name without year to name with year. +static const char* cmVS12GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs12generatorName) - 6; + if(strncmp(p, " 2013", 5) == 0) + { + p += 5; + } + genName = std::string(vs12generatorName) + p; + return p; +} class cmGlobalVisualStudio12Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(!strcmp(name, vs12Win32generatorName)) + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS12GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio12Generator( name, NULL, NULL); } - if(!strcmp(name, vs12Win64generatorName)) + if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio12Generator( name, "x64", "CMAKE_FORCE_WIN64"); } - if(!strcmp(name, vs12ARMgeneratorName)) + if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio12Generator( name, "ARM", NULL); } return 0; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 12"; - entry.Brief = "Generates Visual Studio 12 (2013) project files."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs12generatorName; + entry.Brief = "Generates Visual Studio 12 (VS 2013) project files."; + } - virtual void GetGenerators(std::vector<std::string>& names) const { - names.push_back(vs12Win32generatorName); - names.push_back(vs12Win64generatorName); - names.push_back(vs12ARMgeneratorName); } + virtual void GetGenerators(std::vector<std::string>& names) const + { + names.push_back(vs12generatorName); + names.push_back(vs12generatorName + std::string(" ARM")); + names.push_back(vs12generatorName + std::string(" Win64")); + } }; //---------------------------------------------------------------------------- @@ -64,7 +87,6 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( : cmGlobalVisualStudio11Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS12FindMake.cmake"; std::string vc12Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;" @@ -73,6 +95,18 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( } //---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS12GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 8c8aeb1..5a4a78d 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -24,6 +24,8 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual void WriteSLNHeader(std::ostream& fout); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 4006df4..8651da7 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -32,7 +32,7 @@ std::string GetVS6TargetName(const std::string& targetName) cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() { - this->FindMakeProgramFile = "CMakeVS6FindMake.cmake"; + this->MSDevCommandInitialized = false; } void cmGlobalVisualStudio6Generator @@ -77,52 +77,53 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) } } -std::string cmGlobalVisualStudio6Generator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool) +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand() { - // Visual studio 6 doesn't need project dir - (void) projectDir; - // Ingoring errors is not implemented in visual studio 6 - (void) ignoreErrors; - - // now build the test - std::vector<std::string> mp; - mp.push_back("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio" - "\\6.0\\Setup;VsCommonDir]/MSDev98/Bin"); - cmSystemTools::ExpandRegistryValues(mp[0]); - std::string originalCommand = makeProgram; - std::string makeCommand = - cmSystemTools::FindProgram(makeProgram, mp); - if(makeCommand.size() == 0) + if(!this->MSDevCommandInitialized) { - std::string e = "Generator cannot find Visual Studio 6 msdev program \""; - e += originalCommand; - e += "\" specified by CMAKE_MAKE_PROGRAM cache entry. "; - e += "Please fix the setting."; - cmSystemTools::Error(e.c_str()); - return ""; + this->MSDevCommandInitialized = true; + this->MSDevCommand = this->FindMSDevCommand(); } - makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); + return this->MSDevCommand; +} - // if there are spaces in the makeCommand, assume a full path - // and convert it to a path with no spaces in it as the - // RunSingleCommand does not like spaces -#if defined(_WIN32) && !defined(__CYGWIN__) - if(makeCommand.find(' ') != std::string::npos) +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio6Generator::FindMSDevCommand() +{ + std::string vscmd; + std::string vskey = this->GetRegistryBase() + "\\Setup;VsCommonDir"; + if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, + cmSystemTools::KeyWOW64_32)) { - cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand); + cmSystemTools::ConvertToUnixSlashes(vscmd); + vscmd += "/MSDev98/Bin/"; } -#endif - makeCommand += " "; - makeCommand += projectName; - makeCommand += ".dsw /MAKE \""; + vscmd += "msdev.exe"; + return vscmd; +} + +//---------------------------------------------------------------------------- +void +cmGlobalVisualStudio6Generator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* /*projectDir*/, + const char* targetName, + const char* config, + bool /*fast*/, + std::vector<std::string> const& makeOptions + ) +{ + // now build the test + makeCommand.push_back( + this->SelectMakeProgram(makeProgram, this->GetMSDevCommand()) + ); + + makeCommand.push_back(std::string(projectName)+".dsw"); + makeCommand.push_back("/MAKE"); + std::string targetArg; bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) { @@ -131,35 +132,32 @@ std::string cmGlobalVisualStudio6Generator } if (targetName && strlen(targetName)) { - makeCommand += targetName; + targetArg += targetName; } else { - makeCommand += "ALL_BUILD"; + targetArg += "ALL_BUILD"; } - makeCommand += " - "; + targetArg += " - "; if(config && strlen(config)) { - makeCommand += config; + targetArg += config; } else { - makeCommand += "Debug"; + targetArg += "Debug"; } + makeCommand.push_back(targetArg); if(clean) { - makeCommand += "\" /CLEAN"; + makeCommand.push_back("/CLEAN"); } else { - makeCommand += "\" /BUILD"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + makeCommand.push_back("/BUILD"); } - return makeCommand; + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 6bd39ca..8fe5792 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -52,14 +52,16 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** * Generate the all required files for building this project/tree. This @@ -90,6 +92,7 @@ public: protected: virtual const char* GetIDEVersion() { return "6.0"; } private: + virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); } void GenerateConfigurations(cmMakefile* mf); void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(std::ostream& fout); @@ -100,6 +103,10 @@ private: const std::set<cmStdString>& dependencies); void WriteDSWFooter(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget* target); + std::string MSDevCommand; + bool MSDevCommandInitialized; + std::string const& GetMSDevCommand(); + std::string FindMSDevCommand(); }; #endif diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 2643719..61d3c4c 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -19,7 +19,6 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( const char* platformName) : cmGlobalVisualStudio7Generator(platformName) { - this->FindMakeProgramFile = "CMakeVS71FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfiguration"; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index d476c24..3d939f3 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -20,8 +20,8 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( const char* platformName) { - this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; this->IntelProjectVersion = 0; + this->DevEnvCommandInitialized = false; if (!platformName) { @@ -110,35 +110,60 @@ void cmGlobalVisualStudio7Generator } -std::string cmGlobalVisualStudio7Generator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, const char *targetName, - const char* config, bool ignoreErrors, bool) +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand() +{ + if(!this->DevEnvCommandInitialized) + { + this->DevEnvCommandInitialized = true; + this->DevEnvCommand = this->FindDevEnvCommand(); + } + return this->DevEnvCommand; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand() { - // Visual studio 7 doesn't need project dir - (void) projectDir; - // Ingoring errors is not implemented in visual studio 6 - (void) ignoreErrors; + std::string vscmd; + std::string vskey = this->GetRegistryBase() + ";InstallDir"; + if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(vscmd); + vscmd += "/"; + } + vscmd += "devenv.com"; + return vscmd; +} - // now build the test - std::string makeCommand = - cmSystemTools::ConvertToOutputPath(makeProgram); - std::string lowerCaseCommand = makeCommand; - cmSystemTools::LowerCase(lowerCaseCommand); +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio7Generator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* /*projectDir*/, + const char* targetName, + const char* config, + bool /*fast*/, + std::vector<std::string> const& makeOptions) +{ + // Select the caller- or user-preferred make program, else devenv. + std::string makeProgramSelected = + this->SelectMakeProgram(makeProgram, this->GetDevEnvCommand()); - // if there are spaces in the makeCommand, assume a full path - // and convert it to a path with no spaces in it as the - // RunSingleCommand does not like spaces -#if defined(_WIN32) && !defined(__CYGWIN__) - if(makeCommand.find(' ') != std::string::npos) + // Ignore the above preference if it is msbuild. + // Assume any other value is either a devenv or + // command-line compatible with devenv. + std::string makeProgramLower = makeProgramSelected; + cmSystemTools::LowerCase(makeProgramLower); + if(makeProgramLower.find("msbuild") != std::string::npos) { - cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand); + makeProgramSelected = this->GetDevEnvCommand(); } -#endif - makeCommand += " "; - makeCommand += projectName; - makeCommand += ".sln "; + + makeCommand.push_back(makeProgramSelected); + + makeCommand.push_back(std::string(projectName) + ".sln"); bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) { @@ -147,37 +172,33 @@ std::string cmGlobalVisualStudio7Generator } if(clean) { - makeCommand += "/clean "; + makeCommand.push_back("/clean"); } else { - makeCommand += "/build "; + makeCommand.push_back("/build"); } if(config && strlen(config)) { - makeCommand += config; + makeCommand.push_back(config); } else { - makeCommand += "Debug"; + makeCommand.push_back("Debug"); } - makeCommand += " /project "; + makeCommand.push_back("/project"); if (targetName && strlen(targetName)) { - makeCommand += targetName; + makeCommand.push_back(targetName); } else { - makeCommand += "ALL_BUILD"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + makeCommand.push_back("ALL_BUILD"); } - return makeCommand; + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 66dc443..c7b0081 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -60,14 +60,16 @@ public: * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** * Generate the all required files for building this project/tree. This @@ -108,6 +110,9 @@ public: protected: virtual const char* GetIDEVersion() { return "7.0"; } + std::string const& GetDevEnvCommand(); + virtual std::string FindDevEnvCommand(); + static cmIDEFlagTable const* GetExtraFlagTableVS7(); virtual void OutputSLNFile(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); @@ -166,6 +171,9 @@ protected: private: char* IntelProjectVersion; + std::string DevEnvCommand; + bool DevEnvCommandInitialized; + virtual std::string GetVSMakeProgram() { return this->GetDevEnvCommand(); } }; #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index b9bc1ae..69b0a7a 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -94,7 +94,6 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( const char* additionalPlatformDefinition) : cmGlobalVisualStudio71Generator(platformName) { - this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; @@ -105,6 +104,26 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( } //---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand() +{ + // First look for VCExpress. + std::string vsxcmd; + std::string vsxkey = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\"; + vsxkey += this->GetIDEVersion(); + vsxkey += ";InstallDir"; + if(cmSystemTools::ReadRegistryValue(vsxkey.c_str(), vsxcmd, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(vsxcmd); + vsxcmd += "/VCExpress.exe"; + return vsxcmd; + } + // Now look for devenv. + return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand(); +} + +//---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 2376f8a..ad01a24 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -69,6 +69,8 @@ public: protected: virtual const char* GetIDEVersion() { return "8.0"; } + virtual std::string FindDevEnvCommand(); + virtual bool VSLinksDependencies() const { return false; } bool AddCheckTarget(); diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index aadf982..ccc27ad 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -101,7 +101,6 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS9FindMake.cmake"; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index af80070..7afcfa7 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -500,6 +500,19 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } //---------------------------------------------------------------------------- +void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) +{ + // Visual Studio generators know how to lookup their build tool + // directly instead of needing a helper module to do it, so we + // do not actually need to put CMAKE_MAKE_PROGRAM into the cache. + if(cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) + { + mf->AddDefinition("CMAKE_MAKE_PROGRAM", + this->GetVSMakeProgram().c_str()); + } +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { if(this->AdditionalPlatformDefinition) diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index b665158..da2d021 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -82,6 +82,8 @@ public: }; class OrderedTargetDependSet; + virtual void FindMakeProgram(cmMakefile*); + protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions @@ -107,6 +109,8 @@ protected: const char* AdditionalPlatformDefinition; private: + virtual std::string GetVSMakeProgram() = 0; + void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 13ed143..be0459d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -257,39 +257,30 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& } //---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool) -{ - // Config is not used yet - (void) ignoreErrors; - (void) projectDir; - +void +cmGlobalXCodeGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* /*projectDir*/, + const char* targetName, + const char* config, + bool /*fast*/, + std::vector<std::string> const& makeOptions) +{ // now build the test - if(makeProgram == 0 || !strlen(makeProgram)) - { - cmSystemTools::Error( - "Generator cannot find the appropriate make command."); - return ""; - } - std::string makeCommand = - cmSystemTools::ConvertToOutputPath(makeProgram); - std::string lowerCaseCommand = makeCommand; - cmSystemTools::LowerCase(lowerCaseCommand); + makeCommand.push_back( + this->SelectMakeProgram(makeProgram, "xcodebuild") + ); - makeCommand += " -project "; - makeCommand += projectName; - makeCommand += ".xcode"; + makeCommand.push_back("-project"); + std::string projectArg = projectName; + projectArg += ".xcode"; if(this->XcodeVersion > 20) { - makeCommand += "proj"; + projectArg += "proj"; } + makeCommand.push_back(projectArg); bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) @@ -299,13 +290,13 @@ std::string cmGlobalXCodeGenerator } if(clean) { - makeCommand += " clean"; + makeCommand.push_back("clean"); } else { - makeCommand += " build"; + makeCommand.push_back("build"); } - makeCommand += " -target "; + makeCommand.push_back("-target"); // if it is a null string for config don't use it if(config && *config == 0) { @@ -313,27 +304,24 @@ std::string cmGlobalXCodeGenerator } if (targetName && strlen(targetName)) { - makeCommand += targetName; + makeCommand.push_back(targetName); } else { - makeCommand += "ALL_BUILD"; + makeCommand.push_back("ALL_BUILD"); } if(this->XcodeVersion == 15) { - makeCommand += " -buildstyle Development "; + makeCommand.push_back("-buildstyle"); + makeCommand.push_back("Development"); } else { - makeCommand += " -configuration "; - makeCommand += config?config:"Debug"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + makeCommand.push_back("-configuration"); + makeCommand.push_back(config?config:"Debug"); } - return makeCommand; + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index c053943..e8cbd14 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -53,14 +53,16 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** * Generate the all required files for building this project/tree. This @@ -210,6 +212,7 @@ protected: std::vector<cmXCodeObject*> XCodeObjects; cmXCodeObject* RootObject; private: + void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3dde19f..d2784a9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -257,10 +257,11 @@ void cmLocalGenerator::ConfigureFinalPass() void cmLocalGenerator::TraceDependencies() { // Generate the rule files for each target. - cmTargets& targets = this->Makefile->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - t->second.TraceDependencies(); + t->second->TraceDependencies(); } } @@ -530,10 +531,11 @@ void cmLocalGenerator::GenerateTargetManifest() this->Makefile->GetConfigurations(configNames); // Add our targets to the manifest for each configuration. - cmTargets& targets = this->Makefile->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - cmTarget& target = t->second; + cmGeneratorTarget& target = *t->second; if(configNames.empty()) { target.GenerateTargetManifest(0); @@ -1041,11 +1043,38 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, // If this is the compiler then look for the extra variable // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; + const char* compilerTarget = 0; + const char* compilerOptionTarget = 0; + const char* compilerExternalToolchain = 0; + const char* compilerOptionExternalToolchain = 0; + const char* compilerSysroot = 0; + const char* compilerOptionSysroot = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { std::string arg1 = actualReplace + "_ARG1"; cmSystemTools::ReplaceString(arg1, "${LANG}", lang); compilerArg1 = this->Makefile->GetDefinition(arg1.c_str()); + compilerTarget + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str()); + compilerOptionTarget + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_TARGET").c_str()); + compilerExternalToolchain + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILER_EXTERNAL_TOOLCHAIN").c_str()); + compilerOptionExternalToolchain + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str()); + compilerSysroot + = this->Makefile->GetDefinition("CMAKE_SYSROOT"); + compilerOptionSysroot + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_SYSROOT").c_str()); } if(actualReplace.find("${LANG}") != actualReplace.npos) { @@ -1066,6 +1095,24 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, ret += " "; ret += compilerArg1; } + if (compilerTarget && compilerOptionTarget) + { + ret += " "; + ret += compilerOptionTarget; + ret += compilerTarget; + } + if (compilerExternalToolchain && compilerOptionExternalToolchain) + { + ret += " "; + ret += compilerOptionExternalToolchain; + ret += this->EscapeForShell(compilerExternalToolchain, true); + } + if (compilerSysroot && compilerOptionSysroot) + { + ret += " "; + ret += compilerOptionSysroot; + ret += this->EscapeForShell(compilerSysroot, true); + } return ret; } return replace; @@ -1412,13 +1459,6 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, includeBinaryDir = true; } - // CMake versions below 2.0 would add the source tree to the -I path - // automatically. Preserve compatibility. - if(this->NeedBackwardsCompatibility(1,9)) - { - includeSourceDir = true; - } - // Hack for VTK 4.0 - 4.4 which depend on the old behavior but do // not set the backwards compatibility level automatically. const char* vtkSourceDir = @@ -1467,6 +1507,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, return; } + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + std::vector<std::string> implicitDirs; // Load implicit include directories for this language. std::string impDirVar = "CMAKE_"; @@ -1479,7 +1521,9 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, for(std::vector<std::string>::const_iterator i = impDirVec.begin(); i != impDirVec.end(); ++i) { - emitted.insert(*i); + std::string d = rootPath + *i; + cmSystemTools::ConvertToUnixSlashes(d); + emitted.insert(d); if (!stripImplicitInclDirs) { implicitDirs.push_back(*i); @@ -3071,7 +3115,7 @@ cmLocalGenerator // Decide whether this language wants to replace the source // extension with the object extension. For CMake 2.4 // compatibility do this by default. - bool replaceExt = this->NeedBackwardsCompatibility(2, 4); + bool replaceExt = this->NeedBackwardsCompatibility_2_4(); if(!replaceExt) { if(const char* lang = source.GetLanguage()) @@ -3318,9 +3362,7 @@ unsigned int cmLocalGenerator::GetBackwardsCompatibility() } //---------------------------------------------------------------------------- -bool cmLocalGenerator::NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch) +bool cmLocalGenerator::NeedBackwardsCompatibility_2_4() { // Check the policy to decide whether to pay attention to this // variable. @@ -3348,7 +3390,7 @@ bool cmLocalGenerator::NeedBackwardsCompatibility(unsigned int major, // equal to or lower than the given version. unsigned int actual_compat = this->GetBackwardsCompatibility(); return (actual_compat && - actual_compat <= CMake_VERSION_ENCODE(major, minor, patch)); + actual_compat <= CMake_VERSION_ENCODE(2, 4, 255)); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 10f0b1a..21700e9 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -324,9 +324,7 @@ public: /** * Test whether compatibility is set to a given version or lower. */ - bool NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch = 0xFFu); + bool NeedBackwardsCompatibility_2_4(); /** * Generate a Mac OS X application bundle Info.plist file. diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 89b05d7..f1d5e2c 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -48,7 +48,21 @@ void cmLocalNinjaGenerator::Generate() this->WriteProcessedMakefile(this->GetRulesFileStream()); #endif - this->WriteBuildFileTop(); + // We do that only once for the top CMakeLists.txt file. + if(this->isRootMakefile()) + { + this->WriteBuildFileTop(); + + const std::string showIncludesPrefix = this->GetMakefile() + ->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); + if (!showIncludesPrefix.empty()) + { + cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(), + "localized /showIncludes string"); + this->GetRulesFileStream() + << "msvc_deps_prefix = " << showIncludesPrefix << "\n\n"; + } + } cmTargets& targets = this->GetMakefile()->GetTargets(); for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) @@ -163,10 +177,6 @@ bool cmLocalNinjaGenerator::isRootMakefile() const void cmLocalNinjaGenerator::WriteBuildFileTop() { - // We do that only once for the top CMakeLists.txt file. - if(!this->isRootMakefile()) - return; - // For the build file. this->WriteProjectHeader(this->GetBuildFileStream()); this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); @@ -308,9 +318,13 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, cdCmd << cdStr << this->ConvertToOutputFormat(wd, SHELL); cmdLines.push_back(cdCmd.str()); } + + std::string launcher = this->MakeCustomLauncher(*cc); + for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { - cmdLines.push_back(this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), - SHELL)); + cmdLines.push_back(launcher + + this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), SHELL)); + std::string& cmd = cmdLines.back(); ccg.AppendArguments(i, cmd); } @@ -397,3 +411,39 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() this->WriteCustomCommandBuildStatement(i->first, ccTargetDeps); } } + +std::string cmLocalNinjaGenerator::MakeCustomLauncher( + const cmCustomCommand& cc) +{ + const char* property = "RULE_LAUNCH_CUSTOM"; + const char* property_value = this->Makefile->GetProperty(property); + + if(!property_value || !*property_value) + { + return std::string(); + } + + // Expand rules in the empty string. It may insert the launcher and + // perform replacements. + RuleVariables vars; + vars.RuleLauncher = property; + std::string output; + const std::vector<std::string>& outputs = cc.GetOutputs(); + if(!outputs.empty()) + { + RelativeRoot relative_root = + cc.GetWorkingDirectory() ? NONE : START_OUTPUT; + + output = this->Convert(outputs[0].c_str(), relative_root, SHELL); + } + vars.Output = output.c_str(); + + std::string launcher; + this->ExpandRuleVariables(launcher, vars); + if(!launcher.empty()) + { + launcher += " "; + } + + return launcher; +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index c450841..8eb63c5 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -121,6 +121,7 @@ private: void WriteCustomCommandBuildStatements(); + std::string MakeCustomLauncher(const cmCustomCommand& cc); std::string ConfigName; std::string HomeRelativeOutputPath; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 508eca1..8ed8d0a 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -699,17 +699,6 @@ cmLocalUnixMakefileGenerator3 << "# Escaping for special characters.\n" << "EQUALS = =\n" << "\n"; - - if(const char* edit_cmd = - this->Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) - { - makefileStream - << "# The program to use to edit the cache.\n" - << "CMAKE_EDIT_COMMAND = " - << this->ConvertShellCommand(edit_cmd, FULL) << "\n" - << "\n"; - } - makefileStream << "# The top-level source directory on which CMake was run.\n" << "CMAKE_SOURCE_DIR = " diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index fd6537f..499d3c6 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -140,75 +140,82 @@ bool cmMacroHelperCommand::InvokeInitialPass // Set the FilePath on the arguments to match the function since it is // not stored and the original values may be freed k->FilePath = this->FilePath.c_str(); - tmps = k->Value; - // replace formal arguments - for (unsigned int j = 1; j < this->Args.size(); ++j) + if(k->Delim == cmListFileArgument::Bracket) { - variable = "${"; - variable += this->Args[j]; - variable += "}"; - cmSystemTools::ReplaceString(tmps, variable.c_str(), - expandedArgs[j-1].c_str()); + arg.Value = k->Value; } - // replace argc - cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str()); - - // repleace ARGN - if (tmps.find("${ARGN}") != std::string::npos) + else { - if (!argnDefInitialized) + tmps = k->Value; + // replace formal arguments + for (unsigned int j = 1; j < this->Args.size(); ++j) + { + variable = "${"; + variable += this->Args[j]; + variable += "}"; + cmSystemTools::ReplaceString(tmps, variable.c_str(), + expandedArgs[j-1].c_str()); + } + // replace argc + cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str()); + + // repleace ARGN + if (tmps.find("${ARGN}") != std::string::npos) { - std::vector<std::string>::const_iterator eit; - std::vector<std::string>::size_type cnt = 0; - for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) + if (!argnDefInitialized) { - if ( cnt >= this->Args.size()-1 ) + std::vector<std::string>::const_iterator eit; + std::vector<std::string>::size_type cnt = 0; + for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit) { - if ( argnDef.size() > 0 ) + if ( cnt >= this->Args.size()-1 ) { - argnDef += ";"; + if ( argnDef.size() > 0 ) + { + argnDef += ";"; + } + argnDef += *eit; } - argnDef += *eit; + cnt ++; } - cnt ++; + argnDefInitialized = true; } - argnDefInitialized = true; + cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str()); } - cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str()); - } - - // if the current argument of the current function has ${ARGV in it - // then try replacing ARGV values - if (tmps.find("${ARGV") != std::string::npos) - { - char argvName[60]; - // repleace ARGV, compute it only once - if (!argvDefInitialized) + // if the current argument of the current function has ${ARGV in it + // then try replacing ARGV values + if (tmps.find("${ARGV") != std::string::npos) { - std::vector<std::string>::const_iterator eit; - for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) + char argvName[60]; + + // repleace ARGV, compute it only once + if (!argvDefInitialized) { - if ( argvDef.size() > 0 ) + std::vector<std::string>::const_iterator eit; + for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit) { - argvDef += ";"; + if ( argvDef.size() > 0 ) + { + argvDef += ";"; + } + argvDef += *eit; } - argvDef += *eit; + argvDefInitialized = true; } - argvDefInitialized = true; - } - cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str()); + cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str()); - // also replace the ARGV1 ARGV2 ... etc - for (unsigned int t = 0; t < expandedArgs.size(); ++t) - { - sprintf(argvName,"${ARGV%i}",t); - cmSystemTools::ReplaceString(tmps, argvName, - expandedArgs[t].c_str()); + // also replace the ARGV1 ARGV2 ... etc + for (unsigned int t = 0; t < expandedArgs.size(); ++t) + { + sprintf(argvName,"${ARGV%i}",t); + cmSystemTools::ReplaceString(tmps, argvName, + expandedArgs[t].c_str()); + } } - } - arg.Value = tmps; + arg.Value = tmps; + } arg.Delim = k->Delim; arg.FilePath = k->FilePath; arg.Line = k->Line; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 13c43fa..ac8381c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -799,22 +799,6 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg) this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); } -bool cmMakefile::NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch) -{ - if(this->LocalGenerator) - { - return - this->LocalGenerator->NeedBackwardsCompatibility(major, minor, patch); - } - else - { - return false; - } -} - - namespace { struct file_not_persistent @@ -871,13 +855,15 @@ void cmMakefile::ConfigureFinalPass() this->FinalPass(); const char* oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); - if (oldValue && atof(oldValue) <= 1.2) + if (oldValue && cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, oldValue, "2.4")) { - cmSystemTools::Error("You have requested backwards compatibility " - "with CMake version 1.2 or earlier. This version " - "of CMake only supports backwards compatibility " - "with CMake 1.4 or later. For compatibility with " - "1.2 or earlier please use CMake 2.0"); + this->IssueMessage( + cmake::FATAL_ERROR, + "You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less " + "than 2.4. This version of CMake only supports backwards compatibility " + "with CMake 2.4 or later. For compatibility with older versions please " + "use any CMake 2.8.x release or lower."); } for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); l++) @@ -1456,8 +1442,6 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib); if(tgt) { - // CMake versions below 2.4 allowed linking to modules. - bool allowModules = this->NeedBackwardsCompatibility(2,2); // if it is not a static or shared library then you can not link to it if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) || (tgt->GetType() == cmTarget::SHARED_LIBRARY) || @@ -1470,24 +1454,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, << " may not be linked into another target. " << "One may link only to STATIC or SHARED libraries, or " << "to executables with the ENABLE_EXPORTS property set."; - // in older versions of cmake linking to modules was allowed - if( tgt->GetType() == cmTarget::MODULE_LIBRARY ) - { - e << "\n" - << "If you are developing a new project, re-organize it to avoid " - << "linking to modules. " - << "If you are just trying to build an existing project, " - << "set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower to allow " - << "linking to modules."; - } - // if no modules are allowed then this is always an error - if(!allowModules || - // if we allow modules but the type is not a module then it is - // still an error - (allowModules && tgt->GetType() != cmTarget::MODULE_LIBRARY)) - { - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); - } + this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); } } i->second.AddLinkLibrary( *this, target, lib, llt ); @@ -3105,7 +3072,6 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, cm.SetHomeOutputDirectory(bindir); cm.SetStartDirectory(srcdir); cm.SetStartOutputDirectory(bindir); - cm.SetCMakeCommand(cmakeCommand.c_str()); cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset()); cm.LoadCache(); if(!gg->IsMultiConfig()) @@ -4240,6 +4206,18 @@ bool cmMakefile::EnforceUniqueDir(const char* srcPath, const char* binPath) } //---------------------------------------------------------------------------- +void cmMakefile::AddQtUiFileWithOptions(cmSourceFile *sf) +{ + this->QtUiFilesWithOptions.push_back(sf); +} + +//---------------------------------------------------------------------------- +std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const +{ + return this->QtUiFilesWithOptions; +} + +//---------------------------------------------------------------------------- cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index ca82336..76958ca 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -146,13 +146,6 @@ public: { return this->LocalGenerator;} /** - * Test whether compatibility is set to a given version or lower. - */ - bool NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch = 0xFFu); - - /** * Help enforce global target name uniqueness. */ bool EnforceUniqueName(std::string const& name, std::string& msg, @@ -884,6 +877,9 @@ public: bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } + void AddQtUiFileWithOptions(cmSourceFile *sf); + std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const; + std::set<cmStdString> const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } @@ -1061,6 +1057,8 @@ private: cmSourceFile* source); void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source); + + std::vector<cmSourceFile*> QtUiFilesWithOptions; }; //---------------------------------------------------------------------------- diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6770e10..2fcad79 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -27,6 +27,7 @@ #include "cmMakefileLibraryTargetGenerator.h" #include "cmMakefileUtilityTargetGenerator.h" +#include <ctype.h> cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target) : OSXBundleGenerator(0) @@ -1694,10 +1695,42 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, this->Makefile->GetSafeDefinition(removeFlags.c_str()); std::vector<std::string> removeList; cmSystemTools::ExpandListArgument(removeflags, removeList); + for(std::vector<std::string>::iterator i = removeList.begin(); i != removeList.end(); ++i) { - cmSystemTools::ReplaceString(linkFlags, i->c_str(), ""); + std::string tmp; + std::string::size_type lastPosition = 0; + + for(;;) + { + std::string::size_type position = linkFlags.find(*i, lastPosition); + + if(position == std::string::npos) + { + tmp += linkFlags.substr(lastPosition); + break; + } + else + { + std::string::size_type prefixLength = position - lastPosition; + tmp += linkFlags.substr(lastPosition, prefixLength); + lastPosition = position + i->length(); + + bool validFlagStart = position == 0 || + isspace(linkFlags[position - 1]); + + bool validFlagEnd = lastPosition == linkFlags.size() || + isspace(linkFlags[lastPosition]); + + if(!validFlagStart || !validFlagEnd) + { + tmp += *i; + } + } + } + + linkFlags = tmp; } } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 57adeba..015654b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -261,8 +261,11 @@ cmNinjaNormalTargetGenerator description.str(), comment.str(), /*depfile*/ "", + /*deptype*/ "", rspfile, - rspcontent); + rspcontent, + /*restat*/ false, + /*generator*/ false); } if (this->TargetNameOut != this->TargetNameReal && @@ -277,14 +280,28 @@ cmNinjaNormalTargetGenerator " -E cmake_symlink_executable" " $in $out && $POST_BUILD", "Creating executable symlink $out", - "Rule for creating executable symlink."); + "Rule for creating " + "executable symlink.", + /*depfile*/ "", + /*deptype*/ "", + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); else this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", cmakeCommand + " -E cmake_symlink_library" " $in $SONAME $out && $POST_BUILD", "Creating library symlink $out", - "Rule for creating library symlink."); + "Rule for creating " + "library symlink.", + /*depfile*/ "", + /*deptype*/ "", + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 898aa0e..26eadbe 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -187,6 +187,21 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, return flags; } + +bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang) +{ + cmMakefile* mf = this->GetMakefile(); + + const bool usingMSVC = std::string("MSVC") == + (mf->GetDefinition("CMAKE_C_COMPILER_ID") ? + mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") : + mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID")); + + return !usingMSVC || lang == "RC"; +} + + + // TODO: Refactor with // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string @@ -331,77 +346,78 @@ cmNinjaTargetGenerator void cmNinjaTargetGenerator -::WriteCompileRule(const std::string& language) +::WriteCompileRule(const std::string& lang) { cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.CMTarget = this->GetTarget(); - std::string lang = language; vars.Language = lang.c_str(); vars.Source = "$in"; vars.Object = "$out"; - std::string flags = "$FLAGS"; vars.Defines = "$DEFINES"; vars.TargetPDB = "$TARGET_PDB"; vars.ObjectDir = "$OBJECT_DIR"; cmMakefile* mf = this->GetMakefile(); - bool useClDeps = false; - std::string clBinary; - std::string clDepsBinary; - std::string clShowPrefix; - if (lang == "C" || lang == "CXX" || lang == "RC") + const bool usingMSVC = std::string("MSVC") == + (mf->GetDefinition("CMAKE_C_COMPILER_ID") ? + mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") : + mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID")); + + // Tell ninja dependency format so all deps can be loaded into a database + std::string deptype; + std::string depfile; + std::string cldeps; + std::string flags = "$FLAGS"; + if (usingMSVC) { - clDepsBinary = mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); - if (!clDepsBinary.empty() && !mf->GetIsSourceFileTryCompile()) + if (!mf->GetIsSourceFileTryCompile() && lang == "RC") + { + deptype = "gcc"; + depfile = "$DEP_FILE"; + const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER") ? + mf->GetSafeDefinition("CMAKE_C_COMPILER") : + mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); + cldeps = "\""; + cldeps += mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); + cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \""; + cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); + cldeps += "\" \"" + cl + "\" "; + } + else { - clShowPrefix = mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX"); - clBinary = mf->GetDefinition("CMAKE_C_COMPILER") ? - mf->GetSafeDefinition("CMAKE_C_COMPILER") : - mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); - if (!clBinary.empty() && !clShowPrefix.empty()) - { - useClDeps = true; - const std::string quote = " \""; - clBinary = quote + clBinary + "\" "; - clDepsBinary = quote + clDepsBinary + "\" "; - clShowPrefix = quote + clShowPrefix + "\" "; - vars.DependencyFile = "$DEP_FILE"; - } + deptype = "msvc"; + depfile = ""; + flags += " /showIncludes"; } } - - - std::string depfile; - std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language; - const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str()); - if (depfileFlags || useClDeps) { - std::string depFlagsStr = depfileFlags ? depfileFlags : ""; + else + { + deptype = "gcc"; depfile = "$DEP_FILE"; - cmSystemTools::ReplaceString(depFlagsStr, "<DEPFILE>", "\"$DEP_FILE\""); - cmSystemTools::ReplaceString(depFlagsStr, "<OBJECT>", "$out"); - cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>", - mf->GetDefinition("CMAKE_C_COMPILER")); - flags += " " + depFlagsStr; - } - vars.Flags = flags.c_str(); + const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang; + std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str()); + if (!depfileFlags.empty()) + { + cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE"); + cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out"); + cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>", + mf->GetDefinition("CMAKE_C_COMPILER")); + flags += " " + depfileFlags; + } + } + vars.Flags = flags.c_str(); + vars.DependencyFile = depfile.c_str(); // Rule for compiling object file. - std::string compileCmdVar = "CMAKE_"; - compileCmdVar += language; - compileCmdVar += "_COMPILE_OBJECT"; - std::string compileCmd = mf->GetRequiredDefinition(compileCmdVar.c_str()); + const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT"; + std::string compileCmd = mf->GetRequiredDefinition(cmdVar.c_str()); std::vector<std::string> compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); - if(useClDeps) - { - std::string cmdPrefix = clDepsBinary + lang + " $in \"$DEP_FILE\" $out " + - clShowPrefix + clBinary; - compileCmds.front().insert(0, cmdPrefix); - } + compileCmds.front().insert(0, cldeps); for (std::vector<std::string>::iterator i = compileCmds.begin(); i != compileCmds.end(); ++i) @@ -413,14 +429,19 @@ cmNinjaTargetGenerator // Write the rule for compiling file of the given language. cmOStringStream comment; - comment << "Rule for compiling " << language << " files."; + comment << "Rule for compiling " << lang << " files."; cmOStringStream description; - description << "Building " << language << " object $out"; - this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), + description << "Building " << lang << " object $out"; + this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(lang), cmdLine, description.str(), comment.str(), - depfile); + depfile, + deptype, + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); } void @@ -540,7 +561,10 @@ cmNinjaTargetGenerator cmNinjaVars vars; vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); - vars["DEP_FILE"] = objectFileName + ".d";; + if (needsDepFile(language)) { + vars["DEP_FILE"] = + cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d"); + } EnsureParentDirectoryExists(objectFileName); std::string objectDir = cmSystemTools::GetFilenamePath(objectFileName); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index cf06bfd..1cf811a 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -42,6 +42,8 @@ public: std::string GetTargetName() const; + bool needsDepFile(const std::string& lang); + protected: bool SetMsvcTargetPdbVariable(cmNinjaVars&) const; diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 0220825..86beb97 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -273,7 +273,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget* target, + cmTarget const* target, const char* purpose) { this->GlobalGenerator = gg; diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 96a75de..76bf429 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector<std::string> const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget* Target; + cmTarget const* Target; std::string Purpose; bool Computed; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index c05de17..a18fc16 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -286,6 +286,21 @@ cmPolicies::cmPolicies() CMP0036, "CMP0036", "The build_name command should not be called.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0037, "CMP0037", + "Target names should not be reserved and should match a validity pattern.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0038, "CMP0038", + "Targets may not link directly to themselves.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0039, "CMP0039", + "Utility targets may not have link dependencies.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() @@ -357,15 +372,9 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) { mf->IssueMessage(cmake::FATAL_ERROR, - "An attempt was made to set the policy version of CMake to something " - "earlier than \"2.4\". " - "In CMake 2.4 and below backwards compatibility was handled with the " - "CMAKE_BACKWARDS_COMPATIBILITY variable. " - "In order to get compatibility features supporting versions earlier " - "than 2.4 set policy CMP0001 to OLD to tell CMake to check the " - "CMAKE_BACKWARDS_COMPATIBILITY variable. " - "One way to do this is to set the policy version to 2.4 exactly." - ); + "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. " + "For compatibility with older versions please use any CMake 2.8.x " + "release or lower."); return false; } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 9e72bdc..361d820 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -88,6 +88,10 @@ public: CMP0034, ///< Disallow command: utility_source CMP0035, ///< Disallow command: variable_requires CMP0036, ///< Disallow command: build_name + CMP0037, ///< Target names should not be reserved and + /// should match a validity pattern. + CMP0038, ///< Targets may not link directly to themselves + CMP0039, ///< Utility targets may not have link dependencies /** \brief Always the last entry. * diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutoGenerators.cxx index 651e0ad..36cb368 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -23,13 +23,14 @@ #include <cmsys/Terminal.h> #include <cmsys/ios/sstream> +#include <assert.h> #include <string.h> #if defined(__APPLE__) #include <unistd.h> #endif -#include "cmQtAutomoc.h" +#include "cmQtAutoGenerators.h" static bool requiresMocing(const std::string& text, std::string ¯oName) @@ -113,10 +114,12 @@ static void copyTargetProperty(cmTarget* destinationTarget, } -cmQtAutomoc::cmQtAutomoc() +cmQtAutoGenerators::cmQtAutoGenerators() :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) ,ColorOutput(true) ,RunMocFailed(false) +,RunUicFailed(false) +,RunRccFailed(false) ,GenerateAll(false) { @@ -135,7 +138,25 @@ cmQtAutomoc::cmQtAutomoc() } } -bool cmQtAutomoc::InitializeMocSourceFile(cmTarget* target) +static std::string getAutogenTargetName(cmTarget *target) +{ + std::string autogenTargetName = target->GetName(); + autogenTargetName += "_automoc"; + return autogenTargetName; +} + +static std::string getAutogenTargetDir(cmTarget *target) +{ + cmMakefile* makefile = target->GetMakefile(); + std::string targetDir = makefile->GetCurrentOutputDirectory(); + targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); + targetDir += "/"; + targetDir += getAutogenTargetName(target); + targetDir += ".dir/"; + return targetDir; +} + +bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); // don't do anything if there is no Qt4 or Qt5Core (which contains moc): @@ -149,18 +170,123 @@ bool cmQtAutomoc::InitializeMocSourceFile(cmTarget* target) return false; } - std::string automocTargetName = target->GetName(); - automocTargetName += "_automoc"; - std::string mocCppFile = makefile->GetCurrentOutputDirectory(); - mocCppFile += "/"; - mocCppFile += automocTargetName; - mocCppFile += ".cpp"; - cmSourceFile* mocCppSource = makefile->GetOrCreateSource(mocCppFile.c_str(), - true); - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - mocCppFile.c_str(), false); + if (target->GetPropertyAsBool("AUTOMOC")) + { + std::string automocTargetName = getAutogenTargetName(target); + std::string mocCppFile = makefile->GetCurrentOutputDirectory(); + mocCppFile += "/"; + mocCppFile += automocTargetName; + mocCppFile += ".cpp"; + cmSourceFile* mocCppSource = makefile->GetOrCreateSource( + mocCppFile.c_str(), + true); + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + mocCppFile.c_str(), false); + + target->AddSourceFile(mocCppSource); + } + // create a custom target for running generators at buildtime: + std::string autogenTargetName = getAutogenTargetName(target); + + std::string targetDir = getAutogenTargetDir(target); + + cmCustomCommandLine currentLine; + currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND")); + currentLine.push_back("-E"); + currentLine.push_back("cmake_autogen"); + currentLine.push_back(targetDir); + currentLine.push_back("$<CONFIGURATION>"); + + cmCustomCommandLines commandLines; + commandLines.push_back(currentLine); + + std::string workingDirectory = cmSystemTools::CollapseFullPath( + "", makefile->GetCurrentOutputDirectory()); + + std::vector<std::string> depends; + std::vector<std::string> toolNames; + if (target->GetPropertyAsBool("AUTOMOC")) + { + toolNames.push_back("moc"); + } + if (target->GetPropertyAsBool("AUTOUIC")) + { + toolNames.push_back("uic"); + } + if (target->GetPropertyAsBool("AUTORCC")) + { + toolNames.push_back("rcc"); + } + + std::string tools = toolNames[0]; + toolNames.erase(toolNames.begin()); + while (toolNames.size() > 1) + { + tools += ", " + toolNames[0]; + toolNames.erase(toolNames.begin()); + } + if (toolNames.size() == 1) + { + tools += " and " + toolNames[0]; + } + std::string autogenComment = "Automatic " + tools + " for target "; + autogenComment += target->GetName(); + +#if defined(_WIN32) && !defined(__CYGWIN__) + bool usePRE_BUILD = false; + cmLocalGenerator* localGen = makefile->GetLocalGenerator(); + cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); + if(strstr(gg->GetName(), "Visual Studio")) + { + cmLocalVisualStudioGenerator* vslg = + static_cast<cmLocalVisualStudioGenerator*>(localGen); + // Under VS >= 7 use a PRE_BUILD event instead of a separate target to + // reduce the number of targets loaded into the IDE. + // This also works around a VS 11 bug that may skip updating the target: + // https://connect.microsoft.com/VisualStudio/feedback/details/769495 + usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7; + } + if(usePRE_BUILD) + { + // Add the pre-build command directly to bypass the OBJECT_LIBRARY + // rejection in cmMakefile::AddCustomCommandToTarget because we know + // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. + std::vector<std::string> no_output; + cmCustomCommand cc(makefile, no_output, depends, + commandLines, autogenComment.c_str(), + workingDirectory.c_str()); + cc.SetEscapeOldStyle(false); + cc.SetEscapeAllowMakeVars(true); + target->GetPreBuildCommands().push_back(cc); + } + else +#endif + { + cmTarget* autogenTarget = makefile->AddUtilityCommand( + autogenTargetName.c_str(), true, + workingDirectory.c_str(), depends, + commandLines, false, autogenComment.c_str()); + // Set target folder + const char* autogenFolder = makefile->GetCMakeInstance()->GetProperty( + "AUTOMOC_TARGETS_FOLDER"); + if (!autogenFolder) + { + autogenFolder = makefile->GetCMakeInstance()->GetProperty( + "AUTOGEN_TARGETS_FOLDER"); + } + if (autogenFolder && *autogenFolder) + { + autogenTarget->SetProperty("FOLDER", autogenFolder); + } + else + { + // inherit FOLDER property from target (#13688) + copyTargetProperty(autogenTarget, target, "FOLDER"); + } + + target->AddUtility(autogenTargetName.c_str()); + } - target->AddSourceFile(mocCppSource); return true; } @@ -201,91 +327,103 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, } } -void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) +void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); - const char* targetName = target->GetName(); - bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); + // forget the variables added here afterwards again: + cmMakefile::ScopePushPop varScope(makefile); + static_cast<void>(varScope); - // create a custom target for running automoc at buildtime: - std::string automocTargetName = targetName; - automocTargetName += "_automoc"; + // create a custom target for running generators at buildtime: + std::string autogenTargetName = getAutogenTargetName(target); - std::string targetDir = makefile->GetCurrentOutputDirectory(); - targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); - targetDir += "/"; - targetDir += automocTargetName; - targetDir += ".dir/"; + makefile->AddDefinition("_moc_target_name", + cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str()); - cmCustomCommandLine currentLine; - currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND")); - currentLine.push_back("-E"); - currentLine.push_back("cmake_automoc"); - currentLine.push_back(targetDir); - currentLine.push_back("$<CONFIGURATION>"); + std::string targetDir = getAutogenTargetDir(target); - cmCustomCommandLines commandLines; - commandLines.push_back(currentLine); - - std::string workingDirectory = cmSystemTools::CollapseFullPath( - "", makefile->GetCurrentOutputDirectory()); + const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); + if (!qtVersion) + { + qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); + } + if (const char *targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0)) + { + qtVersion = targetQtVersion; + } + if (qtVersion) + { + makefile->AddDefinition("_target_qt_version", qtVersion); + } - std::vector<std::string> depends; - std::string automocComment = "Automoc for target "; - automocComment += targetName; + std::map<std::string, std::string> configIncludes; + std::map<std::string, std::string> configDefines; -#if defined(_WIN32) && !defined(__CYGWIN__) - bool usePRE_BUILD = false; - cmLocalGenerator* localGen = makefile->GetLocalGenerator(); - cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); - if(strstr(gg->GetName(), "Visual Studio")) + if (target->GetPropertyAsBool("AUTOMOC")) { - cmLocalVisualStudioGenerator* vslg = - static_cast<cmLocalVisualStudioGenerator*>(localGen); - // Under VS >= 7 use a PRE_BUILD event instead of a separate target to - // reduce the number of targets loaded into the IDE. - // This also works around a VS 11 bug that may skip updating the target: - // https://connect.microsoft.com/VisualStudio/feedback/details/769495 - usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7; + this->SetupAutoMocTarget(target, autogenTargetName, + configIncludes, configDefines); } - if(usePRE_BUILD) + if (target->GetPropertyAsBool("AUTOUIC")) { - // Add the pre-build command directly to bypass the OBJECT_LIBRARY - // rejection in cmMakefile::AddCustomCommandToTarget because we know - // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. - std::vector<std::string> no_output; - cmCustomCommand cc(makefile, no_output, depends, - commandLines, automocComment.c_str(), - workingDirectory.c_str()); - cc.SetEscapeOldStyle(false); - cc.SetEscapeAllowMakeVars(true); - target->GetPreBuildCommands().push_back(cc); + this->SetupAutoUicTarget(target); } - else -#endif + if (target->GetPropertyAsBool("AUTORCC")) { - cmTarget* automocTarget = makefile->AddUtilityCommand( - automocTargetName.c_str(), true, - workingDirectory.c_str(), depends, - commandLines, false, automocComment.c_str()); - // Set target folder - const char* automocFolder = makefile->GetCMakeInstance()->GetProperty( - "AUTOMOC_TARGETS_FOLDER"); - if (automocFolder && *automocFolder) + this->SetupAutoRccTarget(target); + } + + const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); + std::string inputFile = cmakeRoot; + inputFile += "/Modules/AutogenInfo.cmake.in"; + std::string outputFile = targetDir; + outputFile += "/AutogenInfo.cmake"; + makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), + false, true, false); + + if (!configDefines.empty() || !configIncludes.empty()) + { + std::ofstream infoFile(outputFile.c_str(), std::ios::app); + if ( !infoFile ) { - automocTarget->SetProperty("FOLDER", automocFolder); + std::string error = "Internal CMake error when trying to open file: "; + error += outputFile.c_str(); + error += " for writing."; + cmSystemTools::Error(error.c_str()); + return; } - else + if (!configDefines.empty()) { - // inherit FOLDER property from target (#13688) - copyTargetProperty(automocTarget, target, "FOLDER"); + for (std::map<std::string, std::string>::iterator + it = configDefines.begin(), end = configDefines.end(); + it != end; ++it) + { + infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << + " " << it->second << ")\n"; + } + } + if (!configIncludes.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configIncludes.begin(), end = configIncludes.end(); + it != end; ++it) + { + infoFile << "set(AM_MOC_INCLUDES_" << it->first << + " " << it->second << ")\n"; + } } - - target->AddUtility(automocTargetName.c_str()); } +} + +void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target, + const std::string &autogenTargetName, + std::map<std::string, std::string> &configIncludes, + std::map<std::string, std::string> &configDefines) +{ + cmMakefile* makefile = target->GetMakefile(); - // configure a file to get all information to automoc at buildtime: std::string _moc_files; std::string _moc_headers; const char* sepFiles = ""; @@ -293,6 +431,9 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::string skip_moc; + const char *sep = ""; + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -303,41 +444,46 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); - if ((skip==false) && (generated == false)) + if (!generated) { - std::string ext = sf->GetExtension(); - cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( - ext.c_str()); - if (fileType == cmSystemTools::CXX_FILE_FORMAT) + if (skip) { - _moc_files += sepFiles; - _moc_files += absFile; - sepFiles = ";"; + skip_moc += sep; + skip_moc += absFile; + sep = ";"; } - else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + else { - _moc_headers += sepHeaders; - _moc_headers += absFile; - sepHeaders = ";"; + std::string ext = sf->GetExtension(); + cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( + ext.c_str()); + if (fileType == cmSystemTools::CXX_FILE_FORMAT) + { + _moc_files += sepFiles; + _moc_files += absFile; + sepFiles = ";"; + } + else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + { + _moc_headers += sepHeaders; + _moc_headers += absFile; + sepHeaders = ";"; + } } } } const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); std::string _moc_options = (tmp!=0 ? tmp : ""); - - // forget the variables added here afterwards again: - cmMakefile::ScopePushPop varScope(makefile); - static_cast<void>(varScope); - - makefile->AddDefinition("_moc_target_name", - cmLocalGenerator::EscapeForCMake(automocTargetName.c_str()).c_str()); makefile->AddDefinition("_moc_options", cmLocalGenerator::EscapeForCMake(_moc_options.c_str()).c_str()); makefile->AddDefinition("_moc_files", cmLocalGenerator::EscapeForCMake(_moc_files.c_str()).c_str()); + makefile->AddDefinition("_skip_moc", + cmLocalGenerator::EscapeForCMake(skip_moc.c_str()).c_str()); makefile->AddDefinition("_moc_headers", cmLocalGenerator::EscapeForCMake(_moc_headers.c_str()).c_str()); + bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); std::string _moc_incs; @@ -352,9 +498,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) makefile->AddDefinition("_moc_compile_defs", cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str()); - std::map<std::string, std::string> configIncludes; - std::map<std::string, std::string> configDefines; - for (std::vector<std::string>::const_iterator li = configs.begin(); li != configs.end(); ++li) { @@ -383,33 +526,17 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } } - const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); - if (!qtVersion) - { - qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); - } - if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0)) - { - qtVersion = targetQtVersion; - } - if (qtVersion) - { - makefile->AddDefinition("_target_qt_version", qtVersion); - } - - { const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE"); makefile->AddDefinition("_qt_moc_executable", qtMoc); - } + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (strcmp(qtVersion, "5") == 0) { cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc"); if (!qt5Moc) { cmSystemTools::Error("Qt5::moc target not found ", - automocTargetName.c_str()); + autogenTargetName.c_str()); return; } makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0)); @@ -419,68 +546,338 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) if (strcmp(qtVersion, "4") != 0) { cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and " - "Qt 5 ", automocTargetName.c_str()); + "Qt 5 ", autogenTargetName.c_str()); } } +} - const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); - std::string inputFile = cmakeRoot; - inputFile += "/Modules/AutomocInfo.cmake.in"; - std::string outputFile = targetDir; - outputFile += "/AutomocInfo.cmake"; - makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), - false, true, false); +void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, + bool isQt5) +{ + static const char* valueOptions[] = { + "tr", + "translate", + "postfix", + "generator", + "g" + }; + std::vector<std::string> extraOpts; + for(std::vector<std::string>::const_iterator it = fileOpts.begin(); + it != fileOpts.end(); ++it) + { + std::vector<std::string>::iterator existingIt + = std::find(opts.begin(), opts.end(), *it); + if (existingIt != opts.end()) + { + const char *o = it->c_str(); + if (*o == '-') + { + ++o; + } + if (isQt5 && *o == '-') + { + ++o; + } + if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), + cmStrCmp(o)) != cmArrayEnd(valueOptions)) + { + assert(existingIt + 1 != opts.end()); + *(existingIt + 1) = *(it + 1); + ++it; + } + } + else + { + extraOpts.push_back(*it); + } + } + opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); +} - if (!configDefines.empty() || !configIncludes.empty()) +void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target) +{ + cmMakefile *makefile = target->GetMakefile(); + + const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE"); + makefile->AddDefinition("_qt_uic_executable", qtUic); + + const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + + std::string skip_uic; + const char *sep = ""; + + bool skip = target->GetPropertyAsBool("SKIP_AUTOUIC"); + + std::set<cmStdString> skipped; + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) { - std::ofstream infoFile(outputFile.c_str(), std::ios::app); - if ( !infoFile ) + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + if (!skip) { - std::string error = "Internal CMake error when trying to open file: "; - error += outputFile.c_str(); - error += " for writing."; - cmSystemTools::Error(error.c_str()); - return; + skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")); } - if (!configDefines.empty()) + + if (skip) { - for (std::map<std::string, std::string>::iterator - it = configDefines.begin(), end = configDefines.end(); - it != end; ++it) + skip_uic += sep; + skip_uic += absFile; + sep = ";"; + skipped.insert(absFile); + } + } + + makefile->AddDefinition("_skip_uic", + cmLocalGenerator::EscapeForCMake(skip_uic.c_str()).c_str()); + + std::vector<cmSourceFile*> uiFilesWithOptions + = makefile->GetQtUiFilesWithOptions(); + + std::string uiFileFiles; + std::string uiFileOptions; + sep = ""; + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + + if (const char* opts = target->GetProperty("AUTOUIC_OPTIONS")) + { + makefile->AddDefinition("_uic_target_options", + cmLocalGenerator::EscapeForCMake(opts).c_str()); + } + + for(std::vector<cmSourceFile*>::const_iterator fileIt = + uiFilesWithOptions.begin(); + fileIt != uiFilesWithOptions.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + + if (!skipped.insert(absFile).second) + { + continue; + } + uiFileFiles += sep; + uiFileFiles += absFile; + uiFileOptions += sep; + std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); + cmSystemTools::ReplaceString(opts, ";", "@list_sep@"); + uiFileOptions += opts; + sep = ";"; + } + + makefile->AddDefinition("_qt_uic_options_files", + cmLocalGenerator::EscapeForCMake(uiFileFiles.c_str()).c_str()); + makefile->AddDefinition("_qt_uic_options_options", + cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str()); + + const char* targetName = target->GetName(); + if (strcmp(qtVersion, "5") == 0) + { + cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic"); + if (!qt5Uic) + { + // Project does not use Qt5Widgets, but has AUTOUIC ON anyway + makefile->RemoveDefinition("_qt_uic_executable"); + } + else + { + makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0)); + } + } + else + { + if (strcmp(qtVersion, "4") != 0) + { + cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " + "Qt 5 ", targetName); + } + } +} + +void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, + bool isQt5) +{ + static const char* valueOptions[] = { + "name", + "root", + "compress", + "threshold" + }; + std::vector<std::string> extraOpts; + for(std::vector<std::string>::const_iterator it = fileOpts.begin(); + it != fileOpts.end(); ++it) + { + std::vector<std::string>::iterator existingIt + = std::find(opts.begin(), opts.end(), *it); + if (existingIt != opts.end()) + { + const char *o = it->c_str(); + if (*o == '-') { - infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << - " " << it->second << ")\n"; + ++o; + } + if (isQt5 && *o == '-') + { + ++o; + } + if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), + cmStrCmp(o)) != cmArrayEnd(valueOptions)) + { + assert(existingIt + 1 != opts.end()); + *(existingIt + 1) = *(it + 1); + ++it; } } - if (!configIncludes.empty()) + else { - for (std::map<std::string, std::string>::iterator - it = configIncludes.begin(), end = configIncludes.end(); - it != end; ++it) + extraOpts.push_back(*it); + } + } + opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); +} + +void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) +{ + std::string _rcc_files; + const char* sepRccFiles = ""; + cmMakefile *makefile = target->GetMakefile(); + + std::vector<cmSourceFile*> newFiles; + + const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + + std::string rccFileFiles; + std::string rccFileOptions; + const char *sep = ""; + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + + std::vector<std::string> rccOptions; + if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) + { + cmSystemTools::ExpandListArgument(opts, rccOptions); + } + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) { - infoFile << "set(AM_MOC_INCLUDES_" << it->first << - " " << it->second << ")\n"; + _rcc_files += sepRccFiles; + _rcc_files += absFile; + sepRccFiles = ";"; + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + newFiles.push_back(rccCppSource); + + if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) + { + std::vector<std::string> optsVec; + cmSystemTools::ExpandListArgument(prop, optsVec); + this->MergeRccOptions(rccOptions, optsVec, + strcmp(qtVersion, "5") == 0); + } + + if (!rccOptions.empty()) + { + rccFileFiles += sep; + rccFileFiles += absFile; + rccFileOptions += sep; + } + const char *listSep = ""; + for(std::vector<std::string>::const_iterator it = rccOptions.begin(); + it != rccOptions.end(); + ++it) + { + rccFileOptions += listSep; + rccFileOptions += *it; + listSep = "@list_sep@"; + } + sep = ";"; } } } -} + for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); + fileIt != newFiles.end(); + ++fileIt) + { + target->AddSourceFile(*fileIt); + } + + makefile->AddDefinition("_rcc_files", + cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); + + makefile->AddDefinition("_qt_rcc_options_files", + cmLocalGenerator::EscapeForCMake(rccFileFiles.c_str()).c_str()); + makefile->AddDefinition("_qt_rcc_options_options", + cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str()); + + const char *qtRcc = makefile->GetSafeDefinition("QT_RCC_EXECUTABLE"); + makefile->AddDefinition("_qt_rcc_executable", qtRcc); + + const char* targetName = target->GetName(); + if (strcmp(qtVersion, "5") == 0) + { + cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc"); + if (!qt5Rcc) + { + cmSystemTools::Error("Qt5::rcc target not found ", + targetName); + return; + } + makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0)); + } + else + { + if (strcmp(qtVersion, "4") != 0) + { + cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " + "Qt 5 ", targetName); + } + } +} -bool cmQtAutomoc::Run(const char* targetDirectory, const char *config) +bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) { bool success = true; cmake cm; cmGlobalGenerator* gg = this->CreateGlobalGenerator(&cm, targetDirectory); cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); - this->ReadAutomocInfoFile(makefile, targetDirectory, config); + this->ReadAutogenInfoFile(makefile, targetDirectory, config); this->ReadOldMocDefinitionsFile(makefile, targetDirectory); this->Init(); if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - success = this->RunAutomoc(makefile); + success = this->RunAutogen(makefile); } this->WriteOldMocDefinitionsFile(targetDirectory); @@ -492,7 +889,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory, const char *config) } -cmGlobalGenerator* cmQtAutomoc::CreateGlobalGenerator(cmake* cm, +cmGlobalGenerator* cmQtAutoGenerators::CreateGlobalGenerator(cmake* cm, const char* targetDirectory) { cmGlobalGenerator* gg = new cmGlobalGenerator(); @@ -509,13 +906,13 @@ cmGlobalGenerator* cmQtAutomoc::CreateGlobalGenerator(cmake* cm, } -bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, +bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config) { std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); - filename += "/AutomocInfo.cmake"; + filename += "/AutogenInfo.cmake"; if (!makefile->ReadListFile(0, filename.c_str())) { @@ -530,12 +927,17 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, "AM_Qt5Core_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); + this->RccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES"); + this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC"); + this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); this->IncludeProjectDirsBefore = makefile->IsOn( "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR"); this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); + this->UicExecutable = makefile->GetSafeDefinition("AM_QT_UIC_EXECUTABLE"); + this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE"); std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS"; std::string compileDefsProp = compileDefsPropOrig; if(config) @@ -561,6 +963,53 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME"); + { + const char *uicOptionsFiles + = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"); + const char *uicTargetOptions + = makefile->GetSafeDefinition("AM_UIC_TARGET_OPTIONS"); + cmSystemTools::ExpandListArgument(uicTargetOptions, this->UicTargetOptions); + const char *uicOptionsOptions + = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"); + std::vector<std::string> uicFilesVec; + cmSystemTools::ExpandListArgument(uicOptionsFiles, uicFilesVec); + std::vector<std::string> uicOptionsVec; + cmSystemTools::ExpandListArgument(uicOptionsOptions, uicOptionsVec); + if (uicFilesVec.size() != uicOptionsVec.size()) + { + return false; + } + for (std::vector<std::string>::iterator fileIt = uicFilesVec.begin(), + optionIt = uicOptionsVec.begin(); + fileIt != uicFilesVec.end(); + ++fileIt, ++optionIt) + { + cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";"); + this->UicOptions[*fileIt] = *optionIt; + } + } + { + const char *rccOptionsFiles + = makefile->GetSafeDefinition("AM_RCC_OPTIONS_FILES"); + const char *rccOptionsOptions + = makefile->GetSafeDefinition("AM_RCC_OPTIONS_OPTIONS"); + std::vector<std::string> rccFilesVec; + cmSystemTools::ExpandListArgument(rccOptionsFiles, rccFilesVec); + std::vector<std::string> rccOptionsVec; + cmSystemTools::ExpandListArgument(rccOptionsOptions, rccOptionsVec); + if (rccFilesVec.size() != rccOptionsVec.size()) + { + return false; + } + for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(), + optionIt = rccOptionsVec.begin(); + fileIt != rccFilesVec.end(); + ++fileIt, ++optionIt) + { + cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";"); + this->RccOptions[*fileIt] = *optionIt; + } + } this->CurrentCompileSettingsStr = this->MakeCompileSettingsString(makefile); this->RelaxedMode = makefile->IsOn("AM_RELAXED_MODE"); @@ -569,7 +1018,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, } -std::string cmQtAutomoc::MakeCompileSettingsString(cmMakefile* makefile) +std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile) { std::string s; s += makefile->GetSafeDefinition("AM_MOC_COMPILE_DEFINITIONS"); @@ -586,7 +1035,7 @@ std::string cmQtAutomoc::MakeCompileSettingsString(cmMakefile* makefile) } -bool cmQtAutomoc::ReadOldMocDefinitionsFile(cmMakefile* makefile, +bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, const char* targetDirectory) { std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); @@ -602,7 +1051,8 @@ bool cmQtAutomoc::ReadOldMocDefinitionsFile(cmMakefile* makefile, } -void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) +void +cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory) { std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); @@ -619,7 +1069,7 @@ void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) } -void cmQtAutomoc::Init() +void cmQtAutoGenerators::Init() { this->OutMocCppFilename = this->Builddir; this->OutMocCppFilename += this->TargetName; @@ -706,7 +1156,7 @@ void cmQtAutomoc::Init() } -bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) +bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) { if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str()) || (this->OldCompileSettingsStr != this->CurrentCompileSettingsStr)) @@ -733,26 +1183,56 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) const std::vector<std::string>& headerExtensions = makefile->GetHeaderExtensions(); + std::vector<std::string> includedUis; + std::vector<std::string> skippedUis; + std::vector<std::string> uicSkipped; + cmSystemTools::ExpandListArgument(this->SkipUic, uicSkipped); + for (std::vector<std::string>::const_iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) { + const bool skipUic = std::find(uicSkipped.begin(), uicSkipped.end(), *it) + != uicSkipped.end(); + std::vector<std::string>& uiFiles = skipUic ? skippedUis : includedUis; const std::string &absFilename = *it; if (this->Verbose) { - std::cout << "AUTOMOC: Checking " << absFilename << std::endl; + std::cout << "AUTOGEN: Checking " << absFilename << std::endl; } if (this->RelaxedMode) { - this->ParseCppFile(absFilename, headerExtensions, includedMocs); + this->ParseCppFile(absFilename, headerExtensions, includedMocs, + uiFiles); } else { - this->StrictParseCppFile(absFilename, headerExtensions, includedMocs); + this->StrictParseCppFile(absFilename, headerExtensions, includedMocs, + uiFiles); } this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles); } + { + std::vector<std::string> mocSkipped; + cmSystemTools::ExpandListArgument(this->SkipMoc, mocSkipped); + for (std::vector<std::string>::const_iterator it = mocSkipped.begin(); + it != mocSkipped.end(); + ++it) + { + if (std::find(uicSkipped.begin(), uicSkipped.end(), *it) + != uicSkipped.end()) + { + const std::string &absFilename = *it; + if (this->Verbose) + { + std::cout << "AUTOGEN: Checking " << absFilename << std::endl; + } + this->ParseForUic(absFilename, includedUis); + } + } + } + std::vector<std::string> headerFilesVec; cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec); for (std::vector<std::string>::const_iterator it = headerFilesVec.begin(); @@ -764,7 +1244,7 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) // key = moc source filepath, value = moc output filename std::map<std::string, std::string> notIncludedMocs; - this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs); + this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis); // run moc on all the moc's that are #included in source files for(std::map<std::string, std::string>::const_iterator @@ -774,6 +1254,17 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) { this->GenerateMoc(it->first, it->second); } + for(std::vector<std::string>::const_iterator it = includedUis.begin(); + it != includedUis.end(); + ++it) + { + this->GenerateUi(*it); + } + + if(!this->RccExecutable.empty()) + { + this->GenerateQrc(); + } cmsys_ios::stringstream outStream; outStream << "/* This file is autogenerated, do not edit*/\n"; @@ -806,6 +1297,17 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) std::cerr << "moc failed..."<< std::endl; return false; } + + if (this->RunUicFailed) + { + std::cerr << "uic failed..."<< std::endl; + return false; + } + if (this->RunRccFailed) + { + std::cerr << "rcc failed..."<< std::endl; + return false; + } outStream.flush(); std::string automocSource = outStream.str(); if (!automocCppChanged) @@ -830,9 +1332,10 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) } -void cmQtAutomoc::ParseCppFile(const std::string& absFilename, +void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs) + std::map<std::string, std::string>& includedMocs, + std::vector<std::string> &includedUis) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -841,7 +1344,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, const std::string contentsString = this->ReadAll(absFilename); if (contentsString.empty()) { - std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n" + std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; return; } @@ -901,7 +1404,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } else { - std::cerr << "AUTOMOC: error: " << absFilename << " The file " + std::cerr << "AUTOGEN: error: " << absFilename << " The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' << this->Join(headerExtensions, ',') << "}\" "; @@ -932,7 +1435,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, fileToMoc = headerToMoc; if ((requiresMoc==false) &&(basename==scannedFileBasename)) { - std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + std::cerr << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << "\", but does not contain a " << macroName << " macro. Running moc on " @@ -943,7 +1446,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } else { - std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + std::cerr << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << "\" instead of \"moc_" << basename << ".cpp\". " "Running moc on " @@ -955,7 +1458,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } else { - std::cerr <<"AUTOMOC: error: " << absFilename << ": The file " + std::cerr <<"AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << "\", which seems to be the moc file from a different " "source file. CMake also could not find a matching " @@ -973,6 +1476,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } + this->ParseForUic(absFilename, contentsString, includedUis); // In this case, check whether the scanned file itself contains a Q_OBJECT. // If this is the case, the moc_foo.cpp should probably be generated from @@ -983,7 +1487,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, if (mocUnderscoreIncluded == true) { // this is for KDE4 compatibility: - std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + std::cerr << "AUTOGEN: warning: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not " "include " << "\"" << scannedFileBasename << ".moc\", but instead " @@ -999,7 +1503,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, else { // otherwise always error out since it will not compile: - std::cerr << "AUTOMOC: error: " << absFilename << ": The file " + std::cerr << "AUTOGEN: error: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not " "include " << "\"" << scannedFileBasename << ".moc\" !\n" @@ -1011,9 +1515,10 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } -void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, +void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs) + std::map<std::string, std::string>& includedMocs, + std::vector<std::string>& includedUis) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -1022,7 +1527,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, const std::string contentsString = this->ReadAll(absFilename); if (contentsString.empty()) { - std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n" + std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; return; } @@ -1069,7 +1574,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, } else { - std::cerr << "AUTOMOC: error: " << absFilename << " The file " + std::cerr << "AUTOGEN: error: " << absFilename << " The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' << this->Join(headerExtensions, ',') << "}\" "; @@ -1090,7 +1595,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, { if (basename != scannedFileBasename) { - std::cerr <<"AUTOMOC: error: " << absFilename << ": The file " + std::cerr <<"AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << "\", which seems to be the moc file from a different " "source file. This is not supported. " @@ -1104,6 +1609,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } + this->ParseForUic(absFilename, contentsString, includedUis); // In this case, check whether the scanned file itself contains a Q_OBJECT. // If this is the case, the moc_foo.cpp should probably be generated from @@ -1114,7 +1620,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, macroName))) { // otherwise always error out since it will not compile: - std::cerr << "AUTOMOC: error: " << absFilename << ": The file " + std::cerr << "AUTOGEN: error: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not include " << "\"" << scannedFileBasename << ".moc\" !\n" << std::endl; @@ -1124,7 +1630,63 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, } -void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename, +void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, + std::vector<std::string>& includedUis) +{ + if (this->UicExecutable.empty()) + { + return; + } + const std::string contentsString = this->ReadAll(absFilename); + if (contentsString.empty()) + { + std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" + << std::endl; + return; + } + this->ParseForUic(absFilename, contentsString, includedUis); +} + + +void cmQtAutoGenerators::ParseForUic(const std::string&, + const std::string& contentsString, + std::vector<std::string>& includedUis) +{ + if (this->UicExecutable.empty()) + { + return; + } + cmsys::RegularExpression uiIncludeRegExp( + "[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); + + std::string::size_type matchOffset = 0; + + matchOffset = 0; + if ((strstr(contentsString.c_str(), "ui_") != NULL) + && (uiIncludeRegExp.find(contentsString))) + { + do + { + const std::string currentUi = uiIncludeRegExp.match(1); + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(currentUi); + + // basename should be the part of the ui filename used for + // finding the correct header, so we need to remove the ui_ part + basename = basename.substr(3); + + includedUis.push_back(basename); + + matchOffset += uiIncludeRegExp.end(); + } while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset)); + } +} + + +void +cmQtAutoGenerators::SearchHeadersForCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, std::set<std::string>& absHeaders) { @@ -1160,28 +1722,29 @@ void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename, } -void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders, +void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders, const std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::string>& notIncludedMocs) + std::map<std::string, std::string>& notIncludedMocs, + std::vector<std::string>& includedUis) { for(std::set<std::string>::const_iterator hIt=absHeaders.begin(); hIt!=absHeaders.end(); ++hIt) { const std::string& headerName = *hIt; + const std::string contents = this->ReadAll(headerName); if (includedMocs.find(headerName) == includedMocs.end()) { if (this->Verbose) { - std::cout << "AUTOMOC: Checking " << headerName << std::endl; + std::cout << "AUTOGEN: Checking " << headerName << std::endl; } const std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(headerName); const std::string currentMoc = "moc_" + basename + ".cpp"; - const std::string contents = this->ReadAll(headerName); std::string macroName; if (requiresMocing(contents, macroName)) { @@ -1189,12 +1752,11 @@ void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders, notIncludedMocs[headerName] = currentMoc; } } + this->ParseForUic(headerName, contents, includedUis); } - } - -bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, +bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, const std::string& mocFileName) { const std::string mocFilePath = this->Builddir + mocFileName; @@ -1260,7 +1822,7 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); if (!result || retVal) { - std::cerr << "AUTOMOC: error: process for " << mocFilePath <<" failed:\n" + std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n" << output << std::endl; this->RunMocFailed = true; cmSystemTools::RemoveFile(mocFilePath.c_str()); @@ -1270,8 +1832,152 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, return false; } +bool cmQtAutoGenerators::GenerateUi(const std::string& uiFileName) +{ + if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false)) + { + cmsys::SystemTools::MakeDirectory(this->Builddir.c_str()); + } + + std::string ui_output_file = "ui_" + uiFileName + ".h"; + std::string ui_input_file = this->Srcdir + uiFileName + ".ui"; + + int sourceNewerThanUi = 0; + bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file.c_str(), + (this->Builddir + ui_output_file).c_str(), + &sourceNewerThanUi); + if (this->GenerateAll || !success || sourceNewerThanUi >= 0) + { + std::string msg = "Generating "; + msg += ui_output_file; + cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue + |cmsysTerminal_Color_ForegroundBold, + msg.c_str(), true, this->ColorOutput); + + std::vector<cmStdString> command; + command.push_back(this->UicExecutable); + + std::string options; + std::vector<std::string> opts = this->UicTargetOptions; + std::map<std::string, std::string>::const_iterator optionIt + = this->UicOptions.find(ui_input_file); + if (optionIt != this->UicOptions.end()) + { + std::vector<std::string> fileOpts; + cmSystemTools::ExpandListArgument(optionIt->second, fileOpts); + this->MergeUicOptions(opts, fileOpts, this->QtMajorVersion == "5"); + } + for(std::vector<std::string>::const_iterator optIt = opts.begin(); + optIt != opts.end(); + ++optIt) + { + command.push_back(*optIt); + } + + command.push_back("-o"); + command.push_back(this->Builddir + ui_output_file); + command.push_back(ui_input_file); + + if (this->Verbose) + { + for(std::vector<cmStdString>::const_iterator cmdIt = command.begin(); + cmdIt != command.end(); + ++cmdIt) + { + std::cout << *cmdIt << " "; + } + std::cout << std::endl; + } + std::string output; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + if (!result || retVal) + { + std::cerr << "AUTOUIC: error: process for " << ui_output_file << + " failed:\n" << output << std::endl; + this->RunUicFailed = true; + cmSystemTools::RemoveFile(ui_output_file.c_str()); + return false; + } + return true; + } + return false; +} + +bool cmQtAutoGenerators::GenerateQrc() +{ + std::vector<std::string> sourceFiles; + cmSystemTools::ExpandListArgument(this->RccSources, sourceFiles); + + for(std::vector<std::string>::const_iterator si = sourceFiles.begin(); + si != sourceFiles.end(); ++si) + { + std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si); + + if (ext != ".qrc") + { + continue; + } + std::vector<cmStdString> command; + command.push_back(this->RccExecutable); + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(*si); + + std::string rcc_output_file = this->Builddir + "qrc_" + basename + ".cpp"; + + int sourceNewerThanQrc = 0; + bool success = cmsys::SystemTools::FileTimeCompare(si->c_str(), + rcc_output_file.c_str(), + &sourceNewerThanQrc); + if (this->GenerateAll || !success || sourceNewerThanQrc >= 0) + { + std::string options; + std::map<std::string, std::string>::const_iterator optionIt + = this->RccOptions.find(*si); + if (optionIt != this->RccOptions.end()) + { + std::vector<std::string> opts; + cmSystemTools::ExpandListArgument(optionIt->second, opts); + for(std::vector<std::string>::const_iterator optIt = opts.begin(); + optIt != opts.end(); + ++optIt) + { + command.push_back(*optIt); + } + } + + command.push_back("-o"); + command.push_back(rcc_output_file); + command.push_back(*si); + + if (this->Verbose) + { + for(std::vector<cmStdString>::const_iterator cmdIt = command.begin(); + cmdIt != command.end(); + ++cmdIt) + { + std::cout << *cmdIt << " "; + } + std::cout << std::endl; + } + std::string output; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + if (!result || retVal) + { + std::cerr << "AUTORCC: error: process for " << rcc_output_file << + " failed:\n" << output << std::endl; + this->RunRccFailed = true; + cmSystemTools::RemoveFile(rcc_output_file.c_str()); + return false; + } + } + } + return true; +} -std::string cmQtAutomoc::Join(const std::vector<std::string>& lst, +std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst, char separator) { if (lst.empty()) @@ -1291,13 +1997,15 @@ std::string cmQtAutomoc::Join(const std::vector<std::string>& lst, } -bool cmQtAutomoc::StartsWith(const std::string& str, const std::string& with) +bool cmQtAutoGenerators::StartsWith(const std::string& str, + const std::string& with) { return (str.substr(0, with.length()) == with); } -bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) +bool cmQtAutoGenerators::EndsWith(const std::string& str, + const std::string& with) { if (with.length() > (str.length())) { @@ -1307,7 +2015,7 @@ bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) } -std::string cmQtAutomoc::ReadAll(const std::string& filename) +std::string cmQtAutoGenerators::ReadAll(const std::string& filename) { std::ifstream file(filename.c_str()); cmsys_ios::stringstream stream; diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutoGenerators.h index ebeeb0e..116f174 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutoGenerators.h @@ -11,26 +11,33 @@ See the License for more information. ============================================================================*/ -#ifndef cmQtAutomoc_h -#define cmQtAutomoc_h +#ifndef cmQtAutoGenerators_h +#define cmQtAutoGenerators_h class cmGlobalGenerator; class cmMakefile; -class cmQtAutomoc +class cmQtAutoGenerators { public: - cmQtAutomoc(); + cmQtAutoGenerators(); bool Run(const char* targetDirectory, const char *config); - bool InitializeMocSourceFile(cmTarget* target); - void SetupAutomocTarget(cmTarget* target); + bool InitializeAutogenTarget(cmTarget* target); + void SetupAutoGenerateTarget(cmTarget* target); private: + void SetupAutoMocTarget(cmTarget* target, + const std::string &autogenTargetName, + std::map<std::string, std::string> &configIncludes, + std::map<std::string, std::string> &configDefines); + void SetupAutoUicTarget(cmTarget* target); + void SetupAutoRccTarget(cmTarget* target); + cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, const char* targetDirectory); - bool ReadAutomocInfoFile(cmMakefile* makefile, + bool ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config); bool ReadOldMocDefinitionsFile(cmMakefile* makefile, @@ -39,22 +46,34 @@ private: std::string MakeCompileSettingsString(cmMakefile* makefile); - bool RunAutomoc(cmMakefile* makefile); + bool RunAutogen(cmMakefile* makefile); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); + bool GenerateUi(const std::string& uiFileName); + bool GenerateQrc(); void ParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs); + std::map<std::string, std::string>& includedMocs, + std::vector<std::string>& includedUis); void StrictParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs); + std::map<std::string, std::string>& includedMocs, + std::vector<std::string>& includedUis); void SearchHeadersForCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, std::set<std::string>& absHeaders); void ParseHeaders(const std::set<std::string>& absHeaders, const std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::string>& notIncludedMocs); + std::map<std::string, std::string>& notIncludedMocs, + std::vector<std::string>& includedUis); + + void ParseForUic(const std::string& fileName, + const std::string& contentsString, + std::vector<std::string>& includedUis); + + void ParseForUic(const std::string& fileName, + std::vector<std::string>& includedUis); void Init(); @@ -63,13 +82,24 @@ private: bool StartsWith(const std::string& str, const std::string& with); std::string ReadAll(const std::string& filename); + void MergeUicOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, bool isQt5); + + void MergeRccOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, bool isQt5); + std::string QtMajorVersion; std::string Sources; + std::string RccSources; + std::string SkipMoc; + std::string SkipUic; std::string Headers; bool IncludeProjectDirsBefore; std::string Srcdir; std::string Builddir; std::string MocExecutable; + std::string UicExecutable; + std::string RccExecutable; std::string MocCompileDefinitionsStr; std::string MocIncludesStr; std::string MocOptionsStr; @@ -84,10 +114,15 @@ private: std::list<std::string> MocIncludes; std::list<std::string> MocDefinitions; std::vector<std::string> MocOptions; + std::vector<std::string> UicTargetOptions; + std::map<std::string, std::string> UicOptions; + std::map<std::string, std::string> RccOptions; bool Verbose; bool ColorOutput; bool RunMocFailed; + bool RunUicFailed; + bool RunRccFailed; bool GenerateAll; bool RelaxedMode; diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 6d4e281..3aa8e1b 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -34,6 +34,8 @@ cmRST::cmRST(std::ostream& os, std::string const& docroot): ReplaceDirective("^.. (\\|[^|]+\\|) replace::[ \t]*(.*)$"), IncludeDirective("^.. include::[ \t]+([^ \t\n]+)$"), TocTreeDirective("^.. toctree::[ \t]*(.*)$"), + ProductionListDirective("^.. productionlist::[ \t]*(.*)$"), + NoteDirective("^.. note::[ \t]*(.*)$"), ModuleRST("^#\\[(=*)\\[\\.rst:$"), CMakeRole("(:cmake)?:(" "command|generator|variable|module|policy|" @@ -227,6 +229,16 @@ void cmRST::ProcessLine(std::string const& line) this->Directive = DirectiveTocTree; this->MarkupLines.push_back(this->TocTreeDirective.match(1)); } + else if(this->ProductionListDirective.find(line)) + { + // Output productionlist directives and their content normally. + this->NormalLine(line); + } + else if(this->NoteDirective.find(line)) + { + // Output note directives and their content normally. + this->NormalLine(line); + } } // An explicit markup start followed nothing but whitespace and a // blank line does not consume any indented text following. diff --git a/Source/cmRST.h b/Source/cmRST.h index fa987cd..3356008 100644 --- a/Source/cmRST.h +++ b/Source/cmRST.h @@ -84,6 +84,8 @@ private: cmsys::RegularExpression ReplaceDirective; cmsys::RegularExpression IncludeDirective; cmsys::RegularExpression TocTreeDirective; + cmsys::RegularExpression ProductionListDirective; + cmsys::RegularExpression NoteDirective; cmsys::RegularExpression ModuleRST; cmsys::RegularExpression CMakeRole; cmsys::RegularExpression Substitution; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 20f38be..bb193bf 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -62,9 +62,17 @@ bool cmSetCommand this->Makefile->RemoveDefinition(args[0].c_str()); return true; } + // SET (VAR PARENT_SCOPE) // Removes the definition of VAR + // in the parent scope. + else if (args.size() == 2 && args[args.size()-1] == "PARENT_SCOPE") + { + this->Makefile->RaiseScope(variable, 0); + return true; + } // here are the remaining options // SET (VAR value ) + // SET (VAR value PARENT_SCOPE) // SET (VAR CACHE TYPE "doc String" [FORCE]) // SET (VAR value CACHE TYPE "doc string" [FORCE]) std::string value; // optional @@ -114,15 +122,8 @@ bool cmSetCommand if (parentScope) { - if (value.empty()) - { - this->Makefile->RaiseScope(variable, 0); - } - else - { - this->Makefile->RaiseScope(variable, value.c_str()); - } - return true; + this->Makefile->RaiseScope(variable, value.c_str()); + return true; } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index d747309..ec98c2c 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -287,6 +287,17 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) } this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE); + + std::string ext = + cmSystemTools::GetFilenameLastExtension(this->Location.GetName()); + if (ext == ".ui") + { + cmMakefile* mf = this->Location.GetMakefile(); + if (strcmp(prop, "AUTOUIC_OPTIONS") == 0) + { + mf->AddQtUiFileWithOptions(this); + } + } } //---------------------------------------------------------------------------- diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 6c77144..18d017d 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -377,7 +377,8 @@ static thisClass* SafeDownCast(cmObject *c) \ return 0;\ } -#if defined(_MSC_VER) && _MSC_VER < 1300 +#if defined(_MSC_VER) && _MSC_VER < 1300 \ + || defined(__GNUC__) && __GNUC__ < 3 #define cmArrayBegin(a) a #define cmArraySize(a) (sizeof(a)/sizeof(*a)) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 8320ecf..b3dbd05 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -43,6 +43,10 @@ # include <sys/wait.h> #endif +#if defined(__APPLE__) +# include <mach-o/dyld.h> +#endif + #include <sys/stat.h> #if defined(_WIN32) && \ @@ -612,8 +616,24 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command, OutputOption outputflag , double timeout ) { + std::vector<std::string> cmd; + for(std::vector<cmStdString>::const_iterator i = command.begin(); + i != command.end(); ++i) + { + cmd.push_back(*i); + } + return cmSystemTools::RunSingleCommand(cmd, output, retVal, dir, + outputflag, timeout); +} + +bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, + std::string* output , + int* retVal , const char* dir , + OutputOption outputflag , + double timeout ) +{ std::vector<const char*> argv; - for(std::vector<cmStdString>::const_iterator a = command.begin(); + for(std::vector<std::string>::const_iterator a = command.begin(); a != command.end(); ++a) { argv.push_back(a->c_str()); @@ -775,6 +795,23 @@ bool cmSystemTools::RunSingleCommand( dir, outputflag, timeout); } +std::string +cmSystemTools::PrintSingleCommand(std::vector<std::string> const& command) +{ + std::string commandStr; + const char* sep = ""; + for(std::vector<std::string>::const_iterator i = command.begin(); + i != command.end(); ++i) + { + commandStr += sep; + commandStr += "\""; + commandStr += *i; + commandStr += "\""; + sep = " "; + } + return commandStr; +} + bool cmSystemTools::DoesFileExistWithExtensions( const char* name, const std::vector<std::string>& headerExts) @@ -1619,18 +1656,23 @@ bool extract_tar(const char* outFileName, bool verbose, archive_error_string(a)); break; } - if (verbose && extract) - { - cmSystemTools::Stdout("x "); - cmSystemTools::Stdout(archive_entry_pathname(entry)); - } - if(verbose && !extract) + if(verbose) { - list_item_verbose(stdout, entry); + if(extract) + { + cmSystemTools::Stdout("x "); + cmSystemTools::Stdout(archive_entry_pathname(entry)); + } + else + { + list_item_verbose(stdout, entry); + } + cmSystemTools::Stdout("\n"); } else if(!extract) { cmSystemTools::Stdout(archive_entry_pathname(entry)); + cmSystemTools::Stdout("\n"); } if(extract) { @@ -1644,15 +1686,7 @@ bool extract_tar(const char* outFileName, bool verbose, } r = archive_write_header(ext, entry); - if (r != ARCHIVE_OK) - { - cmSystemTools::Error("Problem with archive_write_header(): ", - archive_error_string(ext)); - cmSystemTools::Error("Current file: ", - archive_entry_pathname(entry)); - break; - } - else + if (r == ARCHIVE_OK) { copy_data(a, ext); r = archive_write_finish_entry(ext); @@ -1663,10 +1697,22 @@ bool extract_tar(const char* outFileName, bool verbose, break; } } - } - if (verbose || !extract) - { - cmSystemTools::Stdout("\n"); +#ifdef _WIN32 + else if(const char* linktext = archive_entry_symlink(entry)) + { + std::cerr << "cmake -E tar: warning: skipping symbolic link \"" + << archive_entry_pathname(entry) << "\" -> \"" + << linktext << "\"." << std::endl; + } +#endif + else + { + cmSystemTools::Error("Problem with archive_write_header(): ", + archive_error_string(ext)); + cmSystemTools::Error("Current file: ", + archive_entry_pathname(entry)); + break; + } } } archive_read_close(a); @@ -2002,16 +2048,59 @@ unsigned int cmSystemTools::RandomSeed() } //---------------------------------------------------------------------------- -static std::string cmSystemToolsExecutableDirectory; -void cmSystemTools::FindExecutableDirectory(const char* argv0) -{ +static std::string cmSystemToolsCMakeCommand; +static std::string cmSystemToolsCTestCommand; +static std::string cmSystemToolsCPackCommand; +static std::string cmSystemToolsCMakeCursesCommand; +static std::string cmSystemToolsCMakeGUICommand; +static std::string cmSystemToolsCMakeRoot; +void cmSystemTools::FindCMakeResources(const char* argv0) +{ + std::string exe_dir; #if defined(_WIN32) && !defined(__CYGWIN__) (void)argv0; // ignore this on windows char modulepath[_MAX_PATH]; ::GetModuleFileName(NULL, modulepath, sizeof(modulepath)); - cmSystemToolsExecutableDirectory = - cmSystemTools::GetFilenamePath(modulepath); - return; + exe_dir = cmSystemTools::GetFilenamePath(modulepath); +#elif defined(__APPLE__) + (void)argv0; // ignore this on OS X +# define CM_EXE_PATH_LOCAL_SIZE 16384 + char exe_path_local[CM_EXE_PATH_LOCAL_SIZE]; +# if defined(MAC_OS_X_VERSION_10_3) && !defined(MAC_OS_X_VERSION_10_4) + unsigned long exe_path_size = CM_EXE_PATH_LOCAL_SIZE; +# else + uint32_t exe_path_size = CM_EXE_PATH_LOCAL_SIZE; +# endif +# undef CM_EXE_PATH_LOCAL_SIZE + char* exe_path = exe_path_local; + if(_NSGetExecutablePath(exe_path, &exe_path_size) < 0) + { + exe_path = (char*)malloc(exe_path_size); + _NSGetExecutablePath(exe_path, &exe_path_size); + } + exe_dir = + cmSystemTools::GetFilenamePath( + cmSystemTools::GetRealPath(exe_path)); + if(exe_path != exe_path_local) + { + free(exe_path); + } + if(cmSystemTools::GetFilenameName(exe_dir) == "MacOS") + { + // The executable is inside an application bundle. + // Look for ../bin (install tree) and then fall back to + // ../../../bin (build tree). + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + if(cmSystemTools::FileExists((exe_dir+"/bin/cmake").c_str())) + { + exe_dir += "/bin"; + } + else + { + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + } + } #else std::string errorMsg; std::string exe; @@ -2019,7 +2108,7 @@ void cmSystemTools::FindExecutableDirectory(const char* argv0) { // remove symlinks exe = cmSystemTools::GetRealPath(exe.c_str()); - cmSystemToolsExecutableDirectory = + exe_dir = cmSystemTools::GetFilenamePath(exe.c_str()); } else @@ -2027,12 +2116,99 @@ void cmSystemTools::FindExecutableDirectory(const char* argv0) // ??? } #endif + cmSystemToolsCMakeCommand = exe_dir; + cmSystemToolsCMakeCommand += "/cmake"; + cmSystemToolsCMakeCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCTestCommand = exe_dir; + cmSystemToolsCTestCommand += "/ctest"; + cmSystemToolsCTestCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCPackCommand = exe_dir; + cmSystemToolsCPackCommand += "/cpack"; + cmSystemToolsCPackCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCMakeGUICommand = exe_dir; + cmSystemToolsCMakeGUICommand += "/cmake-gui"; + cmSystemToolsCMakeGUICommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand.c_str())) + { + cmSystemToolsCMakeGUICommand = ""; + } + cmSystemToolsCMakeCursesCommand = exe_dir; + cmSystemToolsCMakeCursesCommand += "/ccmake"; + cmSystemToolsCMakeCursesCommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand.c_str())) + { + cmSystemToolsCMakeCursesCommand = ""; + } + +#ifdef CMAKE_BUILD_WITH_CMAKE + // Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>". + std::string dir = cmSystemTools::GetFilenamePath(exe_dir); + cmSystemToolsCMakeRoot = dir + CMAKE_DATA_DIR; + if(!cmSystemTools::FileExists( + (cmSystemToolsCMakeRoot+"/Modules/CMake.cmake").c_str())) + { + // Build tree has "<build>/bin[/<config>]/cmake" and + // "<build>/CMakeFiles/CMakeSourceDir.txt". + std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; + std::ifstream fin(src_dir_txt.c_str()); + std::string src_dir; + if(fin && cmSystemTools::GetLineFromStream(fin, src_dir) && + cmSystemTools::FileIsDirectory(src_dir.c_str())) + { + cmSystemToolsCMakeRoot = src_dir; + } + else + { + dir = cmSystemTools::GetFilenamePath(dir); + src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; + std::ifstream fin2(src_dir_txt.c_str()); + if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) && + cmSystemTools::FileIsDirectory(src_dir.c_str())) + { + cmSystemToolsCMakeRoot = src_dir; + } + } + } +#else + // Bootstrap build knows its source. + cmSystemToolsCMakeRoot = CMAKE_ROOT_DIR; +#endif +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeCommand() +{ + return cmSystemToolsCMakeCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCTestCommand() +{ + return cmSystemToolsCTestCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCPackCommand() +{ + return cmSystemToolsCPackCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeCursesCommand() +{ + return cmSystemToolsCMakeCursesCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeGUICommand() +{ + return cmSystemToolsCMakeGUICommand; } //---------------------------------------------------------------------------- -const char* cmSystemTools::GetExecutableDirectory() +std::string const& cmSystemTools::GetCMakeRoot() { - return cmSystemToolsExecutableDirectory.c_str(); + return cmSystemToolsCMakeRoot; } //---------------------------------------------------------------------------- diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 07235da..4e854c8 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -228,12 +228,19 @@ public: * the command to run, and each argument to the command should * be in comand[1]...command[command.size()] */ + static bool RunSingleCommand(std::vector<std::string> const& command, + std::string* output = 0, + int* retVal = 0, const char* dir = 0, + OutputOption outputflag = OUTPUT_MERGE, + double timeout = 0.0); static bool RunSingleCommand(std::vector<cmStdString> const& command, std::string* output = 0, int* retVal = 0, const char* dir = 0, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); + static std::string PrintSingleCommand(std::vector<std::string> const&); + /** * Parse arguments out of a single string command */ @@ -406,13 +413,16 @@ public: /** Random seed generation. */ static unsigned int RandomSeed(); - /** Find the directory containing the running executable. Save it - in a global location to be queried by GetExecutableDirectory - later. */ - static void FindExecutableDirectory(const char* argv0); + /** Find the directory containing CMake executables. */ + static void FindCMakeResources(const char* argv0); - /** Get the directory containing the currently running executable. */ - static const char* GetExecutableDirectory(); + /** Get the CMake resource paths, after FindCMakeResources. */ + static std::string const& GetCTestCommand(); + static std::string const& GetCPackCommand(); + static std::string const& GetCMakeCommand(); + static std::string const& GetCMakeGUICommand(); + static std::string const& GetCMakeCursesCommand(); + static std::string const& GetCMakeRoot(); #if defined(CMAKE_BUILD_WITH_CMAKE) /** Echo a message in color using KWSys's Terminal cprintf. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ad4ae0c..c9905b6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -22,7 +22,6 @@ #include <cmsys/RegularExpression.hxx> #include <map> #include <set> -#include <queue> #include <stdlib.h> // required for atof #include <assert.h> @@ -71,9 +70,9 @@ struct cmTarget::ImportInfo cmTarget::LinkInterface LinkInterface; }; -struct TargetConfigPair : public std::pair<cmTarget*, std::string> { - TargetConfigPair(cmTarget* tgt, const std::string &config) - : std::pair<cmTarget*, std::string>(tgt, config) {} +struct TargetConfigPair : public std::pair<cmTarget const* , std::string> { + TargetConfigPair(cmTarget const* tgt, const std::string &config) + : std::pair<cmTarget const* , std::string>(tgt, config) {} }; //---------------------------------------------------------------------------- @@ -82,14 +81,13 @@ class cmTargetInternals public: cmTargetInternals() { + this->PolicyWarnedCMP0022 = false; this->SourceFileFlagsConstructed = false; } - cmTargetInternals(cmTargetInternals const& r) + cmTargetInternals(cmTargetInternals const&) { + this->PolicyWarnedCMP0022 = false; this->SourceFileFlagsConstructed = false; - // Only some of these entries are part of the object state. - // Others not copied here are result caches. - this->SourceEntries = r.SourceEntries; } ~cmTargetInternals(); typedef cmTarget::SourceFileFlags SourceFileFlags; @@ -108,6 +106,7 @@ public: typedef std::map<TargetConfigPair, OptionalLinkInterface> LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; + bool PolicyWarnedCMP0022; typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -125,10 +124,6 @@ public: LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct SourceEntry { std::vector<cmSourceFile*> Depends; }; - typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; - SourceEntriesType SourceEntries; - struct TargetPropertyEntry { TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, const std::string &targetName = std::string()) @@ -143,16 +138,16 @@ public: std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries; - std::map<std::string, std::vector<TargetPropertyEntry*> > + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceIncludeDirectoriesEntries; - std::map<std::string, std::vector<TargetPropertyEntry*> > + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileOptionsEntries; - std::map<std::string, std::vector<TargetPropertyEntry*> > + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileDefinitionsEntries; - std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; - std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; - std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone; + mutable std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; + mutable std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; + mutable std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone; }; //---------------------------------------------------------------------------- @@ -274,7 +269,11 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("GNUtoMS", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); + this->SetPropertyDefault("AUTOUIC", 0); + this->SetPropertyDefault("AUTORCC", 0); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); + this->SetPropertyDefault("AUTOUIC_OPTIONS", 0); + this->SetPropertyDefault("AUTORCC_OPTIONS", 0); this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0); this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); this->SetPropertyDefault("WIN32_EXECUTABLE", 0); @@ -432,7 +431,7 @@ std::string cmTarget::GetSupportDirectory() const } //---------------------------------------------------------------------------- -bool cmTarget::IsExecutableWithExports() +bool cmTarget::IsExecutableWithExports() const { return (this->GetType() == cmTarget::EXECUTABLE && this->GetPropertyAsBool("ENABLE_EXPORTS")); @@ -450,7 +449,7 @@ bool cmTarget::IsLinkable() } //---------------------------------------------------------------------------- -bool cmTarget::HasImportLibrary() +bool cmTarget::HasImportLibrary() const { return (this->DLLPlatform && (this->GetType() == cmTarget::SHARED_LIBRARY || @@ -458,7 +457,7 @@ bool cmTarget::HasImportLibrary() } //---------------------------------------------------------------------------- -bool cmTarget::IsFrameworkOnApple() +bool cmTarget::IsFrameworkOnApple() const { return (this->GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("APPLE") && @@ -466,7 +465,7 @@ bool cmTarget::IsFrameworkOnApple() } //---------------------------------------------------------------------------- -bool cmTarget::IsAppBundleOnApple() +bool cmTarget::IsAppBundleOnApple() const { return (this->GetType() == cmTarget::EXECUTABLE && this->Makefile->IsOn("APPLE") && @@ -474,7 +473,7 @@ bool cmTarget::IsAppBundleOnApple() } //---------------------------------------------------------------------------- -bool cmTarget::IsCFBundleOnApple() +bool cmTarget::IsCFBundleOnApple() const { return (this->GetType() == cmTarget::MODULE_LIBRARY && this->Makefile->IsOn("APPLE") && @@ -482,292 +481,13 @@ bool cmTarget::IsCFBundleOnApple() } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() +bool cmTarget::IsBundleOnApple() const { return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || this->IsCFBundleOnApple(); } //---------------------------------------------------------------------------- -class cmTargetTraceDependencies -{ -public: - cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal); - void Trace(); -private: - cmTarget* Target; - cmTargetInternals* Internal; - cmMakefile* Makefile; - cmGlobalGenerator* GlobalGenerator; - typedef cmTargetInternals::SourceEntry SourceEntry; - SourceEntry* CurrentEntry; - std::queue<cmSourceFile*> SourceQueue; - std::set<cmSourceFile*> SourcesQueued; - typedef std::map<cmStdString, cmSourceFile*> NameMapType; - NameMapType NameMap; - - void QueueSource(cmSourceFile* sf); - void FollowName(std::string const& name); - void FollowNames(std::vector<std::string> const& names); - bool IsUtility(std::string const& dep); - void CheckCustomCommand(cmCustomCommand const& cc); - void CheckCustomCommands(const std::vector<cmCustomCommand>& commands); -}; - -//---------------------------------------------------------------------------- -cmTargetTraceDependencies -::cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal): - Target(target), Internal(internal) -{ - // Convenience. - this->Makefile = this->Target->GetMakefile(); - this->GlobalGenerator = - this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); - this->CurrentEntry = 0; - - // Queue all the source files already specified for the target. - std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); - for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - this->QueueSource(*si); - } - - // Queue pre-build, pre-link, and post-build rule dependencies. - this->CheckCustomCommands(this->Target->GetPreBuildCommands()); - this->CheckCustomCommands(this->Target->GetPreLinkCommands()); - this->CheckCustomCommands(this->Target->GetPostBuildCommands()); -} - -//---------------------------------------------------------------------------- -void cmTargetTraceDependencies::Trace() -{ - // Process one dependency at a time until the queue is empty. - while(!this->SourceQueue.empty()) - { - // Get the next source from the queue. - cmSourceFile* sf = this->SourceQueue.front(); - this->SourceQueue.pop(); - this->CurrentEntry = &this->Internal->SourceEntries[sf]; - - // Queue dependencies added explicitly by the user. - if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) - { - std::vector<std::string> objDeps; - cmSystemTools::ExpandListArgument(additionalDeps, objDeps); - this->FollowNames(objDeps); - } - - // Queue the source needed to generate this file, if any. - this->FollowName(sf->GetFullPath()); - - // Queue dependencies added programatically by commands. - this->FollowNames(sf->GetDepends()); - - // Queue custom command dependencies. - if(cmCustomCommand const* cc = sf->GetCustomCommand()) - { - this->CheckCustomCommand(*cc); - } - } - this->CurrentEntry = 0; -} - -//---------------------------------------------------------------------------- -void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) -{ - if(this->SourcesQueued.insert(sf).second) - { - this->SourceQueue.push(sf); - - // Make sure this file is in the target. - this->Target->AddSourceFile(sf); - } -} - -//---------------------------------------------------------------------------- -void cmTargetTraceDependencies::FollowName(std::string const& name) -{ - NameMapType::iterator i = this->NameMap.find(name); - if(i == this->NameMap.end()) - { - // Check if we know how to generate this file. - cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str()); - NameMapType::value_type entry(name, sf); - i = this->NameMap.insert(entry).first; - } - if(cmSourceFile* sf = i->second) - { - // Record the dependency we just followed. - if(this->CurrentEntry) - { - this->CurrentEntry->Depends.push_back(sf); - } - - this->QueueSource(sf); - } -} - -//---------------------------------------------------------------------------- -void -cmTargetTraceDependencies::FollowNames(std::vector<std::string> const& names) -{ - for(std::vector<std::string>::const_iterator i = names.begin(); - i != names.end(); ++i) - { - this->FollowName(*i); - } -} - -//---------------------------------------------------------------------------- -bool cmTargetTraceDependencies::IsUtility(std::string const& dep) -{ - // Dependencies on targets (utilities) are supposed to be named by - // just the target name. However for compatibility we support - // naming the output file generated by the target (assuming there is - // no output-name property which old code would not have set). In - // that case the target name will be the file basename of the - // dependency. - std::string util = cmSystemTools::GetFilenameName(dep); - if(cmSystemTools::GetFilenameLastExtension(util) == ".exe") - { - util = cmSystemTools::GetFilenameWithoutLastExtension(util); - } - - // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str())) - { - // If we find the target and the dep was given as a full path, - // then make sure it was not a full path to something else, and - // the fact that the name matched a target was just a coincidence. - if(cmSystemTools::FileIsFullPath(dep.c_str())) - { - if(t->GetType() >= cmTarget::EXECUTABLE && - t->GetType() <= cmTarget::MODULE_LIBRARY) - { - // This is really only for compatibility so we do not need to - // worry about configuration names and output names. - std::string tLocation = t->GetLocation(0); - tLocation = cmSystemTools::GetFilenamePath(tLocation); - std::string depLocation = cmSystemTools::GetFilenamePath(dep); - depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); - tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); - if(depLocation == tLocation) - { - this->Target->AddUtility(util.c_str()); - return true; - } - } - } - else - { - // The original name of the dependency was not a full path. It - // must name a target, so add the target-level dependency. - this->Target->AddUtility(util.c_str()); - return true; - } - } - - // The dependency does not name a target built in this project. - return false; -} - -//---------------------------------------------------------------------------- -void -cmTargetTraceDependencies -::CheckCustomCommand(cmCustomCommand const& cc) -{ - // Transform command names that reference targets built in this - // project to corresponding target-level dependencies. - cmGeneratorExpression ge(cc.GetBacktrace()); - - // Add target-level dependencies referenced by generator expressions. - std::set<cmTarget*> targets; - - for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin(); - cit != cc.GetCommandLines().end(); ++cit) - { - std::string const& command = *cit->begin(); - // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str())) - { - if(t->GetType() == cmTarget::EXECUTABLE) - { - // The command refers to an executable target built in - // this project. Add the target-level dependency to make - // sure the executable is up to date before this custom - // command possibly runs. - this->Target->AddUtility(command.c_str()); - } - } - - // Check for target references in generator expressions. - for(cmCustomCommandLine::const_iterator cli = cit->begin(); - cli != cit->end(); ++cli) - { - const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge - = ge.Parse(*cli); - cge->Evaluate(this->Makefile, 0, true); - std::set<cmTarget*> geTargets = cge->GetTargets(); - for(std::set<cmTarget*>::const_iterator it = geTargets.begin(); - it != geTargets.end(); ++it) - { - targets.insert(*it); - } - } - } - - for(std::set<cmTarget*>::iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - this->Target->AddUtility((*ti)->GetName()); - } - - // Queue the custom command dependencies. - std::vector<std::string> const& depends = cc.GetDepends(); - for(std::vector<std::string>::const_iterator di = depends.begin(); - di != depends.end(); ++di) - { - std::string const& dep = *di; - if(!this->IsUtility(dep)) - { - // The dependency does not name a target and may be a file we - // know how to generate. Queue it. - this->FollowName(dep); - } - } -} - -//---------------------------------------------------------------------------- -void -cmTargetTraceDependencies -::CheckCustomCommands(const std::vector<cmCustomCommand>& commands) -{ - for(std::vector<cmCustomCommand>::const_iterator cli = commands.begin(); - cli != commands.end(); ++cli) - { - this->CheckCustomCommand(*cli); - } -} - -//---------------------------------------------------------------------------- -void cmTarget::TraceDependencies() -{ - // CMake-generated targets have no dependencies to trace. Normally tracing - // would find nothing anyway, but when building CMake itself the "install" - // target command ends up referencing the "cmake" target but we do not - // really want the dependency because "install" depend on "all" anyway. - if(this->GetType() == cmTarget::GLOBAL_TARGET) - { - return; - } - - // Use a helper object to trace the dependencies. - cmTargetTraceDependencies tracer(this, this->Internal.Get()); - tracer.Trace(); -} - -//---------------------------------------------------------------------------- bool cmTarget::FindSourceFiles() { for(std::vector<cmSourceFile*>::const_iterator @@ -790,7 +510,7 @@ bool cmTarget::FindSourceFiles() } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles() +std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles() const { return this->SourceFiles; } @@ -798,31 +518,14 @@ std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles() //---------------------------------------------------------------------------- void cmTarget::AddSourceFile(cmSourceFile* sf) { - typedef cmTargetInternals::SourceEntriesType SourceEntriesType; - SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf); - if(i == this->Internal->SourceEntries.end()) + if (std::find(this->SourceFiles.begin(), this->SourceFiles.end(), sf) + == this->SourceFiles.end()) { - typedef cmTargetInternals::SourceEntry SourceEntry; - SourceEntriesType::value_type entry(sf, SourceEntry()); - i = this->Internal->SourceEntries.insert(entry).first; this->SourceFiles.push_back(sf); } } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const* -cmTarget::GetSourceDepends(cmSourceFile* sf) -{ - typedef cmTargetInternals::SourceEntriesType SourceEntriesType; - SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf); - if(i != this->Internal->SourceEntries.end()) - { - return &i->second.Depends; - } - return 0; -} - -//---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector<std::string> const& srcs) { for(std::vector<std::string>::const_iterator i = srcs.begin(); @@ -985,16 +688,10 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf, i += this->PrevLinkedLibraries.size(); for( ; i != libs.end(); ++i ) { - // We call this so that the dependencies get written to the cache + // This is equivalent to the target_link_libraries plain signature. this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second ); - - if (this->GetType() == cmTarget::STATIC_LIBRARY) - { - this->AppendProperty("INTERFACE_LINK_LIBRARIES", - ("$<LINK_ONLY:" + - this->GetDebugGeneratorExpressions(i->first.c_str(), i->second) + - ">").c_str()); - } + this->AppendProperty("INTERFACE_LINK_LIBRARIES", + this->GetDebugGeneratorExpressions(i->first.c_str(), i->second).c_str()); } this->PrevLinkedLibraries = libs; } @@ -1010,13 +707,13 @@ void cmTarget::AddLinkDirectory(const char* d) } //---------------------------------------------------------------------------- -const std::vector<std::string>& cmTarget::GetLinkDirectories() +const std::vector<std::string>& cmTarget::GetLinkDirectories() const { return this->LinkDirectories; } //---------------------------------------------------------------------------- -cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) +cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const { // No configuration is always optimized. if(!(config && *config)) @@ -1080,7 +777,8 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname) //---------------------------------------------------------------------------- void cmTarget::GetDirectLinkLibraries(const char *config, - std::vector<std::string> &libs, cmTarget *head) + std::vector<std::string> &libs, + cmTarget const* head) const { const char *prop = this->GetProperty("LINK_LIBRARIES"); if (prop) @@ -1234,12 +932,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt) { - // Never add a self dependency, even if the user asks for it. - if(strcmp( target, lib ) == 0) - { - return; - } - cmTarget *tgt = this->Makefile->FindTargetToUse(lib); { const bool isNonImportedTarget = tgt && !tgt->IsImported(); @@ -1253,7 +945,8 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, } if (cmGeneratorExpression::Find(lib) != std::string::npos - || (tgt && tgt->GetType() == INTERFACE_LIBRARY)) + || (tgt && tgt->GetType() == INTERFACE_LIBRARY) + || (strcmp( target, lib ) == 0)) { return; } @@ -1807,7 +1500,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, } //---------------------------------------------------------------------------- -const char* cmTarget::GetExportName() +const char* cmTarget::GetExportName() const { const char *exportName = this->GetProperty("EXPORT_NAME"); @@ -1900,7 +1593,7 @@ void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry, } //---------------------------------------------------------------------------- -static void processIncludeDirectories(cmTarget *tgt, +static void processIncludeDirectories(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &includes, std::set<std::string> &uniqueIncludes, @@ -2069,7 +1762,8 @@ static void processIncludeDirectories(cmTarget *tgt, } //---------------------------------------------------------------------------- -std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) +std::vector<std::string> +cmTarget::GetIncludeDirectories(const char *config) const { std::vector<std::string> includes; std::set<std::string> uniqueIncludes; @@ -2079,8 +1773,6 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) this->GetName(), "INCLUDE_DIRECTORIES", 0, 0); - this->AppendBuildInterfaceIncludes(); - std::vector<std::string> debugProperties; const char *debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); @@ -2203,7 +1895,7 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) } //---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmTarget *tgt, +static void processCompileOptionsInternal(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, @@ -2262,7 +1954,7 @@ static void processCompileOptionsInternal(cmTarget *tgt, } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget *tgt, +static void processCompileOptions(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, @@ -2275,7 +1967,7 @@ static void processCompileOptions(cmTarget *tgt, //---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, - const char *config) + const char *config) const { std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; @@ -2374,7 +2066,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, } //---------------------------------------------------------------------------- -static void processCompileDefinitions(cmTarget *tgt, +static void processCompileDefinitions(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, @@ -2388,7 +2080,7 @@ static void processCompileDefinitions(cmTarget *tgt, //---------------------------------------------------------------------------- void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, - const char *config) + const char *config) const { std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; @@ -2617,7 +2309,7 @@ void cmTarget::MarkAsImported() } //---------------------------------------------------------------------------- -bool cmTarget::HaveWellDefinedOutputFiles() +bool cmTarget::HaveWellDefinedOutputFiles() const { return this->GetType() == cmTarget::STATIC_LIBRARY || @@ -2627,7 +2319,7 @@ bool cmTarget::HaveWellDefinedOutputFiles() } //---------------------------------------------------------------------------- -cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) +cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const { // There is no output information for imported targets. if(this->IsImported()) @@ -2672,7 +2364,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetDirectory(const char* config, bool implib) +std::string cmTarget::GetDirectory(const char* config, bool implib) const { if (this->IsImported()) { @@ -2701,7 +2393,7 @@ std::string cmTarget::GetPDBDirectory(const char* config) } //---------------------------------------------------------------------------- -const char* cmTarget::GetLocation(const char* config) +const char* cmTarget::GetLocation(const char* config) const { if (this->IsImported()) { @@ -2714,29 +2406,36 @@ const char* cmTarget::GetLocation(const char* config) } //---------------------------------------------------------------------------- -const char* cmTarget::ImportedGetLocation(const char* config) +const char* cmTarget::ImportedGetLocation(const char* config) const { - this->Location = this->ImportedGetFullPath(config, false); - return this->Location.c_str(); + static std::string location; + location = this->ImportedGetFullPath(config, false); + return location.c_str(); } //---------------------------------------------------------------------------- -const char* cmTarget::NormalGetLocation(const char* config) +const char* cmTarget::NormalGetLocation(const char* config) const { + static std::string location; // Handle the configuration-specific case first. if(config) { - this->Location = this->GetFullPath(config, false); - return this->Location.c_str(); + location = this->GetFullPath(config, false); + return location.c_str(); } // Now handle the deprecated build-time configuration location. - this->Location = this->GetDirectory(); + location = this->GetDirectory(); + if(!location.empty()) + { + location += "/"; + } const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); if(cfgid && strcmp(cfgid, ".") != 0) { - this->Location += "/"; - this->Location += cfgid; + location += "/"; + location += cfgid; + location += "/"; } if(this->IsAppBundleOnApple()) @@ -2744,13 +2443,13 @@ const char* cmTarget::NormalGetLocation(const char* config) std::string macdir = this->BuildMacContentDirectory("", config, false); if(!macdir.empty()) { - this->Location += "/"; - this->Location += macdir; + location += "/"; + location += macdir; } } - this->Location += "/"; - this->Location += this->GetFullName(config, false); - return this->Location.c_str(); + location += "/"; + location += this->GetFullName(config, false); + return location.c_str(); } //---------------------------------------------------------------------------- @@ -2810,13 +2509,13 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) } //---------------------------------------------------------------------------- -const char *cmTarget::GetProperty(const char* prop) +const char *cmTarget::GetProperty(const char* prop) const { return this->GetProperty(prop, cmProperty::TARGET); } //---------------------------------------------------------------------------- -bool cmTarget::HandleLocationPropertyPolicy() +bool cmTarget::HandleLocationPropertyPolicy() const { if (this->IsImported()) { @@ -2854,7 +2553,7 @@ bool cmTarget::HandleLocationPropertyPolicy() //---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const char* prop, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope) const { if(!prop) { @@ -2891,7 +2590,8 @@ const char *cmTarget::GetProperty(const char* prop, // cannot take into account the per-configuration name of the // target because the configuration type may not be known at // CMake time. - this->SetProperty("LOCATION", this->GetLocation(0)); + this->Properties.SetProperty("LOCATION", this->GetLocation(0), + cmProperty::TARGET); } // Support "LOCATION_<CONFIG>". @@ -2902,7 +2602,9 @@ const char *cmTarget::GetProperty(const char* prop, return 0; } std::string configName = prop+9; - this->SetProperty(prop, this->GetLocation(configName.c_str())); + this->Properties.SetProperty(prop, + this->GetLocation(configName.c_str()), + cmProperty::TARGET); } else { @@ -2917,7 +2619,9 @@ const char *cmTarget::GetProperty(const char* prop, { return 0; } - this->SetProperty(prop, this->GetLocation(configName.c_str())); + this->Properties.SetProperty(prop, + this->GetLocation(configName.c_str()), + cmProperty::TARGET); } } } @@ -3022,7 +2726,8 @@ const char *cmTarget::GetProperty(const char* prop, // Append this list entry. ss << sname; } - this->SetProperty("SOURCES", ss.str().c_str()); + this->Properties.SetProperty("SOURCES", ss.str().c_str(), + cmProperty::TARGET); } // the type property returns what type the target is @@ -3041,7 +2746,7 @@ const char *cmTarget::GetProperty(const char* prop, } //---------------------------------------------------------------------------- -bool cmTarget::GetPropertyAsBool(const char* prop) +bool cmTarget::GetPropertyAsBool(const char* prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } @@ -3050,13 +2755,13 @@ bool cmTarget::GetPropertyAsBool(const char* prop) class cmTargetCollectLinkLanguages { public: - cmTargetCollectLinkLanguages(cmTarget* target, const char* config, + cmTargetCollectLinkLanguages(cmTarget const* target, const char* config, std::set<cmStdString>& languages, - cmTarget* head): + cmTarget const* head): Config(config), Languages(languages), HeadTarget(head) { this->Visited.insert(target); } - void Visit(cmTarget* target) + void Visit(cmTarget const* target) { if(!target || !this->Visited.insert(target).second) { @@ -3083,14 +2788,15 @@ public: private: const char* Config; std::set<cmStdString>& Languages; - cmTarget* HeadTarget; - std::set<cmTarget*> Visited; + cmTarget const* HeadTarget; + std::set<cmTarget const*> Visited; }; //---------------------------------------------------------------------------- -const char* cmTarget::GetLinkerLanguage(const char* config, cmTarget *head) +const char* cmTarget::GetLinkerLanguage(const char* config, + cmTarget const* head) const { - cmTarget *headTarget = head ? head : this; + cmTarget const* headTarget = head ? head : this; const char* lang = this->GetLinkClosure(config, headTarget) ->LinkerLanguage.c_str(); return *lang? lang : 0; @@ -3098,7 +2804,7 @@ const char* cmTarget::GetLinkerLanguage(const char* config, cmTarget *head) //---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config, - cmTarget *head) + cmTarget const* head) const { TargetConfigPair key(head, cmSystemTools::UpperCase(config ? config : "")); cmTargetInternals::LinkClosureMapType::iterator @@ -3117,12 +2823,12 @@ cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config, class cmTargetSelectLinker { int Preference; - cmTarget* Target; + cmTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GG; std::set<cmStdString> Preferred; public: - cmTargetSelectLinker(cmTarget* target): Preference(0), Target(target) + cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) { this->Makefile = this->Target->GetMakefile(); this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); @@ -3168,7 +2874,7 @@ public: //---------------------------------------------------------------------------- void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, - cmTarget *head) + cmTarget const* head) const { // Get languages built in this target. std::set<cmStdString> languages; @@ -3231,7 +2937,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, } //---------------------------------------------------------------------------- -const char* cmTarget::GetSuffixVariableInternal(bool implib) +const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) { @@ -3257,7 +2963,7 @@ const char* cmTarget::GetSuffixVariableInternal(bool implib) //---------------------------------------------------------------------------- -const char* cmTarget::GetPrefixVariableInternal(bool implib) +const char* cmTarget::GetPrefixVariableInternal(bool implib) const { switch(this->GetType()) { @@ -3280,7 +2986,7 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const char* config) +std::string cmTarget::GetPDBName(const char* config) const { std::string prefix; std::string base; @@ -3312,7 +3018,7 @@ std::string cmTarget::GetPDBName(const char* config) } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const char* config) +bool cmTarget::HasSOName(const char* config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. @@ -3324,7 +3030,7 @@ bool cmTarget::HasSOName(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const char* config) +std::string cmTarget::GetSOName(const char* config) const { if(this->IsImported()) { @@ -3366,7 +3072,7 @@ std::string cmTarget::GetSOName(const char* config) } //---------------------------------------------------------------------------- -bool cmTarget::HasMacOSXRpath(const char* config) +bool cmTarget::HasMacOSXRpath(const char* config) const { bool install_name_is_rpath = false; bool macosx_rpath = this->GetPropertyAsBool("MACOSX_RPATH"); @@ -3452,7 +3158,7 @@ bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetRealName(const char* config) +std::string cmTarget::NormalGetRealName(const char* config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3490,7 +3196,7 @@ std::string cmTarget::NormalGetRealName(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const char* config, bool implib) +std::string cmTarget::GetFullName(const char* config, bool implib) const { if(this->IsImported()) { @@ -3503,7 +3209,8 @@ std::string cmTarget::GetFullName(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullNameImported(const char* config, bool implib) +std::string +cmTarget::GetFullNameImported(const char* config, bool implib) const { return cmSystemTools::GetFilenameName( this->ImportedGetFullPath(config, implib)); @@ -3512,14 +3219,14 @@ std::string cmTarget::GetFullNameImported(const char* config, bool implib) //---------------------------------------------------------------------------- void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, const char* config, - bool implib) + bool implib) const { this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- std::string cmTarget::GetFullPath(const char* config, bool implib, - bool realname) + bool realname) const { if(this->IsImported()) { @@ -3533,7 +3240,7 @@ std::string cmTarget::GetFullPath(const char* config, bool implib, //---------------------------------------------------------------------------- std::string cmTarget::NormalGetFullPath(const char* config, bool implib, - bool realname) + bool realname) const { std::string fpath = this->GetDirectory(config, implib); fpath += "/"; @@ -3560,7 +3267,8 @@ std::string cmTarget::NormalGetFullPath(const char* config, bool implib, } //---------------------------------------------------------------------------- -std::string cmTarget::ImportedGetFullPath(const char* config, bool implib) +std::string +cmTarget::ImportedGetFullPath(const char* config, bool implib) const { std::string result; if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this)) @@ -3576,7 +3284,8 @@ std::string cmTarget::ImportedGetFullPath(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullNameInternal(const char* config, bool implib) +std::string +cmTarget::GetFullNameInternal(const char* config, bool implib) const { std::string prefix; std::string base; @@ -3590,7 +3299,7 @@ void cmTarget::GetFullNameInternal(const char* config, bool implib, std::string& outPrefix, std::string& outBase, - std::string& outSuffix) + std::string& outSuffix) const { // Use just the target name for non-main target types. if(this->GetType() != cmTarget::STATIC_LIBRARY && @@ -3728,7 +3437,7 @@ void cmTarget::GetLibraryNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) + const char* config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3814,7 +3523,7 @@ void cmTarget::ComputeVersionedName(std::string& vName, std::string const& base, std::string const& suffix, std::string const& name, - const char* version) + const char* version) const { vName = this->IsApple? (prefix+base) : name; if(version) @@ -3830,7 +3539,7 @@ void cmTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) + const char* config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3908,76 +3617,6 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, } //---------------------------------------------------------------------------- -void cmTarget::GenerateTargetManifest(const char* config) -{ - cmMakefile* mf = this->Makefile; - cmLocalGenerator* lg = mf->GetLocalGenerator(); - cmGlobalGenerator* gg = lg->GetGlobalGenerator(); - - // Get the names. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - if(this->GetType() == cmTarget::EXECUTABLE) - { - this->GetExecutableNames(name, realName, impName, pdbName, config); - } - else if(this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - } - else - { - return; - } - - // Get the directory. - std::string dir = this->GetDirectory(config, false); - - // Add each name. - std::string f; - if(!name.empty()) - { - f = dir; - f += "/"; - f += name; - gg->AddToManifest(config? config:"", f); - } - if(!soName.empty()) - { - f = dir; - f += "/"; - f += soName; - gg->AddToManifest(config? config:"", f); - } - if(!realName.empty()) - { - f = dir; - f += "/"; - f += realName; - gg->AddToManifest(config? config:"", f); - } - if(!pdbName.empty()) - { - f = this->GetPDBDirectory(config); - f += "/"; - f += pdbName; - gg->AddToManifest(config? config:"", f); - } - if(!impName.empty()) - { - f = this->GetDirectory(config, true); - f += "/"; - f += impName; - gg->AddToManifest(config? config:"", f); - } -} - -//---------------------------------------------------------------------------- void cmTarget::SetPropertyDefault(const char* property, const char* default_value) { @@ -3996,7 +3635,7 @@ void cmTarget::SetPropertyDefault(const char* property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const char *config) +bool cmTarget::HaveBuildTreeRPATH(const char *config) const { if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { @@ -4008,7 +3647,7 @@ bool cmTarget::HaveBuildTreeRPATH(const char *config) } //---------------------------------------------------------------------------- -bool cmTarget::HaveInstallTreeRPATH() +bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); return (install_rpath && *install_rpath) && @@ -4016,7 +3655,7 @@ bool cmTarget::HaveInstallTreeRPATH() } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const char* config) +bool cmTarget::NeedRelinkBeforeInstall(const char* config) const { // Only executables and shared libraries can have an rpath and may // need relinking. @@ -4079,7 +3718,7 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) +std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const { // If building directly for installation then the build tree install_name // is the same as the install tree. @@ -4112,7 +3751,7 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() +std::string cmTarget::GetInstallNameDirForInstallTree() const { if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { @@ -4141,7 +3780,7 @@ std::string cmTarget::GetInstallNameDirForInstallTree() } //---------------------------------------------------------------------------- -const char* cmTarget::GetOutputTargetType(bool implib) +const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) { @@ -4198,7 +3837,7 @@ const char* cmTarget::GetOutputTargetType(bool implib) //---------------------------------------------------------------------------- bool cmTarget::ComputeOutputDir(const char* config, - bool implib, std::string& out) + bool implib, std::string& out) const { bool usesDefaultOutputDir = false; @@ -4278,7 +3917,7 @@ bool cmTarget::ComputeOutputDir(const char* config, } //---------------------------------------------------------------------------- -bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) +bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const { // Look for a target property defining the target output directory // based on the target type. @@ -4344,7 +3983,7 @@ bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const char* config, bool implib) +std::string cmTarget::GetOutputName(const char* config, bool implib) const { std::vector<std::string> props; std::string type = this->GetOutputTargetType(implib); @@ -4381,7 +4020,7 @@ std::string cmTarget::GetOutputName(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkVersion() +std::string cmTarget::GetFrameworkVersion() const { if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) { @@ -4424,7 +4063,7 @@ const char* cmTarget::GetExportMacro() } //---------------------------------------------------------------------------- -bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) +bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const { return this->LinkImplicitNullProperties.find(p) != this->LinkImplicitNullProperties.end(); @@ -4432,52 +4071,135 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) //---------------------------------------------------------------------------- template<typename PropertyType> -PropertyType getTypedProperty(cmTarget *tgt, const char *prop, +PropertyType getTypedProperty(cmTarget const* tgt, const char *prop, PropertyType *); //---------------------------------------------------------------------------- template<> -bool getTypedProperty<bool>(cmTarget *tgt, const char *prop, bool *) +bool getTypedProperty<bool>(cmTarget const* tgt, const char *prop, bool *) { return tgt->GetPropertyAsBool(prop); } //---------------------------------------------------------------------------- template<> -const char *getTypedProperty<const char *>(cmTarget *tgt, const char *prop, - const char **) +const char *getTypedProperty<const char *>(cmTarget const* tgt, + const char *prop, + const char **) { return tgt->GetProperty(prop); } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + //---------------------------------------------------------------------------- template<typename PropertyType> -bool consistentProperty(PropertyType lhs, PropertyType rhs); +PropertyType consistentProperty(PropertyType lhs, PropertyType rhs, + CompatibleType t); //---------------------------------------------------------------------------- template<> -bool consistentProperty(bool lhs, bool rhs) +bool consistentProperty(bool lhs, bool rhs, CompatibleType) { return lhs == rhs; } //---------------------------------------------------------------------------- +const char * consistentStringProperty(const char *lhs, const char *rhs) +{ + return strcmp(lhs, rhs) == 0 ? lhs : 0; +} + +#if defined(_MSC_VER) && _MSC_VER <= 1200 +template<typename T> const T& +cmMaximum(const T& l, const T& r) {return l > r ? l : r;} +template<typename T> const T& +cmMinimum(const T& l, const T& r) {return l < r ? l : r;} +#else +#define cmMinimum std::min +#define cmMaximum std::max +#endif + +//---------------------------------------------------------------------------- +const char * consistentNumberProperty(const char *lhs, const char *rhs, + CompatibleType t) +{ + double lnum; + double rnum; + if(sscanf(lhs, "%lg", &lnum) != 1 || + sscanf(rhs, "%lg", &rnum) != 1) + { + return 0; + } + + if (t == NumberMaxType) + { + return cmMaximum(lnum, rnum) == lnum ? lhs : rhs; + } + else + { + return cmMinimum(lnum, rnum) == lnum ? lhs : rhs; + } +} + +//---------------------------------------------------------------------------- template<> -bool consistentProperty(const char *lhs, const char *rhs) +const char* consistentProperty(const char *lhs, const char *rhs, + CompatibleType t) { if (!lhs && !rhs) - return true; - if (!lhs || !rhs) - return false; - return strcmp(lhs, rhs) == 0; + { + return ""; + } + if (!lhs) + { + return rhs ? rhs : ""; + } + if (!rhs) + { + return lhs ? lhs : ""; + } + switch(t) + { + case BoolType: + assert(!"consistentProperty for strings called with BoolType"); + return 0; + case StringType: + return consistentStringProperty(lhs, rhs); + case NumberMinType: + case NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(!"Unreachable!"); + return 0; +} + +template<typename PropertyType> +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue<bool>(bool) +{ + return false; +} +template<> +const char* impliedValue<const char*>(const char*) +{ + return ""; } //---------------------------------------------------------------------------- template<typename PropertyType> -PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const char *config, const char *defaultValue, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(), @@ -4523,7 +4245,9 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, { if (ifaceIsSet) { - if (!consistentProperty(propContent, ifacePropContent)) + PropertyType consistent = consistentProperty(propContent, + ifacePropContent, t); + if (!consistent) { cmOStringStream e; e << "Property " << p << " on target \"" @@ -4536,6 +4260,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, else { // Agree + propContent = consistent; continue; } } @@ -4547,9 +4272,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, } else if (impliedByUse) { + propContent = impliedValue<PropertyType>(propContent); if (ifaceIsSet) { - if (!consistentProperty(propContent, ifacePropContent)) + PropertyType consistent = consistentProperty(propContent, + ifacePropContent, t); + if (!consistent) { cmOStringStream e; e << "Property " << p << " on target \"" @@ -4563,6 +4291,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, else { // Agree + propContent = consistent; continue; } } @@ -4578,7 +4307,9 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, { if (propInitialized) { - if (!consistentProperty(propContent, ifacePropContent)) + PropertyType consistent = consistentProperty(propContent, + ifacePropContent, t); + if (!consistent) { cmOStringStream e; e << "The INTERFACE_" << p << " property of \"" @@ -4591,6 +4322,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, else { // Agree. + propContent = consistent; continue; } } @@ -4612,25 +4344,50 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, //---------------------------------------------------------------------------- bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) + const char *config) const { return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE", - 0); + BoolType, 0); } //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, - const char *config) + const char *config) const { return checkInterfacePropertyCompatibility<const char *>(this, p, config, - "empty", 0); + "empty", + StringType, 0); } //---------------------------------------------------------------------------- -bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, +const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const char *config) const +{ + return checkInterfacePropertyCompatibility<const char *>(this, + p, + config, + "empty", + NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const char *config) const +{ + return checkInterfacePropertyCompatibility<const char *>(this, + p, + config, + "empty", + NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- +bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, const char *interfaceProperty, const char *config) { @@ -4674,7 +4431,7 @@ bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) + const char *config) const { if (this->TargetTypeValue == OBJECT_LIBRARY) { @@ -4687,7 +4444,7 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) + const char *config) const { if (this->TargetTypeValue == OBJECT_LIBRARY) { @@ -4698,6 +4455,30 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, } //---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const char *config) const +{ + if (this->TargetTypeValue == OBJECT_LIBRARY) + { + return false; + } + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_NUMBER_MIN", + config); +} + +//---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const char *config) const +{ + if (this->TargetTypeValue == OBJECT_LIBRARY) + { + return false; + } + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_NUMBER_MAX", + config); +} + +//---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set<cmStdString>& languages) const { for(std::vector<cmSourceFile*>::const_iterator @@ -4711,7 +4492,7 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const char* config) +bool cmTarget::IsChrpathUsed(const char* config) const { // Only certain target types have an rpath. if(!(this->GetType() == cmTarget::SHARED_LIBRARY || @@ -4778,7 +4559,7 @@ bool cmTarget::IsChrpathUsed(const char* config) //---------------------------------------------------------------------------- cmTarget::ImportInfo const* -cmTarget::GetImportInfo(const char* config, cmTarget *headTarget) +cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const { // There is no imported information for non-imported targets. if(!this->IsImported()) @@ -4828,7 +4609,7 @@ cmTarget::GetImportInfo(const char* config, cmTarget *headTarget) bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, - std::string& suffix) + std::string& suffix) const { // Track the configuration-specific property suffix. suffix = "_"; @@ -4950,7 +4731,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, //---------------------------------------------------------------------------- void cmTarget::ComputeImportInfo(std::string const& desired_config, ImportInfo& info, - cmTarget *headTarget) + cmTarget const* headTarget) const { // This method finds information about an imported target from its // properties. The "IMPORTED_" namespace is reserved for properties @@ -5136,7 +4917,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, //---------------------------------------------------------------------------- cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, - cmTarget *head) + cmTarget const* head) const { // Imported targets have their own link interface. if(this->IsImported()) @@ -5178,8 +4959,8 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, //---------------------------------------------------------------------------- void cmTarget::GetTransitivePropertyLinkLibraries( const char* config, - cmTarget *headTarget, - std::vector<std::string> &libs) + cmTarget const* headTarget, + std::vector<std::string> &libs) const { cmTarget::LinkInterface const* iface = this->GetLinkInterface(config, headTarget); @@ -5219,7 +5000,7 @@ void cmTarget::GetTransitivePropertyLinkLibraries( //---------------------------------------------------------------------------- bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget *headTarget) + cmTarget const* headTarget) const { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -5235,12 +5016,20 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // An explicit list of interface libraries may be set for shared // libraries and executables that export symbols. const char* explicitLibraries = 0; - const char* newExplicitLibraries = - this->GetProperty("INTERFACE_LINK_LIBRARIES"); std::string linkIfaceProp; - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->IsExecutableWithExports()) + if(this->PolicyStatusCMP0022 != cmPolicies::OLD && + this->PolicyStatusCMP0022 != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + } + else if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->IsExecutableWithExports()) { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; @@ -5252,135 +5041,40 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); } - if (newExplicitLibraries - && (!explicitLibraries || - (explicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0))) - { - switch(this->GetPolicyStatusCMP0022()) - { - case cmPolicies::WARN: - { - cmOStringStream w; - w << (this->Makefile->GetPolicies() - ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" - << "Target \"" << this->GetName() << "\" has a " - "INTERFACE_LINK_LIBRARIES property which differs from its " - << linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n " - << newExplicitLibraries - << "\n" - << linkIfaceProp << ":\n " - << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - } - // Fall through - case cmPolicies::OLD: - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - explicitLibraries = newExplicitLibraries; - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - break; - } - } } - else if(this->GetType() == cmTarget::STATIC_LIBRARY) + + if(explicitLibraries && this->PolicyStatusCMP0022 == cmPolicies::WARN && + !this->Internal->PolicyWarnedCMP0022) { - if (newExplicitLibraries) + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + this->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), - "INTERFACE_LINK_LIBRARIES", 0, 0); - std::vector<std::string> ifaceLibs; - cmSystemTools::ExpandListArgument( - ge.Parse(newExplicitLibraries)->Evaluate( - this->Makefile, - config, - false, - headTarget, - this, &dagChecker), ifaceLibs); - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - if (ifaceLibs != impl->Libraries) - { - switch(this->GetPolicyStatusCMP0022()) - { - case cmPolicies::WARN: - { - std::string oldLibraries; - std::string newLibraries; - const char *sep = ""; - for(std::vector<std::string>::const_iterator it - = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) - { - oldLibraries += sep; - oldLibraries += *it; - sep = ";"; - } - sep = ""; - for(std::vector<std::string>::const_iterator it - = ifaceLibs.begin(); it != ifaceLibs.end(); ++it) - { - newLibraries += sep; - newLibraries += *it; - sep = ";"; - } - - cmOStringStream w; - w << (this->Makefile->GetPolicies() - ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" - << "Static library target \"" << this->GetName() << "\" has a " - "INTERFACE_LINK_LIBRARIES property. This should be preferred " - "as the source of the link interface for this library. " - "Ignoring the property and using the link implementation " - "as the link interface instead." - "\n" - "INTERFACE_LINK_LIBRARIES:\n " - << newLibraries - << "\n" - << "Link implementation:\n " - << oldLibraries << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - } - // Fall through - case cmPolicies::OLD: - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - explicitLibraries = newExplicitLibraries; - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - break; - } - } - else - { - iface.Libraries = impl->Libraries; - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; - } - } + cmOStringStream w; + w << + (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Internal->PolicyWarnedCMP0022 = true; } } - else if (this->GetType() == cmTarget::INTERFACE_LIBRARY) - { - explicitLibraries = newExplicitLibraries; - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - } // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. - // Note that CMake versions 2.2 and below allowed linking to modules. - bool canLinkModules = this->Makefile->NeedBackwardsCompatibility(2,2); if(!explicitLibraries && (this->GetType() == cmTarget::EXECUTABLE || - (this->GetType() == cmTarget::MODULE_LIBRARY && !canLinkModules))) + (this->GetType() == cmTarget::MODULE_LIBRARY))) { return false; } @@ -5442,11 +5136,12 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } } } - else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // The implementation shouldn't be the interface if CMP0022 is NEW. That - // way, the LINK_LIBRARIES property can be set directly without having to - // empty the INTERFACE_LINK_LIBRARIES + else if (this->PolicyStatusCMP0022 == cmPolicies::WARN + || this->PolicyStatusCMP0022 == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. { // The link implementation is the default link interface. LinkImplementation const* impl = this->GetLinkImplementation(config, @@ -5459,6 +5154,70 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // Targets using this archive need its language runtime libraries. iface.Languages = impl->Languages; } + + if(this->PolicyStatusCMP0022 == cmPolicies::WARN && + !this->Internal->PolicyWarnedCMP0022) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), + "INTERFACE_LINK_LIBRARIES", 0, 0); + std::vector<std::string> ifaceLibs; + const char* newExplicitLibraries = + this->GetProperty("INTERFACE_LINK_LIBRARIES"); + cmSystemTools::ExpandListArgument( + ge.Parse(newExplicitLibraries)->Evaluate(this->Makefile, + config, + false, + headTarget, + this, &dagChecker), + ifaceLibs); + if (ifaceLibs != impl->Libraries) + { + std::string oldLibraries; + std::string newLibraries; + const char *sep = ""; + for(std::vector<std::string>::const_iterator it + = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) + { + oldLibraries += sep; + oldLibraries += *it; + sep = ";"; + } + sep = ""; + for(std::vector<std::string>::const_iterator it + = ifaceLibs.begin(); it != ifaceLibs.end(); ++it) + { + newLibraries += sep; + newLibraries += *it; + sep = ";"; + } + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + cmOStringStream w; + w << + (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Internal->PolicyWarnedCMP0022 = true; + } + } } if(this->GetType() == cmTarget::STATIC_LIBRARY) @@ -5483,7 +5242,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, //---------------------------------------------------------------------------- cmTarget::LinkImplementation const* -cmTarget::GetLinkImplementation(const char* config, cmTarget *head) +cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const { // There is no link implementation for imported targets. if(this->IsImported()) @@ -5513,7 +5272,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget *head) //---------------------------------------------------------------------------- void cmTarget::ComputeLinkImplementation(const char* config, LinkImplementation& impl, - cmTarget *head) + cmTarget const* head) const { // Compute which library configuration to link. cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); @@ -5528,6 +5287,41 @@ void cmTarget::ComputeLinkImplementation(const char* config, std::string item = this->CheckCMP0004(*li); if(item == this->GetName() || item.empty()) { + if(item == this->GetName()) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0038)) + { + case cmPolicies::WARN: + { + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0038)) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage(messageType, + e.str(), + this->GetBacktrace()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } continue; } cmTarget *tgt = this->Makefile->FindTargetToUse(li->c_str()); @@ -5570,6 +5364,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, } } } + // The entry is meant for this configuration. impl.Libraries.push_back(item); } @@ -5595,7 +5390,8 @@ void cmTarget::ComputeLinkImplementation(const char* config, // Get languages used in our source files. this->GetLanguages(languages); // Get languages used in object library sources. - for(std::vector<std::string>::iterator i = this->ObjectLibraries.begin(); + for(std::vector<std::string>::const_iterator + i = this->ObjectLibraries.begin(); i != this->ObjectLibraries.end(); ++i) { if(cmTarget* objLib = this->Makefile->FindTargetToUse(i->c_str())) @@ -5615,7 +5411,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, } //---------------------------------------------------------------------------- -std::string cmTarget::CheckCMP0004(std::string const& item) +std::string cmTarget::CheckCMP0004(std::string const& item) const { // Strip whitespace off the library names because we used to do this // in case variables were expanded at generate time. We no longer @@ -5674,34 +5470,51 @@ std::string cmTarget::CheckCMP0004(std::string const& item) } template<typename PropertyType> -PropertyType getLinkInterfaceDependentProperty(cmTarget *tgt, +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, const std::string prop, const char *config, + CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget *tgt, - const std::string prop, - const char *config, bool *) +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string prop, + const char *config, + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget *tgt, - const std::string prop, - const char *config, - const char **) +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string prop, + const char *config, + CompatibleType t, + const char **) { - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + switch(t) + { + case BoolType: + assert(!"String compatibility check function called for boolean"); + return 0; + case StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(!"Unreachable!"); + return 0; } //---------------------------------------------------------------------------- template<typename PropertyType> -void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, +void checkPropertyConsistency(cmTarget const* depender, cmTarget *dependee, const char *propName, std::set<cmStdString> &emitted, const char *config, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -5734,7 +5547,7 @@ void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, if(emitted.insert(*pi).second) { getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config, - 0); + t, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -5743,14 +5556,60 @@ void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, } } +static cmStdString intersect(const std::set<cmStdString> &s1, + const std::set<cmStdString> &s2) +{ + std::set<cmStdString> intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} +static cmStdString intersect(const std::set<cmStdString> &s1, + const std::set<cmStdString> &s2, + const std::set<cmStdString> &s3) +{ + cmStdString result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} +static cmStdString intersect(const std::set<cmStdString> &s1, + const std::set<cmStdString> &s2, + const std::set<cmStdString> &s3, + const std::set<cmStdString> &s4) +{ + cmStdString result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + //---------------------------------------------------------------------------- void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config) + const char* config) const { const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); std::set<cmStdString> emittedBools; std::set<cmStdString> emittedStrings; + std::set<cmStdString> emittedMinNumbers; + std::set<cmStdString> emittedMaxNumbers; for(cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin(); @@ -5763,43 +5622,92 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, checkPropertyConsistency<bool>(this, li->Target, "COMPATIBLE_INTERFACE_BOOL", - emittedBools, config, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char *>(this, li->Target, "COMPATIBLE_INTERFACE_STRING", - emittedStrings, config, 0); + emittedStrings, config, + StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency<const char *>(this, li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MIN", + emittedMinNumbers, config, + NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency<const char *>(this, li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MAX", + emittedMaxNumbers, config, + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } } - for(std::set<cmStdString>::const_iterator li = emittedBools.begin(); - li != emittedBools.end(); ++li) + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) { - const std::set<cmStdString>::const_iterator si = emittedStrings.find(*li); - if (si != emittedStrings.end()) + std::set<std::string> props; + std::set<cmStdString>::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) { - cmOStringStream e; - e << "Property \"" << *li << "\" appears in both the " - "COMPATIBLE_INTERFACE_BOOL and the COMPATIBLE_INTERFACE_STRING " - "property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation or a string interpretation, but not both."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - break; + props.insert("COMPATIBLE_INTERFACE_BOOL"); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.insert("COMPATIBLE_INTERFACE_STRING"); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.insert("COMPATIBLE_INTERFACE_NUMBER_MIN"); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.insert("COMPATIBLE_INTERFACE_NUMBER_MAX"); + } + + std::string propsString = *props.begin(); + props.erase(props.begin()); + while (props.size() > 1) + { + propsString += ", " + *props.begin(); + props.erase(props.begin()); } + if (props.size() == 1) + { + propsString += " and the " + *props.begin(); + } + cmOStringStream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation or a string interpretation, but not both."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } } //---------------------------------------------------------------------------- cmComputeLinkInformation* -cmTarget::GetLinkInformation(const char* config, cmTarget *head) +cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const { - cmTarget *headTarget = head ? head : this; + cmTarget const* headTarget = head ? head : this; // Lookup any existing information for this configuration. TargetConfigPair key(headTarget, cmSystemTools::UpperCase(config?config:"")); @@ -5830,7 +5738,7 @@ cmTarget::GetLinkInformation(const char* config, cmTarget *head) //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const char* config, - bool rootDir) + bool rootDir) const { std::string fpath; fpath += this->GetOutputName(config, false); @@ -5845,7 +5753,7 @@ std::string cmTarget::GetFrameworkDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::GetCFBundleDirectory(const char* config, - bool contentOnly) + bool contentOnly) const { std::string fpath; fpath += this->GetOutputName(config, false); @@ -5864,7 +5772,7 @@ std::string cmTarget::GetCFBundleDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::GetAppBundleDirectory(const char* config, - bool contentOnly) + bool contentOnly) const { std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; @@ -5876,7 +5784,7 @@ std::string cmTarget::GetAppBundleDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::BuildMacContentDirectory(const std::string& base, const char* config, - bool contentOnly) + bool contentOnly) const { std::string fpath = base; if(this->IsAppBundleOnApple()) @@ -5896,7 +5804,7 @@ std::string cmTarget::BuildMacContentDirectory(const std::string& base, //---------------------------------------------------------------------------- std::string cmTarget::GetMacContentDirectory(const char* config, - bool implib) + bool implib) const { // Start with the output directory for the target. std::string fpath = this->GetDirectory(config, implib); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e8f4e08..b516a0a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -34,11 +34,14 @@ class cmGlobalGenerator; class cmComputeLinkInformation; class cmListFileBacktrace; class cmTarget; +class cmGeneratorTarget; +class cmTargetTraceDependencies; struct cmTargetLinkInformationMap: - public std::map<std::pair<cmTarget*, std::string>, cmComputeLinkInformation*> + public std::map<std::pair<cmTarget const* , std::string>, + cmComputeLinkInformation*> { - typedef std::map<std::pair<cmTarget*, std::string>, + typedef std::map<std::pair<cmTarget const* , std::string>, cmComputeLinkInformation*> derived; cmTargetLinkInformationMap() {} cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); @@ -94,7 +97,7 @@ public: ///! Set/Get the name of the target const char* GetName() const {return this->Name.c_str();} - const char* GetExportName(); + const char* GetExportName() const; ///! Set the cmMakefile that owns this target void SetMakefile(cmMakefile *mf); @@ -121,16 +124,13 @@ public: /** * Get the list of the source files used by this target */ - std::vector<cmSourceFile*> const& GetSourceFiles(); + std::vector<cmSourceFile*> const& GetSourceFiles() const; void AddSourceFile(cmSourceFile* sf); std::vector<std::string> const& GetObjectLibraries() const { return this->ObjectLibraries; } - /** Get sources that must be built before the given source. */ - std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf); - /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. @@ -176,13 +176,13 @@ public: {return this->OriginalLinkLibraries;} void GetDirectLinkLibraries(const char *config, std::vector<std::string> &, - cmTarget *head); + cmTarget const* head) const; void GetInterfaceLinkLibraries(const char *config, std::vector<std::string> &, cmTarget *head); /** Compute the link type to use for the given configuration. */ - LinkLibraryType ComputeLinkType(const char* config); + LinkLibraryType ComputeLinkType(const char* config) const; /** * Clear the dependency information recorded for this target, if any. @@ -204,7 +204,7 @@ public: void MergeLinkLibraries( cmMakefile& mf, const char* selfname, const LinkLibraryVectorType& libs ); - const std::vector<std::string>& GetLinkDirectories(); + const std::vector<std::string>& GetLinkDirectories() const; void AddLinkDirectory(const char* d); @@ -226,7 +226,7 @@ public: /** * Get/Set whether there is an install rule for this target. */ - bool GetHaveInstallRule() { return this->HaveInstallRule; } + bool GetHaveInstallRule() const { return this->HaveInstallRule; } void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; } /** Add a utility on which this project depends. A utility is an executable @@ -243,9 +243,9 @@ public: ///! Set/Get a property of this target file void SetProperty(const char *prop, const char *value); void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop); - const char *GetProperty(const char *prop, cmProperty::ScopeType scope); - bool GetPropertyAsBool(const char *prop); + const char *GetProperty(const char *prop) const; + const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; + bool GetPropertyAsBool(const char *prop) const; void CheckProperty(const char* prop, cmMakefile* context); const char* GetFeature(const char* feature, const char* config); @@ -281,10 +281,10 @@ public: /** Get the link interface for the given configuration. Returns 0 if the target cannot be linked. */ LinkInterface const* GetLinkInterface(const char* config, - cmTarget *headTarget); + cmTarget const* headTarget) const; void GetTransitivePropertyLinkLibraries(const char* config, - cmTarget *headTarget, - std::vector<std::string> &libs); + cmTarget const* headTarget, + std::vector<std::string> &libs) const; /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ @@ -301,7 +301,7 @@ public: std::vector<std::string> WrongConfigLibraries; }; LinkImplementation const* GetLinkImplementation(const char* config, - cmTarget *head); + cmTarget const* head) const; /** Link information from the transitive closure of the link implementation and the interfaces of its dependencies. */ @@ -313,17 +313,18 @@ public: // Languages whose runtime libraries must be linked. std::vector<std::string> Languages; }; - LinkClosure const* GetLinkClosure(const char* config, cmTarget *head); + LinkClosure const* GetLinkClosure(const char* config, + cmTarget const* head) const; /** Strip off leading and trailing whitespace from an item named in the link dependencies of this target. */ - std::string CheckCMP0004(std::string const& item); + std::string CheckCMP0004(std::string const& item) const; /** Get the directory in which this target will be built. If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical output directory is given. */ - std::string GetDirectory(const char* config = 0, bool implib = false); + std::string GetDirectory(const char* config = 0, bool implib = false) const; /** Get the directory in which this targets .pdb files will be placed. If the configuration name is given then the generator will add its @@ -334,7 +335,7 @@ public: /** Get the location of the target in the build tree for the given configuration. This location is suitable for use as the LOCATION target property. */ - const char* GetLocation(const char* config); + const char* GetLocation(const char* config) const; /** Get the target major and minor version numbers interpreted from the VERSION property. Version 0 is returned if the property is @@ -347,37 +348,32 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch); /** - * Trace through the source files in this target and add al source files - * that they depend on, used by all generators - */ - void TraceDependencies(); - - /** * Make sure the full path to all source files is known. */ bool FindSourceFiles(); ///! Return the preferred linker language for this target - const char* GetLinkerLanguage(const char* config = 0, cmTarget *head = 0); + const char* GetLinkerLanguage(const char* config = 0, + cmTarget const* head = 0) const; /** Get the full name of the target according to the settings in its makefile. */ - std::string GetFullName(const char* config=0, bool implib = false); + std::string GetFullName(const char* config=0, bool implib = false) const; void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, - const char* config=0, bool implib = false); + const char* config=0, bool implib = false) const; /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const char* config=0); + std::string GetPDBName(const char* config=0) const; /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const char* config); + bool HasSOName(const char* config) const; /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const char* config); + std::string GetSOName(const char* config) const; /** Whether this library has \@rpath and platform supports it. */ - bool HasMacOSXRpath(const char* config); + bool HasMacOSXRpath(const char* config) const; /** Test for special case of a third-party shared library that has no soname at all. */ @@ -386,21 +382,21 @@ public: /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const char* config=0, bool implib = false, - bool realname = false); + bool realname = false) const; /** Get the names of the library needed to generate a build rule that takes into account shared library version numbers. This should be called only on a library target. */ void GetLibraryNames(std::string& name, std::string& soName, std::string& realName, std::string& impName, - std::string& pdbName, const char* config); + std::string& pdbName, const char* config) const; /** Get the names of the executable needed to generate a build rule that takes into account executable version numbers. This should be called only on an executable target. */ void GetExecutableNames(std::string& name, std::string& realName, std::string& impName, - std::string& pdbName, const char* config); + std::string& pdbName, const char* config) const; /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS(); @@ -410,39 +406,36 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0); - /** Add the target output files to the global generator manifest. */ - void GenerateTargetManifest(const char* config); - /** * Compute whether this target must be relinked before installing. */ - bool NeedRelinkBeforeInstall(const char* config); + bool NeedRelinkBeforeInstall(const char* config) const; - bool HaveBuildTreeRPATH(const char *config); - bool HaveInstallTreeRPATH(); + bool HaveBuildTreeRPATH(const char *config) const; + bool HaveInstallTreeRPATH() const; /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const char* config); + bool IsChrpathUsed(const char* config) const; /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const char* config); + std::string GetInstallNameDirForBuildTree(const char* config) const; /** Return the install name directory for the target in the * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree(); + std::string GetInstallNameDirForInstallTree() const; cmComputeLinkInformation* GetLinkInformation(const char* config, - cmTarget *head = 0); + cmTarget const* head = 0) const; // Get the properties - cmPropertyMap &GetProperties() { return this->Properties; }; + cmPropertyMap &GetProperties() const { return this->Properties; }; bool GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, - std::string& suffix); + std::string& suffix) const; // Define the properties static void DefineProperties(cmake *cm); @@ -452,7 +445,7 @@ public: const char* GetExportMacro(); void GetCompileDefinitions(std::vector<std::string> &result, - const char *config); + const char *config) const; // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change @@ -463,7 +456,7 @@ public: /** Return whether this target is an executable with symbol exports enabled. */ - bool IsExecutableWithExports(); + bool IsExecutableWithExports() const; /** Return whether this target may be used to link another target. */ bool IsLinkable(); @@ -472,25 +465,25 @@ public: bool IsDLLPlatform() { return this->DLLPlatform; } /** Return whether or not the target has a DLL import library. */ - bool HasImportLibrary(); + bool HasImportLibrary() const; /** Return whether this target is a shared library Framework on Apple. */ - bool IsFrameworkOnApple(); + bool IsFrameworkOnApple() const; /** Return whether this target is a CFBundle (plugin) on Apple. */ - bool IsCFBundleOnApple(); + bool IsCFBundleOnApple() const; /** Return whether this target is an executable Bundle on Apple. */ - bool IsAppBundleOnApple(); + bool IsAppBundleOnApple() const; /** Return whether this target is an executable Bundle, a framework or CFBundle on Apple. */ - bool IsBundleOnApple(); + bool IsBundleOnApple() const; /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ - std::string GetFrameworkVersion(); + std::string GetFrameworkVersion() const; /** Get a backtrace from the creation of the target. */ cmListFileBacktrace const& GetBacktrace() const; @@ -504,21 +497,22 @@ public: /** @return the mac content directory for this target. */ std::string GetMacContentDirectory(const char* config, - bool implib); + bool implib) const; /** @return whether this target have a well defined output file name. */ - bool HaveWellDefinedOutputFiles(); + bool HaveWellDefinedOutputFiles() const; /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const char* config, bool rootDir); + std::string GetFrameworkDirectory(const char* config, bool rootDir) const; /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const char* config, bool contentOnly); + std::string GetCFBundleDirectory(const char* config, bool contentOnly) const; /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const char* config, bool contentOnly); + std::string GetAppBundleDirectory(const char* config, + bool contentOnly) const; - std::vector<std::string> GetIncludeDirectories(const char *config); + std::vector<std::string> GetIncludeDirectories(const char *config) const; void InsertInclude(const cmValueWithOrigin &entry, bool before = false); void InsertCompileOption(const cmValueWithOrigin &entry, @@ -529,19 +523,27 @@ public: void AppendBuildInterfaceIncludes(); void GetCompileOptions(std::vector<std::string> &result, - const char *config); + const char *config) const; - bool IsNullImpliedByLinkLibraries(const std::string &p); + bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config); + const char *config) const; bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config); + const char *config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const char *config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const char *config) const; bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config); + const char *config) const; const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const char *config); + const char *config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const char *config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const char *config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt); @@ -557,7 +559,7 @@ public: { return this->TargetTypeValue == STATIC_LIBRARY; } private: - bool HandleLocationPropertyPolicy(); + bool HandleLocationPropertyPolicy() const; // The set of include directories that are marked as system include // directories. @@ -616,42 +618,42 @@ private: void AnalyzeLibDependencies( const cmMakefile& mf ); - const char* GetSuffixVariableInternal(bool implib); - const char* GetPrefixVariableInternal(bool implib); - std::string GetFullNameInternal(const char* config, bool implib); + const char* GetSuffixVariableInternal(bool implib) const; + const char* GetPrefixVariableInternal(bool implib) const; + std::string GetFullNameInternal(const char* config, bool implib) const; void GetFullNameInternal(const char* config, bool implib, std::string& outPrefix, std::string& outBase, - std::string& outSuffix); + std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. void SetPropertyDefault(const char* property, const char* default_value); // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. - const char* GetOutputTargetType(bool implib); + const char* GetOutputTargetType(bool implib) const; // Get the target base name. - std::string GetOutputName(const char* config, bool implib); + std::string GetOutputName(const char* config, bool implib) const; - const char* ImportedGetLocation(const char* config); - const char* NormalGetLocation(const char* config); + const char* ImportedGetLocation(const char* config) const; + const char* NormalGetLocation(const char* config) const; - std::string GetFullNameImported(const char* config, bool implib); + std::string GetFullNameImported(const char* config, bool implib) const; - std::string ImportedGetFullPath(const char* config, bool implib); + std::string ImportedGetFullPath(const char* config, bool implib) const; std::string NormalGetFullPath(const char* config, bool implib, - bool realname); + bool realname) const; /** Get the real name of the target. Allowed only for non-imported targets. When a library or executable file is versioned this is the full versioned name. If the target is not versioned this is the same as GetFullName. */ - std::string NormalGetRealName(const char* config); + std::string NormalGetRealName(const char* config) const; /** Append to @a base the mac content directory and return it. */ std::string BuildMacContentDirectory(const std::string& base, const char* config, - bool contentOnly); + bool contentOnly) const; private: std::string Name; @@ -669,44 +671,46 @@ private: bool HaveInstallRule; std::string InstallPath; std::string RuntimeInstallPath; - std::string Location; std::string ExportMacro; std::set<cmStdString> Utilities; bool RecordDependencies; - cmPropertyMap Properties; + mutable cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; bool DLLPlatform; bool IsApple; bool IsImportedTarget; - bool DebugIncludesDone; - bool DebugCompileOptionsDone; - bool DebugCompileDefinitionsDone; + mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileDefinitionsDone; mutable std::set<std::string> LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; // Cache target output paths for each configuration. struct OutputInfo; - OutputInfo const* GetOutputInfo(const char* config); - bool ComputeOutputDir(const char* config, bool implib, std::string& out); - bool ComputePDBOutputDir(const char* config, std::string& out); + OutputInfo const* GetOutputInfo(const char* config) const; + bool + ComputeOutputDir(const char* config, bool implib, std::string& out) const; + bool ComputePDBOutputDir(const char* config, std::string& out) const; // Cache import information from properties for each configuration. struct ImportInfo; ImportInfo const* GetImportInfo(const char* config, - cmTarget *workingTarget); + cmTarget const* workingTarget) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info, - cmTarget *head); + cmTarget const* head) const; - cmTargetLinkInformationMap LinkInformation; + mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config); + const char* config) const; bool ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget *head); + cmTarget const* head) const; void ComputeLinkImplementation(const char* config, - LinkImplementation& impl, cmTarget *head); - void ComputeLinkClosure(const char* config, LinkClosure& lc, cmTarget *head); + LinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkClosure(const char* config, LinkClosure& lc, + cmTarget const* head) const; void ClearLinkMaps(); @@ -728,6 +732,8 @@ private: // Internal representation details. friend class cmTargetInternals; + friend class cmGeneratorTarget; + friend class cmTargetTraceDependencies; cmTargetInternalPointer Internal; void ConstructSourceFileFlags(); @@ -736,7 +742,7 @@ private: std::string const& base, std::string const& suffix, std::string const& name, - const char* version); + const char* version) const; }; typedef std::map<cmStdString,cmTarget> cmTargets; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 0707c62..209609d 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -101,6 +101,37 @@ bool cmTargetLinkLibrariesCommand return true; } + if (this->Target->GetType() == cmTarget::UTILITY) + { + const char *modal = 0; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) + { + case cmPolicies::WARN: + modal = "should"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + modal = "must"; + messageType = cmake::FATAL_ERROR; + } + if (modal) + { + cmOStringStream e; + e << this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0039) << "\n" + "Utility target \"" << this->Target->GetName() << "\" " << modal + << " not be used as the target of a target_link_libraries call."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if(messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // but we might not have any libs after variable expansion if(args.size() < 2) { @@ -390,15 +421,26 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, { this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); - if (this->CurrentProcessingState != ProcessingKeywordPublicInterface - && this->CurrentProcessingState != ProcessingPlainPublicInterface) + if(this->CurrentProcessingState == ProcessingLinkLibraries) + { + this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", + this->Target->GetDebugGeneratorExpressions(lib, llt).c_str()); + return true; + } + else if(this->CurrentProcessingState != ProcessingKeywordPublicInterface + && this->CurrentProcessingState != ProcessingPlainPublicInterface) { if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) { + std::string configLib = this->Target + ->GetDebugGeneratorExpressions(lib, llt); + if (cmGeneratorExpression::IsValidTargetName(lib) + || cmGeneratorExpression::Find(lib) != std::string::npos) + { + configLib = "$<LINK_ONLY:" + configLib + ">"; + } this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", - ("$<LINK_ONLY:" + - this->Target->GetDebugGeneratorExpressions(lib, llt) + - ">").c_str()); + configLib.c_str()); } // Not a 'public' or 'interface' library. Do not add to interface // property. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 0dbb5eb..ace1eef 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -219,7 +219,8 @@ void cmVisualStudio10TargetGenerator::Generate() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); - std::string project_defaults="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; + std::string project_defaults= + "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -562,7 +563,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) if(this->SourcesVisited.insert(sf).second) { if(std::vector<cmSourceFile*> const* depends = - this->Target->GetSourceDepends(sf)) + this->GeneratorTarget->GetSourceDepends(sf)) { for(std::vector<cmSourceFile*>::const_iterator di = depends->begin(); di != depends->end(); ++di) @@ -724,7 +725,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); - std::string project_defaults="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; + std::string project_defaults= + "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; project_defaults.append("<Project ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -1049,7 +1051,8 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() si = this->GeneratorTarget->ExternalObjects.begin(); si != this->GeneratorTarget->ExternalObjects.end(); ++si) { - std::vector<cmSourceFile*> const* d=this->Target->GetSourceDepends(*si); + std::vector<cmSourceFile*> const* d = + this->GeneratorTarget->GetSourceDepends(*si); this->WriteSource((d && !d->empty())? "None":"Object", *si); } } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6822fe1..bf27c78 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -99,30 +99,6 @@ static bool cmakeCheckStampFile(const char* stampName); static bool cmakeCheckStampList(const char* stampName); -void cmNeedBackwardsCompatibility(const std::string& variable, - int access_type, void*, const char*, const cmMakefile*) -{ -#ifdef CMAKE_BUILD_WITH_CMAKE - if (access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS) - { - std::string message = "An attempt was made to access a variable: "; - message += variable; - message += - " that has not been defined. Some variables were always defined " - "by CMake in versions prior to 1.6. To fix this you might need to set " - "the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If " - "you are writing a CMakeLists file, (or have already set " - "CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less) then you probably need " - "to include a CMake module to test for the feature this variable " - "defines."; - cmSystemTools::Error(message.c_str()); - } -#else - (void)variable; - (void)access_type; -#endif -} - void cmWarnUnusedCliWarning(const std::string& variable, int, void* ctx, const char*, const cmMakefile*) { @@ -169,12 +145,6 @@ cmake::cmake() #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; - this->VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN", - cmNeedBackwardsCompatibility); - this->VariableWatch->AddWatch("CMAKE_SIZEOF_INT", - cmNeedBackwardsCompatibility); - this->VariableWatch->AddWatch("CMAKE_X_LIBS", - cmNeedBackwardsCompatibility); #endif this->AddDefaultGenerators(); @@ -962,146 +932,30 @@ void cmake::SetDirectoriesFromFile(const char* arg) // cache int cmake::AddCMakePaths() { - // Find the cmake executable - std::string cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - cMakeSelf += cmSystemTools::GetExecutableExtension(); -#ifdef __APPLE__ - // on the apple this might be the gui bundle - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "../../../.."; - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf = cmSystemTools::CollapseFullPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - std::cerr << cMakeSelf.c_str() << "\n"; - } -#endif - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cmSystemTools::Error("CMake executable cannot be found at ", - cMakeSelf.c_str()); - return 0; - } // Save the value in the cache this->CacheManager->AddCacheEntry - ("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.", - cmCacheManager::INTERNAL); - // if the edit command is not yet in the cache, - // or if CMakeEditCommand has been set on this object, - // then set the CMAKE_EDIT_COMMAND in the cache - // This will mean that the last gui to edit the cache - // will be the one that make edit_cache uses. - if(!this->GetCacheDefinition("CMAKE_EDIT_COMMAND") - || !this->CMakeEditCommand.empty()) - { - // Find and save the command to edit the cache - std::string editCacheCommand; - if(!this->CMakeEditCommand.empty()) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) - + std::string("/") - + this->CMakeEditCommand - + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ccmake" + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cmake-gui" + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if(cmSystemTools::FileExists(editCacheCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), - "Path to cache edit program executable.", cmCacheManager::INTERNAL); - } - } - std::string ctestCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ctest" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(ctestCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CTEST_COMMAND", ctestCommand.c_str(), - "Path to ctest program executable.", cmCacheManager::INTERNAL); - } - std::string cpackCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cpack" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(cpackCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CPACK_COMMAND", cpackCommand.c_str(), - "Path to cpack program executable.", cmCacheManager::INTERNAL); - } - - // do CMAKE_ROOT, look for the environment variable first - std::string cMakeRoot; - std::string modules; - if (getenv("CMAKE_ROOT")) - { - cMakeRoot = getenv("CMAKE_ROOT"); - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe/.. - cMakeRoot = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeRoot = cmSystemTools::GetProgramPath(cMakeRoot.c_str()); - std::string::size_type slashPos = cMakeRoot.rfind("/"); - if(slashPos != std::string::npos) - { - cMakeRoot = cMakeRoot.substr(0, slashPos); - } - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try exe/../share/cmake - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } -#ifdef CMAKE_ROOT_DIR - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try compiled in root directory - cMakeRoot = CMAKE_ROOT_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } + ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), + "Path to CMake executable.", cmCacheManager::INTERNAL); +#ifdef CMAKE_BUILD_WITH_CMAKE + this->CacheManager->AddCacheEntry + ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), + "Path to ctest program executable.", cmCacheManager::INTERNAL); + this->CacheManager->AddCacheEntry + ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), + "Path to cpack program executable.", cmCacheManager::INTERNAL); #endif - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if (!cmSystemTools::FileExists(modules.c_str())) + if(!cmSystemTools::FileExists( + (cmSystemTools::GetCMakeRoot()+"/Modules/CMake.cmake").c_str())) { // couldn't find modules cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n" "CMake has most likely not been installed correctly.\n" "Modules directory not found in\n", - cMakeRoot.c_str()); + cmSystemTools::GetCMakeRoot().c_str()); return 0; } this->CacheManager->AddCacheEntry - ("CMAKE_ROOT", cMakeRoot.c_str(), + ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), "Path to CMake installation.", cmCacheManager::INTERNAL); return 1; @@ -1498,9 +1352,9 @@ int cmake::ActualConfigure() {"7.1", "Visual Studio 7 .NET 2003"}, {"8.0", "Visual Studio 8 2005"}, {"9.0", "Visual Studio 9 2008"}, - {"10.0", "Visual Studio 10"}, - {"11.0", "Visual Studio 11"}, - {"12.0", "Visual Studio 12"}, + {"10.0", "Visual Studio 10 2010"}, + {"11.0", "Visual Studio 11 2012"}, + {"12.0", "Visual Studio 12 2013"}, {0, 0}}; for(int i=0; version[i].MSVersion != 0; i++) { @@ -1539,7 +1393,7 @@ int cmake::ActualConfigure() const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); if(genName) { - if(strcmp(this->GlobalGenerator->GetName(), genName) != 0) + if(!this->GlobalGenerator->MatchesGeneratorName(genName)) { std::string message = "Error: generator : "; message += this->GlobalGenerator->GetName(); @@ -1735,9 +1589,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) return 0; } - // set the cmake command - this->CMakeCommand = args[0]; - if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache @@ -1955,14 +1806,6 @@ int cmake::LoadCache() } } - if (this->CMakeCommand.size() < 2) - { - cmSystemTools::Error( - "cmake command was not specified prior to loading the cache in " - "cmake.cxx"); - return -1; - } - // setup CMAKE_ROOT and CMAKE_COMMAND if(!this->AddCMakePaths()) { @@ -2268,82 +2111,6 @@ inline std::string removeQuotes(const std::string& s) return s; } -std::string cmake::FindCMakeProgram(const char* name) const -{ - std::string path; - if ((name) && (*name)) - { - const cmMakefile* mf - = this->GetGlobalGenerator()->GetLocalGenerators()[0]->GetMakefile(); -#ifdef CMAKE_BUILD_WITH_CMAKE - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = removeQuotes(path); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Debug/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Release/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } -#else - // Only for bootstrap - path += mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); -#endif - } - return path; -} - -const char* cmake::GetCTestCommand() -{ - if ( this->CTestCommand.empty() ) - { - this->CTestCommand = this->FindCMakeProgram("ctest"); - } - if ( this->CTestCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CTest executable"); - this->CTestCommand = "CTEST-COMMAND-NOT-FOUND"; - } - return this->CTestCommand.c_str(); -} - -const char* cmake::GetCPackCommand() -{ - if ( this->CPackCommand.empty() ) - { - this->CPackCommand = this->FindCMakeProgram("cpack"); - } - if ( this->CPackCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CPack executable"); - this->CPackCommand = "CPACK-COMMAND-NOT-FOUND"; - } - return this->CPackCommand.c_str(); -} - - -const char* cmake::GetCMakeCommand() -{ - return this->CMakeCommand.c_str(); -} - - void cmake::MarkCliAsUsed(const std::string& variable) { this->UsedCliVariables[variable] = true; @@ -2896,26 +2663,19 @@ int cmake::Build(const std::string& dir, this->CreateGlobalGenerator(it.GetValue())); std::string output; std::string projName; - std::string makeProgram; if(!it.Find("CMAKE_PROJECT_NAME")) { std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n"; return 1; } projName = it.GetValue(); - if(!it.Find("CMAKE_MAKE_PROGRAM")) - { - std::cerr << "Error: could not find CMAKE_MAKE_PROGRAM in Cache\n"; - return 1; - } - makeProgram = it.GetValue(); return gen->Build(0, dir.c_str(), projName.c_str(), target.c_str(), &output, - makeProgram.c_str(), + 0, config.c_str(), clean, false, 0, cmSystemTools::OUTPUT_PASSTHROUGH, - 0, nativeOptions); + nativeOptions); } void cmake::WatchUnusedCli(const char* var) diff --git a/Source/cmake.h b/Source/cmake.h index 7fe130b..dfec55c 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -200,9 +200,6 @@ class cmake ///! get the cmCachemManager used by this invocation of cmake cmCacheManager *GetCacheManager() { return this->CacheManager; } - ///! set the cmake command this instance of cmake should use - void SetCMakeCommand(const char* cmd) { this->CMakeCommand = cmd; } - /** * Given a variable name, return its value (as a string). */ @@ -301,13 +298,6 @@ class cmake */ cmFileTimeComparison* GetFileComparison() { return this->FileComparison; } - /** - * Get the path to ctest - */ - const char* GetCTestCommand(); - const char* GetCPackCommand(); - const char* GetCMakeCommand(); - // Do we want debug output during the cmake run. bool GetDebugOutput() { return this->DebugOutput; } void SetDebugOutputOn(bool b) { this->DebugOutput = b;} @@ -344,10 +334,11 @@ class cmake debugging configurations.*/ std::vector<std::string> const& GetDebugConfigs(); - void SetCMakeEditCommand(const char* s) - { - this->CMakeEditCommand = s; - } + void SetCMakeEditCommand(std::string const& s) + { this->CMakeEditCommand = s; } + std::string const& GetCMakeEditCommand() const + { return this->CMakeEditCommand; } + void SetSuppressDevWarnings(bool v) { this->SuppressDevWarnings = v; @@ -425,8 +416,6 @@ protected: cmVariableWatch* VariableWatch; - ///! Find the full path to one of the cmake programs like ctest, cpack, etc. - std::string FindCMakeProgram(const char* name) const; private: cmake(const cmake&); // Not implemented. void operator=(const cmake&); // Not implemented. @@ -443,15 +432,12 @@ private: bool CheckSystemVars; std::map<cmStdString, bool> UsedCliVariables; std::string CMakeEditCommand; - std::string CMakeCommand; std::string CXXEnvironment; std::string CCEnvironment; std::string CheckBuildSystemArgument; std::string CheckStampFile; std::string CheckStampList; std::string VSSolutionFile; - std::string CTestCommand; - std::string CPackCommand; bool ClearBuildSystem; bool DebugTryCompile; cmFileTimeComparison* FileComparison; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index ff5c8ae..6ef0579 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -162,7 +162,7 @@ static void cmakemainProgressCallback(const char *m, float prog, int main(int ac, char** av) { cmSystemTools::EnableMSVCDebugHook(); - cmSystemTools::FindExecutableDirectory(av[0]); + cmSystemTools::FindCMakeResources(av[0]); if(ac > 1) { if(strcmp(av[1], "--build") == 0) @@ -198,7 +198,6 @@ int do_cmake(int ac, char** av) // Construct and print requested documentation. cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); // the command line args are processed here so that you can do // -DCMAKE_MODULE_PATH=/some/path and have this value accessible here diff --git a/Source/cmaketest.h.in b/Source/cmaketest.h.in deleted file mode 100644 index aada52d..0000000 --- a/Source/cmaketest.h.in +++ /dev/null @@ -1,16 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#define CMAKE_BINARY_DIR "${CMake_BINARY_DIR}" -#define EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}" -#define MAKEPROGRAM "${MAKEPROGRAM}" -#define CMAKE_GENERATOR "${CMAKE_GENERATOR}" -#define DART_MAKECOMMAND "${MAKECOMMAND}" diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 9814aea..d4f464c 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -13,7 +13,7 @@ #include "cmMakefile.h" #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" -#include "cmQtAutomoc.h" +#include "cmQtAutoGenerators.h" #include "cmVersion.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -632,12 +632,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { return cmcmd::ExecuteEchoColor(args); } - else if (args[1] == "cmake_automoc") + else if (args[1] == "cmake_autogen" && args.size() >= 4) { - cmQtAutomoc automoc; + cmQtAutoGenerators autogen; const char *config = args[3].empty() ? 0 : args[3].c_str(); - bool automocSuccess = automoc.Run(args[2].c_str(), config); - return automocSuccess ? 0 : 1; + bool autogenSuccess = autogen.Run(args[2].c_str(), config); + return autogenSuccess ? 0 : 1; } #endif diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 12e71b6..de07458 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -115,7 +115,7 @@ int main (int argc, char *argv[]) { cmSystemTools::DoNotInheritStdPipes(); cmSystemTools::EnableMSVCDebugHook(); - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); // Dispatch 'ctest --launch' mode directly. if(argc >= 2 && strcmp(argv[1], "--launch") == 0) @@ -151,7 +151,6 @@ int main (int argc, char *argv[]) { cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); // Construct and print requested documentation. cmCTestScriptHandler* ch = diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 03916bf..82537ef 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -18,7 +18,7 @@ typedef struct MainFuncPointer func; } functionMapEntry; -functionMapEntry cmakeGeneratedFunctionMapEntries[] = { +static functionMapEntry cmakeGeneratedFunctionMapEntries[] = { @CMAKE_FUNCTION_TABLE_ENTIRES@ {0,0} }; @@ -26,7 +26,7 @@ functionMapEntry cmakeGeneratedFunctionMapEntries[] = { /* Allocate and create a lowercased copy of string (note that it has to be free'd manually) */ -char* lowercase(const char *string) +static char* lowercase(const char *string) { char *new_string, *p; diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt index 1f07dc9..fdc5c00 100644 --- a/Tests/Assembler/CMakeLists.txt +++ b/Tests/Assembler/CMakeLists.txt @@ -15,6 +15,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};") list(APPEND C_FLAGS ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}) endif() + # Clang on OS X, and perhaps other compilers, do not support -g + # for both generating and assembling, so drop it from generating. + list(REMOVE_ITEM C_FLAGS -g) set(SRCS main.s) add_custom_command( OUTPUT main.s diff --git a/Tests/BootstrapTest.cmake b/Tests/BootstrapTest.cmake new file mode 100644 index 0000000..9c9fe09 --- /dev/null +++ b/Tests/BootstrapTest.cmake @@ -0,0 +1,10 @@ +file(MAKE_DIRECTORY "${bin_dir}") +message(STATUS "running bootstrap: ${bootstrap}") +execute_process( + COMMAND ${bootstrap} + WORKING_DIRECTORY "${bin_dir}" + RESULT_VARIABLE result + ) +if(result) + message(FATAL_ERROR "bootstrap failed: ${result}") +endif() diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt index bf9771c..5cda527 100644 --- a/Tests/CFBundleTest/CMakeLists.txt +++ b/Tests/CFBundleTest/CMakeLists.txt @@ -30,8 +30,14 @@ if(NOT RC_COMPILER) message(FATAL_ERROR "could not find Rez to build resources from .r file...") endif() +set(sysroot) +if(CMAKE_OSX_SYSROOT) + set(sysroot -isysroot ${CMAKE_OSX_SYSROOT}) +endif() + execute_process(COMMAND - ${RC_COMPILER} ${RCFILES} -useDF -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + ${RC_COMPILER} ${sysroot} ${RCFILES} -useDF + -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc ) set_source_files_properties( diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt index 07d7c43..818b8c9 100644 --- a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt @@ -22,6 +22,16 @@ generate_export_header(staticlib1) add_library(staticlib2 STATIC staticlib2.cpp) generate_export_header(staticlib2) target_link_libraries(staticlib1 LINK_PUBLIC staticlib2) +if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang) + target_link_libraries(staticlib1 LINK_PRIVATE "-Wl,-v") +endif() add_executable(staticlib_exe staticlib_exe.cpp) target_link_libraries(staticlib_exe staticlib1) + +add_library(onlyplainlib1 SHARED onlyplainlib1.cpp) +add_library(onlyplainlib2 SHARED onlyplainlib2.cpp) +target_link_libraries(onlyplainlib2 onlyplainlib1) + +add_executable(onlyplainlib_user onlyplainlib_user.cpp) +target_link_libraries(onlyplainlib_user onlyplainlib2) diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.cpp new file mode 100644 index 0000000..41dc3ce --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.cpp @@ -0,0 +1,13 @@ + +#include "onlyplainlib1.h" + +OnlyPlainLib1::OnlyPlainLib1() + : result(0) +{ + +} + +int OnlyPlainLib1::GetResult() +{ + return result; +} diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h new file mode 100644 index 0000000..c0373ce --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h @@ -0,0 +1,14 @@ + +struct +#ifdef _WIN32 +__declspec(dllexport) +#endif +OnlyPlainLib1 +{ + OnlyPlainLib1(); + + int GetResult(); + +private: + int result; +}; diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.cpp new file mode 100644 index 0000000..2865ae9 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.cpp @@ -0,0 +1,8 @@ + +#include "onlyplainlib2.h" + +OnlyPlainLib1 onlyPlainLib2() +{ + OnlyPlainLib1 opl1; + return opl1; +} diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h new file mode 100644 index 0000000..74b18a0 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h @@ -0,0 +1,7 @@ + +#include "onlyplainlib1.h" + +#ifdef _WIN32 +__declspec(dllexport) +#endif +OnlyPlainLib1 onlyPlainLib2(); diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib_user.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib_user.cpp new file mode 100644 index 0000000..0fb7b0a --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib_user.cpp @@ -0,0 +1,7 @@ + +#include "onlyplainlib2.h" + +int main(int argc, char **argv) +{ + return onlyPlainLib2().GetResult(); +} diff --git a/Tests/CMakeCopyright.cmake b/Tests/CMakeCopyright.cmake new file mode 100644 index 0000000..a7201e9 --- /dev/null +++ b/Tests/CMakeCopyright.cmake @@ -0,0 +1,22 @@ +if(CMAKE_VERSION MATCHES "\\.(20[0-9][0-9])[0-9][0-9][0-9][0-9](-|$)") + set(version_year "${CMAKE_MATCH_1}") + set(copyright_line_regex "^Copyright 2000-(20[0-9][0-9]) Kitware") + file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../Copyright.txt" copyright_line + LIMIT_COUNT 1 REGEX "${copyright_line_regex}") + if(copyright_line MATCHES "${copyright_line_regex}") + set(copyright_year "${CMAKE_MATCH_1}") + if(copyright_year LESS version_year) + message(FATAL_ERROR "Copyright.txt contains\n" + " ${copyright_line}\n" + "but the current version year is ${version_year}.") + else() + message(STATUS "PASSED: Copyright.txt contains\n" + " ${copyright_line}\n" + "and the current version year is ${version_year}.") + endif() + else() + message(FATAL_ERROR "Copyright.txt has no Copyright line of expected format!") + endif() +else() + message(STATUS "SKIPPED: CMAKE_VERSION does not know the year: ${CMAKE_VERSION}") +endif() diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake index 5f814d9..fda8c54 100644 --- a/Tests/CMakeInstall.cmake +++ b/Tests/CMakeInstall.cmake @@ -17,29 +17,15 @@ if(CMake_TEST_INSTALL) if(CMAKE_CONFIGURATION_TYPES) # There are multiple configurations. Make sure the tested # configuration is the one that is installed. - set(CMake_TEST_INSTALL_CONFIG -C "\${CTEST_CONFIGURATION_TYPE}") + set(CMake_TEST_INSTALL_CONFIG --config $<CONFIGURATION>) else() set(CMake_TEST_INSTALL_CONFIG) endif() - # The CTest of the CMake used to build this CMake. - if(CMAKE_CTEST_COMMAND) - set(CMake_TEST_INSTALL_CTest ${CMAKE_CTEST_COMMAND}) - else() - set(CMake_TEST_INSTALL_CTest ${CMake_BIN_DIR}/ctest) - endif() - # Add a test to install CMake through the build system install target. - add_test(CMake.Install - ${CMake_TEST_INSTALL_CTest} - ${CMake_TEST_INSTALL_CONFIG} - --build-and-test ${CMake_SOURCE_DIR} ${CMake_BINARY_DIR} - --build-generator ${CMAKE_GENERATOR} # Not CMAKE_TEST_GENERATOR - --build-project CMake - --build-makeprogram ${CMAKE_MAKE_PROGRAM} # Not CMAKE_TEST_MAKEPROGRAM - --build-nocmake - --build-noclean - --build-target install) + add_test(NAME CMake.Install + COMMAND cmake --build . --target install ${CMake_TEST_INSTALL_CONFIG} + ) # Avoid running this test simultaneously with other tests: set_tests_properties(CMake.Install PROPERTIES RUN_SERIAL ON) diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect index 744cb88..fa436cb 100644 --- a/Tests/CMakeLib/testRST.expect +++ b/Tests/CMakeLib/testRST.expect @@ -76,6 +76,13 @@ or after a paragraph ending in two colons:: but not after a line ending in two colons:: in the middle of a paragraph. +.. productionlist:: + grammar: `production` + production: "content rendered" + +.. note:: + Notes are called out. + substituted text with multiple lines becomes one line End of first include. diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst index 5cb6d91..54952dd 100644 --- a/Tests/CMakeLib/testRST.rst +++ b/Tests/CMakeLib/testRST.rst @@ -83,6 +83,13 @@ or after a paragraph ending in two colons:: but not after a line ending in two colons:: in the middle of a paragraph. +.. productionlist:: + grammar: `production` + production: "content rendered" + +.. note:: + Notes are called out. + .. |substitution| replace:: |nested substitution| with multiple lines becomes one line diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b9c99e3..48abfae 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -10,7 +10,9 @@ macro(ADD_TEST_MACRO NAME COMMAND) --build-two-config ${build_generator_args} --build-project ${proj} - ${${NAME}_EXTRA_OPTIONS} + ${${NAME}_CTEST_OPTIONS} + --build-options ${build_options} + ${${NAME}_BUILD_OPTIONS} --test-command ${COMMAND} ${ARGN}) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") endmacro() @@ -43,12 +45,25 @@ configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in # Testing if(BUILD_TESTING) + set(CMAKE_TEST_DEVENV "") + if(NOT CMAKE_TEST_DIFFERENT_GENERATOR) + if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") + set(CMAKE_TEST_MAKEPROGRAM "") + else() + set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") + endif() + if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND + NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") + set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") + endif() + endif() + if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32)) set(TEST_CompileCommandOutput 1) endif() set(MAKE_IS_GNU ) - if(${CMAKE_TEST_MAKEPROGRAM} MATCHES make) + if(CMAKE_TEST_MAKEPROGRAM MATCHES make) execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) if("${res}" STREQUAL "0") @@ -60,8 +75,8 @@ if(BUILD_TESTING) # some old versions of make simply cannot handle spaces in paths if (MAKE_IS_GNU OR - "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR - "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode|Borland") + CMAKE_TEST_MAKEPROGRAM MATCHES "nmake|gmake|wmake" OR + CMAKE_TEST_GENERATOR MATCHES "Visual Studio|XCode|Borland") set(MAKE_SUPPORTS_SPACES 1) else() set(MAKE_SUPPORTS_SPACES 0) @@ -69,7 +84,6 @@ if(BUILD_TESTING) set(build_generator_args --build-generator ${CMAKE_TEST_GENERATOR} - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} ) if(CMAKE_TEST_GENERATOR_TOOLSET) list(APPEND build_generator_args @@ -77,6 +91,11 @@ if(BUILD_TESTING) ) endif() + set(build_options) + if(CMAKE_TEST_MAKEPROGRAM) + list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + endif() + add_subdirectory(CMakeLib) add_subdirectory(CMakeOnly) add_subdirectory(RunCMake) @@ -161,6 +180,9 @@ if(BUILD_TESTING) set(CMAKE_LONG_TEST_TIMEOUT 1500) endif() + add_test(NAME CMake.Copyright + COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake) + # add a bunch of standard build-and-test style tests ADD_TEST_MACRO(CommandLineTest CommandLineTest) ADD_TEST_MACRO(FindPackageTest FindPackageTest) @@ -238,6 +260,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Assembler HelloAsm) ADD_TEST_MACRO(SourceGroups SourceGroups) ADD_TEST_MACRO(Preprocess Preprocess) + set(ExportImport_BUILD_OPTIONS -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) @@ -273,6 +296,7 @@ if(BUILD_TESTING) --build-two-config ${build_generator_args} --build-project InterfaceBuildTargets + --build-options ${build_options} --test-command ${CMAKE_CMAKE_COMMAND} -E touch_nocreate ${InterfaceBuildTargets_libname} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets") @@ -316,6 +340,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/BundleUtilities" ${build_generator_args} --build-project BundleUtilities + --build-options ${build_options} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities") @@ -328,7 +353,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/Qt4Deploy" ${build_generator_args} --build-project Qt4Deploy - --build-options + --build-options ${build_options} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} ) @@ -366,7 +391,8 @@ if(BUILD_TESTING) --build-project ExternalDataTest --build-noclean --force-new-ctest-process - --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES} + --build-options ${build_options} + -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES} --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData") @@ -399,7 +425,8 @@ if(BUILD_TESTING) ${build_generator_args} --build-project LinkFlags --build-target LinkFlags - --build-options -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE} + --build-options ${build_options} + -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags") @@ -445,8 +472,8 @@ if(BUILD_TESTING) --build-two-config --build-generator "Eclipse CDT4 - Unix Makefiles" --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Simple + --build-options ${build_options} --test-command Simple) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator") endif () @@ -460,8 +487,8 @@ if(BUILD_TESTING) --build-two-config --build-generator "CodeBlocks - Unix Makefiles" --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Simple + --build-options ${build_options} --test-command Simple) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator") endif () @@ -474,8 +501,8 @@ if(BUILD_TESTING) --build-two-config --build-generator "KDevelop3 - Unix Makefiles" --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project Simple + --build-options ${build_options} --test-command Simple) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator") endif () @@ -483,8 +510,8 @@ if(BUILD_TESTING) endif() # test for correct sub-project generation - # not implemented in VS6 or Xcode - if(NOT MSVC60 AND NOT XCODE AND NOT MSVC70) + # not implemented in VS 6, VS 7.0, Xcode, or Ninja + if(NOT CMAKE_TEST_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja") # run cmake and configure all of SubProject # but only build the independent executable car add_test(SubProject ${CMAKE_CTEST_COMMAND} @@ -494,31 +521,32 @@ if(BUILD_TESTING) --build-project SubProject ${build_generator_args} --build-target car + --build-options ${build_options} --test-command car ) - if(${CMAKE_TEST_GENERATOR} MATCHES "Ninja") - # The Ninja generator does not create a recursive build system. Start - # from the root directory. - set(SubProject_SUBDIR) - else() - set(SubProject_SUBDIR "/foo") - endif() - # For stage 2, do not run cmake again. # Then build the foo sub project which should build # the bar library which should be referenced because # foo links to the static library bar, but bar is not # directly in the foo sub project + if(CMAKE_TEST_MAKEPROGRAM) + set(SubProject-Stage2_BUILD_MAKEPROGRAM + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + ) + endif() add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/SubProject${SubProject_SUBDIR}" - "${CMake_BINARY_DIR}/Tests/SubProject${SubProject_SUBDIR}" - ${build_generator_args} + "${CMake_SOURCE_DIR}/Tests/SubProject/foo" + "${CMake_BINARY_DIR}/Tests/SubProject/foo" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + ${SubProject-Stage2_BUILD_MAKEPROGRAM} --build-nocmake --build-project foo --build-target foo --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo" + --build-options ${build_options} --test-command foo ) set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject) @@ -559,7 +587,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project Framework - --build-options + --build-options ${build_options} "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install" --test-command bar) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework") @@ -571,6 +599,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project TargetName + --build-options ${build_options} --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world) @@ -584,6 +613,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project LibName --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib" + --build-options ${build_options} --test-command foobar ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName") @@ -596,6 +626,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project CustComDepend --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin" + --build-options ${build_options} --test-command foo bar.c ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend") @@ -607,6 +638,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project ArgumentExpansion --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin" + --build-options ${build_options} ) set_tests_properties(ArgumentExpansion PROPERTIES FAIL_REGULAR_EXPRESSION "Unexpected: ") @@ -618,7 +650,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/GeneratorExpression" ${build_generator_args} --build-project GeneratorExpression - --build-options -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE} + --build-options ${build_options} + -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE} --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GeneratorExpression") @@ -631,6 +664,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project CustomCommand --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin" + --build-options ${build_options} --test-command CustomCommand ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand") @@ -644,6 +678,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project TestWorkingDir + --build-options ${build_options} --test-command working ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory") @@ -655,6 +690,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # ${build_generator_args} # --build-project SimpleExclude # --build-two-config + # --build-options ${build_options} # --test-command t4 #--test-command "${CMAKE_COMMAND}" #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}" @@ -668,6 +704,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # ${build_generator_args} # --build-project SameName # --build-two-config +# --build-options ${build_options} # --test-command # "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2") @@ -678,6 +715,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project OutOfSource --build-two-config + --build-options ${build_options} --test-command "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSource") @@ -690,6 +728,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/BuildDepends" ${build_generator_args} --build-project BuildDepends + --build-options ${build_options} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends") @@ -702,7 +741,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project TestSimpleInstall --build-two-config - --build-options + --build-options ${build_options} "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}" --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe) @@ -714,7 +753,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project TestSimpleInstall --build-two-config - --build-options + --build-options ${build_options} "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" "-DSTAGE2:BOOL=1" --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2) @@ -768,6 +807,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" ${build_generator_args} --build-project CPackWiXGenerator + --build-options ${build_options} --test-command ${CMAKE_CMAKE_COMMAND} "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake") @@ -775,12 +815,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() if(CTEST_RUN_CPackComponents) - set(CPackComponents_EXTRA_OPTIONS) + set(CPackComponents_BUILD_OPTIONS) if(APPLE) - set(CPackComponents_EXTRA_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON) + set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON) endif() if(NSIS_MAKENSIS_EXECUTABLE) - set(CPackComponents_EXTRA_OPTIONS ${CPackComponents_EXTRA_OPTIONS} + set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS} -DCPACK_BINARY_NSIS:BOOL=ON) endif() @@ -792,10 +832,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project CPackComponents --build-two-config --build-target package - --build-options + --build-options ${build_options} -DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB} -DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM} - ${CPackComponents_EXTRA_OPTIONS} + ${CPackComponents_BUILD_OPTIONS} --graphviz=CPackComponents.dot --test-command ${CMAKE_CMAKE_COMMAND} "-DCPackComponents_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponents" @@ -819,7 +859,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # ACTIVE_CPACK_GENERATORS variable # now contains the list of 'active generators' - set(CPackComponentsForAll_EXTRA_OPTIONS) + set(CPackComponentsForAll_BUILD_OPTIONS) # set up list of CPack generators list(APPEND GENLST "ZIP") if(APPLE) @@ -851,10 +891,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}" ${build_generator_args} --build-project CPackComponentsForAll - --build-options + --build-options ${build_options} -DCPACK_BINARY_${CPackGen}:BOOL=ON ${CPackRun_CPackComponentWay} - ${CPackComponentsForAll_EXTRA_OPTIONS} + ${CPackComponentsForAll_BUILD_OPTIONS} --graphviz=CPackComponentsForAll.dot --test-command ${CMAKE_CMAKE_COMMAND} "-DCPackComponentsForAll_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}" @@ -888,6 +928,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators" ${build_generator_args} --build-project CPackTestAllGenerators + --build-options ${build_options} --test-command ${CMAKE_CMAKE_COMMAND} -D dir=${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators @@ -910,6 +951,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project UseX11 --build-two-config ${X11_build_target_arg} + --build-options ${build_options} --test-command UseX11) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11") @@ -963,6 +1005,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig" ${build_generator_args} --build-project LoadCommand + --build-options ${build_options} --test-command LoadedCommand ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig") @@ -976,7 +1019,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project Complex --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin" - --build-options + --build-options ${build_options} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} --test-command complex ) @@ -989,7 +1032,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project Complex --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin" - --build-options + --build-options ${build_options} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} --test-command complex) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig") @@ -1003,6 +1046,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project HELLO --build-exe-dir "${CMake_BINARY_DIR}/Example/Demo" + --build-options ${build_options} --test-command helloDemo ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Example") @@ -1015,6 +1059,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project EnvironmentProj --build-exe-dir "${CMake_BINARY_DIR}/Tests/Environment" --force-new-ctest-process + --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment") @@ -1025,38 +1070,50 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt" ${build_generator_args} --build-project QtAutomocNoQt - --build-options -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE} + --build-options ${build_options} + -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt") + # On Windows there is no RPATH, so while Qt might be available for building, + # the required dlls may not be in the PATH, so we can't run the executables + # on that platform. + if(WIN32) + set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V) + else() + set(run_autogen_test QtAutogen) + endif() + find_package(Qt5Widgets QUIET NO_MODULE) if(Qt5Widgets_FOUND) - add_test(Qt5Automoc ${CMAKE_CTEST_COMMAND} + add_test(Qt5Autogen ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutomoc" - "${CMake_BINARY_DIR}/Tests/Qt5Automoc" + "${CMake_SOURCE_DIR}/Tests/QtAutogen" + "${CMake_BINARY_DIR}/Tests/Qt5Autogen" ${build_generator_args} - --build-project QtAutomoc - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Automoc" + --build-project QtAutogen + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen" --force-new-ctest-process - --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 - --test-command ${CMAKE_CTEST_COMMAND} -V + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 + --test-command ${run_autogen_test} ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Automoc") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen") endif() if(QT4_WORKS AND QT_QTGUI_FOUND) - add_test(Qt4Automoc ${CMAKE_CTEST_COMMAND} + add_test(Qt4Autogen ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutomoc" - "${CMake_BINARY_DIR}/Tests/Qt4Automoc" + "${CMake_SOURCE_DIR}/Tests/QtAutogen" + "${CMake_BINARY_DIR}/Tests/Qt4Autogen" ${build_generator_args} - --build-project QtAutomoc - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Automoc" + --build-project QtAutogen + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen" --force-new-ctest-process - --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 - --test-command ${CMAKE_CTEST_COMMAND} -V + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 + --test-command ${run_autogen_test} ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Automoc") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen") add_test(Qt4Targets ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1066,7 +1123,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project Qt4Targets --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Targets" --force-new-ctest-process - --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} --test-command ${CMAKE_CTEST_COMMAND} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets") @@ -1080,6 +1138,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project Qt4And5Automoc --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc" --force-new-ctest-process + --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc") @@ -1099,6 +1158,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project ExternalProjectTest --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject" --force-new-ctest-process + --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject") @@ -1113,6 +1173,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project ExternalProjectUpdateTest --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate" --force-new-ctest-process + --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate") @@ -1125,7 +1186,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR} -DCMAKE_TEST_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET} - -DCMAKE_TEST_MAKEPROGRAM=${CMAKE_TEST_MAKEPROGRAM} -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake ) @@ -1144,6 +1204,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project Tutorial + --build-options ${build_options} --test-command Tutorial 25.0) endforeach() list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial") @@ -1154,6 +1215,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/Testing" ${build_generator_args} --build-project Testing + --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} ) set_tests_properties(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed") @@ -1166,6 +1228,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project Wrapping --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" + --build-options ${build_options} --test-command wrapping ) add_test(qtwrapping ${CMAKE_CTEST_COMMAND} @@ -1175,6 +1238,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project Wrapping --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" + --build-options ${build_options} --test-command qtwrapping ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping") @@ -1186,6 +1250,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --build-project TestDriverTest + --build-options ${build_options} --test-command TestDriverTest test1 ) @@ -1196,6 +1261,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --build-project TestDriverTest + --build-options ${build_options} --test-command TestDriverTest test2 ) @@ -1206,6 +1272,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" --build-project TestDriverTest + --build-options ${build_options} --test-command TestDriverTest subdir/test3 ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver") @@ -1217,6 +1284,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec" ${build_generator_args} --build-project Dependency + --build-options ${build_options} --test-command exec ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency") @@ -1246,7 +1314,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable" --build-project Jump ${build_generator_args} - --build-options + --build-options ${build_options} -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib --test-command jumpExecutable ) @@ -1259,6 +1327,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable" --build-project Jump ${build_generator_args} + --build-options ${build_options} --test-command jumpExecutable ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump") @@ -1270,6 +1339,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project Plugin --build-two-config + --build-options ${build_options} --test-command bin/example) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin") @@ -1285,6 +1355,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/MacRuntimePath" ${build_generator_args} --build-project MacRuntimePath + --build-options ${build_options} + -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} ) endif() @@ -1294,6 +1366,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/LinkLineOrder" ${build_generator_args} --build-project LinkLineOrder + --build-options ${build_options} --test-command Exec1 ) @@ -1303,6 +1376,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/LinkLineOrder" ${build_generator_args} --build-project LinkLineOrder + --build-options ${build_options} --test-command Exec2 ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder") @@ -1323,7 +1397,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/LinkStatic" ${build_generator_args} --build-project LinkStatic - --build-options -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a + --build-options ${build_options} + -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a --test-command LinkStatic ) endif() @@ -1335,6 +1410,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/kwsys" ${build_generator_args} --build-project kwsys + --build-options ${build_options} --test-command kwsysTestsCxx testIOS ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys") @@ -1349,6 +1425,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources" ${build_generator_args} --build-project SUBDIR + --build-options ${build_options} --test-command test "${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere" "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj" @@ -1364,6 +1441,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable" ${build_generator_args} --build-project SUBDIR + --build-options ${build_options} --test-command test "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj" @@ -1376,6 +1454,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable" ${build_generator_args} --build-project SUBDIR + --build-options ${build_options} --test-command test "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o" @@ -1403,6 +1482,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project MakeClean --build-exe-dir "${CMake_BINARY_DIR}/MakeClean" + --build-options ${build_options} --test-command check_clean ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean") @@ -1416,7 +1496,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # Look for evidence that this is a VCExpress build. If so, avoid # the MFC test by default. - string(TOLOWER "${CMAKE_TEST_MAKEPROGRAM}" mkprog) + string(TOLOWER "${CMAKE_MAKE_PROGRAM};${CMAKE_TEST_MAKEPROGRAM}" mkprog) if(mkprog MATCHES "vcexpress") message(STATUS "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test") @@ -1507,6 +1587,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project mfc_driver + --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -VV) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC") @@ -1529,6 +1610,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project VSExternalInclude + --build-options ${build_options} --test-command VSExternalInclude) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude") @@ -1539,10 +1621,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project VSMidl + --build-options ${build_options} --test-command VSMidl) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl") - if(NOT MSVC60 AND NOT CMAKE_TEST_MAKEPROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") + if(CMAKE_TEST_DEVENV) # The test (and tested property) works with .sln files, so it's skipped when: # * Using VS6, which doesn't use .sln files # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file @@ -1554,7 +1637,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild" --build-config ${config} --build-two-config - ${build_generator_args} + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_DEVENV} + --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" --build-project VSExcludeFromDefaultBuild --test-command ${CMAKE_COMMAND} -D "activeConfig=${config}" @@ -1571,31 +1656,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])") - if(CMAKE_TEST_MAKEPROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") - set(MSBUILD_EXECUTABLE "${CMAKE_TEST_MAKEPROGRAM}") - else() - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio (12)") - set(_msbuild_hints "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\${CMAKE_MATCH_1}.0;MSBuildToolsPath]") - else() - set(_FDIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;FrameworkDir32]") - set(_FVER "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;FrameworkVer32]") - set(_msbuild_hints ${_FDIR}/${_FVER}) - endif() - find_program(MSBUILD_EXECUTABLE NAMES msbuild HINTS ${_msbuild_hints}) - endif() - if(MSBUILD_EXECUTABLE) - add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir" - "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" - --build-makeprogram "${MSBUILD_EXECUTABLE}" - --build-project VSProjectInSubdir - --build-target test) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir") - endif() + # This is Visual Studio 10 or above, so the default build tool is MSBuild. + add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir" + "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-project VSProjectInSubdir + --build-target test) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir") endif() endif() @@ -1612,7 +1683,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project BundleTest --build-target install # --build-target package - --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}" + --build-options ${build_options} + "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}" "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" --test-command ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe) @@ -1625,6 +1697,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project CFBundleTest + --build-options ${build_options} --test-command ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE} -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest @@ -1645,7 +1718,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project BundleGeneratorTest --build-target package - --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory" + --build-options ${build_options} + "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory" ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest") endif() @@ -1657,7 +1731,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-noclean --build-project WarnUnusedUnusedViaSet - --build-options "--warn-unused-vars") + --build-options ${build_options} + "--warn-unused-vars") set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'") set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES @@ -1671,7 +1746,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-noclean --build-project WarnUnusedUnusedViaUnset - --build-options "--warn-unused-vars") + --build-options ${build_options} + "--warn-unused-vars") set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES PASS_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:7 \\(set\\):") set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES @@ -1690,7 +1766,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" ${build_generator_args} --build-project WarnUnusedCliUnused - --build-options "-DUNUSED_CLI_VARIABLE=Unused") + --build-options ${build_options} + "-DUNUSED_CLI_VARIABLE=Unused") set_tests_properties(WarnUnusedCliUnused PROPERTIES PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") @@ -1703,7 +1780,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-noclean --build-project WarnUnusedCliUsed - --build-options "-DUSED_VARIABLE=Usage proven") + --build-options ${build_options} + "-DUSED_VARIABLE=Usage proven") set_tests_properties(WarnUnusedCliUsed PROPERTIES PASS_REGULAR_EXPRESSION "Usage proven") set_tests_properties(WarnUnusedCliUsed PROPERTIES @@ -1717,7 +1795,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-noclean --build-project WarnUninitialized - --build-options "--warn-uninitialized") + --build-options ${build_options} + "--warn-uninitialized") set_tests_properties(WarnUninitialized PROPERTIES PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized") @@ -1730,6 +1809,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project TestsWorkingDirectoryProj --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory" --force-new-ctest-process + --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory") @@ -1746,17 +1826,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # ) # A test for ctest_build() with targets in subdirectories + set(ctest_configure_options) if(CMAKE_TEST_GENERATOR_TOOLSET) - set(CMAKE_TEST_GENERATOR_TOOLSET_SELECTION "-T;${CMAKE_TEST_GENERATOR_TOOLSET};") - else() - set(CMAKE_TEST_GENERATOR_TOOLSET_SELECTION) + list(APPEND ctest_configure_options -T ${CMAKE_TEST_GENERATOR_TOOLSET}) + endif() + if(CMAKE_TEST_MAKEPROGRAM) + list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) endif() configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY) - unset(CMAKE_TEST_GENERATOR_TOOLSET_SELECTION) + unset(ctest_configure_options) add_test(CTest.BuildCommand.ProjectInSubdir - ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" - -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested") set(CTEST_TEST_UPDATE 1) @@ -1877,6 +1958,26 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}") endif() + + # Test CTest Update with P4 + find_program(P4_EXECUTABLE NAMES p4) + find_program(P4D_EXECUTABLE NAMES p4d) + mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE) + set(CTEST_TEST_UPDATE_P4 0) + if(P4_EXECUTABLE AND P4D_EXECUTABLE) + if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX) + set(CTEST_TEST_UPDATE_P4 1) + endif() + endif() + if(CTEST_TEST_UPDATE_P4) + set(CTestUpdateP4_DIR "CTest UpdateP4") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY) + add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}") + endif() endif() configure_file( @@ -1914,6 +2015,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ PASS_REGULAR_EXPRESSION "Upload\\.xml") configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log" + ) + set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES + PASS_REGULAR_EXPRESSION "TEST_SUCCESS") + + configure_file( "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" @ONLY ESCAPE_QUOTES) @@ -2091,8 +2203,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" ) + ADD_TEST_MACRO(CTestTestSerialInDepends ${CMAKE_CTEST_COMMAND} -j 4 + --output-on-failure -C "\${CTestTest_CONFIG}") + if(NOT BORLAND) - set(CTestLimitDashJ_EXTRA_OPTIONS --force-new-ctest-process) + set(CTestLimitDashJ_CTEST_OPTIONS --force-new-ctest-process) add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4 --output-on-failure -C "\${CTestTest_CONFIG}") endif() @@ -2312,6 +2427,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" ) + if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_TEST_GENERATOR}" MATCHES "Ninja") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES) + add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/testOutput.log" + ) + set_tests_properties(CTestTestLaunchers PROPERTIES + PASS_REGULAR_EXPRESSION "CTEST_TEST_LAUNCHER_SUCCESS") + endif() + configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY ESCAPE_QUOTES) @@ -2356,16 +2482,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() endif() if(bootstrap) - add_test(BootstrapTest ${CMAKE_CTEST_COMMAND} - --build-and-test - ${CMake_SOURCE_DIR} - ${CMake_BINARY_DIR}/Tests/BootstrapTest - --build-nocmake - --build-noclean - --build-makeprogram ${bootstrap} - --build-generator "${CMAKE_TEST_GENERATOR}" - --test-command - ${CMake_BINARY_DIR}/Tests/BootstrapTest/Bootstrap.cmk/cmake) + add_test(NAME BootstrapTest + COMMAND ${CMAKE_CMAKE_COMMAND} + -D "bootstrap=${bootstrap}" + -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest" + -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake + ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest") # Make this test run early during parallel execution set_tests_properties(BootstrapTest PROPERTIES COST 5000) @@ -2386,6 +2508,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project testf --build-two-config + --build-options ${build_options} + -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} --test-command testf) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") @@ -2404,6 +2528,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project FortranC --build-two-config + --build-options ${build_options} --test-command CMakeFiles/FortranCInterface/FortranCInterface) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC") endif() @@ -2427,6 +2552,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project hello --build-two-config --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") endif() @@ -2446,7 +2572,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc" ${build_generator_args} --build-project SimpleC - --build-options + --build-options ${build_options} "-DCMAKE_SYSTEM_NAME=Generic" "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc") @@ -2464,7 +2590,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win" ${build_generator_args} --build-project Simple - --build-options + --build-options ${build_options} "-DCMAKE_SYSTEM_NAME=Windows" "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}" "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}" @@ -2474,19 +2600,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() endif() - if(UNIX) - string(COMPARE EQUAL "${CMAKE_INSTALL_PREFIX}" "${CMake_BINARY_DIR}/Tests/TestShellInstall/Prefix" - PREFIX_IS_FOR_TEST) - if(PREFIX_IS_FOR_TEST) - configure_file( - ${CMake_SOURCE_DIR}/Tests/TestInstall.sh.in - ${CMake_BINARY_DIR}/Tests/TestShellInstall/TestInstall.sh - @ONLY IMMEDIATE - ) - add_test(ShellInstall /bin/sh ${CMake_BINARY_DIR}/Tests/TestShellInstall/TestShellInstall.sh) - endif() - endif() - if(CMAKE_TEST_PROJECT_CSE_DIR) set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake") if(NOT EXISTS "${script}") @@ -2558,8 +2671,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endforeach() if(TEST_CompileCommandOutput) - set(CompileCommandOutput_EXTRA_OPTIONS - --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}) + set(CompileCommandOutput_BUILD_OPTIONS + -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}) ADD_TEST_MACRO(CompileCommandOutput "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands") endif() @@ -2571,6 +2684,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project IncludeDirectories + --build-options ${build_options} --test-command IncludeDirectories) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories") @@ -2581,6 +2695,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-two-config ${build_generator_args} --build-project InterfaceLinkLibraries + --build-options ${build_options} --test-command InterfaceLinkLibraries) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries") diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 4c49c6a..41714f6 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -3,7 +3,7 @@ set(CMAKE_EXECUTABLE "${CMake_BIN_DIR}/cmake") macro(AddCMakeTest TestName PreArgs) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${TestName}Test.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" @ONLY IMMEDIATE) + "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" @ONLY) add_test(NAME CMake.${TestName} COMMAND ${CMAKE_EXECUTABLE} ${PreArgs} -P "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" ${ARGN}) diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt index 8162f0c..ff40e30 100644 --- a/Tests/CPackComponentsForAll/CMakeLists.txt +++ b/Tests/CPackComponentsForAll/CMakeLists.txt @@ -59,6 +59,7 @@ set(CPACK_PACKAGE_VERSION_MAJOR "1") set(CPACK_PACKAGE_VERSION_MINOR "0") set(CPACK_PACKAGE_VERSION_PATCH "2") set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example") +set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/license.txt) # Tell CPack all of the components to install. The "ALL" # refers to the fact that this is the set of components that @@ -120,4 +121,4 @@ if (NOT ("${CPackComponentWay}" STREQUAL "default")) set(CPACK_PROJECT_CONFIG_FILE ${CPackComponentsForAll_BINARY_DIR}/MyLibCPackConfig-${CPackComponentWay}.cmake) endif () # Include CPack to introduce the appropriate targets -include(CPack)
\ No newline at end of file +include(CPack) diff --git a/Tests/CPackComponentsForAll/license.txt b/Tests/CPackComponentsForAll/license.txt new file mode 100644 index 0000000..ba8ba48 --- /dev/null +++ b/Tests/CPackComponentsForAll/license.txt @@ -0,0 +1,3 @@ +LICENSE +------- +This is an installer created using CPack (http://www.cmake.org). No license provided. diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt index 475e60d..b54925a 100644 --- a/Tests/CPackWiXGenerator/CMakeLists.txt +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -4,15 +4,17 @@ project(CPackWiXGenerator) add_library(mylib mylib.cpp) -add_executable(mylibapp mylibapp.cpp) -target_link_libraries(mylibapp mylib) +add_executable(my-libapp mylibapp.cpp) +target_link_libraries(my-libapp mylib) + +add_executable(my-other-app myotherapp.cpp) install(TARGETS mylib ARCHIVE DESTINATION lib COMPONENT libraries) -install(TARGETS mylibapp +install(TARGETS my-libapp my-other-app RUNTIME DESTINATION bin COMPONENT applications) @@ -36,7 +38,11 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example") set(CPACK_WIX_UPGRADE_GUID "BF20CE5E-7F7C-401D-8F7C-AB45E8D170E6") set(CPACK_WIX_UNINSTALL "1") -set(CPACK_PACKAGE_EXECUTABLES "mylibapp; CPack Wix Test") + +set(CPACK_PACKAGE_EXECUTABLES + "my-libapp" "CPack WiX Test" + "my-other-app" "Second CPack WiX Test" +) include(CPack) diff --git a/Tests/CPackWiXGenerator/myotherapp.cpp b/Tests/CPackWiXGenerator/myotherapp.cpp new file mode 100644 index 0000000..c272dab --- /dev/null +++ b/Tests/CPackWiXGenerator/myotherapp.cpp @@ -0,0 +1 @@ +int main() {}
\ No newline at end of file diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in index ea48c78..abf010b 100644 --- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in +++ b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in @@ -8,5 +8,5 @@ set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@") ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) ctest_start(Experimental) -ctest_configure(OPTIONS "@CMAKE_TEST_GENERATOR_TOOLSET_SELECTION@-DCMAKE_MAKE_PROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@") +ctest_configure(OPTIONS "@ctest_configure_options@") ctest_build(TARGET test) diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in index 26a77a7..c5a7b45 100644 --- a/Tests/CTestTest2/test.cmake.in +++ b/Tests/CTestTest2/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in index 03ebd04..a7420fc 100644 --- a/Tests/CTestTestBadExe/test.cmake.in +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in index efc53fb..b18cdf3 100644 --- a/Tests/CTestTestChecksum/test.cmake.in +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in index bfb3d9a..e2dda95 100644 --- a/Tests/CTestTestCostSerial/test.cmake.in +++ b/Tests/CTestTestCostSerial/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in index 492966c..7ac1bb9 100644 --- a/Tests/CTestTestCrash/test.cmake.in +++ b/Tests/CTestTestCrash/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in index e9c9a4e..94b9cac 100644 --- a/Tests/CTestTestCycle/test.cmake.in +++ b/Tests/CTestTestCycle/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in index 002958b..98b2a27 100644 --- a/Tests/CTestTestDepends/test.cmake.in +++ b/Tests/CTestTestDepends/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in b/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in new file mode 100644 index 0000000..8eb808f --- /dev/null +++ b/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in @@ -0,0 +1,66 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CTEST_RUN_CURRENT_SCRIPT 0) + +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestEmptyBinaryDirectory") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestEmptyBinaryDirectory") + +# make sure ctest does not remove directories without a CMakeCache.txt in it +set(EMPTY_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/empty_binary_dir") +file(MAKE_DIRECTORY "${EMPTY_BINARY_DIR}") + +if(NOT EXISTS "${EMPTY_BINARY_DIR}" + OR EXISTS "${EMPTY_BINARY_DIR}/CMakeCache.txt") + message(FATAL_ERROR "empty_binary_dir precondition failed") +endif() + +ctest_empty_binary_directory("${EMPTY_BINARY_DIR}") + +if(NOT EXISTS "${EMPTY_BINARY_DIR}") + message(FATAL_ERROR "empty_binary_dir should not have been removed") +endif() + +# make sure ctest does remove directories with a CMakeCache.txt +set(VALID_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/valid_binary_dir") +file(MAKE_DIRECTORY "${VALID_BINARY_DIR}") +file(WRITE "${VALID_BINARY_DIR}/CMakeCache.txt") + +if(NOT EXISTS "${VALID_BINARY_DIR}" + OR NOT EXISTS "${VALID_BINARY_DIR}/CMakeCache.txt") + message(FATAL_ERROR "valid_binary_dir precondition failed") +endif() + +ctest_empty_binary_directory("${VALID_BINARY_DIR}") + +if(EXISTS "${VALID_BINARY_DIR}") + message(FATAL_ERROR "valid_binary_dir should have been removed") +endif() + +# make sure ctest removes build directories recursively +set(DEEP_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/deep_binary_dir") +file(MAKE_DIRECTORY "${DEEP_BINARY_DIR}") +file(WRITE "${DEEP_BINARY_DIR}/CMakeCache.txt") + +foreach(SUBDIR A Z A/A A/Z Z/A Z/Z) + set(FULL_SUBDIR "${DEEP_BINARY_DIR}/${SUBDIR}") + file(MAKE_DIRECTORY "${FULL_SUBDIR}") + + foreach(SUBFILE A.cpp Z.bat) + set(FULL_SUBFILE "${FULL_SUBDIR}/${SUBFILE}") + file(WRITE "${FULL_SUBFILE}" "I am '${FULL_SUBFILE}'") + endforeach() +endforeach() + +if(NOT EXISTS "${DEEP_BINARY_DIR}" + OR NOT EXISTS "${DEEP_BINARY_DIR}/CMakeCache.txt" + OR NOT EXISTS "${DEEP_BINARY_DIR}/Z/A/Z.bat") + message(FATAL_ERROR "deep_binary_dir precondition failed") +endif() + +ctest_empty_binary_directory("${DEEP_BINARY_DIR}") + +if(EXISTS "${DEEP_BINARY_DIR}") + message(FATAL_ERROR "deep_binary_dir should have been removed") +endif() + +message("TEST_SUCCESS") diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in index 3c4d219..1dee1ae 100644 --- a/Tests/CTestTestFailure/testNoBuild.cmake.in +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in index a133e2a..04e444d 100644 --- a/Tests/CTestTestFailure/testNoExe.cmake.in +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt new file mode 100644 index 0000000..06c5725 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(launcher_test_project) + +include(CTest) + +add_custom_command( + OUTPUT test1.txt + COMMAND ${CMAKE_COMMAND} + ARGS -DTESTID=1 -P "${CMAKE_CURRENT_SOURCE_DIR}/command.cmake" +) + +add_custom_command( + OUTPUT test2.txt + COMMAND ${CMAKE_COMMAND} + ARGS -DTESTID=2 -P "${CMAKE_CURRENT_SOURCE_DIR}/command.cmake" +) + +add_custom_target(mytarget ALL DEPENDS test1.txt test2.txt) diff --git a/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake new file mode 100644 index 0000000..bf404ab --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake @@ -0,0 +1,8 @@ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_PROJECT_NAME "CTestTestLaunchers") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_test_project/command.cmake b/Tests/CTestTestLaunchers/launcher_test_project/command.cmake new file mode 100644 index 0000000..7f31af9 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_test_project/command.cmake @@ -0,0 +1,5 @@ +if("${TESTID}" STREQUAL "1") + message("success") +elseif("${TESTID}" STREQUAL "2") + message(FATAL_ERROR "failure") +endif() diff --git a/Tests/CTestTestLaunchers/test.cmake.in b/Tests/CTestTestLaunchers/test.cmake.in new file mode 100644 index 0000000..43a6533 --- /dev/null +++ b/Tests/CTestTestLaunchers/test.cmake.in @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 2.8.12) + +# Settings: +set(CTEST_DASHBOARD_SOURCE "@CMake_SOURCE_DIR@/Tests/CTestTestLaunchers") +set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTestLaunchers") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "Launchers-@BUILDNAME@-CTestTestLaunchers") + +set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_SOURCE}/launcher_test_project") +set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/launcher_test_project-bin") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) + +file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " +CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ +CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ +CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ +CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ +CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ +CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ +") + +set(TEST_SUCCESS FALSE) + +ctest_start(Experimental) +ctest_configure(OPTIONS "-DCTEST_USE_LAUNCHERS=1") +ctest_build(NUMBER_ERRORS error_count) + +if("${error_count}" STREQUAL "1") + set(TEST_SUCCESS TRUE) +endif() + +if(TEST_SUCCESS) + message("CTEST_TEST_LAUNCHER_SUCCESS") +endif() diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in index a0d9fb3..5826342 100644 --- a/Tests/CTestTestParallel/test.cmake.in +++ b/Tests/CTestTestParallel/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in index 1e7e344..f69b519 100644 --- a/Tests/CTestTestResourceLock/test.cmake.in +++ b/Tests/CTestTestResourceLock/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in index 8ad6137..26d8058 100644 --- a/Tests/CTestTestScheduler/test.cmake.in +++ b/Tests/CTestTestScheduler/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestSerialInDepends/CMakeLists.txt b/Tests/CTestTestSerialInDepends/CMakeLists.txt new file mode 100644 index 0000000..90e50f9 --- /dev/null +++ b/Tests/CTestTestSerialInDepends/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(CTestTestSerialInDepends) + +enable_testing() + +function(my_add_test NAME COST) + add_test(NAME ${NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_CTEST_COMMAND} -DTEST_NAME=${NAME} + -S ${CMAKE_CURRENT_SOURCE_DIR}/test.ctest) + set_tests_properties(${NAME} PROPERTIES COST ${COST}) +endfunction() + +my_add_test(i_like_company 1000) +my_add_test(i_like_company_too 0) + +my_add_test(i_have_dependencies 1000) +set_tests_properties(i_have_dependencies PROPERTIES + DEPENDS "i_want_to_be_alone") + +my_add_test(i_want_to_be_alone 100) +set_tests_properties(i_want_to_be_alone PROPERTIES RUN_SERIAL 1) diff --git a/Tests/CTestTestSerialInDepends/test.ctest b/Tests/CTestTestSerialInDepends/test.ctest new file mode 100644 index 0000000..28ee094 --- /dev/null +++ b/Tests/CTestTestSerialInDepends/test.ctest @@ -0,0 +1,16 @@ +set(CTEST_RUN_CURRENT_SCRIPT 0) + +set(LOCK_FILE "${TEST_NAME}.lock") + +if("${TEST_NAME}" STREQUAL "i_want_to_be_alone") + file(GLOB LOCK_FILES *.lock) + if(LOCK_FILES) + message(FATAL_ERROR "found lock files of other tests even though this test should be running by itself: ${LOCK_FILES}") + endif() +endif() + +file(WRITE "${LOCK_FILE}") +ctest_sleep(3) +file(REMOVE "${LOCK_FILE}") + +return() diff --git a/Tests/CTestTestStopTime/GetDate.cmake b/Tests/CTestTestStopTime/GetDate.cmake index 60f1e0c..edc6519 100644 --- a/Tests/CTestTestStopTime/GetDate.cmake +++ b/Tests/CTestTestStopTime/GetDate.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.2) +cmake_minimum_required(VERSION 2.8.11) macro(GET_DATE) # @@ -13,10 +13,7 @@ macro(GET_DATE) # ${GD_PREFIX}PREFIX (if '${GD_PREFIX}' is not 'GD_'...!) # ${GD_PREFIX}VERBOSE # - # ${GD_PREFIX}CMD - # ${GD_PREFIX}ARGS # ${GD_PREFIX}OV - # ${GD_PREFIX}RV # # ${GD_PREFIX}REGEX # ${GD_PREFIX}YEAR @@ -25,8 +22,6 @@ macro(GET_DATE) # ${GD_PREFIX}HOUR # ${GD_PREFIX}MINUTE # ${GD_PREFIX}SECOND - # ${GD_PREFIX}FRACTIONAL_SECOND - # ${GD_PREFIX}DAY_OF_WEEK # # Caller can then use these variables to construct names based on # date and time stamps... @@ -51,31 +46,10 @@ macro(GET_DATE) # Retrieve the current date and time in the format: # - # Thu 01/12/2006 8:55:12.01 - # dow mm/dd/YYYY HH:MM:SS.ssssss + # 01/12/2006 08:55:12 + # mm/dd/YYYY HH:MM:SS # - # Use "echo %DATE% %TIME%" on Windows. - # Otherwise, try "date" as implemented on most Unix flavors. - # - if(WIN32) - # - # Use "cmd" shell with %DATE% and %TIME% support... - # May need adjustment in different locales or for custom date/time formats - # set in the Windows Control Panel. - # - set(${GD_PREFIX}CMD "cmd") - set(${GD_PREFIX}ARGS "/c echo %DATE% %TIME%") - else() - # - # Match the format returned by default in US English Windows: - # - set(${GD_PREFIX}CMD "date") - set(${GD_PREFIX}ARGS "\"+%a %m/%d/%Y %H:%M:%S.00\"") - endif() - - exec_program("${${GD_PREFIX}CMD}" "." ARGS "${${GD_PREFIX}ARGS}" - OUTPUT_VARIABLE ${GD_PREFIX}OV RETURN_VALUE ${GD_PREFIX}RV - ) + string(TIMESTAMP "${GD_PREFIX}OV" "%m/%d/%Y %H:%M:%S") if(${GD_PREFIX}VERBOSE) message(STATUS "") @@ -87,114 +61,39 @@ macro(GET_DATE) endif() message(STATUS "${GD_PREFIX}VERBOSE='${${GD_PREFIX}VERBOSE}'") message(STATUS "") - message(STATUS "${GD_PREFIX}CMD='${${GD_PREFIX}CMD}'") - message(STATUS "${GD_PREFIX}ARGS='${${GD_PREFIX}ARGS}'") message(STATUS "${GD_PREFIX}OV='${${GD_PREFIX}OV}'") - message(STATUS "${GD_PREFIX}RV='${${GD_PREFIX}RV}'") message(STATUS "") endif() - if("${${GD_PREFIX}RV}" STREQUAL "0") - # - # Extract eight individual components by matching a regex with paren groupings. - # Use the replace functionality and \\1 thru \\8 to extract components. - # - set(${GD_PREFIX}REGEX "([^ ]+) +([^/]+)/([^/]+)/([^ ]+) +([^:]+):([^:]+):([^\\.]+)\\.(.*)") - - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\1" ${GD_PREFIX}DAY_OF_WEEK "${${GD_PREFIX}OV}") - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\2" ${GD_PREFIX}MONTH "${${GD_PREFIX}OV}") - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\3" ${GD_PREFIX}DAY "${${GD_PREFIX}OV}") - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\4" ${GD_PREFIX}YEAR "${${GD_PREFIX}OV}") - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\5" ${GD_PREFIX}HOUR "${${GD_PREFIX}OV}") - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\6" ${GD_PREFIX}MINUTE "${${GD_PREFIX}OV}") - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\7" ${GD_PREFIX}SECOND "${${GD_PREFIX}OV}") - string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\8" ${GD_PREFIX}FRACTIONAL_SECOND "${${GD_PREFIX}OV}") - - # - # Verify that extracted components don't have anything obviously - # wrong with them... Emit warnings if something looks suspicious... - # - - # Expecting a four digit year: - # - if(NOT "${${GD_PREFIX}YEAR}" MATCHES "^[0-9][0-9][0-9][0-9]$") - message(STATUS "WARNING: Extracted ${GD_PREFIX}YEAR='${${GD_PREFIX}YEAR}' is not a four digit number...") - endif() - - # Expecting month to be <= 12: - # - if(${${GD_PREFIX}MONTH} GREATER 12) - message(STATUS "WARNING: Extracted ${GD_PREFIX}MONTH='${${GD_PREFIX}MONTH}' is greater than 12!") - endif() - - # Expecting day to be <= 31: - # - if(${${GD_PREFIX}DAY} GREATER 31) - message(STATUS "WARNING: Extracted ${GD_PREFIX}DAY='${${GD_PREFIX}DAY}' is greater than 31!") - endif() - - # Expecting hour to be <= 23: - # - if(${${GD_PREFIX}HOUR} GREATER 23) - message(STATUS "WARNING: Extracted ${GD_PREFIX}HOUR='${${GD_PREFIX}HOUR}' is greater than 23!") - endif() - - # Expecting minute to be <= 59: - # - if(${${GD_PREFIX}MINUTE} GREATER 59) - message(STATUS "WARNING: Extracted ${GD_PREFIX}MINUTE='${${GD_PREFIX}MINUTE}' is greater than 59!") - endif() - - # Expecting second to be <= 59: - # - if(${${GD_PREFIX}SECOND} GREATER 59) - message(STATUS "WARNING: Extracted ${GD_PREFIX}SECOND='${${GD_PREFIX}SECOND}' is greater than 59!") - endif() + # + # Extract six individual components by matching a regex with paren groupings. + # Use the replace functionality and \\1 thru \\6 to extract components. + # + set(${GD_PREFIX}REGEX "([^/]+)/([^/]+)/([^ ]+) +([^:]+):([^:]+):([^\\.]+)") - # If individual components are single digit, - # prepend a leading zero: - # - if("${${GD_PREFIX}YEAR}" MATCHES "^[0-9]$") - set(${GD_PREFIX}YEAR "0${${GD_PREFIX}YEAR}") - endif() - if("${${GD_PREFIX}MONTH}" MATCHES "^[0-9]$") - set(${GD_PREFIX}MONTH "0${${GD_PREFIX}MONTH}") - endif() - if("${${GD_PREFIX}DAY}" MATCHES "^[0-9]$") - set(${GD_PREFIX}DAY "0${${GD_PREFIX}DAY}") - endif() - if("${${GD_PREFIX}HOUR}" MATCHES "^[0-9]$") - set(${GD_PREFIX}HOUR "0${${GD_PREFIX}HOUR}") - endif() - if("${${GD_PREFIX}MINUTE}" MATCHES "^[0-9]$") - set(${GD_PREFIX}MINUTE "0${${GD_PREFIX}MINUTE}") - endif() - if("${${GD_PREFIX}SECOND}" MATCHES "^[0-9]$") - set(${GD_PREFIX}SECOND "0${${GD_PREFIX}SECOND}") - endif() + string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\1" ${GD_PREFIX}MONTH "${${GD_PREFIX}OV}") + string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\2" ${GD_PREFIX}DAY "${${GD_PREFIX}OV}") + string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\3" ${GD_PREFIX}YEAR "${${GD_PREFIX}OV}") + string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\4" ${GD_PREFIX}HOUR "${${GD_PREFIX}OV}") + string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\5" ${GD_PREFIX}MINUTE "${${GD_PREFIX}OV}") + string(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\6" ${GD_PREFIX}SECOND "${${GD_PREFIX}OV}") - if(${GD_PREFIX}VERBOSE) - message(STATUS "${GD_PREFIX}REGEX='${${GD_PREFIX}REGEX}'") - message(STATUS "${GD_PREFIX}YEAR='${${GD_PREFIX}YEAR}'") - message(STATUS "${GD_PREFIX}MONTH='${${GD_PREFIX}MONTH}'") - message(STATUS "${GD_PREFIX}DAY='${${GD_PREFIX}DAY}'") - message(STATUS "${GD_PREFIX}HOUR='${${GD_PREFIX}HOUR}'") - message(STATUS "${GD_PREFIX}MINUTE='${${GD_PREFIX}MINUTE}'") - message(STATUS "${GD_PREFIX}SECOND='${${GD_PREFIX}SECOND}'") - message(STATUS "${GD_PREFIX}FRACTIONAL_SECOND='${${GD_PREFIX}FRACTIONAL_SECOND}'") - message(STATUS "${GD_PREFIX}DAY_OF_WEEK='${${GD_PREFIX}DAY_OF_WEEK}'") - message(STATUS "") - message(STATUS "Counters that change...") - message(STATUS "") - message(STATUS "...very very quickly : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}${${GD_PREFIX}HOUR}${${GD_PREFIX}MINUTE}${${GD_PREFIX}SECOND}${${GD_PREFIX}FRACTIONAL_SECOND}") - message(STATUS " every second : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}${${GD_PREFIX}HOUR}${${GD_PREFIX}MINUTE}${${GD_PREFIX}SECOND}") - message(STATUS " daily : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}") - message(STATUS " monthly : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}") - message(STATUS " annually : ${${GD_PREFIX}YEAR}") - message(STATUS "") - endif() - else() - message(SEND_ERROR "ERROR: macro(GET_DATE) failed. ${GD_PREFIX}CMD='${${GD_PREFIX}CMD}' ${GD_PREFIX}ARGS='${${GD_PREFIX}ARGS}' ${GD_PREFIX}OV='${${GD_PREFIX}OV}' ${GD_PREFIX}RV='${${GD_PREFIX}RV}'") + if(${GD_PREFIX}VERBOSE) + message(STATUS "${GD_PREFIX}REGEX='${${GD_PREFIX}REGEX}'") + message(STATUS "${GD_PREFIX}YEAR='${${GD_PREFIX}YEAR}'") + message(STATUS "${GD_PREFIX}MONTH='${${GD_PREFIX}MONTH}'") + message(STATUS "${GD_PREFIX}DAY='${${GD_PREFIX}DAY}'") + message(STATUS "${GD_PREFIX}HOUR='${${GD_PREFIX}HOUR}'") + message(STATUS "${GD_PREFIX}MINUTE='${${GD_PREFIX}MINUTE}'") + message(STATUS "${GD_PREFIX}SECOND='${${GD_PREFIX}SECOND}'") + message(STATUS "") + message(STATUS "Counters that change...") + message(STATUS "") + message(STATUS " every second : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}${${GD_PREFIX}HOUR}${${GD_PREFIX}MINUTE}${${GD_PREFIX}SECOND}") + message(STATUS " daily : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}") + message(STATUS " monthly : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}") + message(STATUS " annually : ${${GD_PREFIX}YEAR}") + message(STATUS "") endif() if(${GD_PREFIX}VERBOSE) diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in index 6804789..d4e5a25 100644 --- a/Tests/CTestTestStopTime/test.cmake.in +++ b/Tests/CTestTestStopTime/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in index 526d453..2b4ef4f 100644 --- a/Tests/CTestTestSubdir/test.cmake.in +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index 40241ff..d3d0888 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in index 19abc89..340877f 100644 --- a/Tests/CTestTestUpload/test.cmake.in +++ b/Tests/CTestTestUpload/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in index 745e5bc..3252754 100644 --- a/Tests/CTestTestZeroTimeout/test.cmake.in +++ b/Tests/CTestTestZeroTimeout/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.1) +cmake_minimum_required(VERSION 2.4) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index aaf88a8..db4e08d 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -37,10 +37,19 @@ function(check_updates build) REGEX "<(${types}|FullName)>" LIMIT_INPUT ${max_update_xml_size} ) + string(REGEX REPLACE "[ \t]*<(${types})>[ \t]*;[ \t]*<FullName>([^<]*)</FullName>" "\\1{\\2}" UPDATE_XML_ENTRIES "${UPDATE_XML_ENTRIES}") + # If specified, remove the given prefix from the files in Update.xml. + # Some VCS systems, like Perforce, return absolute locations + if(DEFINED REPOSITORY_FILE_PREFIX) + string(REPLACE + "${REPOSITORY_FILE_PREFIX}" "" + UPDATE_XML_ENTRIES "${UPDATE_XML_ENTRIES}") + endif() + # Compare expected and actual entries set(EXTRA "${UPDATE_XML_ENTRIES}") list(REMOVE_ITEM EXTRA ${ARGN} ${UPDATE_EXTRA} ${UPDATE_MAYBE}) @@ -216,7 +225,7 @@ function(run_dashboard_script bin_dir) ) # Verify the updates reported by CTest. - list(APPEND UPDATE_MAYBE Updated{subdir}) + list(APPEND UPDATE_MAYBE Updated{subdir} Updated{CTestConfig.cmake}) check_updates(${bin_dir} Updated{foo.txt} Updated{bar.txt} diff --git a/Tests/CTestUpdateP4.cmake.in b/Tests/CTestUpdateP4.cmake.in new file mode 100644 index 0000000..f0420c4 --- /dev/null +++ b/Tests/CTestUpdateP4.cmake.in @@ -0,0 +1,261 @@ +# This script drives creation of a perforce repository and checks +# that CTest can update from it. + +#----------------------------------------------------------------------------- +# Test in a directory next to this script. +get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(P4_TOP "${TOP}") +set(TOP "${TOP}/@CTestUpdateP4_DIR@") + +# Include code common to all update tests. +set(REPOSITORY_FILE_PREFIX "//ctest/") +include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") + +#----------------------------------------------------------------------------- +# Perforce server options +set(P4_HOST localhost) +set(P4_PORT 1888) + +#----------------------------------------------------------------------------- +# Report p4 tools in use and set its defaults +message("Using P4 tools:") +set(P4 "@P4_EXECUTABLE@") +set(P4D "@P4D_EXECUTABLE@") +message(" p4 = ${P4}") +message(" p4d = ${P4D}") + +set(P4_CLIENT -c ctest_p4) +set(P4_OPTIONS -H ${P4_HOST} -p ${P4_PORT}) +set(P4CMD ${P4} ${P4_OPTIONS}) + +#----------------------------------------------------------------------------- +# Start the Perforce server +if(UNIX) + set(P4_ROOT ${P4_TOP}/perforce) + + message("Starting p4d on '${P4_ROOT}' listening on port ${P4_PORT}...") + + # Stop a previous instance of Perforce running + execute_process( + WORKING_DIRECTORY ${TOP} + COMMAND ${P4CMD} admin stop + OUTPUT_QUIET + ERROR_QUIET + ) + + # Make sure we don't have a perforce directory from a previous run + file(REMOVE_RECURSE ${P4_ROOT}) + file(MAKE_DIRECTORY ${P4_ROOT}) + + set(P4_SERVER "nohup '${P4D}' -d -r '${P4_ROOT}'") + set(P4_SERVER "${P4_SERVER} -L '${P4_ROOT}/p4.log'") + set(P4_SERVER "${P4_SERVER} -J '${P4_ROOT}/journal'") + set(P4_SERVER "${P4_SERVER} -p ${P4_PORT} >/dev/null 2>&1 &") + + message("Server command line: ${P4_SERVER}") + + execute_process( + COMMAND sh -c " +${P4_SERVER} +for i in 1 2 3 4 5 6 7 8 9 10; do + echo 'Waiting for server to start...' + sleep 1 + if '${P4}' -H ${P4_HOST} -p ${P4_PORT} help >/dev/null 2>&1; then + echo 'Server started.' + exit + fi +done +echo 'Gave up waiting for server to start.' +" + ) +endif() + +#----------------------------------------------------------------------------- +# Initialize the testing directory. +message("Creating test directory...") +init_testing() + +#----------------------------------------------------------------------------- +# Create the repository. +message("Creating depot...") +file(WRITE ${TOP}/depot.spec "Depot: ctest\n") +file(APPEND ${TOP}/depot.spec "Type: local\n") +file(APPEND ${TOP}/depot.spec "Map: ctest/...\n") +run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${P4CMD} depot -i + INPUT_FILE ${TOP}/depot.spec +) + +#----------------------------------------------------------------------------- +# Import initial content into the repository. +message("Importing content...") +create_content(user-source) + +message("Creating client spec...") +file(WRITE ${TOP}/client.spec "Client: ctest_p4\n") +file(APPEND ${TOP}/client.spec "Root: ${TOP}/user-source\n") +file(APPEND ${TOP}/client.spec "View: //ctest/... //ctest_p4/...\n") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} client -i + INPUT_FILE ${TOP}/client.spec +) + +# After creating the depot and the client view, all P4 commands need to +# have the client spec passed to them +list(APPEND P4CMD ${P4_CLIENT}) + +message("Adding files to repository") +file(GLOB_RECURSE files ${TOP}/user-source/*) +foreach(filename ${files}) + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} add ${filename} + ) +endforeach() + +message("Submitting changes to repository") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} submit -d "CTEST: Initial content" +) +message("Tagging the repository") +file(WRITE ${TOP}/label.spec "Label: r1\n") +file(APPEND ${TOP}/label.spec "View: //ctest/...\n") + +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} label -i + INPUT_FILE ${TOP}/label.spec +) + +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} labelsync -l r1 +) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content...") +update_content(user-source files_added files_removed dirs_added) +foreach(filename ${files_added}) + message("add: ${filename}") + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} add ${TOP}/user-source/${filename} + ) +endforeach() +foreach(filename ${files_removed}) + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} delete ${TOP}/user-source/${filename} + ) +endforeach() + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 2...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} submit -d "CTEST: Changed content" +) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content again...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} edit //ctest/... +) + +change_content(user-source) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} revert -a //ctest/... +) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 3...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} submit -d "CTEST: Changed content again" +) + +#----------------------------------------------------------------------------- +# Go back to before the changes so we can test updating. +message("Backing up to revision 1...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} sync @r1 + ) + +# Create a modified file. +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} sync @r1 + ) + +# We should p4 open any files that modify_content creates +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} open ${TOP}/user-source/CTestConfig.cmake +) +modify_content(user-source) + +#----------------------------------------------------------------------------- +# Test updating the user work directory with the command-line interface. +message("Running CTest Dashboard Command Line...") + +# Create the user build tree. +create_build_tree(user-source user-binary) +file(APPEND ${TOP}/user-binary/CTestConfiguration.ini + "# P4 command configuration +UpdateCommand: ${P4} +P4Client: ctest_p4 +P4Options: -H ${P4_HOST} -p ${P4_PORT} +") + +# Run the dashboard command line interface. +run_dashboard_command_line(user-binary) + +# Revert the modified files +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${P4CMD} revert ${TOP}/user-source/CTestConfig.cmake +) + +#----------------------------------------------------------------------------- +# Test initial checkout and update with a dashboard script. +# Create a new client so we can check out files on a different directory +message("Running CTest Dashboard Script...") + +message("Creating client spec...") +file(WRITE ${TOP}/client2.spec "Client: ctest2_p4\n") +file(APPEND ${TOP}/client2.spec "Root: ${TOP}/dash-source\n") +file(APPEND ${TOP}/client2.spec "View: //ctest/... //ctest2_p4/...\n") +run_child( + COMMAND ${P4CMD} client -i + INPUT_FILE ${TOP}/client2.spec +) + +file(MAKE_DIRECTORY ${TOP}/dash-source) + +create_dashboard_script(dash-binary + "# P4 command configuration +set(CTEST_P4_CLIENT \"ctest2_p4\") +set(CTEST_P4_OPTIONS \"-H ${P4_HOST} -p ${P4_PORT}\") +set(CTEST_UPDATE_COMMAND \"${P4}\") +") + +# Run the dashboard script with CTest. +run_dashboard_script(dash-binary) + +#----------------------------------------------------------------------------- +# Clean up +message("Shutting down p4d") +run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${P4CMD} admin stop +)
\ No newline at end of file diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index 5ee9fd7..8186c61 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -20,11 +20,25 @@ set_property(TARGET iface1 APPEND PROPERTY STRING_PROP2 STRING_PROP3 ) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_NUMBER_MIN + NUMBER_MIN_PROP1 + NUMBER_MIN_PROP2 +) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_NUMBER_MAX + NUMBER_MAX_PROP1 + NUMBER_MAX_PROP2 +) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1) set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP2 prop2) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP1 100) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP2 200) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP1 100) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP2 200) add_executable(CompatibleInterface main.cpp) target_link_libraries(CompatibleInterface iface1) @@ -33,6 +47,10 @@ set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON) set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON) set_property(TARGET CompatibleInterface PROPERTY STRING_PROP2 prop2) set_property(TARGET CompatibleInterface PROPERTY STRING_PROP3 prop3) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP1 50) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP2 250) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP1 50) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP2 250) target_compile_definitions(CompatibleInterface PRIVATE @@ -42,6 +60,10 @@ target_compile_definitions(CompatibleInterface $<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP1>,prop1>:STRING_PROP1> $<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP2>,prop2>:STRING_PROP2> $<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP3>,prop3>:STRING_PROP3> + $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP1>,50>:NUMBER_MIN_PROP1=50> + $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP2>,200>:NUMBER_MIN_PROP2=200> + $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP1>,100>:NUMBER_MAX_PROP1=100> + $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP2>,250>:NUMBER_MAX_PROP2=250> ) diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp index f5e6e38..fa299e9 100644 --- a/Tests/CompatibleInterface/main.cpp +++ b/Tests/CompatibleInterface/main.cpp @@ -23,6 +23,19 @@ #error Expected STRING_PROP3 #endif +template<bool test> +struct CMakeStaticAssert; + +template<> +struct CMakeStaticAssert<true> {}; + +enum { + NumericMaxTest1 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP1 == 100>), + NumericMaxTest2 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP2 == 250>), + NumericMinTest1 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP1 == 50>), + NumericMinTest2 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP2 == 200>) +}; + #include "iface2.h" int main(int argc, char **argv) diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 50dccbe..fcde44d 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -1,7 +1,7 @@ # # A more complex test case # -set(CMAKE_BACKWARDS_COMPATIBILITY 1.4) +cmake_minimum_required(VERSION 2.4) project (Complex) # Try setting a new policy. The IF test is for coverage. @@ -198,14 +198,14 @@ make_directory("${Complex_BINARY_DIR}/make_dir") configure_file( ${Complex_SOURCE_DIR}/Library/dummy ${Complex_BINARY_DIR}/Library/dummylib.lib - COPYONLY IMMEDIATE) + COPYONLY) foreach (ext ${CMAKE_SHLIB_SUFFIX};.so;.a;.sl ${CMAKE_SHARED_LIBRARY_SUFFIX}.2 ${CMAKE_STATIC_LIBRARY_SUFFIX}.2) configure_file( ${Complex_SOURCE_DIR}/Library/dummy ${Complex_BINARY_DIR}/Library/libdummylib${ext} - COPYONLY IMMEDIATE) + COPYONLY) endforeach () find_library(FIND_DUMMY_LIB @@ -281,7 +281,7 @@ if (WIN32) configure_file( ${Complex_SOURCE_DIR}/Library/dummy "${dir}/${file}" - COPYONLY IMMEDIATE) + COPYONLY) exec_program(${CMAKE_COMMAND} ARGS "-E write_regv \"${hkey}\" \"${dir}\"") find_path(REGISTRY_TEST_PATH ${file} diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index 2613f27..bf23d4a 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 1.3) # # Create exe. # diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index e904f28..31442ba 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -838,13 +838,13 @@ int main() #endif #endif // defined(_WIN32) && !defined(__CYGWIN__) - if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0) + if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) { - cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3"); + cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 2.4"); } else { - cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3"); + cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 2.4"); } // ---------------------------------------------------------------------- diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index cbb4286..a4a0e0e 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -1,7 +1,7 @@ # # A more complex test case # -set(CMAKE_BACKWARDS_COMPATIBILITY 1.4) +cmake_minimum_required(VERSION 2.4) project (Complex) # Try setting a new policy. The IF test is for coverage. @@ -198,12 +198,12 @@ make_directory("${Complex_BINARY_DIR}/make_dir") configure_file( ${Complex_SOURCE_DIR}/Library/dummy ${Complex_BINARY_DIR}/Library/dummylib.lib - COPYONLY IMMEDIATE) + COPYONLY) foreach (ext ${CMAKE_SHLIB_SUFFIX};.so;.a;.sl) configure_file( ${Complex_SOURCE_DIR}/Library/dummy ${Complex_BINARY_DIR}/Library/libdummylib${ext} - COPYONLY IMMEDIATE) + COPYONLY) endforeach () find_library(FIND_DUMMY_LIB @@ -251,7 +251,7 @@ if (WIN32) configure_file( ${Complex_SOURCE_DIR}/Library/dummy "${dir}/${file}" - COPYONLY IMMEDIATE) + COPYONLY) exec_program(${CMAKE_COMMAND} ARGS "-E write_regv \"${hkey}\" \"${dir}\"") find_path(REGISTRY_TEST_PATH ${file} diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 432dbf8..01f1005 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 1.3) # # Create exe. # diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index e904f28..31442ba 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -838,13 +838,13 @@ int main() #endif #endif // defined(_WIN32) && !defined(__CYGWIN__) - if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0) + if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) { - cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3"); + cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 2.4"); } else { - cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3"); + cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 2.4"); } // ---------------------------------------------------------------------- diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 30daa7d..2408141 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -170,7 +170,7 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/not_included.h configure_file( ${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h - @ONLY IMMEDIATE + @ONLY ) # add the executable @@ -375,7 +375,7 @@ foreach(arg ${CHECK_ARGS} "") endforeach() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c - @ONLY IMMEDIATE) + @ONLY) add_executable(check_command_line ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c) set(output_name "check_command_line") @@ -449,3 +449,10 @@ set_property(SOURCE perconfig.out PROPERTY SYMBOLIC 1) add_custom_target(perconfig_target ALL COMMAND ${CMAKE_COMMAND} -E echo "perconfig=$<TARGET_FILE:perconfig>" "config=$<CONFIGURATION>" DEPENDS perconfig.out) + +# Test SOURCES in add_custom_target() with COMPILE_DEFINITIONS +# which previously caused a crash in the makefile generators. +add_custom_target(source_in_custom_target SOURCES source_in_custom_target.cpp) +set_property(SOURCE source_in_custom_target + PROPERTY COMPILE_DEFINITIONS "TEST" +) diff --git a/Tests/CustomCommand/source_in_custom_target.cpp b/Tests/CustomCommand/source_in_custom_target.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CustomCommand/source_in_custom_target.cpp diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index b8368fc..8be8d33 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -42,7 +42,6 @@ add_custom_command( --build-target install --build-generator ${CMAKE_GENERATOR} --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake VERBATIM ) @@ -64,7 +63,6 @@ add_custom_command( --build-project Import --build-generator ${CMAKE_GENERATOR} --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake VERBATIM ) diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in index 98d355f..fba6ee2 100644 --- a/Tests/ExportImport/InitialCache.cmake.in +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -1,3 +1,4 @@ +set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program") set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler") set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags") set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags") diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index cda5fed..8f165ce 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -198,13 +198,13 @@ if(TEST_MODULE_DEPENDS) --build-project ExtFort --build-generator ${CMAKE_GENERATOR} --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options -DCMAKE_Fortran_COMPILER:STRING=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS} -DCMAKE_Fortran_FLAGS_DEBUG:STRING=${CMAKE_Fortran_FLAGS_DEBUG} -DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE} -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL} -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} + -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} ${External_BUILD_TYPE} VERBATIM ) diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt index 5e5b6c4..a87b41e 100644 --- a/Tests/MacRuntimePath/CMakeLists.txt +++ b/Tests/MacRuntimePath/CMakeLists.txt @@ -38,7 +38,6 @@ add_custom_command( --build-target install --build-generator ${CMAKE_GENERATOR} --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options -C${MacRuntimePath_BINARY_DIR}/InitialCache.cmake VERBATIM ) @@ -60,7 +59,6 @@ add_custom_command( --build-project MacRuntimePath_B --build-generator ${CMAKE_GENERATOR} --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options -C${MacRuntimePath_BINARY_DIR}/InitialCache.cmake VERBATIM ) diff --git a/Tests/MacRuntimePath/InitialCache.cmake.in b/Tests/MacRuntimePath/InitialCache.cmake.in index be15eb3..3dc9041 100644 --- a/Tests/MacRuntimePath/InitialCache.cmake.in +++ b/Tests/MacRuntimePath/InitialCache.cmake.in @@ -1,3 +1,4 @@ +set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program") set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler") set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags") set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags") diff --git a/Tests/MakeClean/CMakeLists.txt b/Tests/MakeClean/CMakeLists.txt index 13348a2..8ac624a 100644 --- a/Tests/MakeClean/CMakeLists.txt +++ b/Tests/MakeClean/CMakeLists.txt @@ -37,21 +37,14 @@ foreach(f ${TOCLEAN_FILES}) set(CHECK_FILES "${CHECK_FILES} \"${f}\",\n") endforeach() configure_file(${MakeClean_SOURCE_DIR}/check_clean.c.in - ${MakeClean_BINARY_DIR}/check_clean.c @ONLY IMMEDIATE) + ${MakeClean_BINARY_DIR}/check_clean.c @ONLY) add_executable(check_clean ${MakeClean_BINARY_DIR}/check_clean.c) # After the executable builds, clean the files. add_custom_command( TARGET check_clean POST_BUILD - COMMAND ${CMAKE_CTEST_COMMAND} - ARGS --build-and-test - ${MakeClean_SOURCE_DIR}/ToClean - ${MakeClean_BINARY_DIR}/ToClean - --build-generator ${CMAKE_GENERATOR} - --build-project ToClean - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-noclean - --build-target clean + COMMAND ${CMAKE_COMMAND} --build ${MakeClean_BINARY_DIR}/ToClean + --target clean COMMENT "Clean the ToClean Project" ) diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt index 37d7292..089fd13 100644 --- a/Tests/MakeClean/ToClean/CMakeLists.txt +++ b/Tests/MakeClean/ToClean/CMakeLists.txt @@ -40,4 +40,4 @@ list(APPEND TOCLEAN_FILES "${ToClean_BINARY_DIR}/toclean_copy${CMAKE_EXECUTABLE_ # Configure a file listing these build-time-generated files. configure_file(${ToClean_SOURCE_DIR}/ToCleanFiles.cmake.in - ${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY IMMEDIATE) + ${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY) diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index 8312dca..5a6f3d5 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -42,3 +42,4 @@ ExternalData_Add_Target(Data1) add_subdirectory(Data2) add_subdirectory(Data3) +add_subdirectory(Data4) diff --git a/Tests/Module/ExternalData/Data4/CMakeLists.txt b/Tests/Module/ExternalData/Data4/CMakeLists.txt new file mode 100644 index 0000000..ac977fb --- /dev/null +++ b/Tests/Module/ExternalData/Data4/CMakeLists.txt @@ -0,0 +1,15 @@ +set(Store0 ${CMAKE_BINARY_DIR}/ExternalData/Other) +set(Store1 ${CMAKE_BINARY_DIR}/ExternalData/Objects) +set(ExternalData_OBJECT_STORES ${Store0} ${Store1}) +unset(ExternalData_URL_TEMPLATES) # All objects already in stores! +ExternalData_Add_Test(Data4 + NAME Data4Check + COMMAND ${CMAKE_COMMAND} + -D Data=DATA{Data.dat} + -D Other=DATA{Other.dat} + -D Store0=${Store0} + -D Store1=${Store1} + -P ${CMAKE_CURRENT_SOURCE_DIR}/Data4Check.cmake + ) +ExternalData_Add_Target(Data4) +add_dependencies(Data4 Data3) diff --git a/Tests/Module/ExternalData/Data4/Data.dat.md5 b/Tests/Module/ExternalData/Data4/Data.dat.md5 new file mode 100644 index 0000000..70e39bd --- /dev/null +++ b/Tests/Module/ExternalData/Data4/Data.dat.md5 @@ -0,0 +1 @@ +8c018830e3efa5caf3c7415028335a57 diff --git a/Tests/Module/ExternalData/Data4/Data4Check.cmake b/Tests/Module/ExternalData/Data4/Data4Check.cmake new file mode 100644 index 0000000..e614cc4 --- /dev/null +++ b/Tests/Module/ExternalData/Data4/Data4Check.cmake @@ -0,0 +1,26 @@ +if(NOT EXISTS "${Data}") + message(SEND_ERROR "Input file:\n ${Data}\ndoes not exist!") +endif() +if(NOT EXISTS "${Other}") + message(SEND_ERROR "Input file:\n ${Other}\ndoes not exist!") +endif() +# Verify that the 'Data' object was found in the second store location left +# from Data1 target downloads and that the 'Other' object was found in the +# first store location left from Data3 target downloads. Neither object +# should exist in the opposite store. +foreach(should_exist + "${Store0}/MD5/aaad162b85f60d1eb57ca71a23e8efd7" + "${Store1}/MD5/8c018830e3efa5caf3c7415028335a57" + ) + if(NOT EXISTS ${should_exist}) + message(SEND_ERROR "Store file:\n ${should_exist}\nshould exist!") + endif() +endforeach() +foreach(should_not_exist + "${Store0}/MD5/8c018830e3efa5caf3c7415028335a57" + "${Store1}/MD5/aaad162b85f60d1eb57ca71a23e8efd7" + ) + if(EXISTS ${should_not_exist}) + message(SEND_ERROR "Store file:\n ${should_not_exist}\nshould not exist!") + endif() +endforeach() diff --git a/Tests/Module/ExternalData/Data4/Other.dat.md5 b/Tests/Module/ExternalData/Data4/Other.dat.md5 new file mode 100644 index 0000000..5312faa --- /dev/null +++ b/Tests/Module/ExternalData/Data4/Other.dat.md5 @@ -0,0 +1 @@ +aaad162b85f60d1eb57ca71a23e8efd7 diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt index 13a07b4..0aeefaa 100644 --- a/Tests/ObjectLibrary/CMakeLists.txt +++ b/Tests/ObjectLibrary/CMakeLists.txt @@ -58,3 +58,5 @@ target_compile_definitions(ABmain PUBLIC $<TARGET_PROPERTY:B,INTERFACE_COMPILE_D add_executable(UseABinternal ${dummy} $<TARGET_OBJECTS:ABmain> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B> ) + +add_subdirectory(ExportLanguages) diff --git a/Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt b/Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt new file mode 100644 index 0000000..22c92a7 --- /dev/null +++ b/Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) +project(ExportLanguages CXX) +add_library(ExportLanguagesA OBJECT a.cxx) +add_library(ExportLanguagesB STATIC a.c $<TARGET_OBJECTS:ExportLanguagesA>) + +# Verify that object library languages are propagated. +export(TARGETS ExportLanguagesB NAMESPACE Exp FILE BExport.cmake) +include(ExternalProject) +ExternalProject_Add(ExportLanguagesTest + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ExportLanguagesTest" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ExportLanguagesTest" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) +add_dependencies(ExportLanguagesTest ExportLanguagesA ExportLanguagesB) diff --git a/Tests/ObjectLibrary/ExportLanguages/ExportLanguagesTest/CMakeLists.txt b/Tests/ObjectLibrary/ExportLanguages/ExportLanguagesTest/CMakeLists.txt new file mode 100644 index 0000000..fc8dd2b --- /dev/null +++ b/Tests/ObjectLibrary/ExportLanguages/ExportLanguagesTest/CMakeLists.txt @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 2.8) + +project(ExportLanguagesTest) + +include(${CMAKE_CURRENT_BINARY_DIR}/../BExport.cmake) +get_property(configs TARGET ExpExportLanguagesB PROPERTY IMPORTED_CONFIGURATIONS) +foreach(c ${configs}) + get_property(langs TARGET ExpExportLanguagesB PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES_${c}) + list(FIND langs CXX pos) + if(${pos} LESS 0) + message(FATAL_ERROR "Target export does not list object library languages.") + endif() +endforeach() diff --git a/Tests/ObjectLibrary/ExportLanguages/a.c b/Tests/ObjectLibrary/ExportLanguages/a.c new file mode 100644 index 0000000..af20d3f --- /dev/null +++ b/Tests/ObjectLibrary/ExportLanguages/a.c @@ -0,0 +1 @@ +int a(void) { return 0; } diff --git a/Tests/RunCMake/ObjectLibrary/a.cxx b/Tests/ObjectLibrary/ExportLanguages/a.cxx index ae9c87c..ae9c87c 100644 --- a/Tests/RunCMake/ObjectLibrary/a.cxx +++ b/Tests/ObjectLibrary/ExportLanguages/a.cxx diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index d1b8334..c6ed15d 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -50,37 +50,15 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND # Verify that targets export with proper IMPORTED SONAME properties. export(TARGETS example_mod_1 example_mod_2 NAMESPACE exp_ FILE ${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) - include(${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) - get_property(configs TARGET exp_example_mod_1 PROPERTY IMPORTED_CONFIGURATIONS) - foreach(c ${configs}) - string(TOUPPER "${c}" CONFIG) - get_property(soname1 TARGET exp_example_mod_1 PROPERTY IMPORTED_SONAME_${CONFIG}) - get_property(soname2 TARGET exp_example_mod_2 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) - if(soname1) - message(STATUS "exp_example_mod_1 has IMPORTED_SONAME_${CONFIG} as expected: ${soname1}") - else() - message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_SONAME_${CONFIG} but should") - endif() - if(soname2) - message(STATUS "exp_example_mod_2 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname2}") - else() - message(SEND_ERROR "exp_example_mod_2 does not have IMPORTED_NO_SONAME_${CONFIG} but should") - endif() - endforeach() - # Parse the binary to check for SONAME if possible. - if("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") - find_program(READELF_EXE readelf) - if(READELF_EXE) - add_custom_target(check_mod_soname ALL COMMAND - ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} - -Dmod1=$<TARGET_FILE:example_mod_1> - -Dmod2=$<TARGET_FILE:example_mod_2> - -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mod_soname.cmake - ) - add_dependencies(check_mod_soname example_mod_1 example_mod_2) - endif() - endif() + include(ExternalProject) + ExternalProject_Add(PluginTest + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PluginTest" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/PluginTest" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" + ) + add_dependencies(PluginTest example_mod_1 example_mod_2) endif() # TODO: diff --git a/Tests/Plugin/PluginTest/CMakeLists.txt b/Tests/Plugin/PluginTest/CMakeLists.txt new file mode 100644 index 0000000..79ef8a9 --- /dev/null +++ b/Tests/Plugin/PluginTest/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 2.8) + +project(PluginTest) + +include(${CMAKE_CURRENT_BINARY_DIR}/../mods.cmake) +get_property(configs TARGET exp_example_mod_1 PROPERTY IMPORTED_CONFIGURATIONS) +foreach(c ${configs}) + string(TOUPPER "${c}" CONFIG) + get_property(soname1 TARGET exp_example_mod_1 PROPERTY IMPORTED_SONAME_${CONFIG}) + get_property(soname2 TARGET exp_example_mod_2 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) + if(soname1) + message(STATUS "exp_example_mod_1 has IMPORTED_SONAME_${CONFIG} as expected: ${soname1}") + else() + message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_SONAME_${CONFIG} but should") + endif() + if(soname2) + message(STATUS "exp_example_mod_2 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname2}") + else() + message(SEND_ERROR "exp_example_mod_2 does not have IMPORTED_NO_SONAME_${CONFIG} but should") + endif() +endforeach() + +# Parse the binary to check for SONAME if possible. +if("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") + find_program(READELF_EXE readelf) + if(READELF_EXE) + add_custom_target(check_mod_soname ALL COMMAND + ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} + -Dmod1=$<TARGET_FILE:exp_example_mod_1> + -Dmod2=$<TARGET_FILE:exp_example_mod_2> + -P ${CMAKE_CURRENT_SOURCE_DIR}/../check_mod_soname.cmake + ) + endif() +endif() diff --git a/Tests/QtAutomoc/Adir/CMakeLists.txt b/Tests/QtAutogen/Adir/CMakeLists.txt index a1c36ff..a1c36ff 100644 --- a/Tests/QtAutomoc/Adir/CMakeLists.txt +++ b/Tests/QtAutogen/Adir/CMakeLists.txt diff --git a/Tests/QtAutomoc/Adir/libA.cpp b/Tests/QtAutogen/Adir/libA.cpp index 3968c44..3968c44 100644 --- a/Tests/QtAutomoc/Adir/libA.cpp +++ b/Tests/QtAutogen/Adir/libA.cpp diff --git a/Tests/QtAutomoc/Adir/libA.h b/Tests/QtAutogen/Adir/libA.h index 03ad1e0..03ad1e0 100644 --- a/Tests/QtAutomoc/Adir/libA.h +++ b/Tests/QtAutogen/Adir/libA.h diff --git a/Tests/QtAutomoc/Bdir/CMakeLists.txt b/Tests/QtAutogen/Bdir/CMakeLists.txt index d9d4aa7..d9d4aa7 100644 --- a/Tests/QtAutomoc/Bdir/CMakeLists.txt +++ b/Tests/QtAutogen/Bdir/CMakeLists.txt diff --git a/Tests/QtAutomoc/Bdir/libB.cpp b/Tests/QtAutogen/Bdir/libB.cpp index 72f2cfa..72f2cfa 100644 --- a/Tests/QtAutomoc/Bdir/libB.cpp +++ b/Tests/QtAutogen/Bdir/libB.cpp diff --git a/Tests/QtAutomoc/Bdir/libB.h b/Tests/QtAutogen/Bdir/libB.h index 510c17f..510c17f 100644 --- a/Tests/QtAutomoc/Bdir/libB.h +++ b/Tests/QtAutogen/Bdir/libB.h diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 8ad693a..7991c4e 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.11) -project(QtAutomoc) +project(QtAutogen) if (QT_TEST_VERSION STREQUAL 4) find_package(Qt4 REQUIRED) @@ -35,15 +35,20 @@ add_definitions(-DFOO -DSomeDefine="Barx") # enable relaxed mode so automoc can handle all the special cases: set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + # create an executable and two library targets, each requiring automoc: add_library(codeeditorLib STATIC codeeditor.cpp) add_library(privateSlot OBJECT private_slot.cpp) -add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp - xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>) +add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp + xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot> + test.qrc resourcetester.cpp +) -set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) +set_target_properties(QtAutogen codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) include(GenerateExportHeader) # The order is relevant here. B depends on A, and B headers depend on A @@ -59,7 +64,7 @@ set_target_properties(libC PROPERTIES AUTOMOC TRUE) generate_export_header(libC) target_link_libraries(libC LINK_PUBLIC libB) -target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} libC) +target_link_libraries(QtAutogen codeeditorLib ${QT_LIBRARIES} libC) add_library(empty STATIC empty.cpp) set_target_properties(empty PROPERTIES AUTOMOC TRUE) diff --git a/Tests/QtAutomoc/abc.cpp b/Tests/QtAutogen/abc.cpp index 4bbc769..4bbc769 100644 --- a/Tests/QtAutomoc/abc.cpp +++ b/Tests/QtAutogen/abc.cpp diff --git a/Tests/QtAutomoc/abc.h b/Tests/QtAutogen/abc.h index d1924b0..d1924b0 100644 --- a/Tests/QtAutomoc/abc.h +++ b/Tests/QtAutogen/abc.h diff --git a/Tests/QtAutomoc/abc_p.h b/Tests/QtAutogen/abc_p.h index 952fff3..952fff3 100644 --- a/Tests/QtAutomoc/abc_p.h +++ b/Tests/QtAutogen/abc_p.h diff --git a/Tests/QtAutomoc/bar.cpp b/Tests/QtAutogen/bar.cpp index 8be4815..8be4815 100644 --- a/Tests/QtAutomoc/bar.cpp +++ b/Tests/QtAutogen/bar.cpp diff --git a/Tests/QtAutomoc/blub.cpp b/Tests/QtAutogen/blub.cpp index bd53972..bd53972 100644 --- a/Tests/QtAutomoc/blub.cpp +++ b/Tests/QtAutogen/blub.cpp diff --git a/Tests/QtAutomoc/blub.h b/Tests/QtAutogen/blub.h index 1967bc1..1967bc1 100644 --- a/Tests/QtAutomoc/blub.h +++ b/Tests/QtAutogen/blub.h diff --git a/Tests/QtAutomoc/calwidget.cpp b/Tests/QtAutogen/calwidget.cpp index cbfa5a8..defde20 100644 --- a/Tests/QtAutomoc/calwidget.cpp +++ b/Tests/QtAutogen/calwidget.cpp @@ -49,7 +49,10 @@ #include "calwidget.h" + #include "ui_calwidget.h" + Window::Window() + : ui(new Ui::Window) { createPreviewGroupBox(); createGeneralOptionsGroupBox(); diff --git a/Tests/QtAutomoc/calwidget.h b/Tests/QtAutogen/calwidget.h index 8447389..d21a473 100644 --- a/Tests/QtAutomoc/calwidget.h +++ b/Tests/QtAutogen/calwidget.h @@ -52,6 +52,11 @@ class QGroupBox; class QLabel; + namespace Ui + { + class Window; + } + class Window : public QWidget { Q_OBJECT @@ -116,6 +121,8 @@ QCheckBox *firstFridayCheckBox; QCheckBox *mayFirstCheckBox; + + Ui::Window *ui; }; #endif diff --git a/Tests/QtAutogen/calwidget.ui b/Tests/QtAutogen/calwidget.ui new file mode 100644 index 0000000..1c245ca --- /dev/null +++ b/Tests/QtAutogen/calwidget.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Window</class> + <widget class="QWidget" name="Window"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QPushButton" name="pushButton"> + <property name="geometry"> + <rect> + <x>90</x> + <y>180</y> + <width>94</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutomoc/codeeditor.cpp b/Tests/QtAutogen/codeeditor.cpp index 01da062..01da062 100644 --- a/Tests/QtAutomoc/codeeditor.cpp +++ b/Tests/QtAutogen/codeeditor.cpp diff --git a/Tests/QtAutomoc/codeeditor.h b/Tests/QtAutogen/codeeditor.h index 56e9e792..56e9e792 100644 --- a/Tests/QtAutomoc/codeeditor.h +++ b/Tests/QtAutogen/codeeditor.h diff --git a/Tests/QtAutomoc/defines_test/CMakeLists.txt b/Tests/QtAutogen/defines_test/CMakeLists.txt index ad4e684..ad4e684 100644 --- a/Tests/QtAutomoc/defines_test/CMakeLists.txt +++ b/Tests/QtAutogen/defines_test/CMakeLists.txt diff --git a/Tests/QtAutomoc/defines_test/defines_test.cpp b/Tests/QtAutogen/defines_test/defines_test.cpp index 2836d35..2836d35 100644 --- a/Tests/QtAutomoc/defines_test/defines_test.cpp +++ b/Tests/QtAutogen/defines_test/defines_test.cpp diff --git a/Tests/QtAutomoc/empty.cpp b/Tests/QtAutogen/empty.cpp index ab32cf6..ab32cf6 100644 --- a/Tests/QtAutomoc/empty.cpp +++ b/Tests/QtAutogen/empty.cpp diff --git a/Tests/QtAutomoc/empty.h b/Tests/QtAutogen/empty.h index 4566142..4566142 100644 --- a/Tests/QtAutomoc/empty.h +++ b/Tests/QtAutogen/empty.h diff --git a/Tests/QtAutomoc/foo.cpp b/Tests/QtAutogen/foo.cpp index 699ba09..699ba09 100644 --- a/Tests/QtAutomoc/foo.cpp +++ b/Tests/QtAutogen/foo.cpp diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutogen/foo.h index 32d4c8d..f23ec07 100644 --- a/Tests/QtAutomoc/foo.h +++ b/Tests/QtAutogen/foo.h @@ -16,7 +16,10 @@ #include <QObject> -class Foo : public QObject +class Foo +#ifdef FOO + : public QObject +#endif { Q_OBJECT public: diff --git a/Tests/QtAutomoc/gadget.cpp b/Tests/QtAutogen/gadget.cpp index 23d95fa..23d95fa 100644 --- a/Tests/QtAutomoc/gadget.cpp +++ b/Tests/QtAutogen/gadget.cpp diff --git a/Tests/QtAutomoc/gadget.h b/Tests/QtAutogen/gadget.h index 7c688ee..7c688ee 100644 --- a/Tests/QtAutomoc/gadget.h +++ b/Tests/QtAutogen/gadget.h diff --git a/Tests/QtAutomoc/libC.cpp b/Tests/QtAutogen/libC.cpp index 8d61cb1..8d61cb1 100644 --- a/Tests/QtAutomoc/libC.cpp +++ b/Tests/QtAutogen/libC.cpp diff --git a/Tests/QtAutomoc/libC.h b/Tests/QtAutogen/libC.h index 4fb4a2c..4fb4a2c 100644 --- a/Tests/QtAutomoc/libC.h +++ b/Tests/QtAutogen/libC.h diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutogen/main.cpp index bd80180..c8a036e 100644 --- a/Tests/QtAutomoc/main.cpp +++ b/Tests/QtAutogen/main.cpp @@ -38,7 +38,8 @@ ** ****************************************************************************/ -#include <QApplication> +#include <QCoreApplication> +#include <QTimer> #include "codeeditor.h" #include "calwidget.h" @@ -49,17 +50,11 @@ #include "xyz.h" #include "yaf.h" #include "libC.h" +#include "resourcetester.h" int main(int argv, char **args) { - QApplication app(argv, args); - - CodeEditor editor; - editor.setWindowTitle(QObject::tr("Code Editor Example")); - editor.show(); - - Window w; - w.show(); + QCoreApplication app(argv, args); Foo foo; foo.doFoo(); @@ -82,5 +77,9 @@ int main(int argv, char **args) LibC lc; lc.foo(); + ResourceTester rt; + + QTimer::singleShot(0, &rt, SLOT(doTest())); + return app.exec(); } diff --git a/Tests/QtAutomoc/private_slot.cpp b/Tests/QtAutogen/private_slot.cpp index 1387a70..1387a70 100644 --- a/Tests/QtAutomoc/private_slot.cpp +++ b/Tests/QtAutogen/private_slot.cpp diff --git a/Tests/QtAutomoc/private_slot.h b/Tests/QtAutogen/private_slot.h index 28e5448..28e5448 100644 --- a/Tests/QtAutomoc/private_slot.h +++ b/Tests/QtAutogen/private_slot.h diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp new file mode 100644 index 0000000..43314e1 --- /dev/null +++ b/Tests/QtAutogen/resourcetester.cpp @@ -0,0 +1,21 @@ + +#include "resourcetester.h" + +#include <QDebug> +#include <QApplication> +#include <QFile> +#include <QTimer> + +ResourceTester::ResourceTester(QObject *parent) + : QObject(parent) +{ + +} + +void ResourceTester::doTest() +{ + if (!QFile::exists(":/CMakeLists.txt")) + qApp->exit(EXIT_FAILURE); + + QTimer::singleShot(0, qApp, SLOT(quit())); +} diff --git a/Tests/QtAutogen/resourcetester.h b/Tests/QtAutogen/resourcetester.h new file mode 100644 index 0000000..b02cb4e --- /dev/null +++ b/Tests/QtAutogen/resourcetester.h @@ -0,0 +1,17 @@ + +#ifndef RESOURCE_TESTER_H +#define RESOURCE_TESTER_H + +#include <QObject> + +class ResourceTester : public QObject +{ + Q_OBJECT +public: + explicit ResourceTester(QObject *parent = 0); + +private slots: + void doTest(); +}; + +#endif diff --git a/Tests/QtAutomoc/sub/bar.h b/Tests/QtAutogen/sub/bar.h index db56b8e..db56b8e 100644 --- a/Tests/QtAutomoc/sub/bar.h +++ b/Tests/QtAutogen/sub/bar.h diff --git a/Tests/QtAutogen/test.qrc b/Tests/QtAutogen/test.qrc new file mode 100644 index 0000000..c3d4e3c --- /dev/null +++ b/Tests/QtAutogen/test.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>CMakeLists.txt</file> +</qresource> +</RCC> diff --git a/Tests/QtAutomoc/xyz.cpp b/Tests/QtAutogen/xyz.cpp index a3562a3..a3562a3 100644 --- a/Tests/QtAutomoc/xyz.cpp +++ b/Tests/QtAutogen/xyz.cpp diff --git a/Tests/QtAutomoc/xyz.h b/Tests/QtAutogen/xyz.h index 8175d37..8175d37 100644 --- a/Tests/QtAutomoc/xyz.h +++ b/Tests/QtAutogen/xyz.h diff --git a/Tests/QtAutomoc/yaf.cpp b/Tests/QtAutogen/yaf.cpp index d278ab4..d278ab4 100644 --- a/Tests/QtAutomoc/yaf.cpp +++ b/Tests/QtAutogen/yaf.cpp diff --git a/Tests/QtAutomoc/yaf.h b/Tests/QtAutogen/yaf.h index 8689f83..8689f83 100644 --- a/Tests/QtAutomoc/yaf.h +++ b/Tests/QtAutogen/yaf.h diff --git a/Tests/QtAutomoc/yaf_p.h b/Tests/QtAutogen/yaf_p.h index f0368ad..f0368ad 100644 --- a/Tests/QtAutomoc/yaf_p.h +++ b/Tests/QtAutogen/yaf_p.h diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe.cmake b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe.cmake new file mode 100644 index 0000000..b0268c8 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe.cmake @@ -0,0 +1,7 @@ +enable_language(CXX) + +add_library(testLib empty_vs6_1.cpp) +add_executable(testExe empty_vs6_2.cpp) +target_link_libraries(testExe testLib) + +export(TARGETS testExe FILE "${CMAKE_CURRENT_BINARY_DIR}/cmp0022NOWARN-exe.cmake") diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared.cmake b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared.cmake new file mode 100644 index 0000000..57c3ed0 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared.cmake @@ -0,0 +1,8 @@ +enable_language(CXX) + +add_library(foo SHARED empty_vs6_1.cpp) +add_library(bar SHARED empty_vs6_2.cpp) +target_link_libraries(bar foo) + +add_executable(zot empty.cpp) +target_link_libraries(zot bar) diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW.cmake b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW.cmake new file mode 100644 index 0000000..3fee15d --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW.cmake @@ -0,0 +1,14 @@ + +project(CMP0022-NOWARN-static-NEW) + +cmake_policy(SET CMP0022 NEW) + +add_library(foo STATIC empty_vs6_1.cpp) +add_library(bar STATIC empty_vs6_2.cpp) +add_library(bat STATIC empty_vs6_3.cpp) +target_link_libraries(foo bar) +# The last element here needs to contain a space so that it is a single +# element which is not a valid target name. As bar is a STATIC library, +# this tests that the LINK_ONLY generator expression is not used for +# that element, creating an error. +target_link_libraries(bar LINK_PRIVATE bat "-lz -lm") diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt index 6d519f0..6a6a0c7 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt @@ -3,14 +3,16 @@ CMake Warning \(dev\) in CMakeLists.txt: interface. Run "cmake --help-policy CMP0022" for policy details. Use the cmake_policy command to set the policy and suppress this warning. - Target "bar" has a INTERFACE_LINK_LIBRARIES property which differs from its - LINK_INTERFACE_LIBRARIES properties. + Target "bar" has an INTERFACE_LINK_LIBRARIES property. This should be + preferred as the source of the link interface for this library but because + CMP0022 is not set CMake is ignoring the property and using the link + implementation as the link interface instead. INTERFACE_LINK_LIBRARIES: foo - LINK_INTERFACE_LIBRARIES: + Link implementation: \(empty\) diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-static-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-static-stderr.txt index e41133a..1370c5e 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-static-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-static-stderr.txt @@ -3,10 +3,10 @@ CMake Warning \(dev\) in CMakeLists.txt: interface. Run "cmake --help-policy CMP0022" for policy details. Use the cmake_policy command to set the policy and suppress this warning. - Static library target "bar" has a INTERFACE_LINK_LIBRARIES property. This - should be preferred as the source of the link interface for this library. - Ignoring the property and using the link implementation as the link - interface instead. + Target "bar" has an INTERFACE_LINK_LIBRARIES property. This should be + preferred as the source of the link interface for this library but because + CMP0022 is not set CMake is ignoring the property and using the link + implementation as the link interface instead. INTERFACE_LINK_LIBRARIES: diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt index 93c0ab3..2f7dfbf 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt @@ -1,10 +1,10 @@ -CMake Warning \(dev\) in CMakeLists.txt: +^CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link interface. Run "cmake --help-policy CMP0022" for policy details. Use the cmake_policy command to set the policy and suppress this warning. - Target "bar" has a INTERFACE_LINK_LIBRARIES property which differs from its - LINK_INTERFACE_LIBRARIES properties. + Target "bar" has an INTERFACE_LINK_LIBRARIES property which differs from + its LINK_INTERFACE_LIBRARIES properties. INTERFACE_LINK_LIBRARIES: diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt index 6370b24..f672285 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt @@ -3,8 +3,8 @@ CMake Warning \(dev\) in CMakeLists.txt: interface. Run "cmake --help-policy CMP0022" for policy details. Use the cmake_policy command to set the policy and suppress this warning. - Target "bar" has a INTERFACE_LINK_LIBRARIES property which differs from its - LINK_INTERFACE_LIBRARIES properties. + Target "bar" has an INTERFACE_LINK_LIBRARIES property which differs from + its LINK_INTERFACE_LIBRARIES properties. INTERFACE_LINK_LIBRARIES: diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN.cmake b/Tests/RunCMake/CMP0022/CMP0022-WARN.cmake index 24b7f45..fe7e858 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN.cmake +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN.cmake @@ -9,3 +9,8 @@ set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES bat) add_library(user empty.cpp) target_link_libraries(user bar) + +# Use "bar" again with a different "head" target to check +# that the warning does not appear again. +add_library(user2 empty_vs6_3.cpp) +target_link_libraries(user2 bar) diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-exe.cmake b/Tests/RunCMake/CMP0022/CMP0022-export-exe.cmake new file mode 100644 index 0000000..d832fac --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-export-exe.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) + +cmake_policy(SET CMP0022 NEW) + +add_library(testLib empty_vs6_1.cpp) +add_executable(testExe empty_vs6_2.cpp) +target_link_libraries(testExe testLib) + +export(TARGETS testExe FILE "${CMAKE_CURRENT_BINARY_DIR}/cmp0022NEW-exe.cmake") diff --git a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake index 8e5824a..4c10996 100644 --- a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake @@ -4,7 +4,11 @@ run_cmake(CMP0022-WARN) run_cmake(CMP0022-WARN-tll) run_cmake(CMP0022-WARN-static) run_cmake(CMP0022-WARN-empty-old) +run_cmake(CMP0022-NOWARN-exe) +run_cmake(CMP0022-NOWARN-shared) run_cmake(CMP0022-NOWARN-static) +run_cmake(CMP0022-NOWARN-static-NEW) run_cmake(CMP0022-NOWARN-static-link_libraries) run_cmake(CMP0022-export) +run_cmake(CMP0022-export-exe) run_cmake(CMP0022-install-export) diff --git a/Tests/RunCMake/CMP0022/empty_vs6_4.cpp b/Tests/RunCMake/CMP0022/empty_vs6_4.cpp new file mode 100644 index 0000000..7efedab --- /dev/null +++ b/Tests/RunCMake/CMP0022/empty_vs6_4.cpp @@ -0,0 +1 @@ +#include "empty.cpp" diff --git a/Tests/RunCMake/build_command/BeforeProject-result.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/build_command/BeforeProject-result.txt +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-result.txt diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt new file mode 100644 index 0000000..9d2c35b --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt @@ -0,0 +1,35 @@ +CMake Error at CMP0037-NEW-colon.cmake:4 \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "lib:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-colon.cmake:5 \(add_executable\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "exe:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-colon.cmake:6 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake new file mode 100644 index 0000000..f4c070d --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0037 NEW) + +add_library("lib:colon" empty.cpp) +add_executable("exe:colon" empty.cpp) +add_custom_target("custom:colon") diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt new file mode 100644 index 0000000..13835af --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt @@ -0,0 +1,33 @@ +CMake Error at CMP0037-NEW-reserved.cmake:4 \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "all" is reserved or not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-reserved.cmake:5 \(add_executable\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "clean" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-reserved.cmake:6 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "help" is reserved or not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake new file mode 100644 index 0000000..e9f6404 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0037 NEW) + +add_library(all empty.cpp) +add_executable(clean empty.cpp) +add_custom_target(help) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-result.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt new file mode 100644 index 0000000..2525bcd --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt @@ -0,0 +1,35 @@ +CMake Error at CMP0037-NEW-space.cmake:4 \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "lib with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-space.cmake:5 \(add_executable\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "exe with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-space.cmake:6 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake new file mode 100644 index 0000000..9227986 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0037 NEW) + +add_library("lib with spaces" empty.cpp) +add_executable("exe with spaces" empty.cpp) +add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake new file mode 100644 index 0000000..870a286 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0037 OLD) + +add_library(all empty.cpp) +add_executable(clean empty.cpp) +add_custom_target(help) diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake new file mode 100644 index 0000000..46193a1 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0037 OLD) + +add_library("lib with spaces" empty.cpp) +add_executable("exe with spaces" empty.cpp) +add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-result.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt new file mode 100644 index 0000000..d3b0e17 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt @@ -0,0 +1,38 @@ +CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:2 \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "lib:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:3 \(add_executable\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "exe:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:4 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake new file mode 100644 index 0000000..445e3b2 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake @@ -0,0 +1,4 @@ + +add_library("lib:colon" empty.cpp) +add_executable("exe:colon" empty.cpp) +add_custom_target("custom:colon") diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-result.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt new file mode 100644 index 0000000..e39477a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt @@ -0,0 +1,37 @@ +CMake Warning \(dev\) at CMP0037-WARN-space.cmake:2 \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "lib with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-space.cmake:3 \(add_executable\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "exe with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-space.cmake:4 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake new file mode 100644 index 0000000..e50a64d --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake @@ -0,0 +1,4 @@ + +add_library("lib with spaces" empty.cpp) +add_executable("exe with spaces" empty.cpp) +add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/CMakeLists.txt b/Tests/RunCMake/CMP0037/CMakeLists.txt new file mode 100644 index 0000000..f1d9cae --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake new file mode 100644 index 0000000..b7d8d7b --- /dev/null +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -0,0 +1,13 @@ +include(RunCMake) + +run_cmake(CMP0037-OLD-space) +run_cmake(CMP0037-NEW-space) +run_cmake(CMP0037-WARN-space) +run_cmake(CMP0037-NEW-colon) + +if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make")) + run_cmake(CMP0037-WARN-colon) +endif() + +run_cmake(CMP0037-OLD-reserved) +run_cmake(CMP0037-NEW-reserved) diff --git a/Tests/RunCMake/CMP0037/empty.cpp b/Tests/RunCMake/CMP0037/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0037/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW-result.txt b/Tests/RunCMake/CMP0038/CMP0038-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt new file mode 100644 index 0000000..3d0a428 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0038-NEW.cmake:3 \(add_library\): + Target "self_link" links to itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake b/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake new file mode 100644 index 0000000..6296b83 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0038 NEW) +add_library(self_link empty.cpp) +target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt b/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake b/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake new file mode 100644 index 0000000..3752821 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0038 OLD) +add_library(self_link empty.cpp) +target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt b/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt new file mode 100644 index 0000000..64631e7 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0038-WARN.cmake:2 \(add_library\): + Policy CMP0038 is not set: Targets may not link directly to themselves. + Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + Target "self_link" links to itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake b/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake new file mode 100644 index 0000000..5b92d09 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake @@ -0,0 +1,3 @@ + +add_library(self_link empty.cpp) +target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMakeLists.txt b/Tests/RunCMake/CMP0038/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0038/RunCMakeTest.cmake b/Tests/RunCMake/CMP0038/RunCMakeTest.cmake new file mode 100644 index 0000000..fc3500a --- /dev/null +++ b/Tests/RunCMake/CMP0038/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0038-WARN) +run_cmake(CMP0038-NEW) +run_cmake(CMP0038-OLD) diff --git a/Tests/RunCMake/CMP0038/empty.cpp b/Tests/RunCMake/CMP0038/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0038/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0039/CMP0039-NEW-result.txt b/Tests/RunCMake/CMP0039/CMP0039-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0039/CMP0039-NEW-stderr.txt b/Tests/RunCMake/CMP0039/CMP0039-NEW-stderr.txt new file mode 100644 index 0000000..821c4f8 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-NEW-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at CMP0039-NEW.cmake:7 \(target_link_libraries\): + Policy CMP0039 is not set: Utility targets may not have link dependencies. + Run "cmake --help-policy CMP0039" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + Utility target "utility" must not be used as the target of a + target_link_libraries call. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0039/CMP0039-NEW.cmake b/Tests/RunCMake/CMP0039/CMP0039-NEW.cmake new file mode 100644 index 0000000..2032d64 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-NEW.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0039 NEW) + +add_custom_target(utility + COMMAND ${CMAKE_COMMAND} -E echo test +) +target_link_libraries(utility m) diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt b/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt b/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD.cmake b/Tests/RunCMake/CMP0039/CMP0039-OLD.cmake new file mode 100644 index 0000000..9a513f4 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-OLD.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0039 OLD) + +add_custom_target(utility + COMMAND ${CMAKE_COMMAND} -E echo test +) +target_link_libraries(utility m) diff --git a/Tests/RunCMake/CMP0039/CMP0039-WARN-result.txt b/Tests/RunCMake/CMP0039/CMP0039-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0039/CMP0039-WARN-stderr.txt b/Tests/RunCMake/CMP0039/CMP0039-WARN-stderr.txt new file mode 100644 index 0000000..a8e6c70 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-WARN-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at CMP0039-WARN.cmake:5 \(target_link_libraries\): + Policy CMP0039 is not set: Utility targets may not have link dependencies. + Run "cmake --help-policy CMP0039" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + Utility target "utility" should not be used as the target of a + target_link_libraries call. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0039/CMP0039-WARN.cmake b/Tests/RunCMake/CMP0039/CMP0039-WARN.cmake new file mode 100644 index 0000000..6249993 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-WARN.cmake @@ -0,0 +1,5 @@ + +add_custom_target(utility + COMMAND ${CMAKE_COMMAND} -E echo test +) +target_link_libraries(utility m) diff --git a/Tests/RunCMake/CMP0039/CMakeLists.txt b/Tests/RunCMake/CMP0039/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0039/RunCMakeTest.cmake b/Tests/RunCMake/CMP0039/RunCMakeTest.cmake new file mode 100644 index 0000000..58e8ea9 --- /dev/null +++ b/Tests/RunCMake/CMP0039/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0039-WARN) +run_cmake(CMP0039-NEW) +run_cmake(CMP0039-OLD) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 8148cb6..bb1b909 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -56,10 +56,14 @@ add_RunCMake_test(CMP0022) add_RunCMake_test(CMP0026) add_RunCMake_test(CMP0027) add_RunCMake_test(CMP0028) +add_RunCMake_test(CMP0037) +add_RunCMake_test(CMP0038) +add_RunCMake_test(CMP0039) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) endif() +add_RunCMake_test(CompilerNotFound) add_RunCMake_test(Configure) add_RunCMake_test(DisallowedCommands) add_RunCMake_test(ExternalData) @@ -93,6 +97,7 @@ add_RunCMake_test(Syntax) add_RunCMake_test(add_dependencies) add_RunCMake_test(build_command) +add_RunCMake_test(cmake_minimum_required) add_RunCMake_test(find_package) add_RunCMake_test(get_filename_component) add_RunCMake_test(if) @@ -102,11 +107,13 @@ add_RunCMake_test(list) add_RunCMake_test(message) add_RunCMake_test(string) add_RunCMake_test(try_compile) +add_RunCMake_test(set) add_RunCMake_test(variable_watch) add_RunCMake_test(CMP0004) add_RunCMake_test(TargetPolicies) add_RunCMake_test(alias_targets) add_RunCMake_test(interface_library) +add_RunCMake_test(no_install_prefix) find_package(Qt4 QUIET) find_package(Qt5Core QUIET) diff --git a/Tests/RunCMake/CTest/BeforeProject-stderr.txt b/Tests/RunCMake/CTest/BeforeProject-stderr.txt index 354896b..2d934a4 100644 --- a/Tests/RunCMake/CTest/BeforeProject-stderr.txt +++ b/Tests/RunCMake/CTest/BeforeProject-stderr.txt @@ -1,6 +1,6 @@ -CMake Error at .*/Modules/CTest.cmake:[0-9]+ \(build_command\): - build_command\(\) requires CMAKE_MAKE_PROGRAM to be defined. Call project\(\) - or enable_language\(\) first. +CMake Error at .*/Modules/CTestTargets.cmake:20 \(message\): + Do not include\(CTest\) before calling project\(\). Call Stack \(most recent call first\): - BeforeProject.cmake:[0-9]+ \(include\) - CMakeLists.txt:[0-9]+ \(include\) + .*/Modules/CTest.cmake:297 \(include\) + BeforeProject.cmake:1 \(include\) + CMakeLists.txt:5 \(include\) diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler-override.cmake b/Tests/RunCMake/CompilerChange/EmptyCompiler-override.cmake new file mode 100644 index 0000000..28d29e0 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-override.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt b/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt index 4745b25..cf3b1b3 100644 --- a/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt +++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt @@ -1,5 +1,13 @@ You have changed variables that require your cache to be deleted. Configure will be re-run and you may have to reset some variables. The following variables have changed: -CMAKE_C_COMPILER= *( -|$) +CMAKE_C_COMPILER= * ++ +CMake Error at EmptyCompiler.cmake:2 \(enable_language\): + No CMAKE_C_COMPILER could be found. + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:6 \(include\)$ diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake b/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake index c87ec49..06e9e03 100644 --- a/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake +++ b/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake @@ -1,3 +1,2 @@ +set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_LIST_DIR}/EmptyCompiler-override.cmake) enable_language(C) -message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake index d383716..5bb2821 100644 --- a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake @@ -22,8 +22,8 @@ set(ccIn ${RunCMake_SOURCE_DIR}/cc.sh.in) set(cc1 ${RunCMake_BINARY_DIR}/cc1.sh) set(cc2 ${RunCMake_BINARY_DIR}/cc2.sh) set(cc3 CMAKE_C_COMPILER-NOTFOUND) -configure_file(${ccIn} ${cc1} @ONLY IMMEDIATE) -configure_file(${ccIn} ${cc2} @ONLY IMMEDIATE) +configure_file(${ccIn} ${cc1} @ONLY) +configure_file(${ccIn} ${cc2} @ONLY) # Use a single build tree for remaining tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build) diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-result.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr.txt new file mode 100644 index 0000000..c98842d --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at BadCompilerC.cmake:2 \(enable_language\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC.cmake b/Tests/RunCMake/CompilerNotFound/BadCompilerC.cmake new file mode 100644 index 0000000..10fe59a --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER "no-C-compiler") +enable_language(C) +message(FATAL_ERROR "This error should not be reached.") diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-result.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr.txt new file mode 100644 index 0000000..7ef4f5e --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at BadCompilerCXX.cmake:2 \(enable_language\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX.cmake b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX.cmake new file mode 100644 index 0000000..3b1e890 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX.cmake @@ -0,0 +1,3 @@ +set(CMAKE_CXX_COMPILER "no-CXX-compiler") +enable_language(CXX) +message(FATAL_ERROR "This error should not be reached.") diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-result.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr.txt new file mode 100644 index 0000000..eecff54 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr.txt @@ -0,0 +1,25 @@ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX.cmake b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX.cmake new file mode 100644 index 0000000..2b6fa61 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX.cmake @@ -0,0 +1,4 @@ +set(CMAKE_C_COMPILER "no-C-compiler") +set(CMAKE_CXX_COMPILER "no-CXX-compiler") +project(BadCompilerCandCXXInner C CXX) +message(FATAL_ERROR "This error should not be reached.") diff --git a/Tests/RunCMake/CompilerNotFound/CMakeLists.txt b/Tests/RunCMake/CompilerNotFound/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE-result.txt b/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE-stderr.txt b/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE-stderr.txt new file mode 100644 index 0000000..88bb95e --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at NoCompilerC-IDE.cmake:2 \(enable_language\): + No CMAKE_C_COMPILER could be found. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE.cmake b/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE.cmake new file mode 100644 index 0000000..45e1a68 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerC-IDE.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER_ID_ERROR_FOR_TEST "#error NoCompilerC-IDE") +enable_language(C) +message(FATAL_ERROR "This error should not be reached.") diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE-result.txt b/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE-stderr.txt b/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE-stderr.txt new file mode 100644 index 0000000..4c92323 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at NoCompilerCXX-IDE.cmake:2 \(enable_language\): + No CMAKE_CXX_COMPILER could be found. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE.cmake b/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE.cmake new file mode 100644 index 0000000..85025a0 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerCXX-IDE.cmake @@ -0,0 +1,3 @@ +set(CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST "#error NoCompilerCXX-IDE") +enable_language(CXX) +message(FATAL_ERROR "This error should not be reached.") diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE-result.txt b/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE-stderr.txt b/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE-stderr.txt new file mode 100644 index 0000000..21c69f5 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at NoCompilerCandCXX-IDE.cmake:3 \(project\): + No CMAKE_C_COMPILER could be found. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at NoCompilerCandCXX-IDE.cmake:3 \(project\): + No CMAKE_CXX_COMPILER could be found. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE.cmake b/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE.cmake new file mode 100644 index 0000000..78256a9 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/NoCompilerCandCXX-IDE.cmake @@ -0,0 +1,4 @@ +set(CMAKE_C_COMPILER_ID_ERROR_FOR_TEST "#error NoCompilerCandCXX-IDE") +set(CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST "#error NoCompilerCandCXX-IDE") +project(NoCompilerCandCXXInner C CXX) +message(FATAL_ERROR "This error should not be reached.") diff --git a/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake new file mode 100644 index 0000000..8b84f39 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) + +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") + run_cmake(NoCompilerC-IDE) + run_cmake(NoCompilerCXX-IDE) + run_cmake(NoCompilerCandCXX-IDE) +else() + run_cmake(BadCompilerC) + run_cmake(BadCompilerCXX) + run_cmake(BadCompilerCandCXX) +endif() diff --git a/Tests/RunCMake/DisallowedCommands/CMakeLists.txt b/Tests/RunCMake/DisallowedCommands/CMakeLists.txt index e8db6b0..12cd3c7 100644 --- a/Tests/RunCMake/DisallowedCommands/CMakeLists.txt +++ b/Tests/RunCMake/DisallowedCommands/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt index ad059d4..ccbaf5a 100644 --- a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt +++ b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt @@ -1,5 +1,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): - ExternalData_URL_TEMPLATES is not set! + Neither ExternalData_URL_TEMPLATES nor ExternalData_OBJECT_STORES is set! Call Stack \(most recent call first\): NoURLTemplates.cmake:2 \(ExternalData_Add_Target\) CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/ObjectStoreOnly.cmake b/Tests/RunCMake/ExternalData/ObjectStoreOnly.cmake new file mode 100644 index 0000000..5e66101 --- /dev/null +++ b/Tests/RunCMake/ExternalData/ObjectStoreOnly.cmake @@ -0,0 +1,3 @@ +include(ExternalData) +set(ExternalData_OBJECT_STORES "${CMAKE_CURRENT_BINARY_DIR}") +ExternalData_Add_Target(Data) diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake index 8fba82c..93ff08f 100644 --- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake @@ -22,6 +22,7 @@ run_cmake(NormalData2) run_cmake(NormalData3) run_cmake(NormalDataSub1) run_cmake(NotUnderRoot) +run_cmake(ObjectStoreOnly) run_cmake(Semicolon1) run_cmake(Semicolon2) run_cmake(Semicolon3) diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-result.txt b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt new file mode 100644 index 0000000..533d38c --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt @@ -0,0 +1,26 @@ +CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): + Error evaluating generator expression: + + \$<TARGET_FILE:objlib> + + Target "objlib" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): + Error evaluating generator expression: + + \$<TARGET_SONAME_FILE:objlib> + + Target "objlib" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): + Error evaluating generator expression: + + \$<TARGET_LINKER_FILE:objlib> + + Target "objlib" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake new file mode 100644 index 0000000..c47ee2b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake @@ -0,0 +1,7 @@ +enable_language(C) +add_library(objlib OBJECT empty.c) +add_custom_target(check ALL COMMAND echo + $<TARGET_FILE:objlib> + $<TARGET_SONAME_FILE:objlib> + $<TARGET_LINKER_FILE:objlib> + ) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 62bf29b..54d5064 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -7,4 +7,5 @@ run_cmake(BadNOT) run_cmake(BadStrEqual) run_cmake(BadZero) run_cmake(BadTargetName) +run_cmake(BadTargetTypeObject) run_cmake(BadInstallPrefix) diff --git a/Tests/RunCMake/GeneratorExpression/empty.c b/Tests/RunCMake/GeneratorExpression/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/empty.c diff --git a/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake b/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake deleted file mode 100644 index 0796c21..0000000 --- a/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake +++ /dev/null @@ -1,15 +0,0 @@ -enable_language(CXX) -add_library(A OBJECT a.cxx) -add_library(B STATIC a.c $<TARGET_OBJECTS:A>) - -# Verify that object library languages are propagated. -export(TARGETS B NAMESPACE Exp FILE BExport.cmake) -include(${CMAKE_CURRENT_BINARY_DIR}/BExport.cmake) -get_property(configs TARGET ExpB PROPERTY IMPORTED_CONFIGURATIONS) -foreach(c ${configs}) - get_property(langs TARGET ExpB PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES_${c}) - list(FIND langs CXX pos) - if(${pos} LESS 0) - message(FATAL_ERROR "Target export does not list object library languages.") - endif() -endforeach() diff --git a/Tests/RunCMake/ObjectLibrary/MissingSource-result.txt b/Tests/RunCMake/ObjectLibrary/MissingSource-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/MissingSource-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/MissingSource-stderr.txt b/Tests/RunCMake/ObjectLibrary/MissingSource-stderr.txt new file mode 100644 index 0000000..411cd7c --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/MissingSource-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at MissingSource.cmake:1 \(add_library\): + Cannot find source file: + + missing.c + + Tried extensions( \.[A-Za-z+]+| + )* +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/MissingSource.cmake b/Tests/RunCMake/ObjectLibrary/MissingSource.cmake new file mode 100644 index 0000000..258eaed --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/MissingSource.cmake @@ -0,0 +1 @@ +add_library(A OBJECT missing.c) diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index 55db14d..42973f8 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -6,12 +6,12 @@ run_cmake(BadSourceExpression3) run_cmake(BadObjSource1) run_cmake(BadObjSource2) run_cmake(Export) -run_cmake(ExportLanguages) run_cmake(Import) run_cmake(Install) run_cmake(LinkObjLHS) run_cmake(LinkObjRHS1) run_cmake(LinkObjRHS2) +run_cmake(MissingSource) run_cmake(ObjWithObj) run_cmake(PostBuild) run_cmake(PreBuild) diff --git a/Tests/RunCMake/Syntax/BracketComment5.cmake b/Tests/RunCMake/Syntax/BracketComment5.cmake index bb6d9f3..dc9e6b4 100644 --- a/Tests/RunCMake/Syntax/BracketComment5.cmake +++ b/Tests/RunCMake/Syntax/BracketComment5.cmake @@ -2,5 +2,10 @@ message(FATAL_ERROR "This is commented out.") #]] #[[ message(FATAL_ERROR "This is commented out.") +#]]#[[ +message(FATAL_ERROR "This is commented out.") #]] #message(FATAL_ERROR "This is commented out.") +#[[ +message(FATAL_ERROR "This is commented out.") +#]]#message(FATAL_ERROR "This is commented out.") message(STATUS "The above FATAL_ERROR did not occur.") diff --git a/Tests/RunCMake/Syntax/Escape1-stderr.txt b/Tests/RunCMake/Syntax/Escape1-stderr.txt new file mode 100644 index 0000000..6601ce7 --- /dev/null +++ b/Tests/RunCMake/Syntax/Escape1-stderr.txt @@ -0,0 +1,3 @@ +^\\##\[\[#\]\]#\[\[\]\]x#\\" +\$\@\^\\; \(\)#\\" +\$\@\^; \(\)$ diff --git a/Tests/RunCMake/Syntax/Escape1.cmake b/Tests/RunCMake/Syntax/Escape1.cmake new file mode 100644 index 0000000..3bf801e --- /dev/null +++ b/Tests/RunCMake/Syntax/Escape1.cmake @@ -0,0 +1,3 @@ +message([[\#]] \#[[ \#]] "#[[]]" x#comment + "\#\\\"\n\$\@\^\;\ \t\(\)"#comment + \#\\\"\n\$\@\^\;\ \t\(\)) diff --git a/Tests/RunCMake/Syntax/ForEachBracket1-stderr.txt b/Tests/RunCMake/Syntax/ForEachBracket1-stderr.txt new file mode 100644 index 0000000..93c31cf --- /dev/null +++ b/Tests/RunCMake/Syntax/ForEachBracket1-stderr.txt @@ -0,0 +1,2 @@ +^\${x}:a +\${x}:b$ diff --git a/Tests/RunCMake/Syntax/ForEachBracket1.cmake b/Tests/RunCMake/Syntax/ForEachBracket1.cmake new file mode 100644 index 0000000..a55e21f --- /dev/null +++ b/Tests/RunCMake/Syntax/ForEachBracket1.cmake @@ -0,0 +1,3 @@ +foreach(x a b) + message([[${x}:]] "${x}") +endforeach() diff --git a/Tests/RunCMake/Syntax/FunctionBracket1-stderr.txt b/Tests/RunCMake/Syntax/FunctionBracket1-stderr.txt new file mode 100644 index 0000000..9ba6179 --- /dev/null +++ b/Tests/RunCMake/Syntax/FunctionBracket1-stderr.txt @@ -0,0 +1,2 @@ +^\${x},\${ARGN},\${ARGC},\${ARGV},\${ARGV0},\${ARGV1},\${ARGV2}:a,n,2,a;n,a,n, +\${x},\${ARGN},\${ARGC},\${ARGV},\${ARGV0},\${ARGV1},\${ARGV2}:b,n,2,b;n,b,n,$ diff --git a/Tests/RunCMake/Syntax/FunctionBracket1.cmake b/Tests/RunCMake/Syntax/FunctionBracket1.cmake new file mode 100644 index 0000000..8ed4f65 --- /dev/null +++ b/Tests/RunCMake/Syntax/FunctionBracket1.cmake @@ -0,0 +1,6 @@ +function(fun x) + message([[${x},${ARGN},${ARGC},${ARGV},${ARGV0},${ARGV1},${ARGV2}:]] + "${x},${ARGN},${ARGC},${ARGV},${ARGV0},${ARGV1},${ARGV2}") +endfunction(fun) +fun(a n) +fun(b n) diff --git a/Tests/RunCMake/Syntax/MacroBracket1-stderr.txt b/Tests/RunCMake/Syntax/MacroBracket1-stderr.txt new file mode 100644 index 0000000..9ba6179 --- /dev/null +++ b/Tests/RunCMake/Syntax/MacroBracket1-stderr.txt @@ -0,0 +1,2 @@ +^\${x},\${ARGN},\${ARGC},\${ARGV},\${ARGV0},\${ARGV1},\${ARGV2}:a,n,2,a;n,a,n, +\${x},\${ARGN},\${ARGC},\${ARGV},\${ARGV0},\${ARGV1},\${ARGV2}:b,n,2,b;n,b,n,$ diff --git a/Tests/RunCMake/Syntax/MacroBracket1.cmake b/Tests/RunCMake/Syntax/MacroBracket1.cmake new file mode 100644 index 0000000..ef6de20 --- /dev/null +++ b/Tests/RunCMake/Syntax/MacroBracket1.cmake @@ -0,0 +1,6 @@ +macro(mac x) + message([[${x},${ARGN},${ARGC},${ARGV},${ARGV0},${ARGV1},${ARGV2}:]] + "${x},${ARGN},${ARGC},${ARGV},${ARGV0},${ARGV1},${ARGV2}") +endmacro(mac) +mac(a n) +mac(b n) diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake index 2d49f76..5f05cfc 100644 --- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake +++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake @@ -12,6 +12,9 @@ run_cmake(CommandComments) run_cmake(CommandError0) run_cmake(CommandError1) run_cmake(CommandError2) +run_cmake(ForEachBracket1) +run_cmake(FunctionBracket1) +run_cmake(MacroBracket1) run_cmake(String0) run_cmake(String1) run_cmake(StringBackslash) @@ -39,6 +42,7 @@ run_cmake(BracketNoSpace2) run_cmake(BracketNoSpace3) run_cmake(BracketNoSpace4) run_cmake(BracketNoSpace5) +run_cmake(Escape1) run_cmake(ParenNoSpace0) run_cmake(ParenNoSpace1) run_cmake(ParenNoSpace2) diff --git a/Tests/RunCMake/build_command/BeforeProject-stderr.txt b/Tests/RunCMake/build_command/BeforeProject-stderr.txt index d3d7661..2ae0ed1 100644 --- a/Tests/RunCMake/build_command/BeforeProject-stderr.txt +++ b/Tests/RunCMake/build_command/BeforeProject-stderr.txt @@ -1,5 +1,7 @@ -CMake Error at BeforeProject.cmake:[0-9]+ \(build_command\): - build_command\(\) requires CMAKE_MAKE_PROGRAM to be defined. Call project\(\) - or enable_language\(\) first. +CMake Warning \(dev\) at BeforeProject.cmake:2 \(message\): + build_command\(\) returned: + + .*cmake.* --build \..* Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) + CMakeLists.txt:5 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/build_command/BeforeProject.cmake b/Tests/RunCMake/build_command/BeforeProject.cmake index 15788d1..a2175c4 100644 --- a/Tests/RunCMake/build_command/BeforeProject.cmake +++ b/Tests/RunCMake/build_command/BeforeProject.cmake @@ -1,2 +1,3 @@ build_command(MAKECOMMAND_DEFAULT_VALUE) +message(AUTHOR_WARNING "build_command() returned:\n ${MAKECOMMAND_DEFAULT_VALUE}") project(${RunCMake_TEST} NONE) diff --git a/Tests/RunCMake/build_command/ErrorsCommon.cmake b/Tests/RunCMake/build_command/ErrorsCommon.cmake index d224539..f007b88 100644 --- a/Tests/RunCMake/build_command/ErrorsCommon.cmake +++ b/Tests/RunCMake/build_command/ErrorsCommon.cmake @@ -37,9 +37,9 @@ build_command(cmd) message("4. cmd='${cmd}'") # Test the two-arg legacy signature: -build_command(legacy_cmd ${CMAKE_BUILD_TOOL}) +build_command(legacy_cmd ${CMAKE_MAKE_PROGRAM}) message("5. legacy_cmd='${legacy_cmd}'") -message(" CMAKE_BUILD_TOOL='${CMAKE_BUILD_TOOL}'") +message(" CMAKE_MAKE_PROGRAM='${CMAKE_MAKE_PROGRAM}'") # Test the optional KEYWORDs: build_command(cmd CONFIGURATION hoohaaConfig) diff --git a/Tests/RunCMake/cmake_minimum_required/Before24-stderr.txt b/Tests/RunCMake/cmake_minimum_required/Before24-stderr.txt new file mode 100644 index 0000000..4a6f16d --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Before24-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning \(dev\) at Before24.cmake:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/cmake_minimum_required/Before24.cmake b/Tests/RunCMake/cmake_minimum_required/Before24.cmake new file mode 100644 index 0000000..c28fc8a --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Before24.cmake @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 2.2) diff --git a/Tests/RunCMake/cmake_minimum_required/CMakeLists.txt b/Tests/RunCMake/cmake_minimum_required/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/cmake_minimum_required/CompatBefore24-result.txt b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt new file mode 100644 index 0000000..a874466 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less than + 2.4. This version of CMake only supports backwards compatibility with + CMake 2.4 or later. For compatibility with older versions please use any + CMake 2.8.x release or lower. diff --git a/Tests/RunCMake/cmake_minimum_required/CompatBefore24.cmake b/Tests/RunCMake/cmake_minimum_required/CompatBefore24.cmake new file mode 100644 index 0000000..ca0cb1d --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/CompatBefore24.cmake @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 2.4) +set(CMAKE_BACKWARDS_COMPATIBILITY 2.2) diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBefore24-result.txt b/Tests/RunCMake/cmake_minimum_required/PolicyBefore24-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBefore24-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBefore24-stderr.txt b/Tests/RunCMake/cmake_minimum_required/PolicyBefore24-stderr.txt new file mode 100644 index 0000000..840211a --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBefore24-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at PolicyBefore24.cmake:2 \(cmake_policy\): + Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. For + compatibility with older versions please use any CMake 2.8.x release or + lower. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/cmake_minimum_required/PolicyBefore24.cmake b/Tests/RunCMake/cmake_minimum_required/PolicyBefore24.cmake new file mode 100644 index 0000000..62d3836 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/PolicyBefore24.cmake @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 2.4) +cmake_policy(VERSION 2.2) diff --git a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake new file mode 100644 index 0000000..e4c65e3 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(Before24) +run_cmake(CompatBefore24) +run_cmake(PolicyBefore24) diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index 56caf68..7375888 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(invalid_name) run_cmake(target_commands) +run_cmake(no_shared_libs) diff --git a/Tests/RunCMake/interface_library/no_shared_libs-stderr.txt b/Tests/RunCMake/interface_library/no_shared_libs-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/interface_library/no_shared_libs-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/interface_library/no_shared_libs.cmake b/Tests/RunCMake/interface_library/no_shared_libs.cmake new file mode 100644 index 0000000..ed81878 --- /dev/null +++ b/Tests/RunCMake/interface_library/no_shared_libs.cmake @@ -0,0 +1,5 @@ + +cmake_minimum_required(VERSION 2.8.12.20131009) +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) +add_library(foo INTERFACE) +target_compile_definitions(foo INTERFACE FOO_DEFINE) diff --git a/Tests/RunCMake/no_install_prefix/CMakeLists.txt b/Tests/RunCMake/no_install_prefix/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake b/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake new file mode 100644 index 0000000..2923449 --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake @@ -0,0 +1,15 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix") + +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/prefix") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/prefix/NoPrefix") +file(WRITE "${RunCMake_BINARY_DIR}/prefix/NoPrefix/NoPrefixConfig.cmake" "") +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/prefix") +run_cmake(with_install_prefix) + +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/prefix") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/prefix/NoPrefix") +file(WRITE "${RunCMake_BINARY_DIR}/prefix/NoPrefix/NoPrefixConfig.cmake" "") +list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FIND_NO_INSTALL_PREFIX=1") +run_cmake(no_install_prefix) diff --git a/Tests/RunCMake/no_install_prefix/do_test.cmake b/Tests/RunCMake/no_install_prefix/do_test.cmake new file mode 100644 index 0000000..340c7dc --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/do_test.cmake @@ -0,0 +1,2 @@ + +find_package(NoPrefix REQUIRED) diff --git a/Tests/RunCMake/no_install_prefix/no_install_prefix-result.txt b/Tests/RunCMake/no_install_prefix/no_install_prefix-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/no_install_prefix-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt b/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt new file mode 100644 index 0000000..66c6241 --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt @@ -0,0 +1,18 @@ +CMake Error at do_test.cmake:2 \(find_package\): + By not providing "FindNoPrefix.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NoPrefix", + but CMake did not find one. + + Could not find a package configuration file provided by "NoPrefix" with any + of the following names: + + NoPrefixConfig.cmake + noprefix-config.cmake + + Add the installation prefix of "NoPrefix" to CMAKE_PREFIX_PATH or set + "NoPrefix_DIR" to a directory containing one of the above files. If + "NoPrefix" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + no_install_prefix.cmake:2 \(include\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/no_install_prefix/no_install_prefix.cmake b/Tests/RunCMake/no_install_prefix/no_install_prefix.cmake new file mode 100644 index 0000000..c7d28da --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/no_install_prefix.cmake @@ -0,0 +1,2 @@ + +include(do_test.cmake) diff --git a/Tests/RunCMake/no_install_prefix/with_install_prefix-result.txt b/Tests/RunCMake/no_install_prefix/with_install_prefix-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/with_install_prefix-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/no_install_prefix/with_install_prefix-stderr.txt b/Tests/RunCMake/no_install_prefix/with_install_prefix-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/with_install_prefix-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/no_install_prefix/with_install_prefix.cmake b/Tests/RunCMake/no_install_prefix/with_install_prefix.cmake new file mode 100644 index 0000000..c7d28da --- /dev/null +++ b/Tests/RunCMake/no_install_prefix/with_install_prefix.cmake @@ -0,0 +1,2 @@ + +include(do_test.cmake) diff --git a/Tests/RunCMake/set/CMakeLists.txt b/Tests/RunCMake/set/CMakeLists.txt new file mode 100644 index 0000000..4b3de84 --- /dev/null +++ b/Tests/RunCMake/set/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/set/PARENT_SCOPE-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/set/PARENT_SCOPE-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/set/PARENT_SCOPE.cmake b/Tests/RunCMake/set/PARENT_SCOPE.cmake new file mode 100644 index 0000000..9bd6bca --- /dev/null +++ b/Tests/RunCMake/set/PARENT_SCOPE.cmake @@ -0,0 +1,33 @@ +set(FOO ) +set(BAR "bar") +set(BAZ "baz") +set(BOO "boo") + +function(_parent_scope) + set(FOO "foo" PARENT_SCOPE) + set(BAR "" PARENT_SCOPE) + set(BAZ PARENT_SCOPE) + unset(BOO PARENT_SCOPE) +endfunction() + +_parent_scope() + +if(NOT DEFINED FOO) + message(FATAL_ERROR "FOO not defined") +elseif(NOT "${FOO}" STREQUAL "foo") + message(FATAL_ERROR "FOO should be \"foo\", not \"${FOO}\"") +endif() + +if(NOT DEFINED BAR) + message(FATAL_ERROR "BAR not defined") +elseif(NOT "${BAR}" STREQUAL "") + message(FATAL_ERROR "BAR should be an empty string, not \"${BAR}\"") +endif() + +if(DEFINED BAZ) + message(FATAL_ERROR "BAZ defined") +endif() + +if(DEFINED BOO) + message(FATAL_ERROR "BOO defined") +endif() diff --git a/Tests/RunCMake/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake new file mode 100644 index 0000000..5d036e3 --- /dev/null +++ b/Tests/RunCMake/set/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(PARENT_SCOPE) diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index b969bfd..cc3c3be 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -308,7 +308,7 @@ else() endif() if(CMAKE_CONFIGURATION_TYPES) - set(SI_CONFIG -C ${CMAKE_CFG_INTDIR}) + set(SI_CONFIG --config $<CONFIGURATION>) else() set(SI_CONFIG) endif() @@ -367,7 +367,9 @@ set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) include(InstallRequiredSystemLibraries) if(CTEST_TEST_CPACK) - set(PACKAGE_TARGET --build-target package) + set(package_command COMMAND + ${CMAKE_COMMAND} --build . --target package ${SI_CONFIG} + ) # Avoid settings that require the .zip file command line tools... # (just build an NSIS installer without component support) @@ -375,24 +377,19 @@ if(CTEST_TEST_CPACK) set(CPACK_BINARY_ZIP OFF) set(CPACK_MONOLITHIC_INSTALL ON) else() - set(PACKAGE_TARGET) + set(package_command) endif() include(CPack) +set(install_command COMMAND + ${CMAKE_COMMAND} --build . --target install ${SI_CONFIG} + ) + add_custom_command( TARGET ${install_target} POST_BUILD - COMMAND ${CMAKE_CTEST_COMMAND} - ARGS ${SI_CONFIG} - --build-and-test - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} - --build-generator ${CMAKE_GENERATOR} - --build-project ${PROJECT_NAME} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-noclean - --build-target install - ${PACKAGE_TARGET} + ${install_command} + ${package_command} COMMENT "Install Project" ) diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index b969bfd..cc3c3be 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -308,7 +308,7 @@ else() endif() if(CMAKE_CONFIGURATION_TYPES) - set(SI_CONFIG -C ${CMAKE_CFG_INTDIR}) + set(SI_CONFIG --config $<CONFIGURATION>) else() set(SI_CONFIG) endif() @@ -367,7 +367,9 @@ set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) include(InstallRequiredSystemLibraries) if(CTEST_TEST_CPACK) - set(PACKAGE_TARGET --build-target package) + set(package_command COMMAND + ${CMAKE_COMMAND} --build . --target package ${SI_CONFIG} + ) # Avoid settings that require the .zip file command line tools... # (just build an NSIS installer without component support) @@ -375,24 +377,19 @@ if(CTEST_TEST_CPACK) set(CPACK_BINARY_ZIP OFF) set(CPACK_MONOLITHIC_INSTALL ON) else() - set(PACKAGE_TARGET) + set(package_command) endif() include(CPack) +set(install_command COMMAND + ${CMAKE_COMMAND} --build . --target install ${SI_CONFIG} + ) + add_custom_command( TARGET ${install_target} POST_BUILD - COMMAND ${CMAKE_CTEST_COMMAND} - ARGS ${SI_CONFIG} - --build-and-test - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} - --build-generator ${CMAKE_GENERATOR} - --build-project ${PROJECT_NAME} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-noclean - --build-target install - ${PACKAGE_TARGET} + ${install_command} + ${package_command} COMMENT "Install Project" ) diff --git a/Tests/TestInstall.sh.in b/Tests/TestInstall.sh.in deleted file mode 100755 index 9535780..0000000 --- a/Tests/TestInstall.sh.in +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -CMAKE_COMMAND="@CMAKE_INSTALL_PREFIX@/bin/cmake" -CMake_SOURCE_DIR="@CMake_SOURCE_DIR@" -CMake_BINARY_DIR="@CMake_BINARY_DIR@" -CMAKE_INSTALL_PREFIX="@CMAKE_INSTALL_PREFIX@" -CMAKE_BUILD_TOOL="@CMAKE_BUILD_TOOL@" - -SOURCE_DIR="${CMake_SOURCE_DIR}/Tests/Simple" -BINARY_DIR="${CMake_BINARY_DIR}/Tests/TestInstall" - -install() -{ - echo "Erasing ${CMAKE_INSTALL_PREFIX}" && - ([ ! -d "${CMAKE_INSTALL_PREFIX}" ] || rm -rf "${CMAKE_INSTALL_PREFIX}") && - mkdir -p "${CMAKE_INSTALL_PREFIX}" && - echo "Running make install" && - ( - cd "${CMake_BINARY_DIR}" && - "${CMAKE_BUILD_TOOL}" install - ) -} - -setup() -{ - echo "Entering ${BINARY_DIR}" && - cd "${BINARY_DIR}" -} - -write_cache() -{ - install || return 1 - setup || return 1 - echo "Writing CMakeCache.txt" - ( - cat > CMakeCache.txt <<EOF -EOF - ) -} - -run_cmake() -{ - write_cache || return 1 - echo "Running CMake" - "${CMAKE_COMMAND}" "${SOURCE_DIR}" -} - -run_make() -{ - run_cmake || return 1 - echo "Running ${CMAKE_BUILD_TOOL}" - "${CMAKE_BUILD_TOOL}" -} - -run_test() -{ - echo "Running ${BINARY_DIR}/simple" - ( - "${BINARY_DIR}/simple" - ) -} - -run_make && run_test diff --git a/Tests/Wrapping/CMakeLists.txt b/Tests/Wrapping/CMakeLists.txt index 58e9c32..1dc7ffc 100644 --- a/Tests/Wrapping/CMakeLists.txt +++ b/Tests/Wrapping/CMakeLists.txt @@ -54,7 +54,7 @@ if (QT_FOUND AND QT_WRAP_UI) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/foo.ui.in - ${CMAKE_CURRENT_BINARY_DIR}/foo.ui IMMEDIATE) + ${CMAKE_CURRENT_BINARY_DIR}/foo.ui) set (QT_WRAP_UI "On") set (QT_UIC_EXE "${QT_UIC_EXECUTABLE}") @@ -102,6 +102,6 @@ add_dependencies(fakefluid Wrap) configure_file( ${Wrapping_SOURCE_DIR}/dummy ${Wrapping_BINARY_DIR}/gl.h - COPYONLY IMMEDIATE) + COPYONLY) use_mangled_mesa (${Wrapping_BINARY_DIR} ${Wrapping_BINARY_DIR}/mangled_mesa) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 16d9aac..5e0ef87 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -15,6 +15,7 @@ if(NOT CMake_SOURCE_DIR) set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) + include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) include(${CMake_SOURCE_DIR}/Source/CMakeVersionCompute.cmake) include(${CMake_SOURCE_DIR}/Source/CMakeInstallDestinations.cmake) unset(CMAKE_DATA_DIR) @@ -35,9 +36,18 @@ elseif(NOT SPHINX_EXECUTABLE) message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!") endif() +set(copyright_line_regex "^Copyright (2000-20[0-9][0-9] Kitware.*)") +file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line + LIMIT_COUNT 1 REGEX "${copyright_line_regex}") +if(copyright_line MATCHES "${copyright_line_regex}") + set(conf_copyright "${CMAKE_MATCH_1}") +else() + set(conf_copyright "Kitware, Inc.") +endif() + +set(conf_docs "${CMake_SOURCE_DIR}/Help") set(conf_path "${CMAKE_CURRENT_SOURCE_DIR}") -set(conf_copyright "2000-2013 Kitware, Inc.") -set(conf_version "${CMake_MAJOR_VERSION}.${CMake_MINOR_VERSION}.${CMake_PATCH_VERSION}") +set(conf_version "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") set(conf_release "${CMake_VERSION}") configure_file(conf.py.in conf.py @ONLY) diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in index 5dbdede..ef622fd 100644 --- a/Utilities/Sphinx/conf.py.in +++ b/Utilities/Sphinx/conf.py.in @@ -10,14 +10,17 @@ # See the License for more information. #============================================================================= import sys +import os +import re +import glob sys.path.insert(0, r'@conf_path@') source_suffix = '.rst' master_doc = 'index' + project = 'CMake' copyright = '@conf_copyright@' - version = '@conf_version@' # feature version release = '@conf_release@' # full version string @@ -26,24 +29,35 @@ primary_domain = 'cmake' exclude_patterns = [] extensions = ['cmake'] - -man_pages = [ - ('manual/cmake.1', 'cmake', 'CMake Command-Line Reference', [], 1), - ('manual/ccmake.1', 'ccmake', 'CMake Curses Dialog Command-Line Reference', [], 1), - ('manual/cmake-gui.1', 'cmake-gui', 'CMake GUI Command-Line Reference', [], 1), - ('manual/cpack.1', 'cpack', 'CPack Command-Line Reference', [], 1), - ('manual/ctest.1', 'ctest', 'CTest Command-Line Reference', [], 1), - ('manual/cmake-commands.7', 'cmake-commands', 'CMake Language Command Reference', [], 7), - ('manual/cmake-generators.7', 'cmake-generators', 'CMake Generators Reference', [], 7), - ('manual/cmake-modules.7', 'cmake-modules', 'CMake Modules Reference', [], 7), - ('manual/cmake-policies.7', 'cmake-policies', 'CMake Policies Reference', [], 7), - ('manual/cmake-properties.7', 'cmake-properties', 'CMake Properties Reference', [], 7), - ('manual/cmake-variables.7', 'cmake-variables', 'CMake Variables Reference', [], 7), - ('manual/cmake-generator-expressions.7', 'cmake-generator-expressions', 'CMake Generator Expressions', [], 7), - ('manual/cmake-developer.7', 'cmake-developer', 'CMake Developer Reference', [], 7), -] +templates_path = ['@conf_path@/templates'] + +cmake_manuals = sorted(glob.glob(r'@conf_docs@/manual/*.rst')) +cmake_manual_description = re.compile('^\.\. cmake-manual-description:(.*)$') +man_pages = [] +for fpath in cmake_manuals: + try: + name, sec, rst = os.path.basename(fpath).split('.') + desc = None + f = open(fpath, 'r') + for l in f: + m = cmake_manual_description.match(l) + if m: + desc = m.group(1).strip() + break + f.close() + if desc: + man_pages.append(('manual/%s.%s' % (name, sec), + name, desc, [], int(sec))) + else: + sys.stderr.write("ERROR: No cmake-manual-description in '%s'\n" % fpath) + except Exception, e: + sys.stderr.write("ERROR: %s\n" % str(e)) man_show_urls = False html_show_sourcelink = True html_static_path = ['@conf_path@/static'] html_style = 'cmake.css' +html_theme = 'default' +html_title = 'CMake %s Documentation' % release +html_short_title = '%s Documentation' % release +html_favicon = 'cmake-favicon.ico' diff --git a/Utilities/Sphinx/static/cmake-favicon.ico b/Utilities/Sphinx/static/cmake-favicon.ico Binary files differnew file mode 100644 index 0000000..fce8f92 --- /dev/null +++ b/Utilities/Sphinx/static/cmake-favicon.ico diff --git a/Utilities/Sphinx/static/cmake-logo-16.png b/Utilities/Sphinx/static/cmake-logo-16.png Binary files differnew file mode 100644 index 0000000..2039c25 --- /dev/null +++ b/Utilities/Sphinx/static/cmake-logo-16.png diff --git a/Utilities/Sphinx/templates/layout.html b/Utilities/Sphinx/templates/layout.html new file mode 100644 index 0000000..635ace3 --- /dev/null +++ b/Utilities/Sphinx/templates/layout.html @@ -0,0 +1,13 @@ +{% extends "!layout.html" %} +{% block rootrellink %} + <li> + <img src="{{ pathto('_static/cmake-logo-16.png', 1) }}" alt="" + style="vertical-align: middle; margin-top: -2px" /> + </li> + <li> + <a href="http://www.cmake.org/">CMake</a>{{ reldelim1 }} + </li> + <li> + <a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }} + </li> +{% endblock %} diff --git a/Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake b/Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake index d025769..cfcf47b 100644 --- a/Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake +++ b/Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake @@ -45,8 +45,7 @@ MACRO(CURL_CHECK_C_SOURCE_COMPILES SOURCE VAR) SET(src "${src}\nint main() { ${SOURCE} ; return 0; }") SET(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - IMMEDIATE) + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c") MESSAGE(STATUS "Performing Test ${message}") TRY_COMPILE(${VAR} ${CMAKE_BINARY_DIR} diff --git a/Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake b/Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake index 19681bd..1bd837a 100644 --- a/Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake +++ b/Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake @@ -45,8 +45,7 @@ MACRO(CURL_CHECK_C_SOURCE_RUNS SOURCE VAR) SET(src "${src}\nint main() { ${SOURCE} ; return 0; }") SET(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - IMMEDIATE) + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c") MESSAGE(STATUS "Performing Test ${message}") TRY_RUN(${VAR} ${VAR}_COMPILED ${CMAKE_BINARY_DIR} diff --git a/Utilities/cmlibarchive/build/cmake/CheckFuncs.cmake b/Utilities/cmlibarchive/build/cmake/CheckFuncs.cmake index 0670df9..84cc881 100644 --- a/Utilities/cmlibarchive/build/cmake/CheckFuncs.cmake +++ b/Utilities/cmlibarchive/build/cmake/CheckFuncs.cmake @@ -31,7 +31,7 @@ MACRO (CHECK_FUNCTION_EXISTS_GLIBC _FUNC _FUNCVAR) SET(CHECK_STUB_FUNC_1 "__stub_${_FUNC}") SET(CHECK_STUB_FUNC_2 "__stub___${_FUNC}") CONFIGURE_FILE( ${_selfdir_CheckFunctionExistsGlibc}/CheckFuncs_stub.c.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c IMMEDIATE) + ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c) TRY_COMPILE(__stub ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c @@ -28,7 +28,13 @@ cmake_install_dest_default() { cat "${cmake_source_dir}/Source/CMakeInstallDestinations.cmake" | sed -n ' /^ *set(CMAKE_'"${1}"'_DIR_DEFAULT.*) # '"${2}"'$/ { - s/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT *"\([^"]*\)").*$/\1/;p;q;} + s/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT *"\([^"]*\)").*$/\1/ + s/${CMake_VERSION_MAJOR}/'"${cmake_version_major}"'/ + s/${CMake_VERSION_MINOR}/'"${cmake_version_minor}"'/ + s/${CMake_VERSION_PATCH}/'"${cmake_version_patch}"'/ + p + q +} ' } @@ -56,6 +62,8 @@ if [ "$cmake_version_rc" != "" ]; then cmake_version="${cmake_version}-rc${cmake_version_rc}" fi +cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`" + cmake_data_dir_keyword="OTHER" cmake_doc_dir_keyword="OTHER" cmake_man_dir_keyword="OTHER" @@ -396,7 +404,7 @@ Directory and file names: # Display CMake bootstrap usage cmake_version_display() { - echo "CMake ${cmake_version}, Copyright 2000-2012 Kitware, Inc." + echo "CMake ${cmake_version}, ${cmake_copyright}" } # Display CMake bootstrap error, display the log file and exit |