diff options
125 files changed, 1563 insertions, 648 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 9c73647..433710b 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -79,7 +79,7 @@ set the path with these commands: (if (save-excursion (beginning-of-line) (let ((parse-end (point))) - (beginning-of-buffer) + (goto-char (point-min)) (nth 3 (parse-partial-sexp (point) parse-end)) ) ) @@ -186,7 +186,6 @@ the indentation. Otherwise it retains the same position on the line" (defun unscreamify-cmake-buffer () "Convert all CMake commands to lowercase in buffer." (interactive) - (setq save-point (point)) (goto-char (point-min)) (while (re-search-forward "^\\([ \t]*\\)\\(\\w+\\)\\([ \t]*(\\)" nil t) (replace-match @@ -195,7 +194,6 @@ the indentation. Otherwise it retains the same position on the line" (downcase (match-string 2)) (match-string 3)) t)) - (goto-char save-point) ) ;------------------------------------------------------------------------------ @@ -268,36 +266,21 @@ the indentation. Otherwise it retains the same position on the line" ;;;###autoload -(defun cmake-command-run (type &optional topic) +(defun cmake-command-run (type &optional topic buffer) "Runs the command cmake with the arguments specified. The optional argument topic will be appended to the argument list." (interactive "s") - (let* ((bufname (concat "*CMake" type (if topic "-") topic "*")) - (buffer (get-buffer bufname)) + (let* ((bufname (if buffer buffer (concat "*CMake" type (if topic "-") topic "*"))) + (buffer (if (get-buffer bufname) (get-buffer bufname) (generate-new-buffer bufname))) + (command (concat cmake-mode-cmake-executable " " type " " topic)) + ;; Turn of resizing of mini-windows for shell-command. + (resize-mini-windows nil) ) - (if buffer - (display-buffer buffer 'not-this-window) - ;; Buffer doesn't exist. Create it and fill it - (setq buffer (generate-new-buffer bufname)) - (setq command (concat cmake-mode-cmake-executable " " type " " topic)) - (message "Running %s" command) - ;; We don't want the contents of the shell-command running to the - ;; minibuffer, so turn it off. A value of nil means don't automatically - ;; resize mini-windows. - (setq resize-mini-windows-save resize-mini-windows) - (setq resize-mini-windows nil) - (shell-command command buffer) - ;; Save the original window, so that we can come back to it later. - ;; save-excursion doesn't seem to work for this. - (setq window (selected-window)) - ;; We need to select it so that we can apply special modes to it + (shell-command command buffer) + (save-selected-window (select-window (display-buffer buffer 'not-this-window)) (cmake-mode) - (toggle-read-only t) - ;; Restore the original window - (select-window window) - (setq resize-mini-windows resize-mini-windows-save) - ) + (toggle-read-only t)) ) ) @@ -309,32 +292,42 @@ optional argument topic will be appended to the argument list." ) (defvar cmake-help-command-history nil "Topic read history.") +(defvar cmake-help-commands '() "List of available topics for --help-command.") +(defun cmake-command-list-as-list () + "Run cmake --help-command-list and return a list where each element is a cmake command." + (let ((temp-buffer-name "*CMake Commands Temporary*")) + (save-window-excursion + (cmake-command-run "--help-command-list" nil temp-buffer-name) + (with-current-buffer temp-buffer-name + (cdr (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n" t))))) + ) (require 'thingatpt) ;;;###autoload -(defun cmake-get-topic (type) +(defun cmake-get-command () "Gets the topic from the minibuffer input. The default is the word the cursor is on." - (interactive) (let* ((default-entry (word-at-point)) - (input (read-string - (format "CMake %s (default %s): " type default-entry) ; prompt - nil ; initial input + (input (completing-read + "CMake command: " ; prompt + ((lambda () + (if cmake-help-commands cmake-help-commands + (setq cmake-help-commands (cmake-command-list-as-list))))) ; completions + nil ; predicate + t ; require-match + default-entry ; initial-input 'cmake-help-command-history ; command history - default-entry ; default-value ))) (if (string= input "") (error "No argument given") input)) ) - ;;;###autoload (defun cmake-help-command () "Prints out the help message corresponding to the command the cursor is on." (interactive) - (setq command (cmake-get-topic "command")) - (cmake-command-run "--help-command" (downcase command)) - ) + (cmake-command-run "--help-command" (downcase (cmake-get-command)) "*CMake Help*")) + ;;;###autoload (progn diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..76561b9 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,34 @@ +Contributing to CMake +********************* + +Community +========= + +CMake is maintained by `Kitware, Inc.`_ and developed in +collaboration with a productive community of contributors. + +.. _`Kitware, Inc.`: http://www.kitware.com + +The preferred entry point for new contributors is the mailing list. +Please subscribe and post to the `CMake Developers List`_ to offer +contributions. Regular and productive contributors may be invited +to gain direct push access. + +.. _`CMake Developers List`: http://www.cmake.org/mailman/listinfo/cmake-developers + +Patches +======= + +Please base all new work on the ``master`` branch. Then use +``git format-patch`` to produce patches suitable to post to +the mailing list. + +License +======= + +We do not require any formal copyright assignment or contributor license +agreement. Any contributions intentionally sent upstream are presumed +to be offerred under terms of the OSI-approved BSD 3-clause License. +See `Copyright.txt`_ for details. + +.. _`Copyright.txt`: Copyright.txt diff --git a/ChangeLog.manual b/ChangeLog.manual index 5d2dc8b..b389d8b 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,20 @@ +Changes in CMake 2.8.12.2 (since 2.8.12.1) +------------------------------------------ +Brad King (4): + VS: Map /Fd to ProgramDataBaseFileName for VS 7,8,9 (#14577) + Replace <OBJECT_DIR> rule placeholder consistently (#14667) + VS: Convert include path to backslashes for VS >= 10 + Revert "Ninja: Track configured files so we can regenerate them." + +Rolf Eike Beer (1): + FindOpenMP: fix detecting compilers that do not need any special flag (#14567) + +Ruslan Baratov (1): + Xcode: Fix storyboard view + +Ted Kremenek (1): + CMakeDetermineCompilerId: Fix compiler line match for Xcode 5.1 + Changes in CMake 2.8.12.1 (since 2.8.12) ---------------------------------------- Brad King (9): diff --git a/Help/command/project.rst b/Help/command/project.rst index 9b9f93f..c601a01 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -1,27 +1,57 @@ project ------- -Set a name for the entire project. +Set a name, version, and enable languages for the entire project. -:: +.. code-block:: cmake - project(<projectname> [languageName1 languageName2 ... ] ) + project(<PROJECT-NAME> [LANGUAGES] [<language-name>...]) + project(<PROJECT-NAME> + [VERSION <major>[.<minor>[.<patch>[.<tweak>]]]] + [LANGUAGES <language-name>...]) -Sets the name of the project. Additionally this sets the variables -<projectName>_BINARY_DIR and <projectName>_SOURCE_DIR to the -respective values. +Sets the name of the project and stores the name in the +:variable:`PROJECT_NAME` variable. Additionally this sets variables + +* :variable:`PROJECT_SOURCE_DIR`, + :variable:`<PROJECT-NAME>_SOURCE_DIR` +* :variable:`PROJECT_BINARY_DIR`, + :variable:`<PROJECT-NAME>_BINARY_DIR` + +If ``VERSION`` is specified, given components must be non-negative integers. +If ``VERSION`` is not specified, the default version is the empty string. +The ``VERSION`` option may not be used unless policy :policy:`CMP0048` is +set to ``NEW``. + +The :command:`project()` command stores the version number and its components +in variables + +* :variable:`PROJECT_VERSION`, + :variable:`<PROJECT-NAME>_VERSION` +* :variable:`PROJECT_VERSION_MAJOR`, + :variable:`<PROJECT-NAME>_VERSION_MAJOR` +* :variable:`PROJECT_VERSION_MINOR`, + :variable:`<PROJECT-NAME>_VERSION_MINOR` +* :variable:`PROJECT_VERSION_PATCH`, + :variable:`<PROJECT-NAME>_VERSION_PATCH` +* :variable:`PROJECT_VERSION_TWEAK`, + :variable:`<PROJECT-NAME>_VERSION_TWEAK` + +Variables corresponding to unspecified versions are set to the empty string +(if policy :policy:`CMP0048` is set to ``NEW``). Optionally you can specify which languages your project supports. -Example languages are CXX (i.e. C++), C, Fortran, etc. By default C -and CXX are enabled. E.g. if you do not have a C++ compiler, you can -disable the check for it by explicitly listing the languages you want -to support, e.g. C. By using the special language "NONE" all checks -for any language can be disabled. If a variable exists called -CMAKE_PROJECT_<projectName>_INCLUDE, the file pointed to by that -variable will be included as the last step of the project command. - -The top-level CMakeLists.txt file for a project must contain a -literal, direct call to the project() command; loading one through the -include() command is not sufficient. If no such call exists CMake -will implicitly add one to the top that enables the default languages -(C and CXX). +Example languages are ``C``, ``CXX`` (i.e. C++), ``Fortran``, etc. +By default ``C`` and ``CXX`` are enabled if no language options are +given. Specify language ``NONE``, or use the ``LANGUAGES`` keyword +and list no languages, to skip enabling any languages. + +If a variable exists called :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`, +the file pointed to by that variable will be included as the last step of the +project command. + +The top-level ``CMakeLists.txt`` file for a project must contain a +literal, direct call to the :command:`project` command; loading one +through the :command:`include` command is not sufficient. If no such +call exists CMake will implicitly add one to the top that enables the +default languages (``C`` and ``CXX``). diff --git a/Help/index.rst b/Help/index.rst index 551db75..7fce223 100644 --- a/Help/index.rst +++ b/Help/index.rst @@ -35,6 +35,7 @@ Reference Manuals /manual/cmake-packages.7 /manual/cmake-policies.7 /manual/cmake-properties.7 + /manual/cmake-qt.7 /manual/cmake-toolchains.7 /manual/cmake-variables.7 diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index d5fbc98..d169e1a 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -33,17 +33,19 @@ The ``at()`` member function of ``std::vector`` may not be used. Use int i1 = someVec.at(5); // Wrong int i2 = someVec[5]; // Ok -std::string::append -------------------- +std::string::append and std::string::clear +------------------------------------------ -The ``append()`` member function of ``std::string`` may not be used. Use -``operator+=`` instead: +The ``append()`` and ``clear()`` member functions of ``std::string`` may not +be used. Use ``operator+=`` and ``operator=`` instead: .. code-block:: c++ std::string stringBuilder; stringBuilder.append("chunk"); // Wrong + stringBuilder.clear(); // Wrong stringBuilder += "chunk"; // Ok + stringBuilder = ""; // Ok std::set const iterators ------------------------ @@ -124,6 +126,29 @@ A loop must be used instead: theVector.push_back(*li); } +std::set::insert +---------------- + +Use of ``std::set::insert`` is not allowed with any source container: + +.. code-block:: c++ + + std::set<cmTarget*> theSet; + theSet.insert(targets.begin(), targets.end()); // Wrong + +A loop must be used instead: + +.. code-block:: c++ + + ConstIterator it = targets.begin(); + const ConstIterator end = targets.end(); + for ( ; it != end; ++it) + { + theSet.insert(*it); + } + +.. MSVC6, SunCC 5.9 + Template Parameter Defaults --------------------------- diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 02f596b..5a9ec95 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -99,3 +99,4 @@ All Policies /policy/CMP0045 /policy/CMP0046 /policy/CMP0047 + /policy/CMP0048 diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst new file mode 100644 index 0000000..eff73b3 --- /dev/null +++ b/Help/manual/cmake-qt.7.rst @@ -0,0 +1,184 @@ +.. cmake-manual-description: CMake Qt Features Reference + +cmake-qt(7) +*********** + +.. only:: html or latex + + .. contents:: + +Introduction +============ + +CMake can find and use Qt 4 and Qt 5 libraries. The Qt 4 libraries are found +by the :module:`FindQt4` find-module shipped with CMake, whereas the +Qt 5 libraries are found using "Config-file Packages" shipped with Qt 5. See +:manual:`cmake-packages(7)` for more information about CMake packages, and +see `the Qt cmake manual <http://qt-project.org/doc/qt-5/cmake-manual.html>`_ +for your Qt version. + +Qt 4 and Qt 5 may be used together in the same +:manual:`CMake buildsystem <cmake-buildsystem(7)>`: + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) + + project(Qt4And5) + + set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + + find_package(Qt5Widgets REQUIRED) + add_executable(publisher publisher.cpp) + target_link_libraries(publisher Qt5::Widgets Qt5::DBus) + + find_package(Qt4 REQUIRED) + add_executable(subscriber subscriber.cpp) + target_link_libraries(subscriber Qt4::QtGui Qt4::QtDBus) + +A CMake target may not link to both Qt 4 and Qt 5. A diagnostic is issued if +this is attempted or results from transitive target dependency evaluation. + +Qt Build Tools +============== + +Qt relies on some bundled tools for code generation, such as ``moc`` for +meta-object code generation, ``uic`` for widget layout and population, +and ``rcc`` for virtual filesystem content generation. These tools may be +automatically invoked by :manual:`cmake(1)` if the appropriate conditions +are met. The automatic tool invocation may be used with both Qt 4 and Qt 5. + +The tools are executed as part of a synthesized custom target generated by +CMake. Target dependencies may be added to that custom target by adding them +to the :prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property. + +AUTOMOC +''''''' + +The :prop_tgt:`AUTOMOC` target property controls whether :manual:`cmake(1)` +inspects the C++ files in the target to determine if they require ``moc`` to +be run, and to create rules to execute ``moc`` at the appropriate time. + +If a ``Q_OBJECT`` or ``Q_GADGET`` macro is found in a header file, ``moc`` +will be run on the file. The result will be put into a file named according +to ``moc_<basename>.cpp``. If the macro is found in a C++ implementation +file, the moc output will be put into a file named according to +``<basename>.moc``, following the Qt conventions. The ``moc file`` may be +included by the user in the C++ implementation file with a preprocessor +``#include``. If it is not so included, it will be added to a separate file +which is compiled into the target. + +The ``moc`` command line will consume the :prop_tgt:`COMPILE_DEFINITIONS` and +:prop_tgt:`INCLUDE_DIRECTORIES` target properties from the target it is being +invoked for, and for the appropriate build configuration. + +Generated ``moc_*.cpp`` and ``*.moc`` files are placed in the build directory +so it is convenient to set the :variable:`CMAKE_INCLUDE_CURRENT_DIR` +variable. The :prop_tgt:`AUTOMOC` target property may be pre-set for all +following targets by setting the :variable:`CMAKE_AUTOMOC` variable. The +:prop_tgt:`AUTOMOC_MOC_OPTIONS` target property may be populated to set +options to pass to ``moc``. The :variable:`CMAKE_AUTOMOC_MOC_OPTIONS` +variable may be populated to pre-set the options for all following targets. + +AUTOUIC +''''''' + +The :prop_tgt:`AUTOUIC` target property controls whether :manual:`cmake(1)` +inspects the C++ files in the target to determine if they require ``uic`` to +be run, and to create rules to execute ``uic`` at the appropriate time. + +If a preprocessor ``#include`` directive is found which matches +``ui_<basename>.h``, and a ``<basename>.ui`` file exists, then ``uic`` will +be executed to generate the appropriate file. + +Generated ``ui_*.h`` files are placed in the build directory so it is +convenient to set the :variable:`CMAKE_INCLUDE_CURRENT_DIR` variable. The +:prop_tgt:`AUTOUIC` target property may be pre-set for all following targets +by setting the :variable:`CMAKE_AUTOUIC` variable. The +:prop_tgt:`AUTOUIC_OPTIONS` target property may be populated to set options +to pass to ``uic``. The :variable:`CMAKE_AUTOUIC_OPTIONS` variable may be +populated to pre-set the options for all following targets. The +:prop_sf:`AUTOUIC_OPTIONS` source file property may be set on the +``<basename>.ui`` file to set particular options for the file. This +overrides options from the :prop_tgt:`AUTOUIC_OPTIONS` target property. + +A target may populate the :prop_tgt:`INTERFACE_AUTOUIC_OPTIONS` target +property with options that should be used when invoking ``uic``. This must be +consistent with the :prop_tgt:`AUTOUIC_OPTIONS` target property content of the +depender target. The :variable:`CMAKE_DEBUG_TARGET_PROPERTIES` variable may +be used to track the origin target of such +:prop_tgt:`INTERFACE_AUTOUIC_OPTIONS`. This means that a library which +provides an alternative translation system for Qt may specify options which +should be used when running ``uic``: + +.. code-block:: cmake + + add_library(KI18n klocalizedstring.cpp) + target_link_libraries(KI18n Qt5::Core) + + # KI18n uses the tr2i18n() function instead of tr(). That function is + # declared in the klocalizedstring.h header. + set(autouic_options + -tr tr2i18n + -include klocalizedstring.h + ) + + set_property(TARGET KI18n APPEND PROPERTY + INTERFACE_AUTOUIC_OPTIONS ${autouic_options} + ) + +A consuming project linking to the target exported from upstream automatically +uses appropriate options when ``uic`` is run by :prop_tgt:`AUTOUIC`, as a +result of linking with the :prop_tgt:`IMPORTED` target: + +.. code-block:: cmake + + set(CMAKE_AUTOUIC ON) + # Uses a libwidget.ui file: + add_library(LibWidget libwidget.cpp) + target_link_libraries(LibWidget + KF5::KI18n + Qt5::Widgets + ) + + +AUTORCC +''''''' + +The :prop_tgt:`AUTORCC` target property controls whether :manual:`cmake(1)` +creates rules to execute ``rcc`` at the appropriate time on source files +which have the suffix ``.qrc``. + +.. code-block:: cmake + + add_executable(myexe main.cpp resource_file.qrc) + +The :prop_tgt:`AUTORCC` target property may be pre-set for all following targets +by setting the :variable:`CMAKE_AUTORCC` variable. The +:prop_tgt:`AUTORCC_OPTIONS` target property may be populated to set options +to pass to ``rcc``. The :variable:`CMAKE_AUTORCC_OPTIONS` variable may be +populated to pre-set the options for all following targets. The +:prop_sf:`AUTORCC_OPTIONS` source file property may be set on the +``<name>.qrc`` file to set particular options for the file. This +overrides options from the :prop_tgt:`AUTORCC_OPTIONS` target property. + +qtmain.lib on Windows +===================== + +The Qt 4 and 5 :prop_tgt:`IMPORTED` targets for the QtGui libraries specify +that the qtmain.lib static library shipped with Qt will be linked by all +dependent executables which have the :prop_tgt:`WIN32_EXECUTABLE` enabled. + +Do disable this behavior, enable the ``Qt5_NO_LINK_QTMAIN`` target property for +Qt 5 based targets or ``QT4_NO_LINK_QTMAIN`` target property for Qt 4 based +targets. + +.. code-block:: cmake + + add_executable(myexe WIN32 main.cpp) + target_link_libraries(myexe Qt4::QtGui) + + add_executable(myexe_no_qtmain WIN32 main_no_qtmain.cpp) + set_property(TARGET main_no_qtmain PROPERTY QT4_NO_LINK_QTMAIN ON) + target_link_libraries(main_no_qtmain Qt4::QtGui) diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 832bd99..c4ae193 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -79,7 +79,17 @@ Variables that Provide Information /variable/PROJECT-NAME_BINARY_DIR /variable/PROJECT_NAME /variable/PROJECT-NAME_SOURCE_DIR + /variable/PROJECT-NAME_VERSION + /variable/PROJECT-NAME_VERSION_MAJOR + /variable/PROJECT-NAME_VERSION_MINOR + /variable/PROJECT-NAME_VERSION_PATCH + /variable/PROJECT-NAME_VERSION_TWEAK /variable/PROJECT_SOURCE_DIR + /variable/PROJECT_VERSION + /variable/PROJECT_VERSION_MAJOR + /variable/PROJECT_VERSION_MINOR + /variable/PROJECT_VERSION_PATCH + /variable/PROJECT_VERSION_TWEAK Variables that Change Behavior ============================== @@ -121,6 +131,7 @@ Variables that Change Behavior /variable/CMAKE_POLICY_DEFAULT_CMPNNNN /variable/CMAKE_PREFIX_PATH /variable/CMAKE_PROGRAM_PATH + /variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE /variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY /variable/CMAKE_STAGING_PREFIX /variable/CMAKE_SYSTEM_IGNORE_PATH diff --git a/Help/policy/CMP0048.rst b/Help/policy/CMP0048.rst new file mode 100644 index 0000000..ae51329 --- /dev/null +++ b/Help/policy/CMP0048.rst @@ -0,0 +1,22 @@ +CMP0048 +------- + +The :command:`project` command manages VERSION variables. + +CMake version 3.0.0 introduced the ``VERSION`` option of the :command:`project` +command to specify a project version as well as the name. In order to keep +:variable:`PROJECT_VERSION` and related variables consistent with variable +:variable:`PROJECT_NAME` it is necessary to set the VERSION variables +to the empty string when no ``VERSION`` is given to :command:`project`. +However, this can change behavior for existing projects that set VERSION +variables themselves since :command:`project` may now clear them. +This policy controls the behavior for compatibility with such projects. + +The OLD behavior for this policy is to leave VERSION variables untouched. +The NEW behavior for this policy is to set VERSION as documented by the +:command:`project` command. + +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/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst new file mode 100644 index 0000000..ba9df5a --- /dev/null +++ b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst @@ -0,0 +1,6 @@ +CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE +------------------------------------ + +A CMake language file or module to be included by the :command:`project` +command. This is is intended for injecting custom code into project +builds without modifying their source. diff --git a/Help/variable/PROJECT-NAME_BINARY_DIR.rst b/Help/variable/PROJECT-NAME_BINARY_DIR.rst index a19940f..49bc558 100644 --- a/Help/variable/PROJECT-NAME_BINARY_DIR.rst +++ b/Help/variable/PROJECT-NAME_BINARY_DIR.rst @@ -3,6 +3,6 @@ Top level binary directory for the named project. -A variable is created with the name used in the PROJECT command, and -is the binary directory for the project. This can be useful when -SUBDIR is used to connect several projects. +A variable is created with the name used in the :command:`project` command, +and is the binary directory for the project. This can be useful when +:command:`add_subdirectory` is used to connect several projects. diff --git a/Help/variable/PROJECT-NAME_SOURCE_DIR.rst b/Help/variable/PROJECT-NAME_SOURCE_DIR.rst index f2f5caf..4df3e22 100644 --- a/Help/variable/PROJECT-NAME_SOURCE_DIR.rst +++ b/Help/variable/PROJECT-NAME_SOURCE_DIR.rst @@ -3,6 +3,6 @@ Top level source directory for the named project. -A variable is created with the name used in the PROJECT command, and -is the source directory for the project. This can be useful when -add_subdirectory is used to connect several projects. +A variable is created with the name used in the :command:`project` command, +and is the source directory for the project. This can be useful when +:command:`add_subdirectory` is used to connect several projects. diff --git a/Help/variable/PROJECT-NAME_VERSION.rst b/Help/variable/PROJECT-NAME_VERSION.rst new file mode 100644 index 0000000..0f6ed51 --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION.rst @@ -0,0 +1,11 @@ +<PROJECT-NAME>_VERSION +---------------------- + +Value given to the ``VERSION`` option of the most recent call to the +:command:`project` command with project name ``<PROJECT-NAME>``, if any. + +See also the component-wise version variables +:variable:`<PROJECT-NAME>_VERSION_MAJOR`, +:variable:`<PROJECT-NAME>_VERSION_MINOR`, +:variable:`<PROJECT-NAME>_VERSION_PATCH`, and +:variable:`<PROJECT-NAME>_VERSION_TWEAK`. diff --git a/Help/variable/PROJECT-NAME_VERSION_MAJOR.rst b/Help/variable/PROJECT-NAME_VERSION_MAJOR.rst new file mode 100644 index 0000000..9e2d755 --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_MAJOR.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_MAJOR +---------------------------- + +First version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT-NAME_VERSION_MINOR.rst b/Help/variable/PROJECT-NAME_VERSION_MINOR.rst new file mode 100644 index 0000000..fa2cdab --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_MINOR.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_MINOR +---------------------------- + +Second version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT-NAME_VERSION_PATCH.rst b/Help/variable/PROJECT-NAME_VERSION_PATCH.rst new file mode 100644 index 0000000..85b5e6b --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_PATCH.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_PATCH +---------------------------- + +Third version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT-NAME_VERSION_TWEAK.rst b/Help/variable/PROJECT-NAME_VERSION_TWEAK.rst new file mode 100644 index 0000000..65c4044 --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_TWEAK.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_TWEAK +---------------------------- + +Fourth version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_BINARY_DIR.rst b/Help/variable/PROJECT_BINARY_DIR.rst index e506bdd..09e9ef2 100644 --- a/Help/variable/PROJECT_BINARY_DIR.rst +++ b/Help/variable/PROJECT_BINARY_DIR.rst @@ -3,4 +3,4 @@ PROJECT_BINARY_DIR Full path to build directory for project. -This is the binary directory of the most recent PROJECT command. +This is the binary directory of the most recent :command:`project` command. diff --git a/Help/variable/PROJECT_NAME.rst b/Help/variable/PROJECT_NAME.rst index 7559af6..61aa8bc 100644 --- a/Help/variable/PROJECT_NAME.rst +++ b/Help/variable/PROJECT_NAME.rst @@ -3,4 +3,4 @@ PROJECT_NAME Name of the project given to the project command. -This is the name given to the most recent PROJECT command. +This is the name given to the most recent :command:`project` command. diff --git a/Help/variable/PROJECT_SOURCE_DIR.rst b/Help/variable/PROJECT_SOURCE_DIR.rst index c9ba132..27f2838 100644 --- a/Help/variable/PROJECT_SOURCE_DIR.rst +++ b/Help/variable/PROJECT_SOURCE_DIR.rst @@ -3,4 +3,4 @@ PROJECT_SOURCE_DIR Top level source directory for the current project. -This is the source directory of the most recent PROJECT command. +This is the source directory of the most recent :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION.rst b/Help/variable/PROJECT_VERSION.rst new file mode 100644 index 0000000..234558d --- /dev/null +++ b/Help/variable/PROJECT_VERSION.rst @@ -0,0 +1,11 @@ +PROJECT_VERSION +--------------- + +Value given to the ``VERSION`` option of the most recent call to the +:command:`project` command, if any. + +See also the component-wise version variables +:variable:`PROJECT_VERSION_MAJOR`, +:variable:`PROJECT_VERSION_MINOR`, +:variable:`PROJECT_VERSION_PATCH`, and +:variable:`PROJECT_VERSION_TWEAK`. diff --git a/Help/variable/PROJECT_VERSION_MAJOR.rst b/Help/variable/PROJECT_VERSION_MAJOR.rst new file mode 100644 index 0000000..4b6072c --- /dev/null +++ b/Help/variable/PROJECT_VERSION_MAJOR.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_MAJOR +--------------------- + +First version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION_MINOR.rst b/Help/variable/PROJECT_VERSION_MINOR.rst new file mode 100644 index 0000000..5f31220 --- /dev/null +++ b/Help/variable/PROJECT_VERSION_MINOR.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_MINOR +--------------------- + +Second version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION_PATCH.rst b/Help/variable/PROJECT_VERSION_PATCH.rst new file mode 100644 index 0000000..ac72ec0 --- /dev/null +++ b/Help/variable/PROJECT_VERSION_PATCH.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_PATCH +--------------------- + +Third version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION_TWEAK.rst b/Help/variable/PROJECT_VERSION_TWEAK.rst new file mode 100644 index 0000000..d7f96d6 --- /dev/null +++ b/Help/variable/PROJECT_VERSION_TWEAK.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_TWEAK +--------------------- + +Fourth version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Modules/CMakeFindJavaCommon.cmake b/Modules/CMakeFindJavaCommon.cmake new file mode 100644 index 0000000..fcf0389 --- /dev/null +++ b/Modules/CMakeFindJavaCommon.cmake @@ -0,0 +1,41 @@ + +#============================================================================= +# Copyright 2013-2014 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.) + +# Do not include this module directly from code outside CMake! +set(_JAVA_HOME "") +if(JAVA_HOME AND IS_DIRECTORY "${JAVA_HOME}") + set(_JAVA_HOME "${JAVA_HOME}") + set(_JAVA_HOME_EXPLICIT 1) +else() + set(_ENV_JAVA_HOME "") + if(DEFINED ENV{JAVA_HOME}) + file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _ENV_JAVA_HOME) + endif() + if(_ENV_JAVA_HOME AND IS_DIRECTORY "${_ENV_JAVA_HOME}") + set(_JAVA_HOME "${_ENV_JAVA_HOME}") + set(_JAVA_HOME_EXPLICIT 1) + else() + set(_CMD_JAVA_HOME "") + if(APPLE AND EXISTS /usr/libexec/java_home) + execute_process(COMMAND /usr/libexec/java_home + OUTPUT_VARIABLE _CMD_JAVA_HOME OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}") + set(_JAVA_HOME "${_CMD_JAVA_HOME}") + set(_JAVA_HOME_EXPLICIT 0) + endif() + unset(_CMD_JAVA_HOME) + endif() + unset(_ENV_JAVA_HOME) +endif() diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index f388fe0..473bbe5 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -99,7 +99,7 @@ # # :: # -# WRITE_BASIC_PACKAGE_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion|ExactVersion) ) +# WRITE_BASIC_PACKAGE_VERSION_FILE( filename [VERSION major.minor.patch] COMPATIBILITY (AnyNewerVersion|SameMajorVersion|ExactVersion) ) # # # @@ -112,6 +112,9 @@ # filename is the output filename, it should be in the build tree. # major.minor.patch is the version number of the project to be installed # +# If no ``VERSION`` is given, the :variable:`PROJECT_VERSION` variable +# is used. If this hasn't been set, it errors out. +# # The COMPATIBILITY mode AnyNewerVersion means that the installed # package version will be considered compatible if it is newer or # exactly the same as the requested version. This mode should be used diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 63f1180..0df51a8 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -30,6 +30,7 @@ # [SVN_TRUST_CERT 1 ] # Trust the Subversion server site certificate # [GIT_REPOSITORY url] # URL of git repo # [GIT_TAG tag] # Git branch name, commit id or tag +# [GIT_SUBMODULES modules...] # Git submodules that shall be updated, all if empty # [HG_REPOSITORY url] # URL of mercurial repo # [HG_TAG tag] # Mercurial branch name, commit id or tag # [URL /.../src.tgz] # Full path or URL of source @@ -289,7 +290,7 @@ define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED ) -function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir gitclone_infofile gitclone_stampfile) +function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_submodules src_name work_dir gitclone_infofile gitclone_stampfile) file(WRITE ${script_filename} "if(\"${git_tag}\" STREQUAL \"\") message(FATAL_ERROR \"Tag for git checkout should not be empty.\") @@ -352,7 +353,7 @@ if(error_code) endif() execute_process( - COMMAND \"${git_EXECUTABLE}\" submodule update --recursive + COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) @@ -440,7 +441,7 @@ endif() endfunction() -function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_repository work_dir) +function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_submodules git_repository work_dir) file(WRITE ${script_filename} "if(\"${git_tag}\" STREQUAL \"\") message(FATAL_ERROR \"Tag for git checkout should not be empty.\") @@ -499,7 +500,7 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\" endif() execute_process( - COMMAND \"${git_EXECUTABLE}\" submodule update --recursive + COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) @@ -585,13 +586,30 @@ message(STATUS \"downloading... done\") endfunction() -function(_ep_write_verifyfile_script script_filename local hash) +function(_ep_write_verifyfile_script script_filename local hash retries download_script) if("${hash}" MATCHES "${_ep_hash_regex}") set(algo "${CMAKE_MATCH_1}") string(TOLOWER "${CMAKE_MATCH_2}" expect_value) set(script_content "set(expect_value \"${expect_value}\") -file(${algo} \"\${file}\" actual_value) -if(\"\${actual_value}\" STREQUAL \"\${expect_value}\") +set(attempt 0) +set(succeeded 0) +while(\${attempt} LESS ${retries} OR \${attempt} EQUAL ${retries} AND NOT \${succeeded}) + file(${algo} \"\${file}\" actual_value) + if(\"\${actual_value}\" STREQUAL \"\${expect_value}\") + set(succeeded 1) + elseif(\${attempt} LESS ${retries}) + message(STATUS \"${algo} hash of \${file} +does not match expected value + expected: \${expect_value} + actual: \${actual_value} +Retrying download. +\") + file(REMOVE \"\${file}\") + execute_process(COMMAND ${CMAKE_COMMAND} -P \"${download_script}\") + endif() +endwhile() + +if(\${succeeded}) message(STATUS \"verifying file... done\") else() message(FATAL_ERROR \"error: ${algo} hash of @@ -1306,6 +1324,7 @@ function(_ep_add_download_command name) if(NOT git_tag) set(git_tag "master") endif() + get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES) # For the download step, and the git clone operation, only the repository # should be recorded in a configured RepositoryInfo file. If the repo @@ -1330,7 +1349,7 @@ function(_ep_add_download_command name) # The script will delete the source directory and then call git clone. # _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir} - ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${src_name} ${work_dir} + ${GIT_EXECUTABLE} ${git_repository} ${git_tag} "${git_submodules}" ${src_name} ${work_dir} ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt ) set(comment "Performing download step (git clone) for '${name}'") @@ -1394,6 +1413,8 @@ function(_ep_add_download_command name) set(repository "external project URL") set(module "${url}") set(tag "${hash}") + set(retries 0) + set(download_script "") configure_file( "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" "${stamp_dir}/${name}-urlinfo.txt" @@ -1423,16 +1444,17 @@ function(_ep_add_download_command name) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) - _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" - "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") - set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake + set(download_script "${stamp_dir}/download-${name}.cmake") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") + set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) + set(retries 3) set(comment "Performing download step (download, verify and extract) for '${name}'") else() set(file "${url}") set(comment "Performing download step (verify and extract) for '${name}'") endif() - _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}") + _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}" "${retries}" "${download_script}") list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake COMMAND) _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}") @@ -1521,8 +1543,9 @@ function(_ep_add_update_command name) if(NOT git_tag) set(git_tag "master") endif() + get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES) _ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake - ${GIT_EXECUTABLE} ${git_tag} ${git_repository} ${work_dir} + ${GIT_EXECUTABLE} ${git_tag} "${git_submodules}" ${git_repository} ${work_dir} ) set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake) set(always 1) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 05f38eb..7bc8d49 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -32,9 +32,7 @@ # script (in alphebetical order). Note that any of these flags can be # changed multiple times in the same directory before calling # CUDA_ADD_EXECUTABLE, CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX -# or CUDA_WRAP_SRCS. -# -# :: +# or CUDA_WRAP_SRCS:: # # CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) # -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. @@ -43,19 +41,11 @@ # nvcc in the generated source. If you compile to PTX and then load the # file yourself, you can mix bit sizes between device and host. # -# -# -# :: -# # CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) # -- Set to ON if you want the custom build rule to be attached to the source # file in Visual Studio. Turn OFF if you add the same cuda file to multiple # targets. # -# -# -# :: -# # This allows the user to build the target from the CUDA file; however, bad # things can happen if the CUDA source file is added to multiple targets. # When performing parallel builds it is possible for the custom build @@ -68,44 +58,24 @@ # this script could detect the reuse of source files across multiple targets # and turn the option off for the user, but no good solution could be found. # -# -# -# :: -# # CUDA_BUILD_CUBIN (Default OFF) # -- Set to ON to enable and extra compilation pass with the -cubin option in # Device mode. The output is parsed and register, shared memory usage is # printed during build. # -# -# -# :: -# # CUDA_BUILD_EMULATION (Default OFF for device mode) # -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files # when CUDA_BUILD_EMULATION is TRUE. # -# -# -# :: -# # CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) # -- Set to the path you wish to have the generated files placed. If it is # blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. # Intermediate files will always be placed in # CMAKE_CURRENT_BINARY_DIR/CMakeFiles. # -# -# -# :: -# # CUDA_HOST_COMPILATION_CPP (Default ON) # -- Set to OFF for C compilation of host code. # -# -# -# :: -# # CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER, $(VCInstallDir)/bin for VS) # -- Set the host compiler to be used by nvcc. Ignored if -ccbin or # --compiler-bindir is already present in the CUDA_NVCC_FLAGS or @@ -113,19 +83,11 @@ # $(VCInstallDir)/bin is a special value that expands out to the path when # the command is run from withing VS. # -# -# -# :: -# # CUDA_NVCC_FLAGS # CUDA_NVCC_FLAGS_<CONFIG> # -- Additional NVCC command line arguments. NOTE: multiple arguments must be # semi-colon delimited (e.g. --compiler-options;-Wall) # -# -# -# :: -# # CUDA_PROPAGATE_HOST_FLAGS (Default ON) # -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration # dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the @@ -137,10 +99,6 @@ # CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for # shared library compilation are not affected by this flag. # -# -# -# :: -# # CUDA_SEPARABLE_COMPILATION (Default OFF) # -- If set this will enable separable compilation for all CUDA runtime object # files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY @@ -148,38 +106,22 @@ # CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and # CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. # -# -# -# :: -# # CUDA_VERBOSE_BUILD (Default OFF) # -- Set to ON to see all the commands used when building the CUDA file. When # using a Makefile generator the value defaults to VERBOSE (run make # VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will # always print the output. # -# -# -# The script creates the following macros (in alphebetical order): -# -# :: +# The script creates the following macros (in alphebetical order):: # # CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) # -- Adds the cufft library to the target (can be any target). Handles whether # you are in emulation mode or not. # -# -# -# :: -# # CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) # -- Adds the cublas library to the target (can be any target). Handles # whether you are in emulation mode or not. # -# -# -# :: -# # CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... # [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) # -- Creates an executable "cuda_target" which is made up of the files @@ -193,43 +135,23 @@ # nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, # CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. # -# -# -# :: -# # CUDA_ADD_LIBRARY( cuda_target file0 file1 ... # [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) # -- Same as CUDA_ADD_EXECUTABLE except that a library is created. # -# -# -# :: -# # CUDA_BUILD_CLEAN_TARGET() # -- Creates a convience target that deletes all the dependency files # generated. You should make clean after running this target to ensure the # dependency files get regenerated. # -# -# -# :: -# # CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] # [OPTIONS ...] ) # -- Returns a list of generated files from the input source files to be used # with ADD_LIBRARY or ADD_EXECUTABLE. # -# -# -# :: -# # CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) # -- Returns a list of PTX files generated from the input source files. # -# -# -# :: -# # CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var # cuda_target # object_files ) @@ -242,10 +164,6 @@ # automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that # this is a function and not a macro. # -# -# -# :: -# # CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) # -- Sets the directories that should be passed to nvcc # (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu @@ -253,17 +171,9 @@ # # # -# -# -# :: -# # CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target # nvcc_flags object_files) # -# -# -# :: -# # -- Generates the link object required by separable compilation from the given # object files. This is called automatically for CUDA_ADD_EXECUTABLE and # CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS @@ -273,91 +183,51 @@ # specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function # instead of a macro. # -# -# -# :: -# # CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... # [STATIC | SHARED | MODULE] [OPTIONS ...] ) # -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, # CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this # function under the hood. # -# -# -# :: -# # Given the list of files (file0 file1 ... fileN) this macro generates # custom commands that generate either PTX or linkable objects (use "PTX" or # "OBJ" for the format argument to switch). Files that don't end with .cu # or have the HEADER_FILE_ONLY property are ignored. # -# -# -# :: -# # The arguments passed in after OPTIONS are extra command line options to # give to nvcc. You can also specify per configuration options by # specifying the name of the configuration followed by the options. General # options must preceed configuration specific options. Not all # configurations need to be specified, only the ones provided will be used. # -# -# -# :: -# # OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" # DEBUG -g # RELEASE --use_fast_math # RELWITHDEBINFO --use_fast_math;-g # MINSIZEREL --use_fast_math # -# -# -# :: -# # For certain configurations (namely VS generating object files with # CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will # be produced for the given cuda file. This is because when you add the # cuda file to Visual Studio it knows that this file produces an object file # and will link in the resulting object file automatically. # -# -# -# :: -# # This script will also generate a separate cmake script that is used at # build time to invoke nvcc. This is for several reasons. # -# -# -# :: -# # 1. nvcc can return negative numbers as return values which confuses # Visual Studio into thinking that the command succeeded. The script now # checks the error codes and produces errors when there was a problem. # -# -# -# :: -# # 2. nvcc has been known to not delete incomplete results when it # encounters problems. This confuses build systems into thinking the # target was generated when in fact an unusable file exists. The script # now deletes the output files if there was an error. # -# -# -# :: -# # 3. By putting all the options that affect the build into a file and then # make the build rule dependent on the file, the output files will be # regenerated when the options change. # -# -# -# :: -# # This script also looks at optional arguments STATIC, SHARED, or MODULE to # determine when to target the object compilation for a shared library. # BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in @@ -366,27 +236,17 @@ # <target_name>_EXPORTS is defined when a shared library compilation is # detected. # -# -# -# :: -# # Flags passed into add_definitions with -D or /D are passed along to nvcc. # # # -# The script defines the following variables: -# -# :: +# The script defines the following variables:: # # CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. # CUDA_VERSION_MINOR -- The minor version. # CUDA_VERSION # CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR # -# -# -# :: -# # CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). # CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the # SDK. This script will not directly support finding @@ -427,32 +287,15 @@ # Only available for CUDA version 3.2+. # Windows only. # -# -# -# -# -# :: -# + # James Bigler, NVIDIA Corp (nvidia.com - jbigler) # Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html # -# -# -# :: -# # Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. # -# -# -# :: -# # Copyright (c) 2007-2009 # Scientific Computing and Imaging Institute, University of Utah # -# -# -# :: -# # This code is licensed under the MIT License. See the FindCUDA.cmake script # for the text of the license. diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index f1cb57e..669e3e2 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -6,7 +6,10 @@ # # This module finds if Java is installed and determines where the # include files and libraries are. It also determines what the name of -# the library is. This code sets the following variables: +# the library is. The caller may set variable JAVA_HOME to specify a +# Java installation prefix explicitly. +# +# This module sets the following result variables: # # :: # @@ -91,22 +94,37 @@ macro(java_append_library_directories _var) endforeach() endmacro() +include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake) + +# Save CMAKE_FIND_FRAMEWORK +if(DEFINED CMAKE_FIND_FRAMEWORK) + set(_JNI_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) +else() + unset(_JNI_CMAKE_FIND_FRAMEWORK) +endif() + +if(_JAVA_HOME_EXPLICIT) + set(CMAKE_FIND_FRAMEWORK NEVER) +endif() + +set(JAVA_AWT_LIBRARY_DIRECTORIES) +if(_JAVA_HOME) + JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES + ${_JAVA_HOME}/jre/lib/{libarch} + ${_JAVA_HOME}/jre/lib + ${_JAVA_HOME}/lib + ${_JAVA_HOME} + ) +endif() get_filename_component(java_install_version "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) -set(JAVA_AWT_LIBRARY_DIRECTORIES +list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib" ) - -file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME) - JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES - ${_JAVA_HOME}/jre/lib/{libarch} - ${_JAVA_HOME}/jre/lib - ${_JAVA_HOME}/lib - ${_JAVA_HOME} /usr/lib /usr/local/lib /usr/lib/jvm/java/lib @@ -135,20 +153,21 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES set(JAVA_JVM_LIBRARY_DIRECTORIES) foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES}) - set(JAVA_JVM_LIBRARY_DIRECTORIES - ${JAVA_JVM_LIBRARY_DIRECTORIES} + list(APPEND JAVA_JVM_LIBRARY_DIRECTORIES "${dir}" "${dir}/client" "${dir}/server" ) endforeach() - -set(JAVA_AWT_INCLUDE_DIRECTORIES +set(JAVA_AWT_INCLUDE_DIRECTORIES) +if(_JAVA_HOME) + list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include) +endif() +list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include" - ${_JAVA_HOME}/include /usr/include /usr/local/include /usr/lib/java/include @@ -173,7 +192,7 @@ foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") get_filename_component(jpath "${JAVA_PROG}" PATH) foreach(JAVA_INC_PATH ../include ../java/include ../share/java/include) if(EXISTS ${jpath}/${JAVA_INC_PATH}) - set(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}") + list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES "${jpath}/${JAVA_INC_PATH}") endif() endforeach() foreach(JAVA_LIB_PATH @@ -181,54 +200,55 @@ foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") ../java/lib ../java/jre/lib ../java/jre/lib/i386 ../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386) if(EXISTS ${jpath}/${JAVA_LIB_PATH}) - set(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}") + list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES "${jpath}/${JAVA_LIB_PATH}") endif() endforeach() endforeach() if(APPLE) - if(EXISTS ~/Library/Frameworks/JavaVM.framework) - set(JAVA_HAVE_FRAMEWORK 1) - endif() - if(EXISTS /Library/Frameworks/JavaVM.framework) - set(JAVA_HAVE_FRAMEWORK 1) - endif() - if(EXISTS /System/Library/Frameworks/JavaVM.framework) - set(JAVA_HAVE_FRAMEWORK 1) + if(CMAKE_FIND_FRAMEWORK STREQUAL "ONLY") + set(_JNI_SEARCHES FRAMEWORK) + elseif(CMAKE_FIND_FRAMEWORK STREQUAL "NEVER") + set(_JNI_SEARCHES NORMAL) + elseif(CMAKE_FIND_FRAMEWORK STREQUAL "LAST") + set(_JNI_SEARCHES NORMAL FRAMEWORK) + else() + set(_JNI_SEARCHES FRAMEWORK NORMAL) endif() + set(_JNI_FRAMEWORK_JVM NAMES JavaVM) + set(_JNI_FRAMEWORK_JAWT "${_JNI_FRAMEWORK_JVM}") +else() + set(_JNI_SEARCHES NORMAL) +endif() - if(JAVA_HAVE_FRAMEWORK) - if(NOT JAVA_AWT_LIBRARY) - set (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE) - endif() - - if(NOT JAVA_JVM_LIBRARY) - set (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE) - endif() +set(_JNI_NORMAL_JVM + NAMES jvm + PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES} + ) - if(NOT JAVA_AWT_INCLUDE_PATH) - if(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h) - set (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE) - endif() - endif() +set(_JNI_NORMAL_JAWT + NAMES jawt + PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES} + ) - # If using "-framework JavaVM", prefer its headers *before* the others in - # JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here) - # - set(JAVA_AWT_INCLUDE_DIRECTORIES - ~/Library/Frameworks/JavaVM.framework/Headers - /Library/Frameworks/JavaVM.framework/Headers - /System/Library/Frameworks/JavaVM.framework/Headers - ${JAVA_AWT_INCLUDE_DIRECTORIES} - ) +foreach(search ${_JNI_SEARCHES}) + find_library(JAVA_JVM_LIBRARY ${_JNI_${search}_JVM}) + find_library(JAVA_AWT_LIBRARY ${_JNI_${search}_JAWT}) + if(JAVA_JVM_LIBRARY) + break() endif() +endforeach() +unset(_JNI_SEARCHES) +unset(_JNI_FRAMEWORK_JVM) +unset(_JNI_FRAMEWORK_JAWT) +unset(_JNI_NORMAL_JVM) +unset(_JNI_NORMAL_JAWT) + +# Find headers matching the library. +if("${JAVA_JVM_LIBRARY};${JAVA_AWT_LIBRARY};" MATCHES "(/JavaVM.framework|-framework JavaVM);") + set(CMAKE_FIND_FRAMEWORK ONLY) else() - find_library(JAVA_AWT_LIBRARY jawt - PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES} - ) - find_library(JAVA_JVM_LIBRARY NAMES jvm JavaVM - PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES} - ) + set(CMAKE_FIND_FRAMEWORK NEVER) endif() # add in the include path @@ -252,6 +272,14 @@ find_path(JAVA_AWT_INCLUDE_PATH jawt.h ${JAVA_INCLUDE_PATH} ) +# Restore CMAKE_FIND_FRAMEWORK +if(DEFINED _JNI_CMAKE_FIND_FRAMEWORK) + set(CMAKE_FIND_FRAMEWORK ${_JNI_CMAKE_FIND_FRAMEWORK}) + unset(_JNI_CMAKE_FIND_FRAMEWORK) +else() + unset(CMAKE_FIND_FRAMEWORK) +endif() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index e35fc1d..a488c46 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -5,8 +5,10 @@ # Find Java # # This module finds if Java is installed and determines where the -# include files and libraries are. This code sets the following -# variables: +# include files and libraries are. The caller may set variable JAVA_HOME +# to specify a Java installation prefix explicitly. +# +# This module sets the following result variables: # # :: # @@ -67,8 +69,14 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake) + # The HINTS option should only be used for values computed from the system. -set(_JAVA_HINTS +set(_JAVA_HINTS) +if(_JAVA_HOME) + list(APPEND _JAVA_HINTS ${_JAVA_HOME}/bin) +endif() +list(APPEND _JAVA_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin" @@ -77,7 +85,6 @@ set(_JAVA_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin" - $ENV{JAVA_HOME}/bin ) # Hard-coded guesses should still go in PATHS. This ensures that the user # environment can always override hard guesses. diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 80ba798..9ea77d4 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -35,78 +35,7 @@ # meta-object code generation,``uic`` for widget layout and population, # and ``rcc`` for virtual filesystem content generation. These tools may be # automatically invoked by :manual:`cmake(1)` if the appropriate conditions -# are met. -# -# The tools are executed as part of a synthesized custom target generated by -# CMake. Target dependencies may be added to that custom target by adding them -# to the :prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property. -# -# AUTOMOC -# ''''''' -# -# The :prop_tgt:`AUTOMOC` target property controls whether :manual:`cmake(1)` -# inspects the C++ files in the target to determine if they require ``moc`` to -# be run, and to create rules to execute ``moc`` at the appropriate time. -# -# If a ``Q_OBJECT`` or ``Q_GADGET`` macro is found in a header file, ``moc`` -# will be run on the file. The result will be put into a file named according -# to ``moc_<basename>.cpp``. If the macro is found in a C++ implementation -# file, the moc output will be put into a file named according to -# ``<basename>.moc``, following the Qt conventions. The ``moc file`` may be -# included by the user in the C++ implementation file with a preprocessor -# ``#include``. If it is not so included, it will be added to a separate file -# which is compiled into the target. -# -# Generated ``moc_*.cpp`` and ``*.moc`` files are placed in the build directory -# so it is convenient to set the :variable:`CMAKE_INCLUDE_CURRENT_DIR` -# variable. The :prop_tgt:`AUTOMOC` target property may be pre-set for all -# following targets by setting the :variable:`CMAKE_AUTOMOC` variable. The -# :prop_tgt:`AUTOMOC_MOC_OPTIONS` target property may be populated to set -# options to pass to ``moc``. The :variable:`CMAKE_AUTOMOC_MOC_OPTIONS` -# variable may be populated to pre-set the options for all following targets. -# -# AUTOUIC -# ''''''' -# -# The :prop_tgt:`AUTOUIC` target property controls whether :manual:`cmake(1)` -# inspects the C++ files in the target to determine if they require ``uic`` to -# be run, and to create rules to execute ``uic`` at the appropriate time. -# -# If a preprocessor ``#include`` directive is found which matches -# ``ui_<basename>.h``, and a ``<basename>.ui`` file exists, then ``uic`` will -# be executed to generate the appropriate file. -# -# Generated ``ui_*.h`` files are placed in the build directory so it is -# convenient to set the :variable:`CMAKE_INCLUDE_CURRENT_DIR` variable. The -# :prop_tgt:`AUTOUIC` target property may be pre-set for all following targets -# by setting the :variable:`CMAKE_AUTOUIC` variable. The -# :prop_tgt:`AUTOUIC_OPTIONS` target property may be populated to set options -# to pass to ``uic``. The :variable:`CMAKE_AUTOUIC_OPTIONS` variable may be -# populated to pre-set the options for all following targets. The -# :prop_sf:`AUTOUIC_OPTIONS` source file property may be set on the -# ``<basename>.ui`` file to set particular options for the file. This -# overrides options from the :prop_tgt:`AUTOUIC_OPTIONS` target property. -# -# AUTORCC -# ''''''' -# -# The :prop_tgt:`AUTORCC` target property controls whether :manual:`cmake(1)` -# creates rules to execute ``rcc`` at the appropriate time on source files -# which have the suffix ``.qrc``. -# -# .. code-block:: cmake -# -# add_executable(myexe main.cpp resource_file.qrc) -# -# The :prop_tgt:`AUTORCC` target property may be pre-set for all following targets -# by setting the :variable:`CMAKE_AUTORCC` variable. The -# :prop_tgt:`AUTORCC_OPTIONS` target property may be populated to set options -# to pass to ``rcc``. The :variable:`CMAKE_AUTORCC_OPTIONS` variable may be -# populated to pre-set the options for all following targets. The -# :prop_sf:`AUTORCC_OPTIONS` source file property may be set on the -# ``<name>.qrc`` file to set particular options for the file. This -# overrides options from the :prop_tgt:`AUTORCC_OPTIONS` target property. -# +# are met. See :manual:`cmake-qt(7)` for more. # # Qt Macros # ========= diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index 95187b4..7d28e95 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -6,7 +6,7 @@ # # :: # -# WRITE_BASIC_CONFIG_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion) ) +# WRITE_BASIC_CONFIG_VERSION_FILE( filename [VERSION major.minor.patch] COMPATIBILITY (AnyNewerVersion|SameMajorVersion) ) # # # @@ -46,7 +46,11 @@ function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) endif() if("${CVF_VERSION}" STREQUAL "") - message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()") + if ("${PROJECT_VERSION}" STREQUAL "") + message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()") + else() + set(CVF_VERSION "${PROJECT_VERSION}") + endif() endif() configure_file("${versionTemplateFile}" "${_filename}" @ONLY) diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..1b5b0c3 --- /dev/null +++ b/README.rst @@ -0,0 +1,83 @@ +CMake +***** + +Introduction +============ + +CMake is a cross-platform, open-source build system generator. +For full documentation visit the `CMake Home Page`_ and the +`CMake Documentation Page`_. + +.. _`CMake Home Page`: http://www.cmake.org +.. _`CMake Documentation Page`: http://www.cmake.org/cmake/help/documentation.html + +CMake is maintained by `Kitware, Inc.`_ and developed in +collaboration with a productive community of contributors. + +.. _`Kitware, Inc.`: http://www.kitware.com + +License +======= + +CMake is distributed under the OSI-approved BSD 3-clause License. +See `Copyright.txt`_ for details. + +.. _`Copyright.txt`: Copyright.txt + +Building CMake +============== + +Supported Platforms +------------------- + +MS Windows, Mac OS X, Linux, FreeBSD, Solaris, HP-UX, IRIX, BeOS, QNX + +Other UNIX-like operating systems may work too out of the box, if not +it should not be a major problem to port CMake to this platform. +Subscribe and post to the `CMake Users List`_ to ask if others have +had experience with the platform. + +.. _`CMake Users List`: http://www.cmake.org/mailman/listinfo/cmake + +Building CMake from Scratch +--------------------------- + +UNIX/Mac OSX/MinGW/MSYS/Cygwin +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You need to have a compiler and a make installed. +Run the ``bootstrap`` script you find the in the source directory of CMake. +You can use the ``--help`` option to see the supported options. +You may use the ``--prefix=<install_prefix>`` option to specify a custom +installation directory for CMake. You can run the ``bootstrap`` script from +within the CMake source directory or any other build directory of your +choice. Once this has finished successfully, run ``make`` and +``make install``. In summary:: + + $ ./bootstrap && make && make install + +Windows +^^^^^^^ + +You need to download and install a binary release of CMake in order to build +CMake. You can get these releases from the `CMake Download Page`_ . Then +proceed with the instructions below. + +.. _`CMake Download Page`: http://www.cmake.org/cmake/resources/software.html + +Building CMake with CMake +------------------------- + +You can build CMake as any other project with a CMake-based build system: +run the installed CMake on the sources of this CMake with your preferred +options and generators. Then build it and install it. +For instructions how to do this, see documentation on `Running CMake`_. + +.. _`Running CMake`: http://www.cmake.org/cmake/help/runningcmake.html + +Contributing +============ + +See `CONTRIBUTING.rst`_ for instructions to contribute. + +.. _`CONTRIBUTING.rst`: CONTRIBUTING.rst diff --git a/Readme.txt b/Readme.txt deleted file mode 100644 index 11926bc..0000000 --- a/Readme.txt +++ /dev/null @@ -1,53 +0,0 @@ -This is CMake, the cross-platform, open-source make system. -CMake is distributed under the BSD License, see Copyright.txt. -For documentation see the Docs/ directory once you have built CMake -or visit http://www.cmake.org. - - -Building CMake -============== - - -Supported Platforms -------------------- - -MS Windows, Mac OS X, Linux, FreeBSD, Solaris, HP-UX, IRIX, BeOS, QNX - -Other UNIX-like operating systems may work too out of the box, if not -it shouldn't be a major problem to port CMake to this platform. Contact the -CMake mailing list in this case: http://www.cmake.org/mailman/listinfo/cmake - - -If you don't have any previous version of CMake already installed --------------------------------------------------------------- - -* UNIX/Mac OSX/MinGW/MSYS/Cygwin: - -You need to have a compiler and a make installed. -Run the bootstrap script you find the in the source directory of CMake. -You can use the --help option to see the supported options. -You may want to use the --prefix=<install_prefix> option to specify a custom -installation directory for CMake. You can run the bootstrap script from -within the CMake source directory or any other build directory of your -choice. Once this has finished successfully, run make and make install. -So basically it's the same as you may be used to from autotools-based -projects: - -$ ./bootstrap; make; make install - - -* Other Windows: - -You need to download and install a binary release of CMake in order to build -CMake. You can get these releases from -http://www.cmake.org/HTML/Download.html . Then proceed with the instructions -below. - - -You already have a version of CMake installed ---------------------------------------------- - -You can build CMake as any other project with a CMake-based build system: -run the installed CMake on the sources of this CMake with your preferred -options and generators. Then build it and install it. -For instructions how to do this, see http://www.cmake.org/HTML/RunningCMake.html diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 60cd354..4a70f5a 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 20140123) +set(CMake_VERSION_TWEAK 20140204) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 0058721..b09d6f5 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -380,10 +380,16 @@ std::string cmCTestP4::GetWorkingRevision() p4_identify.push_back(0); std::string rev; - IdentifyParser out(this, "rev-out> ", rev); - OutputLogger err(this->Log, "rev-err> "); + IdentifyParser out(this, "p4_changes-out> ", rev); + OutputLogger err(this->Log, "p4_changes-err> "); - RunChild(&p4_identify[0], &out, &err); + bool result = RunChild(&p4_identify[0], &out, &err); + + // If there was a problem contacting the server return "<unknown>" + if(!result) + { + return "<unknown>"; + } if(rev.empty()) { @@ -423,29 +429,24 @@ void cmCTestP4::LoadRevisions() // Use 'p4 changes ...@old,new' to get a list of changelists std::string range = this->SourceDirectory + "/..."; - if(this->OldRevision != "0") + // If any revision is unknown it means we couldn't contact the server. + // Do not process updates + if(this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>") { - range.append("@").append(this->OldRevision); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " At least one of the revisions " + << "is unknown. No repository changes will be reported.\n"); + return; } - if(this->NewRevision != "0") - { - if(this->OldRevision != "0") - { - range.append(",").append(this->NewRevision); - } - else - { - range.append("@").append(this->NewRevision); - } - } + range.append("@").append(this->OldRevision) + .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> "); + ChangesParser out(this, "p4_changes-out> "); + OutputLogger err(this->Log, "p4_changes-err> "); ChangeLists.clear(); this->RunChild(&p4_changes[0], &out, &err); @@ -464,8 +465,8 @@ void cmCTestP4::LoadRevisions() p4_describe.push_back(i->c_str()); p4_describe.push_back(0); - DescribeParser outDescribe(this, "describe-out> "); - OutputLogger errDescribe(this->Log, "describe-err> "); + DescribeParser outDescribe(this, "p4_describe-out> "); + OutputLogger errDescribe(this->Log, "p4_describe-err> "); this->RunChild(&p4_describe[0], &outDescribe, &errDescribe); } } @@ -484,8 +485,8 @@ void cmCTestP4::LoadModifications() p4_diff.push_back(source.c_str()); p4_diff.push_back(0); - DiffParser out(this, "diff-out> "); - OutputLogger err(this->Log, "diff-err> "); + DiffParser out(this, "p4_diff-out> "); + OutputLogger err(this->Log, "p4_diff-err> "); this->RunChild(&p4_diff[0], &out, &err); } @@ -503,8 +504,8 @@ bool cmCTestP4::UpdateCustom(const std::string& custom) } p4_custom.push_back(0); - OutputLogger custom_out(this->Log, "custom-out> "); - OutputLogger custom_err(this->Log, "custom-err> "); + OutputLogger custom_out(this->Log, "p4_customsync-out> "); + OutputLogger custom_err(this->Log, "p4_customsync-err> "); return this->RunUpdateCommand(&p4_custom[0], &custom_out, &custom_err); } @@ -518,6 +519,14 @@ bool cmCTestP4::UpdateImpl() return this->UpdateCustom(custom); } + // If we couldn't get a revision number before updating, abort. + if(this->OldRevision == "<unknown>") + { + this->UpdateCommandLine = "Unknown current revision"; + cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown current revision\n"); + return false; + } + std::vector<char const*> p4_sync; SetP4Options(p4_sync); @@ -552,8 +561,8 @@ bool cmCTestP4::UpdateImpl() p4_sync.push_back(source.c_str()); p4_sync.push_back(0); - OutputLogger out(this->Log, "sync-out> "); - OutputLogger err(this->Log, "sync-err> "); + OutputLogger out(this->Log, "p4_sync-out> "); + OutputLogger err(this->Log, "p4_sync-err> "); return this->RunUpdateCommand(&p4_sync[0], &out, &err); } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 4b8c07d..f487e8e 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -145,8 +145,10 @@ public: const char* GetCacheValue(const char* key) const; /** Get the version of CMake that wrote the cache. */ - unsigned int GetCacheMajorVersion() { return this->CacheMajorVersion; } - unsigned int GetCacheMinorVersion() { return this->CacheMinorVersion; } + unsigned int GetCacheMajorVersion() const + { return this->CacheMajorVersion; } + unsigned int GetCacheMinorVersion() const + { return this->CacheMinorVersion; } bool NeedCacheCompatibility(int major, int minor); protected: diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 3620a38..b672148 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -64,7 +64,7 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r) } //---------------------------------------------------------------------------- -cmCustomCommand::cmCustomCommand(cmMakefile* mf, +cmCustomCommand::cmCustomCommand(cmMakefile const* mf, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index e20d2bf..6851105 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -30,7 +30,7 @@ public: cmCustomCommand& operator=(cmCustomCommand const& r); /** Main constructor specifies all information for the command. */ - cmCustomCommand(cmMakefile* mf, + cmCustomCommand(cmMakefile const* mf, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index b156691..ff84fb7 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -449,8 +449,12 @@ cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const buildCommand = make; } else if ( generator == "MinGW Makefiles" || - generator == "Unix Makefiles" || - generator == "Ninja" ) + generator == "Unix Makefiles" ) + { + ss << make << " -j " << this->CpuCount; + buildCommand = ss.str(); + } + else if ( generator == "Ninja" ) { ss << make; buildCommand = ss.str(); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 3e9b786..33e76cd 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -567,9 +567,9 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( { // Add the file to the list of sources. std::string source = (*sfIt)->GetFullPath(); - cmSourceGroup& sourceGroup = + cmSourceGroup* sourceGroup = makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup.AssignSource(*sfIt); + sourceGroup->AssignSource(*sfIt); } for(std::vector<cmSourceGroup>::iterator sgIt = sourceGroups.begin(); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 311763b..e79bc6c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2983,6 +2983,8 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) << " for file: [" << file << "]" << std::endl << " expected hash: [" << expectedHash << "]" << std::endl << " actual hash: [" << actualHash << "]" << std::endl + << " status: [" << (int)res << ";\"" + << ::curl_easy_strerror(res) << "\"]" << std::endl ; this->SetError(oss.str().c_str()); return false; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 03486d8..a61cab1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -3032,3 +3032,10 @@ void cmGlobalGenerator::ProcessEvaluationFiles() } } } + +//---------------------------------------------------------------------------- +std::string cmGlobalGenerator::ExpandCFGIntDir(const std::string& str, + const std::string& /*config*/) const +{ + return str; +} diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ebc2db5..753eebf 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -193,6 +193,10 @@ public: ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "."; } + ///! expand CFGIntDir for a configuration + virtual std::string ExpandCFGIntDir(const std::string& str, + const std::string& config) const; + /** Get whether the generator should use a script for link commands. */ bool GetUseLinkScript() const { return this->UseLinkScript; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 5e1f1ed..731bc00 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1110,16 +1110,24 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*restat=*/ false, /*generator=*/ true); + cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(lg); + cmNinjaDeps implicitDeps; - for (std::vector<cmLocalGenerator *>::const_iterator i = - this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) { - const std::vector<std::string>& lf = (*i)->GetMakefile()->GetListFiles(); - implicitDeps.insert(implicitDeps.end(), lf.begin(), lf.end()); - } + for(std::vector<cmLocalGenerator*>::const_iterator i = + this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) + { + std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles(); + for(std::vector<std::string>::const_iterator fi = lf.begin(); + fi != lf.end(); ++fi) + { + implicitDeps.push_back(ng->ConvertToNinjaPath(fi->c_str())); + } + } + implicitDeps.push_back("CMakeCache.txt"); + std::sort(implicitDeps.begin(), implicitDeps.end()); implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()), implicitDeps.end()); - implicitDeps.push_back("CMakeCache.txt"); this->WriteBuild(os, "Re-run CMake if any of its inputs changed.", diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 42492e6..0c5f35b 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -902,3 +902,20 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet this->insert(*ti); } } + +std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir( + const std::string& str, + const std::string& config) const +{ + std::string replace = GetCMakeCFGIntDir(); + + std::string tmp = str; + for(std::string::size_type i = tmp.find(replace); + i != std::string::npos; + i = tmp.find(replace, i)) + { + tmp.replace(i, replace.size(), config); + i += config.size(); + } + return tmp; +} diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index eab613d..9186d65 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -84,6 +84,10 @@ public: virtual void FindMakeProgram(cmMakefile*); + + virtual std::string ExpandCFGIntDir(const std::string& str, + const std::string& config) const; + protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 41961ed..484b28f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2272,14 +2272,24 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string search_paths; std::vector<std::string> runtimeDirs; pcli->GetRPath(runtimeDirs, false); + // runpath dirs needs to be unique to prevent corruption + std::set<std::string> unique_dirs; + for(std::vector<std::string>::const_iterator i = runtimeDirs.begin(); i != runtimeDirs.end(); ++i) { - if(!search_paths.empty()) + std::string runpath = *i; + runpath = this->ExpandCFGIntDir(runpath, configName); + + if(unique_dirs.find(runpath) == unique_dirs.end()) { - search_paths += " "; + unique_dirs.insert(runpath); + if(!search_paths.empty()) + { + search_paths += " "; + } + search_paths += this->XCodeEscapePath(runpath.c_str()); } - search_paths += this->XCodeEscapePath((*i).c_str()); } if(!search_paths.empty()) { @@ -2960,10 +2970,10 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, cmSourceFile* sf = *s; // Add the file to the list of sources. std::string const& source = sf->GetFullPath(); - cmSourceGroup& sourceGroup = + cmSourceGroup* sourceGroup = mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = - this->CreateOrGetPBXGroup(cmtarget, &sourceGroup); + this->CreateOrGetPBXGroup(cmtarget, sourceGroup); cmStdString key = GetGroupMapKey(cmtarget, sf); this->GroupMap[key] = pbxgroup; } @@ -2975,10 +2985,10 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, oi = objs.begin(); oi != objs.end(); ++oi) { std::string const& source = *oi; - cmSourceGroup& sourceGroup = + cmSourceGroup* sourceGroup = mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = - this->CreateOrGetPBXGroup(cmtarget, &sourceGroup); + this->CreateOrGetPBXGroup(cmtarget, sourceGroup); cmStdString key = GetGroupMapKeyFromPath(cmtarget, source); this->GroupMap[key] = pbxgroup; } @@ -3675,6 +3685,30 @@ const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" : "."; } +std::string cmGlobalXCodeGenerator::ExpandCFGIntDir(const std::string& str, + const std::string& config) const +{ + std::string replace1 = "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; + std::string replace2 = "$(CONFIGURATION)"; + + std::string tmp = str; + for(std::string::size_type i = tmp.find(replace1); + i != std::string::npos; + i = tmp.find(replace1, i)) + { + tmp.replace(i, replace1.size(), config); + i += config.size(); + } + for(std::string::size_type i = tmp.find(replace2); + i != std::string::npos; + i = tmp.find(replace2, i)) + { + tmp.replace(i, replace2.size(), config); + i += config.size(); + } + return tmp; +} + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index ae7f07e..c9d20c2 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -79,6 +79,9 @@ public: ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const; + ///! expand CFGIntDir + virtual std::string ExpandCFGIntDir(const std::string& str, + const std::string& config) const; void SetCurrentLocalGenerator(cmLocalGenerator*); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 68f45a6..7a39f45 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -669,22 +669,36 @@ cmInstallTargetGenerator cli->GetRPath(oldRuntimeDirs, false); cli->GetRPath(newRuntimeDirs, true); - // Note: These are separate commands to avoid install_name_tool - // corruption on 10.6. + // Note: These paths are kept unique to avoid install_name_tool corruption. + std::set<std::string> runpaths; for(std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin(); i != oldRuntimeDirs.end(); ++i) { - os << indent << "execute_process(COMMAND " << installNameTool << "\n"; - os << indent << " -delete_rpath \"" << *i << "\"\n"; - os << indent << " \"" << toDestDirPath << "\")\n"; + std::string runpath = this->Target->GetMakefile()->GetLocalGenerator()-> + GetGlobalGenerator()->ExpandCFGIntDir(*i, config); + + if(runpaths.find(runpath) == runpaths.end()) + { + runpaths.insert(runpath); + os << indent << "execute_process(COMMAND " << installNameTool << "\n"; + os << indent << " -delete_rpath \"" << runpath << "\"\n"; + os << indent << " \"" << toDestDirPath << "\")\n"; + } } + runpaths.clear(); for(std::vector<std::string>::const_iterator i = newRuntimeDirs.begin(); i != newRuntimeDirs.end(); ++i) { - os << indent << "execute_process(COMMAND " << installNameTool << "\n"; - os << indent << " -add_rpath \"" << *i << "\"\n"; - os << indent << " \"" << toDestDirPath << "\")\n"; + std::string runpath = this->Target->GetMakefile()->GetLocalGenerator()-> + GetGlobalGenerator()->ExpandCFGIntDir(*i, config); + + if(runpaths.find(runpath) == runpaths.end()) + { + os << indent << "execute_process(COMMAND " << installNameTool << "\n"; + os << indent << " -add_rpath \"" << runpath << "\"\n"; + os << indent << " \"" << toDestDirPath << "\")\n"; + } } } else diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c13b8ee..a2a66ae 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2187,7 +2187,11 @@ void cmLocalGenerator return; } AddVisibilityCompileOption(flags, target, this, lang); - AddInlineVisibilityCompileOption(flags, target, this); + + if(strcmp(lang, "CXX") == 0) + { + AddInlineVisibilityCompileOption(flags, target, this); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index fb12521..a5e8294 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -324,9 +324,9 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, { // Add the file to the list of sources. std::string source = (*i)->GetFullPath(); - cmSourceGroup& sourceGroup = + cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup.AssignSource(*i); + sourceGroup->AssignSource(*i); // while we are at it, if it is a .rule file then for visual studio 6 we // must generate it if ((*i)->GetPropertyAsBool("__CMAKE_RULE")) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 57a4880..212b06b 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1392,9 +1392,9 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { this->ModuleDefinitionFile = (*i)->GetFullPath(); } - cmSourceGroup& sourceGroup = + cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup.AssignSource(*i); + sourceGroup->AssignSource(*i); } // open the project diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 856462e..f248c57 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -169,17 +169,17 @@ void cmMakefile::Initialize() this->CheckCMP0000 = false; } -unsigned int cmMakefile::GetCacheMajorVersion() +unsigned int cmMakefile::GetCacheMajorVersion() const { return this->GetCacheManager()->GetCacheMajorVersion(); } -unsigned int cmMakefile::GetCacheMinorVersion() +unsigned int cmMakefile::GetCacheMinorVersion() const { return this->GetCacheManager()->GetCacheMinorVersion(); } -bool cmMakefile::NeedCacheCompatibility(int major, int minor) +bool cmMakefile::NeedCacheCompatibility(int major, int minor) const { return this->GetCacheManager()->NeedCacheCompatibility(major, minor); } @@ -260,7 +260,7 @@ void cmMakefile // call print on all the classes in the makefile -void cmMakefile::Print() +void cmMakefile::Print() const { // print the class lists std::cout << "classes:\n"; @@ -359,7 +359,7 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const } //---------------------------------------------------------------------------- -void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) +void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const { cmOStringStream msg; msg << lff.FilePath << "(" << lff.Line << "): "; @@ -734,7 +734,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, } //---------------------------------------------------------------------------- -void cmMakefile::EnforceDirectoryLevelRules() +void cmMakefile::EnforceDirectoryLevelRules() const { // Diagnose a violation of CMP0000 if necessary. if(this->CheckCMP0000) @@ -884,7 +884,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, - bool escapeOldStyle) + bool escapeOldStyle) const { // Find the target to which to add the custom command. cmTargets::iterator ti = this->Targets.find(target); @@ -1570,23 +1570,23 @@ void cmMakefile::InitializeFromParent() // Initialize definitions with the closure of the parent scope. this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure(); - const std::vector<cmValueWithOrigin> parentIncludes = + const std::vector<cmValueWithOrigin>& parentIncludes = parent->GetIncludeDirectoriesEntries(); this->IncludeDirectoriesEntries.insert(this->IncludeDirectoriesEntries.end(), - parentIncludes.begin(), - parentIncludes.end()); + parentIncludes.begin(), + parentIncludes.end()); - const std::vector<cmValueWithOrigin> parentOptions = + const std::vector<cmValueWithOrigin>& parentOptions = parent->GetCompileOptionsEntries(); this->CompileOptionsEntries.insert(this->CompileOptionsEntries.end(), parentOptions.begin(), parentOptions.end()); - const std::vector<cmValueWithOrigin> parentDefines = + const std::vector<cmValueWithOrigin>& parentDefines = parent->GetCompileDefinitionsEntries(); this->CompileDefinitionsEntries.insert(this->CompileDefinitionsEntries.end(), - parentDefines.begin(), - parentDefines.end()); + parentDefines.begin(), + parentDefines.end()); this->SystemIncludeDirectories = parent->SystemIncludeDirectories; @@ -2058,7 +2058,8 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) return &it->second; } -cmSourceFile *cmMakefile::LinearGetSourceFileWithOutput(const char *cname) +cmSourceFile* +cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const { std::string name = cname; std::string out; @@ -2094,7 +2095,7 @@ cmSourceFile *cmMakefile::LinearGetSourceFileWithOutput(const char *cname) return 0; } -cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) +cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const { std::string name = cname; @@ -2105,7 +2106,7 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) return LinearGetSourceFileWithOutput(cname); } // Otherwise we use an efficient lookup map. - OutputToSourceMap::iterator o = this->OutputToSource.find(name); + OutputToSourceMap::const_iterator o = this->OutputToSource.find(name); if (o != this->OutputToSource.end()) { return (*o).second; @@ -2114,19 +2115,20 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) } #if defined(CMAKE_BUILD_WITH_CMAKE) -cmSourceGroup* cmMakefile::GetSourceGroup(const std::vector<std::string>&name) +cmSourceGroup* +cmMakefile::GetSourceGroup(const std::vector<std::string>&name) const { cmSourceGroup* sg = 0; // first look for source group starting with the same as the one we wants - for (std::vector<cmSourceGroup>::iterator sgIt = this->SourceGroups.begin(); - sgIt != this->SourceGroups.end(); ++sgIt) - + for (std::vector<cmSourceGroup>::const_iterator + sgIt = this->SourceGroups.begin(); + sgIt != this->SourceGroups.end(); ++sgIt) { std::string sgName = sgIt->GetName(); if(sgName == name[0]) { - sg = &(*sgIt); + sg = const_cast<cmSourceGroup*>(&(*sgIt)); break; } } @@ -2136,7 +2138,7 @@ cmSourceGroup* cmMakefile::GetSourceGroup(const std::vector<std::string>&name) // iterate through its children to find match source group for(unsigned int i=1; i<name.size(); ++i) { - sg = sg->lookupChild(name[i].c_str()); + sg = sg->LookupChild(name[i].c_str()); if(sg == 0) { break; @@ -2207,7 +2209,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, for(++i; i<=lastElement; ++i) { sg->AddChild(cmSourceGroup(name[i].c_str(), 0, sg->GetFullName())); - sg = sg->lookupChild(name[i].c_str()); + sg = sg->LookupChild(name[i].c_str()); fullname = sg->GetFullName(); if(strlen(fullname)) { @@ -2375,7 +2377,7 @@ const char* cmMakefile::GetSONameFlag(const char* language) const return GetDefinition(name.c_str()); } -bool cmMakefile::CanIWriteThisFile(const char* fileName) +bool cmMakefile::CanIWriteThisFile(const char* fileName) const { if ( !this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES") ) { @@ -2517,7 +2519,7 @@ std::vector<std::string> cmMakefile } -const char *cmMakefile::ExpandVariablesInString(std::string& source) +const char *cmMakefile::ExpandVariablesInString(std::string& source) const { return this->ExpandVariablesInString(source, false, false); } @@ -2529,7 +2531,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source, const char* filename, long line, bool removeEmpty, - bool replaceAt) + bool replaceAt) const { if ( source.empty() || source.find_first_of("$@\\") == source.npos) { @@ -2773,9 +2775,9 @@ cmMakefile::GetConfigurations(std::vector<std::string>& configs, * non-inherited SOURCE_GROUP commands will have precedence over * inherited ones. */ -cmSourceGroup& +cmSourceGroup* cmMakefile::FindSourceGroup(const char* source, - std::vector<cmSourceGroup> &groups) + std::vector<cmSourceGroup> &groups) const { // First search for a group that lists the file explicitly. for(std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin(); @@ -2784,7 +2786,7 @@ cmMakefile::FindSourceGroup(const char* source, cmSourceGroup *result = sg->MatchChildrenFiles(source); if(result) { - return *result; + return result; } } @@ -2795,13 +2797,13 @@ cmMakefile::FindSourceGroup(const char* source, cmSourceGroup *result = sg->MatchChildrenRegex(source); if(result) { - return *result; + return result; } } // Shouldn't get here, but just in case, return the default group. - return groups.front(); + return &groups.front(); } #endif @@ -2864,7 +2866,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError) bool cmMakefile::ExpandArguments( std::vector<cmListFileArgument> const& inArgs, - std::vector<std::string>& outArgs) + std::vector<std::string>& outArgs) const { std::vector<cmListFileArgument>::const_iterator i; std::string value; @@ -3008,7 +3010,7 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args) } //---------------------------------------------------------------------------- -cmSourceFile* cmMakefile::GetSource(const char* sourceName) +cmSourceFile* cmMakefile::GetSource(const char* sourceName) const { cmSourceFileLocation sfl(this, sourceName); for(std::vector<cmSourceFile*>::const_iterator @@ -3056,7 +3058,7 @@ void cmMakefile::EnableLanguage(std::vector<std::string> const & lang, void cmMakefile::ExpandSourceListArguments( std::vector<std::string> const& arguments, - std::vector<std::string>& newargs, unsigned int /* start */) + std::vector<std::string>& newargs, unsigned int /* start */) const { // now expand the args unsigned int i; @@ -3235,9 +3237,9 @@ void cmMakefile::AddMacro(const char* name, const char* signature) this->MacrosMap[name] = signature; } -void cmMakefile::GetListOfMacros(std::string& macros) +void cmMakefile::GetListOfMacros(std::string& macros) const { - StringStringMap::iterator it; + StringStringMap::const_iterator it; macros = ""; int cc = 0; for ( it = this->MacrosMap.begin(); it != this->MacrosMap.end(); ++it ) @@ -3256,7 +3258,7 @@ cmCacheManager *cmMakefile::GetCacheManager() const return this->GetCMakeInstance()->GetCacheManager(); } -void cmMakefile::DisplayStatus(const char* message, float s) +void cmMakefile::DisplayStatus(const char* message, float s) const { cmake* cm = this->GetLocalGenerator()->GetGlobalGenerator() ->GetCMakeInstance(); @@ -3269,7 +3271,7 @@ void cmMakefile::DisplayStatus(const char* message, float s) cm->UpdateProgress(message, s); } -std::string cmMakefile::GetModulesFile(const char* filename) +std::string cmMakefile::GetModulesFile(const char* filename) const { std::string result; @@ -3369,7 +3371,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) void cmMakefile::ConfigureString(const std::string& input, std::string& output, bool atOnly, - bool escapeQuotes) + bool escapeQuotes) const { // Split input to handle one line at a time. std::string::const_iterator lineStart = input.begin(); @@ -3673,7 +3675,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString); } -const char *cmMakefile::GetPropertyOrDefinition(const char* prop) +const char *cmMakefile::GetPropertyOrDefinition(const char* prop) const { const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY); if (!ret) @@ -3683,13 +3685,13 @@ const char *cmMakefile::GetPropertyOrDefinition(const char* prop) return ret; } -const char *cmMakefile::GetProperty(const char* prop) +const char *cmMakefile::GetProperty(const char* prop) const { return this->GetProperty(prop, cmProperty::DIRECTORY); } const char *cmMakefile::GetProperty(const char* prop, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope) const { if(!prop) { @@ -3713,8 +3715,9 @@ const char *cmMakefile::GetProperty(const char* prop, } else if (!strcmp("LISTFILE_STACK",prop)) { - for (std::deque<cmStdString>::iterator i = this->ListFileStack.begin(); - i != this->ListFileStack.end(); ++i) + for (std::deque<cmStdString>::const_iterator + i = this->ListFileStack.begin(); + i != this->ListFileStack.end(); ++i) { if (i != this->ListFileStack.begin()) { @@ -3828,7 +3831,7 @@ const char *cmMakefile::GetProperty(const char* prop, return retVal; } -bool cmMakefile::GetPropertyAsBool(const char* prop) +bool cmMakefile::GetPropertyAsBool(const char* prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } @@ -3937,13 +3940,13 @@ void cmMakefile::AddCMakeDependFilesFromUser() } } -std::string cmMakefile::GetListFileStack() +std::string cmMakefile::GetListFileStack() const { cmOStringStream tmp; size_t depth = this->ListFileStack.size(); if (depth > 0) { - std::deque<cmStdString>::iterator it = this->ListFileStack.end(); + std::deque<cmStdString>::const_iterator it = this->ListFileStack.end(); do { if (depth != this->ListFileStack.size()) @@ -4089,7 +4092,7 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, //---------------------------------------------------------------------------- cmTarget* cmMakefile::FindTargetToUse(const std::string& name, - bool excludeAliases) + bool excludeAliases) const { // Look for an imported target. These take priority because they // are more local in scope and do not have to be globally unique. @@ -4113,7 +4116,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, } //---------------------------------------------------------------------------- -bool cmMakefile::IsAlias(const std::string& name) +bool cmMakefile::IsAlias(const std::string& name) const { if (this->AliasTargets.find(name) != this->AliasTargets.end()) return true; @@ -4122,7 +4125,8 @@ bool cmMakefile::IsAlias(const std::string& name) } //---------------------------------------------------------------------------- -cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) +cmGeneratorTarget* +cmMakefile::FindGeneratorTargetToUse(const char* name) const { if (cmTarget *t = this->FindTargetToUse(name)) { @@ -4133,7 +4137,7 @@ cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) //---------------------------------------------------------------------------- bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, - bool isCustom) + bool isCustom) const { if(this->IsAlias(name)) { @@ -4224,7 +4228,8 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, } //---------------------------------------------------------------------------- -bool cmMakefile::EnforceUniqueDir(const char* srcPath, const char* binPath) +bool cmMakefile::EnforceUniqueDir(const char* srcPath, + const char* binPath) const { // Make sure the binary directory is unique. cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); @@ -4285,7 +4290,7 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const //---------------------------------------------------------------------------- cmPolicies::PolicyStatus -cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) +cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { // Get the current setting of the policy. cmPolicies::PolicyStatus cur = this->GetPolicyStatusInternal(id); @@ -4313,10 +4318,10 @@ cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) //---------------------------------------------------------------------------- cmPolicies::PolicyStatus -cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) +cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const { // Is the policy set in our stack? - for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); + for(PolicyStackType::const_reverse_iterator psi = this->PolicyStack.rbegin(); psi != this->PolicyStack.rend(); ++psi) { PolicyStackEntry::const_iterator pse = psi->find(id); @@ -4466,7 +4471,7 @@ bool cmMakefile::SetPolicyVersion(const char *version) ApplyPolicyVersion(this,version); } -cmPolicies *cmMakefile::GetPolicies() +cmPolicies *cmMakefile::GetPolicies() const { if (!this->GetCMakeInstance()) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index dadf7ff..45f3b9f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -63,8 +63,8 @@ public: * was used to write the currently loaded cache, note * this method will not work before the cache is loaded. */ - unsigned int GetCacheMajorVersion(); - unsigned int GetCacheMinorVersion(); + unsigned int GetCacheMajorVersion() const; + unsigned int GetCacheMinorVersion() const; /* Check for unused variables in this scope */ void CheckForUnusedVariables() const; @@ -76,7 +76,7 @@ public: bool VariableUsed(const char* ) const; /** Return whether compatibility features needed for a version of the cache or lower should be enabled. */ - bool NeedCacheCompatibility(int major, int minor); + bool NeedCacheCompatibility(int major, int minor) const; /** * Construct an empty makefile. @@ -142,14 +142,14 @@ public: void SetLocalGenerator(cmLocalGenerator*); ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() + cmLocalGenerator* GetLocalGenerator() const { return this->LocalGenerator;} /** * Help enforce global target name uniqueness. */ bool EnforceUniqueName(std::string const& name, std::string& msg, - bool isCustom = false); + bool isCustom = false) const; /** * Perform FinalPass, Library dependency analysis etc before output of the @@ -165,7 +165,7 @@ public: /** * Print the object state to std::cout. */ - void Print(); + void Print() const; /** Add a custom command to the build. */ void AddCustomCommandToTarget(const char* target, @@ -173,7 +173,7 @@ public: const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, - bool escapeOldStyle = true); + bool escapeOldStyle = true) const; cmSourceFile* AddCustomCommandToOutput( const std::vector<std::string>& outputs, const std::vector<std::string>& depends, @@ -250,13 +250,6 @@ public: */ void AddLinkDirectory(const char*); - /** - * Get the list of link directories - */ - std::vector<std::string>& GetLinkDirectories() - { - return this->LinkDirectories; - } const std::vector<std::string>& GetLinkDirectories() const { return this->LinkDirectories; @@ -356,7 +349,7 @@ public: */ bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); bool SetPolicy(const char *id, cmPolicies::PolicyStatus status); - cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id); + cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const; bool SetPolicyVersion(const char *version); void RecordPolicies(cmPolicies::PolicyMap& pm); //@} @@ -379,7 +372,7 @@ public: /** * Get the Policies Instance */ - cmPolicies *GetPolicies(); + cmPolicies *GetPolicies() const; /** * Add an auxiliary directory to the build. @@ -492,7 +485,7 @@ public: { this->IncludeFileRegularExpression = regex; } - const char* GetIncludeRegularExpression() + const char* GetIncludeRegularExpression() const { return this->IncludeFileRegularExpression.c_str(); } @@ -505,7 +498,7 @@ public: { this->ComplainFileRegularExpression = regex; } - const char* GetComplainRegularExpression() + const char* GetComplainRegularExpression() const { return this->ComplainFileRegularExpression.c_str(); } @@ -539,15 +532,14 @@ public: /** Find a target to use in place of the given name. The target returned may be imported or built within the project. */ cmTarget* FindTargetToUse(const std::string& name, - bool excludeAliases = false); - bool IsAlias(const std::string& name); - cmGeneratorTarget* FindGeneratorTargetToUse(const char* name); + bool excludeAliases = false) const; + bool IsAlias(const std::string& name) const; + cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const; /** * Mark include directories as system directories. */ void AddSystemIncludeDirectories(const std::set<cmStdString> &incs); - bool IsSystemIncludeDirectory(const char* dir, const char *config); /** Expand out any arguements in the vector that have ; separated * strings into multiple arguements. A new vector is created @@ -558,12 +550,12 @@ public: */ void ExpandSourceListArguments(std::vector<std::string> const& argsIn, std::vector<std::string>& argsOut, - unsigned int startArgumentIndex); + unsigned int startArgumentIndex) const; /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then a null pointer is returned. */ - cmSourceFile* GetSource(const char* sourceName); + cmSourceFile* GetSource(const char* sourceName) const; /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then create the source file and return it. generated @@ -576,7 +568,7 @@ public: /** * Obtain a list of auxiliary source directories. */ - std::vector<std::string>& GetAuxSourceDirectories() + const std::vector<std::string>& GetAuxSourceDirectories() const {return this->AuxSourceDirectories;} //@{ @@ -621,13 +613,13 @@ public: /** * Get a list of preprocessor define flags. */ - const char* GetDefineFlags() + const char* GetDefineFlags() const {return this->DefineFlags.c_str();} /** * Make sure CMake can write this file */ - bool CanIWriteThisFile(const char* fileName); + bool CanIWriteThisFile(const char* fileName) const; #if defined(CMAKE_BUILD_WITH_CMAKE) /** @@ -639,7 +631,7 @@ public: /** * Get the source group */ - cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name); + cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name) const; #endif /** @@ -652,10 +644,7 @@ public: { this->ListFiles.push_back(file);} void AddCMakeDependFilesFromUser(); - /** - * Get the list file stack as a string - */ - std::string GetListFileStack(); + std::string GetListFileStack() const; /** * Get the current context backtrace. @@ -677,14 +666,14 @@ public: * entry in the this->Definitions map. Also \@var\@ is * expanded to match autoconf style expansions. */ - const char *ExpandVariablesInString(std::string& source); + const char *ExpandVariablesInString(std::string& source) const; const char *ExpandVariablesInString(std::string& source, bool escapeQuotes, bool noEscapes, bool atOnly = false, const char* filename = 0, long line = -1, bool removeEmpty = false, - bool replaceAt = true); + bool replaceAt = true) const; /** * Remove any remaining variables in the string. Anything with ${var} or @@ -703,7 +692,7 @@ public: * See cmConfigureFileCommand for details. */ void ConfigureString(const std::string& input, std::string& output, - bool atOnly, bool escapeQuotes); + bool atOnly, bool escapeQuotes) const; /** * Copy file but change lines acording to ConfigureString @@ -717,14 +706,14 @@ public: /** * find what source group this source is in */ - cmSourceGroup& FindSourceGroup(const char* source, - std::vector<cmSourceGroup> &groups); + cmSourceGroup* FindSourceGroup(const char* source, + std::vector<cmSourceGroup> &groups) const; #endif /** * Print a command's invocation */ - void PrintCommandTrace(const cmListFileFunction& lff); + void PrintCommandTrace(const cmListFileFunction& lff) const; /** * Execute a single CMake command. Returns true if the command @@ -760,14 +749,14 @@ public: #endif ///! Display progress or status message. - void DisplayStatus(const char*, float); + void DisplayStatus(const char*, float) const; /** * Expand the given list file arguments into the full set after * variable replacement and list expansion. */ bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs, - std::vector<std::string>& outArgs); + std::vector<std::string>& outArgs) const; /** * Get the instance */ @@ -784,7 +773,7 @@ public: * Is there a source file that has the provided source file as an output? * if so then return it */ - cmSourceFile *GetSourceFileWithOutput(const char *outName); + cmSourceFile *GetSourceFileWithOutput(const char *outName) const; /** * Add a macro to the list of macros. The arguments should be name of the @@ -803,20 +792,20 @@ public: /** * Get a list of macros as a ; separated string */ - void GetListOfMacros(std::string& macros); + void GetListOfMacros(std::string& macros) const; /** * Return a location of a file in cmake or custom modules directory */ - std::string GetModulesFile(const char* name); + std::string GetModulesFile(const char* name) const; ///! Set/Get a property of this directory 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 *GetPropertyOrDefinition(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 *GetPropertyOrDefinition(const char *prop) const; + const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; + bool GetPropertyAsBool(const char *prop) const; const char* GetFeature(const char* feature, const char* config); @@ -837,7 +826,7 @@ public: void AddTestGenerator(cmTestGenerator* g) { if(g) this->TestGenerators.push_back(g); } - std::vector<cmTestGenerator*>& GetTestGenerators() + const std::vector<cmTestGenerator*>& GetTestGenerators() const { return this->TestGenerators; } // Define the properties @@ -864,20 +853,20 @@ public: /** Set whether or not to report a CMP0000 violation. */ void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } - std::vector<cmValueWithOrigin> GetIncludeDirectoriesEntries() const + const std::vector<cmValueWithOrigin>& GetIncludeDirectoriesEntries() const { return this->IncludeDirectoriesEntries; } - std::vector<cmValueWithOrigin> GetCompileOptionsEntries() const + const std::vector<cmValueWithOrigin>& GetCompileOptionsEntries() const { return this->CompileOptionsEntries; } - std::vector<cmValueWithOrigin> GetCompileDefinitionsEntries() const + const std::vector<cmValueWithOrigin>& GetCompileDefinitionsEntries() const { return this->CompileDefinitionsEntries; } - bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } + bool IsGeneratingBuildSystem() const { return this->GeneratingBuildSystem; } void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } void AddQtUiFileWithOptions(cmSourceFile *sf); @@ -958,7 +947,7 @@ private: bool ParseDefineFlag(std::string const& definition, bool remove); - bool EnforceUniqueDir(const char* srcPath, const char* binPath); + bool EnforceUniqueDir(const char* srcPath, const char* binPath) const; friend class cmMakeDepend; // make depend needs direct access // to the Sources array @@ -979,9 +968,9 @@ private: std::map<cmStdString, bool> SubDirectoryOrder; - cmsys::RegularExpression cmDefineRegex; - cmsys::RegularExpression cmDefine01Regex; - cmsys::RegularExpression cmAtVarRegex; + mutable cmsys::RegularExpression cmDefineRegex; + mutable cmsys::RegularExpression cmDefine01Regex; + mutable cmsys::RegularExpression cmAtVarRegex; cmPropertyMap Properties; @@ -1005,7 +994,6 @@ private: CallStackType CallStack; friend class cmMakefileCall; - cmTarget* FindBasicTarget(const char* name); std::vector<cmTarget*> ImportedTargetsOwned; std::map<cmStdString, cmTarget*> ImportedTargets; @@ -1031,12 +1019,13 @@ private: typedef std::vector<PolicyStackEntry> PolicyStackType; PolicyStackType PolicyStack; std::vector<PolicyStackType::size_type> PolicyBarriers; - cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id); + cmPolicies::PolicyStatus + GetPolicyStatusInternal(cmPolicies::PolicyID id) const; bool CheckCMP0000; // Enforce rules about CMakeLists.txt files. - void EnforceDirectoryLevelRules(); + void EnforceDirectoryLevelRules() const; bool GeneratingBuildSystem; /** @@ -1045,7 +1034,7 @@ private: * relative file paths. It is used as a fall back by * GetSourceFileWithOutput(const char*). */ - cmSourceFile *LinearGetSourceFileWithOutput(const char *cname); + cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const; // A map for fast output to input look up. #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index a1451f1..e191256 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -341,6 +341,11 @@ cmPolicies::cmPolicies() CMP0047, "CMP0047", "Use QCC compiler id for the qcc drivers on QNX.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0048, "CMP0048", + "project() command manages VERSION variables.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index d1bba7b..42271dd 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -101,6 +101,7 @@ public: CMP0045, ///< Error on non-existent target in get_target_property CMP0046, ///< Error on non-existent dependency in add_dependencies CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX. + CMP0048, ///< project() command manages VERSION variables /** \brief Always the last entry. * diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 11f9a76..a9ce0cc 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -62,15 +62,168 @@ bool cmProjectCommand "Value Computed by CMake", cmCacheManager::STATIC); } + bool haveVersion = false; + bool haveLanguages = false; + std::string version; std::vector<std::string> languages; - if(args.size() > 1) + enum Doing { DoingLanguages, DoingVersion }; + Doing doing = DoingLanguages; + for(size_t i = 1; i < args.size(); ++i) { - for(size_t i =1; i < args.size(); ++i) + if(args[i] == "LANGUAGES") + { + if(haveLanguages) + { + this->Makefile->IssueMessage + (cmake::FATAL_ERROR, "LANGUAGES may be specified at most once."); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + haveLanguages = true; + doing = DoingLanguages; + } + else if (args[i] == "VERSION") + { + if(haveVersion) + { + this->Makefile->IssueMessage + (cmake::FATAL_ERROR, "VERSION may be specified at most once."); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + haveVersion = true; + doing = DoingVersion; + } + else if(doing == DoingVersion) + { + doing = DoingLanguages; + version = args[i]; + } + else // doing == DoingLanguages { languages.push_back(args[i]); } } - else + + if (haveVersion && !haveLanguages && !languages.empty()) + { + this->Makefile->IssueMessage + (cmake::FATAL_ERROR, + "project with VERSION must use LANGUAGES before language names."); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + if (haveLanguages && languages.empty()) + { + languages.push_back("NONE"); + } + + cmPolicies::PolicyStatus cmp0048 = + this->Makefile->GetPolicyStatus(cmPolicies::CMP0048); + if (haveVersion) + { + // Set project VERSION variables to given values + if (cmp0048 == cmPolicies::OLD || + cmp0048 == cmPolicies::WARN) + { + this->Makefile->IssueMessage + (cmake::FATAL_ERROR, + "VERSION not allowed unless CMP0048 is set to NEW"); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + + cmsys::RegularExpression + vx("^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$"); + if(!vx.find(version)) + { + std::string e = "VERSION \"" + version + "\" format invalid."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + + std::string vs; + const char* sep = ""; + char vb[4][64]; + unsigned int v[4] = {0,0,0,0}; + int vc = sscanf(version.c_str(), "%u.%u.%u.%u", + &v[0], &v[1], &v[2], &v[3]); + for(int i=0; i < 4; ++i) + { + if(i < vc) + { + sprintf(vb[i], "%u", v[i]); + vs += sep; + vs += vb[i]; + sep = "."; + } + else + { + vb[i][0] = 0; + } + } + + std::string vv; + vv = args[0] + "_VERSION"; + this->Makefile->AddDefinition("PROJECT_VERSION", vs.c_str()); + this->Makefile->AddDefinition(vv.c_str(), vs.c_str()); + vv = args[0] + "_VERSION_MAJOR"; + this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", vb[0]); + this->Makefile->AddDefinition(vv.c_str(), vb[0]); + vv = args[0] + "_VERSION_MINOR"; + this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", vb[1]); + this->Makefile->AddDefinition(vv.c_str(), vb[1]); + vv = args[0] + "_VERSION_PATCH"; + this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", vb[2]); + this->Makefile->AddDefinition(vv.c_str(), vb[2]); + vv = args[0] + "_VERSION_TWEAK"; + this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]); + this->Makefile->AddDefinition(vv.c_str(), vb[3]); + } + else if(cmp0048 != cmPolicies::OLD) + { + // Set project VERSION variables to empty + std::vector<std::string> vv; + vv.push_back("PROJECT_VERSION"); + vv.push_back("PROJECT_VERSION_MAJOR"); + vv.push_back("PROJECT_VERSION_MINOR"); + vv.push_back("PROJECT_VERSION_PATCH"); + vv.push_back("PROJECT_VERSION_TWEAK"); + vv.push_back(args[0] + "_VERSION"); + vv.push_back(args[0] + "_VERSION_MAJOR"); + vv.push_back(args[0] + "_VERSION_MINOR"); + vv.push_back(args[0] + "_VERSION_PATCH"); + vv.push_back(args[0] + "_VERSION_TWEAK"); + std::string vw; + for(std::vector<std::string>::iterator i = vv.begin(); + i != vv.end(); ++i) + { + const char* v = this->Makefile->GetDefinition(i->c_str()); + if(v && *v) + { + if(cmp0048 == cmPolicies::WARN) + { + vw += "\n "; + vw += *i; + } + else + { + this->Makefile->AddDefinition(i->c_str(), ""); + } + } + } + if(!vw.empty()) + { + cmOStringStream w; + w << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0048)) + << "\nThe following variable(s) would be set to empty:" << vw; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + } + + if (languages.empty()) { // if no language is specified do c and c++ languages.push_back("C"); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index ec98c2c..23422a2 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -142,7 +142,7 @@ bool cmSourceFile::FindFullPath(std::string* error) } // The file is not generated. It must exist on disk. - cmMakefile* mf = this->Location.GetMakefile(); + cmMakefile const* mf = this->Location.GetMakefile(); const char* tryDirs[3] = {0, 0, 0}; if(this->Location.DirectoryIsAmbiguous()) { @@ -264,7 +264,7 @@ void cmSourceFile::CheckExtension() void cmSourceFile::CheckLanguage(std::string const& ext) { // Try to identify the source file language from the extension. - cmMakefile* mf = this->Location.GetMakefile(); + cmMakefile const* mf = this->Location.GetMakefile(); cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator(); if(const char* l = gg->GetLanguageFromExtension(ext.c_str())) { @@ -292,10 +292,10 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) cmSystemTools::GetFilenameLastExtension(this->Location.GetName()); if (ext == ".ui") { - cmMakefile* mf = this->Location.GetMakefile(); + cmMakefile const* mf = this->Location.GetMakefile(); if (strcmp(prop, "AUTOUIC_OPTIONS") == 0) { - mf->AddQtUiFileWithOptions(this); + const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this); } } } @@ -360,7 +360,7 @@ const char* cmSourceFile::GetProperty(const char* prop) const this->Properties.GetPropertyValue(prop, cmProperty::SOURCE_FILE, chain); if (chain) { - cmMakefile* mf = this->Location.GetMakefile(); + cmMakefile const* mf = this->Location.GetMakefile(); return mf->GetProperty(prop,cmProperty::SOURCE_FILE); } diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 5525b61..5a8578b 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -18,7 +18,7 @@ //---------------------------------------------------------------------------- cmSourceFileLocation -::cmSourceFileLocation(cmMakefile* mf, const char* name): Makefile(mf) +::cmSourceFileLocation(cmMakefile const* mf, const char* name): Makefile(mf) { this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name); this->AmbiguousExtension = true; @@ -89,7 +89,7 @@ void cmSourceFileLocation::UpdateExtension(const char* name) // The global generator checks extensions of enabled languages. cmGlobalGenerator* gg = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); - cmMakefile* mf = this->Makefile; + cmMakefile const* mf = this->Makefile; const std::vector<std::string>& srcExts = mf->GetSourceExtensions(); const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions(); if(gg->GetLanguageFromExtension(ext.c_str()) || @@ -170,7 +170,7 @@ cmSourceFileLocation // Only a fixed set of extensions will be tried to match a file on // disk. One of these must match if loc refers to this source file. std::string ext = this->Name.substr(loc.Name.size()+1); - cmMakefile* mf = this->Makefile; + cmMakefile const* mf = this->Makefile; const std::vector<std::string>& srcExts = mf->GetSourceExtensions(); if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) { diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index 216dd07..c03eee7 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -33,7 +33,7 @@ public: * Construct for a source file created in a given cmMakefile * instance with an initial name. */ - cmSourceFileLocation(cmMakefile* mf, const char* name); + cmSourceFileLocation(cmMakefile const* mf, const char* name); /** * Return whether the givne source file location could refers to the @@ -81,9 +81,9 @@ public: /** * Get the cmMakefile instance for which the source file was created. */ - cmMakefile* GetMakefile() const { return this->Makefile; } + cmMakefile const* GetMakefile() const { return this->Makefile; } private: - cmMakefile* Makefile; + cmMakefile const* Makefile; bool AmbiguousDirectory; bool AmbiguousExtension; std::string Directory; diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index f09976f..d272b6c 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -126,12 +126,12 @@ void cmSourceGroup::AddChild(cmSourceGroup child) } //---------------------------------------------------------------------------- -cmSourceGroup *cmSourceGroup::lookupChild(const char* name) +cmSourceGroup *cmSourceGroup::LookupChild(const char* name) const { // initializing iterators - std::vector<cmSourceGroup>::iterator iter = + std::vector<cmSourceGroup>::const_iterator iter = this->Internal->GroupChildren.begin(); - std::vector<cmSourceGroup>::iterator end = + const std::vector<cmSourceGroup>::const_iterator end = this->Internal->GroupChildren.end(); // st @@ -142,7 +142,7 @@ cmSourceGroup *cmSourceGroup::lookupChild(const char* name) // look if descenened is the one were looking for if(sgName == name) { - return &(*iter); // if it so return it + return const_cast<cmSourceGroup*>(&(*iter)); // if it so return it } } diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 11a0c74..3bbdef9 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -56,7 +56,7 @@ public: /** * Looks up child and returns it */ - cmSourceGroup *lookupChild(const char *name); + cmSourceGroup *LookupChild(const char *name) const; /** * Get the name of this group. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 21f8d4c..e51095e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1620,16 +1620,11 @@ void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, } //---------------------------------------------------------------------------- -void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry, - bool before) +void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry) { cmGeneratorExpression ge(entry.Backtrace); - std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position - = before ? this->Internal->CompileDefinitionsEntries.begin() - : this->Internal->CompileDefinitionsEntries.end(); - - this->Internal->CompileDefinitionsEntries.insert(position, + this->Internal->CompileDefinitionsEntries.push_back( new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index ce0d812..271824b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -531,8 +531,7 @@ public: bool before = false); void InsertCompileOption(const cmValueWithOrigin &entry, bool before = false); - void InsertCompileDefinition(const cmValueWithOrigin &entry, - bool before = false); + void InsertCompileDefinition(const cmValueWithOrigin &entry); void AppendBuildInterfaceIncludes(); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index eee7c14..ed7e243 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -708,9 +708,9 @@ void cmVisualStudio10TargetGenerator::WriteGroups() { cmSourceFile* sf = *s; std::string const& source = sf->GetFullPath(); - cmSourceGroup& sourceGroup = + cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); - groupsUsed.insert(&sourceGroup); + groupsUsed.insert(sourceGroup); } this->AddMissingSourceGroups(groupsUsed, sourceGroups); @@ -901,9 +901,9 @@ WriteGroupSources(const char* name, { cmSourceFile* sf = s->SourceFile; std::string const& source = sf->GetFullPath(); - cmSourceGroup& sourceGroup = + cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); - const char* filter = sourceGroup.GetFullName(); + const char* filter = sourceGroup->GetFullName(); this->WriteString("<", 2); std::string path = this->ConvertPath(source, s->RelativePath); this->ConvertToWindowsSlash(path); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 60dc688..1e04f2f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -400,6 +400,29 @@ if(BUILD_TESTING) ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets) endif() + if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND + (NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2) AND + (CMAKE_SYSTEM_NAME MATCHES "Linux")) + + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag( + -fvisibility-inlines-hidden run_inlines_hidden_test) + endif() + + if(run_inlines_hidden_test) + add_test(VisibilityInlinesHidden ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VisibilityInlinesHidden" + "${CMake_BINARY_DIR}/Tests/VisibilityInlinesHidden" + ${build_generator_args} + --build-project VisibilityInlinesHidden + --build-options ${build_options} + ) + list(APPEND TEST_BUILD_DIRS + "${CMake_BINARY_DIR}/Tests/VisibilityInlinesHidden" + ) + endif() + add_test(LinkFlags-prepare ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 41714f6..ce36830 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -38,6 +38,10 @@ AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" ) +AddCMakeTest(FileDownloadBadHash "") +set_property(TEST CMake.FileDownloadBadHash PROPERTY + WILL_FAIL TRUE + ) AddCMakeTest(FileUpload "") diff --git a/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in b/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in new file mode 100644 index 0000000..4a47c06 --- /dev/null +++ b/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in @@ -0,0 +1,10 @@ +set(url "file://@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") +set(dir "@CMAKE_CURRENT_BINARY_DIR@/downloads") + +file(DOWNLOAD + ${url} + ${dir}/file3.png + TIMEOUT 2 + STATUS status + EXPECTED_HASH SHA1=5555555555555555555555555555555555555555 + ) diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 91086c6..83ade2b 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -94,3 +94,16 @@ file(DOWNLOAD EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 ) message(STATUS "${status}") + +message(STATUS "FileDownload:11") +file(DOWNLOAD + badhostname.png + ${dir}/file11.png + TIMEOUT 2 + STATUS status + ) +message(STATUS "${status}") +list(GET status 0 status_code) +if(NOT ${status_code} EQUAL 6) + message(SEND_ERROR "error: expected status code 6 for bad host name, got: ${status_code}") +endif() diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index db4e08d..642a618 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -54,7 +54,9 @@ function(check_updates build) set(EXTRA "${UPDATE_XML_ENTRIES}") list(REMOVE_ITEM EXTRA ${ARGN} ${UPDATE_EXTRA} ${UPDATE_MAYBE}) set(MISSING "${ARGN}" ${UPDATE_EXTRA}) - list(REMOVE_ITEM MISSING ${UPDATE_XML_ENTRIES}) + if(NOT "" STREQUAL "${UPDATE_XML_ENTRIES}") + list(REMOVE_ITEM MISSING ${UPDATE_XML_ENTRIES}) + endif() if(NOT UPDATE_NOT_GLOBAL) set(rev_elements Revision PriorRevision ${UPDATE_GLOBAL_ELEMENTS}) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 602ff0f..d9344ec 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -512,6 +512,22 @@ if(do_git_tests) LOG_UPDATE 1 ) set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + + # git by explicit branch/tag with empty submodule list + # + set(proj TutorialStep1-GIT-bytag-withsubmodules) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_TAG "origin/master" + GIT_SUBMODULES "" + UPDATE_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + endif() set(do_hg_tests 0) diff --git a/Tests/RunCMake/CMP0041/CMakeLists.txt b/Tests/RunCMake/CMP0041/CMakeLists.txt index 11ea636..f1d9cae 100644 --- a/Tests/RunCMake/CMP0041/CMakeLists.txt +++ b/Tests/RunCMake/CMP0041/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0042/CMakeLists.txt b/Tests/RunCMake/CMP0042/CMakeLists.txt index 11ea636..f1d9cae 100644 --- a/Tests/RunCMake/CMP0042/CMakeLists.txt +++ b/Tests/RunCMake/CMP0042/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0043/CMakeLists.txt b/Tests/RunCMake/CMP0043/CMakeLists.txt index b465c88..5e95460 100644 --- a/Tests/RunCMake/CMP0043/CMakeLists.txt +++ b/Tests/RunCMake/CMP0043/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0045/CMakeLists.txt b/Tests/RunCMake/CMP0045/CMakeLists.txt index 11ea636..f1d9cae 100644 --- a/Tests/RunCMake/CMP0045/CMakeLists.txt +++ b/Tests/RunCMake/CMP0045/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9646e67..c29b736 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -82,6 +82,7 @@ add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(list) add_RunCMake_test(message) +add_RunCMake_test(project) add_RunCMake_test(string) add_RunCMake_test(try_compile) add_RunCMake_test(set) diff --git a/Tests/RunCMake/project/CMP0048-NEW-stderr.txt b/Tests/RunCMake/project/CMP0048-NEW-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-NEW-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/project/CMP0048-NEW-stdout.txt b/Tests/RunCMake/project/CMP0048-NEW-stdout.txt new file mode 100644 index 0000000..38261e5 --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-NEW-stdout.txt @@ -0,0 +1,30 @@ +-- PROJECT_VERSION='1.2.3.4' +-- ProjectA_VERSION='1.2.3.4' +-- PROJECT_VERSION_MAJOR='1' +-- ProjectA_VERSION_MAJOR='1' +-- PROJECT_VERSION_MINOR='2' +-- ProjectA_VERSION_MINOR='2' +-- PROJECT_VERSION_PATCH='3' +-- ProjectA_VERSION_PATCH='3' +-- PROJECT_VERSION_TWEAK='4' +-- ProjectA_VERSION_TWEAK='4' +-- PROJECT_VERSION='0.1.2' +-- ProjectB_VERSION='0.1.2' +-- PROJECT_VERSION_MAJOR='0' +-- ProjectB_VERSION_MAJOR='0' +-- PROJECT_VERSION_MINOR='1' +-- ProjectB_VERSION_MINOR='1' +-- PROJECT_VERSION_PATCH='2' +-- ProjectB_VERSION_PATCH='2' +-- PROJECT_VERSION_TWEAK='' +-- ProjectB_VERSION_TWEAK='' +-- PROJECT_VERSION='' +-- ProjectC_VERSION='' +-- PROJECT_VERSION_MAJOR='' +-- ProjectC_VERSION_MAJOR='' +-- PROJECT_VERSION_MINOR='' +-- ProjectC_VERSION_MINOR='' +-- PROJECT_VERSION_PATCH='' +-- ProjectC_VERSION_PATCH='' +-- PROJECT_VERSION_TWEAK='' +-- ProjectC_VERSION_TWEAK='' diff --git a/Tests/RunCMake/project/CMP0048-NEW.cmake b/Tests/RunCMake/project/CMP0048-NEW.cmake new file mode 100644 index 0000000..7e16b70 --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-NEW.cmake @@ -0,0 +1,19 @@ +macro(print_versions name) + foreach(v "" _MAJOR _MINOR _PATCH _TWEAK) + message(STATUS "PROJECT_VERSION${v}='${PROJECT_VERSION${v}}'") + message(STATUS "${name}_VERSION${v}='${${name}_VERSION${v}}'") + endforeach() +endmacro() + +cmake_policy(SET CMP0048 NEW) + +project(ProjectA VERSION 1.2.3.4 LANGUAGES NONE) +print_versions(ProjectA) + +project(ProjectB VERSION 0.1.2 LANGUAGES NONE) +print_versions(ProjectB) + +set(PROJECT_VERSION 1) +set(ProjectC_VERSION 1) +project(ProjectC NONE) +print_versions(ProjectC) diff --git a/Tests/RunCMake/project/CMP0048-OLD-VERSION-result.txt b/Tests/RunCMake/project/CMP0048-OLD-VERSION-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-OLD-VERSION-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/CMP0048-OLD-VERSION-stderr.txt b/Tests/RunCMake/project/CMP0048-OLD-VERSION-stderr.txt new file mode 100644 index 0000000..3a13d32 --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-OLD-VERSION-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0048-OLD-VERSION.cmake:1 \(project\): + VERSION not allowed unless CMP0048 is set to NEW +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/project/CMP0048-OLD-VERSION.cmake b/Tests/RunCMake/project/CMP0048-OLD-VERSION.cmake new file mode 100644 index 0000000..6fbbe0a --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-OLD-VERSION.cmake @@ -0,0 +1,2 @@ +project(MyProject VERSION 1 LANGUAGES NONE) +message("This line not reached.") diff --git a/Tests/RunCMake/project/CMP0048-OLD-stdout.txt b/Tests/RunCMake/project/CMP0048-OLD-stdout.txt new file mode 100644 index 0000000..1a25c7b --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-OLD-stdout.txt @@ -0,0 +1,2 @@ +-- PROJECT_VERSION='1' +-- MyProject_VERSION_TWEAK='0' diff --git a/Tests/RunCMake/project/CMP0048-OLD.cmake b/Tests/RunCMake/project/CMP0048-OLD.cmake new file mode 100644 index 0000000..6c32d2c --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-OLD.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0048 OLD) +set(PROJECT_VERSION 1) +set(MyProject_VERSION_TWEAK 0) +project(MyProject NONE) +message(STATUS "PROJECT_VERSION='${PROJECT_VERSION}'") +message(STATUS "MyProject_VERSION_TWEAK='${MyProject_VERSION_TWEAK}'") diff --git a/Tests/RunCMake/project/CMP0048-WARN-stderr.txt b/Tests/RunCMake/project/CMP0048-WARN-stderr.txt new file mode 100644 index 0000000..6d29ad2 --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-WARN-stderr.txt @@ -0,0 +1,12 @@ +CMake Warning \(dev\) at CMP0048-WARN.cmake:3 \(project\): + Policy CMP0048 is not set: project\(\) command manages VERSION variables. + Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The following variable\(s\) would be set to empty: + + PROJECT_VERSION + MyProject_VERSION_TWEAK +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/project/CMP0048-WARN.cmake b/Tests/RunCMake/project/CMP0048-WARN.cmake new file mode 100644 index 0000000..97359e6 --- /dev/null +++ b/Tests/RunCMake/project/CMP0048-WARN.cmake @@ -0,0 +1,3 @@ +set(PROJECT_VERSION 1) +set(MyProject_VERSION_TWEAK 0) +project(MyProject NONE) diff --git a/Tests/RunCMake/project/CMakeLists.txt b/Tests/RunCMake/project/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/project/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/project/LanguagesEmpty-stdout.txt b/Tests/RunCMake/project/LanguagesEmpty-stdout.txt new file mode 100644 index 0000000..fb9c7e8 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesEmpty-stdout.txt @@ -0,0 +1 @@ +ENABLED_LANGUAGES='NONE' diff --git a/Tests/RunCMake/project/LanguagesEmpty.cmake b/Tests/RunCMake/project/LanguagesEmpty.cmake new file mode 100644 index 0000000..4de2cca --- /dev/null +++ b/Tests/RunCMake/project/LanguagesEmpty.cmake @@ -0,0 +1,3 @@ +project(ProjectA LANGUAGES) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") diff --git a/Tests/RunCMake/project/LanguagesImplicit-stdout.txt b/Tests/RunCMake/project/LanguagesImplicit-stdout.txt new file mode 100644 index 0000000..fb9c7e8 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesImplicit-stdout.txt @@ -0,0 +1 @@ +ENABLED_LANGUAGES='NONE' diff --git a/Tests/RunCMake/project/LanguagesImplicit.cmake b/Tests/RunCMake/project/LanguagesImplicit.cmake new file mode 100644 index 0000000..e408454 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesImplicit.cmake @@ -0,0 +1,3 @@ +project(ProjectA NONE) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") diff --git a/Tests/RunCMake/project/LanguagesNONE-stdout.txt b/Tests/RunCMake/project/LanguagesNONE-stdout.txt new file mode 100644 index 0000000..fb9c7e8 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesNONE-stdout.txt @@ -0,0 +1 @@ +ENABLED_LANGUAGES='NONE' diff --git a/Tests/RunCMake/project/LanguagesNONE.cmake b/Tests/RunCMake/project/LanguagesNONE.cmake new file mode 100644 index 0000000..2c0125f --- /dev/null +++ b/Tests/RunCMake/project/LanguagesNONE.cmake @@ -0,0 +1,3 @@ +project(ProjectA LANGUAGES NONE) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") diff --git a/Tests/RunCMake/project/LanguagesTwice-result.txt b/Tests/RunCMake/project/LanguagesTwice-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/LanguagesTwice-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/LanguagesTwice-stderr.txt b/Tests/RunCMake/project/LanguagesTwice-stderr.txt new file mode 100644 index 0000000..9c69dd0 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesTwice-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LanguagesTwice.cmake:1 \(project\): + LANGUAGES may be specified at most once. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/project/LanguagesTwice.cmake b/Tests/RunCMake/project/LanguagesTwice.cmake new file mode 100644 index 0000000..6c4a3dc --- /dev/null +++ b/Tests/RunCMake/project/LanguagesTwice.cmake @@ -0,0 +1,2 @@ +project(ProjectA LANGUAGES NONE LANGUAGES) +message("This line not reached.") diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake new file mode 100644 index 0000000..6ab0fc9 --- /dev/null +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -0,0 +1,17 @@ +include(RunCMake) + +run_cmake(LanguagesImplicit) +run_cmake(LanguagesEmpty) +run_cmake(LanguagesNONE) +run_cmake(LanguagesTwice) +run_cmake(VersionAndLanguagesEmpty) +run_cmake(VersionEmpty) +run_cmake(VersionInvalid) +run_cmake(VersionMissingLanguages) +run_cmake(VersionMissingValueOkay) +run_cmake(VersionTwice) + +run_cmake(CMP0048-OLD) +run_cmake(CMP0048-OLD-VERSION) +run_cmake(CMP0048-WARN) +run_cmake(CMP0048-NEW) diff --git a/Tests/RunCMake/project/VersionAndLanguagesEmpty-stdout.txt b/Tests/RunCMake/project/VersionAndLanguagesEmpty-stdout.txt new file mode 100644 index 0000000..eae7da7 --- /dev/null +++ b/Tests/RunCMake/project/VersionAndLanguagesEmpty-stdout.txt @@ -0,0 +1,2 @@ +-- ENABLED_LANGUAGES='NONE' +-- PROJECT_VERSION='1' diff --git a/Tests/RunCMake/project/VersionAndLanguagesEmpty.cmake b/Tests/RunCMake/project/VersionAndLanguagesEmpty.cmake new file mode 100644 index 0000000..d6056ce --- /dev/null +++ b/Tests/RunCMake/project/VersionAndLanguagesEmpty.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectA VERSION 1 LANGUAGES NONE) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") +message(STATUS "PROJECT_VERSION='${PROJECT_VERSION}'") diff --git a/Tests/RunCMake/project/VersionEmpty-stdout.txt b/Tests/RunCMake/project/VersionEmpty-stdout.txt new file mode 100644 index 0000000..3ae42e0 --- /dev/null +++ b/Tests/RunCMake/project/VersionEmpty-stdout.txt @@ -0,0 +1,2 @@ +-- ENABLED_LANGUAGES='NONE' +-- PROJECT_VERSION='' diff --git a/Tests/RunCMake/project/VersionEmpty.cmake b/Tests/RunCMake/project/VersionEmpty.cmake new file mode 100644 index 0000000..0cfb291 --- /dev/null +++ b/Tests/RunCMake/project/VersionEmpty.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0048 NEW) +set(PROJECT_VERSION 1) +project(ProjectA VERSION "" LANGUAGES NONE) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") +message(STATUS "PROJECT_VERSION='${PROJECT_VERSION}'") diff --git a/Tests/RunCMake/project/VersionInvalid-result.txt b/Tests/RunCMake/project/VersionInvalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/VersionInvalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/VersionInvalid-stderr.txt b/Tests/RunCMake/project/VersionInvalid-stderr.txt new file mode 100644 index 0000000..48358d1 --- /dev/null +++ b/Tests/RunCMake/project/VersionInvalid-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VersionInvalid.cmake:2 \(project\): + VERSION "NONE" format invalid. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/project/VersionInvalid.cmake b/Tests/RunCMake/project/VersionInvalid.cmake new file mode 100644 index 0000000..8d5dd7f --- /dev/null +++ b/Tests/RunCMake/project/VersionInvalid.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectA VERSION NONE) +message("This line not reached.") diff --git a/Tests/RunCMake/project/VersionMissingLanguages-result.txt b/Tests/RunCMake/project/VersionMissingLanguages-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/VersionMissingLanguages-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt b/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt new file mode 100644 index 0000000..52433bc --- /dev/null +++ b/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VersionMissingLanguages.cmake:2 \(project\): + project with VERSION must use LANGUAGES before language names. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/project/VersionMissingLanguages.cmake b/Tests/RunCMake/project/VersionMissingLanguages.cmake new file mode 100644 index 0000000..dc41514 --- /dev/null +++ b/Tests/RunCMake/project/VersionMissingLanguages.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectA VERSION 1 NONE) +message("This line not reached.") diff --git a/Tests/RunCMake/project/VersionMissingValueOkay-stdout.txt b/Tests/RunCMake/project/VersionMissingValueOkay-stdout.txt new file mode 100644 index 0000000..3ae42e0 --- /dev/null +++ b/Tests/RunCMake/project/VersionMissingValueOkay-stdout.txt @@ -0,0 +1,2 @@ +-- ENABLED_LANGUAGES='NONE' +-- PROJECT_VERSION='' diff --git a/Tests/RunCMake/project/VersionMissingValueOkay.cmake b/Tests/RunCMake/project/VersionMissingValueOkay.cmake new file mode 100644 index 0000000..1fb1437 --- /dev/null +++ b/Tests/RunCMake/project/VersionMissingValueOkay.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0048 NEW) +set(PROJECT_VERSION 1) +project(ProjectA VERSION LANGUAGES NONE) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") +message(STATUS "PROJECT_VERSION='${PROJECT_VERSION}'") diff --git a/Tests/RunCMake/project/VersionTwice-result.txt b/Tests/RunCMake/project/VersionTwice-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/VersionTwice-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/VersionTwice-stderr.txt b/Tests/RunCMake/project/VersionTwice-stderr.txt new file mode 100644 index 0000000..ec07ead --- /dev/null +++ b/Tests/RunCMake/project/VersionTwice-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VersionTwice.cmake:2 \(project\): + VERSION may be specified at most once. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/project/VersionTwice.cmake b/Tests/RunCMake/project/VersionTwice.cmake new file mode 100644 index 0000000..dc0c996 --- /dev/null +++ b/Tests/RunCMake/project/VersionTwice.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectA VERSION 1 VERSION) +message("This line not reached.") diff --git a/Tests/VisibilityInlinesHidden/CMakeLists.txt b/Tests/VisibilityInlinesHidden/CMakeLists.txt new file mode 100644 index 0000000..8ebc39c --- /dev/null +++ b/Tests/VisibilityInlinesHidden/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8) + +project(VisibilityInlinesHidden) + +add_library(inlines_hidden SHARED foo.cpp bar.c) +set_property(TARGET inlines_hidden PROPERTY VISIBILITY_INLINES_HIDDEN ON) +target_compile_options(inlines_hidden PRIVATE -Werror) + +add_custom_command(TARGET inlines_hidden POST_BUILD + COMMAND ${CMAKE_COMMAND} + -DCMAKE_NM=${CMAKE_NM} + -DTEST_LIBRARY_PATH=$<TARGET_FILE:inlines_hidden> + -P ${CMAKE_CURRENT_SOURCE_DIR}/verify.cmake +) diff --git a/Tests/VisibilityInlinesHidden/bar.c b/Tests/VisibilityInlinesHidden/bar.c new file mode 100644 index 0000000..e425999 --- /dev/null +++ b/Tests/VisibilityInlinesHidden/bar.c @@ -0,0 +1 @@ +void bar() {} diff --git a/Tests/VisibilityInlinesHidden/foo.cpp b/Tests/VisibilityInlinesHidden/foo.cpp new file mode 100644 index 0000000..2b66b69 --- /dev/null +++ b/Tests/VisibilityInlinesHidden/foo.cpp @@ -0,0 +1,11 @@ +class Foo +{ +public: + void bar() {} +}; + +void baz() +{ + Foo foo; + foo.bar(); +} diff --git a/Tests/VisibilityInlinesHidden/verify.cmake b/Tests/VisibilityInlinesHidden/verify.cmake new file mode 100644 index 0000000..80dd13c --- /dev/null +++ b/Tests/VisibilityInlinesHidden/verify.cmake @@ -0,0 +1,14 @@ +execute_process(COMMAND ${CMAKE_NM} -D ${TEST_LIBRARY_PATH} + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE ERROR +) + +if(NOT "${RESULT}" STREQUAL "0") + message(FATAL_ERROR "nm failed [${RESULT}] [${OUTPUT}] [${ERROR}]") +endif() + +if(${OUTPUT} MATCHES "Foo[^\\n]*bar") + message(FATAL_ERROR + "Found Foo::bar() which should have been hidden [${OUTPUT}]") +endif() diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 410f37a..8b3e325 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -11,4 +11,25 @@ #============================================================================= subdirs(Doxygen KWStyle) -add_subdirectory(Sphinx) +if(CMAKE_DOC_TARBALL) + # Undocumented option to extract and install pre-built documentation. + # This is intended for use during packaging of CMake itself. + if(CMAKE_DOC_TARBALL MATCHES "/([^/]+)\\.tar\\.gz$") + set(dir "${CMAKE_MATCH_1}") + else() + message(FATAL_ERROR "CMAKE_DOC_TARBALL must end in .tar.gz") + endif() + add_custom_command( + OUTPUT ${dir}.stamp + COMMAND cmake -E remove_directory ${dir} + COMMAND cmake -E tar xf ${CMAKE_DOC_TARBALL} + COMMAND cmake -E touch ${dir}.stamp + DEPENDS ${CMAKE_DOC_TARBALL} + ) + add_custom_target(documentation ALL DEPENDS ${dir}.stamp) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dir}/ + DESTINATION . USE_SOURCE_PERMISSIONS) +else() + # Normal documentation build. + add_subdirectory(Sphinx) +endif() diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 37e223d..95428b6 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -28,15 +28,53 @@ function(write_batch_shell_script filename) math(EXPR y "160*(${i}%4)") file(APPEND ${filename} " -${CMAKE_COMMAND} -DCMAKE_CREATE_VERSION=${CMAKE_CREATE_VERSION} -P ${CMAKE_ROOT}/Utilities/Release/${f} < /dev/null >& ${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log & -xterm -geometry 64x6+${x}+${y} -sb -sl 2000 -T ${f}-${CMAKE_CREATE_VERSION}.log -e tail -f ${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log& +\"${CMAKE_COMMAND}\" -DCMAKE_CREATE_VERSION=${CMAKE_CREATE_VERSION} -DCMAKE_DOC_TARBALL=\"${CMAKE_DOC_TARBALL}\" -P \"${CMAKE_ROOT}/Utilities/Release/${f}\" < /dev/null >& \"${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log\" & +xterm -geometry 64x6+${x}+${y} -sb -sl 2000 -T ${f}-${CMAKE_CREATE_VERSION}.log -e tail -f \"${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log\" & ") math(EXPR i "${i}+1") endforeach() execute_process(COMMAND chmod a+x ${filename}) endfunction() +function(write_docs_shell_script filename) + find_program(SPHINX_EXECUTABLE + NAMES sphinx-build sphinx-build.py + DOC "Sphinx Documentation Builder (sphinx-doc.org)" + ) + if(NOT SPHINX_EXECUTABLE) + message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!") + endif() + + set(name cmake-${CMAKE_CREATE_VERSION}-docs) + file(WRITE "${filename}" "#!/usr/bin/env bash + +name=${name} && +inst=\"\$PWD/\$name\" +(GIT_WORK_TREE=x git archive --prefix=\${name}-src/ ${CMAKE_CREATE_VERSION}) | tar x && +rm -rf \${name}-build && +mkdir \${name}-build && +cd \${name}-build && +\"${CMAKE_COMMAND}\" ../\${name}-src/Utilities/Sphinx \\ + -DCMAKE_INSTALL_PREFIX=\"\$inst/\" \\ + -DSPHINX_EXECUTABLE=\"${SPHINX_EXECUTABLE}\" \\ + -DSPHINX_HTML=ON -DSPHINX_MAN=ON && +make install && +cd .. && +tar czf \${name}.tar.gz \${name} || +echo 'Failed to create \${name}.tar.gz' +") + execute_process(COMMAND chmod a+x ${filename}) + set(CMAKE_DOC_TARBALL "${name}.tar.gz" PARENT_SCOPE) +endfunction() + +write_docs_shell_script("create-${CMAKE_CREATE_VERSION}-docs.sh") write_batch_shell_script("create-${CMAKE_CREATE_VERSION}-batch1.sh" ${RELEASE_SCRIPTS_BATCH_1}) +unset(CMAKE_DOC_TARBALL) # No pre-built docs in second batch. write_batch_shell_script("create-${CMAKE_CREATE_VERSION}-batch2.sh" ${RELEASE_SCRIPTS_BATCH_2}) -message("Run ./create-${CMAKE_CREATE_VERSION}-batch1.sh, then after all those builds complete, run ./create-${CMAKE_CREATE_VERSION}-batch2.sh") +message("Run one at a time: + ./create-${CMAKE_CREATE_VERSION}-docs.sh && + ./create-${CMAKE_CREATE_VERSION}-batch1.sh && + ./create-${CMAKE_CREATE_VERSION}-batch2.sh && + echo done +") diff --git a/Utilities/Release/dash2win64_cygwin.cmake b/Utilities/Release/dash2win64_cygwin.cmake index 663c615..ac3c527 100644 --- a/Utilities/Release/dash2win64_cygwin.cmake +++ b/Utilities/Release/dash2win64_cygwin.cmake @@ -10,11 +10,13 @@ set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release CMAKE_Fortran_COMPILER_FULLPATH:FILEPATH=FALSE CTEST_TEST_TIMEOUT:STRING=7200 DART_TESTING_TIMEOUT:STRING=7200 +SPHINX_HTML:BOOL=ON +SPHINX_MAN:BOOL=ON ") set(CXX g++) set(CC gcc) set(SCRIPT_NAME dash2win64cygwin) -set(GIT_EXTRA "git config core.autocrlf true") +set(GIT_EXTRA "git config core.autocrlf false") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) # WARNING: Temporary fix!! This exclusion of the ExternalProject test diff --git a/Utilities/Release/release_cmake.cmake b/Utilities/Release/release_cmake.cmake index f351ac8..630f54f 100644 --- a/Utilities/Release/release_cmake.cmake +++ b/Utilities/Release/release_cmake.cmake @@ -66,6 +66,17 @@ macro(remote_command comment command) endif() endmacro() +if(CMAKE_DOC_TARBALL) + message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:'") + execute_process(COMMAND + scp ${CMAKE_DOC_TARBALL} ${HOST}: + RESULT_VARIABLE result) + if(${result} GREATER 0) + message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:'") + endif() + get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME) +endif() + # set this so configure file will work from script mode # create the script specific for the given host set(SCRIPT_FILE release_cmake-${SCRIPT_NAME}.sh) diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in index 82c039b..f41bda8 100755 --- a/Utilities/Release/release_cmake.sh.in +++ b/Utilities/Release/release_cmake.sh.in @@ -15,6 +15,13 @@ check_exit_value() fi } +CMAKE_DOC_TARBALL="" +if [ ! -z "@CMAKE_DOC_TARBALL_NAME@" ] ; then + CMAKE_DOC_TARBALL=@CMAKE_RELEASE_DIRECTORY@/@CMAKE_DOC_TARBALL_NAME@ + mv "$HOME/@CMAKE_DOC_TARBALL_NAME@" "$CMAKE_DOC_TARBALL" + check_exit_value $? "mv doc tarball" || exit 1 +fi + if [ ! -z "@CC@" ]; then export CC="@CC@" check_exit_value $? "set CC compiler env var" || exit 1 @@ -76,6 +83,11 @@ if [ ! -z "@USER_OVERRIDE@" ]; then echo "CMAKE_USER_MAKE_RULES_OVERRIDE:FILEPATH=@CMAKE_RELEASE_DIRECTORY@/@CMAKE_CREATE_VERSION@-build/user.txt" >> @CMAKE_RELEASE_DIRECTORY@/@CMAKE_CREATE_VERSION@-build/CMakeCache.txt fi +# Point build at pre-built documentation tarball, if any. +if [ ! -z "$CMAKE_DOC_TARBALL" ]; then + echo "CMAKE_DOC_TARBALL:FILEPATH=$CMAKE_DOC_TARBALL" >> @CMAKE_RELEASE_DIRECTORY@/@CMAKE_CREATE_VERSION@-build/CMakeCache.txt +fi + echo "Checkout the source for @CMAKE_CREATE_VERSION@" cd @CMAKE_RELEASE_DIRECTORY@ if [ ! -z "@GIT_COMMAND@" ]; then diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index aa9735e..c60788f 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -111,5 +111,8 @@ endif() if(SPHINX_HTML) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html - DESTINATION ${CMAKE_DOC_DIR}) + DESTINATION ${CMAKE_DOC_DIR} + PATTERN .buildinfo EXCLUDE + PATTERN objects.inv EXCLUDE + ) endif() |