diff options
106 files changed, 1335 insertions, 649 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/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-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/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in index 7554213..b6f9791 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -1,4 +1,4 @@ -set(AM_SOURCES @_moc_files@ ) +set(AM_SOURCES @_cpp_files@ ) set(AM_RCC_SOURCES @_rcc_files@ ) set(AM_SKIP_MOC @_skip_moc@ ) set(AM_SKIP_UIC @_skip_uic@ ) 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 1c1bd2f..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 ) @@ -1323,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 @@ -1347,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}'") @@ -1541,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 0bf2b99..21a853d 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 # ========= @@ -1185,71 +1114,29 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) set(QT_LINGUIST_EXECUTABLE NOTFOUND) endif() - find_program(QT_MOC_EXECUTABLE - NAMES moc-qt4 moc moc4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_UIC_EXECUTABLE - NAMES uic-qt4 uic uic4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_UIC3_EXECUTABLE - NAMES uic3 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_RCC_EXECUTABLE - NAMES rcc - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_DBUSCPP2XML_EXECUTABLE - NAMES qdbuscpp2xml - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_DBUSXML2CPP_EXECUTABLE - NAMES qdbusxml2cpp - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_LUPDATE_EXECUTABLE - NAMES lupdate-qt4 lupdate lupdate4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_LRELEASE_EXECUTABLE - NAMES lrelease-qt4 lrelease lrelease4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE - NAMES qcollectiongenerator-qt4 qcollectiongenerator - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - - find_program(QT_DESIGNER_EXECUTABLE - NAMES designer-qt4 designer designer4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) + macro(_find_qt4_program VAR NAME) + find_program(${VAR} + NAMES ${ARGN} + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH + ) + if (${VAR} AND NOT TARGET ${NAME}) + add_executable(${NAME} IMPORTED) + set_property(TARGET ${NAME} PROPERTY IMPORTED_LOCATION ${${VAR}}) + endif() + endmacro() - find_program(QT_LINGUIST_EXECUTABLE - NAMES linguist-qt4 linguist linguist4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) + _find_qt4_program(QT_MOC_EXECUTABLE Qt4::moc moc-qt4 moc moc4) + _find_qt4_program(QT_UIC_EXECUTABLE Qt4::uic uic-qt4 uic uic4) + _find_qt4_program(QT_UIC3_EXECUTABLE Qt4::uic3 uic3) + _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc) + _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml) + _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp) + _find_qt4_program(QT_LUPDATE_EXECUTABLE Qt4::lupdate lupdate-qt4 lupdate lupdate4) + _find_qt4_program(QT_LRELEASE_EXECUTABLE Qt4::lrelease lrelease-qt4 lrelease lrelease4) + _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator) + _find_qt4_program(QT_DESIGNER_EXECUTABLE Qt4::designer designer-qt4 designer designer4) + _find_qt4_program(QT_LINGUIST_EXECUTABLE Qt4::linguist linguist-qt4 linguist linguist4) if (QT_MOC_EXECUTABLE) set(QT_WRAP_CPP "YES") diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index fd9819f..df2318b 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -140,7 +140,7 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target) set(_moc_extra_parameters_file @${_moc_parameters_file}) add_custom_command(OUTPUT ${outfile} - COMMAND ${QT_MOC_EXECUTABLE} ${_moc_extra_parameters_file} + COMMAND Qt4::moc ${_moc_extra_parameters_file} DEPENDS ${infile} ${_moc_working_dir} VERBATIM) @@ -191,7 +191,7 @@ macro (QT4_WRAP_UI outfiles ) get_filename_component(infile ${it} ABSOLUTE) set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) add_custom_command(OUTPUT ${outfile} - COMMAND ${QT_UIC_EXECUTABLE} + COMMAND Qt4::uic ARGS ${ui_options} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} VERBATIM) set(${outfiles} ${${outfiles}} ${outfile}) @@ -238,7 +238,7 @@ macro (QT4_ADD_RESOURCES outfiles ) endif() add_custom_command(OUTPUT ${outfile} - COMMAND ${QT_RCC_EXECUTABLE} + COMMAND Qt4::rcc ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM) @@ -272,7 +272,7 @@ macro(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) endif() add_custom_command(OUTPUT "${_impl}" "${_header}" - COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile} + COMMAND Qt4::qdbusxml2cpp ${_params} -p ${_basename} ${_infile} DEPENDS ${_infile} VERBATIM) set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE) @@ -318,7 +318,7 @@ macro(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options endif () add_custom_command(OUTPUT ${_target} - COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target} + COMMAND Qt4::qdbuscpp2xml ${_qt4_dbus_options} ${_in_file} -o ${_target} DEPENDS ${_in_file} VERBATIM ) endmacro() @@ -342,12 +342,12 @@ macro(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional if(_optionalClassName) add_custom_command(OUTPUT "${_impl}" "${_header}" - COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} + COMMAND Qt4::qdbuscpp2xml -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} DEPENDS ${_infile} VERBATIM ) else() add_custom_command(OUTPUT "${_impl}" "${_header}" - COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} + COMMAND Qt4::qdbusxml2cpp -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} DEPENDS ${_infile} VERBATIM ) endif() @@ -445,7 +445,7 @@ macro(QT4_CREATE_TRANSLATION _qm_files) file(WRITE ${_ts_pro} "SOURCES =${_pro_srcs}\nINCLUDEPATH =${_pro_includes}\n") endif() add_custom_command(OUTPUT ${_ts_file} - COMMAND ${QT_LUPDATE_EXECUTABLE} + COMMAND Qt4::lupdate ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file} DEPENDS ${_my_sources} ${_ts_pro} VERBATIM) endforeach() @@ -466,7 +466,7 @@ macro(QT4_ADD_TRANSLATION _qm_files) endif() add_custom_command(OUTPUT ${qm} - COMMAND ${QT_LRELEASE_EXECUTABLE} + COMMAND Qt4::lrelease ARGS ${_abs_FILE} -qm ${qm} DEPENDS ${_abs_FILE} VERBATIM ) 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/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4bbc4e7..8a676dd 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 20140129) +set(CMake_VERSION_TWEAK 20140203) #set(CMake_VERSION_RC 1) 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/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/cmMakefile.cxx b/Source/cmMakefile.cxx index 55a9d5c..f248c57 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 66a33bb..45f3b9f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -853,15 +853,15 @@ 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; } 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/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index da22ab5..cab59fe 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -115,6 +115,15 @@ static void copyTargetProperty(cmTarget* destinationTarget, } +static std::string ReadAll(const std::string& filename) +{ + cmsys::ifstream file(filename.c_str()); + cmsys_ios::stringstream stream; + stream << file.rdbuf(); + file.close(); + return stream.str(); +} + cmQtAutoGenerators::cmQtAutoGenerators() :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) ,ColorOutput(true) @@ -222,7 +231,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) if (target->GetPropertyAsBool("AUTORCC")) { toolNames.push_back("rcc"); - this->InitializeAutoRccTarget(target); } std::string tools = toolNames[0]; @@ -371,6 +379,13 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) std::map<std::string, std::string> configDefines; std::map<std::string, std::string> configUicOptions; + if (target->GetPropertyAsBool("AUTOMOC") + || target->GetPropertyAsBool("AUTOUIC")) + { + this->SetupSourceFiles(target); + } + makefile->AddDefinition("_cpp_files", + cmLocalGenerator::EscapeForCMake(this->Sources.c_str()).c_str()); if (target->GetPropertyAsBool("AUTOMOC")) { this->SetupAutoMocTarget(target, autogenTargetName, @@ -439,23 +454,20 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) } } -void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, - const std::string &autogenTargetName, - std::map<std::string, std::string> &configIncludes, - std::map<std::string, std::string> &configDefines) +void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); - std::string _moc_files; - std::string _moc_headers; const char* sepFiles = ""; const char* sepHeaders = ""; std::vector<cmSourceFile*> srcFiles; target->GetSourceFiles(srcFiles); - std::string skip_moc; - const char *sep = ""; + const char *skipMocSep = ""; + const char *skipUicSep = ""; + + std::vector<cmSourceFile*> newRccFiles; for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); @@ -464,48 +476,83 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, cmSourceFile* sf = *fileIt; std::string absFile = cmsys::SystemTools::GetRealPath( sf->GetFullPath().c_str()); - bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + bool skipMoc = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); + if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) + { + this->SkipUic += skipUicSep; + this->SkipUic += absFile; + skipUicSep = ";"; + } + + std::string ext = sf->GetExtension(); + if (ext == "qrc" + && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + newRccFiles.push_back(rccCppSource); + } + if (!generated) { - if (skip) + if (skipMoc) { - skip_moc += sep; - skip_moc += absFile; - sep = ";"; + this->SkipMoc += skipMocSep; + this->SkipMoc += absFile; + skipMocSep = ";"; } else { - std::string ext = sf->GetExtension(); cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( ext.c_str()); if (fileType == cmSystemTools::CXX_FILE_FORMAT) { - _moc_files += sepFiles; - _moc_files += absFile; + this->Sources += sepFiles; + this->Sources += absFile; sepFiles = ";"; } else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) { - _moc_headers += sepHeaders; - _moc_headers += absFile; + this->Headers += sepHeaders; + this->Headers += absFile; sepHeaders = ";"; } } } } + for(std::vector<cmSourceFile*>::const_iterator fileIt = newRccFiles.begin(); + fileIt != newRccFiles.end(); + ++fileIt) + { + const_cast<cmTarget*>(target)->AddSourceFile(*fileIt); + } +} + +void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, + const std::string &autogenTargetName, + std::map<std::string, std::string> &configIncludes, + std::map<std::string, std::string> &configDefines) +{ + cmMakefile* makefile = target->GetMakefile(); + const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); std::string _moc_options = (tmp!=0 ? tmp : ""); makefile->AddDefinition("_moc_options", cmLocalGenerator::EscapeForCMake(_moc_options.c_str()).c_str()); - makefile->AddDefinition("_moc_files", - cmLocalGenerator::EscapeForCMake(_moc_files.c_str()).c_str()); makefile->AddDefinition("_skip_moc", - cmLocalGenerator::EscapeForCMake(skip_moc.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->SkipMoc.c_str()).c_str()); makefile->AddDefinition("_moc_headers", - cmLocalGenerator::EscapeForCMake(_moc_headers.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->Headers.c_str()).c_str()); bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); @@ -549,9 +596,6 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, } } - const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE"); - makefile->AddDefinition("_qt_moc_executable", qtMoc); - const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (strcmp(qtVersion, "5") == 0) { @@ -564,13 +608,21 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, } makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0)); } - else + else if (strcmp(qtVersion, "4") == 0) { - if (strcmp(qtVersion, "4") != 0) + cmTarget *qt4Moc = makefile->FindTargetToUse("Qt4::moc"); + if (!qt4Moc) { - cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and " - "Qt 5 ", autogenTargetName.c_str()); + cmSystemTools::Error("Qt4::moc target not found ", + autogenTargetName.c_str()); + return; } + makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(0)); + } + else + { + cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and " + "Qt 5 ", autogenTargetName.c_str()); } } @@ -641,50 +693,22 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, { cmMakefile *makefile = target->GetMakefile(); - const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE"); - makefile->AddDefinition("_qt_uic_executable", qtUic); - - std::vector<cmSourceFile*> srcFiles; - target->GetSourceFiles(srcFiles); - - std::string skip_uic; - const char *sep = ""; - - bool skip = target->GetPropertyAsBool("SKIP_AUTOUIC"); - std::set<cmStdString> skipped; + std::vector<std::string> skipVec; + cmSystemTools::ExpandListArgument(this->SkipUic.c_str(), skipVec); - for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); - fileIt != srcFiles.end(); - ++fileIt) + for (std::vector<std::string>::const_iterator li = skipVec.begin(); + li != skipVec.end(); ++li) { - cmSourceFile* sf = *fileIt; - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath().c_str()); - if (!skip) - { - skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")); - } - - if (skip) - { - skip_uic += sep; - skip_uic += absFile; - sep = ";"; - skipped.insert(absFile); - } + skipped.insert(*li); } makefile->AddDefinition("_skip_uic", - cmLocalGenerator::EscapeForCMake(skip_uic.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->SkipUic.c_str()).c_str()); std::vector<cmSourceFile*> uiFilesWithOptions = makefile->GetQtUiFilesWithOptions(); - std::string uiFileFiles; - std::string uiFileOptions; - sep = ""; - const char *qtVersion = makefile->GetDefinition("_target_qt_version"); std::string _uic_opts; @@ -713,6 +737,10 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } } + std::string uiFileFiles; + std::string uiFileOptions; + const char* sep = ""; + for(std::vector<cmSourceFile*>::const_iterator fileIt = uiFilesWithOptions.begin(); fileIt != uiFilesWithOptions.end(); @@ -747,20 +775,27 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, if (!qt5Uic) { // Project does not use Qt5Widgets, but has AUTOUIC ON anyway - makefile->RemoveDefinition("_qt_uic_executable"); } else { makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0)); } } - else + else if (strcmp(qtVersion, "4") == 0) { - if (strcmp(qtVersion, "4") != 0) + cmTarget *qt4Uic = makefile->FindTargetToUse("Qt4::uic"); + if (!qt4Uic) { - cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " - "Qt 5 ", targetName); + cmSystemTools::Error("Qt4::uic target not found ", + targetName); + return; } + makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0)); + } + else + { + cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " + "Qt 5 ", targetName); } } @@ -807,51 +842,6 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) -{ - cmMakefile *makefile = target->GetMakefile(); - - std::vector<cmSourceFile*> srcFiles; - target->GetSourceFiles(srcFiles); - - std::vector<cmSourceFile*> newFiles; - - for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); - fileIt != srcFiles.end(); - ++fileIt) - { - cmSourceFile* sf = *fileIt; - std::string ext = sf->GetExtension(); - if (ext == "qrc") - { - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath().c_str()); - bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); - - if (!skip) - { - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); - newFiles.push_back(rccCppSource); - } - } - } - - for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); - fileIt != newFiles.end(); - ++fileIt) - { - target->AddSourceFile(*fileIt); - } -} - void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) { std::string _rcc_files; @@ -927,9 +917,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) makefile->AddDefinition("_qt_rcc_options_options", cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str()); - const char *qtRcc = makefile->GetSafeDefinition("QT_RCC_EXECUTABLE"); - makefile->AddDefinition("_qt_rcc_executable", qtRcc); - const char* targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { @@ -942,21 +929,45 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) } makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0)); } - else + else if (strcmp(qtVersion, "4") == 0) { - if (strcmp(qtVersion, "4") != 0) + cmTarget *qt4Rcc = makefile->FindTargetToUse("Qt4::rcc"); + if (!qt4Rcc) { - cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " - "Qt 5 ", targetName); + cmSystemTools::Error("Qt4::rcc target not found ", + targetName); + return; } + makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0)); + } + else + { + cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " + "Qt 5 ", targetName); } } +static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, + const char* targetDirectory) +{ + cmGlobalGenerator* gg = new cmGlobalGenerator(); + gg->SetCMakeInstance(cm); + + cmLocalGenerator* lg = gg->CreateLocalGenerator(); + lg->GetMakefile()->SetHomeOutputDirectory(targetDirectory); + lg->GetMakefile()->SetStartOutputDirectory(targetDirectory); + lg->GetMakefile()->SetHomeDirectory(targetDirectory); + lg->GetMakefile()->SetStartDirectory(targetDirectory); + gg->SetCurrentLocalGenerator(lg); + + return gg; +} + bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) { bool success = true; cmake cm; - cmGlobalGenerator* gg = this->CreateGlobalGenerator(&cm, targetDirectory); + cmGlobalGenerator* gg = CreateGlobalGenerator(&cm, targetDirectory); cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); this->ReadAutogenInfoFile(makefile, targetDirectory, config); @@ -977,24 +988,6 @@ bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) return success; } - -cmGlobalGenerator* cmQtAutoGenerators::CreateGlobalGenerator(cmake* cm, - const char* targetDirectory) -{ - cmGlobalGenerator* gg = new cmGlobalGenerator(); - gg->SetCMakeInstance(cm); - - cmLocalGenerator* lg = gg->CreateLocalGenerator(); - lg->GetMakefile()->SetHomeOutputDirectory(targetDirectory); - lg->GetMakefile()->SetStartOutputDirectory(targetDirectory); - lg->GetMakefile()->SetHomeDirectory(targetDirectory); - lg->GetMakefile()->SetStartDirectory(targetDirectory); - gg->SetCurrentLocalGenerator(lg); - - return gg; -} - - bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config) @@ -1027,6 +1020,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); this->UicExecutable = makefile->GetSafeDefinition("AM_QT_UIC_EXECUTABLE"); this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE"); + { std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS"; std::string compileDefsProp = compileDefsPropOrig; if(config) @@ -1037,6 +1031,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const char *compileDefs = makefile->GetDefinition(compileDefsProp.c_str()); this->MocCompileDefinitionsStr = compileDefs ? compileDefs : makefile->GetSafeDefinition(compileDefsPropOrig.c_str()); + } + { std::string includesPropOrig = "AM_MOC_INCLUDES"; std::string includesProp = includesPropOrig; if(config) @@ -1047,6 +1043,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const char *includes = makefile->GetDefinition(includesProp.c_str()); this->MocIncludesStr = includes ? includes : makefile->GetSafeDefinition(includesPropOrig.c_str()); + } this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); @@ -1066,7 +1063,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, = makefile->GetSafeDefinition(uicOptionsProp.c_str()); cmSystemTools::ExpandListArgument( uicTargetOptions ? uicTargetOptions - : makefile->GetSafeDefinition(includesPropOrig.c_str()), + : makefile->GetSafeDefinition(uicOptionsPropOrig.c_str()), this->UicTargetOptions); const char *uicOptionsOptions = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"); @@ -1412,7 +1409,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) if (!automocCppChanged) { // compare contents of the _automoc.cpp file - const std::string oldContents = this->ReadAll(this->OutMocCppFilename); + const std::string oldContents = ReadAll(this->OutMocCppFilename); if (oldContents == automocSource) { // nothing changed: don't touch the _automoc.cpp file @@ -1440,13 +1437,19 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - const std::string contentsString = this->ReadAll(absFilename); + const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; return; } + this->ParseForUic(absFilename, contentsString, includedUis); + if (this->MocExecutable.empty()) + { + return; + } + const std::string absPath = cmsys::SystemTools::GetFilenamePath( cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; const std::string scannedFileBasename = cmsys::SystemTools:: @@ -1575,7 +1578,6 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } - this->ParseForUic(absFilename, contentsString, includedUis); // In this case, check whether the scanned file itself contains a Q_OBJECT. // If this is the case, the moc_foo.cpp should probably be generated from @@ -1623,13 +1625,19 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - const std::string contentsString = this->ReadAll(absFilename); + const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; return; } + this->ParseForUic(absFilename, contentsString, includedUis); + if (this->MocExecutable.empty()) + { + return; + } + const std::string absPath = cmsys::SystemTools::GetFilenamePath( cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; const std::string scannedFileBasename = cmsys::SystemTools:: @@ -1708,7 +1716,6 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } - this->ParseForUic(absFilename, contentsString, includedUis); // In this case, check whether the scanned file itself contains a Q_OBJECT. // If this is the case, the moc_foo.cpp should probably be generated from @@ -1736,7 +1743,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, { return; } - const std::string contentsString = this->ReadAll(absFilename); + const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" @@ -1831,9 +1838,10 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders, ++hIt) { const std::string& headerName = *hIt; - const std::string contents = this->ReadAll(headerName); + const std::string contents = ReadAll(headerName); - if (includedMocs.find(headerName) == includedMocs.end()) + if (!this->MocExecutable.empty() + && includedMocs.find(headerName) == includedMocs.end()) { if (this->Verbose) { @@ -1956,7 +1964,6 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& uiFileName) std::vector<cmStdString> command; command.push_back(this->UicExecutable); - std::string options; std::vector<std::string> opts = this->UicTargetOptions; std::map<std::string, std::string>::const_iterator optionIt = this->UicOptions.find(ui_input_file); @@ -2031,7 +2038,6 @@ bool cmQtAutoGenerators::GenerateQrc() &sourceNewerThanQrc); if (this->GenerateAll || !success || sourceNewerThanQrc >= 0) { - std::string options; std::map<std::string, std::string>::const_iterator optionIt = this->RccOptions.find(*si); if (optionIt != this->RccOptions.end()) @@ -2112,13 +2118,3 @@ bool cmQtAutoGenerators::EndsWith(const std::string& str, } return (str.substr(str.length() - with.length(), with.length()) == with); } - - -std::string cmQtAutoGenerators::ReadAll(const std::string& filename) -{ - cmsys::ifstream file(filename.c_str()); - cmsys_ios::stringstream stream; - stream << file.rdbuf(); - file.close(); - return stream.str(); -} diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 80123d8..f66d02b 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -25,6 +25,7 @@ public: bool InitializeAutogenTarget(cmTarget* target); void SetupAutoGenerateTarget(cmTarget const* target); + void SetupSourceFiles(cmTarget const* target); private: void SetupAutoMocTarget(cmTarget const* target, @@ -33,12 +34,8 @@ private: std::map<std::string, std::string> &configDefines); void SetupAutoUicTarget(cmTarget const* target, std::map<std::string, std::string> &configUicOptions); - void InitializeAutoRccTarget(cmTarget* target); void SetupAutoRccTarget(cmTarget const* target); - cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, - const char* targetDirectory); - bool ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config); @@ -82,7 +79,6 @@ private: std::string Join(const std::vector<std::string>& lst, char separator); bool EndsWith(const std::string& str, const std::string& with); bool StartsWith(const std::string& str, const std::string& with); - std::string ReadAll(const std::string& filename); void MergeUicOptions(std::vector<std::string> &opts, const std::vector<std::string> &fileOpts, bool isQt5); 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/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index a79111a..2807f97 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/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/Qt4And5Automoc/CMakeLists.txt b/Tests/Qt4And5Automoc/CMakeLists.txt index 0cc80fe..61d5743 100644 --- a/Tests/Qt4And5Automoc/CMakeLists.txt +++ b/Tests/Qt4And5Automoc/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 2.8.12) project(Qt4And5Automoc) @@ -7,7 +8,17 @@ find_package(Qt5Core REQUIRED) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) -add_executable(qt4_exe main_qt4.cpp) +macro(generate_main_file VERSION) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/main_qt${VERSION}.cpp" COPYONLY) + file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/main_qt${VERSION}.cpp" + "#include \"main_qt${VERSION}.moc\"\n" + ) +endmacro() + +generate_main_file(4) +generate_main_file(5) + +add_executable(qt4_exe "${CMAKE_CURRENT_BINARY_DIR}/main_qt4.cpp") target_link_libraries(qt4_exe Qt4::QtCore) -add_executable(qt5_exe main_qt5.cpp) +add_executable(qt5_exe "${CMAKE_CURRENT_BINARY_DIR}/main_qt5.cpp") target_link_libraries(qt5_exe Qt5::Core) diff --git a/Tests/Qt4And5Automoc/main.cpp b/Tests/Qt4And5Automoc/main.cpp.in index 00fd641..00fd641 100644 --- a/Tests/Qt4And5Automoc/main.cpp +++ b/Tests/Qt4And5Automoc/main.cpp.in diff --git a/Tests/Qt4And5Automoc/main_qt4.cpp b/Tests/Qt4And5Automoc/main_qt4.cpp deleted file mode 100644 index a84ce89..0000000 --- a/Tests/Qt4And5Automoc/main_qt4.cpp +++ /dev/null @@ -1,4 +0,0 @@ - -#include "main.cpp" - -#include "main_qt4.moc" diff --git a/Tests/Qt4And5Automoc/main_qt5.cpp b/Tests/Qt4And5Automoc/main_qt5.cpp deleted file mode 100644 index 287b261..0000000 --- a/Tests/Qt4And5Automoc/main_qt5.cpp +++ /dev/null @@ -1,4 +0,0 @@ - -#include "main.cpp" - -#include "main_qt5.moc" diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 7b99395..515bf5b 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -11,6 +11,11 @@ if (QT_TEST_VERSION STREQUAL 4) include(UseQt4) set(QT_QTCORE_TARGET Qt4::QtCore) + + macro(qtx_wrap_cpp) + qt4_wrap_cpp(${ARGN}) + endmacro() + else() if (NOT QT_TEST_VERSION STREQUAL 5) message(SEND_ERROR "Invalid Qt version specified.") @@ -25,6 +30,11 @@ else() if(Qt5_POSITION_INDEPENDENT_CODE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() + + macro(qtx_wrap_cpp) + qt5_wrap_cpp(${ARGN}) + endmacro() + endif() @@ -77,3 +87,7 @@ set_target_properties(empty PROPERTIES AUTOMOC TRUE) target_link_libraries(empty no_link_language) add_library(no_link_language STATIC empty.h) set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE) + +qtx_wrap_cpp(uicOnlyMoc uiconly.h) +add_executable(uiconly uiconly.cpp ${uicOnlyMoc}) +target_link_libraries(uiconly ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/uiconly.cpp b/Tests/QtAutogen/uiconly.cpp new file mode 100644 index 0000000..cdb3318 --- /dev/null +++ b/Tests/QtAutogen/uiconly.cpp @@ -0,0 +1,13 @@ + +#include "uiconly.h" + +UicOnly::UicOnly(QWidget *parent) + : QWidget(parent), ui(new Ui::UicOnly) +{ + +} + +int main() +{ + return 0; +} diff --git a/Tests/QtAutogen/uiconly.h b/Tests/QtAutogen/uiconly.h new file mode 100644 index 0000000..9e21f82 --- /dev/null +++ b/Tests/QtAutogen/uiconly.h @@ -0,0 +1,20 @@ + +#ifndef UIC_ONLY_H +#define UIC_ONLY_H + +#include <QWidget> +#include <memory> + +#include "ui_uiconly.h" + +class UicOnly : public QWidget +{ + Q_OBJECT +public: + explicit UicOnly(QWidget *parent = 0); + +private: + const std::auto_ptr<Ui::UicOnly> ui; +}; + +#endif diff --git a/Tests/QtAutogen/uiconly.ui b/Tests/QtAutogen/uiconly.ui new file mode 100644 index 0000000..13fb832 --- /dev/null +++ b/Tests/QtAutogen/uiconly.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UicOnly</class> + <widget class="QWidget" name="UicOnly"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> 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() |