diff options
83 files changed, 936 insertions, 349 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 119168d..433710b 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -266,38 +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 - (let ((buffer (generate-new-buffer bufname)) - (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 - (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) - ) - ) + (shell-command command buffer) + (save-selected-window + (select-window (display-buffer buffer 'not-this-window)) + (cmake-mode) + (toggle-read-only t)) ) ) @@ -309,30 +292,41 @@ 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) - (cmake-command-run "--help-command" (downcase (cmake-get-topic "command")))) + (cmake-command-run "--help-command" (downcase (cmake-get-command)) "*CMake Help*")) ;;;###autoload diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..2ebe9b6 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,29 @@ +Contributing to CMake +********************* + +Community +========= + +The preferred entry point for new contributors is the mailing list. +Please subscribe and post to the `CMake Developers List`_ to offer +contributions. Regular and productive contributors may be invited +to gain direct push access. + +.. _`CMake Developers List`: http://www.cmake.org/mailman/listinfo/cmake-developers + +Patches +======= + +Please base all new work on the ``master`` branch. Then use +``git format-patch`` to produce patches suitable to post to +the mailing list. + +License +======= + +We do not require any formal copyright assignment or contributor license +agreement. Any contributions intentionally sent upstream are presumed +to be offerred under terms of the OSI-approved BSD 3-clause License. +See `Copyright.txt`_ for details. + +.. _`Copyright.txt`: Copyright.txt diff --git a/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/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-variables.7.rst b/Help/manual/cmake-variables.7.rst index 832bd99..c4ae193 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -79,7 +79,17 @@ Variables that Provide Information /variable/PROJECT-NAME_BINARY_DIR /variable/PROJECT_NAME /variable/PROJECT-NAME_SOURCE_DIR + /variable/PROJECT-NAME_VERSION + /variable/PROJECT-NAME_VERSION_MAJOR + /variable/PROJECT-NAME_VERSION_MINOR + /variable/PROJECT-NAME_VERSION_PATCH + /variable/PROJECT-NAME_VERSION_TWEAK /variable/PROJECT_SOURCE_DIR + /variable/PROJECT_VERSION + /variable/PROJECT_VERSION_MAJOR + /variable/PROJECT_VERSION_MINOR + /variable/PROJECT_VERSION_PATCH + /variable/PROJECT_VERSION_TWEAK Variables that Change Behavior ============================== @@ -121,6 +131,7 @@ Variables that Change Behavior /variable/CMAKE_POLICY_DEFAULT_CMPNNNN /variable/CMAKE_PREFIX_PATH /variable/CMAKE_PROGRAM_PATH + /variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE /variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY /variable/CMAKE_STAGING_PREFIX /variable/CMAKE_SYSTEM_IGNORE_PATH diff --git a/Help/policy/CMP0048.rst b/Help/policy/CMP0048.rst new file mode 100644 index 0000000..ae51329 --- /dev/null +++ b/Help/policy/CMP0048.rst @@ -0,0 +1,22 @@ +CMP0048 +------- + +The :command:`project` command manages VERSION variables. + +CMake version 3.0.0 introduced the ``VERSION`` option of the :command:`project` +command to specify a project version as well as the name. In order to keep +:variable:`PROJECT_VERSION` and related variables consistent with variable +:variable:`PROJECT_NAME` it is necessary to set the VERSION variables +to the empty string when no ``VERSION`` is given to :command:`project`. +However, this can change behavior for existing projects that set VERSION +variables themselves since :command:`project` may now clear them. +This policy controls the behavior for compatibility with such projects. + +The OLD behavior for this policy is to leave VERSION variables untouched. +The NEW behavior for this policy is to set VERSION as documented by the +:command:`project` command. + +This policy was introduced in CMake version 3.0.0. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst new file mode 100644 index 0000000..ba9df5a --- /dev/null +++ b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst @@ -0,0 +1,6 @@ +CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE +------------------------------------ + +A CMake language file or module to be included by the :command:`project` +command. This is is intended for injecting custom code into project +builds without modifying their source. diff --git a/Help/variable/PROJECT-NAME_BINARY_DIR.rst b/Help/variable/PROJECT-NAME_BINARY_DIR.rst index a19940f..49bc558 100644 --- a/Help/variable/PROJECT-NAME_BINARY_DIR.rst +++ b/Help/variable/PROJECT-NAME_BINARY_DIR.rst @@ -3,6 +3,6 @@ Top level binary directory for the named project. -A variable is created with the name used in the PROJECT command, and -is the binary directory for the project. This can be useful when -SUBDIR is used to connect several projects. +A variable is created with the name used in the :command:`project` command, +and is the binary directory for the project. This can be useful when +:command:`add_subdirectory` is used to connect several projects. diff --git a/Help/variable/PROJECT-NAME_SOURCE_DIR.rst b/Help/variable/PROJECT-NAME_SOURCE_DIR.rst index f2f5caf..4df3e22 100644 --- a/Help/variable/PROJECT-NAME_SOURCE_DIR.rst +++ b/Help/variable/PROJECT-NAME_SOURCE_DIR.rst @@ -3,6 +3,6 @@ Top level source directory for the named project. -A variable is created with the name used in the PROJECT command, and -is the source directory for the project. This can be useful when -add_subdirectory is used to connect several projects. +A variable is created with the name used in the :command:`project` command, +and is the source directory for the project. This can be useful when +:command:`add_subdirectory` is used to connect several projects. diff --git a/Help/variable/PROJECT-NAME_VERSION.rst b/Help/variable/PROJECT-NAME_VERSION.rst new file mode 100644 index 0000000..0f6ed51 --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION.rst @@ -0,0 +1,11 @@ +<PROJECT-NAME>_VERSION +---------------------- + +Value given to the ``VERSION`` option of the most recent call to the +:command:`project` command with project name ``<PROJECT-NAME>``, if any. + +See also the component-wise version variables +:variable:`<PROJECT-NAME>_VERSION_MAJOR`, +:variable:`<PROJECT-NAME>_VERSION_MINOR`, +:variable:`<PROJECT-NAME>_VERSION_PATCH`, and +:variable:`<PROJECT-NAME>_VERSION_TWEAK`. diff --git a/Help/variable/PROJECT-NAME_VERSION_MAJOR.rst b/Help/variable/PROJECT-NAME_VERSION_MAJOR.rst new file mode 100644 index 0000000..9e2d755 --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_MAJOR.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_MAJOR +---------------------------- + +First version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT-NAME_VERSION_MINOR.rst b/Help/variable/PROJECT-NAME_VERSION_MINOR.rst new file mode 100644 index 0000000..fa2cdab --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_MINOR.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_MINOR +---------------------------- + +Second version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT-NAME_VERSION_PATCH.rst b/Help/variable/PROJECT-NAME_VERSION_PATCH.rst new file mode 100644 index 0000000..85b5e6b --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_PATCH.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_PATCH +---------------------------- + +Third version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT-NAME_VERSION_TWEAK.rst b/Help/variable/PROJECT-NAME_VERSION_TWEAK.rst new file mode 100644 index 0000000..65c4044 --- /dev/null +++ b/Help/variable/PROJECT-NAME_VERSION_TWEAK.rst @@ -0,0 +1,5 @@ +<PROJECT-NAME>_VERSION_TWEAK +---------------------------- + +Fourth version number component of the :variable:`<PROJECT-NAME>_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_BINARY_DIR.rst b/Help/variable/PROJECT_BINARY_DIR.rst index e506bdd..09e9ef2 100644 --- a/Help/variable/PROJECT_BINARY_DIR.rst +++ b/Help/variable/PROJECT_BINARY_DIR.rst @@ -3,4 +3,4 @@ PROJECT_BINARY_DIR Full path to build directory for project. -This is the binary directory of the most recent PROJECT command. +This is the binary directory of the most recent :command:`project` command. diff --git a/Help/variable/PROJECT_NAME.rst b/Help/variable/PROJECT_NAME.rst index 7559af6..61aa8bc 100644 --- a/Help/variable/PROJECT_NAME.rst +++ b/Help/variable/PROJECT_NAME.rst @@ -3,4 +3,4 @@ PROJECT_NAME Name of the project given to the project command. -This is the name given to the most recent PROJECT command. +This is the name given to the most recent :command:`project` command. diff --git a/Help/variable/PROJECT_SOURCE_DIR.rst b/Help/variable/PROJECT_SOURCE_DIR.rst index c9ba132..27f2838 100644 --- a/Help/variable/PROJECT_SOURCE_DIR.rst +++ b/Help/variable/PROJECT_SOURCE_DIR.rst @@ -3,4 +3,4 @@ PROJECT_SOURCE_DIR Top level source directory for the current project. -This is the source directory of the most recent PROJECT command. +This is the source directory of the most recent :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION.rst b/Help/variable/PROJECT_VERSION.rst new file mode 100644 index 0000000..234558d --- /dev/null +++ b/Help/variable/PROJECT_VERSION.rst @@ -0,0 +1,11 @@ +PROJECT_VERSION +--------------- + +Value given to the ``VERSION`` option of the most recent call to the +:command:`project` command, if any. + +See also the component-wise version variables +:variable:`PROJECT_VERSION_MAJOR`, +:variable:`PROJECT_VERSION_MINOR`, +:variable:`PROJECT_VERSION_PATCH`, and +:variable:`PROJECT_VERSION_TWEAK`. diff --git a/Help/variable/PROJECT_VERSION_MAJOR.rst b/Help/variable/PROJECT_VERSION_MAJOR.rst new file mode 100644 index 0000000..4b6072c --- /dev/null +++ b/Help/variable/PROJECT_VERSION_MAJOR.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_MAJOR +--------------------- + +First version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION_MINOR.rst b/Help/variable/PROJECT_VERSION_MINOR.rst new file mode 100644 index 0000000..5f31220 --- /dev/null +++ b/Help/variable/PROJECT_VERSION_MINOR.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_MINOR +--------------------- + +Second version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION_PATCH.rst b/Help/variable/PROJECT_VERSION_PATCH.rst new file mode 100644 index 0000000..ac72ec0 --- /dev/null +++ b/Help/variable/PROJECT_VERSION_PATCH.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_PATCH +--------------------- + +Third version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Help/variable/PROJECT_VERSION_TWEAK.rst b/Help/variable/PROJECT_VERSION_TWEAK.rst new file mode 100644 index 0000000..d7f96d6 --- /dev/null +++ b/Help/variable/PROJECT_VERSION_TWEAK.rst @@ -0,0 +1,5 @@ +PROJECT_VERSION_TWEAK +--------------------- + +Fourth version number component of the :variable:`PROJECT_VERSION` +variable as set by the :command:`project` command. diff --git a/Modules/CMakeFindJavaCommon.cmake b/Modules/CMakeFindJavaCommon.cmake new file mode 100644 index 0000000..fcf0389 --- /dev/null +++ b/Modules/CMakeFindJavaCommon.cmake @@ -0,0 +1,41 @@ + +#============================================================================= +# Copyright 2013-2014 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Do not include this module directly from code outside CMake! +set(_JAVA_HOME "") +if(JAVA_HOME AND IS_DIRECTORY "${JAVA_HOME}") + set(_JAVA_HOME "${JAVA_HOME}") + set(_JAVA_HOME_EXPLICIT 1) +else() + set(_ENV_JAVA_HOME "") + if(DEFINED ENV{JAVA_HOME}) + file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _ENV_JAVA_HOME) + endif() + if(_ENV_JAVA_HOME AND IS_DIRECTORY "${_ENV_JAVA_HOME}") + set(_JAVA_HOME "${_ENV_JAVA_HOME}") + set(_JAVA_HOME_EXPLICIT 1) + else() + set(_CMD_JAVA_HOME "") + if(APPLE AND EXISTS /usr/libexec/java_home) + execute_process(COMMAND /usr/libexec/java_home + OUTPUT_VARIABLE _CMD_JAVA_HOME OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}") + set(_JAVA_HOME "${_CMD_JAVA_HOME}") + set(_JAVA_HOME_EXPLICIT 0) + endif() + unset(_CMD_JAVA_HOME) + endif() + unset(_ENV_JAVA_HOME) +endif() diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index f388fe0..473bbe5 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -99,7 +99,7 @@ # # :: # -# WRITE_BASIC_PACKAGE_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion|ExactVersion) ) +# WRITE_BASIC_PACKAGE_VERSION_FILE( filename [VERSION major.minor.patch] COMPATIBILITY (AnyNewerVersion|SameMajorVersion|ExactVersion) ) # # # @@ -112,6 +112,9 @@ # filename is the output filename, it should be in the build tree. # major.minor.patch is the version number of the project to be installed # +# If no ``VERSION`` is given, the :variable:`PROJECT_VERSION` variable +# is used. If this hasn't been set, it errors out. +# # The COMPATIBILITY mode AnyNewerVersion means that the installed # package version will be considered compatible if it is newer or # exactly the same as the requested version. This mode should be used diff --git a/Modules/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/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index 95187b4..7d28e95 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -6,7 +6,7 @@ # # :: # -# WRITE_BASIC_CONFIG_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion) ) +# WRITE_BASIC_CONFIG_VERSION_FILE( filename [VERSION major.minor.patch] COMPATIBILITY (AnyNewerVersion|SameMajorVersion) ) # # # @@ -46,7 +46,11 @@ function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) endif() if("${CVF_VERSION}" STREQUAL "") - message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()") + if ("${PROJECT_VERSION}" STREQUAL "") + message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()") + else() + set(CVF_VERSION "${PROJECT_VERSION}") + endif() endif() configure_file("${versionTemplateFile}" "${_filename}" @ONLY) diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..6be9aa8 --- /dev/null +++ b/README.rst @@ -0,0 +1,78 @@ +CMake +***** + +Introduction +============ + +CMake is a cross-platform, open-source build system generator. +For full documentation visit the `CMake Home Page`_ and the +`CMake Documentation Page`_. + +.. _`CMake Home Page`: http://www.cmake.org +.. _`CMake Documentation Page`: http://www.cmake.org/cmake/help/documentation.html + +License +======= + +CMake is distributed under the OSI-approved BSD 3-clause License. +See `Copyright.txt`_ for details. + +.. _`Copyright.txt`: Copyright.txt + +Building CMake +============== + +Supported Platforms +------------------- + +MS Windows, Mac OS X, Linux, FreeBSD, Solaris, HP-UX, IRIX, BeOS, QNX + +Other UNIX-like operating systems may work too out of the box, if not +it should not be a major problem to port CMake to this platform. +Subscribe and post to the `CMake Users List`_ to ask if others have +had experience with the platform. + +.. _`CMake Users List`: http://www.cmake.org/mailman/listinfo/cmake + +Building CMake from Scratch +--------------------------- + +UNIX/Mac OSX/MinGW/MSYS/Cygwin +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You need to have a compiler and a make installed. +Run the ``bootstrap`` script you find the in the source directory of CMake. +You can use the ``--help`` option to see the supported options. +You may use the ``--prefix=<install_prefix>`` option to specify a custom +installation directory for CMake. You can run the ``bootstrap`` script from +within the CMake source directory or any other build directory of your +choice. Once this has finished successfully, run ``make`` and +``make install``. In summary:: + + $ ./bootstrap && make && make install + +Windows +^^^^^^^ + +You need to download and install a binary release of CMake in order to build +CMake. You can get these releases from the `CMake Download Page`_ . Then +proceed with the instructions below. + +.. _`CMake Download Page`: http://www.cmake.org/cmake/resources/software.html + +Building CMake with CMake +------------------------- + +You can build CMake as any other project with a CMake-based build system: +run the installed CMake on the sources of this CMake with your preferred +options and generators. Then build it and install it. +For instructions how to do this, see documentation on `Running CMake`_. + +.. _`Running CMake`: http://www.cmake.org/cmake/help/runningcmake.html + +Contributing +============ + +See `CONTRIBUTING.rst`_ for instructions to contribute. + +.. _`CONTRIBUTING.rst`: CONTRIBUTING.rst diff --git a/Readme.txt b/Readme.txt deleted file mode 100644 index 11926bc..0000000 --- a/Readme.txt +++ /dev/null @@ -1,53 +0,0 @@ -This is CMake, the cross-platform, open-source make system. -CMake is distributed under the BSD License, see Copyright.txt. -For documentation see the Docs/ directory once you have built CMake -or visit http://www.cmake.org. - - -Building CMake -============== - - -Supported Platforms -------------------- - -MS Windows, Mac OS X, Linux, FreeBSD, Solaris, HP-UX, IRIX, BeOS, QNX - -Other UNIX-like operating systems may work too out of the box, if not -it shouldn't be a major problem to port CMake to this platform. Contact the -CMake mailing list in this case: http://www.cmake.org/mailman/listinfo/cmake - - -If you don't have any previous version of CMake already installed --------------------------------------------------------------- - -* UNIX/Mac OSX/MinGW/MSYS/Cygwin: - -You need to have a compiler and a make installed. -Run the bootstrap script you find the in the source directory of CMake. -You can use the --help option to see the supported options. -You may want to use the --prefix=<install_prefix> option to specify a custom -installation directory for CMake. You can run the bootstrap script from -within the CMake source directory or any other build directory of your -choice. Once this has finished successfully, run make and make install. -So basically it's the same as you may be used to from autotools-based -projects: - -$ ./bootstrap; make; make install - - -* Other Windows: - -You need to download and install a binary release of CMake in order to build -CMake. You can get these releases from -http://www.cmake.org/HTML/Download.html . Then proceed with the instructions -below. - - -You already have a version of CMake installed ---------------------------------------------- - -You can build CMake as any other project with a CMake-based build system: -run the installed CMake on the sources of this CMake with your preferred -options and generators. Then build it and install it. -For instructions how to do this, see http://www.cmake.org/HTML/RunningCMake.html diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 35ef398..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 20140201) +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/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/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/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 |