diff options
90 files changed, 1218 insertions, 393 deletions
diff --git a/Help/command/execute_process.rst b/Help/command/execute_process.rst index 3f0ccc2..478b30e 100644 --- a/Help/command/execute_process.rst +++ b/Help/command/execute_process.rst @@ -3,7 +3,7 @@ execute_process Execute one or more child processes. -:: +.. code-block:: cmake execute_process(COMMAND <cmd1> [args1...]] [COMMAND <cmd2> [args2...] [...]] @@ -21,28 +21,55 @@ Execute one or more child processes. [ERROR_STRIP_TRAILING_WHITESPACE]) Runs the given sequence of one or more commands with the standard -output of each process piped to the standard input of the next. A -single standard error pipe is used for all processes. If -WORKING_DIRECTORY is given the named directory will be set as the -current working directory of the child processes. If TIMEOUT is given -the child processes will be terminated if they do not finish in the -specified number of seconds (fractions are allowed). If -RESULT_VARIABLE is given the variable will be set to contain the -result of running the processes. This will be an integer return code -from the last child or a string describing an error condition. If -OUTPUT_VARIABLE or ERROR_VARIABLE are given the variable named will be -set with the contents of the standard output and standard error pipes -respectively. If the same variable is named for both pipes their -output will be merged in the order produced. If INPUT_FILE, -OUTPUT_FILE, or ERROR_FILE is given the file named will be attached to -the standard input of the first process, standard output of the last -process, or standard error of all processes respectively. If -OUTPUT_QUIET or ERROR_QUIET is given then the standard output or -standard error results will be quietly ignored. If more than one -OUTPUT_* or ERROR_* option is given for the same pipe the precedence -is not specified. If no OUTPUT_* or ERROR_* options are given the -output will be shared with the corresponding pipes of the CMake -process itself. - -The execute_process command is a newer more powerful version of -exec_program, but the old command has been kept for compatibility. +output of each process piped to the standard input of the next. +A single standard error pipe is used for all processes. + +Options: + +COMMAND + A child process command line. + + CMake executes the child process using operating system APIs directly. + All arguments are passed VERBATIM to the child process. + No intermediate shell is used, so shell operators such as ``>`` + are treated as normal arguments. + (Use the ``INPUT_*``, ``OUTPUT_*``, and ``ERROR_*`` options to + redirect stdin, stdout, and stderr.) + +WORKING_DIRECTORY + The named directory will be set as the current working directory of + the child processes. + +TIMEOUT + The child processes will be terminated if they do not finish in the + specified number of seconds (fractions are allowed). + +RESULT_VARIABLE + The variable will be set to contain the result of running the processes. + This will be an integer return code from the last child or a string + describing an error condition. + +OUTPUT_VARIABLE, ERROR_VARIABLE + The variable named will be set with the contents of the standard output + and standard error pipes, respectively. If the same variable is named + for both pipes their output will be merged in the order produced. + +INPUT_FILE, OUTPUT_FILE, ERROR_FILE + The file named will be attached to the standard input of the first + process, standard output of the last process, or standard error of + all processes, respectively. + +OUTPUT_QUIET, ERROR_QUIET + The standard output or standard error results will be quietly ignored. + +If more than one ``OUTPUT_*`` or ``ERROR_*`` option is given for the +same pipe the precedence is not specified. +If no ``OUTPUT_*`` or ``ERROR_*`` options are given the output will +be shared with the corresponding pipes of the CMake process itself. + +The :command:`execute_process` command is a newer more powerful version of +:command:`exec_program`, but the old command has been kept for compatibility. +Both commands run while CMake is processing the project prior to build +system generation. Use :command:`add_custom_target` and +:command:`add_custom_command` to create custom commands that run at +build time. diff --git a/Help/index.rst b/Help/index.rst index dea1463..0d33825 100644 --- a/Help/index.rst +++ b/Help/index.rst @@ -40,6 +40,7 @@ Other Manuals /manual/cmake-developer.7 /manual/cmake-generator-expressions.7 + /manual/cmake-language.7 .. only:: html diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 5d20c54..5857acf 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -255,7 +255,8 @@ containing just the line:: The ``cmake-module`` directive will scan the module file to extract reStructuredText markup from comment blocks that start in ``.rst:``. -Add to the top of ``Modules/<module-name>.cmake`` a #-comment of the form: +Add to the top of ``Modules/<module-name>.cmake`` a +:ref:`Line Comment` block of the form: .. code-block:: cmake @@ -265,7 +266,7 @@ Add to the top of ``Modules/<module-name>.cmake`` a #-comment of the form: # # <reStructuredText documentation of module> -or a bracket-comment of the form: +or a :ref:`Bracket Comment` of the form: .. code-block:: cmake diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst new file mode 100644 index 0000000..7285897 --- /dev/null +++ b/Help/manual/cmake-language.7.rst @@ -0,0 +1,470 @@ +.. cmake-manual-description: CMake Language Reference + +cmake-language(7) +***************** + +.. only:: html or latex + + .. contents:: + +Organization +============ + +CMake input files are written in the "CMake Language" in source files +named ``CMakeLists.txt`` or ending in a ``.cmake`` file name extension. + +CMake Language source files in a project are organized into: + +* `Directories`_ (``CMakeLists.txt``), +* `Scripts`_ (``<script>.cmake``), and +* `Modules`_ (``<module>.cmake``). + +Directories +----------- + +When CMake processes a project source tree, the entry point is +a source file called ``CMakeLists.txt`` in the top-level source +directory. This file may contain the entire build specification +or use the :command:`add_subdirectory` command to add subdirectories +to the build. Each subdirectory added by the command must also +contain a ``CMakeLists.txt`` file as the entry point to that +directory. For each source directory whose ``CMakeLists.txt`` file +is processed CMake generates a corresponding directory in the build +tree to act as the default working and output directory. + +Scripts +------- + +An individual ``<script>.cmake`` source file may be processed +in *script mode* by using the :manual:`cmake(1)` command-line tool +with the ``-P`` option. Script mode simply runs the commands in +the given CMake Language source file and does not generate a +build system. It does not allow CMake commands that define build +targets or actions. + +Modules +------- + +CMake Language code in either `Directories`_ or `Scripts`_ may +use the :command:`include` command to load a ``<module>.cmake`` +source file in the scope of the including context. +See the :manual:`cmake-modules(7)` manual page for documentation +of modules included with the CMake distribution. +Project source trees may also provide their own modules and +specify their location(s) in the :variable:`CMAKE_MODULE_PATH` +variable. + +Syntax +====== + +Encoding +-------- + +A CMake Language source file must be written in 7-bit ASCII text +to be portable across all supported platforms. Newlines may be +encoded as either ``\n`` or ``\r\n`` but will be converted to ``\n`` +as input files are read. + +Note that the implementation is 8-bit clean so source files may +be encoded as UTF-8 on platforms with system APIs supporting this +encoding. Furthermore, CMake 3.0 and above allow a leading UTF-8 +`Byte-Order Mark`_ in source files. + +.. _`Byte-Order Mark`: http://en.wikipedia.org/wiki/Byte_order_mark + +Source Files +------------ + +A CMake Language source file consists of zero or more +`Command Invocations`_ separated by newlines and optionally +spaces and `Comments`_: + +.. productionlist:: + file: `file_element`* + file_element: `command_invocation` `line_ending` | + : (`bracket_comment`|`space`)* `line_ending` + line_ending: `line_comment`? `newline` + space: <match '[ \t]+'> + newline: <match '\n'> + +Note that any source file line not inside `Command Arguments`_ or +a `Bracket Comment`_ can end in a `Line Comment`_. + +.. _`Command Invocations`: + +Command Invocations +------------------- + +A *command invocation* is a name followed by paren-enclosed arguments +separated by whitespace: + +.. productionlist:: + command_invocation: `space`* `identifier` `space`* '(' `arguments` ')' + identifier: <match '[A-Za-z_][A-Za-z0-9_]*'> + arguments: `argument`? `separated_arguments`* + separated_arguments: `separation`+ `argument`? | + : `separation`* '(' `arguments` ')' + separation: `space` | `line_ending` + +For example: + +.. code-block:: cmake + + add_executable(hello world.c) + +Command names are case-insensitive. +Nested unquoted parentheses in the arguments must balance. +Each ``(`` or ``)`` is given to the command invocation as +a literal `Unquoted Argument`_. This may be used in calls +to the :command:`if` command to enclose conditions. +For example: + +.. code-block:: cmake + + if(FALSE AND (FALSE OR TRUE)) # evaluates to FALSE + +.. note:: + CMake versions prior to 3.0 require command name identifiers + to be at least 2 characters. + + CMake versions prior to 2.8.12 silently accept an `Unquoted Argument`_ + or a `Quoted Argument`_ immediately following a `Quoted Argument`_ and + not separated by any whitespace. For compatibility, CMake 2.8.12 and + higher accept such code but produce a warning. + +Command Arguments +----------------- + +There are three types of arguments within `Command Invocations`_: + +.. productionlist:: + argument: `bracket_argument` | `quoted_argument` | `unquoted_argument` + +Bracket Argument +^^^^^^^^^^^^^^^^ + +A *bracket argument*, inspired by `Lua`_ long bracket syntax, +encloses content between opening and closing "brackets" of the +same length: + +.. productionlist:: + bracket_argument: `bracket_open` `bracket_content` `bracket_close` + bracket_open: '[' '='{len} '[' + bracket_content: <any text not containing a `bracket_close` + : of the same {len} as the `bracket_open`> + bracket_close: ']' '='{len} ']' + +An opening bracket of length *len >= 0* is written ``[`` followed +by *len* ``=`` followed by ``[`` and the corresponding closing +bracket is written ``]`` followed by *len* ``=`` followed by ``]``. +Brackets do not nest. A unique length may always be chosen +for the opening and closing brackets to contain closing brackets +of other lengths. + +Bracket argument content consists of all text between the opening +and closing brackets, except that one newline immediately following +the opening bracket, if any, is ignored. No evaluation of the +enclosed content, such as `Escape Sequences`_ or `Variable References`_, +is performed. A bracket argument is always given to the command +invocation as exactly one argument. + +For example: + +.. code-block:: cmake + + message([=[ + This is the first line in a bracket argument with bracket length 1. + No \-escape sequences or ${variable} references are evaluated. + This is always one argument even though it contains a ; character. + The text does not end on a closing bracket of length 0 like ]]. + It does end in a closing bracket of length 1. + ]=]) + +.. note:: + CMake versions prior to 3.0 do not support bracket arguments. + They interpret the opening bracket as the start of an + `Unquoted Argument`_. + +.. _`Lua`: http://www.lua.org/ + +Quoted Argument +^^^^^^^^^^^^^^^ + +A *quoted argument* encloses content between opening and closing +double-quote characters: + +.. productionlist:: + quoted_argument: '"' `quoted_element`* '"' + quoted_element: <any character except '\' or '"'> | + : `escape_sequence` | + : `quoted_continuation` + quoted_continuation: '\' `newline` + +Quoted argument content consists of all text between opening and +closing quotes. Both `Escape Sequences`_ and `Variable References`_ +are evaluated. A quoted argument is always given to the command +invocation as exactly one argument. + +For example: + +.. code-block:: cmake + + message("This is a quoted argument containing multiple lines. + This is always one argument even though it contains a ; character. + Both \\-escape sequences and ${variable} references are evaluated. + The text does not end on an escaped double-quote like \". + It does end in an unescaped double quote. + ") + +The final ``\`` on any line ending in an odd number of backslashes +is treated as a line continuation and ignored along with the +immediately following newline character. For example: + +.. code-block:: cmake + + message("\ + This is the first line of a quoted argument. \ + In fact it is the only line but since it is long \ + the source code uses line continuation.\ + ") + +.. note:: + CMake versions prior to 3.0 do not support continuation with ``\``. + They report errors in quoted arguments containing lines ending in + an odd number of ``\`` characters. + +Unquoted Argument +^^^^^^^^^^^^^^^^^ + +An *unquoted argument* is not enclosed by any quoting syntax. +It may not contain any whitespace, ``(``, ``)``, ``#``, ``"``, or ``\`` +except when escaped by a backslash: + +.. productionlist:: + unquoted_argument: `unquoted_element`+ | `unquoted_legacy` + unquoted_element: <any character except whitespace or one of '()#"\'> | + : `escape_sequence` + unquoted_legacy: <see note in text> + +Unquoted argument content consists of all text in a contiguous block +of allowed or escaped characters. Both `Escape Sequences`_ and +`Variable References`_ are evaluated. The resulting value is divided +in the same way `Lists`_ divide into elements. Each non-empty element +is given to the command invocation as an argument. Therefore an +unquoted argument may be given to a command invocation as zero or +more arguments. + +For example: + +.. code-block:: cmake + + foreach(arg + NoSpace + Escaped\ Space + This;Divides;Into;Five;Arguments + Escaped\;Semicolon + ) + message("${arg}") + endforeach() + +.. note:: + To support legacy CMake code, unquoted arguments may also contain + double-quoted strings (``"..."``, possibly enclosing horizontal + whitespace), and make-style variable references (``$(MAKEVAR)``). + Unescaped double-quotes must balance, may not appear at the + beginning of an unquoted argument, and are treated as part of the + content. For example, the unquoted arguments ``-Da="b c"``, + ``-Da=$(v)``, and ``a" "b"c"d`` are each interpreted literally. + + The above "unquoted_legacy" production represents such arguments. + We do not recommend using legacy unquoted arguments in new code. + Instead use a `Quoted Argument`_ or a `Bracket Argument`_ to + represent the content. + +Escape Sequences +---------------- + +An *escape sequence* is a ``\`` followed by one character: + +.. productionlist:: + escape_sequence: `escape_identity` | `escape_encoded` | `escape_semicolon` + escape_identity: '\(' | '\)' | '\#' | '\"' | '\ ' | + : '\\' | '\$' | '\@' | '\^' + escape_encoded: '\t' | '\r' | '\n' + escape_semicolon: '\;' + +A ``\`` followed by one of ``()#" \#@^`` simply encodes the literal +character without interpreting it as syntax. A ``\t``, ``\r``, or ``\n`` +encodes a tab, carriage return, or newline character, respectively. +A ``\;`` encodes itself but may be used in an `Unquoted Argument`_ +to encode the ``;`` without dividing the argument value on it. + +Variable References +------------------- + +A *variable reference* has the form ``${variable_name}`` and is +evaluated inside a `Quoted Argument`_ or an `Unquoted Argument`_. +A variable reference is replaced by the value of the variable, +or by the empty string if the variable is not set. +Variable references can nest and are evaluated from the +inside out, e.g. ``${outer_${inner_variable}_variable}``. + +The `Variables`_ section documents the scope of variable names +and how their values are set. + +Comments +-------- + +A comment starts with a ``#`` character that is not inside a +`Bracket Argument`_, `Quoted Argument`_, or escaped with ``\`` +as part of an `Unquoted Argument`_. There are two types of +comments: a `Bracket Comment`_ and a `Line Comment`_. + +.. _`Bracket Comment`: + +Bracket Comment +^^^^^^^^^^^^^^^ + +A ``#`` immediately followed by a `Bracket Argument`_ forms a +*bracket comment* consisting of the entire bracket enclosure: + +.. productionlist:: + bracket_comment: '#' `bracket_argument` + +For example: + +.. code-block:: cmake + + #[[This is a bracket comment. + It runs until the close bracket.]] + message("First Argument\n" #[[Bracket Comment]] "Second Argument") + +.. note:: + CMake versions prior to 3.0 do not support bracket comments. + They interpret the opening ``#`` as the start of a `Line Comment`_. + +.. _`Line Comment`: + +Line Comment +^^^^^^^^^^^^ + +A ``#`` not immediately followed by a `Bracket Argument`_ forms a +*line comment* that runs until the end of the line: + +.. productionlist:: + line_comment: '#' <any text not starting in a `bracket_argument` + : and not containing a `newline`> + +For example: + +.. code-block:: cmake + + # This is a line comment. + message("First Argument\n" # This is a line comment :) + "Second Argument") # This is a line comment. + +Control Structures +================== + +Conditional Blocks +------------------ + +The :command:`if`/:command:`elseif`/:command:`else`/:command:`endif` +commands delimit code blocks to be executed conditionally. + +Loops +----- + +The :command:`foreach`/:command:`endforeach` and +:command:`while`/:command:`endwhile` commands delimit code +blocks to be executed in a loop. The :command:`break` command +may be used inside such blocks to terminate the loop early. + +Command Definitions +------------------- + +The :command:`macro`/:command:`endmacro`, and +:command:`function`/:command:`endfunction` commands delimit +code blocks to be recorded for later invocation as commands. + +Variables +========= + +Variables are the basic unit of storage in the CMake Language. +Their values are always of string type, though some commands may +interpret the strings as values of other types. +The :command:`set` and :command:`unset` commands explicitly +set or unset a variable, but other commands have semantics +that modify variables as well. +Variable names are case-sensitive and may consist of almost +any text, but we recommend sticking to names consisting only +of alphanumeric characters plus ``_`` and ``-``. + +Variables have dynamic scope. Each variable "set" or "unset" +creates a binding in the current scope: + +Function Scope + `Command Definitions`_ created by the :command:`function` command + create commands that, when invoked, process the recorded commands + in a new variable binding scope. A variable "set" or "unset" + binds in this scope and is visible for the current function and + any nested calls, but not after the function returns. + +Directory Scope + Each of the `Directories`_ in a source tree has its own variable + bindings. Before processing the ``CMakeLists.txt`` file for a + directory, CMake copies all variable bindings currently defined + in the parent directory, if any, to initialize the new directory + scope. CMake `Scripts`_, when processed with ``cmake -P``, bind + variables in one "directory" scope. + + A variable "set" or "unset" not inside a function call binds + to the current directory scope. + +Persistent Cache + CMake stores a separate set of "cache" variables, or "cache entries", + whose values persist across multiple runs within a project build + tree. Cache entries have an isolated binding scope modified only + by explicit request, such as by the ``CACHE`` option of the + :command:`set` and :command:`unset` commands. + +When evaluating `Variable References`_, CMake first searches the +function call stack, if any, for a binding and then falls back +to the binding in the current directory scope, if any. If a +"set" binding is found, its value is used. If an "unset" binding +is found, or no binding is found, CMake then searches for a +cache entry. If a cache entry is found, its value is used. +Otherwise, the variable reference evaluates to an empty string. + +The :manual:`cmake-variables(7)` manual documents many variables +that are provided by CMake or have meaning to CMake when set +by project code. + +Lists +===== + +Although all values in CMake are stored as strings, a string +may be treated as a list in certain contexts, such as during +evaluation of an `Unquoted Argument`_. In such contexts, a string +is divided into list elements by splitting on ``;`` characters not +following an unequal number of ``[`` and ``]`` characters and not +immediately preceded by a ``\``. The sequence ``\;`` does not +divide a value but is replaced by ``;`` in the resulting element. + +A list of elements is represented as a string by concatenating +the elements separated by ``;``. For example, the :command:`set` +command stores multiple values into the destination variable +as a list: + +.. code-block:: cmake + + set(srcs a.c b.c c.c) # sets "srcs" to "a.c;b.c;c.c" + +Lists are meant for simple use cases such as a list of source +files and should not be used for complex data processing tasks. +Most commands that construct lists do not escape ``;`` characters +in list elements, thus flattening nested lists: + +.. code-block:: cmake + + set(x a "b;c") # sets "x" to "a;b;c", not "a;b\;c" diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 5879a30..2430ee9 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -70,3 +70,6 @@ All Policies /policy/CMP0034 /policy/CMP0035 /policy/CMP0036 + /policy/CMP0037 + /policy/CMP0038 + /policy/CMP0039 diff --git a/Help/policy/CMP0037.rst b/Help/policy/CMP0037.rst new file mode 100644 index 0000000..5df3c00 --- /dev/null +++ b/Help/policy/CMP0037.rst @@ -0,0 +1,21 @@ +CMP0037 +------- + +Target names should match a validity pattern. + +CMake 2.8.12 and lower allowed creating targets using :command:`add_library` and +:command:`add_executable` with unrestricted choice for the target name. Newer +cmake features such as :manual:`cmake-generator-expressions(7)` and some +diagnostics expect target names to match a restricted pattern. + +Target names may contain upper and lower case letters, numbers, the underscore +character (_), dot(.), plus(+) and minus(-). As a special case, ALIAS +targets and INTERFACE library targets may contain two consequtive colons. + +The OLD behavior for this policy is to allow creating targets which do not match +the validity pattern. The NEW behavior for this policy is to report an error +if an add_* command is used with an invalid target name. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/policy/CMP0038.rst b/Help/policy/CMP0038.rst new file mode 100644 index 0000000..c448ed6 --- /dev/null +++ b/Help/policy/CMP0038.rst @@ -0,0 +1,16 @@ +CMP0038 +------- + +Targets may not link directly to themselves + +CMake 2.8.12 and lower allowed a build target to link to itself directly with +a :command:`target_link_libraries` call. This is an indicator of a bug in +user code. + +The OLD behavior for this policy is to ignore targets which list themselves +in their own link implementation. The NEW behavior for this policy is to +report an error if a target attempts to link to itself. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/policy/CMP0039.rst b/Help/policy/CMP0039.rst new file mode 100644 index 0000000..1d20f0c --- /dev/null +++ b/Help/policy/CMP0039.rst @@ -0,0 +1,17 @@ +CMP0039 +------- + +Utility targets may not have link dependencies + +CMake 2.8.12 and lower allowed using utility targets in the left hand side +position of the :command:`target_link_libraries` command. This is an indicator +of a bug in user code. + +The OLD behavior for this policy is to ignore attempts to set the link +libraries of utility targets. The NEW behavior for this policy is to +report an error if an attempt is made to set the link libraries of a +utility target. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index c01245c..570b7e2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -38,6 +38,12 @@ configure_file( "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h" ) +# Tell CMake executable in the build tree where to find the source tree. +configure_file( + "${CMake_SOURCE_DIR}/Source/CMakeSourceDir.txt.in" + "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" @ONLY + ) + # add the include path to find the .h include_directories( "${CMake_BINARY_DIR}/Source" diff --git a/Source/CMakeSourceDir.txt.in b/Source/CMakeSourceDir.txt.in new file mode 100644 index 0000000..5e6a988 --- /dev/null +++ b/Source/CMakeSourceDir.txt.in @@ -0,0 +1 @@ +@CMake_SOURCE_DIR@ diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 98a90f7..18d2a0c 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 20131107) +set(CMake_VERSION_TWEAK 20131112) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 63a7596..0e16a40 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1143,12 +1143,6 @@ int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; - if ( !this->SetCMakeRoot() ) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot initialize the generator" << std::endl); - return 0; - } // set the running generator name this->SetOption("CPACK_GENERATOR", this->Name.c_str()); // Load the project specific config file @@ -1205,32 +1199,6 @@ const char* cmCPackGenerator::GetOption(const char* op) const } //---------------------------------------------------------------------- -int cmCPackGenerator::SetCMakeRoot() -{ - // use the CMAKE_ROOT from cmake which should have been - // found by now - const char* root= - this->MakefileMap->GetDefinition("CMAKE_ROOT"); - - if(root) - { - this->CMakeRoot = root; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << this->CMakeRoot.c_str() << std::endl); - this->SetOption("CMAKE_ROOT", this->CMakeRoot.c_str()); - return 1; - } - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Could not find CMAKE_ROOT !!!" - << std::endl - << "CMake has most likely not been installed correctly." - << std::endl - <<"Modules directory not found in" - << std::endl); - return 0; -} - -//---------------------------------------------------------------------- int cmCPackGenerator::PackageFiles() { return 0; diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 5cb2280..bb33aa0 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -105,9 +105,6 @@ public: bool IsSet(const char* name) const; bool IsOn(const char* name) const; - //! Set all the variables - int SetCMakeRoot(); - //! Set the logger void SetLogger(cmCPackLog* log) { this->Logger = log; } @@ -285,10 +282,6 @@ protected: */ std::vector<std::string> files; - std::string CPackSelf; - std::string CMakeSelf; - std::string CMakeRoot; - std::map<std::string, cmCPackInstallationType> InstallationTypes; /** * The set of components. diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 9f8cc14..438b16d 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -99,7 +99,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, // this is CPack. int main (int argc, char *argv[]) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); cmCPackLog log; log.SetErrorPrefix("CPack Error: "); @@ -228,7 +228,6 @@ int main (int argc, char *argv[]) // This part is used for cpack documentation lookup as well. cminst.AddCMakePaths(); - doc.SetCMakeRoot(cminst.GetCacheDefinition("CMAKE_ROOT")); if ( parsed && !help ) { diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 4fa3c53..5e53dbe 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -59,7 +59,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, { unsigned int k; std::vector<std::string> args; - args.push_back(this->CTest->GetCMakeExecutable()); + args.push_back(cmSystemTools::GetCMakeCommand()); args.push_back(this->SourceDir); if(this->BuildGenerator.size()) { diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index db33cb6..5eed409 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -86,7 +86,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } std::string cmakeConfigureCommand = "\""; - cmakeConfigureCommand += this->CTest->GetCMakeExecutable(); + cmakeConfigureCommand += cmSystemTools::GetCMakeCommand(); cmakeConfigureCommand += "\""; std::vector<std::string>::const_iterator it; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 7d33cf3..00a0a09 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -222,13 +222,13 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) // execute the script passing in the arguments to the script as well as the // arguments from this invocation of cmake std::vector<const char*> argv; - argv.push_back(this->CTest->GetCTestExecutable()); + argv.push_back(cmSystemTools::GetCTestCommand().c_str()); argv.push_back("-SR"); argv.push_back(total_script_arg.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Executable for CTest is: " << - this->CTest->GetCTestExecutable() << "\n"); + cmSystemTools::GetCTestCommand() << "\n"); // now pass through all the other arguments std::vector<cmStdString> &initArgs = @@ -397,9 +397,9 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) this->Makefile->AddDefinition("CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str()); this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME", - this->CTest->GetCTestExecutable()); + cmSystemTools::GetCTestCommand().c_str()); this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME", - this->CTest->GetCMakeExecutable()); + cmSystemTools::GetCMakeCommand().c_str()); this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); this->UpdateElapsedTime(); diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index fdfe331..ce50845 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -80,14 +80,13 @@ void CMakeErrorHandler(const char* message, const char* title, bool&, void* clie int main(int argc, char** argv) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); cmDocumentation doc; doc.addCMakeStandardDocSections(); if(doc.CheckOptions(argc, argv)) { cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); std::vector<cmDocumentationEntry> generators; hcm.GetGeneratorDocumentation(generators); doc.SetName("ccmake"); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 4fee0bb..d94cd37 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -43,14 +43,14 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, this->HelpMessage.push_back(""); this->HelpMessage.push_back(s_ConstHelpMessage); this->CMakeInstance = new cmake; - this->CMakeInstance->SetCMakeEditCommand("ccmake"); + this->CMakeInstance->SetCMakeEditCommand( + cmSystemTools::GetCMakeCursesCommand()); // create the arguments for the cmake object std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0].c_str()); whereCMake += "/cmake"; this->Args[0] = whereCMake; this->CMakeInstance->SetArgs(this->Args); - this->CMakeInstance->SetCMakeCommand(whereCMake.c_str()); this->SearchString = ""; this->OldSearchString = ""; this->SearchMode = false; diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 15f9ef1..88a9fc9 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -118,6 +118,13 @@ if(APPLE) # TBD: MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_BUNDLE_VERSION}" MACOSX_BUNDLE_COPYRIGHT "Copyright 2000-2013 Kitware, Inc." ) + + # Create a symlink in the build tree to provide a "cmake-gui" next + # to the "cmake" executable that refers to the application bundle. + add_custom_command(TARGET cmake-gui POST_BUILD + COMMAND ln -sf ${CMAKE_BUNDLE_NAME}.app/Contents/MacOS/${CMAKE_BUNDLE_NAME} + $<TARGET_FILE_DIR:cmake>/cmake-gui + ) endif() set(CMAKE_INSTALL_DESTINATION_ARGS BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}") diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 095aeb6..408bb4c 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -48,7 +48,7 @@ static const char * cmDocumentationOptions[][2] = int main(int argc, char** argv) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); // check docs first so that X is not need to get docs // do docs, if args were given cmDocumentation doc; @@ -58,7 +58,6 @@ int main(int argc, char** argv) // Construct and print requested documentation. cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); std::vector<cmDocumentationEntry> generators; hcm.GetGeneratorDocumentation(generators); diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0d01181..0fe5f8c 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -33,34 +33,13 @@ QCMake::QCMake(QObject* p) qRegisterMetaType<QCMakeProperty>(); qRegisterMetaType<QCMakePropertyList>(); - QDir execDir(QCoreApplication::applicationDirPath()); - -#if defined(Q_OS_MAC) - if(execDir.exists("../bin/cmake")) - { - execDir.cd("../bin"); - } - else - { - execDir.cd("../../../"); // path to cmake in build directory (need to fix for deployment) - } -#endif - - QString cmakeCommand = QString("cmake")+QString::fromLocal8Bit(cmSystemTools::GetExecutableExtension()); - cmakeCommand = execDir.filePath(cmakeCommand); - cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetErrorCallback(QCMake::errorCallback, this); - cmSystemTools::FindExecutableDirectory(cmakeCommand.toLocal8Bit().data()); this->CMakeInstance = new cmake; - this->CMakeInstance->SetCMakeCommand(cmakeCommand.toLocal8Bit().data()); -#if defined(Q_OS_MAC) - this->CMakeInstance->SetCMakeEditCommand("cmake-gui.app/Contents/MacOS/cmake-gui"); -#else - this->CMakeInstance->SetCMakeEditCommand("cmake-gui"); -#endif + this->CMakeInstance->SetCMakeEditCommand( + cmSystemTools::GetCMakeGUICommand()); this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this); diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 5785259..a93e834 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -69,6 +69,44 @@ bool cmAddExecutableCommand } } + bool nameOk = cmGeneratorExpression::IsValidTargetName(exename); + if (nameOk && !importTarget && !isAlias) + { + nameOk = exename.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << exename << "\" is not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // Special modifiers are not allowed with IMPORTED signature. if(importTarget && (use_win32 || use_macbundle || excludeFromAll)) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 0e61c99..4c591b6 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -108,6 +108,45 @@ bool cmAddLibraryCommand break; } } + + bool nameOk = cmGeneratorExpression::IsValidTargetName(libName); + if (nameOk && !importTarget && !isAlias) + { + nameOk = libName.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = type != cmTarget::INTERFACE_LIBRARY; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << libName << "\" is not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + if (isAlias) { if(!cmGeneratorExpression::IsValidTargetName(libName.c_str())) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 98f19cc..bfabc9f 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1298,7 +1298,8 @@ int cmCTest::RunTest(std::vector<const char*> argv, } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Test timeout computed to be: " << timeout << "\n"); - if(cmSystemTools::SameFile(argv[0], this->CTestSelf.c_str()) && + if(cmSystemTools::SameFile( + argv[0], cmSystemTools::GetCTestCommand().c_str()) && !this->ForceNewCTestProcess) { cmCTest inst; @@ -2257,7 +2258,6 @@ bool cmCTest::AddVariableDefinition(const std::string &arg) // the main entry point of ctest, called from main int cmCTest::Run(std::vector<std::string> &args, std::string* output) { - this->FindRunningCMake(); const char* ctestExec = "ctest"; bool cmakeAndTest = false; bool executeTests = true; @@ -2498,29 +2498,6 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) } //---------------------------------------------------------------------- -void cmCTest::FindRunningCMake() -{ - // Find our own executable. - this->CTestSelf = cmSystemTools::GetExecutableDirectory(); - this->CTestSelf += "/ctest"; - this->CTestSelf += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(this->CTestSelf.c_str())) - { - cmSystemTools::Error("CTest executable cannot be found at ", - this->CTestSelf.c_str()); - } - - this->CMakeSelf = cmSystemTools::GetExecutableDirectory(); - this->CMakeSelf += "/cmake"; - this->CMakeSelf += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(this->CMakeSelf.c_str())) - { - cmSystemTools::Error("CMake executable cannot be found at ", - this->CMakeSelf.c_str()); - } -} - -//---------------------------------------------------------------------- void cmCTest::SetNotesFiles(const char* notes) { if ( !notes ) diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 5dd35ce..c0a06c5 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -287,10 +287,6 @@ public: //source directory, it will become /.../relative/path/to/file std::string GetShortPathToFile(const char* fname); - //! Get the path to CTest - const char* GetCTestExecutable() { return this->CTestSelf.c_str(); } - const char* GetCMakeExecutable() { return this->CMakeSelf.c_str(); } - enum { EXPERIMENTAL, NIGHTLY, @@ -490,8 +486,6 @@ private: int CompatibilityMode; // information for the --build-and-test options - std::string CMakeSelf; - std::string CTestSelf; std::string BinaryDir; std::string NotesFiles; @@ -546,9 +540,6 @@ private: int GenerateCTestNotesOutput(std::ostream& os, const VectorOfStrings& files); - ///! Find the running cmake - void FindRunningCMake(); - //! Check if the argument is the one specified bool CheckArgument(const std::string& arg, const char* varg1, const char* varg2 = 0); diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 348f5d3..c5e95d0 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -16,6 +16,4 @@ #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER -#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}" -#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 682478e..8029577 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -605,7 +605,8 @@ void cmDocumentation::GlobHelp(std::vector<std::string>& files, std::string const& pattern) { cmsys::Glob gl; - std::string findExpr = this->CMakeRoot + "/Help/" + pattern + ".rst"; + std::string findExpr = + cmSystemTools::GetCMakeRoot() + "/Help/" + pattern + ".rst"; if(gl.FindFiles(findExpr)) { files = gl.GetFiles(); @@ -649,7 +650,7 @@ bool cmDocumentation::PrintFiles(std::ostream& os, std::vector<std::string> files; this->GlobHelp(files, pattern); std::sort(files.begin(), files.end()); - cmRST r(os, this->CMakeRoot + "/Help"); + cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help"); for (std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 07e614d..209cc27 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -83,9 +83,6 @@ public: void AppendSection(const char *sectionName, cmDocumentationEntry &docs); - /** Set cmake root so we can find installed files */ - void SetCMakeRoot(const char* root) { this->CMakeRoot = root? root:"";} - /** Add common (to all tools) documentation section(s) */ void addCommonStandardDocSections(); @@ -127,7 +124,6 @@ private: std::string NameString; std::map<std::string,cmDocumentationSection*> AllSections; - std::string CMakeRoot; std::string CurrentArgument; struct RequestedHelpItem diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx index 96fdb3e..5174118 100644 --- a/Source/cmExportSetMap.cxx +++ b/Source/cmExportSetMap.cxx @@ -23,7 +23,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string &name) return it->second; } -cmExportSetMap::~cmExportSetMap() +void cmExportSetMap::clear() { for(std::map<std::string, cmExportSet*>::iterator it = this->begin(); it != this->end(); @@ -31,4 +31,10 @@ cmExportSetMap::~cmExportSetMap() { delete it->second; } + this->derived::clear(); +} + +cmExportSetMap::~cmExportSetMap() +{ + this->clear(); } diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h index 4663c55..965046c 100644 --- a/Source/cmExportSetMap.h +++ b/Source/cmExportSetMap.h @@ -18,6 +18,7 @@ class cmExportSet; /// A name -> cmExportSet map with overloaded operator[]. class cmExportSetMap : public std::map<std::string, cmExportSet*> { + typedef std::map<std::string, cmExportSet*> derived; public: /** \brief Overloaded operator[]. * @@ -26,6 +27,8 @@ public: */ cmExportSet* operator[](const std::string &name); + void clear(); + /// Overloaded destructor deletes all member export sets. ~cmExportSetMap(); }; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 9c9df99..4ea5895 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2065,7 +2065,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cmCustomCommandLines cpackCommandLines; std::vector<std::string> depends; cmCustomCommandLine singleLine; - singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); + singleLine.push_back(cmSystemTools::GetCPackCommand()); if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) { singleLine.push_back("-C"); @@ -2106,7 +2106,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); + singleLine.push_back(cmSystemTools::GetCPackCommand()); singleLine.push_back("--config"); configFile = mf->GetStartOutputDirectory();; configFile += "/CPackSourceConfig.cmake"; @@ -2132,7 +2132,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - singleLine.push_back(this->GetCMakeInstance()->GetCTestCommand()); + singleLine.push_back(cmSystemTools::GetCTestCommand()); singleLine.push_back("--force-new-ctest-process"); if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c18a7eb..ac8381c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3072,7 +3072,6 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, cm.SetHomeOutputDirectory(bindir); cm.SetStartDirectory(srcdir); cm.SetStartOutputDirectory(bindir); - cm.SetCMakeCommand(cmakeCommand.c_str()); cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset()); cm.LoadCache(); if(!gg->IsMultiConfig()) diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index ab822d3..3881c54 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -286,6 +286,21 @@ cmPolicies::cmPolicies() CMP0036, "CMP0036", "The build_name command should not be called.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0037, "CMP0037", + "Target names should match a validity pattern.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0038, "CMP0038", + "Targets may not link directly to themselves.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0039, "CMP0039", + "Utility targets may not have link dependencies", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 9e72bdc..fc239d4 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -88,6 +88,9 @@ public: CMP0034, ///< Disallow command: utility_source CMP0035, ///< Disallow command: variable_requires CMP0036, ///< Disallow command: build_name + CMP0037, ///< Target names should match a validity pattern. + CMP0038, ///< Targets may not link directly to themselves + CMP0039, ///< Utility targets may not have link dependencies /** \brief Always the last entry. * diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1ecda88..f5376eb 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -43,6 +43,10 @@ # include <sys/wait.h> #endif +#if defined(__APPLE__) +# include <mach-o/dyld.h> +#endif + #include <sys/stat.h> #if defined(_WIN32) && \ @@ -2011,16 +2015,59 @@ unsigned int cmSystemTools::RandomSeed() } //---------------------------------------------------------------------------- -static std::string cmSystemToolsExecutableDirectory; -void cmSystemTools::FindExecutableDirectory(const char* argv0) -{ +static std::string cmSystemToolsCMakeCommand; +static std::string cmSystemToolsCTestCommand; +static std::string cmSystemToolsCPackCommand; +static std::string cmSystemToolsCMakeCursesCommand; +static std::string cmSystemToolsCMakeGUICommand; +static std::string cmSystemToolsCMakeRoot; +void cmSystemTools::FindCMakeResources(const char* argv0) +{ + std::string exe_dir; #if defined(_WIN32) && !defined(__CYGWIN__) (void)argv0; // ignore this on windows char modulepath[_MAX_PATH]; ::GetModuleFileName(NULL, modulepath, sizeof(modulepath)); - cmSystemToolsExecutableDirectory = - cmSystemTools::GetFilenamePath(modulepath); - return; + exe_dir = cmSystemTools::GetFilenamePath(modulepath); +#elif defined(__APPLE__) + (void)argv0; // ignore this on OS X +# define CM_EXE_PATH_LOCAL_SIZE 16384 + char exe_path_local[CM_EXE_PATH_LOCAL_SIZE]; +# if defined(MAC_OS_X_VERSION_10_3) && !defined(MAC_OS_X_VERSION_10_4) + unsigned long exe_path_size = CM_EXE_PATH_LOCAL_SIZE; +# else + uint32_t exe_path_size = CM_EXE_PATH_LOCAL_SIZE; +# endif +# undef CM_EXE_PATH_LOCAL_SIZE + char* exe_path = exe_path_local; + if(_NSGetExecutablePath(exe_path, &exe_path_size) < 0) + { + exe_path = (char*)malloc(exe_path_size); + _NSGetExecutablePath(exe_path, &exe_path_size); + } + exe_dir = + cmSystemTools::GetFilenamePath( + cmSystemTools::GetRealPath(exe_path)); + if(exe_path != exe_path_local) + { + free(exe_path); + } + if(cmSystemTools::GetFilenameName(exe_dir) == "MacOS") + { + // The executable is inside an application bundle. + // Look for ../bin (install tree) and then fall back to + // ../../../bin (build tree). + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + if(cmSystemTools::FileExists((exe_dir+"/bin/cmake").c_str())) + { + exe_dir += "/bin"; + } + else + { + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + } + } #else std::string errorMsg; std::string exe; @@ -2028,7 +2075,7 @@ void cmSystemTools::FindExecutableDirectory(const char* argv0) { // remove symlinks exe = cmSystemTools::GetRealPath(exe.c_str()); - cmSystemToolsExecutableDirectory = + exe_dir = cmSystemTools::GetFilenamePath(exe.c_str()); } else @@ -2036,12 +2083,99 @@ void cmSystemTools::FindExecutableDirectory(const char* argv0) // ??? } #endif + cmSystemToolsCMakeCommand = exe_dir; + cmSystemToolsCMakeCommand += "/cmake"; + cmSystemToolsCMakeCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCTestCommand = exe_dir; + cmSystemToolsCTestCommand += "/ctest"; + cmSystemToolsCTestCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCPackCommand = exe_dir; + cmSystemToolsCPackCommand += "/cpack"; + cmSystemToolsCPackCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCMakeGUICommand = exe_dir; + cmSystemToolsCMakeGUICommand += "/cmake-gui"; + cmSystemToolsCMakeGUICommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand.c_str())) + { + cmSystemToolsCMakeGUICommand = ""; + } + cmSystemToolsCMakeCursesCommand = exe_dir; + cmSystemToolsCMakeCursesCommand += "/ccmake"; + cmSystemToolsCMakeCursesCommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand.c_str())) + { + cmSystemToolsCMakeCursesCommand = ""; + } + +#ifdef CMAKE_BUILD_WITH_CMAKE + // Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>". + std::string dir = cmSystemTools::GetFilenamePath(exe_dir); + cmSystemToolsCMakeRoot = dir + CMAKE_DATA_DIR; + if(!cmSystemTools::FileExists( + (cmSystemToolsCMakeRoot+"/Modules/CMake.cmake").c_str())) + { + // Build tree has "<build>/bin[/<config>]/cmake" and + // "<build>/CMakeFiles/CMakeSourceDir.txt". + std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; + std::ifstream fin(src_dir_txt.c_str()); + std::string src_dir; + if(fin && cmSystemTools::GetLineFromStream(fin, src_dir) && + cmSystemTools::FileIsDirectory(src_dir.c_str())) + { + cmSystemToolsCMakeRoot = src_dir; + } + else + { + dir = cmSystemTools::GetFilenamePath(dir); + src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; + std::ifstream fin2(src_dir_txt.c_str()); + if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) && + cmSystemTools::FileIsDirectory(src_dir.c_str())) + { + cmSystemToolsCMakeRoot = src_dir; + } + } + } +#else + // Bootstrap build knows its source. + cmSystemToolsCMakeRoot = CMAKE_ROOT_DIR; +#endif +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeCommand() +{ + return cmSystemToolsCMakeCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCTestCommand() +{ + return cmSystemToolsCTestCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCPackCommand() +{ + return cmSystemToolsCPackCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeCursesCommand() +{ + return cmSystemToolsCMakeCursesCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeGUICommand() +{ + return cmSystemToolsCMakeGUICommand; } //---------------------------------------------------------------------------- -const char* cmSystemTools::GetExecutableDirectory() +std::string const& cmSystemTools::GetCMakeRoot() { - return cmSystemToolsExecutableDirectory.c_str(); + return cmSystemToolsCMakeRoot; } //---------------------------------------------------------------------------- diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 07235da..69f6381 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -406,13 +406,16 @@ public: /** Random seed generation. */ static unsigned int RandomSeed(); - /** Find the directory containing the running executable. Save it - in a global location to be queried by GetExecutableDirectory - later. */ - static void FindExecutableDirectory(const char* argv0); - - /** Get the directory containing the currently running executable. */ - static const char* GetExecutableDirectory(); + /** Find the directory containing CMake executables. */ + static void FindCMakeResources(const char* argv0); + + /** Get the CMake resource paths, after FindCMakeResources. */ + static std::string const& GetCTestCommand(); + static std::string const& GetCPackCommand(); + static std::string const& GetCMakeCommand(); + static std::string const& GetCMakeGUICommand(); + static std::string const& GetCMakeCursesCommand(); + static std::string const& GetCMakeRoot(); #if defined(CMAKE_BUILD_WITH_CMAKE) /** Echo a message in color using KWSys's Terminal cprintf. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index dc65297..c9905b6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -932,12 +932,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt) { - // Never add a self dependency, even if the user asks for it. - if(strcmp( target, lib ) == 0) - { - return; - } - cmTarget *tgt = this->Makefile->FindTargetToUse(lib); { const bool isNonImportedTarget = tgt && !tgt->IsImported(); @@ -951,7 +945,8 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, } if (cmGeneratorExpression::Find(lib) != std::string::npos - || (tgt && tgt->GetType() == INTERFACE_LIBRARY)) + || (tgt && tgt->GetType() == INTERFACE_LIBRARY) + || (strcmp( target, lib ) == 0)) { return; } @@ -5292,6 +5287,41 @@ void cmTarget::ComputeLinkImplementation(const char* config, std::string item = this->CheckCMP0004(*li); if(item == this->GetName() || item.empty()) { + if(item == this->GetName()) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0038)) + { + case cmPolicies::WARN: + { + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0038)) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage(messageType, + e.str(), + this->GetBacktrace()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } continue; } cmTarget *tgt = this->Makefile->FindTargetToUse(li->c_str()); @@ -5334,6 +5364,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, } } } + // The entry is meant for this configuration. impl.Libraries.push_back(item); } diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index c289459..209609d 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -101,6 +101,37 @@ bool cmTargetLinkLibrariesCommand return true; } + if (this->Target->GetType() == cmTarget::UTILITY) + { + const char *modal = 0; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) + { + case cmPolicies::WARN: + modal = "should"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + modal = "must"; + messageType = cmake::FATAL_ERROR; + } + if (modal) + { + cmOStringStream e; + e << this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0039) << "\n" + "Utility target \"" << this->Target->GetName() << "\" " << modal + << " not be used as the target of a target_link_libraries call."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if(messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // but we might not have any libs after variable expansion if(args.size() < 2) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index f786691..8bde300 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -932,34 +932,18 @@ void cmake::SetDirectoriesFromFile(const char* arg) // cache int cmake::AddCMakePaths() { - // Find the cmake executable - std::string cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - cMakeSelf += cmSystemTools::GetExecutableExtension(); -#ifdef __APPLE__ - // on the apple this might be the gui bundle - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "../../../.."; - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf = cmSystemTools::CollapseFullPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - std::cerr << cMakeSelf.c_str() << "\n"; - } -#endif - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cmSystemTools::Error("CMake executable cannot be found at ", - cMakeSelf.c_str()); - return 0; - } // Save the value in the cache this->CacheManager->AddCacheEntry - ("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.", - cmCacheManager::INTERNAL); + ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), + "Path to CMake executable.", cmCacheManager::INTERNAL); +#ifdef CMAKE_BUILD_WITH_CMAKE + this->CacheManager->AddCacheEntry + ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), + "Path to ctest program executable.", cmCacheManager::INTERNAL); + this->CacheManager->AddCacheEntry + ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), + "Path to cpack program executable.", cmCacheManager::INTERNAL); +#endif // if the edit command is not yet in the cache, // or if CMakeEditCommand has been set on this object, // then set the CMAKE_EDIT_COMMAND in the cache @@ -972,20 +956,17 @@ int cmake::AddCMakePaths() std::string editCacheCommand; if(!this->CMakeEditCommand.empty()) { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) - + std::string("/") - + this->CMakeEditCommand - + cmSystemTools::GetFilenameExtension(cMakeSelf); + editCacheCommand = this->CMakeEditCommand; } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) + if(!cmSystemTools::FileExists(editCacheCommand.c_str()) && + !cmSystemTools::GetCMakeCursesCommand().empty()) { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ccmake" + cmSystemTools::GetFilenameExtension(cMakeSelf); + editCacheCommand = cmSystemTools::GetCMakeCursesCommand(); } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) + if(!cmSystemTools::FileExists(editCacheCommand.c_str()) && + !cmSystemTools::GetCMakeGUICommand().empty()) { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cmake-gui" + cmSystemTools::GetFilenameExtension(cMakeSelf); + editCacheCommand = cmSystemTools::GetCMakeGUICommand(); } if(cmSystemTools::FileExists(editCacheCommand.c_str())) { @@ -994,84 +975,19 @@ int cmake::AddCMakePaths() "Path to cache edit program executable.", cmCacheManager::INTERNAL); } } - std::string ctestCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ctest" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(ctestCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CTEST_COMMAND", ctestCommand.c_str(), - "Path to ctest program executable.", cmCacheManager::INTERNAL); - } - std::string cpackCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cpack" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(cpackCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CPACK_COMMAND", cpackCommand.c_str(), - "Path to cpack program executable.", cmCacheManager::INTERNAL); - } - // do CMAKE_ROOT, look for the environment variable first - std::string cMakeRoot; - std::string modules; - if (getenv("CMAKE_ROOT")) - { - cMakeRoot = getenv("CMAKE_ROOT"); - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe/.. - cMakeRoot = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeRoot = cmSystemTools::GetProgramPath(cMakeRoot.c_str()); - std::string::size_type slashPos = cMakeRoot.rfind("/"); - if(slashPos != std::string::npos) - { - cMakeRoot = cMakeRoot.substr(0, slashPos); - } - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try exe/../share/cmake - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } -#ifdef CMAKE_ROOT_DIR - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try compiled in root directory - cMakeRoot = CMAKE_ROOT_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } -#endif - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if (!cmSystemTools::FileExists(modules.c_str())) + if(!cmSystemTools::FileExists( + (cmSystemTools::GetCMakeRoot()+"/Modules/CMake.cmake").c_str())) { // couldn't find modules cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n" "CMake has most likely not been installed correctly.\n" "Modules directory not found in\n", - cMakeRoot.c_str()); + cmSystemTools::GetCMakeRoot().c_str()); return 0; } this->CacheManager->AddCacheEntry - ("CMAKE_ROOT", cMakeRoot.c_str(), + ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), "Path to CMake installation.", cmCacheManager::INTERNAL); return 1; @@ -1705,9 +1621,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) return 0; } - // set the cmake command - this->CMakeCommand = args[0]; - if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache @@ -1925,14 +1838,6 @@ int cmake::LoadCache() } } - if (this->CMakeCommand.size() < 2) - { - cmSystemTools::Error( - "cmake command was not specified prior to loading the cache in " - "cmake.cxx"); - return -1; - } - // setup CMAKE_ROOT and CMAKE_COMMAND if(!this->AddCMakePaths()) { @@ -2238,82 +2143,6 @@ inline std::string removeQuotes(const std::string& s) return s; } -std::string cmake::FindCMakeProgram(const char* name) const -{ - std::string path; - if ((name) && (*name)) - { - const cmMakefile* mf - = this->GetGlobalGenerator()->GetLocalGenerators()[0]->GetMakefile(); -#ifdef CMAKE_BUILD_WITH_CMAKE - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = removeQuotes(path); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Debug/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Release/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } -#else - // Only for bootstrap - path += mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); -#endif - } - return path; -} - -const char* cmake::GetCTestCommand() -{ - if ( this->CTestCommand.empty() ) - { - this->CTestCommand = this->FindCMakeProgram("ctest"); - } - if ( this->CTestCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CTest executable"); - this->CTestCommand = "CTEST-COMMAND-NOT-FOUND"; - } - return this->CTestCommand.c_str(); -} - -const char* cmake::GetCPackCommand() -{ - if ( this->CPackCommand.empty() ) - { - this->CPackCommand = this->FindCMakeProgram("cpack"); - } - if ( this->CPackCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CPack executable"); - this->CPackCommand = "CPACK-COMMAND-NOT-FOUND"; - } - return this->CPackCommand.c_str(); -} - - -const char* cmake::GetCMakeCommand() -{ - return this->CMakeCommand.c_str(); -} - - void cmake::MarkCliAsUsed(const std::string& variable) { this->UsedCliVariables[variable] = true; diff --git a/Source/cmake.h b/Source/cmake.h index 7fe130b..d461fbd 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -200,9 +200,6 @@ class cmake ///! get the cmCachemManager used by this invocation of cmake cmCacheManager *GetCacheManager() { return this->CacheManager; } - ///! set the cmake command this instance of cmake should use - void SetCMakeCommand(const char* cmd) { this->CMakeCommand = cmd; } - /** * Given a variable name, return its value (as a string). */ @@ -301,13 +298,6 @@ class cmake */ cmFileTimeComparison* GetFileComparison() { return this->FileComparison; } - /** - * Get the path to ctest - */ - const char* GetCTestCommand(); - const char* GetCPackCommand(); - const char* GetCMakeCommand(); - // Do we want debug output during the cmake run. bool GetDebugOutput() { return this->DebugOutput; } void SetDebugOutputOn(bool b) { this->DebugOutput = b;} @@ -344,7 +334,7 @@ class cmake debugging configurations.*/ std::vector<std::string> const& GetDebugConfigs(); - void SetCMakeEditCommand(const char* s) + void SetCMakeEditCommand(std::string const& s) { this->CMakeEditCommand = s; } @@ -425,8 +415,6 @@ protected: cmVariableWatch* VariableWatch; - ///! Find the full path to one of the cmake programs like ctest, cpack, etc. - std::string FindCMakeProgram(const char* name) const; private: cmake(const cmake&); // Not implemented. void operator=(const cmake&); // Not implemented. @@ -443,15 +431,12 @@ private: bool CheckSystemVars; std::map<cmStdString, bool> UsedCliVariables; std::string CMakeEditCommand; - std::string CMakeCommand; std::string CXXEnvironment; std::string CCEnvironment; std::string CheckBuildSystemArgument; std::string CheckStampFile; std::string CheckStampList; std::string VSSolutionFile; - std::string CTestCommand; - std::string CPackCommand; bool ClearBuildSystem; bool DebugTryCompile; cmFileTimeComparison* FileComparison; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index ff5c8ae..6ef0579 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -162,7 +162,7 @@ static void cmakemainProgressCallback(const char *m, float prog, int main(int ac, char** av) { cmSystemTools::EnableMSVCDebugHook(); - cmSystemTools::FindExecutableDirectory(av[0]); + cmSystemTools::FindCMakeResources(av[0]); if(ac > 1) { if(strcmp(av[1], "--build") == 0) @@ -198,7 +198,6 @@ int do_cmake(int ac, char** av) // Construct and print requested documentation. cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); // the command line args are processed here so that you can do // -DCMAKE_MODULE_PATH=/some/path and have this value accessible here diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 12e71b6..de07458 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -115,7 +115,7 @@ int main (int argc, char *argv[]) { cmSystemTools::DoNotInheritStdPipes(); cmSystemTools::EnableMSVCDebugHook(); - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); // Dispatch 'ctest --launch' mode directly. if(argc >= 2 && strcmp(argv[1], "--launch") == 0) @@ -151,7 +151,6 @@ int main (int argc, char *argv[]) { cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); // Construct and print requested documentation. cmCTestScriptHandler* ch = diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt index bf9771c..5cda527 100644 --- a/Tests/CFBundleTest/CMakeLists.txt +++ b/Tests/CFBundleTest/CMakeLists.txt @@ -30,8 +30,14 @@ if(NOT RC_COMPILER) message(FATAL_ERROR "could not find Rez to build resources from .r file...") endif() +set(sysroot) +if(CMAKE_OSX_SYSROOT) + set(sysroot -isysroot ${CMAKE_OSX_SYSROOT}) +endif() + execute_process(COMMAND - ${RC_COMPILER} ${RCFILES} -useDF -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + ${RC_COMPILER} ${sysroot} ${RCFILES} -useDF + -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc ) set_source_files_properties( diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW.cmake b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW.cmake new file mode 100644 index 0000000..3fee15d --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW.cmake @@ -0,0 +1,14 @@ + +project(CMP0022-NOWARN-static-NEW) + +cmake_policy(SET CMP0022 NEW) + +add_library(foo STATIC empty_vs6_1.cpp) +add_library(bar STATIC empty_vs6_2.cpp) +add_library(bat STATIC empty_vs6_3.cpp) +target_link_libraries(foo bar) +# The last element here needs to contain a space so that it is a single +# element which is not a valid target name. As bar is a STATIC library, +# this tests that the LINK_ONLY generator expression is not used for +# that element, creating an error. +target_link_libraries(bar LINK_PRIVATE bat "-lz -lm") diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static.cmake b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static.cmake index ad3b8df..3e4144f 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static.cmake +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static.cmake @@ -5,8 +5,4 @@ add_library(foo STATIC empty_vs6_1.cpp) add_library(bar STATIC empty_vs6_2.cpp) add_library(bat STATIC empty_vs6_3.cpp) target_link_libraries(foo bar) -# The last element here needs to contain a space so that it is a single -# element which is not a valid target name. As bar is a STATIC library, -# this tests that the LINK_ONLY generator expression is not used for -# that element, creating an error. -target_link_libraries(bar bat "-lz -lm") +target_link_libraries(bar bat) diff --git a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake index 2781d20..4c10996 100644 --- a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake @@ -7,6 +7,7 @@ run_cmake(CMP0022-WARN-empty-old) run_cmake(CMP0022-NOWARN-exe) run_cmake(CMP0022-NOWARN-shared) run_cmake(CMP0022-NOWARN-static) +run_cmake(CMP0022-NOWARN-static-NEW) run_cmake(CMP0022-NOWARN-static-link_libraries) run_cmake(CMP0022-export) run_cmake(CMP0022-export-exe) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-result.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt new file mode 100644 index 0000000..aadc7d7 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt @@ -0,0 +1,19 @@ +CMake Error at CMP0037-NEW-colon.cmake:4 \(add_library\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "lib:colon" is not valid for certain CMake features, such + as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-colon.cmake:5 \(add_executable\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "exe:colon" is not valid for certain CMake features, such + as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake new file mode 100644 index 0000000..5c564f3 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake @@ -0,0 +1,5 @@ + +cmake_policy(SET CMP0037 NEW) + +add_library("lib:colon" empty.cpp) +add_executable("exe:colon" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-result.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt new file mode 100644 index 0000000..169db86 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt @@ -0,0 +1,19 @@ +CMake Error at CMP0037-NEW-space.cmake:4 \(add_library\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "lib with spaces" is not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-space.cmake:5 \(add_executable\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "exe with spaces" is not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake new file mode 100644 index 0000000..9e2faaa --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake @@ -0,0 +1,5 @@ + +cmake_policy(SET CMP0037 NEW) + +add_library("lib with spaces" empty.cpp) +add_executable("exe with spaces" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake new file mode 100644 index 0000000..af98f12 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake @@ -0,0 +1,5 @@ + +cmake_policy(SET CMP0037 OLD) + +add_library("lib with spaces" empty.cpp) +add_executable("exe with spaces" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-result.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt new file mode 100644 index 0000000..c9366fa --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt @@ -0,0 +1,21 @@ +CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:2 \(add_library\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "lib:colon" is not valid for certain CMake features, such + as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:3 \(add_executable\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "exe:colon" is not valid for certain CMake features, such + as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake new file mode 100644 index 0000000..17c815e --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake @@ -0,0 +1,3 @@ + +add_library("lib:colon" empty.cpp) +add_executable("exe:colon" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-result.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt new file mode 100644 index 0000000..b29aad5 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt @@ -0,0 +1,21 @@ +CMake Warning \(dev\) at CMP0037-WARN-space.cmake:2 \(add_library\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "lib with spaces" is not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-space.cmake:3 \(add_executable\): + Policy CMP0037 is not set: Target names should match a validity pattern. + Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The target name "exe with spaces" is not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake new file mode 100644 index 0000000..4a10828 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake @@ -0,0 +1,3 @@ + +add_library("lib with spaces" empty.cpp) +add_executable("exe with spaces" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMakeLists.txt b/Tests/RunCMake/CMP0037/CMakeLists.txt new file mode 100644 index 0000000..f1d9cae --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake new file mode 100644 index 0000000..fbb1788 --- /dev/null +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -0,0 +1,10 @@ +include(RunCMake) + +run_cmake(CMP0037-OLD-space) +run_cmake(CMP0037-NEW-space) +run_cmake(CMP0037-WARN-space) +run_cmake(CMP0037-NEW-colon) + +if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make")) + run_cmake(CMP0037-WARN-colon) +endif() diff --git a/Tests/RunCMake/CMP0037/empty.cpp b/Tests/RunCMake/CMP0037/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0037/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW-result.txt b/Tests/RunCMake/CMP0038/CMP0038-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt new file mode 100644 index 0000000..3d0a428 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0038-NEW.cmake:3 \(add_library\): + Target "self_link" links to itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake b/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake new file mode 100644 index 0000000..6296b83 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0038 NEW) +add_library(self_link empty.cpp) +target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt b/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake b/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake new file mode 100644 index 0000000..3752821 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0038 OLD) +add_library(self_link empty.cpp) +target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt b/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt new file mode 100644 index 0000000..64631e7 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-WARN-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0038-WARN.cmake:2 \(add_library\): + Policy CMP0038 is not set: Targets may not link directly to themselves. + Run "cmake --help-policy CMP0038" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + Target "self_link" links to itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake b/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake new file mode 100644 index 0000000..5b92d09 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMP0038-WARN.cmake @@ -0,0 +1,3 @@ + +add_library(self_link empty.cpp) +target_link_libraries(self_link self_link) diff --git a/Tests/RunCMake/CMP0038/CMakeLists.txt b/Tests/RunCMake/CMP0038/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0038/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0038/RunCMakeTest.cmake b/Tests/RunCMake/CMP0038/RunCMakeTest.cmake new file mode 100644 index 0000000..fc3500a --- /dev/null +++ b/Tests/RunCMake/CMP0038/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0038-WARN) +run_cmake(CMP0038-NEW) +run_cmake(CMP0038-OLD) diff --git a/Tests/RunCMake/CMP0038/empty.cpp b/Tests/RunCMake/CMP0038/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0038/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0039/CMP0039-NEW-result.txt b/Tests/RunCMake/CMP0039/CMP0039-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0039/CMP0039-NEW-stderr.txt b/Tests/RunCMake/CMP0039/CMP0039-NEW-stderr.txt new file mode 100644 index 0000000..1496c05 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-NEW-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at CMP0039-NEW.cmake:7 \(target_link_libraries\): + Policy CMP0039 is not set: Utility targets may not have link dependencies + Run "cmake --help-policy CMP0039" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + Utility target "utility" must not be used as the target of a + target_link_libraries call. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0039/CMP0039-NEW.cmake b/Tests/RunCMake/CMP0039/CMP0039-NEW.cmake new file mode 100644 index 0000000..2032d64 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-NEW.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0039 NEW) + +add_custom_target(utility + COMMAND ${CMAKE_COMMAND} -E echo test +) +target_link_libraries(utility m) diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt b/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt b/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD.cmake b/Tests/RunCMake/CMP0039/CMP0039-OLD.cmake new file mode 100644 index 0000000..9a513f4 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-OLD.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0039 OLD) + +add_custom_target(utility + COMMAND ${CMAKE_COMMAND} -E echo test +) +target_link_libraries(utility m) diff --git a/Tests/RunCMake/CMP0039/CMP0039-WARN-result.txt b/Tests/RunCMake/CMP0039/CMP0039-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0039/CMP0039-WARN-stderr.txt b/Tests/RunCMake/CMP0039/CMP0039-WARN-stderr.txt new file mode 100644 index 0000000..9387f8c --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-WARN-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at CMP0039-WARN.cmake:5 \(target_link_libraries\): + Policy CMP0039 is not set: Utility targets may not have link dependencies + Run "cmake --help-policy CMP0039" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + Utility target "utility" should not be used as the target of a + target_link_libraries call. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0039/CMP0039-WARN.cmake b/Tests/RunCMake/CMP0039/CMP0039-WARN.cmake new file mode 100644 index 0000000..6249993 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMP0039-WARN.cmake @@ -0,0 +1,5 @@ + +add_custom_target(utility + COMMAND ${CMAKE_COMMAND} -E echo test +) +target_link_libraries(utility m) diff --git a/Tests/RunCMake/CMP0039/CMakeLists.txt b/Tests/RunCMake/CMP0039/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0039/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0039/RunCMakeTest.cmake b/Tests/RunCMake/CMP0039/RunCMakeTest.cmake new file mode 100644 index 0000000..58e8ea9 --- /dev/null +++ b/Tests/RunCMake/CMP0039/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0039-WARN) +run_cmake(CMP0039-NEW) +run_cmake(CMP0039-OLD) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 99a0fb3..bf3dcc1 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -56,6 +56,9 @@ add_RunCMake_test(CMP0022) add_RunCMake_test(CMP0026) add_RunCMake_test(CMP0027) add_RunCMake_test(CMP0028) +add_RunCMake_test(CMP0037) +add_RunCMake_test(CMP0038) +add_RunCMake_test(CMP0039) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) |