diff options
264 files changed, 4561 insertions, 1248 deletions
diff --git a/Help/command/FIND_XXX_ROOT.txt b/Help/command/FIND_XXX_ROOT.txt index efc076f..b5cab68 100644 --- a/Help/command/FIND_XXX_ROOT.txt +++ b/Help/command/FIND_XXX_ROOT.txt @@ -1,9 +1,9 @@ -The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more +The CMake variable :variable:`CMAKE_FIND_ROOT_PATH` specifies one or more directories to be prepended to all other search directories. This effectively "re-roots" the entire search under given locations. Paths which are descendants of the :variable:`CMAKE_STAGING_PREFIX` are excluded from this re-rooting, because that variable is always a path on the host system. -By default the CMAKE_FIND_ROOT_PATH is empty. +By default the :variable:`CMAKE_FIND_ROOT_PATH` is empty. The :variable:`CMAKE_SYSROOT` variable can also be used to specify exactly one directory to use as a prefix. Setting :variable:`CMAKE_SYSROOT` also has other @@ -12,12 +12,12 @@ effects. See the documentation for that variable for more. These variables are especially useful when cross-compiling to point to the root directory of the target environment and CMake will search there too. By default at first the directories listed in -CMAKE_FIND_ROOT_PATH are searched, then the :variable:`CMAKE_SYSROOT` directory is -searched, and then the non-rooted directories will be +:variable:`CMAKE_FIND_ROOT_PATH` are searched, then the :variable:`CMAKE_SYSROOT` +directory is searched, and then the non-rooted directories will be searched. The default behavior can be adjusted by setting |CMAKE_FIND_ROOT_PATH_MODE_XXX|. This behavior can be manually overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH the search order will be as described above. If -NO_CMAKE_FIND_ROOT_PATH is used then CMAKE_FIND_ROOT_PATH will not be +NO_CMAKE_FIND_ROOT_PATH is used then :variable:`CMAKE_FIND_ROOT_PATH` will not be used. If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted directories and directories below :variable:`CMAKE_STAGING_PREFIX` will be searched. diff --git a/Help/command/find_file.rst b/Help/command/find_file.rst index 549b317..db7e151 100644 --- a/Help/command/find_file.rst +++ b/Help/command/find_file.rst @@ -22,6 +22,6 @@ find_file .. |CMAKE_SYSTEM_XXX_MAC_PATH| replace:: CMAKE_SYSTEM_FRAMEWORK_PATH .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace:: - CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + :variable:`CMAKE_FIND_ROOT_PATH_MODE_INCLUDE` .. include:: FIND_XXX.txt diff --git a/Help/command/find_library.rst b/Help/command/find_library.rst index 8598be7..91342ba 100644 --- a/Help/command/find_library.rst +++ b/Help/command/find_library.rst @@ -22,7 +22,7 @@ find_library .. |CMAKE_SYSTEM_XXX_MAC_PATH| replace:: CMAKE_SYSTEM_FRAMEWORK_PATH .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace:: - CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + :variable:`CMAKE_FIND_ROOT_PATH_MODE_LIBRARY` .. include:: FIND_XXX.txt diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index c394a08..f09cb41 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -320,7 +320,7 @@ hard-coded guesses. .. |FIND_XXX| replace:: find_package .. |FIND_ARGS_XXX| replace:: <package> .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace:: - CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + :variable:`CMAKE_FIND_ROOT_PATH_MODE_PACKAGE` .. include:: FIND_XXX_MAC.txt .. include:: FIND_XXX_ROOT.txt diff --git a/Help/command/find_path.rst b/Help/command/find_path.rst index c85011a..95d49e7 100644 --- a/Help/command/find_path.rst +++ b/Help/command/find_path.rst @@ -22,7 +22,7 @@ find_path .. |CMAKE_SYSTEM_XXX_MAC_PATH| replace:: CMAKE_SYSTEM_FRAMEWORK_PATH .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace:: - CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + :variable:`CMAKE_FIND_ROOT_PATH_MODE_INCLUDE` .. include:: FIND_XXX.txt diff --git a/Help/command/find_program.rst b/Help/command/find_program.rst index da5a41d..c62a8a5 100644 --- a/Help/command/find_program.rst +++ b/Help/command/find_program.rst @@ -20,6 +20,6 @@ find_program .. |CMAKE_SYSTEM_XXX_MAC_PATH| replace:: CMAKE_SYSTEM_APPBUNDLE_PATH .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace:: - CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + :variable:`CMAKE_FIND_ROOT_PATH_MODE_PROGRAM` .. include:: FIND_XXX.txt diff --git a/Help/command/if.rst b/Help/command/if.rst index 0279be7..49c356e 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -3,24 +3,24 @@ if Conditionally execute a group of commands. -:: - - if(expression) - # then section. - COMMAND1(ARGS ...) - COMMAND2(ARGS ...) - ... - elseif(expression2) - # elseif section. - COMMAND1(ARGS ...) - COMMAND2(ARGS ...) - ... - else(expression) - # else section. - COMMAND1(ARGS ...) - COMMAND2(ARGS ...) - ... - endif(expression) +.. code-block:: cmake + + if(expression) + # then section. + COMMAND1(ARGS ...) + COMMAND2(ARGS ...) + ... + elseif(expression2) + # elseif section. + COMMAND1(ARGS ...) + COMMAND2(ARGS ...) + ... + else(expression) + # else section. + COMMAND1(ARGS ...) + COMMAND2(ARGS ...) + ... + endif(expression) Evaluates the given expression. If the result is true, the commands in the THEN section are invoked. Otherwise, the commands in the else @@ -28,212 +28,174 @@ section are invoked. The elseif and else sections are optional. You may have multiple elseif clauses. Note that the expression in the else and endif clause is optional. Long expressions can be used and there is a traditional order of precedence. Parenthetical expressions -are evaluated first followed by unary operators such as EXISTS, -COMMAND, and DEFINED. Then any EQUAL, LESS, GREATER, STRLESS, -STRGREATER, STREQUAL, MATCHES will be evaluated. Then NOT operators -and finally AND, OR operators will be evaluated. Possible expressions -are: - -:: - - if(<constant>) - -True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. -False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, '', -or ends in the suffix '-NOTFOUND'. Named boolean constants are -case-insensitive. If the argument is not one of these constants, it -is treated as a variable: - -:: - - if(<variable>) - -True if the variable is defined to a value that is not a false -constant. False otherwise. (Note macro arguments are not variables.) - -:: - - if(NOT <expression>) - -True if the expression is not true. - -:: - - if(<expr1> AND <expr2>) - -True if both expressions would be considered true individually. - -:: - - if(<expr1> OR <expr2>) - -True if either expression would be considered true individually. - -:: - - if(COMMAND command-name) - -True if the given name is a command, macro or function that can be -invoked. - -:: - - if(POLICY policy-id) - -True if the given name is an existing policy (of the form CMP<NNNN>). - -:: - - if(TARGET target-name) - -True if the given name is an existing target, built or imported. - -:: - - if(EXISTS file-name) - if(EXISTS directory-name) - -True if the named file or directory exists. Behavior is well-defined -only for full paths. - -:: - - if(file1 IS_NEWER_THAN file2) - -True if file1 is newer than file2 or if one of the two files doesn't -exist. Behavior is well-defined only for full paths. If the file -time stamps are exactly the same, an IS_NEWER_THAN comparison returns -true, so that any dependent build operations will occur in the event -of a tie. This includes the case of passing the same file name for -both file1 and file2. - -:: - - if(IS_DIRECTORY directory-name) - -True if the given name is a directory. Behavior is well-defined only -for full paths. - -:: - - if(IS_SYMLINK file-name) - -True if the given name is a symbolic link. Behavior is well-defined -only for full paths. - -:: - - if(IS_ABSOLUTE path) - -True if the given path is an absolute path. - -:: - - if(<variable|string> MATCHES regex) - -True if the given string or variable's value matches the given regular -expression. - -:: - - if(<variable|string> LESS <variable|string>) - if(<variable|string> GREATER <variable|string>) - if(<variable|string> EQUAL <variable|string>) - -True if the given string or variable's value is a valid number and the -inequality or equality is true. - -:: - - if(<variable|string> STRLESS <variable|string>) - if(<variable|string> STRGREATER <variable|string>) - if(<variable|string> STREQUAL <variable|string>) - -True if the given string or variable's value is lexicographically less -(or greater, or equal) than the string or variable on the right. - -:: - - if(<variable|string> VERSION_LESS <variable|string>) - if(<variable|string> VERSION_EQUAL <variable|string>) - if(<variable|string> VERSION_GREATER <variable|string>) - -Component-wise integer version number comparison (version format is -major[.minor[.patch[.tweak]]]). - -:: - - if(DEFINED <variable>) - -True if the given variable is defined. It does not matter if the -variable is true or false just if it has been set. (Note macro -arguments are not variables.) - -:: - - if((expression) AND (expression OR (expression))) - -The expressions inside the parenthesis are evaluated first and then -the remaining expression is evaluated as in the previous examples. -Where there are nested parenthesis the innermost are evaluated as part -of evaluating the expression that contains them. +are evaluated first followed by unary tests such as ``EXISTS``, +``COMMAND``, and ``DEFINED``. Then any binary tests such as +``EQUAL``, ``LESS``, ``GREATER``, ``STRLESS``, ``STRGREATER``, +``STREQUAL``, and ``MATCHES`` will be evaluated. Then boolean ``NOT`` +operators and finally boolean ``AND`` and then ``OR`` operators will +be evaluated. + +Possible expressions are: + +``if(<constant>)`` + True if the constant is ``1``, ``ON``, ``YES``, ``TRUE``, ``Y``, + or a non-zero number. False if the constant is ``0``, ``OFF``, + ``NO``, ``FALSE``, ``N``, ``IGNORE``, ``NOTFOUND``, the empty string, + or ends in the suffix ``-NOTFOUND``. Named boolean constants are + case-insensitive. If the argument is not one of these constants, it + is treated as a variable. + +``if(<variable>)`` + True if the variable is defined to a value that is not a false + constant. False otherwise. (Note macro arguments are not variables.) + +``if(NOT <expression>)`` + True if the expression is not true. + +``if(<expr1> AND <expr2>)`` + True if both expressions would be considered true individually. + +``if(<expr1> OR <expr2>)`` + True if either expression would be considered true individually. + +``if(COMMAND command-name)`` + True if the given name is a command, macro or function that can be + invoked. + +``if(POLICY policy-id)`` + True if the given name is an existing policy (of the form ``CMP<NNNN>``). + +``if(TARGET target-name)`` + True if the given name is an existing logical target name such as those + created by the :command:`add_executable`, :command:`add_library`, or + :command:`add_custom_target` commands. + +``if(EXISTS path-to-file-or-directory)`` + True if the named file or directory exists. Behavior is well-defined + only for full paths. + +``if(file1 IS_NEWER_THAN file2)`` + True if file1 is newer than file2 or if one of the two files doesn't + exist. Behavior is well-defined only for full paths. If the file + time stamps are exactly the same, an ``IS_NEWER_THAN`` comparison returns + true, so that any dependent build operations will occur in the event + of a tie. This includes the case of passing the same file name for + both file1 and file2. + +``if(IS_DIRECTORY path-to-directory)`` + True if the given name is a directory. Behavior is well-defined only + for full paths. + +``if(IS_SYMLINK file-name)`` + True if the given name is a symbolic link. Behavior is well-defined + only for full paths. + +``if(IS_ABSOLUTE path)`` + True if the given path is an absolute path. + +``if(<variable|string> MATCHES regex)`` + True if the given string or variable's value matches the given regular + expression. + +``if(<variable|string> LESS <variable|string>)`` + True if the given string or variable's value is a valid number and less + than that on the right. + +``if(<variable|string> GREATER <variable|string>)`` + True if the given string or variable's value is a valid number and greater + than that on the right. + +``if(<variable|string> EQUAL <variable|string>)`` + True if the given string or variable's value is a valid number and equal + to that on the right. + +``if(<variable|string> STRLESS <variable|string>)`` + True if the given string or variable's value is lexicographically less + than the string or variable on the right. + +``if(<variable|string> STRGREATER <variable|string>)`` + True if the given string or variable's value is lexicographically greater + than the string or variable on the right. + +``if(<variable|string> STREQUAL <variable|string>)`` + True if the given string or variable's value is lexicographically equal + to the string or variable on the right. + +``if(<variable|string> VERSION_LESS <variable|string>)`` + Component-wise integer version number comparison (version format is + ``major[.minor[.patch[.tweak]]]``). + +``if(<variable|string> VERSION_EQUAL <variable|string>)`` + Component-wise integer version number comparison (version format is + ``major[.minor[.patch[.tweak]]]``). + +``if(<variable|string> VERSION_GREATER <variable|string>)`` + Component-wise integer version number comparison (version format is + ``major[.minor[.patch[.tweak]]]``). + +``if(DEFINED <variable>)`` + True if the given variable is defined. It does not matter if the + variable is true or false just if it has been set. (Note macro + arguments are not variables.) + +``if((expression) AND (expression OR (expression)))`` + The expressions inside the parenthesis are evaluated first and then + the remaining expression is evaluated as in the previous examples. + Where there are nested parenthesis the innermost are evaluated as part + of evaluating the expression that contains them. The if command was written very early in CMake's history, predating -the ${} variable evaluation syntax, and for convenience evaluates +the ``${}`` variable evaluation syntax, and for convenience evaluates variables named by its arguments as shown in the above signatures. -Note that normal variable evaluation with ${} applies before the if -command even receives the arguments. Therefore code like - -:: - - set(var1 OFF) - set(var2 "var1") - if(${var2}) - -appears to the if command as +Note that normal variable evaluation with ``${}`` applies before the if +command even receives the arguments. Therefore code like:: -:: + set(var1 OFF) + set(var2 "var1") + if(${var2}) - if(var1) +appears to the if command as:: -and is evaluated according to the if(<variable>) case documented -above. The result is OFF which is false. However, if we remove the -${} from the example then the command sees + if(var1) -:: +and is evaluated according to the ``if(<variable>)`` case documented +above. The result is ``OFF`` which is false. However, if we remove the +``${}`` from the example then the command sees:: - if(var2) + if(var2) -which is true because var2 is defined to "var1" which is not a false +which is true because ``var2`` is defined to "var1" which is not a false constant. Automatic evaluation applies in the other cases whenever the -above-documented signature accepts <variable|string>: +above-documented signature accepts ``<variable|string>``: -1) The left hand argument to MATCHES is first checked to see if it is -a defined variable, if so the variable's value is used, otherwise the -original value is used. +* The left hand argument to ``MATCHES`` is first checked to see if it is + a defined variable, if so the variable's value is used, otherwise the + original value is used. -2) If the left hand argument to MATCHES is missing it returns false -without error +* If the left hand argument to ``MATCHES`` is missing it returns false + without error -3) Both left and right hand arguments to LESS GREATER EQUAL are -independently tested to see if they are defined variables, if so their -defined values are used otherwise the original value is used. +* Both left and right hand arguments to ``LESS``, ``GREATER``, and + ``EQUAL`` are independently tested to see if they are defined + variables, if so their defined values are used otherwise the original + value is used. -4) Both left and right hand arguments to STRLESS STREQUAL STRGREATER -are independently tested to see if they are defined variables, if so -their defined values are used otherwise the original value is used. +* Both left and right hand arguments to ``STRLESS``, ``STREQUAL``, and + ``STRGREATER`` are independently tested to see if they are defined + variables, if so their defined values are used otherwise the original + value is used. -5) Both left and right hand argumemnts to VERSION_LESS VERSION_EQUAL -VERSION_GREATER are independently tested to see if they are defined -variables, if so their defined values are used otherwise the original -value is used. +* Both left and right hand argumemnts to ``VERSION_LESS``, + ``VERSION_EQUAL``, and ``VERSION_GREATER`` are independently tested + to see if they are defined variables, if so their defined values are + used otherwise the original value is used. -6) The right hand argument to NOT is tested to see if it is a boolean -constant, if so the value is used, otherwise it is assumed to be a -variable and it is dereferenced. +* The right hand argument to ``NOT`` is tested to see if it is a boolean + constant, if so the value is used, otherwise it is assumed to be a + variable and it is dereferenced. -7) The left and right hand arguments to AND OR are independently -tested to see if they are boolean constants, if so they are used as -such, otherwise they are assumed to be variables and are dereferenced. +* The left and right hand arguments to ``AND`` and ``OR`` are independently + tested to see if they are boolean constants, if so they are used as + such, otherwise they are assumed to be variables and are dereferenced. diff --git a/Help/command/source_group.rst b/Help/command/source_group.rst index 77bb9ad..6e3829c 100644 --- a/Help/command/source_group.rst +++ b/Help/command/source_group.rst @@ -1,28 +1,44 @@ source_group ------------ -Define a grouping for sources in the makefile. +Define a grouping for source files in IDE project generation. -:: +.. code-block:: cmake - source_group(name [REGULAR_EXPRESSION regex] [FILES src1 src2 ...]) + source_group(<name> [FILES <src>...] [REGULAR_EXPRESSION <regex>]) Defines a group into which sources will be placed in project files. -This is mainly used to setup file tabs in Visual Studio. Any file -whose name is listed or matches the regular expression will be placed -in this group. If a file matches multiple groups, the LAST group that -explicitly lists the file will be favored, if any. If no group -explicitly lists the file, the LAST group whose regular expression -matches the file will be favored. +This is intended to set up file tabs in Visual Studio. +The options are: -The name of the group may contain backslashes to specify subgroups: +``FILES`` + Any source file specified explicitly will be placed in group + ``<name>``. Relative paths are interpreted with respect to the + current source directory. -:: +``REGULAR_EXPRESSION`` + Any source file whose name matches the regular expression will + be placed in group ``<name>``. + +If a source file matches multiple groups, the *last* group that +explicitly lists the file with ``FILES`` will be favored, if any. +If no group explicitly lists the file, the *last* group whose +regular expression matches the file will be favored. + +The ``<name>`` of the group may contain backslashes to specify subgroups: + +.. code-block:: cmake source_group(outer\\inner ...) -For backwards compatibility, this command also supports the format: +For backwards compatibility, the short-hand signature + +.. code-block:: cmake + + source_group(<name> <regex>) + +is equivalent to -:: +.. code-block:: cmake - source_group(name regex) + source_group(<name> REGULAR_EXPRESSION <regex>) diff --git a/Help/generator/Kate.rst b/Help/generator/Kate.rst new file mode 100644 index 0000000..9b61a93 --- /dev/null +++ b/Help/generator/Kate.rst @@ -0,0 +1,26 @@ +Kate +---- + +Generates Kate project files. + +A project file for Kate will be created in the top directory in the top level +build directory. +To use it in kate, the Project plugin must be enabled. +The project file is loaded in kate simply by opening the +ProjectName.kateproject file in the editor. +If the kate Build-plugin is enabled, all targets generated by CMake are +available for building. + +This "extra" generator may be specified as: + +``Kate - MinGW Makefiles`` + Generate with :generator:`MinGW Makefiles`. + +``Kate - NMake Makefiles`` + Generate with :generator:`NMake Makefiles`. + +``Kate - Ninja`` + Generate with :generator:`Ninja`. + +``Kate - Unix Makefiles`` + Generate with :generator:`Unix Makefiles`. diff --git a/Help/index.rst b/Help/index.rst index a466e4b..f5cb8a5 100644 --- a/Help/index.rst +++ b/Help/index.rst @@ -27,6 +27,7 @@ Reference Manuals /manual/cmake-commands.7 /manual/cmake-generators.7 + /manual/cmake-toolchains.7 /manual/cmake-modules.7 /manual/cmake-packages.7 /manual/cmake-policies.7 diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index bd9e7c2..ed28abd 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -178,3 +178,9 @@ property is non-empty:: Content of ``...`` when the property is exported using :command:`export`, or when the target is used by another target in the same buildsystem. Expands to the empty string otherwise. +``$<LOWER_CASE:...>`` + Content of ``...`` converted to lower case. +``$<UPPER_CASE:...>`` + Content of ``...`` converted to upper case. +``$<MAKE_C_IDENTIFIER:...>`` + Content of ``...`` converted to a C identifier. diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index 93fbf77..b72c7ef 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -81,4 +81,5 @@ The following extra generators are known to CMake. /generator/CodeBlocks /generator/Eclipse CDT4 /generator/KDevelop3 + /generator/Kate /generator/Sublime Text 2 diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index e954a86..9e26392 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -21,7 +21,21 @@ for a policy, also avoiding the warning. The :command:`cmake_minimum_required` command does more than report an error if a too-old version of CMake is used to build a project. It also sets all policies introduced in that CMake version or earlier to -NEW behavior. +NEW behavior. To manage policies without increasing the minimum required +CMake version, the :command:`if(POLICY)` command may be used:: + + if(POLICY CMP0990) + cmake_policy(SET CMP0990 NEW) + endif() + +This has the effect of using the NEW behavior with newer CMake releases which +users may be using and not issuing a compatibility warning. + +The setting of a policy is confined in some cases to not propagate to the +parent scope. For example, if the files read by the :command:`include` command +or the :command:`find_package` command contain a use of :command:`cmake_policy`, +that policy setting will not affect the caller by default. Both commands accept +an optional ``NO_POLICY_SCOPE`` keyword to control this behavior. The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used to determine whether to report an error on use of deprecated macros or @@ -74,3 +88,4 @@ All Policies /policy/CMP0038 /policy/CMP0039 /policy/CMP0040 + /policy/CMP0041 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 2097062..d569e31 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -141,6 +141,7 @@ Properties on Targets /prop_tgt/INSTALL_NAME_DIR /prop_tgt/INSTALL_RPATH /prop_tgt/INSTALL_RPATH_USE_LINK_PATH + /prop_tgt/INTERFACE_AUTOUIC_OPTIONS /prop_tgt/INTERFACE_COMPILE_DEFINITIONS /prop_tgt/INTERFACE_COMPILE_OPTIONS /prop_tgt/INTERFACE_INCLUDE_DIRECTORIES diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst new file mode 100644 index 0000000..fbe546e --- /dev/null +++ b/Help/manual/cmake-toolchains.7.rst @@ -0,0 +1,160 @@ +.. cmake-manual-description: CMake Toolchains Reference + +cmake-toolchains(7) +******************* + +.. only:: html or latex + + .. contents:: + +Introduction +============ + +CMake uses a toolchain of utilities to compile, link libraries and create +archives, and other tasks to drive the build. The toolchain utilities available +are determined by the languages enabled. In normal builds, CMake automatically +determines the toolchain for host builds based on system introspection and +defaults. In cross-compiling scenarios, a toolchain file may be specified +with information about compiler and utility paths. + +Languages +========= + +Languages are enabled by the :command:`project` command. If no project command +is in the top-level CMakeLists file, one will be implicitly generated. By default +the enabled languages are C and CXX:: + + project(C_Only C) + +A special value of NONE can also be used with the :command:`project` command +to enable no languages:: + + project(MyProject NONE) + +The :command:`enable_language` command can be used to enable languages after the +:command:`project` command:: + + enable_language(CXX) + +When a language is enabled, CMake finds a compiler for that language, and +determines some information, such as the vendor and version of the compiler, +the target architecture and bitwidth, the location of corresponding utilities +etc. + +The :prop_gbl:`ENABLED_LANGUAGES` global property contains the languages which +are currently enabled. + +Variables and Properties +======================== + +Several variables relate to the language components of a toolchain which are +enabled. :variable:`CMAKE_<LANG>_COMPILER` is the full path to the compiler used +for ``<LANG>``. :variable:`CMAKE_<LANG>_COMPILER_ID` is the identifier used +by CMake for the compiler and :variable:`CMAKE_<LANG>_COMPILER_VERSION` is the +version of the compiler. + +The :variable:`CMAKE_<LANG>_FLAGS` variables and the configuration-specific +equivalents contain flags that will be added to the compile command when +compiling a file of a particular language. + +As the linker is invoked by the compiler driver, CMake needs a way to determine +which compiler to use to invoke the linker. This is calculated by the +:prop_sf:`LANGUAGE` of source files in the target, and in the case of static +libraries, the language of the dependent libraries. The choice CMake makes may +be overridden with the :prop_tgt:`LINKER_LANGUAGE` target property. + +Toolchain Features +================== + +CMake provides the :command:`try_compile` command and wrapper macros such as +:module:`CheckCXXSourceCompiles`, :module:`CheckCXXSymbolExists` and +:module:`CheckIncludeFile` to test capability and availability of various +toolchain features. These APIs test the toolchain in some way and cache the +result so that the test does not have to be performed again the next time +CMake runs. + +Some toolchain features have built-in handling in CMake, and do not require +compile-tests. For example, :prop_tgt:`POSITION_INDEPENDENT_CODE` allows +specifying that a target should be built as position-independent code, if +the compiler supports that feature. The :prop_tgt:`<LANG>_VISIBILITY_PRESET` +and :prop_tgt:`VISIBILITY_INLINES_HIDDEN` target properties add flags for +hidden visibility, if supported by the compiler. + +Cross Compiling +=============== + +If :manual:`cmake(1)` is invoked with the command line parameter +``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the file will be loaded early to set +values for the compilers. A typical cross-compiling toolchain has content such +as:: + + set(CMAKE_SYSTEM_NAME Linux) + + set(CMAKE_SYSROOT /home/devel/rasp-pi-rootfs) + set(CMAKE_STAGING_PREFIX /home/devel/stage) + + set(CMAKE_C_COMPILER /home/devel/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc) + set(CMAKE_CXX_COMPILER /home/devel/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g++) + + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +The :variable:`CMAKE_SYSTEM_NAME` is the CMake-identifier of the target platform +to build for. + +The :variable:`CMAKE_SYSROOT` is optional, and may be specified if a sysroot +is available. + +The :variable:`CMAKE_STAGING_PREFIX` is also optional. It may be used to specify +a path on the host to install to. The :variable:`CMAKE_INSTALL_PREFIX` is always +the runtime installation location, even when cross-compiling. + +The :variable:`CMAKE_<LANG>_COMPILER` variables may be set to full paths, or to +names of compilers to search for in standard locations. In cases where CMake does +not have enough information to extract information from the compiler, the +:module:`CMakeForceCompiler` module can be used to bypass some of the checks. + +CMake ``find_*`` commands will look in the sysroot, and the :variable:`CMAKE_FIND_ROOT_PATH` +entries by default in all cases, as well as looking in the host system root prefix. +Although this can be controlled on a case-by-case basis, when cross-compiling, it +can be useful to exclude looking in either the host or the target for particular +artifacts. Generally, includes, libraries and packages should be found in the +target system prefixes, whereas executables which must be run as part of the build +should be found only on the host and not on the target. This is the purpose of +the ``CMAKE_FIND_ROOT_PATH_MODE_*`` variables. + +Some compilers are inherently cross compilers, such as Clang and the QNX QCC +compiler. The :variable:`CMAKE_<LANG>_COMPILER_TARGET` can be set to pass a +value to those supported compilers when compiling:: + + set(CMAKE_SYSTEM_NAME Linux) + + set(triple arm-linux-gnueabihf) + + set(CMAKE_C_COMPILER clang) + set(CMAKE_C_COMPILER_TARGET ${triple}) + set(CMAKE_CXX_COMPILER clang++) + set(CMAKE_CXX_COMPILER_TARGET ${triple}) + +Or, for QCC:: + + set(CMAKE_SYSTEM_NAME QNX) + + set(arch gcc_ntoarmv7le) + + set(CMAKE_C_COMPILER qcc) + set(CMAKE_C_COMPILER_TARGET ${arch}) + set(CMAKE_CXX_COMPILER QCC) + set(CMAKE_CXX_COMPILER_TARGET ${arch}) + + +Similarly, some compilers do not ship their own supplementary utilities +such as linkers, but provide a way to specify the location of the external +toolchain which will be used by the compiler driver. The +:variable:`CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN` variable can be set in a +toolchain file to pass the path to the compiler driver. + +The :variable:`CMAKE_CROSSCOMPILING` variable is set to true when CMake is +cross-compiling. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 4e24823..d86db37 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -64,10 +64,14 @@ Variables that Provide Information /variable/CMAKE_STANDARD_LIBRARIES /variable/CMAKE_STATIC_LIBRARY_PREFIX /variable/CMAKE_STATIC_LIBRARY_SUFFIX + /variable/CMAKE_TOOLCHAIN_FILE /variable/CMAKE_TWEAK_VERSION /variable/CMAKE_VERBOSE_MAKEFILE /variable/CMAKE_VERSION + /variable/CMAKE_VS_DEVENV_COMMAND /variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION + /variable/CMAKE_VS_MSBUILD_COMMAND + /variable/CMAKE_VS_MSDEV_COMMAND /variable/CMAKE_VS_PLATFORM_TOOLSET /variable/CMAKE_XCODE_PLATFORM_TOOLSET /variable/PROJECT_BINARY_DIR @@ -96,8 +100,13 @@ Variables that Change Behavior /variable/CMAKE_SYSROOT /variable/CMAKE_FIND_LIBRARY_PREFIXES /variable/CMAKE_FIND_LIBRARY_SUFFIXES - /variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE /variable/CMAKE_FIND_NO_INSTALL_PREFIX + /variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE + /variable/CMAKE_FIND_ROOT_PATH + /variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + /variable/CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + /variable/CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + /variable/CMAKE_FIND_ROOT_PATH_MODE_PROGRAM /variable/CMAKE_IGNORE_PATH /variable/CMAKE_INCLUDE_PATH /variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE @@ -204,6 +213,7 @@ Variables that Control the Build /variable/CMAKE_NO_BUILTIN_CHRPATH /variable/CMAKE_NO_SYSTEM_FROM_IMPORTED /variable/CMAKE_PDB_OUTPUT_DIRECTORY + /variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_POSITION_INDEPENDENT_CODE /variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY /variable/CMAKE_SHARED_LINKER_FLAGS_CONFIG diff --git a/Help/policy/CMP0024.rst b/Help/policy/CMP0024.rst index 4c8c714..abfcc75 100644 --- a/Help/policy/CMP0024.rst +++ b/Help/policy/CMP0024.rst @@ -11,7 +11,7 @@ until later at generate-time, such as the link language and complete list of link libraries. Future refactoring will change the effect of the export() command to be executed at generate-time. Use ALIAS targets instead in cases where the goal is to refer to targets by -another name +another name. The OLD behavior for this policy is to allow including the result of an export() command. The NEW behavior for this policy is to not to diff --git a/Help/policy/CMP0037.rst b/Help/policy/CMP0037.rst index 059b2e6..f4d2f4e 100644 --- a/Help/policy/CMP0037.rst +++ b/Help/policy/CMP0037.rst @@ -11,7 +11,7 @@ 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. +targets and IMPORTED targets may contain two consequtive colons. Target names reserved by one or more CMake generators are not allowed. Among others these include "all", "help" and "test". diff --git a/Help/policy/CMP0041.rst b/Help/policy/CMP0041.rst new file mode 100644 index 0000000..acb85af --- /dev/null +++ b/Help/policy/CMP0041.rst @@ -0,0 +1,25 @@ +CMP0041 +------- + +Error on relative include with generator expression. + +Diagnostics in CMake 2.8.12 and lower silently ignored an entry in the +:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of a target if it contained a generator +expression at any position. + +The path entries in that target property should not be relative. High-level +API should ensure that by adding either a source directory or a install +directory prefix, as appropriate. + +As an additional diagnostic, the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` generated +on an :prop_tgt:`IMPORTED` target for the install location should not contain +paths in the source directory or the build directory. + +The OLD behavior for this policy is to ignore relative path entries if they +contain a generator expression. The NEW behavior for this policy is to report +an error if a generator expression appears in another location and the path is +relative. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/prop_tgt/AUTOUIC_OPTIONS.rst b/Help/prop_tgt/AUTOUIC_OPTIONS.rst index c6cf885..aeec38b 100644 --- a/Help/prop_tgt/AUTOUIC_OPTIONS.rst +++ b/Help/prop_tgt/AUTOUIC_OPTIONS.rst @@ -15,3 +15,7 @@ This property is initialized by the value of the variable The options set on the target may be overridden by :prop_sf:`AUTOUIC_OPTIONS` set on the .ui source file. + +This property may use "generator expressions" with the syntax "$<...>". +See the :manual:`cmake-generator-expressions(7)` manual for available +expressions. diff --git a/Help/prop_tgt/INTERFACE_AUTOUIC_OPTIONS.rst b/Help/prop_tgt/INTERFACE_AUTOUIC_OPTIONS.rst new file mode 100644 index 0000000..e97d293 --- /dev/null +++ b/Help/prop_tgt/INTERFACE_AUTOUIC_OPTIONS.rst @@ -0,0 +1,14 @@ +INTERFACE_AUTOUIC_OPTIONS +------------------------- + +List of interface options to pass to uic. + +Targets may populate this property to publish the options +required to use when invoking ``uic``. Consuming targets can add entries to their +own :prop_tgt:`AUTOUIC_OPTIONS` property such as +``$<TARGET_PROPERTY:foo,INTERFACE_AUTOUIC_OPTIONS>`` to use the uic options +specified in the interface of ``foo``. This is done automatically by +the :command:`target_link_libraries` command. + +This property supports generator expressions. See the +:manual:`cmake-generator-expressions(7)` manual for available expressions. diff --git a/Help/prop_tgt/PDB_NAME.rst b/Help/prop_tgt/PDB_NAME.rst index fe059e0..e8fc3be 100644 --- a/Help/prop_tgt/PDB_NAME.rst +++ b/Help/prop_tgt/PDB_NAME.rst @@ -1,10 +1,13 @@ PDB_NAME -------- -Output name for MS debug symbols .pdb file from linker. +Output name for the MS debug symbol ``.pdb`` file generated by the +linker for an executable or shared library target. -Set the base name for debug symbols file created for an executable or -shared library target. If not set, the logical target name is used by -default. +This property specifies the base name for the debug symbols file. +If not set, the logical target name is used by default. -This property is not implemented by the Visual Studio 6 generator. +.. include:: PDB_NOTE.txt + +This property is not implemented by the :generator:`Visual Studio 6` +generator. diff --git a/Help/prop_tgt/PDB_NAME_CONFIG.rst b/Help/prop_tgt/PDB_NAME_CONFIG.rst index 50c3aa2..c846b57 100644 --- a/Help/prop_tgt/PDB_NAME_CONFIG.rst +++ b/Help/prop_tgt/PDB_NAME_CONFIG.rst @@ -1,8 +1,10 @@ PDB_NAME_<CONFIG> ----------------- -Per-configuration name for MS debug symbols .pdb file. +Per-configuration output name for the MS debug symbol ``.pdb`` file +generated by the linker for an executable or shared library target. -This is the configuration-specific version of PDB_NAME. +This is the configuration-specific version of :prop_tgt:`PDB_NAME`. -This property is not implemented by the Visual Studio 6 generator. +This property is not implemented by the :generator:`Visual Studio 6` +generator. diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt new file mode 100644 index 0000000..e55aba2 --- /dev/null +++ b/Help/prop_tgt/PDB_NOTE.txt @@ -0,0 +1,8 @@ +.. note:: + This property does not apply to STATIC library targets because no linker + is invoked to produce them so they have no linker-generated ``.pdb`` file + containing debug symbols. + + The compiler-generated program database files specified by the MSVC + ``/Fd`` flag are not the same as linker-generated program database + files and so are not influenced by this property. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst index d973e90d..9a863a1 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst @@ -1,11 +1,15 @@ PDB_OUTPUT_DIRECTORY -------------------- -Output directory for MS debug symbols .pdb file from linker. +Output directory for the MS debug symbols ``.pdb`` file +generated by the linker for an executable or shared library target. This property specifies the directory into which the MS debug symbols will be placed by the linker. This property is initialized by the -value of the variable CMAKE_PDB_OUTPUT_DIRECTORY if it is set when a -target is created. +value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is +set when a target is created. -This property is not implemented by the Visual Studio 6 generator. +.. include:: PDB_NOTE.txt + +This property is not implemented by the :generator:`Visual Studio 6` +generator. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst index 25ab944..caec2de 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -1,13 +1,15 @@ PDB_OUTPUT_DIRECTORY_<CONFIG> ----------------------------- -Per-configuration output directory for MS debug symbols .pdb files. +Per-configuration output directory for the MS debug symbol ``.pdb`` file +generated by the linker for an executable or shared library target. -This is a per-configuration version of PDB_OUTPUT_DIRECTORY, but -multi-configuration generators (VS, Xcode) do NOT append a +This is a per-configuration version of :prop_tgt:`PDB_OUTPUT_DIRECTORY`, +but multi-configuration generators (VS, Xcode) do NOT append a per-configuration subdirectory to the specified directory. This -property is initialized by the value of the variable -CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG> if it is set when a target is -created. +property is initialized by the value of the +:variable:`CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable if it is +set when a target is created. -This property is not implemented by the Visual Studio 6 generator. +This property is not implemented by the :generator:`Visual Studio 6` +generator. diff --git a/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst b/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst index 3754410..e06d35c 100644 --- a/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst +++ b/Help/prop_tgt/VISIBILITY_INLINES_HIDDEN.rst @@ -4,8 +4,8 @@ VISIBILITY_INLINES_HIDDEN Whether to add a compile flag to hide symbols of inline functions The VISIBILITY_INLINES_HIDDEN property determines whether a flag for -hiding symbols for inline functions. the value passed used in a -visibility related compile option, such as -fvisibility=. This -property only has an affect for libraries and executables with -exports. This property is initialized by the value of the variable -CMAKE_VISIBILITY_INLINES_HIDDEN if it is set when a target is created. +hiding symbols for inline functions, such as -fvisibility-inlines-hidden, +should be used when invoking the compiler. This property only has an affect +for libraries and executables with exports. This property is initialized by +the value of the :variable:`CMAKE_VISIBILITY_INLINES_HIDDEN` if it is set +when a target is created. diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index 2ded823..11aed0c 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -5,7 +5,9 @@ Enables tracing output for target properties. This variable can be populated with a list of properties to generate debug output for when evaluating target properties. Currently it can -only be used when evaluating the INCLUDE_DIRECTORIES, -COMPILE_DEFINITIONS and COMPILE_OPTIONS target properties. In that -case, it outputs a backtrace for each entry in the target property. +only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`, +:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`, +:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property +listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_`` +properties. It outputs an origin for each entry in the target property. Default is unset. diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH.rst b/Help/variable/CMAKE_FIND_ROOT_PATH.rst new file mode 100644 index 0000000..67948f7 --- /dev/null +++ b/Help/variable/CMAKE_FIND_ROOT_PATH.rst @@ -0,0 +1,8 @@ +CMAKE_FIND_ROOT_PATH +-------------------- + +List of root paths to search on the filesystem. + +This variable is most useful when cross-compiling. CMake uses the paths in +this list as alternative roots to find filesystem items with :command:`find_package`, +:command:`find_library` etc. diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE.rst b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE.rst new file mode 100644 index 0000000..df1af5a --- /dev/null +++ b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE.rst @@ -0,0 +1,6 @@ +CMAKE_FIND_ROOT_PATH_MODE_INCLUDE +--------------------------------- + +.. |FIND_XXX| replace:: :command:`find_file` and :command:`find_path` + +.. include:: CMAKE_FIND_ROOT_PATH_MODE_XXX.txt diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_LIBRARY.rst b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_LIBRARY.rst new file mode 100644 index 0000000..52ab89d --- /dev/null +++ b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_LIBRARY.rst @@ -0,0 +1,6 @@ +CMAKE_FIND_ROOT_PATH_MODE_LIBRARY +--------------------------------- + +.. |FIND_XXX| replace:: :command:`find_library` + +.. include:: CMAKE_FIND_ROOT_PATH_MODE_XXX.txt diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_PACKAGE.rst b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_PACKAGE.rst new file mode 100644 index 0000000..3872947 --- /dev/null +++ b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_PACKAGE.rst @@ -0,0 +1,6 @@ +CMAKE_FIND_ROOT_PATH_MODE_PACKAGE +--------------------------------- + +.. |FIND_XXX| replace:: :command:`find_package` + +.. include:: CMAKE_FIND_ROOT_PATH_MODE_XXX.txt diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_PROGRAM.rst b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_PROGRAM.rst new file mode 100644 index 0000000..d24a78a --- /dev/null +++ b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_PROGRAM.rst @@ -0,0 +1,6 @@ +CMAKE_FIND_ROOT_PATH_MODE_PROGRAM +--------------------------------- + +.. |FIND_XXX| replace:: :command:`find_program` + +.. include:: CMAKE_FIND_ROOT_PATH_MODE_XXX.txt diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt new file mode 100644 index 0000000..ab65e09 --- /dev/null +++ b/Help/variable/CMAKE_FIND_ROOT_PATH_MODE_XXX.txt @@ -0,0 +1,8 @@ +This variable controls whether the :variable:`CMAKE_FIND_ROOT_PATH` and +:variable:`CMAKE_SYSROOT` are used by |FIND_XXX|. + +If set to ``ONLY``, then only the roots in :variable:`CMAKE_FIND_ROOT_PATH` +will be searched. If set to ``NEVER``, then the roots in +:variable:`CMAKE_FIND_ROOT_PATH` will be ignored and only the host system +root will be used. If set to ``BOTH``, then the host system paths and the +paths in :variable:`CMAKE_FIND_ROOT_PATH` will be searched. diff --git a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst index 86c0b0e..033998d 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst @@ -10,4 +10,4 @@ may be set to a path to a path to the external toolchain and will be passed to the compiler driver if supported. This variable may only be set in a toolchain file specified by -the ``CMAKE_TOOLCHAIN_FILE`` variable. +the :variable:`CMAKE_TOOLCHAIN_FILE` variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst b/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst index 7c8efee..656c57d 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst @@ -8,4 +8,4 @@ QNX qcc. These compiler drivers support a command-line argument to specify the target to cross-compile for. This variable may only be set in a toolchain file specified by -the ``CMAKE_TOOLCHAIN_FILE`` variable. +the :variable:`CMAKE_TOOLCHAIN_FILE` variable. diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst index 0c851ad..97caa8a 100644 --- a/Help/variable/CMAKE_MAKE_PROGRAM.rst +++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst @@ -29,6 +29,10 @@ to configure the project: * The Visual Studio generators set this to the full path to ``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9), ``VCExpress.exe`` (VS Express 8,9), or ``msdev.exe`` (VS 6). + (See also variables + :variable:`CMAKE_VS_MSBUILD_COMMAND`, + :variable:`CMAKE_VS_DEVENV_COMMAND`, and + :variable:`CMAKE_VS_MSDEV_COMMAND`.) These generators prefer to lookup the build tool at build time rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache diff --git a/Help/variable/CMAKE_PDB_OUTPUT_DIRECTORY.rst b/Help/variable/CMAKE_PDB_OUTPUT_DIRECTORY.rst index 938d159..763bcb3 100644 --- a/Help/variable/CMAKE_PDB_OUTPUT_DIRECTORY.rst +++ b/Help/variable/CMAKE_PDB_OUTPUT_DIRECTORY.rst @@ -1,8 +1,9 @@ CMAKE_PDB_OUTPUT_DIRECTORY -------------------------- -Where to put all the MS debug symbol files from linker. +Output directory for MS debug symbol ``.pdb`` files generated by the +linker for executable and shared library targets. -This variable is used to initialize the PDB_OUTPUT_DIRECTORY property -on all the targets. See that target property for additional +This variable is used to initialize the :prop_tgt:`PDB_OUTPUT_DIRECTORY` +property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG.rst new file mode 100644 index 0000000..4d18eec --- /dev/null +++ b/Help/variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -0,0 +1,11 @@ +CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG> +----------------------------------- + +Per-configuration output directory for MS debug symbol ``.pdb`` files +generated by the linker for executable and shared library targets. + +This is a per-configuration version of :variable:`CMAKE_PDB_OUTPUT_DIRECTORY`. +This variable is used to initialize the +:prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>` +property on all the targets. See that target property for additional +information. diff --git a/Help/variable/CMAKE_SYSROOT.rst b/Help/variable/CMAKE_SYSROOT.rst index e42e63a..7aa0450 100644 --- a/Help/variable/CMAKE_SYSROOT.rst +++ b/Help/variable/CMAKE_SYSROOT.rst @@ -9,4 +9,4 @@ necessary on installation. The ``CMAKE_SYSROOT`` is also used to prefix paths searched by the ``find_*`` commands. This variable may only be set in a toolchain file specified by -the ``CMAKE_TOOLCHAIN_FILE`` variable. +the :variable:`CMAKE_TOOLCHAIN_FILE` variable. diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst new file mode 100644 index 0000000..e1a65e1 --- /dev/null +++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst @@ -0,0 +1,9 @@ +CMAKE_TOOLCHAIN_FILE +-------------------- + +Path to toolchain file supplied to :manual:`cmake(1)`. + +This variable is specified on the command line when cross-compiling with CMake. +It is the path to a file which is read early in the CMake run and which specifies +locations for compilers and toolchain utilities, and other target platform and +compiler related information. diff --git a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst index 451ce8c..2420a25 100644 --- a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst +++ b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst @@ -1,8 +1,9 @@ CMAKE_VERBOSE_MAKEFILE ---------------------- -Create verbose makefiles if on. +Enable verbose output from Makefile builds. -This variable defaults to false. You can set this variable to true to -make CMake produce verbose makefiles that show each command line as it -is used. +This variable is a cache entry initialized (to FALSE) by +the :command:`project` command. Users may enable the option +in their local build tree to get more verbose output from +Makefile builds and show each command line as it is launched. diff --git a/Help/variable/CMAKE_VS_DEVENV_COMMAND.rst b/Help/variable/CMAKE_VS_DEVENV_COMMAND.rst new file mode 100644 index 0000000..14cc50a --- /dev/null +++ b/Help/variable/CMAKE_VS_DEVENV_COMMAND.rst @@ -0,0 +1,14 @@ +CMAKE_VS_DEVENV_COMMAND +----------------------- + +The generators for :generator:`Visual Studio 7` and above set this +variable to the ``devenv.com`` command installed with the corresponding +Visual Studio version. Note that this variable may be empty on +Visual Studio Express editions because they do not provide this tool. + +This variable is not defined by other generators even if ``devenv.com`` +is installed on the computer. + +The :variable:`CMAKE_VS_MSBUILD_COMMAND` is also provided for +:generator:`Visual Studio 10 2010` and above. +See also the :variable:`CMAKE_MAKE_PROGRAM` variable. diff --git a/Help/variable/CMAKE_VS_MSBUILD_COMMAND.rst b/Help/variable/CMAKE_VS_MSBUILD_COMMAND.rst new file mode 100644 index 0000000..58f2bef --- /dev/null +++ b/Help/variable/CMAKE_VS_MSBUILD_COMMAND.rst @@ -0,0 +1,13 @@ +CMAKE_VS_MSBUILD_COMMAND +------------------------ + +The generators for :generator:`Visual Studio 10 2010` and above set this +variable to the ``MSBuild.exe`` command installed with the corresponding +Visual Studio version. + +This variable is not defined by other generators even if ``MSBuild.exe`` +is installed on the computer. + +The :variable:`CMAKE_VS_DEVENV_COMMAND` is also provided for the +non-Express editions of Visual Studio. +See also the :variable:`CMAKE_MAKE_PROGRAM` variable. diff --git a/Help/variable/CMAKE_VS_MSDEV_COMMAND.rst b/Help/variable/CMAKE_VS_MSDEV_COMMAND.rst new file mode 100644 index 0000000..718baaf --- /dev/null +++ b/Help/variable/CMAKE_VS_MSDEV_COMMAND.rst @@ -0,0 +1,10 @@ +CMAKE_VS_MSDEV_COMMAND +---------------------- + +The :generator:`Visual Studio 6` generator sets this variable to the +``msdev.exe`` command installed with Visual Studio 6. + +This variable is not defined by other generators even if ``msdev.exe`` +is installed on the computer. + +See also the :variable:`CMAKE_MAKE_PROGRAM` variable. diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 0f5b694..e0cce45 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -119,16 +119,16 @@ if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the compiler during debug builds.") set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the compiler during release minsize builds.") + "Flags used by the compiler during release builds for minimum size.") set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + "Flags used by the compiler during release builds.") set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") + "Flags used by the compiler during release builds with debug info.") endif() if(CMAKE_C_STANDARD_LIBRARIES_INIT) set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT}" - CACHE STRING "Libraries linked by defalut with all C applications.") + CACHE STRING "Libraries linked by default with all C applications.") mark_as_advanced(CMAKE_C_STANDARD_LIBRARIES) endif() diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 9cf3489..3010a48 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -209,17 +209,17 @@ if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the compiler during debug builds.") set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the compiler during release minsize builds.") + "Flags used by the compiler during release builds for minimum size.") set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + "Flags used by the compiler during release builds.") set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") + "Flags used by the compiler during release builds with debug info.") endif() if(CMAKE_CXX_STANDARD_LIBRARIES_INIT) set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES_INIT}" - CACHE STRING "Libraries linked by defalut with all C++ applications.") + CACHE STRING "Libraries linked by default with all C++ applications.") mark_as_advanced(CMAKE_CXX_STANDARD_LIBRARIES) endif() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index efb06c0..2bcf3d1 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -154,24 +154,33 @@ Id flags: ${testflags} else() set(id_subsystem 1) endif() - if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]") - set(build /p:Configuration=Debug /p:Platform=@id_platform@ /p:VisualStudioVersion=${vs_version}.0) - elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]") - set(build /make) - else() - set(build /build Debug) - endif() set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) get_filename_component(id_src "${src}" NAME) configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in ${id_dir}/CompilerId${lang}.${ext} @ONLY) - execute_process( - COMMAND ${CMAKE_MAKE_PROGRAM} CompilerId${lang}.${ext} ${build} - WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} - OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT - ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT - RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT - ) + if(CMAKE_VS_MSBUILD_COMMAND AND NOT lang STREQUAL "Fortran") + set(command "${CMAKE_VS_MSBUILD_COMMAND}" "CompilerId${lang}.${ext}" + "/p:Configuration=Debug" "/p:Platform=${id_platform}" "/p:VisualStudioVersion=${vs_version}.0" + ) + elseif(CMAKE_VS_DEVENV_COMMAND) + set(command "${CMAKE_VS_DEVENV_COMMAND}" "CompilerId${lang}.${ext}" "/build" "Debug") + elseif(CMAKE_VS_MSDEV_COMMAND) + set(command "${CMAKE_VS_MSDEV_COMMAND}" "CompilerId${lang}.${ext}" "/make") + else() + set(command "") + endif() + if(command) + execute_process( + COMMAND ${command} + WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} + OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT + ) + else() + set(CMAKE_${lang}_COMPILER_ID_RESULT 1) + set(CMAKE_${lang}_COMPILER_ID_OUTPUT "VS environment not known to support ${lang}") + endif() # Match the compiler location line printed out. if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CMAKE_${lang}_COMPILER=([^%\r\n]+)[\r\n]") # Strip VS diagnostic output from the end of the line. @@ -223,7 +232,7 @@ Id flags: ${testflags} # ... # /path/to/cc ...CompilerId${lang}/... # to extract the compiler front-end for the language. - if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/\\./CompilerId${lang}[ \t\n\\\"]") + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/(\\./)?CompilerId${lang}[ \t\n\\\"]") set(_comp "${CMAKE_MATCH_2}") if(EXISTS "${_comp}") set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) diff --git a/Modules/CMakeFindKate.cmake b/Modules/CMakeFindKate.cmake new file mode 100644 index 0000000..4dcdb28 --- /dev/null +++ b/Modules/CMakeFindKate.cmake @@ -0,0 +1,31 @@ + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This file is included in CMakeSystemSpecificInformation.cmake if +# the Eclipse CDT4 extra generator has been selected. + + +# Try to find out how many CPUs we have and set the -j argument for make accordingly + +include(ProcessorCount) +processorcount(_CMAKE_KATE_PROCESSOR_COUNT) + +# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name +# (we may also get here in the future e.g. for ninja) +if("${_CMAKE_KATE_PROCESSOR_COUNT}" GREATER 1 AND CMAKE_HOST_UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) + set(_CMAKE_KATE_INITIAL_MAKE_ARGS "-j${_CMAKE_KATE_PROCESSOR_COUNT}") +endif() + +# This variable is used by the Eclipse generator and appended to the make invocation commands. +set(CMAKE_KATE_MAKE_ARGUMENTS "${_CMAKE_KATE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Kate invokes make. Enter e.g. -j<some_number> to get parallel builds") diff --git a/Modules/CMakeFortranCompilerABI.F b/Modules/CMakeFortranCompilerABI.F index 7e24553..21ca7ff 100644 --- a/Modules/CMakeFortranCompilerABI.F +++ b/Modules/CMakeFortranCompilerABI.F @@ -20,6 +20,10 @@ PRINT *, 'INFO:sizeof_dptr[8]' #elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4 PRINT *, 'INFO:sizeof_dptr[4]' +#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ == 8 + PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ == 4 + PRINT *, 'INFO:sizeof_dptr[4]' #endif #if 0 diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index debfd46..080dc68 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -218,7 +218,7 @@ endif() if(CMAKE_Fortran_STANDARD_LIBRARIES_INIT) set(CMAKE_Fortran_STANDARD_LIBRARIES "${CMAKE_Fortran_STANDARD_LIBRARIES_INIT}" - CACHE STRING "Libraries linked by defalut with all Fortran applications.") + CACHE STRING "Libraries linked by default with all Fortran applications.") mark_as_advanced(CMAKE_Fortran_STANDARD_LIBRARIES) endif() @@ -226,11 +226,11 @@ if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the compiler during debug builds.") set (CMAKE_Fortran_FLAGS_MINSIZEREL "${CMAKE_Fortran_FLAGS_MINSIZEREL_INIT}" CACHE STRING - "Flags used by the compiler during release minsize builds.") + "Flags used by the compiler during release builds for minimum size.") set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE_INIT}" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + "Flags used by the compiler during release builds.") set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") + "Flags used by the compiler during release builds with debug info.") endif() diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 3f0978d..d9e0ba7 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -63,6 +63,14 @@ # # If set, this icon is used in place of the default icon. # +# .. variable:: CPACK_WIX_UI_REF +# +# This variable allows you to override the Id of the ``<UIRef>`` element +# in the WiX template. +# +# The default is ``WixUI_InstallDir`` in case no CPack components have +# been defined and ``WixUI_FeatureTree`` otherwise. +# # .. variable:: CPACK_WIX_UI_BANNER # # The bitmap will appear at the top of all installer pages other than the @@ -108,6 +116,57 @@ # If this variable is not set, the default MSI template included with CMake # will be used. # +# .. variable:: CPACK_WIX_PATCH_FILE +# +# Optional XML file with fragments to be inserted into generated WiX sources +# +# This optional variable can be used to specify an XML file that the +# WiX generator will use to inject fragments into its generated +# source files. +# +# Patch files understood by the CPack WiX generator +# roughly follow this RELAX NG compact schema: +# +# .. code-block:: none +# +# start = CPackWiXPatch +# +# CPackWiXPatch = element CPackWiXPatch { CPackWiXFragment* } +# +# CPackWiXFragment = element CPackWiXFragment +# { +# attribute Id { string }, +# fragmentContent* +# } +# +# fragmentContent = element * - CPackWiXFragment +# { +# (attribute * { text } | text | fragmentContent)* +# } +# +# Currently fragments can be injected into most +# Component, File and Directory elements. +# +# The following example illustrates how this works. +# +# Given that the WiX generator creates the following XML element: +# +# .. code-block:: xml +# +# <Component Id="CM_CP_applications.bin.my_libapp.exe" Guid="*"/> +# +# The following XML patch file may be used to inject an Environment element +# into it: +# +# .. code-block:: xml +# +# <CPackWiXPatch> +# <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe"> +# <Environment Id="MyEnvironment" Action="set" +# Name="MyVariableName" Value="MyVariableValue"/> +# </CPackWiXFragment> +# </CPackWiXPatch> +# # .. variable:: CPACK_WIX_EXTRA_SOURCES # # Extra WiX source files diff --git a/Modules/CTestUseLaunchers.cmake b/Modules/CTestUseLaunchers.cmake index 2fab247..c79119f 100644 --- a/Modules/CTestUseLaunchers.cmake +++ b/Modules/CTestUseLaunchers.cmake @@ -46,9 +46,31 @@ if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja") endif() if(CTEST_USE_LAUNCHERS) - set(CTEST_LAUNCH_COMPILE "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <OBJECT> --source <SOURCE> --language <LANGUAGE> --") - set(CTEST_LAUNCH_LINK "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <TARGET> --target-type <TARGET_TYPE> --language <LANGUAGE> --") - set(CTEST_LAUNCH_CUSTOM "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <OUTPUT> --") + set(__launch_common_options + "--target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR>") + + set(__launch_compile_options + "${__launch_common_options} --output <OBJECT> --source <SOURCE> --language <LANGUAGE>") + + set(__launch_link_options + "${__launch_common_options} --output <TARGET> --target-type <TARGET_TYPE> --language <LANGUAGE>") + + set(__launch_custom_options + "${__launch_common_options} --output <OUTPUT>") + + if("${CMAKE_GENERATOR}" MATCHES "Ninja") + set(__launch_compile_options "${__launch_compile_options} --filter-prefix <CMAKE_CL_SHOWINCLUDES_PREFIX>") + endif() + + set(CTEST_LAUNCH_COMPILE + "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_compile_options} --") + + set(CTEST_LAUNCH_LINK + "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_link_options} --") + + set(CTEST_LAUNCH_CUSTOM + "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_custom_options} --") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CTEST_LAUNCH_COMPILE}") set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CTEST_LAUNCH_LINK}") set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "${CTEST_LAUNCH_CUSTOM}") diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake index 56e739e..83789cc 100644 --- a/Modules/FindBacktrace.cmake +++ b/Modules/FindBacktrace.cmake @@ -58,17 +58,20 @@ endif(Backtrace_HEADER) find_path(Backtrace_INCLUDE_DIR "${_Backtrace_HEADER_TRY}") set(Backtrace_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR}) -# First, check if we already have backtrace(), e.g., in libc -cmake_push_check_state(RESET) -set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS}) -check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND) -cmake_pop_check_state() +if (NOT DEFINED Backtrace_LIBRARY) + # First, check if we already have backtrace(), e.g., in libc + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS}) + check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND) + cmake_pop_check_state() +endif() if(_Backtrace_SYM_FOUND) - set(Backtrace_LIBRARY) - if(NOT Backtrace_FIND_QUIETLY) + # Avoid repeating the message() call below each time CMake is run. + if(NOT Backtrace_FIND_QUIETLY AND NOT DEFINED Backtrace_LIBRARY) message(STATUS "backtrace facility detected in default set of libraries") endif() + set(Backtrace_LIBRARY "" CACHE FILEPATH "Library providing backtrace(3), empty for default set of libraries") else() # Check for external library, for non-glibc systems if(Backtrace_INCLUDE_DIR) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 179dc00..6f03c86 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -65,7 +65,10 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h PATH_SUFFIXES include/freetype2 include ) -find_path(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h +find_path(FREETYPE_INCLUDE_DIR_freetype2 + NAMES + freetype/config/ftheader.h + config/ftheader.h HINTS ENV FREETYPE_DIR PATHS @@ -97,11 +100,18 @@ find_library(FREETYPE_LIBRARY # set the user variables if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}") + list(REMOVE_DUPLICATES FREETYPE_INCLUDE_DIRS) endif() set(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") -if(FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") - file(STRINGS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h" freetype_version_str +if(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") +elseif(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") +endif() + +if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H) + file(STRINGS "${FREETYPE_H}" freetype_version_str REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$") unset(FREETYPE_VERSION_STRING) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 46a0355..28b8454 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -738,6 +738,11 @@ _qt4_find_qmake("${_QT4_QMAKE_NAMES}" QT_QMAKE_EXECUTABLE QTVERSION) if (QT_QMAKE_EXECUTABLE AND QTVERSION) + if (QT_QMAKE_EXECUTABLE_LAST) + string(COMPARE NOTEQUAL "${QT_QMAKE_EXECUTABLE_LAST}" "${QT_QMAKE_EXECUTABLE}" QT_QMAKE_CHANGED) + endif() + set(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE) + _qt4_get_version_components("${QTVERSION}" QT_VERSION_MAJOR QT_VERSION_MINOR QT_VERSION_PATCH) # ask qmake for the mkspecs directory @@ -1198,6 +1203,10 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) "${QT_MKSPECS_DIR}/default" ${QT_INCLUDE_DIR} ) + set_property(TARGET Qt4::QtCore APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS + $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG> + ) set_property(TARGET Qt4::QtCore PROPERTY INTERFACE_QT_MAJOR_VERSION 4 ) diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index 55f4c0d..8bd4048 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -52,8 +52,6 @@ if(SWIG_EXECUTABLE) endif() else() string(REGEX REPLACE "[\n\r]+" ";" SWIG_swiglib_output ${SWIG_swiglib_output}) - # force the path to be computed each time in case SWIG_EXECUTABLE has changed. - set(SWIG_DIR SWIG_DIR-NOTFOUND) find_path(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output} NO_CMAKE_FIND_ROOT_PATH) if(SWIG_DIR) set(SWIG_USE_FILE ${CMAKE_CURRENT_LIST_DIR}/UseSWIG.cmake) diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 2338721..0d13318 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -73,6 +73,8 @@ # License text for the above reference.) find_program(Subversion_SVN_EXECUTABLE svn + PATHS + [HKEY_LOCAL_MACHINE\\Software\\TortoiseSVN;Directory]/bin DOC "subversion command line client") mark_as_advanced(Subversion_SVN_EXECUTABLE) diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index f3ec441..fc3f87e 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -341,7 +341,9 @@ foreach(_path list(APPEND _apps_paths "${_apps}") endif() endforeach() -list(REMOVE_DUPLICATES _apps_paths) +if(_apps_paths) + list(REMOVE_DUPLICATES _apps_paths) +endif() set(CMAKE_SYSTEM_APPBUNDLE_PATH ${_apps_paths}) unset(_apps_paths) diff --git a/Modules/Platform/MirBSD.cmake b/Modules/Platform/MirBSD.cmake new file mode 100644 index 0000000..7637f9b --- /dev/null +++ b/Modules/Platform/MirBSD.cmake @@ -0,0 +1 @@ +include(Platform/OpenBSD) diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index 22ee776..0fe0b32 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -182,6 +182,20 @@ function(ProcessorCount var) endif() endif() + if(NOT count) + # Haiku + find_program(ProcessorCount_cmd_sysinfo sysinfo) + if(ProcessorCount_cmd_sysinfo) + execute_process(COMMAND ${ProcessorCount_cmd_sysinfo} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE sysinfo_X_output) + string(REGEX MATCHALL "\nCPU #[0-9]+:" procs "\n${sysinfo_X_output}") + list(LENGTH procs count) + #message("ProcessorCount: trying sysinfo '${ProcessorCount_cmd_sysinfo}'") + endif() + endif() + # Since cygwin builds of CMake do not define WIN32 anymore, but they still # run on Windows, and will still have this env var defined: # diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index b5f005f..fd9819f 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -120,6 +120,7 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target) string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}") if(moc_target) + set (_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>) set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>") set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>") diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index 2bcbea6..c814187 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -2,16 +2,18 @@ # TestCXXAcceptsFlag # ------------------ # -# Test CXX compiler for a flag +# Deprecated. See :module:`CheckCXXCompilerFlag`. # -# Check if the CXX compiler accepts a flag +# Check if the CXX compiler accepts a flag. # -# :: +# .. code-block:: cmake # -# Macro CHECK_CXX_ACCEPTS_FLAG(FLAGS VARIABLE) - -# checks if the function exists -# FLAGS - the flags to try -# VARIABLE - variable to store the result +# CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>) +# +# ``<flags>`` +# the flags to try +# ``<variable>`` +# variable to store the result #============================================================================= # Copyright 2002-2009 Kitware, Inc. diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 28d5ff0..67cab4a 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -59,12 +59,15 @@ macro(SWIG_MODULE_INITIALIZE name language) set(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}") set(SWIG_MODULE_${name}_REAL_NAME "${name}") + if (CMAKE_SWIG_FLAGS MATCHES "-noproxy") + set (SWIG_MODULE_${name}_NOPROXY TRUE) + endif () if("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "UNKNOWN") message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found") - elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "PYTHON") - # when swig is used without the -interface it will produce in the module.py - # a 'import _modulename' statement, which implies having a corresponding - # _modulename.so (*NIX), _modulename.pyd (Win32). + elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "PYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY) + # swig will produce a module.py containing an 'import _modulename' statement, + # which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32), + # unless the -noproxy flag is used set(SWIG_MODULE_${name}_REAL_NAME "_${name}") elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "PERL") set(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") @@ -200,7 +203,10 @@ macro(SWIG_ADD_MODULE name language) ${swig_generated_sources} ${swig_other_sources}) string(TOLOWER "${language}" swig_lowercase_language) - if ("${swig_lowercase_language}" STREQUAL "java") + if ("${swig_lowercase_language}" STREQUAL "octave") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".oct") + elseif ("${swig_lowercase_language}" STREQUAL "java") if (APPLE) # In java you want: # System.loadLibrary("LIBRARY"); @@ -210,8 +216,7 @@ macro(SWIG_ADD_MODULE name language) # Linux : libLIBRARY.so set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") endif () - endif () - if ("${swig_lowercase_language}" STREQUAL "python") + elseif ("${swig_lowercase_language}" STREQUAL "python") # this is only needed for the python case where a _modulename.so is generated set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") # Python extension modules on Windows must have the extension ".pyd" @@ -225,6 +230,17 @@ macro(SWIG_ADD_MODULE name language) if(WIN32 AND NOT CYGWIN) set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".pyd") endif() + elseif ("${swig_lowercase_language}" STREQUAL "ruby") + # In ruby you want: + # require 'LIBRARY' + # then ruby will look for a library whose name is platform dependent, namely + # MacOS : LIBRARY.bundle + # Windows: LIBRARY.dll + # Linux : LIBRARY.so + set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + if (APPLE) + set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".bundle") + endif () endif () endmacro() diff --git a/Modules/WIX.template.in b/Modules/WIX.template.in index 0bc7e10..59a75c7 100644 --- a/Modules/WIX.template.in +++ b/Modules/WIX.template.in @@ -39,6 +39,6 @@ <FeatureRef Id="ProductFeature"/> - <UIRef Id="WixUI_InstallDir" /> + <UIRef Id="$(var.CPACK_WIX_UI_REF)" /> </Product> </Wix> diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 570b7e2..3c944fb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -188,6 +188,8 @@ set(SRCS cmExtraCodeBlocksGenerator.h cmExtraEclipseCDT4Generator.cxx cmExtraEclipseCDT4Generator.h + cmExtraKateGenerator.cxx + cmExtraKateGenerator.h cmExtraSublimeTextGenerator.cxx cmExtraSublimeTextGenerator.h cmFileTimeComparison.cxx @@ -515,6 +517,7 @@ if(WIN32) CPack/WiX/cmCPackWIXGenerator.cxx CPack/WiX/cmWIXSourceWriter.cxx CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXPatchParser.cxx ) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 43004cc..0ada63d 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 20131127) +set(CMake_VERSION_TWEAK 20131220) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1d7681b..6f1daaa 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -23,6 +23,7 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Directory.hxx> +#include <cmsys/Encoding.hxx> #include <rpc.h> // for GUID generation @@ -198,6 +199,18 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() << std::endl); } + if(GetOption("CPACK_WIX_UI_REF") == 0) + { + std::string defaultRef = "WixUI_InstallDir"; + + if(Components.size()) + { + defaultRef = "WixUI_FeatureTree"; + } + + SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); + } + CollectExtensions("CPACK_WIX_EXTENSIONS", candleExtensions); CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", candleExtensions); @@ -205,6 +218,12 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() CollectExtensions("CPACK_WIX_EXTENSIONS", lightExtensions); CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", lightExtensions); + const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); + if(patchFilePath) + { + LoadPatchFragments(patchFilePath); + } + return true; } @@ -296,6 +315,7 @@ bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() SetOptionIfNotSet("CPACK_WIX_PROGRAM_MENU_FOLDER", GetOption("CPACK_PACKAGE_NAME")); CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER"); + CopyDefinition(includeFile, "CPACK_WIX_UI_REF"); return true; } @@ -401,40 +421,77 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() featureDefinitions.BeginElement("Feature"); featureDefinitions.AddAttribute("Id", "ProductFeature"); - featureDefinitions.AddAttribute("Title", Name); + featureDefinitions.AddAttribute("Display", "expand"); + featureDefinitions.AddAttribute("ConfigurableDirectory", "INSTALL_ROOT"); + + std::string cpackPackageName; + if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) + { + return false; + } + featureDefinitions.AddAttribute("Title", cpackPackageName); + featureDefinitions.AddAttribute("Level", "1"); + + CreateFeatureHierarchy(featureDefinitions); + featureDefinitions.EndElement("Feature"); - featureDefinitions.BeginElement("FeatureRef"); - featureDefinitions.AddAttribute("Id", "ProductFeature"); + bool hasShortcuts = false; - std::vector<std::string> cpackPackageExecutablesList; - const char *cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); - if(cpackPackageExecutables) + shortcut_map_t globalShortcuts; + if(Components.empty()) { - cmSystemTools::ExpandListArgument(cpackPackageExecutables, - cpackPackageExecutablesList); - if(cpackPackageExecutablesList.size() % 2 != 0 ) + AddComponentsToFeature(toplevel, "ProductFeature", + directoryDefinitions, fileDefinitions, featureDefinitions, + globalShortcuts); + if(globalShortcuts.size()) + { + hasShortcuts = true; + } + } + else + { + for(std::map<std::string, cmCPackComponent>::const_iterator + i = Components.begin(); i != Components.end(); ++i) + { + cmCPackComponent const& component = i->second; + + std::string componentPath = toplevel; + componentPath += "/"; + componentPath += component.Name; + + std::string componentFeatureId = "CM_C_" + component.Name; + + shortcut_map_t featureShortcuts; + AddComponentsToFeature(componentPath, componentFeatureId, + directoryDefinitions, fileDefinitions, + featureDefinitions, featureShortcuts); + if(featureShortcuts.size()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and " - "<text label>." << std::endl); - return false; + hasShortcuts = true; } - } - AddDirectoryAndFileDefinitons( - toplevel, "INSTALL_ROOT", - directoryDefinitions, fileDefinitions, featureDefinitions, - cpackPackageExecutablesList); + if(featureShortcuts.size()) + { + if(!CreateStartMenuShortcuts(component.Name, componentFeatureId, + featureShortcuts, fileDefinitions, featureDefinitions)) + { + return false; + } + } + } + } - if(!CreateStartMenuShortcuts( - directoryDefinitions, fileDefinitions, featureDefinitions)) + if(hasShortcuts) { + if(!CreateStartMenuShortcuts(std::string(), "ProductFeature", + globalShortcuts, fileDefinitions, featureDefinitions)) + { return false; + } } - featureDefinitions.EndElement("FeatureRef"); featureDefinitions.EndElement("Fragment"); fileDefinitions.EndElement("Fragment"); @@ -444,6 +501,12 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() } directoryDefinitions.EndElement("Directory"); + + if(hasShortcuts) + { + CreateStartMenuFolder(directoryDefinitions); + } + directoryDefinitions.EndElement("Directory"); directoryDefinitions.EndElement("Fragment"); @@ -472,19 +535,179 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() wixSources.push_back(mainSourceFilePath); + std::string fragmentList; + for(cmWIXPatchParser::fragment_map_t::const_iterator + i = fragments.begin(); i != fragments.end(); ++i) + { + if(!fragmentList.empty()) + { + fragmentList += ", "; + } + + fragmentList += "'"; + fragmentList += i->first; + fragmentList += "'"; + } + + if(fragmentList.size()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Some XML patch fragments did not have matching IDs: " << + fragmentList << std::endl); + return false; + } + return true; } -bool cmCPackWIXGenerator::CreateStartMenuShortcuts( +bool cmCPackWIXGenerator::CreateFeatureHierarchy( + cmWIXSourceWriter& featureDefinitions) +{ + for(std::map<std::string, cmCPackComponentGroup>::const_iterator + i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i) + { + cmCPackComponentGroup const& group = i->second; + if(group.ParentGroup == 0) + { + if(!EmitFeatureForComponentGroup(featureDefinitions, group)) + { + return false; + } + } + } + + for(std::map<std::string, cmCPackComponent>::const_iterator + i = Components.begin(); i != Components.end(); ++i) + { + cmCPackComponent const& component = i->second; + + if(!component.Group) + { + if(!EmitFeatureForComponent(featureDefinitions, component)) + { + return false; + } + } + } + + return true; +} + +bool cmCPackWIXGenerator::EmitFeatureForComponentGroup( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponentGroup const& group) +{ + featureDefinitions.BeginElement("Feature"); + featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name); + + if(group.IsExpandedByDefault) + { + featureDefinitions.AddAttribute("Display", "expand"); + } + + featureDefinitions.AddAttributeUnlessEmpty( + "Title", group.DisplayName); + + featureDefinitions.AddAttributeUnlessEmpty( + "Description", group.Description); + + for(std::vector<cmCPackComponentGroup*>::const_iterator + i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) + { + if(!EmitFeatureForComponentGroup(featureDefinitions, **i)) + { + return false; + } + } + + for(std::vector<cmCPackComponent*>::const_iterator + i = group.Components.begin(); i != group.Components.end(); ++i) + { + if(!EmitFeatureForComponent(featureDefinitions, **i)) + { + return false; + } + } + + featureDefinitions.EndElement("Feature"); + + return true; +} + +bool cmCPackWIXGenerator::EmitFeatureForComponent( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponent const& component) +{ + featureDefinitions.BeginElement("Feature"); + featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name); + + featureDefinitions.AddAttributeUnlessEmpty( + "Title", component.DisplayName); + + featureDefinitions.AddAttributeUnlessEmpty( + "Description", component.Description); + + if(component.IsRequired) + { + featureDefinitions.AddAttribute("Absent", "disallow"); + } + + if(component.IsHidden) + { + featureDefinitions.AddAttribute("Display", "hidden"); + } + + featureDefinitions.EndElement("Feature"); + + return true; +} + +bool cmCPackWIXGenerator::AddComponentsToFeature( + std::string const& rootPath, + std::string const& featureId, cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions) + cmWIXSourceWriter& featureDefinitions, + shortcut_map_t& shortcutMap) { - if(shortcutMap.empty()) + featureDefinitions.BeginElement("FeatureRef"); + featureDefinitions.AddAttribute("Id", featureId); + + std::vector<std::string> cpackPackageExecutablesList; + const char *cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); + if(cpackPackageExecutables) { - return true; + cmSystemTools::ExpandListArgument(cpackPackageExecutables, + cpackPackageExecutablesList); + if(cpackPackageExecutablesList.size() % 2 != 0 ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and " + "<text label>." << std::endl); + return false; + } } + AddDirectoryAndFileDefinitons( + rootPath, "INSTALL_ROOT", + directoryDefinitions, fileDefinitions, featureDefinitions, + cpackPackageExecutablesList, shortcutMap); + + featureDefinitions.EndElement("FeatureRef"); + + return true; +} + +bool cmCPackWIXGenerator::CreateStartMenuShortcuts( + std::string const& cpackComponentName, + std::string const& featureId, + shortcut_map_t& shortcutMap, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions) +{ + featureDefinitions.BeginElement("FeatureRef"); + featureDefinitions.AddAttribute("Id", featureId); + std::string cpackVendor; if(!RequireOption("CPACK_PACKAGE_VENDOR", cpackVendor)) { @@ -497,10 +720,19 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( return false; } + std::string idSuffix; + if(!cpackComponentName.empty()) + { + idSuffix += "_"; + idSuffix += cpackComponentName; + } + + std::string componentId = "CM_SHORTCUT" + idSuffix; + fileDefinitions.BeginElement("DirectoryRef"); fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); fileDefinitions.BeginElement("Component"); - fileDefinitions.AddAttribute("Id", "SHORTCUT"); + fileDefinitions.AddAttribute("Id", componentId); fileDefinitions.AddAttribute("Guid", "*"); for(shortcut_map_t::const_iterator @@ -522,10 +754,13 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.EndElement("Shortcut"); } - CreateUninstallShortcut(cpackPackageName, fileDefinitions); + if(cpackComponentName.empty()) + { + CreateUninstallShortcut(cpackPackageName, fileDefinitions); + } fileDefinitions.BeginElement("RemoveFolder"); - fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER" + idSuffix); fileDefinitions.AddAttribute("On", "uninstall"); fileDefinitions.EndElement("RemoveFolder"); @@ -535,7 +770,15 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.BeginElement("RegistryValue"); fileDefinitions.AddAttribute("Root", "HKCU"); fileDefinitions.AddAttribute("Key", registryKey); - fileDefinitions.AddAttribute("Name", "installed"); + + std::string valueName; + if(!cpackComponentName.empty()) + { + valueName = cpackComponentName + "_"; + } + valueName += "installed"; + + fileDefinitions.AddAttribute("Name", valueName); fileDefinitions.AddAttribute("Type", "integer"); fileDefinitions.AddAttribute("Value", "1"); fileDefinitions.AddAttribute("KeyPath", "yes"); @@ -545,19 +788,10 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.EndElement("DirectoryRef"); featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", "SHORTCUT"); + featureDefinitions.AddAttribute("Id", componentId); featureDefinitions.EndElement("ComponentRef"); - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); - - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); - directoryDefinitions.AddAttribute("Name", startMenuFolder); - directoryDefinitions.EndElement("Directory"); - - directoryDefinitions.EndElement("Directory"); + featureDefinitions.EndElement("FeatureRef"); return true; } @@ -628,7 +862,8 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions, - const std::vector<std::string>& packageExecutables) + const std::vector<std::string>& packageExecutables, + shortcut_map_t& shortcutMap) { cmsys::Directory dir; dir.Load(topdir.c_str()); @@ -662,8 +897,10 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( directoryDefinitions, fileDefinitions, featureDefinitions, - packageExecutables); + packageExecutables, + shortcutMap); + ApplyPatchFragment(subDirectoryId, directoryDefinitions); directoryDefinitions.EndElement("Directory"); } else @@ -683,7 +920,10 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( fileDefinitions.AddAttribute("Source", fullPath); fileDefinitions.AddAttribute("KeyPath", "yes"); + ApplyPatchFragment(fileId, fileDefinitions); fileDefinitions.EndElement("File"); + + ApplyPatchFragment(componentId, fileDefinitions); fileDefinitions.EndElement("Component"); fileDefinitions.EndElement("DirectoryRef"); @@ -747,11 +987,12 @@ std::string cmCPackWIXGenerator::GenerateGUID() UUID guid; UuidCreate(&guid); - unsigned char *tmp = 0; - UuidToString(&guid, &tmp); + unsigned short *tmp = 0; + UuidToStringW(&guid, &tmp); - std::string result(reinterpret_cast<char*>(tmp)); - RpcStringFree(&tmp); + std::string result = + cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(tmp)); + RpcStringFreeW(&tmp); return cmSystemTools::UpperCase(result); } @@ -922,3 +1163,60 @@ void cmCPackWIXGenerator::AddCustomFlags( stream << " " << QuotePath(*i); } } + +void cmCPackWIXGenerator::CreateStartMenuFolder( + cmWIXSourceWriter& directoryDefinitions) +{ + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); + + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); + directoryDefinitions.AddAttribute("Name", startMenuFolder); + directoryDefinitions.EndElement("Directory"); + + directoryDefinitions.EndElement("Directory"); +} + +void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) +{ + cmWIXPatchParser parser(fragments, Logger); + parser.ParseFile(patchFilePath.c_str()); +} + +void cmCPackWIXGenerator::ApplyPatchFragment( + const std::string& id, cmWIXSourceWriter& writer) +{ + cmWIXPatchParser::fragment_map_t::iterator i = fragments.find(id); + if(i == fragments.end()) return; + + const cmWIXPatchElement& fragment = i->second; + for(cmWIXPatchElement::child_list_t::const_iterator + j = fragment.children.begin(); j != fragment.children.end(); ++j) + { + ApplyPatchElement(**j, writer); + } + + fragments.erase(i); +} + +void cmCPackWIXGenerator::ApplyPatchElement( + const cmWIXPatchElement& element, cmWIXSourceWriter& writer) +{ + writer.BeginElement(element.name); + + for(cmWIXPatchElement::attributes_t::const_iterator + i = element.attributes.begin(); i != element.attributes.end(); ++i) + { + writer.AddAttribute(i->first, i->second); + } + + for(cmWIXPatchElement::child_list_t::const_iterator + i = element.children.begin(); i != element.children.end(); ++i) + { + ApplyPatchElement(**i, writer); + } + + writer.EndElement(element.name); +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 481a07d..a0a057c 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -13,6 +13,8 @@ #ifndef cmCPackWIXGenerator_h #define cmCPackWIXGenerator_h +#include "cmWIXPatchParser.h" + #include <CPack/cmCPackGenerator.h> #include <string> @@ -56,7 +58,7 @@ protected: virtual bool SupportsComponentInstallation() const { - return false; + return true; } private: @@ -79,9 +81,30 @@ private: bool CreateWiXSourceFiles(); - bool CreateStartMenuShortcuts( + bool CreateFeatureHierarchy( + cmWIXSourceWriter& featureDefinitions); + + bool EmitFeatureForComponentGroup( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponentGroup const& group); + + bool EmitFeatureForComponent( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponent const& component); + + bool AddComponentsToFeature( + std::string const& rootPath, + std::string const& featureId, cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions, + shortcut_map_t& shortcutMap); + + bool CreateStartMenuShortcuts( + std::string const& cpackComponentName, + std::string const& featureId, + shortcut_map_t& shortcutMap, + cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions); void CreateUninstallShortcut( @@ -106,7 +129,8 @@ private: cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions, - const std::vector<std::string>& pkgExecutables); + const std::vector<std::string>& pkgExecutables, + shortcut_map_t& shortcutMap); bool RequireOption(const std::string& name, std::string& value) const; @@ -136,13 +160,23 @@ private: void AddCustomFlags( const std::string& variableName, std::ostream& stream); + void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions); + + void LoadPatchFragments(const std::string& patchFilePath); + + void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer); + + void ApplyPatchElement(const cmWIXPatchElement& element, + cmWIXSourceWriter& writer); + std::vector<std::string> wixSources; id_map_t pathToIdMap; ambiguity_map_t idAmbiguityCounter; - shortcut_map_t shortcutMap; extension_set_t candleExtensions; extension_set_t lightExtensions; + + cmWIXPatchParser::fragment_map_t fragments; }; #endif diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx new file mode 100644 index 0000000..0a3b3bc --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -0,0 +1,145 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXPatchParser.h" + +#include <CPack/cmCPackGenerator.h> + +#include <cm_expat.h> + +cmWIXPatchElement::~cmWIXPatchElement() +{ + for(child_list_t::iterator i = children.begin(); i != children.end(); ++i) + { + delete *i; + } +} + +cmWIXPatchParser::cmWIXPatchParser( + fragment_map_t& fragments, cmCPackLog* logger): + Logger(logger), + state(BEGIN_DOCUMENT), + valid(true), + fragments(fragments) +{ + +} + +void cmWIXPatchParser::StartElement(const char *name, const char **atts) +{ + std::string name_str = name; + if(state == BEGIN_DOCUMENT) + { + if(name_str == "CPackWiXPatch") + { + state = BEGIN_FRAGMENTS; + } + else + { + ReportValidationError("Expected root element 'CPackWiXPatch'"); + } + } + else if(state == BEGIN_FRAGMENTS) + { + if(name_str == "CPackWiXFragment") + { + state = INSIDE_FRAGMENT; + StartFragment(atts); + } + else + { + ReportValidationError("Expected 'CPackWixFragment' element"); + } + } + else if(state == INSIDE_FRAGMENT) + { + cmWIXPatchElement &parent = *elementStack.back(); + + parent.children.resize(parent.children.size() + 1); + cmWIXPatchElement*& currentElement = parent.children.back(); + currentElement = new cmWIXPatchElement; + currentElement->name = name; + + for(size_t i = 0; atts[i]; i += 2) + { + std::string key = atts[i]; + std::string value = atts[i+1]; + + currentElement->attributes[key] = value; + } + + elementStack.push_back(currentElement); + } +} + +void cmWIXPatchParser::StartFragment(const char **attributes) +{ + for(size_t i = 0; attributes[i]; i += 2) + { + std::string key = attributes[i]; + std::string value = attributes[i+1]; + + if(key == "Id") + { + if(fragments.find(value) != fragments.end()) + { + std::stringstream tmp; + tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; + ReportValidationError(tmp.str()); + } + + elementStack.push_back(&fragments[value]); + } + else + { + ReportValidationError( + "The only allowed 'CPackWixFragment' attribute is 'Id'"); + } + } +} + +void cmWIXPatchParser::EndElement(const char *name) +{ + std::string name_str = name; + if(state == INSIDE_FRAGMENT) + { + if(name_str == "CPackWiXFragment") + { + state = BEGIN_FRAGMENTS; + elementStack.clear(); + } + else + { + elementStack.pop_back(); + } + } +} + +void cmWIXPatchParser::ReportError(int line, int column, const char* msg) +{ + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while processing XML patch file at " << line << ":" << column << + ": "<< msg << std::endl); + valid = false; +} + +void cmWIXPatchParser::ReportValidationError(const std::string& message) +{ + ReportError(XML_GetCurrentLineNumber(Parser), + XML_GetCurrentColumnNumber(Parser), + message.c_str()); +} + +bool cmWIXPatchParser::IsValid() const +{ + return valid; +} diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h new file mode 100644 index 0000000..4fa5e6f --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -0,0 +1,75 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackWIXPatchParser_h +#define cmCPackWIXPatchParser_h + +#include <cmXMLParser.h> + +#include <CPack/cmCPackLog.h> + +#include <map> +#include <list> + +struct cmWIXPatchElement +{ + ~cmWIXPatchElement(); + + typedef std::list<cmWIXPatchElement*> child_list_t; + typedef std::map<std::string, std::string> attributes_t; + + std::string name; + child_list_t children; + attributes_t attributes; +}; + +/** \class cmWIXPatchParser + * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE) + */ +class cmWIXPatchParser : public cmXMLParser +{ +public: + typedef std::map<std::string, cmWIXPatchElement> fragment_map_t; + + cmWIXPatchParser(fragment_map_t& fragments, cmCPackLog* logger); + +private: + virtual void StartElement(const char *name, const char **atts); + + void StartFragment(const char **attributes); + + virtual void EndElement(const char *name); + virtual void ReportError(int line, int column, const char* msg); + + void ReportValidationError(const std::string& message); + + bool IsValid() const; + + cmCPackLog* Logger; + + enum ParserState + { + BEGIN_DOCUMENT, + BEGIN_FRAGMENTS, + INSIDE_FRAGMENT + }; + + ParserState state; + + bool valid; + + fragment_map_t& fragments; + + std::list<cmWIXPatchElement*> elementStack; +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index 214b8ac..c8a3922 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -123,6 +123,15 @@ void cmWIXSourceWriter::AddAttribute( file << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; } +void cmWIXSourceWriter::AddAttributeUnlessEmpty( + const std::string& key, const std::string& value) +{ + if(value.size()) + { + AddAttribute(key, value); + } +} + std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value) { if(value.empty()) diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 0c7803c..670d4c0 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -40,6 +40,9 @@ public: void AddAttribute( const std::string& key, const std::string& value); + void AddAttributeUnlessEmpty( + const std::string& key, const std::string& value); + static std::string WindowsCodepageToUtf8(const std::string& value); private: diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 9831d02..8e5fd78 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -64,7 +64,8 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) DoingTargetName, DoingTargetType, DoingBuildDir, - DoingCount }; + DoingCount, + DoingFilterPrefix }; Doing doing = DoingNone; int arg0 = 0; for(int i=1; !arg0 && i < argc; ++i) @@ -98,6 +99,10 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) { doing = DoingBuildDir; } + else if(strcmp(arg, "--filter-prefix") == 0) + { + doing = DoingFilterPrefix; + } else if(doing == DoingOutput) { this->OptionOutput = arg; @@ -132,6 +137,11 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) this->OptionBuildDir = arg; doing = DoingNone; } + else if(doing == DoingFilterPrefix) + { + this->OptionFilterPrefix = arg; + doing = DoingNone; + } } // Extract the real command line. @@ -573,8 +583,15 @@ void cmCTestLaunch::DumpFileToXML(std::ostream& fxml, std::string line; const char* sep = ""; + while(cmSystemTools::GetLineFromStream(fin, line)) { + if(OptionFilterPrefix.size() && cmSystemTools::StringStartsWith( + line.c_str(), OptionFilterPrefix.c_str())) + { + continue; + } + fxml << sep << cmXMLSafe(line).Quotes(false); sep = "\n"; } diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index 7457e83..a86a9df 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -45,6 +45,7 @@ private: std::string OptionTargetName; std::string OptionTargetType; std::string OptionBuildDir; + std::string OptionFilterPrefix; bool ParseArguments(int argc, const char* const* argv); // The real command line appearing after launcher arguments. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 31cc393..1be5980 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -619,19 +619,19 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, } //---------------------------------------------------------------------------- -cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index, +cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const char* name) { // Look for a target in the scope of the depender. cmMakefile* mf = this->Makefile; if(depender_index >= 0) { - if(cmTarget* depender = this->EntryList[depender_index].Target) + if(cmTarget const* depender = this->EntryList[depender_index].Target) { mf = depender->GetMakefile(); } } - cmTarget* tgt = mf->FindTargetToUse(name); + cmTarget const* tgt = mf->FindTargetToUse(name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -950,7 +950,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) int count = 2; for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if(cmTarget* target = this->EntryList[*ni].Target) + if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = target->GetLinkInterface(this->Config, this->HeadTarget)) @@ -997,7 +997,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index, // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str())) + if(cmTarget const* tgt + = this->FindTargetToLink(depender_index, item.c_str())) { if(!tgt->IsImported()) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b86c9b2..cf227fb 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -40,7 +40,7 @@ public: struct LinkEntry { std::string Item; - cmTarget* Target; + cmTarget const* Target; bool IsSharedDep; bool IsFlag; LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} @@ -53,7 +53,7 @@ public: EntryVector const& Compute(); void SetOldLinkDirMode(bool b); - std::set<cmTarget*> const& GetOldWrongConfigItems() const + std::set<cmTarget const*> const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } private: @@ -83,7 +83,7 @@ private: void AddDirectLinkEntries(); void AddLinkEntries(int depender_index, std::vector<std::string> const& libs); - cmTarget* FindTargetToLink(int depender_index, const char* name); + cmTarget const* FindTargetToLink(int depender_index, const char* name); // One entry for each unique item. std::vector<LinkEntry> EntryList; @@ -164,7 +164,7 @@ private: // Compatibility help. bool OldLinkDirMode; void CheckWrongConfigItem(int depender_index, std::string const& item); - std::set<cmTarget*> OldWrongConfigItems; + std::set<cmTarget const*> OldWrongConfigItems; }; #endif diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0ef3d2e..f3bdddd 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -477,7 +477,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths() } //---------------------------------------------------------------------------- -std::set<cmTarget*> const& +std::set<cmTarget const*> const& cmComputeLinkInformation::GetSharedLibrariesLinked() { return this->SharedLibrariesLinked; @@ -542,11 +542,11 @@ bool cmComputeLinkInformation::Compute() // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - std::set<cmTarget*> const& wrongItems = cld.GetOldWrongConfigItems(); - for(std::set<cmTarget*>::const_iterator i = wrongItems.begin(); + std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems(); + for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin(); i != wrongItems.end(); ++i) { - cmTarget* tgt = *i; + cmTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -620,7 +620,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) } //---------------------------------------------------------------------------- -void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) +void cmComputeLinkInformation::AddItem(std::string const& item, + cmTarget const* tgt) { // Compute the proper name to use to link this library. const char* config = this->Config; @@ -700,7 +701,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, - cmTarget* tgt) + cmTarget const* tgt) { // If dropping shared library dependencies, ignore them. if(this->SharedDependencyMode == SharedDepModeNone) @@ -1062,7 +1063,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddTargetItem(std::string const& item, - cmTarget* target) + cmTarget const* target) { // This is called to handle a link item that is a full path to a target. // If the target is not a static library make sure the link type is @@ -1744,7 +1745,7 @@ cmComputeLinkInformation::GetRuntimeSearchPath() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget* target) + cmTarget const* target) { // Ignore targets on Apple where install_name is not @rpath. // The dependenty library can be found with other means such as diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 1da5495..356e6ed 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -39,11 +39,11 @@ public: Item(): Value(), IsPath(true), Target(0) {} Item(Item const& item): Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} - Item(std::string const& v, bool p, cmTarget* target = 0): + Item(std::string const& v, bool p, cmTarget const* target = 0): Value(v), IsPath(p), Target(target) {} std::string Value; bool IsPath; - cmTarget* Target; + cmTarget const* Target; }; typedef std::vector<Item> ItemVector; ItemVector const& GetItems(); @@ -57,13 +57,13 @@ public: void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install); std::string GetRPathString(bool for_install); std::string GetChrpathString(); - std::set<cmTarget*> const& GetSharedLibrariesLinked(); + std::set<cmTarget const*> const& GetSharedLibrariesLinked(); std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString(); private: - void AddItem(std::string const& item, cmTarget* tgt); - void AddSharedDepItem(std::string const& item, cmTarget* tgt); + void AddItem(std::string const& item, cmTarget const* tgt); + void AddSharedDepItem(std::string const& item, cmTarget const* tgt); // Output information. ItemVector Items; @@ -71,7 +71,7 @@ private: std::vector<std::string> Depends; std::vector<std::string> FrameworkPaths; std::vector<std::string> RuntimeSearchPath; - std::set<cmTarget*> SharedLibrariesLinked; + std::set<cmTarget const*> SharedLibrariesLinked; // Context information. cmTarget const* Target; @@ -139,7 +139,7 @@ private: std::string NoCaseExpression(const char* str); // Handling of link items. - void AddTargetItem(std::string const& item, cmTarget* target); + void AddTargetItem(std::string const& item, cmTarget const* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); void AddUserItem(std::string const& item, bool pathNotKnown); @@ -179,7 +179,8 @@ private: // Runtime path computation. cmOrderDirectories* OrderRuntimeSearchPath; - void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target); + void AddLibraryRuntimeInfo(std::string const& fullPath, + cmTarget const* target); void AddLibraryRuntimeInfo(std::string const& fullPath); // Dependent library path computation. diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index cb9e37e..73a8e27 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute() //---------------------------------------------------------------------------- void -cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, +cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps) { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = this->TargetIndex.find(t); + std::map<cmTarget const*, int>::const_iterator tii + = this->TargetIndex.find(t); assert(tii != this->TargetIndex.end()); int i = tii->second; @@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, EdgeList const& nl = this->FinalGraph[i]; for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - cmTarget* dep = this->Targets[*ni]; + cmTarget const* dep = this->Targets[*ni]; cmTargetDependSet::iterator di = deps.insert(dep).first; di->SetType(ni->IsStrong()); } @@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets() this->GlobalGenerator->GetLocalGenerators(); for(unsigned int i = 0; i < lgens.size(); ++i) { - cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) + const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); + for(cmTargets::const_iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - cmTarget* target = &ti->second; + cmTarget const* target = &ti->second; int index = static_cast<int>(this->Targets.size()); this->TargetIndex[target] = index; this->Targets.push_back(target); @@ -198,7 +200,11 @@ void cmComputeTargetDepends::CollectDepends() void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; + if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return; + } // Loop over all targets linked directly in all configs. // We need to make targets depend on the union of all config-specific @@ -208,15 +214,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::set<cmStdString> emitted; { std::vector<std::string> tlibs; - if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // For INTERFACE_LIBRARY depend on the interface instead. - depender->GetInterfaceLinkLibraries(0, tlibs, depender); - } - else - { - depender->GetDirectLinkLibraries(0, tlibs, depender); - } + depender->GetDirectLinkLibraries(0, tlibs, depender); // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -237,15 +235,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) it != configs.end(); ++it) { std::vector<std::string> tlibs; - if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // For INTERFACE_LIBRARY depend on the interface instead. - depender->GetInterfaceLinkLibraries(it->c_str(), tlibs, depender); - } - else - { - depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); - } + depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); + // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -282,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; if(cmTarget::LinkInterface const* iface = dependee->GetLinkInterface(config, depender)) { @@ -311,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, bool linking, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; - cmTarget* dependee = + cmTarget const* depender = this->Targets[depender_index]; + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -346,10 +337,10 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, bool linking) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; // Check the target's makefile first. - cmTarget* dependee = + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a @@ -370,7 +361,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, bool linking) { if(dependee->IsImported()) @@ -380,7 +371,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set<cmStdString>::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget* transitive_dependee = + if(cmTarget const* transitive_dependee = dependee->GetMakefile()->FindTargetToUse(i->c_str())) { this->AddTargetDepend(depender_index, transitive_dependee, false); @@ -391,7 +382,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = + std::map<cmTarget const*, int>::const_iterator tii = this->TargetIndex.find(dependee); assert(tii != this->TargetIndex.end()); int dependee_index = tii->second; @@ -411,13 +402,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name) for(int depender_index = 0; depender_index < n; ++depender_index) { EdgeList const& nl = graph[depender_index]; - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; fprintf(stderr, "target %d is [%s]\n", depender_index, depender->GetName()); for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_index = *ni; - cmTarget* dependee = this->Targets[dependee_index]; + cmTarget const* dependee = this->Targets[dependee_index]; fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, dependee->GetName(), ni->IsStrong()? "strong" : "weak"); } @@ -504,7 +495,7 @@ cmComputeTargetDepends { // Get the depender. int i = *ci; - cmTarget* depender = this->Targets[i]; + cmTarget const* depender = this->Targets[i]; // Describe the depender. e << " \"" << depender->GetName() << "\" of type " @@ -517,7 +508,7 @@ cmComputeTargetDepends int j = *ni; if(cmap[j] == c) { - cmTarget* dependee = this->Targets[j]; + cmTarget const* dependee = this->Targets[j]; e << " depends on \"" << dependee->GetName() << "\"" << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n"; } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index d6131cf..6cd6da0 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -38,19 +38,21 @@ public: bool Compute(); - std::vector<cmTarget*> const& GetTargets() const { return this->Targets; } - void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps); + std::vector<cmTarget const*> const& + GetTargets() const { return this->Targets; } + void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps); private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); void AddTargetDepend(int depender_index, const char* dependee_name, bool linking); - void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking); + void AddTargetDepend(int depender_index, cmTarget const* dependee, + bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); void AddInterfaceDepends(int depender_index, const char* dependee_name, bool linking, std::set<cmStdString> &emitted); - void AddInterfaceDepends(int depender_index, cmTarget* dependee, + void AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted); cmGlobalGenerator* GlobalGenerator; @@ -58,8 +60,8 @@ private: bool NoCycles; // Collect all targets. - std::vector<cmTarget*> Targets; - std::map<cmTarget*, int> TargetIndex; + std::vector<cmTarget const*> Targets; + std::map<cmTarget const*, int> TargetIndex; // Represent the target dependency graph. The entry at each // top-level index corresponds to a depender whose dependencies are diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 50835e2..c10f86f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -77,6 +77,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te, cmGeneratorExpression::BuildInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, + cmGeneratorExpression::BuildInterface, + properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); const bool newCMP0022Behavior = @@ -226,10 +229,8 @@ cmExportBuildFileGenerator::HandleMissingTarget( // Append it with the export namespace. link_libs += this->Namespace; link_libs += dependee->GetExportName(); -// if generate time {} } - //---------------------------------------------------------------------------- std::vector<std::string> cmExportBuildFileGenerator diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 86ddc3f..0a67ccf 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -16,6 +16,7 @@ #include "cmake.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/Encoding.hxx> #include "cmExportBuildFileGenerator.h" @@ -135,6 +136,14 @@ bool cmExportCommand return false; } } + else + { + cmOStringStream e; + e << "given target \"" << *currentTarget + << "\" which is not built by this project."; + this->SetError(e.str().c_str()); + return false; + } } cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator() @@ -244,14 +253,14 @@ void cmExportCommand::ReportRegistryError(std::string const& msg, cmOStringStream e; e << msg << "\n" << " HKEY_CURRENT_USER\\" << key << "\n"; - char winmsg[1024]; - if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + wchar_t winmsg[1024]; + if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), winmsg, 1024, 0) > 0) { e << "Windows reported:\n" - << " " << winmsg; + << " " << cmsys::Encoding::ToNarrow(winmsg); } this->Makefile->IssueMessage(cmake::WARNING, e.str()); } @@ -264,8 +273,9 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package, std::string key = "Software\\Kitware\\CMake\\Packages\\"; key += package; HKEY hKey; - LONG err = RegCreateKeyEx(HKEY_CURRENT_USER, - key.c_str(), 0, 0, REG_OPTION_NON_VOLATILE, + LONG err = RegCreateKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(key).c_str(), + 0, 0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, &hKey, 0); if(err != ERROR_SUCCESS) { @@ -273,8 +283,11 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package, "Cannot create/open registry key", key, err); return; } - err = RegSetValueEx(hKey, hash, 0, REG_SZ, (BYTE const*)content, - static_cast<DWORD>(strlen(content)+1)); + + std::wstring wcontent = cmsys::Encoding::ToWide(content); + err = RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(), + 0, REG_SZ, (BYTE const*)wcontent.c_str(), + static_cast<DWORD>(wcontent.size()+1)*sizeof(wchar_t)); RegCloseKey(hKey); if(err != ERROR_SUCCESS) { diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index dc62284..2a87e4f 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -233,26 +233,46 @@ static bool checkInterfaceDirs(const std::string &prepro, const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0; + bool hadFatalError = false; + for(std::vector<std::string>::iterator li = parts.begin(); li != parts.end(); ++li) { - if (cmGeneratorExpression::Find(*li) != std::string::npos) + size_t genexPos = cmGeneratorExpression::Find(*li); + if (genexPos == 0) { continue; } + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + if (genexPos != std::string::npos) + { + switch (target->GetPolicyStatusCMP0041()) + { + case cmPolicies::WARN: + messageType = cmake::WARNING; + e << target->GetMakefile()->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0041) << "\n"; + break; + case cmPolicies::OLD: + continue; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + hadFatalError = true; + break; // Issue fatal message. + } + } if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) { continue; } if (!cmSystemTools::FileIsFullPath(li->c_str())) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } if (isSubDirectory(li->c_str(), installDir)) { @@ -260,29 +280,44 @@ static bool checkInterfaceDirs(const std::string &prepro, } if (isSubDirectory(li->c_str(), topBinaryDir)) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } if (!inSourceBuild) { if (isSubDirectory(li->c_str(), topSourceDir)) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } } } - return true; + return !hadFatalError; +} + +//---------------------------------------------------------------------------- +static void prefixItems(std::string &exportDirs) +{ + std::vector<std::string> entries; + cmGeneratorExpression::Split(exportDirs, entries); + exportDirs = ""; + const char *sep = ""; + for(std::vector<std::string>::const_iterator ei = entries.begin(); + ei != entries.end(); ++ei) + { + exportDirs += sep; + sep = ";"; + if (!cmSystemTools::FileIsFullPath(ei->c_str()) + && ei->find("${_IMPORT_PREFIX}") == std::string::npos) + { + exportDirs += "${_IMPORT_PREFIX}/"; + } + exportDirs += *ei; + } } //---------------------------------------------------------------------------- @@ -301,7 +336,10 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); - std::string dirs = tei->InterfaceIncludeDirectories; + std::string dirs = cmGeneratorExpression::Preprocess( + tei->InterfaceIncludeDirectories, + preprocessRule, + true); this->ReplaceInstallPrefix(dirs); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0, @@ -330,6 +368,8 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( return; } + prefixItems(exportDirs); + std::string includes = (input?input:""); const char* sep = input ? ";" : ""; includes += sep + exportDirs; @@ -362,7 +402,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget *tgt, const char *prop, +void getPropertyContents(cmTarget const* tgt, const char *prop, std::set<std::string> &ifaceProperties) { const char *p = tgt->GetProperty(prop); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index ad17556..1025dc0 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -140,6 +140,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", + te, + cmGeneratorExpression::InstallInterface, + properties, missingTargets); const bool newCMP0022Behavior = te->GetPolicyStatusCMP0022() != cmPolicies::WARN @@ -293,16 +297,14 @@ cmExportInstallFileGenerator { // Collect import properties for this target. cmTargetExport const* te = *tei; - ImportPropertyMap properties; - std::set<std::string> importedLocations; - if (!properties.empty() - && te->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (te->Target->GetType() == cmTarget::INTERFACE_LIBRARY) { - this->GenerateImportPropertyCode(os, config, te->Target, properties); - this->GenerateImportedFileChecksCode(os, te->Target, properties, - importedLocations); continue; } + + ImportPropertyMap properties; + std::set<std::string> importedLocations; + this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator, properties, importedLocations); this->SetImportLocationProperty(config, suffix, te->LibraryGenerator, diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx new file mode 100644 index 0000000..177ef8d --- /dev/null +++ b/Source/cmExtraKateGenerator.cxx @@ -0,0 +1,339 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2004 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmExtraKateGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmake.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmTarget.h" +#include "cmSystemTools.h" +#include "cmXMLSafe.h" + +#include <cmsys/SystemTools.hxx> + +//---------------------------------------------------------------------------- +void cmExtraKateGenerator +::GetDocumentation(cmDocumentationEntry& entry, const char*) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Kate project files."; +} + +cmExtraKateGenerator::cmExtraKateGenerator() +:cmExternalMakefileProjectGenerator() +{ +#if defined(_WIN32) + this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); + this->SupportedGlobalGenerators.push_back("NMake Makefiles"); +// disable until somebody actually tests it: +// this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); +#endif + this->SupportedGlobalGenerators.push_back("Ninja"); + this->SupportedGlobalGenerators.push_back("Unix Makefiles"); +} + + +void cmExtraKateGenerator::Generate() +{ + const cmMakefile* mf + = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), + mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), + this->GetPathBasename(mf->GetHomeOutputDirectory())); + this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0); + + this->CreateKateProjectFile(mf); + this->CreateDummyKateProjectFile(mf); +} + + +void cmExtraKateGenerator::CreateKateProjectFile(const cmMakefile* mf) const +{ + std::string filename = mf->GetHomeOutputDirectory(); + filename += "/.kateproject"; + cmGeneratedFileStream fout(filename.c_str()); + if (!fout) + { + return; + } + + std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::string args = mf->GetRequiredDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); + + fout << + "{\n" + "\t\"name\": \"" << this->ProjectName << "\",\n" + "\t\"directory\": \"" << mf->GetHomeDirectory() << "\",\n" + "\t\"files\": [ { " << this->GenerateFilesString(mf) << "} ],\n"; + this->WriteTargets(mf, fout); + fout << "}\n"; +} + + +void +cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, + cmGeneratedFileStream& fout) const +{ + fout << + "\t\"build\": {\n" + "\t\t\"directory\": \"" << mf->GetHomeOutputDirectory() << "\",\n" + "\t\t\"default_target\": \"all\",\n" + "\t\t\"prev_target\": \"all\",\n" + "\t\t\"clean_target\": \"clean\",\n" + "\t\t\"targets\":[\n"; + + const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string makeArgs = mf->GetSafeDefinition( + "CMAKE_KATE_MAKE_ARGUMENTS"); + const char* homeOutputDir = mf->GetHomeOutputDirectory(); + + this->AppendTarget(fout, "all", make, makeArgs, + homeOutputDir, homeOutputDir); + this->AppendTarget(fout, "clean", make, makeArgs, + homeOutputDir, homeOutputDir); + + // add all executable and library targets and some of the GLOBAL + // and UTILITY targets + for (std::vector<cmLocalGenerator*>::const_iterator + it = this->GlobalGenerator->GetLocalGenerators().begin(); + it != this->GlobalGenerator->GetLocalGenerators().end(); + ++it) + { + const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); + cmMakefile* makefile=(*it)->GetMakefile(); + std::string currentDir = makefile->GetCurrentOutputDirectory(); + bool topLevel = (currentDir == makefile->GetHomeOutputDirectory()); + + for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti) + { + switch(ti->second.GetType()) + { + case cmTarget::GLOBAL_TARGET: + { + bool insertTarget = false; + // Only add the global targets from CMAKE_BINARY_DIR, + // not from the subdirs + if (topLevel) + { + insertTarget = true; + // only add the "edit_cache" target if it's not ccmake, because + // this will not work within the IDE + if (ti->first == "edit_cache") + { + const char* editCommand = makefile->GetDefinition + ("CMAKE_EDIT_COMMAND"); + if (editCommand == 0) + { + insertTarget = false; + } + else if (strstr(editCommand, "ccmake")!=NULL) + { + insertTarget = false; + } + } + } + if (insertTarget) + { + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); + } + } + break; + case cmTarget::UTILITY: + // Add all utility targets, except the Nightly/Continuous/ + // Experimental-"sub"targets as e.g. NightlyStart + if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) + || ((ti->first.find("Continuous")==0)&&(ti->first!="Continuous")) + || ((ti->first.find("Experimental")==0) + && (ti->first!="Experimental"))) + { + break; + } + + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); + break; + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + case cmTarget::OBJECT_LIBRARY: + { + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); + std::string fastTarget = ti->first; + fastTarget += "/fast"; + this->AppendTarget(fout, fastTarget, make, makeArgs, + currentDir, homeOutputDir); + + } + break; + default: + break; + } + } + + //insert rules for compiling, preprocessing and assembling individual files + std::vector<std::string> objectFileTargets; + (*it)->GetIndividualFileTargets(objectFileTargets); + for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin(); + fit != objectFileTargets.end(); + ++fit) + { + this->AppendTarget(fout, *fit, make, makeArgs, currentDir,homeOutputDir); + } + } + + fout << + "\t] }\n"; +} + + +void +cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, + const std::string& target, + const std::string& make, + const std::string& makeArgs, + const std::string& path, + const char* homeOutputDir + ) const +{ + static char JsonSep = ' '; + + fout << + "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", " + "\"build_cmd\":\"" << make + << " -C " << (this->UseNinja ? homeOutputDir : path.c_str()) + << " " << makeArgs << " " + << target << "\"}\n"; + + JsonSep = ','; +} + + + +void +cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const +{ + std::string filename = mf->GetHomeOutputDirectory(); + filename += "/"; + filename += this->ProjectName; + filename += ".kateproject"; + cmGeneratedFileStream fout(filename.c_str()); + if (!fout) + { + return; + } + + fout << "#Generated by cmake, do not edit.\n"; +} + + +std::string +cmExtraKateGenerator::GenerateFilesString(const cmMakefile* mf) const +{ + std::string s = mf->GetHomeDirectory(); + s += "/.git"; + if(cmSystemTools::FileExists(s.c_str())) + { + return std::string("\"git\": 1 "); + } + + s = mf->GetHomeDirectory(); + s += "/.svn"; + if(cmSystemTools::FileExists(s.c_str())) + { + return std::string("\"svn\": 1 "); + } + + s = mf->GetHomeDirectory(); + s += "/"; + + std::set<std::string> files; + std::string tmp; + const std::vector<cmLocalGenerator *>& lgs = + this->GlobalGenerator->GetLocalGenerators(); + + for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin(); + it!=lgs.end(); it++) + { + cmMakefile* makefile=(*it)->GetMakefile(); + const std::vector<std::string>& listFiles=makefile->GetListFiles(); + for (std::vector<std::string>::const_iterator lt=listFiles.begin(); + lt!=listFiles.end(); lt++) + { + tmp=*lt; + { + files.insert(tmp); + } + } + + const std::vector<cmSourceFile*>& sources = makefile->GetSourceFiles(); + for (std::vector<cmSourceFile*>::const_iterator sfIt = sources.begin(); + sfIt != sources.end(); sfIt++) + { + cmSourceFile* sf = *sfIt; + if (sf->GetPropertyAsBool("GENERATED")) + { + continue; + } + + tmp = sf->GetFullPath(); + files.insert(tmp); + } + } + + const char* sep = ""; + tmp = "\"list\": ["; + for(std::set<std::string>::const_iterator it = files.begin(); + it != files.end(); ++it) + { + tmp += sep; + tmp += " \""; + tmp += *it; + tmp += "\""; + sep = ","; + } + tmp += "] "; + + return tmp; +} + + +std::string cmExtraKateGenerator::GenerateProjectName(const std::string& name, + const std::string& type, + const std::string& path) const +{ + return name + (type.empty() ? "" : "-") + type + "@" + path; +} + + +std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const +{ + std::string outputBasename = path; + while (outputBasename.size() > 0 && + (outputBasename[outputBasename.size() - 1] == '/' || + outputBasename[outputBasename.size() - 1] == '\\')) + { + outputBasename.resize(outputBasename.size() - 1); + } + std::string::size_type loc = outputBasename.find_last_of("/\\"); + if (loc != std::string::npos) + { + outputBasename = outputBasename.substr(loc + 1); + } + + return outputBasename; +} diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h new file mode 100644 index 0000000..6ced5fe --- /dev/null +++ b/Source/cmExtraKateGenerator.h @@ -0,0 +1,62 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2013 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmExtraKateGenerator_h +#define cmExtraKateGenerator_h + +#include "cmExternalMakefileProjectGenerator.h" + +class cmLocalGenerator; +class cmMakefile; +class cmTarget; +class cmGeneratedFileStream; + +/** \class cmExtraKateGenerator + * \brief Write Kate project files for Makefile or ninja based projects + */ +class cmExtraKateGenerator : public cmExternalMakefileProjectGenerator +{ +public: + cmExtraKateGenerator(); + + virtual const char* GetName() const + { return cmExtraKateGenerator::GetActualName();} + static const char* GetActualName() { return "Kate";} + static cmExternalMakefileProjectGenerator* New() + { return new cmExtraKateGenerator; } + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry, + const char* fullName) const; + + virtual void Generate(); +private: + void CreateKateProjectFile(const cmMakefile* mf) const; + void CreateDummyKateProjectFile(const cmMakefile* mf) const; + void WriteTargets(const cmMakefile* mf, cmGeneratedFileStream& fout) const; + void AppendTarget(cmGeneratedFileStream& fout, + const std::string& target, + const std::string& make, + const std::string& makeArgs, + const std::string& path, + const char* homeOutputDir) const; + + std::string GenerateFilesString(const cmMakefile* mf) const; + std::string GetPathBasename(const std::string& path) const; + std::string GenerateProjectName(const std::string& name, + const std::string& type, + const std::string& path) const; + + std::string ProjectName; + bool UseNinja; +}; + +#endif diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 3167be4..02f10c0 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -16,6 +16,8 @@ # include <cmsys/hash_map.hxx> #endif +#include <cmsys/Encoding.hxx> + // Use a platform-specific API to get file times efficiently. #if !defined(_WIN32) || defined(__CYGWIN__) # define cmFileTimeComparison_Type struct stat @@ -86,7 +88,8 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname, // Windows version. Get the modification time from extended file // attributes. WIN32_FILE_ATTRIBUTE_DATA fdata; - if(!GetFileAttributesEx(fname, GetFileExInfoStandard, &fdata)) + if(!GetFileAttributesExW(cmsys::Encoding::ToWide(fname).c_str(), + GetFileExInfoStandard, &fdata)) { return false; } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 12f04d6..55c20d6 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -13,6 +13,7 @@ #include <cmsys/Directory.hxx> #include <cmsys/RegularExpression.hxx> +#include <cmsys/Encoding.hxx> #ifdef CMAKE_BUILD_WITH_CMAKE #include "cmVariableWatch.h" @@ -1245,23 +1246,23 @@ void cmFindPackageCommand::LoadPackageRegistryWinSystem() void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view) { - std::string key = "Software\\Kitware\\CMake\\Packages\\"; - key += this->Name; - std::set<cmStdString> bad; + std::wstring key = L"Software\\Kitware\\CMake\\Packages\\"; + key += cmsys::Encoding::ToWide(this->Name); + std::set<std::wstring> bad; HKEY hKey; - if(RegOpenKeyEx(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(), - 0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS) + if(RegOpenKeyExW(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(), + 0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS) { DWORD valueType = REG_NONE; - char name[16384]; - std::vector<char> data(512); + wchar_t name[16383]; // RegEnumValue docs limit name to 32767 _bytes_ + std::vector<wchar_t> data(512); bool done = false; DWORD index = 0; while(!done) { DWORD nameSize = static_cast<DWORD>(sizeof(name)); - DWORD dataSize = static_cast<DWORD>(data.size()-1); - switch(RegEnumValue(hKey, index, name, &nameSize, + DWORD dataSize = static_cast<DWORD>(data.size()*sizeof(data[0])); + switch(RegEnumValueW(hKey, index, name, &nameSize, 0, &valueType, (BYTE*)&data[0], &dataSize)) { case ERROR_SUCCESS: @@ -1269,7 +1270,7 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, if(valueType == REG_SZ) { data[dataSize] = 0; - cmsys_ios::stringstream ss(&data[0]); + cmsys_ios::stringstream ss(cmsys::Encoding::ToNarrow(&data[0])); if(!this->CheckPackageRegistryEntry(ss)) { // The entry is invalid. @@ -1278,7 +1279,7 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, } break; case ERROR_MORE_DATA: - data.resize(dataSize+1); + data.resize((dataSize+sizeof(data[0])-1)/sizeof(data[0])); break; case ERROR_NO_MORE_ITEMS: default: done = true; break; } @@ -1288,13 +1289,13 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, // Remove bad values if possible. if(user && !bad.empty() && - RegOpenKeyEx(HKEY_CURRENT_USER, key.c_str(), + RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_SET_VALUE|view, &hKey) == ERROR_SUCCESS) { - for(std::set<cmStdString>::const_iterator vi = bad.begin(); + for(std::set<std::wstring>::const_iterator vi = bad.begin(); vi != bad.end(); ++vi) { - RegDeleteValue(hKey, vi->c_str()); + RegDeleteValueW(hKey, vi->c_str()); } RegCloseKey(hKey); } diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index f34a35b..2e66d78 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -245,7 +245,7 @@ static void prefixItems(const std::string &content, std::string &result, result += sep; sep = ";"; if (!cmSystemTools::FileIsFullPath(ei->c_str()) - && cmGeneratorExpression::Find(*ei) == std::string::npos) + && cmGeneratorExpression::Find(*ei) != 0) { result += prefix; } diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 7399c7b..92f74f3 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -210,3 +210,11 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileOptions() const return (strcmp(prop, "COMPILE_OPTIONS") == 0 || strcmp(prop, "INTERFACE_COMPILE_OPTIONS") == 0 ); } + +//---------------------------------------------------------------------------- +bool cmGeneratorExpressionDAGChecker::EvaluatingAutoUicOptions() const +{ + const char *prop = this->Property.c_str(); + return (strcmp(prop, "AUTOUIC_OPTIONS") == 0 + || strcmp(prop, "INTERFACE_AUTOUIC_OPTIONS") == 0 ); +} diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index c8594e7..fd47ad7 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -20,13 +20,15 @@ F(EvaluatingIncludeDirectories) \ F(EvaluatingSystemIncludeDirectories) \ F(EvaluatingCompileDefinitions) \ - F(EvaluatingCompileOptions) + F(EvaluatingCompileOptions) \ + F(EvaluatingAutoUicOptions) #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ F(INCLUDE_DIRECTORIES) \ F(SYSTEM_INCLUDE_DIRECTORIES) \ F(COMPILE_DEFINITIONS) \ - F(COMPILE_OPTIONS) + F(COMPILE_OPTIONS) \ + F(AUTOUIC_OPTIONS) //---------------------------------------------------------------------------- struct cmGeneratorExpressionDAGChecker diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 17bf041..c8010d0 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -82,7 +82,6 @@ static const struct ZeroNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { - // Unreachable return std::string(); } } zeroNode; @@ -94,13 +93,12 @@ static const struct OneNode : public cmGeneratorExpressionNode virtual bool AcceptsArbitraryContentParameter() const { return true; } - std::string Evaluate(const std::vector<std::string> &, + std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { - // Unreachable - return std::string(); + return parameters.front(); } } oneNode; @@ -199,6 +197,54 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode } strEqualNode; //---------------------------------------------------------------------------- +static const struct LowerCaseNode : public cmGeneratorExpressionNode +{ + LowerCaseNode() {} + + bool AcceptsArbitraryContentParameter() const { return true; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::LowerCase(parameters.front()); + } +} lowerCaseNode; + +//---------------------------------------------------------------------------- +static const struct UpperCaseNode : public cmGeneratorExpressionNode +{ + UpperCaseNode() {} + + bool AcceptsArbitraryContentParameter() const { return true; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::UpperCase(parameters.front()); + } +} upperCaseNode; + +//---------------------------------------------------------------------------- +static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode +{ + MakeCIdentifierNode() {} + + bool AcceptsArbitraryContentParameter() const { return true; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::MakeCidentifier(parameters.front().c_str()); + } +} makeCIdentifierNode; + +//---------------------------------------------------------------------------- static const struct Angle_RNode : public cmGeneratorExpressionNode { Angle_RNode() {} @@ -308,6 +354,7 @@ static const struct CCompilerIdNode : public CompilerIdNode reportError(context, content->GetOriginalExpression(), "$<C_COMPILER_ID> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "C"); @@ -335,6 +382,7 @@ static const struct CXXCompilerIdNode : public CompilerIdNode reportError(context, content->GetOriginalExpression(), "$<CXX_COMPILER_ID> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "CXX"); @@ -402,6 +450,7 @@ static const struct CCompilerVersionNode : public CompilerVersionNode reportError(context, content->GetOriginalExpression(), "$<C_COMPILER_VERSION> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "C"); @@ -430,6 +479,7 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode reportError(context, content->GetOriginalExpression(), "$<CXX_COMPILER_VERSION> may only be used with targets. It may " "not be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "CXX"); @@ -462,7 +512,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode return parameters.front().empty() ? "1" : "0"; } - if (cmsysString_strcasecmp(parameters.begin()->c_str(), platformId) == 0) + if (strcmp(parameters.begin()->c_str(), platformId) == 0) { return "1"; } @@ -1442,6 +1492,12 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &targetSoNameFileDirNode; else if (identifier == "STREQUAL") return &strEqualNode; + else if (identifier == "LOWER_CASE") + return &lowerCaseNode; + else if (identifier == "UPPER_CASE") + return &upperCaseNode; + else if (identifier == "MAKE_C_IDENTIFIER") + return &makeCIdentifierNode; else if (identifier == "BOOL") return &boolNode; else if (identifier == "ANGLE-R") @@ -1586,14 +1642,6 @@ std::string GeneratorExpressionContent::Evaluate( return std::string(); } - if (node->NumExpectedParameters() == 1 - && node->AcceptsArbitraryContentParameter()) - { - return this->ProcessArbitraryContent(node, identifier, context, - dagChecker, - this->ParamChildren.begin()); - } - std::vector<std::string> parameters; this->EvaluateParameters(node, identifier, context, dagChecker, parameters); if (context->HadError) @@ -1621,33 +1669,35 @@ std::string GeneratorExpressionContent::EvaluateParameters( pend = this->ParamChildren.end(); const bool acceptsArbitraryContent = node->AcceptsArbitraryContentParameter(); - for ( ; pit != pend; ++pit) + int counter = 1; + for ( ; pit != pend; ++pit, ++counter) { - std::string parameter; - std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = - pit->begin(); - const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end = - pit->end(); - for ( ; it != end; ++it) - { - parameter += (*it)->Evaluate(context, dagChecker); - if (context->HadError) - { - return std::string(); - } - } - parameters.push_back(parameter); - if (acceptsArbitraryContent - && parameters.size() == (unsigned int)numExpected - 1) + if (acceptsArbitraryContent && counter == numExpected) { - assert(pit != pend); std::string lastParam = this->ProcessArbitraryContent(node, identifier, context, dagChecker, - pit + 1); + pit); parameters.push_back(lastParam); return std::string(); } + else + { + std::string parameter; + std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = + pit->begin(); + const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end = + pit->end(); + for ( ; it != end; ++it) + { + parameter += (*it)->Evaluate(context, dagChecker); + if (context->HadError) + { + return std::string(); + } + } + parameters.push_back(parameter); + } } } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5a535c7..fdd4e6d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,7 +693,8 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const } } -bool cmStrictTargetComparison::operator()(cmTarget *t1, cmTarget *t2) const +bool cmStrictTargetComparison::operator()(cmTarget const* t1, + cmTarget const* t2) const { int nameResult = strcmp(t1->GetName(), t2->GetName()); if (nameResult == 0) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d2b65b2..8b760f1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -101,10 +101,10 @@ private: }; struct cmStrictTargetComparison { - bool operator()(cmTarget *t1, cmTarget *t2) const; + bool operator()(cmTarget const* t1, cmTarget const* t2) const; }; -typedef std::map<cmTarget*, +typedef std::map<cmTarget const*, cmGeneratorTarget*, cmStrictTargetComparison> cmGeneratorTargetsType; diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index bd3db3e..70004ea 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -44,6 +44,8 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + + virtual bool AllowNotParallel() const { return false; } }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e6f3d94..f160d28 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -950,7 +950,7 @@ void cmGlobalGenerator::ClearEnabledLanguages() } bool cmGlobalGenerator::IsDependedOn(const char* project, - cmTarget* targetIn) + cmTarget const* targetIn) { // Get all local gens for this project std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; @@ -1214,8 +1214,8 @@ bool cmGlobalGenerator::ComputeTargetDepends() { return false; } - std::vector<cmTarget*> const& targets = ctd.GetTargets(); - for(std::vector<cmTarget*>::const_iterator ti = targets.begin(); + std::vector<cmTarget const*> const& targets = ctd.GetTargets(); + for(std::vector<cmTarget const*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); @@ -1379,6 +1379,10 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() for(cmGeneratorTargetsType::iterator ti = targets.begin(); ti != targets.end(); ++ti) { + if (ti->second->Target->IsImported()) + { + continue; + } cmGeneratorTarget* gt = ti->second; gt->ClassifySources(); gt->LookupObjectLibraries(); @@ -1432,7 +1436,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() } //---------------------------------------------------------------------------- -cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const +cmGeneratorTarget* +cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const { cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); if(ti == this->GeneratorTargets.end()) @@ -1954,7 +1959,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() clg = clg->GetParent()) { // This local generator includes the target. - std::set<cmTarget*>& targetSet = + std::set<cmTarget const*>& targetSet = this->LocalGeneratorToTargetMap[clg]; targetSet.insert(&target); @@ -1965,7 +1970,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() for(TargetDependSet::const_iterator ti = tgtdeps.begin(); ti != tgtdeps.end(); ++ti) { - targetSet.insert(*ti); + cmTarget const* ttt = *ti; + targetSet.insert(ttt); } } } @@ -2478,7 +2484,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, //---------------------------------------------------------------------------- cmGlobalGenerator::TargetDependSet const& -cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target) +cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target) { return this->TargetDependencies[&target]; } @@ -2600,7 +2606,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddTargetDepends(cmTarget* target, +void cmGlobalGenerator::AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets) { // add the target itself @@ -2611,7 +2617,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target, TargetDependSet const& ts = this->GetTargetDirectDepends(*target); for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) { - cmTarget* dtarget = *i; + cmTarget const* dtarget = *i; this->AddTargetDepends(dtarget, projectTargets); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index eb720a8..f60d24d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -218,7 +218,7 @@ public: /** If check to see if the target is linked to by any other target in the project */ - bool IsDependedOn(const char* project, cmTarget* target); + bool IsDependedOn(const char* project, cmTarget const* target); ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const char* start_dir); @@ -266,10 +266,10 @@ public: // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies - TargetDependSet const& GetTargetDirectDepends(cmTarget & target); + TargetDependSet const& GetTargetDirectDepends(cmTarget const& target); /** Get per-target generator information. */ - cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; + cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap() const {return this->ProjectMap;} @@ -323,7 +323,8 @@ protected: TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); virtual bool IsRootOnlyTarget(cmTarget* target); - void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets); + void AddTargetDepends(cmTarget const* target, + TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); @@ -333,7 +334,8 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); - typedef std::vector<std::pair<cmQtAutoGenerators, cmTarget*> > AutogensType; + typedef std::vector<std::pair<cmQtAutoGenerators, + cmTarget const*> > AutogensType; void CreateQtAutoGeneratorsTargets(AutogensType& autogens); std::string SelectMakeProgram(const char* makeProgram, @@ -362,7 +364,8 @@ protected: cmLocalGenerator* CurrentLocalGenerator; // map from project name to vector of local generators in that project std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap; - std::map<cmLocalGenerator*, std::set<cmTarget *> > LocalGeneratorToTargetMap; + std::map<cmLocalGenerator*, std::set<cmTarget const*> > + LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set<cmStdString> InstallComponents; @@ -420,7 +423,7 @@ private: std::vector<std::string> FilesReplacedDuringGenerate; // Store computed inter-target dependencies. - typedef std::map<cmTarget *, TargetDependSet> TargetDependMap; + typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap; TargetDependMap TargetDependencies; // Per-target generator information. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 77571b2..4b92058 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -830,7 +830,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() void cmGlobalNinjaGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs) { const char* configName = target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); @@ -879,7 +879,7 @@ cmGlobalNinjaGenerator void cmGlobalNinjaGenerator -::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs) { if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 4fd0d5c..de38923 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -283,8 +283,8 @@ public: ASD.insert(deps.begin(), deps.end()); } - void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs); void AddDependencyToAll(cmTarget* target); void AddDependencyToAll(const std::string& input); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 6333873..622a7c5 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -480,7 +480,6 @@ cmGlobalUnixMakefileGenerator3 (l->second->GetType() == cmTarget::SHARED_LIBRARY) || (l->second->GetType() == cmTarget::MODULE_LIBRARY) || (l->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (l->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (l->second->GetType() == cmTarget::UTILITY)) { if(l->second->Target->IsImported()) @@ -658,7 +657,6 @@ cmGlobalUnixMakefileGenerator3 (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY))) { // Add a rule to build the target by name. @@ -680,10 +678,6 @@ cmGlobalUnixMakefileGenerator3 t->second->GetName(), depends, commands, true); - if (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) - { - continue; - } // Add a fast rule to build the target std::string localName = lg->GetRelativeTargetDirectory(*t->second->Target); @@ -757,7 +751,6 @@ cmGlobalUnixMakefileGenerator3 || (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) - || (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY))) { std::string makefileName; @@ -774,64 +767,53 @@ cmGlobalUnixMakefileGenerator3 << localName << "\n\n"; commands.clear(); + makeTargetName = localName; + makeTargetName += "/depend"; + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); - if(t->second->GetType() != cmTarget::INTERFACE_LIBRARY) + // add requires if we need it for this generator + if (needRequiresStep) { makeTargetName = localName; - makeTargetName += "/depend"; + makeTargetName += "/requires"; commands.push_back(lg->GetRecursiveMakeCall (makefileName.c_str(),makeTargetName.c_str())); + } + makeTargetName = localName; + makeTargetName += "/build"; + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); - // add requires if we need it for this generator - if (needRequiresStep) - { - makeTargetName = localName; - makeTargetName += "/requires"; - commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); - } - makeTargetName = localName; - makeTargetName += "/build"; - commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); - - // Write the rule. - localName += "/all"; - depends.clear(); + // Write the rule. + localName += "/all"; + depends.clear(); - std::string progressDir = - lg->GetMakefile()->GetHomeOutputDirectory(); - progressDir += cmake::GetCMakeFilesDirectory(); + std::string progressDir = + lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir += cmake::GetCMakeFilesDirectory(); + { + cmOStringStream progCmd; + progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; + // all target counts + progCmd << lg->Convert(progressDir.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL); + progCmd << " "; + std::vector<unsigned long>& progFiles = + this->ProgressMap[t->second->Target].Marks; + for (std::vector<unsigned long>::iterator i = progFiles.begin(); + i != progFiles.end(); ++i) { - cmOStringStream progCmd; - progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; - // all target counts - progCmd << lg->Convert(progressDir.c_str(), - cmLocalGenerator::FULL, - cmLocalGenerator::SHELL); - progCmd << " "; - std::vector<unsigned long>& progFiles = - this->ProgressMap[t->second->Target].Marks; - for (std::vector<unsigned long>::iterator i = progFiles.begin(); - i != progFiles.end(); ++i) - { - progCmd << " " << *i; - } - commands.push_back(progCmd.str()); + progCmd << " " << *i; } - progressDir = "Built target "; - progressDir += t->second->GetName(); - lg->AppendEcho(commands,progressDir.c_str()); - } - else - { - depends.clear(); + commands.push_back(progCmd.str()); } + progressDir = "Built target "; + progressDir += t->second->GetName(); + lg->AppendEcho(commands,progressDir.c_str()); + this->AppendGlobalTargetDepends(depends,*t->second->Target); - if(depends.empty() && this->EmptyRuleHackDepends != "") - { - depends.push_back(this->EmptyRuleHackDepends); - } lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", localName.c_str(), depends, commands, true); @@ -847,7 +829,7 @@ cmGlobalUnixMakefileGenerator3 // Write the rule. commands.clear(); - std::string progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); progressDir += cmake::GetCMakeFilesDirectory(); { @@ -859,7 +841,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // - std::set<cmTarget *> emitted; + std::set<cmTarget const*> emitted; progCmd << " " << this->CountProgressMarksInTarget(t->second->Target, emitted); commands.push_back(progCmd.str()); @@ -937,8 +919,8 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 -::CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted) +::CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted) { size_t count = 0; if(emitted.insert(target).second) @@ -964,9 +946,10 @@ cmGlobalUnixMakefileGenerator3 ::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg) { size_t count = 0; - std::set<cmTarget*> emitted; - std::set<cmTarget*> const& targets = this->LocalGeneratorToTargetMap[lg]; - for(std::set<cmTarget*>::const_iterator t = targets.begin(); + std::set<cmTarget const*> emitted; + std::set<cmTarget const*> const& targets + = this->LocalGeneratorToTargetMap[lg]; + for(std::set<cmTarget const*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { count += this->CountProgressMarksInTarget(*t, emitted); @@ -987,7 +970,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress( //---------------------------------------------------------------------------- bool cmGlobalUnixMakefileGenerator3::ProgressMapCompare -::operator()(cmTarget* l, cmTarget* r) const +::operator()(cmTarget const* l, cmTarget const* r) const { // Order by target name. if(int c = strcmp(l->GetName(), r->GetName())) diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 284f5d1..00a86eb 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -125,6 +125,9 @@ public: const std::string &workingDirectory, const std::string &compileCommand); + /** Does the make tool tolerate .NOTPARALLEL? */ + virtual bool AllowNotParallel() const { return true; } + protected: void WriteMainMakefile2(); void WriteMainCMakefile(); @@ -181,13 +184,14 @@ protected: std::vector<unsigned long> Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; - typedef std::map<cmTarget*, TargetProgress, + struct ProgressMapCompare { bool operator()(cmTarget const*, + cmTarget const*) const; }; + typedef std::map<cmTarget const*, TargetProgress, ProgressMapCompare> ProgressMapType; ProgressMapType ProgressMap; - size_t CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted); + size_t CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); cmGeneratedFileStream *CommandDatabase; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 7d4abbd..6983ef9 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -256,6 +256,14 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- +void cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf) +{ + this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf); + mf->AddDefinition("CMAKE_VS_MSBUILD_COMMAND", + this->GetMSBuildCommand().c_str()); +} + +//---------------------------------------------------------------------------- std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand() { if(!this->MSBuildCommandInitialized) diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 66440ea..976d41f 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -91,6 +91,8 @@ public: virtual const char* GetToolsVersion() { return "4.0"; } + virtual void FindMakeProgram(cmMakefile*); + protected: virtual const char* GetIDEVersion() { return "10.0"; } diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 8651da7..38c47ef 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -78,6 +78,14 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) } //---------------------------------------------------------------------------- +void cmGlobalVisualStudio6Generator::FindMakeProgram(cmMakefile* mf) +{ + this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf); + mf->AddDefinition("CMAKE_VS_MSDEV_COMMAND", + this->GetMSDevCommand().c_str()); +} + +//---------------------------------------------------------------------------- std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand() { if(!this->MSDevCommandInitialized) @@ -197,7 +205,7 @@ void cmGlobalVisualStudio6Generator tt = orderedProjectTargets.begin(); tt != orderedProjectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -263,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& target) + cmTarget const& target) { fout << "#########################################################" "######################\n\n"; @@ -356,7 +364,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 8fe5792..5521410 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -89,6 +89,8 @@ public: ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "$(IntDir)"; } + virtual void FindMakeProgram(cmMakefile*); + protected: virtual const char* GetIDEVersion() { return "6.0"; } private: @@ -97,12 +99,12 @@ private: void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(std::ostream& fout); void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, cmTarget const& t); void WriteExternalProject(std::ostream& fout, const char* name, const char* path, const std::set<cmStdString>& dependencies); void WriteDSWFooter(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); std::string MSDevCommand; bool MSDevCommandInitialized; std::string const& GetMSDevCommand(); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 61d3c4c..6cfad25 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -157,7 +157,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& t) + cmTarget const& t) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -209,7 +209,7 @@ void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, const char*, - const char*, cmTarget& target) + const char*, cmTarget const& target) { VSDependSet const& depends = this->VSTargetDepends[&target]; for(VSDependSet::const_iterator di = depends.begin(); diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index e136db7..04e3a55 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -59,9 +59,11 @@ protected: std::vector<cmLocalGenerator*>& generators); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index f523a8f..1899b40 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -16,6 +16,7 @@ #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" #include "cmake.h" +#include <cmsys/Encoding.hxx> cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( const char* platformName) @@ -111,6 +112,14 @@ void cmGlobalVisualStudio7Generator } //---------------------------------------------------------------------------- +void cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf) +{ + this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf); + mf->AddDefinition("CMAKE_VS_DEVENV_COMMAND", + this->GetDevEnvCommand().c_str()); +} + +//---------------------------------------------------------------------------- std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand() { if(!this->DevEnvCommandInitialized) @@ -326,7 +335,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -367,7 +376,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -461,7 +470,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -610,7 +619,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, const char* dspname, - const char* dir, cmTarget& target) + const char* dir, cmTarget const& target) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -650,7 +659,7 @@ void cmGlobalVisualStudio7Generator ::WriteProjectDepends(std::ostream& fout, const char* dspname, - const char*, cmTarget& target) + const char*, cmTarget const& target) { int depcount = 0; std::string dspguid = this->GetGUID(dspname); @@ -810,7 +819,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; @@ -889,11 +898,11 @@ void cmGlobalVisualStudio7Generator::CreateGUID(const char* name) } std::string ret; UUID uid; - unsigned char *uidstr; + unsigned short *uidstr; UuidCreate(&uid); - UuidToString(&uid,&uidstr); - ret = reinterpret_cast<char*>(uidstr); - RpcStringFree(&uidstr); + UuidToStringW(&uid,&uidstr); + ret = cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(uidstr)); + RpcStringFreeW(&uidstr); ret = cmSystemTools::UpperCase(ret); this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), ret.c_str(), "Stored GUID", @@ -931,7 +940,7 @@ cmGlobalVisualStudio7Generator std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget* target) + cmTarget const* target) { std::set<std::string> activeConfigs; // if it is a utilitiy target then only make it part of the diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index c7b0081..611422a 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -107,6 +107,8 @@ public: const char* GetIntelProjectVersion(); + virtual void FindMakeProgram(cmMakefile*); + protected: virtual const char* GetIDEVersion() { return "7.0"; } @@ -119,9 +121,11 @@ protected: virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const&t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, @@ -130,7 +134,7 @@ protected: cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); virtual void WriteTargetsToSolution( std::ostream& fout, @@ -156,7 +160,7 @@ protected: std::string ConvertToSolutionPath(const char* path); std::set<std::string> IsPartOfDefaultBuild(const char* project, - cmTarget* target); + cmTarget const* target); std::vector<std::string> Configurations; std::map<cmStdString, cmStdString> GUIDMap; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e4ce13f..12c240b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::WriteProjectDepends( - std::ostream& fout, const char*, const char*, cmTarget& t) + std::ostream& fout, const char*, const char*, cmTarget const& t) { TargetDependSet const& unordered = this->GetTargetDirectDepends(t); OrderedTargetDependSet depends(unordered); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index ad01a24..5b952c4 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -84,7 +84,7 @@ protected: const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, - const char* path, cmTarget &t); + const char* path, cmTarget const& t); std::string Name; std::string WindowsCEVersion; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 7afcfa7..93a597c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmTarget.h" +#include <cmsys/Encoding.hxx> //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() @@ -314,7 +315,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target, +void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target, TargetSet& linked) { if(linked.insert(target).second) @@ -347,7 +348,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::FollowLinkDepends( - cmTarget* target, std::set<cmTarget*>& linked) + cmTarget const* target, std::set<cmTarget const*>& linked) { if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { @@ -396,7 +397,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -static bool VSLinkable(cmTarget* t) +static bool VSLinkable(cmTarget const* t) { return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY; } @@ -438,7 +439,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // Collect implicit link dependencies (target_link_libraries). // Static libraries cannot depend on their link implementation // due to behavior (2), but they do not really need to. - std::set<cmTarget*> linkDepends; + std::set<cmTarget const*> linkDepends; if(target.GetType() != cmTarget::STATIC_LIBRARY) { for(TargetDependSet::const_iterator di = depends.begin(); @@ -453,7 +454,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Collect explicit util dependencies (add_dependencies). - std::set<cmTarget*> utilDepends; + std::set<cmTarget const*> utilDepends; for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { @@ -473,18 +474,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Emit link dependencies. - for(std::set<cmTarget*>::iterator di = linkDepends.begin(); + for(std::set<cmTarget const*>::iterator di = linkDepends.begin(); di != linkDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; vsTargetDepend.insert(dep->GetName()); } // Emit util dependencies. Possibly use intermediate targets. - for(std::set<cmTarget*>::iterator di = utilDepends.begin(); + for(std::set<cmTarget const*>::iterator di = utilDepends.begin(); di != utilDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) { // Direct dependency allowed. @@ -522,7 +523,8 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) } //---------------------------------------------------------------------------- -std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target) +std::string +cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target) { UtilityDependsMap::iterator i = this->UtilityDepends.find(target); if(i == this->UtilityDepends.end()) @@ -559,52 +561,53 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, keyname = regKeyBase + "\\OtherProjects7"; hkey = NULL; - result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), - 0, KEY_READ, &hkey); + result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), + 0, KEY_READ, &hkey); if (ERROR_SUCCESS == result) { // Iterate the subkeys and look for the values of interest in each subkey: - CHAR subkeyname[256]; - DWORD cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]); - CHAR keyclass[256]; - DWORD cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]); + wchar_t subkeyname[256]; + DWORD cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]); + wchar_t keyclass[256]; + DWORD cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]); FILETIME lastWriteTime; lastWriteTime.dwHighDateTime = 0; lastWriteTime.dwLowDateTime = 0; - while (ERROR_SUCCESS == RegEnumKeyEx(hkey, index, subkeyname, + while (ERROR_SUCCESS == RegEnumKeyExW(hkey, index, subkeyname, &cch_subkeyname, 0, keyclass, &cch_keyclass, &lastWriteTime)) { // Open the subkey and query the values of interest: HKEY hsubkey = NULL; - result = RegOpenKeyEx(hkey, subkeyname, 0, KEY_READ, &hsubkey); + result = RegOpenKeyExW(hkey, subkeyname, 0, KEY_READ, &hsubkey); if (ERROR_SUCCESS == result) { DWORD valueType = REG_SZ; - CHAR data1[256]; - DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]); - RegQueryValueEx(hsubkey, "Path", 0, &valueType, + wchar_t data1[256]; + DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]); + RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE) &data1[0], &cch_data1); DWORD data2 = 0; DWORD cch_data2 = sizeof(data2); - RegQueryValueEx(hsubkey, "Security", 0, &valueType, + RegQueryValueExW(hsubkey, L"Security", 0, &valueType, (LPBYTE) &data2, &cch_data2); DWORD data3 = 0; DWORD cch_data3 = sizeof(data3); - RegQueryValueEx(hsubkey, "StorageFormat", 0, &valueType, + RegQueryValueExW(hsubkey, L"StorageFormat", 0, &valueType, (LPBYTE) &data3, &cch_data3); - s2 = cmSystemTools::LowerCase(data1); + s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1)); cmSystemTools::ConvertToUnixSlashes(s2); if (s2 == s1) { macrosRegistered = true; } - std::string fullname(data1); + std::string fullname = cmsys::Encoding::ToNarrow(data1); std::string filename; std::string filepath; std::string filepathname; @@ -636,8 +639,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, } ++index; - cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]); - cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]); + cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]); + cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]); lastWriteTime.dwHighDateTime = 0; lastWriteTime.dwLowDateTime = 0; } @@ -662,27 +665,28 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, keyname = regKeyBase + "\\RecordingProject7"; hkey = NULL; - result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), - 0, KEY_READ, &hkey); + result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), + 0, KEY_READ, &hkey); if (ERROR_SUCCESS == result) { DWORD valueType = REG_SZ; - CHAR data1[256]; - DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]); - RegQueryValueEx(hkey, "Path", 0, &valueType, + wchar_t data1[256]; + DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]); + RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE) &data1[0], &cch_data1); DWORD data2 = 0; DWORD cch_data2 = sizeof(data2); - RegQueryValueEx(hkey, "Security", 0, &valueType, + RegQueryValueExW(hkey, L"Security", 0, &valueType, (LPBYTE) &data2, &cch_data2); DWORD data3 = 0; DWORD cch_data3 = sizeof(data3); - RegQueryValueEx(hkey, "StorageFormat", 0, &valueType, + RegQueryValueExW(hkey, L"StorageFormat", 0, &valueType, (LPBYTE) &data3, &cch_data3); - s2 = cmSystemTools::LowerCase(data1); + s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1)); cmSystemTools::ConvertToUnixSlashes(s2); if (s2 == s1) { @@ -714,24 +718,27 @@ void WriteVSMacrosFileRegistryEntry( { std::string keyname = regKeyBase + "\\OtherProjects7"; HKEY hkey = NULL; - LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), 0, + LONG result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), 0, KEY_READ|KEY_WRITE, &hkey); if (ERROR_SUCCESS == result) { // Create the subkey and set the values of interest: HKEY hsubkey = NULL; - char lpClass[] = ""; - result = RegCreateKeyEx(hkey, nextAvailableSubKeyName.c_str(), 0, - lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0); + wchar_t lpClass[] = L""; + result = RegCreateKeyExW(hkey, + cmsys::Encoding::ToWide(nextAvailableSubKeyName).c_str(), 0, + lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0); if (ERROR_SUCCESS == result) { DWORD dw = 0; std::string s(macrosFile); cmSystemTools::ReplaceString(s, "/", "\\"); + std::wstring ws = cmsys::Encoding::ToWide(s); - result = RegSetValueEx(hsubkey, "Path", 0, REG_SZ, (LPBYTE) s.c_str(), - static_cast<DWORD>(strlen(s.c_str()) + 1)); + result = RegSetValueExW(hsubkey, L"Path", 0, REG_SZ, (LPBYTE)ws.c_str(), + static_cast<DWORD>(ws.size() + 1)*sizeof(wchar_t)); if (ERROR_SUCCESS != result) { std::cout << "error result 1: " << result << std::endl; @@ -741,7 +748,7 @@ void WriteVSMacrosFileRegistryEntry( // Security value is always "1" for sample macros files (seems to be "2" // if you put the file somewhere outside the standard VSMacros folder) dw = 1; - result = RegSetValueEx(hsubkey, "Security", + result = RegSetValueExW(hsubkey, L"Security", 0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD)); if (ERROR_SUCCESS != result) { @@ -751,7 +758,7 @@ void WriteVSMacrosFileRegistryEntry( // StorageFormat value is always "0" for sample macros files dw = 0; - result = RegSetValueEx(hsubkey, "StorageFormat", + result = RegSetValueExW(hsubkey, L"StorageFormat", 0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD)); if (ERROR_SUCCESS != result) { @@ -839,7 +846,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, } } } -bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget& target) +bool +cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // check to see if this is a fortran build std::set<cmStdString> languages; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index da2d021..54e3c28 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -60,7 +60,7 @@ public: const char* vsSolutionFile = 0); // return true if target is fortran only - bool TargetIsFortranOnly(cmTarget& t); + bool TargetIsFortranOnly(cmTarget const& t); /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); @@ -75,7 +75,7 @@ public: /** Return true if building for Windows CE */ virtual bool TargetsWindowsCE() const { return false; } - class TargetSet: public std::set<cmTarget*> {}; + class TargetSet: public std::set<cmTarget const*> {}; struct TargetCompare { bool operator()(cmTarget const* l, cmTarget const* r) const; @@ -96,15 +96,15 @@ protected: virtual bool ComputeTargetDepends(); class VSDependSet: public std::set<cmStdString> {}; - class VSDependMap: public std::map<cmTarget*, VSDependSet> {}; + class VSDependMap: public std::map<cmTarget const*, VSDependSet> {}; VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); bool CheckTargetLinks(cmTarget& target, const char* name); std::string GetUtilityForTarget(cmTarget& target, const char*); - virtual std::string WriteUtilityDepend(cmTarget*) = 0; - std::string GetUtilityDepend(cmTarget* target); - typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; + virtual std::string WriteUtilityDepend(cmTarget const*) = 0; + std::string GetUtilityDepend(cmTarget const* target); + typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* AdditionalPlatformDefinition; @@ -113,11 +113,12 @@ private: void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; - void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked); + void FollowLinkDepends(cmTarget const* target, + std::set<cmTarget const*>& linked); class TargetSetMap: public std::map<cmTarget*, TargetSet> {}; TargetSetMap TargetLinkClosure; - void FillLinkClosure(cmTarget* target, TargetSet& linked); + void FillLinkClosure(cmTarget const* target, TargetSet& linked); TargetSet const& GetTargetLinkClosure(cmTarget* target); }; diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 23e60a1..d5350ef 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -43,6 +43,8 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + + virtual bool AllowNotParallel() const { return false; } }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index be0459d..b5a46d0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2622,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } //---------------------------------------------------------------------------- -cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) +cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) { if(!t) { @@ -3031,23 +3031,23 @@ cmXCodeObject* cmGlobalXCodeGenerator cmStdString curr_tgt_folder; for(std::vector<std::string>::size_type i = 0; i < tgt_folders.size();i++) { - curr_tgt_folder += tgt_folders[i]; - it = this->TargetGroup.find(curr_tgt_folder); - if(it == this->TargetGroup.end()) + if (i != 0) { - tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]); - this->TargetGroup[curr_tgt_folder] = tgroup; + curr_tgt_folder += "/"; } - else + curr_tgt_folder += tgt_folders[i]; + it = this->TargetGroup.find(curr_tgt_folder); + if(it != this->TargetGroup.end()) { tgroup = it->second; continue; } + tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]); + this->TargetGroup[curr_tgt_folder] = tgroup; if(i == 0) { this->SourcesGroupChildren->AddObject(tgroup); } - curr_tgt_folder += "/"; } } this->TargetGroup[target] = tgroup; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index e8cbd14..6281c3b 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -125,7 +125,7 @@ private: multipleOutputPairs ); - cmXCodeObject* FindXCodeTarget(cmTarget*); + cmXCodeObject* FindXCodeTarget(cmTarget const*); std::string GetOrCreateId(const char* name, const char* id); // create cmXCodeObject from these functions so that memory can be managed diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 91ea861..236ca1f 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -228,11 +228,6 @@ void cmInstallCommandIncludesArgument::Parse( for ( ; it != args->end(); ++it) { std::string dir = *it; - if (!cmSystemTools::FileIsFullPath(it->c_str()) - && cmGeneratorExpression::Find(*it) == std::string::npos) - { - dir = "$<INSTALL_PREFIX>/" + dir; - } cmSystemTools::ConvertToUnixSlashes(dir); this->IncludeDirs.push_back(dir); } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7b9109e..68f45a6 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -328,9 +328,10 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const } //---------------------------------------------------------------------------- -std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, - const char* config, - NameType nameType) +std::string +cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, + const char* config, + NameType nameType) { std::string fname; // Compute the name of the library. @@ -515,11 +516,12 @@ cmInstallTargetGenerator std::map<cmStdString, cmStdString> install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { - std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked(); - for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin(); + std::set<cmTarget const*> const& sharedLibs + = cli->GetSharedLibrariesLinked(); + for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin(); j != sharedLibs.end(); ++j) { - cmTarget* tgt = *j; + cmTarget const* tgt = *j; // The install_name of an imported target does not change. if(tgt->IsImported()) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..18c3957 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -53,7 +53,8 @@ public: NameReal }; - static std::string GetInstallFilename(cmTarget*target, const char* config, + static std::string GetInstallFilename(cmTarget const* target, + const char* config, NameType nameType = NameNormal); cmTarget* GetTarget() const { return this->Target; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index d26d6e9..402855c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -261,6 +261,10 @@ void cmLocalGenerator::TraceDependencies() for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { + if (t->second->Target->IsImported()) + { + continue; + } t->second->TraceDependencies(); } } @@ -545,6 +549,10 @@ void cmLocalGenerator::GenerateTargetManifest() { continue; } + if (target.Target->IsImported()) + { + continue; + } if(configNames.empty()) { target.GenerateTargetManifest(0); @@ -807,6 +815,7 @@ static const char* ruleReplaceVars[] = "CMAKE_CURRENT_BINARY_DIR", "CMAKE_RANLIB", "CMAKE_LINKER", + "CMAKE_CL_SHOWINCLUDES_PREFIX", 0 }; @@ -1385,7 +1394,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, - cmTarget* target, + cmTarget const* target, const char* config) { std::vector<std::string> targetDefines; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 21700e9..ad662d5 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -224,8 +224,9 @@ public: bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, const char* lang, const char* config); - void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target, - const char* config); + void AddCompileDefinitions(std::set<std::string>& defines, + cmTarget const* target, + const char* config); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); @@ -266,6 +267,7 @@ public: const char* Defines; const char* RuleLauncher; const char* DependencyFile; + const char* FilterPrefix; }; /** Set whether to treat conversions to SHELL as a link script shell. */ diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 5ada88d..20e8eea 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -388,9 +388,13 @@ void cmLocalUnixMakefileGenerator3 (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY)) { + if (t->second->Target->IsImported()) + { + continue; + } + emitted.insert(t->second->GetName()); // for subdirs add a rule to build this specific target by name. @@ -1681,6 +1685,17 @@ void cmLocalUnixMakefileGenerator3 "default_target", depends, no_commands, true); + + // Help out users that try "gmake target1 target2 -j". + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); + if(gg->AllowNotParallel()) + { + std::vector<std::string> no_depends; + this->WriteMakeRule(ruleFileStream, + "Allow only one \"make -f Makefile2\" at a time, but pass parallelism.", + ".NOTPARALLEL", no_depends, no_commands, true); + } } this->WriteSpecialTargetsTop(ruleFileStream); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 2fd1016..14832e5 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -2224,7 +2224,7 @@ static bool cmLVS6G_IsFAT(const char* dir) char volRoot[4] = "_:/"; volRoot[0] = dir[0]; char fsName[16]; - if(GetVolumeInformation(volRoot, 0, 0, 0, 0, 0, fsName, 16) && + if(GetVolumeInformationA(volRoot, 0, 0, 0, 0, 0, fsName, 16) && strstr(fsName, "FAT") != 0) { return true; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 35818ee..399b582 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -85,9 +85,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() case cmTarget::OBJECT_LIBRARY: this->WriteObjectLibraryRules(); break; - case cmTarget::INTERFACE_LIBRARY: - // Nothing to do. - break; default: // If language is not known, this is an error. cmSystemTools::Error("Unknown Library Type"); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2063a24..6e70285 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -76,7 +76,6 @@ cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt) case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: - case cmTarget::INTERFACE_LIBRARY: result = new cmMakefileLibraryTargetGenerator(tgt); break; case cmTarget::UTILITY: diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index b9b469c..0b3018e 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -306,6 +306,11 @@ cmPolicies::cmPolicies() CMP0040, "CMP0040", "The target in the TARGET signature of add_custom_command() must exist.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0041, "CMP0041", + "Error on relative include with generator expression.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 6834121..245ec4b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -94,6 +94,7 @@ public: CMP0039, ///< Utility targets may not have link dependencies CMP0040, ///< The target in the TARGET signature of /// add_custom_command() must exist. + CMP0041, ///< Error on relative include with generator expression /** \brief Always the last entry. * diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a7d20ae..a561aab 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -138,14 +138,14 @@ cmQtAutoGenerators::cmQtAutoGenerators() } } -static std::string getAutogenTargetName(cmTarget *target) +static std::string getAutogenTargetName(cmTarget const* target) { std::string autogenTargetName = target->GetName(); autogenTargetName += "_automoc"; return autogenTargetName; } -static std::string getAutogenTargetDir(cmTarget *target) +static std::string getAutogenTargetDir(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); std::string targetDir = makefile->GetCurrentOutputDirectory(); @@ -221,6 +221,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) if (target->GetPropertyAsBool("AUTORCC")) { toolNames.push_back("rcc"); + this->InitializeAutoRccTarget(target); } std::string tools = toolNames[0]; @@ -295,7 +296,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) return true; } -static void GetCompileDefinitionsAndDirectories(cmTarget *target, +static void GetCompileDefinitionsAndDirectories(cmTarget const* target, const char * config, std::string &incs, std::string &defs) @@ -303,10 +304,12 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, cmMakefile* makefile = target->GetMakefile(); cmLocalGenerator* localGen = makefile->GetLocalGenerator(); std::vector<std::string> includeDirs; - cmGeneratorTarget gtgt(target); + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); // Get the include dirs for this target, without stripping the implicit // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 - localGen->GetIncludeDirectories(includeDirs, >gt, "CXX", config, false); + localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); const char* sep = ""; incs = ""; for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin(); @@ -332,7 +335,7 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, } } -void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) +void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); @@ -365,6 +368,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) std::map<std::string, std::string> configIncludes; std::map<std::string, std::string> configDefines; + std::map<std::string, std::string> configUicOptions; if (target->GetPropertyAsBool("AUTOMOC")) { @@ -373,7 +377,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) } if (target->GetPropertyAsBool("AUTOUIC")) { - this->SetupAutoUicTarget(target); + this->SetupAutoUicTarget(target, configUicOptions); } if (target->GetPropertyAsBool("AUTORCC")) { @@ -388,7 +392,9 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), false, true, false); - if (!configDefines.empty() || !configIncludes.empty()) + if (!configDefines.empty() + || !configIncludes.empty() + || !configUicOptions.empty()) { std::ofstream infoFile(outputFile.c_str(), std::ios::app); if ( !infoFile ) @@ -419,10 +425,20 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) " " << it->second << ")\n"; } } + if (!configUicOptions.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configUicOptions.begin(), end = configUicOptions.end(); + it != end; ++it) + { + infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << + " " << it->second << ")\n"; + } + } } } -void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target, +void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines) @@ -513,7 +529,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target, config_moc_compile_defs); if (config_moc_incs != _moc_incs) { - configIncludes["_moc_incs_" + *li] = + configIncludes[*li] = cmLocalGenerator::EscapeForCMake(config_moc_incs.c_str()); if(_moc_incs.empty()) { @@ -522,7 +538,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target, } if (config_moc_compile_defs != _moc_compile_defs) { - configDefines["_moc_compile_defs_" + *li] = + configDefines[*li] = cmLocalGenerator::EscapeForCMake(config_moc_compile_defs.c_str()); if(_moc_compile_defs.empty()) { @@ -565,6 +581,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, "translate", "postfix", "generator", + "include", // Since Qt 5.3 "g" }; std::vector<std::string> extraOpts; @@ -600,7 +617,25 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target) +static void GetUicOpts(cmTarget const* target, const char * config, + std::string &optString) +{ + std::vector<std::string> opts; + target->GetAutoUicOptions(opts, config); + + const char* sep = ""; + for(std::vector<std::string>::const_iterator optIt = opts.begin(); + optIt != opts.end(); + ++optIt) + { + optString += sep; + sep = ";"; + optString += *optIt; + } +} + +void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, + std::map<std::string, std::string> &configUicOptions) { cmMakefile *makefile = target->GetMakefile(); @@ -649,10 +684,30 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target) const char *qtVersion = makefile->GetDefinition("_target_qt_version"); - if (const char* opts = target->GetProperty("AUTOUIC_OPTIONS")) + std::string _uic_opts; + std::vector<std::string> configs; + const char *config = makefile->GetConfigurations(configs); + GetUicOpts(target, config, _uic_opts); + + if (!_uic_opts.empty()) { - makefile->AddDefinition("_uic_target_options", - cmLocalGenerator::EscapeForCMake(opts).c_str()); + _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts.c_str()); + makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); + } + for (std::vector<std::string>::const_iterator li = configs.begin(); + li != configs.end(); ++li) + { + std::string config_uic_opts; + GetUicOpts(target, li->c_str(), config_uic_opts); + if (config_uic_opts != _uic_opts) + { + configUicOptions[*li] = + cmLocalGenerator::EscapeForCMake(config_uic_opts.c_str()); + if(_uic_opts.empty()) + { + _uic_opts = config_uic_opts; + } + } } for(std::vector<cmSourceFile*>::const_iterator fileIt = @@ -749,14 +804,47 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) +void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) +{ + cmMakefile *makefile = target->GetMakefile(); + + const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + target->AddSourceFile(rccCppSource); + } + } + } +} + +void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) { std::string _rcc_files; const char* sepRccFiles = ""; cmMakefile *makefile = target->GetMakefile(); - std::vector<cmSourceFile*> newFiles; - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); std::string rccFileFiles; @@ -789,17 +877,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) _rcc_files += absFile; sepRccFiles = ";"; - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); - newFiles.push_back(rccCppSource); - if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) { std::vector<std::string> optsVec; @@ -828,13 +905,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) } } - for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); - fileIt != newFiles.end(); - ++fileIt) - { - target->AddSourceFile(*fileIt); - } - makefile->AddDefinition("_rcc_files", cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); @@ -971,9 +1041,19 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, { const char *uicOptionsFiles = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"); + std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS"; + std::string uicOptionsProp = uicOptionsPropOrig; + if(config) + { + uicOptionsProp += "_"; + uicOptionsProp += config; + } const char *uicTargetOptions - = makefile->GetSafeDefinition("AM_UIC_TARGET_OPTIONS"); - cmSystemTools::ExpandListArgument(uicTargetOptions, this->UicTargetOptions); + = makefile->GetSafeDefinition(uicOptionsProp.c_str()); + cmSystemTools::ExpandListArgument( + uicTargetOptions ? uicTargetOptions + : makefile->GetSafeDefinition(includesPropOrig.c_str()), + this->UicTargetOptions); const char *uicOptionsOptions = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"); std::vector<std::string> uicFilesVec; @@ -1299,18 +1379,18 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) if (this->RunMocFailed) { - std::cerr << "moc failed..."<< std::endl; + std::cerr << "moc failed..." << std::endl; return false; } if (this->RunUicFailed) { - std::cerr << "uic failed..."<< std::endl; + std::cerr << "uic failed..." << std::endl; return false; } if (this->RunRccFailed) { - std::cerr << "rcc failed..."<< std::endl; + std::cerr << "rcc failed..." << std::endl; return false; } outStream.flush(); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 116f174..80123d8 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -24,15 +24,17 @@ public: bool Run(const char* targetDirectory, const char *config); bool InitializeAutogenTarget(cmTarget* target); - void SetupAutoGenerateTarget(cmTarget* target); + void SetupAutoGenerateTarget(cmTarget const* target); private: - void SetupAutoMocTarget(cmTarget* target, + void SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines); - void SetupAutoUicTarget(cmTarget* target); - void SetupAutoRccTarget(cmTarget* target); + void SetupAutoUicTarget(cmTarget const* target, + std::map<std::string, std::string> &configUicOptions); + void InitializeAutoRccTarget(cmTarget* target); + void SetupAutoRccTarget(cmTarget const* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, const char* targetDirectory); diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 7369fe6..eb6e52f 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -423,19 +423,19 @@ struct cmStrCmp { cmStrCmp(const char *test) : m_test(test) {} cmStrCmp(std::string &test) : m_test(test.c_str()) {} - bool operator()(const char * input) + bool operator()(const char * input) const { return strcmp(input, m_test) == 0; } // For use with binary_search - bool operator()(const char *str1, const char *str2) + bool operator()(const char *str1, const char *str2) const { return strcmp(str1, str2) < 0; } private: - const char *m_test; + const char * const m_test; }; #endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b3dbd05..b8163c8 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -25,6 +25,7 @@ #include <cmsys/RegularExpression.hxx> #include <cmsys/Directory.hxx> #include <cmsys/System.h> +#include <cmsys/Encoding.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmArchiveWrite.h" # include <cm_libarchive.h> @@ -880,19 +881,23 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) Try multiple times since we may be racing against another process creating/opening the destination file just before our MoveFileEx. */ int tries = 5; - while(!MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) && --tries) + while(!MoveFileExW(cmsys::Encoding::ToWide(oldname).c_str(), + cmsys::Encoding::ToWide(newname).c_str(), + MOVEFILE_REPLACE_EXISTING) && --tries) { // Try again only if failure was due to access permissions. if(GetLastError() != ERROR_ACCESS_DENIED) { return false; } - DWORD attrs = GetFileAttributes(newname); + DWORD attrs = + GetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str()); if((attrs != INVALID_FILE_ATTRIBUTES) && (attrs & FILE_ATTRIBUTE_READONLY)) { // Remove the read-only attribute from the destination file. - SetFileAttributes(newname, attrs & ~FILE_ATTRIBUTE_READONLY); + SetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str(), + attrs & ~FILE_ATTRIBUTE_READONLY); } else { @@ -1884,10 +1889,12 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle hFrom = - CreateFile(fromFile, GENERIC_READ, FILE_SHARE_READ, 0, - OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(fromFile).c_str(), + GENERIC_READ, FILE_SHARE_READ, 0, + OPEN_EXISTING, 0, 0); cmSystemToolsWindowsHandle hTo = - CreateFile(toFile, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(toFile).c_str(), + GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!hFrom || !hTo) { return false; @@ -1938,7 +1945,8 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if(!h) { return false; @@ -1964,7 +1972,8 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFile(fname, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!h) { return false; @@ -2059,9 +2068,10 @@ 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)); - exe_dir = cmSystemTools::GetFilenamePath(modulepath); + wchar_t modulepath[_MAX_PATH]; + ::GetModuleFileNameW(NULL, modulepath, sizeof(modulepath)); + exe_dir = + cmSystemTools::GetFilenamePath(cmsys::Encoding::ToNarrow(modulepath)); #elif defined(__APPLE__) (void)argv0; // ignore this on OS X # define CM_EXE_PATH_LOCAL_SIZE 16384 diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2423b27..a0177fb 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -828,7 +828,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config, //---------------------------------------------------------------------------- void cmTarget::GetInterfaceLinkLibraries(const char *config, - std::vector<std::string> &libs, cmTarget *head) const + std::vector<std::string> &libs, + cmTarget const* head) const { const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (prop) @@ -1058,7 +1059,7 @@ void cmTarget::FinalizeSystemIncludeDirectories() std::string targetName = cge->Evaluate(this->Makefile, 0, false, this, 0, 0); cmTarget *tgt = this->Makefile->FindTargetToUse(targetName.c_str()); - if (!tgt) + if (!tgt || tgt == this) { continue; } @@ -2043,6 +2044,32 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- +void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, + const char *config) const +{ + const char *prop + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, const char *config) const { @@ -4280,6 +4307,95 @@ const char* impliedValue<const char*>(const char*) return ""; } + +template<typename PropertyType> +std::string valueAsString(PropertyType); +template<> +std::string valueAsString<bool>(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString<const char*>(const char* value) +{ + return value ? value : "(unset)"; +} + +//---------------------------------------------------------------------------- +void +cmTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + cmListFileBacktrace lfbt; + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport, lfbt); +} + +//---------------------------------------------------------------------------- +std::string compatibilityType(CompatibleType t) +{ + switch(t) + { + case BoolType: + return "Boolean compatibility"; + case StringType: + return "String compatibility"; + case NumberMaxType: + return "Numeric maximum compatibility"; + case NumberMinType: + return "Numeric minimum compatibility"; + } + assert(!"Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(CompatibleType t, bool dominant) +{ + switch(t) + { + case BoolType: + case StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case NumberMaxType: + case NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(!"Unreachable!"); + return ""; +} + //---------------------------------------------------------------------------- template<typename PropertyType> PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, @@ -4307,6 +4423,23 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); bool propInitialized = explicitlySet; + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString<PropertyType>(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + for(cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin(); li != deps.end(); ++li) @@ -4328,12 +4461,25 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, PropertyType ifacePropContent = getTypedProperty<PropertyType>(li->Target, ("INTERFACE_" + p).c_str(), 0); + + std::string reportEntry; + if (ifacePropContent) + { + reportEntry += " * Target \""; + reportEntry += li->Target->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString<PropertyType>(ifacePropContent); + reportEntry += "\" "; + } + if (explicitlySet) { if (ifaceIsSet) { PropertyType consistent = consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent); if (!consistent) { cmOStringStream e; @@ -4346,7 +4492,6 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - // Agree propContent = consistent; continue; } @@ -4360,10 +4505,19 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, else if (impliedByUse) { propContent = impliedValue<PropertyType>(propContent); + + reportEntry += " * Target \""; + reportEntry += li->Target->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString<PropertyType>(propContent); + reportEntry += "\" "; + if (ifaceIsSet) { PropertyType consistent = consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent); if (!consistent) { cmOStringStream e; @@ -4377,7 +4531,6 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - // Agree propContent = consistent; continue; } @@ -4396,6 +4549,8 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { PropertyType consistent = consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent); if (!consistent) { cmOStringStream e; @@ -4408,13 +4563,13 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - // Agree. propContent = consistent; continue; } } else { + report += reportEntry + "(Interface set)\n"; propContent = ifacePropContent; propInitialized = true; } @@ -4426,6 +4581,9 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } } } + + tgt->ReportPropertyOrigin(p, valueAsString<PropertyType>(propContent), + report, compatibilityType(t)); return propContent; } @@ -4539,7 +4697,8 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, { return false; } - return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", + return (p == "AUTOUIC_OPTIONS") || + isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", config); } @@ -4702,6 +4861,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** imp, std::string& suffix) const { + if (this->GetType() == INTERFACE_LIBRARY) + { + // This method attempts to find a config-specific LOCATION for the + // IMPORTED library. In the case of INTERFACE_LIBRARY, there is no + // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate + // and valid response. + return true; + } + // Track the configuration-specific property suffix. suffix = "_"; suffix += desired_config; @@ -4834,8 +5002,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, const char* loc = 0; const char* imp = 0; std::string suffix; - if (this->GetType() != INTERFACE_LIBRARY && - !this->GetMappedConfig(desired_config, &loc, &imp, suffix)) + if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix)) { return; } @@ -5447,7 +5614,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, { e << "Target \"" << this->GetName() << "\" links to target \"" << item << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or a ALIAS target is " + "call is missing for an IMPORTED target, or an ALIAS target is " "missing?"; this->Makefile->GetCMakeInstance()->IssueMessage(messageType, e.str(), @@ -5604,7 +5771,8 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template<typename PropertyType> -void checkPropertyConsistency(cmTarget const* depender, cmTarget *dependee, +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, const char *propName, std::set<cmStdString> &emitted, const char *config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 35ec680..bf4a8ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -25,7 +25,8 @@ F(CMP0008) \ F(CMP0020) \ F(CMP0021) \ - F(CMP0022) + F(CMP0022) \ + F(CMP0041) class cmake; class cmMakefile; @@ -186,7 +187,7 @@ public: cmTarget const* head) const; void GetInterfaceLinkLibraries(const char *config, std::vector<std::string> &, - cmTarget *head) const; + cmTarget const* head) const; /** Compute the link type to use for the given configuration. */ LinkLibraryType ComputeLinkType(const char* config) const; @@ -532,6 +533,8 @@ public: void GetCompileOptions(std::vector<std::string> &result, const char *config) const; + void GetAutoUicOptions(std::vector<std::string> &result, + const char *config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, @@ -566,6 +569,11 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: bool HandleLocationPropertyPolicy() const; @@ -688,6 +696,7 @@ private: bool IsApple; bool IsImportedTarget; mutable bool DebugIncludesDone; + mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable std::set<std::string> LinkImplicitNullProperties; diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h index 258bacd..1feb072 100644 --- a/Source/cmTargetDepend.h +++ b/Source/cmTargetDepend.h @@ -20,17 +20,17 @@ class cmTarget; It may be marked as a 'link' or 'util' edge or both. */ class cmTargetDepend { - cmTarget* Target; + cmTarget const* Target; // The set order depends only on the Target, so we use // mutable members to acheive a map with set syntax. mutable bool Link; mutable bool Util; public: - cmTargetDepend(cmTarget* t): Target(t), Link(false), Util(false) {} - operator cmTarget*() const { return this->Target; } - cmTarget* operator->() const { return this->Target; } - cmTarget& operator*() const { return *this->Target; } + cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {} + operator cmTarget const*() const { return this->Target; } + cmTarget const* operator->() const { return this->Target; } + cmTarget const& operator*() const { return *this->Target; } friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r) { return l.Target < r.Target; } void SetType(bool strong) const diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index e7b906c..913bdab 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -50,7 +50,7 @@ std::string cmTargetIncludeDirectoriesCommand it != content.end(); ++it) { if (cmSystemTools::FileIsFullPath(it->c_str()) - || cmGeneratorExpression::Find(*it) != std::string::npos) + || cmGeneratorExpression::Find(*it) == 0) { dirs += sep + *it; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 10663b7..b9ae701 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1841,7 +1841,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() for( OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { - cmTarget* dt = *i; + cmTarget const* dt = *i; if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index bf27c78..741e263 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -73,6 +73,7 @@ # include "cmExtraCodeBlocksGenerator.h" #endif #include "cmExtraSublimeTextGenerator.h" +#include "cmExtraKateGenerator.h" #ifdef CMAKE_USE_KDEVELOP # include "cmGlobalKdevelopGenerator.h" @@ -991,6 +992,8 @@ void cmake::AddDefaultExtraGenerators() &cmExtraCodeBlocksGenerator::New); this->AddExtraGenerator(cmExtraSublimeTextGenerator::GetActualName(), &cmExtraSublimeTextGenerator::New); + this->AddExtraGenerator(cmExtraKateGenerator::GetActualName(), + &cmExtraKateGenerator::New); #ifdef CMAKE_USE_ECLIPSE this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(), diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 8571557..0675470 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -23,6 +23,7 @@ #include <windows.h> #include <sstream> #include <cmSystemTools.h> +#include <cmsys/Encoding.hxx> // We don't want any wildcard expansion. // See http://msdn.microsoft.com/en-us/library/zay8tzh6(v=vs.85).aspx @@ -100,7 +101,7 @@ static std::string getArg(std::string& cmdline) { return ret; } -static void parseCommandLine(LPTSTR wincmdline, +static void parseCommandLine(LPWSTR wincmdline, std::string& lang, std::string& srcfile, std::string& dfile, @@ -109,7 +110,7 @@ static void parseCommandLine(LPTSTR wincmdline, std::string& clpath, std::string& binpath, std::string& rest) { - std::string cmdline(wincmdline); + std::string cmdline = cmsys::Encoding::ToNarrow(wincmdline); /* self */ getArg(cmdline); lang = getArg(cmdline); srcfile = getArg(cmdline); @@ -247,7 +248,7 @@ int main() { // the same command line verbatim. std::string lang, srcfile, dfile, objfile, prefix, cl, binpath, rest; - parseCommandLine(GetCommandLine(), lang, srcfile, dfile, objfile, + parseCommandLine(GetCommandLineW(), lang, srcfile, dfile, objfile, prefix, cl, binpath, rest); // needed to suppress filename output of msvc tools diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index d4f464c..d3b7b5f 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1294,7 +1294,8 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, // to do the final link. If mt has any value other than 0 or 1090650113 // then there was some problem with the command itself and there was an // error so return the error code back out of cmake so make can report it. - if(mtRet != 1090650113) + // (when hosted on a posix system the value is 187) + if(mtRet != 1090650113 && mtRet != 187) { return mtRet; } diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c index a36eecc..cda78e2 100644 --- a/Source/kwsys/EncodingC.c +++ b/Source/kwsys/EncodingC.c @@ -68,7 +68,7 @@ size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* str, size_t n) char* kwsysEncoding_DupToNarrow(const wchar_t* str) { char* ret = NULL; - size_t length = kwsysEncoding_wcstombs(0, str, 0); + size_t length = kwsysEncoding_wcstombs(0, str, 0) + 1; if(length > 0) { ret = malloc(length); diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in index 8170fb3..c340c55 100644 --- a/Source/kwsys/FStream.hxx.in +++ b/Source/kwsys/FStream.hxx.in @@ -81,7 +81,7 @@ namespace @KWSYS_NAMESPACE@ internal_buffer_type *rdbuf() const { - return buf_.get(); + return buf_; } ~basic_ifstream() diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index b9af2f1..faeb967 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -2449,6 +2449,7 @@ static void kwsysProcessKill(pid_t process_id) if(f) { size_t nread = fread(buffer, 1, KWSYSPE_PIPE_BUFFER_SIZE, f); + fclose(f); buffer[nread] = '\0'; if(nread > 0) { @@ -2463,7 +2464,6 @@ static void kwsysProcessKill(pid_t process_id) } } } - fclose(f); } } } diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 2f6c949..5f20853 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -3162,8 +3162,17 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() kwsys_stl::string cores = this->ExtractValueFromCpuInfoFile(buffer,"cpu cores"); int numberOfCoresPerCPU=atoi(cores.c_str()); - this->NumberOfPhysicalCPU=static_cast<unsigned int>( - numberOfCoresPerCPU*(maxId+1)); + if (maxId > 0) + { + this->NumberOfPhysicalCPU=static_cast<unsigned int>( + numberOfCoresPerCPU*(maxId+1)); + } + else + { + // Linux Sparc: get cpu count + this->NumberOfPhysicalCPU= + atoi(this->ExtractValueFromCpuInfoFile(buffer,"ncpus active").c_str()); + } #else // __CYGWIN__ // does not have "physical id" entries, neither "cpu cores" @@ -3185,7 +3194,19 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() // CPU speed (checking only the first processor) kwsys_stl::string CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"cpu MHz"); - this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str())); + if(!CPUSpeed.empty()) + { + this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str())); + } +#ifdef __linux + else + { + // Linux Sparc: CPU speed is in Hz and encoded in hexadecimal + CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"Cpu0ClkTck"); + this->CPUSpeedInMHz = static_cast<float>( + strtoull(CPUSpeed.c_str(),0,16))/1000000.0f; + } +#endif // Chip family kwsys_stl::string familyStr = @@ -4991,7 +5012,12 @@ bool SystemInformationImplementation::QueryHPUXProcessor() case CPU_PA_RISC2_0: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x200; +# ifdef CPU_HP_INTEL_EM_1_0 + case CPU_HP_INTEL_EM_1_0: +# endif +# ifdef CPU_IA64_ARCHREV_0 case CPU_IA64_ARCHREV_0: +# endif this->ChipID.Vendor = "GenuineIntel"; this->Features.HasIA64 = true; break; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 4649f3b..f4a443f 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2115,10 +2115,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) SystemTools::RemoveFile(destination); #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ofstream fout(destination, + kwsys::ofstream fout(destination, kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc); #else - kwsys_ios::ofstream fout(destination, + kwsys::ofstream fout(destination, kwsys_ios::ios::out | kwsys_ios::ios::trunc); #endif if(!fout) diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx index 8e74a50..a65c430 100644 --- a/Source/kwsys/testEncoding.cxx +++ b/Source/kwsys/testEncoding.cxx @@ -16,14 +16,18 @@ #endif #include KWSYS_HEADER(Encoding.hxx) +#include KWSYS_HEADER(Encoding.h) #include KWSYS_HEADER(ios/iostream) #include <locale.h> +#include <string.h> +#include <stdlib.h> // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 # include "Encoding.hxx.in" +# include "Encoding.h.in" # include "kwsys_ios_iostream.h.in" #endif @@ -68,11 +72,16 @@ static int testHelloWorldEncoding() std::cout << str << std::endl; std::wstring wstr = kwsys::Encoding::ToWide(str); std::string str2 = kwsys::Encoding::ToNarrow(wstr); - if(!wstr.empty() && str != str2) + wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str()); + char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr); + if(!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()))) { std::cout << "converted string was different: " << str2 << std::endl; + std::cout << "converted string was different: " << c_str2 << std::endl; ret++; } + free(c_wstr); + free(c_str2); } return ret; } diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index 21b8e15..8a564c7 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -45,7 +45,8 @@ add_executable(consumer target_include_directories(consumer PRIVATE $<TARGET_PROPERTY:target_include_directories,INTERFACE_INCLUDE_DIRECTORIES> - relative_dir + relative_dir + relative_dir/$<TARGET_PROPERTY:NAME> ) # Test no items diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 82b800a..7e3443e 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -3,6 +3,7 @@ #include "publicinclude.h" #include "interfaceinclude.h" #include "relative_dir.h" +#include "consumer.h" #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -24,4 +25,8 @@ #error Expected RELATIVE_DIR_DEFINE #endif +#ifndef CONSUMER_DEFINE +#error Expected CONSUMER_DEFINE +#endif + int main() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/relative_dir/consumer/consumer.h b/Tests/CMakeCommands/target_include_directories/relative_dir/consumer/consumer.h new file mode 100644 index 0000000..b915373 --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/relative_dir/consumer/consumer.h @@ -0,0 +1,2 @@ + +#define CONSUMER_DEFINE diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index f7a320a..5ea604f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -285,24 +285,6 @@ if(BUILD_TESTING) PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)") endif() - if(CMAKE_TEST_GENERATOR MATCHES Make) - set(InterfaceBuildTargets_libname testlib) - if (CMAKE_TEST_GENERATOR MATCHES "Borland|Watcom") - set(InterfaceBuildTargets_libname testlib.lib) - endif() - add_test(InterfaceBuildTargets ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/InterfaceBuildTargets" - "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets" - --build-two-config - ${build_generator_args} - --build-project InterfaceBuildTargets - --build-options ${build_options} - --test-command ${CMAKE_CMAKE_COMMAND} -E touch_nocreate ${InterfaceBuildTargets_libname} - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets") - endif() - list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) if(NOT QT4_FOUND) @@ -1081,8 +1063,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # on that platform. if(WIN32) set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V) + set(run_autouic_test ${CMAKE_CTEST_COMMAND} -V) else() set(run_autogen_test QtAutogen) + set(run_autouic_test QtAutoUicInterface) endif() find_package(Qt5Widgets QUIET NO_MODULE) @@ -1100,6 +1084,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command ${run_autogen_test} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen") + + add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" + "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface" + ${build_generator_args} + --build-project QtAutoUicInterface + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface" + --force-new-ctest-process + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 + --test-command ${run_autouic_test} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface") endif() if(QT4_WORKS AND QT_QTGUI_FOUND) add_test(Qt4Autogen ${CMAKE_CTEST_COMMAND} @@ -1116,6 +1114,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen") + add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" + "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface" + ${build_generator_args} + --build-project QtAutoUicInterface + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface" + --force-new-ctest-process + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 + --test-command ${run_autouic_test} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface") + add_test(Qt4Targets ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Qt4Targets" diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt index b54925a..0b06045 100644 --- a/Tests/CPackWiXGenerator/CMakeLists.txt +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -14,11 +14,16 @@ install(TARGETS mylib DESTINATION lib COMPONENT libraries) -install(TARGETS my-libapp my-other-app +install(TARGETS my-libapp RUNTIME DESTINATION bin COMPONENT applications) +install(TARGETS my-other-app + RUNTIME + DESTINATION bin + COMPONENT applications2) + install(FILES mylib.h "file with spaces.h" DESTINATION include COMPONENT headers) @@ -44,6 +49,8 @@ set(CPACK_PACKAGE_EXECUTABLES "my-other-app" "Second CPack WiX Test" ) +set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml") + include(CPack) cpack_add_install_type(Full DISPLAY_NAME "Everything") @@ -56,11 +63,18 @@ cpack_add_component_group(Development DESCRIPTION "All of the tools you'll ever need to develop software") cpack_add_component(applications + REQUIRED DISPLAY_NAME "MyLib Application" DESCRIPTION "An extremely useful application that makes use of MyLib" GROUP Runtime INSTALL_TYPES Full) +cpack_add_component(applications2 + DISPLAY_NAME "MyLib Extra Application" + DESCRIPTION "Another extremely useful application that makes use of MyLib" + GROUP Runtime + INSTALL_TYPES Full) + cpack_add_component(documentation DISPLAY_NAME "MyLib Documentation" DESCRIPTION "The extensive suite of MyLib Application documentation files" diff --git a/Tests/CPackWiXGenerator/patch.xml b/Tests/CPackWiXGenerator/patch.xml new file mode 100644 index 0000000..13c392d --- /dev/null +++ b/Tests/CPackWiXGenerator/patch.xml @@ -0,0 +1,7 @@ +<CPackWiXPatch> + <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe"> + <Environment Id="MyEnvironment" Action="set" + Name="CPackWiXGeneratorTest" + Value="CPackWiXGeneratorTest"/> + </CPackWiXFragment> +</CPackWiXPatch> diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index b5162c9..9bd7249 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -1,5 +1,13 @@ REGEX_ESCAPE_STRING(CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") +get_filename_component(CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR + "${CMAKE_CURRENT_BINARY_DIR}" REALPATH +) + +REGEX_ESCAPE_STRING(CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR + "${CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR}" +) + foreach (_retval 0 1) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY) endforeach () @@ -180,7 +188,7 @@ set_tests_properties(CTestTestMemcheckDummyBC PROPERTIES PASS_REGULAR_EXPRESSION "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+.[0-9]+ sec\n\n100% tests passed, 0 tests failed out of 1\n(.*\n)?Error parsing XML in stream at line 1: no element found\n") set_tests_properties(CTestTestMemcheckDummyValgrindInvalidSupFile PROPERTIES - PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n") + PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n") set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/Testing/Temporary/MemoryChecker.1.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/test.cmake\n") diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index 8186c61..5e64d2a 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -31,6 +31,13 @@ set_property(TARGET iface1 APPEND PROPERTY NUMBER_MAX_PROP2 ) +set(CMAKE_DEBUG_TARGET_PROPERTIES + BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 BOOL_PROP4 + STRING_PROP1 STRING_PROP2 STRING_PROP3 + NUMBER_MIN_PROP1 NUMBER_MIN_PROP2 + NUMBER_MAX_PROP1 NUMBER_MAX_PROP2 +) + set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1) diff --git a/Tests/Contracts/VTK/CMakeLists.txt b/Tests/Contracts/VTK/CMakeLists.txt new file mode 100644 index 0000000..ef19325 --- /dev/null +++ b/Tests/Contracts/VTK/CMakeLists.txt @@ -0,0 +1,47 @@ +# The VTK external project for CMake +# --------------------------------------------------------------------------- +cmake_minimum_required(VERSION 2.8) +project(VTK) +include(ExternalProject) + +# find "HOME". VTK will be downloaded & built within a subdirectory. +if(NOT DEFINED HOME) + if(DEFINED ENV{CTEST_REAL_HOME}) + set(HOME "$ENV{CTEST_REAL_HOME}") + else() + set(HOME "$ENV{HOME}") + endif() + + if(NOT HOME AND WIN32) + # Try for USERPROFILE as HOME equivalent: + string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}") + + # But just use root of SystemDrive if USERPROFILE contains any spaces: + # (Default on XP and earlier...) + if(HOME MATCHES " ") + string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}") + endif() + endif() +endif() + +set(base_dir "${HOME}/.cmake/Contracts/VTK") + +if(NOT DEFINED SITE) + site_name(SITE) +endif() + +# configure our dashboard script +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in + ${base_dir}/Dashboard.cmake + @ONLY) + +# build & test VTK's release branch +ExternalProject_Add(${PROJECT_NAME} + GIT_REPOSITORY "git://vtk.org/VTK.git" + GIT_TAG "release" + PREFIX ${base_dir} + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_CTEST_COMMAND} -S "${base_dir}/Dashboard.cmake" + INSTALL_COMMAND "" +) diff --git a/Tests/Contracts/VTK/Dashboard.cmake.in b/Tests/Contracts/VTK/Dashboard.cmake.in new file mode 100644 index 0000000..c3d10f4 --- /dev/null +++ b/Tests/Contracts/VTK/Dashboard.cmake.in @@ -0,0 +1,37 @@ +# This submission's role is to test leading edge of cmake development +# against VTK release +# +# Maintainer: Zack Galbreath <zack.galbreath@kitware.com> +# +# This file was generated as part of the CMake/VTK Contracts test. +# See <CMake-src>/Tests/Contracts/VTK/ for more information + +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "Contracts.VTK") +set(CTEST_DASHBOARD_ROOT "@base_dir@") +set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/src/VTK") +set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/VTK-build") + +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CONFIGURATION_TYPE Debug) +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +# Assume a Linux build, with a make that supports -j9. Modify this script if +# assumption is ever invalid. +# +set(CTEST_BUILD_COMMAND "@CMAKE_MAKE_PROGRAM@ -j9 -i") + +ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) + +file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " + BUILD_EXAMPLES:BOOL=ON + BUILD_TESTING:BOOL=ON + VTK_WRAP_PYTHON:BOOL=ON + ExternalData_OBJECT_STORES:FILEPATH=@base_dir@/ExternalData +") + +ctest_start(Nightly) +ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}") +ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}") +ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" INCLUDE "PythonSmoke") +ctest_submit(BUILD "${CTEST_BINARY_DIRECTORY}") diff --git a/Tests/Contracts/VTK/RunTest.cmake b/Tests/Contracts/VTK/RunTest.cmake new file mode 100644 index 0000000..65285cf --- /dev/null +++ b/Tests/Contracts/VTK/RunTest.cmake @@ -0,0 +1,3 @@ +set(exe "$ENV{HOME}/.cmake/Contracts/VTK/VTK-build/bin/vtkCommonCoreCxxTests") +set(args otherArrays) +set(VTK_RUN_TEST ${exe} ${args}) diff --git a/Tests/Contracts/vtk542/CMakeLists.txt b/Tests/Contracts/vtk542/CMakeLists.txt deleted file mode 100644 index cfb8b16..0000000 --- a/Tests/Contracts/vtk542/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# The VTK external project for CMake -# --------------------------------------------------------------------------- -cmake_minimum_required(VERSION 2.8) -project(vtk542) -include(ExternalProject) - - -set(vtk_source "${CMAKE_CURRENT_BINARY_DIR}/VTK-source") -set(vtk_binary "${CMAKE_CURRENT_BINARY_DIR}/VTK-build") - -ExternalProject_Add(VTK - DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} - URL "http://www.vtk.org/files/release/5.4/vtk-5.4.2.tar.gz" - URL_MD5 c2c797091d4b2128d9a1bd32c4b78227 - SOURCE_DIR ${vtk_source} - BINARY_DIR ${vtk_binary} - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_ARGS - -DBUILD_EXAMPLES:BOOL=ON - -DBUILD_TESTING:BOOL=ON - INSTALL_COMMAND "" - ) -# make it so that each build will run make in the VTK build tree -ExternalProject_Add_Step(VTK forcebuild - COMMAND ${CMAKE_COMMAND} - -E remove ${CMAKE_CURRENT_BUILD_DIR}/VTK-prefix/src/VTK-stamp/VTK-build - DEPENDEES configure - DEPENDERS build - ALWAYS 1 - ) diff --git a/Tests/Contracts/vtk542/RunTest.cmake b/Tests/Contracts/vtk542/RunTest.cmake deleted file mode 100644 index b4bd5b0..0000000 --- a/Tests/Contracts/vtk542/RunTest.cmake +++ /dev/null @@ -1 +0,0 @@ -set(vtk542_RUN_TEST VTK-build/bin/CommonCxxTests otherArrays) diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index 8be8d33..02a0371 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required (VERSION 2.7.20090711) project(ExportImport C CXX) +if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +endif() # Wipe out the install tree to make sure the exporter works. add_custom_command( diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index cbae967..0e2828e 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -311,7 +311,25 @@ install(TARGETS testLibRequired INCLUDES DESTINATION installIncludesTest $<INSTALL_PREFIX>/installIncludesTest2 - ) + installIncludesTest3/$<TARGET_PROPERTY:NAME> + $<TARGET_PROPERTY:NAME>/installIncludesTest4 + $<INSTALL_INTERFACE:installIncludesTest5$<0:>> + $<INSTALL_INTERFACE:$<0:>installIncludesTest6> + $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/installIncludesTest7> +) + +target_include_directories(testLibRequired INTERFACE + # These can't be in the above install(INCLUDES DESTINATION call because + # that is only for installed interfaces. These directories are prefixes + # in the build dir, which is an error for the installed interface. + # We add them here so that we don't have to add conditions in the Import + # component of the test. + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest5$<0:>> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/$<0:>installIncludesTest6> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest7> + $<INSTALL_INTERFACE:installIncludesTest8/$<0:>> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest8$<0:>> +) install(TARGETS testLibIncludeRequired1 testLibIncludeRequired2 @@ -334,6 +352,18 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest/installIncludesTest. file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2/installIncludesTest2.h" "// No content\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest3/testLibRequired") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest3/testLibRequired/installIncludesTest3.h" "// No content\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/testLibRequired/installIncludesTest4") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibRequired/installIncludesTest4/installIncludesTest4.h" "// No content\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest5") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest5/installIncludesTest5.h" "// No content\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest6") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest6/installIncludesTest6.h" "// No content\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest7") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest7/installIncludesTest7.h" "// No content\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest8") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest8/installIncludesTest8.h" "// No content\n") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest/installIncludesTest.h" DESTINATION installIncludesTest @@ -342,6 +372,30 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2/installIncludesTest2.h" DESTINATION installIncludesTest2 ) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest3/testLibRequired/installIncludesTest3.h" + DESTINATION installIncludesTest3/testLibRequired +) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibRequired/installIncludesTest4/installIncludesTest4.h" + DESTINATION testLibRequired/installIncludesTest4 +) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest5/installIncludesTest5.h" + DESTINATION installIncludesTest5 +) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest6/installIncludesTest6.h" + DESTINATION installIncludesTest6 +) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest7/installIncludesTest7.h" + DESTINATION installIncludesTest7 +) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest8/installIncludesTest8.h" + DESTINATION installIncludesTest8 +) install(TARGETS testLibDepends testSharedLibDepends EXPORT DependsExp DESTINATION lib ) install(EXPORT DependsExp FILE testLibDependsTargets.cmake DESTINATION lib/cmake/testLibDepends) diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c index 48a4c44..953d0ad 100644 --- a/Tests/ExportImport/Import/A/deps_iface.c +++ b/Tests/ExportImport/Import/A/deps_iface.c @@ -6,6 +6,12 @@ #include "installIncludesTest.h" #include "installIncludesTest2.h" +#include "installIncludesTest3.h" +#include "installIncludesTest4.h" +#include "installIncludesTest5.h" +#include "installIncludesTest6.h" +#include "installIncludesTest7.h" +#include "installIncludesTest8.h" #ifndef testLibRequired_IFACE_DEFINE #error Expected testLibRequired_IFACE_DEFINE diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 8f165ce..adc4308 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required (VERSION 2.6) project(testf C CXX Fortran) +if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +endif() + message("CTEST_FULL_OUTPUT ") set(CMAKE_VERBOSE_MAKEFILE 1) message("ENV_FLAGS = $ENV{FFLAGS}") diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index e0df8c2..892f80f 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -193,6 +193,9 @@ add_custom_target(check-part3 ALL -Dtest_platform_id_Linux=$<PLATFORM_ID:Linux> -Dtest_platform_id_Windows=$<PLATFORM_ID:Windows> -Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin> + -Dlower_case=$<LOWER_CASE:Mi,XeD> + -Dupper_case=$<UPPER_CASE:MiX,eD> + -Dmake_c_identifier=$<MAKE_C_IDENTIFIER:4f,oo:+bar-$> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" VERBATIM diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 93ea487..3361eeb 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -34,3 +34,6 @@ foreach(system Linux Windows Darwin) check(test_platform_id_${system} 0) endif() endforeach() +check(lower_case "mi,xed") +check(upper_case "MIX,ED") +check(make_c_identifier "_4f_oo__bar__") diff --git a/Tests/InterfaceBuildTargets/CMakeLists.txt b/Tests/InterfaceBuildTargets/CMakeLists.txt deleted file mode 100644 index a00e5d5..0000000 --- a/Tests/InterfaceBuildTargets/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -project(InterfaceBuildTargets) - -add_library(testlib EXCLUDE_FROM_ALL testlib.cxx) -set_property(TARGET testlib PROPERTY PREFIX "") -if(CMAKE_GENERATOR MATCHES "Borland|Watcom") - # These librarians add the .lib suffix anyway. - set_property(TARGET testlib PROPERTY SUFFIX ".lib") -else() - set_property(TARGET testlib PROPERTY SUFFIX "") -endif() - -add_library(iface INTERFACE) -target_link_libraries(iface INTERFACE testlib) diff --git a/Tests/InterfaceBuildTargets/main.cxx b/Tests/InterfaceBuildTargets/main.cxx deleted file mode 100644 index e9ad257..0000000 --- a/Tests/InterfaceBuildTargets/main.cxx +++ /dev/null @@ -1,5 +0,0 @@ - -int main(int, char**) -{ - return 0; -} diff --git a/Tests/InterfaceBuildTargets/testlib.cxx b/Tests/InterfaceBuildTargets/testlib.cxx deleted file mode 100644 index 02bd6b0..0000000 --- a/Tests/InterfaceBuildTargets/testlib.cxx +++ /dev/null @@ -1,5 +0,0 @@ - -void testlib(void) -{ - -} diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 53aeb03..8154ced 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -13,3 +13,17 @@ add_subdirectory(libsdir) add_executable(sharedlibtestexe sharedlibtestexe.cpp) target_link_libraries(sharedlibtestexe shared_iface) + +add_library(broken EXCLUDE_FROM_ALL broken.cpp) + +add_library(iface_broken INTERFACE) +# This is not a dependency, so broken will not be built (and the error in +# it will not be hit) +target_link_libraries(iface_broken INTERFACE broken) + +add_library(iface_whitelist INTERFACE) +# The target property CUSTOM will never be evaluated on the INTERFACE library. +target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTOM>>:irrelevant>) + +add_executable(exec_whitelist dummy.cpp) +target_link_libraries(exec_whitelist iface_whitelist) diff --git a/Tests/InterfaceLibrary/broken.cpp b/Tests/InterfaceLibrary/broken.cpp new file mode 100644 index 0000000..1fd1041 --- /dev/null +++ b/Tests/InterfaceLibrary/broken.cpp @@ -0,0 +1,2 @@ + +#error Broken diff --git a/Tests/InterfaceLibrary/dummy.cpp b/Tests/InterfaceLibrary/dummy.cpp new file mode 100644 index 0000000..341aaaf --- /dev/null +++ b/Tests/InterfaceLibrary/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int, char **) +{ + return 0; +} diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt index a87b41e..5c7b921 100644 --- a/Tests/MacRuntimePath/CMakeLists.txt +++ b/Tests/MacRuntimePath/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 2.8) project(MacRuntimePath) - +if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +endif() # Wipe out the install tree to make sure the exporter works. add_custom_command( diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 09f1881..bf867a9 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -55,93 +55,9 @@ else() endif() endif() -set(DEPS - libshared - libstatic - lib_shared_and_static -) - -foreach(DEP ${DEPS}) - try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${DEP}_build - ${CMAKE_CURRENT_SOURCE_DIR}/${DEP} - ${DEP} - OUTPUT_VARIABLE Out - ) - if (NOT Result) - message("OUTPUT: ${Out}") - endif() -endforeach() - -# The _do_build macro is called from a child scope, where -# the current source and binary dir are different. Save them here -# for use in the macro. -set(TEST_TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(TEST_TOP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) - - -# We seem to get race conditions is writing this stuff to the same file at least on MinGW -# So to write to separate source and build directories, we use a count to differentiate. -set (COUNT 0) -macro(_do_build Include Library LibrarySource Source) - - math(EXPR COUNT "${COUNT} + 1" ) - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n" - "int main() { ${Source}; }\n" - ) - - if ("${Library}" STREQUAL "static_variant") - set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") - endif() - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt" - "cmake_minimum_required(VERSION 2.8)\n" - - "project(compiletest)\n" - - "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" - - "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n" - - "include(GenerateExportHeader)\n" - - "add_compiler_export_flags()\n" - - "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n" - " add_definitions(${ERROR_FLAG})\n" - "endif()\n" - - "include(\"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build/Targets.cmake\")\n" - - "include_directories(\"${TEST_TOP_SOURCE_DIR}/${LibrarySource}\"\n" - " \"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build\")\n" - - "${CONDITIONAL_STATIC_DEFINE}" - - "add_executable(compiletest src.cpp)\n" - "target_link_libraries(compiletest ${Library})\n" - ) - - try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT} - ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT} - compiletest - OUTPUT_VARIABLE Out - ) -endmacro() - -macro(build_fail Include Library LibrarySource Source Message) - _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - test_fail(Result ${Message}) -endmacro() - -macro(build_pass Include Library LibrarySource Source Message) - _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - test_pass(Result ${Message}) -endmacro() - include(GenerateExportHeader) -add_subdirectory(visibility_preset) +add_subdirectory(lib_shared_and_static) add_compiler_export_flags() @@ -159,23 +75,17 @@ macro(macro_add_test_library name) ${${name}_BINARY_DIR} # For the export header. ) list(APPEND link_libraries ${name}) - add_subdirectory(${name}test) endmacro() macro_add_test_library(libshared) macro_add_test_library(libstatic) -add_subdirectory(lib_shared_and_static) -add_subdirectory(lib_shared_and_statictest) -add_subdirectory(override_symbol) add_subdirectory(nodeprecated) -add_subdirectory(prefix) if(NOT BORLAND) add_subdirectory(c_identifier) endif() if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) - # We deliberately call deprecated methods, and test for that elsewhere. # No need to clutter the test output with warnings. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") endif() @@ -187,3 +97,24 @@ endif() add_executable(GenerateExportHeader exportheader_test.cpp) target_link_libraries(GenerateExportHeader ${link_libraries}) +if (WIN32) + if(MSVC AND COMPILER_HAS_DEPRECATED) + set(_platform Win32) + elseif(MINGW AND COMPILER_HAS_DEPRECATED) + set(_platform MinGW) + else() + set(_platform WinEmpty) + endif() +elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(_platform UNIX) +elseif(COMPILER_HAS_DEPRECATED) + set(_platform UNIX_DeprecatedOnly) +else() + set(_platform Empty) +endif() +message("#### Testing reference: ${_platform}") +target_compile_definitions(GenerateExportHeader + PRIVATE + "SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}" + "BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}" +) diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp index 55c3c1a..146374a 100644 --- a/Tests/Module/GenerateExportHeader/exportheader_test.cpp +++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp @@ -11,6 +11,52 @@ #define DOES_NOT_BUILD(function) function #endif +#include <fstream> +#include <iostream> +#include <stdlib.h> +#include <string> + +void compare(const char* refName, const char* testName) +{ + std::ifstream ref; + ref.open(refName); + if (!ref.is_open()) + { + std::cout << "Could not open \"" << refName << "\"." << std::endl; + exit(1); + } + std::ifstream test; + test.open(testName); + if (!test.is_open()) + { + std::cout << "Could not open \"" << testName << "\"." << std::endl; + exit(1); + } + + while (!ref.eof() && !test.eof()) + { + std::string refLine; + std::string testLine; + std::getline(ref, refLine); + std::getline(test, testLine); + if (testLine.size() && testLine[testLine.size()-1] == ' ') + { + testLine = testLine.substr(0, testLine.size() - 1); + } + if (refLine != testLine) + { + std::cout << "Ref and test are not the same:\n Ref: \"" + << refLine << "\"\n Test: \"" << testLine << "\"\n"; + exit(1); + } + } + if (!ref.eof() || !test.eof()) + { + std::cout << "Ref and test have differing numbers of lines."; + exit(1); + } +} + int main() { { @@ -78,5 +124,13 @@ int main() libstatic_not_exported(); libstatic_excluded(); +#define STRINGIFY_IMPL(A) #A +#define STRINGIFY(A) STRINGIFY_IMPL(A) + + compare(STRINGIFY(SRC_DIR) "/libshared_export.h", + STRINGIFY(BIN_DIR) "/libshared/libshared_export.h"); + compare(STRINGIFY(SRC_DIR) "/libstatic_export.h", + STRINGIFY(BIN_DIR) "/libstatic/libstatic_export.h"); + return 0; } diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt index be0387f..c1be125 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -5,7 +5,15 @@ project(lib_shared_and_static) include(GenerateExportHeader) -add_compiler_export_flags() +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + +if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden") + message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") +endif() +if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden") + message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") +endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -14,9 +22,13 @@ set(lib_SRCS ) add_library(shared_variant SHARED ${lib_SRCS}) +set_target_properties(shared_variant PROPERTIES DEFINE_SYMBOL SHARED_VARIANT_MAKEDLL) add_library(static_variant ${lib_SRCS}) -generate_export_header(shared_variant BASE_NAME libshared_and_static) +generate_export_header(shared_variant + BASE_NAME libshared_and_static + PREFIX_NAME MYPREFIX_ +) set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h index 049bfe9..5ad77f4 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -4,51 +4,51 @@ #include "libshared_and_static_export.h" -class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { +class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { public: int libshared_and_static() const; int libshared_and_static_exported() const; - int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; int libshared_and_static_not_exported() const; - int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; }; class LibsharedAndStaticNotExported { public: int libshared_and_static() const; - int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; - int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; int libshared_and_static_not_exported() const; - int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; }; -class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { +class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { public: int libshared_and_static() const; - int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; - int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; int libshared_and_static_not_exported() const; - int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; }; -LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); +MYPREFIX_LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); -LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); +MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); int libshared_and_static_not_exported(); -int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); +int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); #endif diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt deleted file mode 100644 index 207534d..0000000 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ - -macro(shared_variant_build_pass Source Message) - build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -macro(shared_variant_build_fail Source Message) - build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -macro(static_variant_build_pass Source Message) - build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -macro(static_variant_build_fail Source Message) - build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") -shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") -# if (COMPILER_HAS_DEPRECATED) -# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") -# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") -# else() -# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") -# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") -# endif() -static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") - -if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) - shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") -else() - shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant") -endif() diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt deleted file mode 100644 index 2a97d8f..0000000 --- a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ - -macro(shared_build_pass Source Message) - build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message}) -endmacro() - -macro(shared_build_fail Source Message) - build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message}) -endmacro() - -shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") -shared_build_pass("return libshared_exported();" "Failed to build exported function.") - -# if (COMPILER_HAS_DEPRECATED) -# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") -# else() -# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") -# endif() -if (COMPILER_HAS_HIDDEN_VISIBILITY) - shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") -else() - # There is no MSVC equivalent to hiding symbols. - shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.") -endif() - -if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) - shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") - shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") - shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") - shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") - shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") - shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") - - shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") - shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") -else() - shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.") - shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.") - shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.") - shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.") - shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.") - shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.") - - shared_build_pass("return libshared_excluded();" "Built use of excluded function.") - shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.") -endif() diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt deleted file mode 100644 index eb6bb87..0000000 --- a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ - -macro(static_build_pass Source Message) - build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) -endmacro() - -macro(static_build_fail Source Message) - build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) -endmacro() - -static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") - -# if (COMPILER_HAS_DEPRECATED) -# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") -# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") -# else() -# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") -# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") -# endif() diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt deleted file mode 100644 index aeeef20..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(override_symbol) - -add_library(somelib SHARED someclass.cpp) - -set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL) - -generate_export_header(somelib) - -add_executable(consumer main.cpp) - -target_link_libraries(consumer somelib) diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp deleted file mode 100644 index eec46d3..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -#include "someclass.h" - -int main(int, char**) -{ - SomeClass sc; - sc.someMethod(); - return 0; -} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp deleted file mode 100644 index 427ec29..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "someclass.h" - -void SomeClass::someMethod() const -{ - -} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h deleted file mode 100644 index ae5e844..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h +++ /dev/null @@ -1,8 +0,0 @@ - -#include "somelib_export.h" - -class SOMELIB_EXPORT SomeClass -{ -public: - void someMethod() const; -}; diff --git a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt deleted file mode 100644 index bd64df2..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -project(use_prefix) - -set(use_prefix_lib_SRCS - useprefixclass.cpp -) - -add_library(use_prefix_lib SHARED useprefixclass.cpp) - -generate_export_header(use_prefix_lib - PREFIX_NAME MYPREFIX_ -) - -add_executable(use_prefix main.cpp) - -target_link_libraries(use_prefix use_prefix_lib)
\ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp deleted file mode 100644 index 507f6fd..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/main.cpp +++ /dev/null @@ -1,8 +0,0 @@ - -#include "useprefixclass.h" - -int main(int argc, char **argv) -{ - UsePrefixClass upc; - return upc.someMethod(); -} diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp deleted file mode 100644 index 1fd2cb2..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "useprefixclass.h" - -int UsePrefixClass::someMethod() const -{ - return 0; -} diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h deleted file mode 100644 index f5e31b5..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h +++ /dev/null @@ -1,13 +0,0 @@ - -#ifndef USEPREFIXCLASS_H -#define USEPREFIXCLASS_H - -#include "use_prefix_lib_export.h" - -class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass -{ -public: - int someMethod() const; -}; - -#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h new file mode 100644 index 0000000..b6749b2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT +# else + /* We are using this library */ +# define LIBSHARED_EXPORT +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h new file mode 100644 index 0000000..e8000e2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h new file mode 100644 index 0000000..d376631 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h new file mode 100644 index 0000000..fd021e9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h new file mode 100644 index 0000000..7d8087f --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h new file mode 100644 index 0000000..fd021e9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h new file mode 100644 index 0000000..5681f58 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT +# else + /* We are using this library */ +# define LIBSHARED_EXPORT +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h new file mode 100644 index 0000000..fd021e9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h new file mode 100644 index 0000000..976c92e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __declspec(deprecated) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h new file mode 100644 index 0000000..db4df61 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __declspec(deprecated) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h new file mode 100644 index 0000000..2dc41d4 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h new file mode 100644 index 0000000..e8000e2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt b/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt deleted file mode 100644 index 2571d22..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ - -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) - -if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden") - message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") -endif() -if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden") - message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") -endif() - -add_library(visibility_preset SHARED visibility_preset.cpp) -generate_export_header(visibility_preset) - -add_executable(visibility_preset_exe main.cpp) - -target_link_libraries(visibility_preset_exe visibility_preset) diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp deleted file mode 100644 index 89c3977..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -#include "visibility_preset.h" - -int main() -{ - VisibilityPreset vp; - vp.someMethod(); - return 0; -} diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp deleted file mode 100644 index c97dec6..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "visibility_preset.h" - -void VisibilityPreset::someMethod() -{ - -} diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h deleted file mode 100644 index 8becbe1..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h +++ /dev/null @@ -1,13 +0,0 @@ - -#ifndef VISIBILITY_PRESET_H -#define VISIBILITY_PRESET_H - -#include "visibility_preset_export.h" - -class VISIBILITY_PRESET_EXPORT VisibilityPreset -{ -public: - void someMethod(); -}; - -#endif diff --git a/Tests/QtAutoUicInterface/CMakeLists.txt b/Tests/QtAutoUicInterface/CMakeLists.txt new file mode 100644 index 0000000..555f016 --- /dev/null +++ b/Tests/QtAutoUicInterface/CMakeLists.txt @@ -0,0 +1,70 @@ + +cmake_minimum_required(VERSION 2.8.12) + +project(QtAutoUicInterface) + +if (QT_TEST_VERSION STREQUAL 4) + find_package(Qt4 REQUIRED) + + include(UseQt4) + + set(QT_CORE_TARGET Qt4::QtCore) + set(QT_GUI_TARGET Qt4::QtGui) +else() + if (NOT QT_TEST_VERSION STREQUAL 5) + message(SEND_ERROR "Invalid Qt version specified.") + endif() + find_package(Qt5Widgets REQUIRED) + + set(QT_CORE_TARGET Qt5::Core) + set(QT_GUI_TARGET Qt5::Widgets) +endif() + +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) + +# BEGIN Upstream + +set(CMAKE_VERBOSE_MAKEFILE ON) + +add_library(KI18n klocalizedstring.cpp) +target_link_libraries(KI18n ${QT_CORE_TARGET}) + +set(autouic_options + -tr tr2$<$<NOT:$<BOOL:$<TARGET_PROPERTY:NO_KUIT_SEMANTIC>>>:x>i18n +) +if (NOT Qt5Widgets_VERSION VERSION_LESS 5.3.0) + list(APPEND autouic_options -include klocalizedstring.h) +endif() + +set_property(TARGET KI18n APPEND PROPERTY + INTERFACE_AUTOUIC_OPTIONS ${autouic_options} +) + +set(domainProp $<TARGET_PROPERTY:TRANSLATION_DOMAIN>) +set(nameLower $<LOWER_CASE:$<MAKE_C_IDENTIFIER:$<TARGET_PROPERTY:NAME>>>) +set(domain_logic + $<$<BOOL:${domainProp}>:${domainProp}>$<$<NOT:$<BOOL:${domainProp}>>:${nameLower}> +) +set_property(TARGET KI18n APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS "TRANSLATION_DOMAIN=${domain_logic}" +) + +# END upstream + +add_library(LibWidget libwidget.cpp) +target_link_libraries(LibWidget KI18n ${QT_GUI_TARGET}) +set_property(TARGET LibWidget PROPERTY NO_KUIT_SEMANTIC ON) +set_property(TARGET LibWidget PROPERTY TRANSLATION_DOMAIN customdomain) + +add_library(MyWidget mywidget.cpp) +target_link_libraries(MyWidget KI18n ${QT_GUI_TARGET}) + +add_executable(QtAutoUicInterface main.cpp) +target_compile_definitions(QtAutoUicInterface + PRIVATE + UI_LIBWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/ui_libwidget.h" + UI_MYWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/ui_mywidget.h" +) diff --git a/Tests/QtAutoUicInterface/klocalizedstring.cpp b/Tests/QtAutoUicInterface/klocalizedstring.cpp new file mode 100644 index 0000000..f2324bb --- /dev/null +++ b/Tests/QtAutoUicInterface/klocalizedstring.cpp @@ -0,0 +1,12 @@ + +#include "klocalizedstring.h" + +QString tr2xi18n(const char *text, const char *) +{ + return QLatin1String("TranslatedX") + QString::fromLatin1(text); +} + +QString tr2i18n(const char *text, const char *) +{ + return QLatin1String("Translated") + QString::fromLatin1(text); +} diff --git a/Tests/QtAutoUicInterface/klocalizedstring.h b/Tests/QtAutoUicInterface/klocalizedstring.h new file mode 100644 index 0000000..559058f --- /dev/null +++ b/Tests/QtAutoUicInterface/klocalizedstring.h @@ -0,0 +1,17 @@ + +#ifndef KLOCALIZEDSTRING_H +#define KLOCALIZEDSTRING_H + +#include <QString> + +#ifdef _WIN32 +__declspec(dllexport) +#endif +QString tr2xi18n(const char *text, const char *comment = 0); + +#ifdef _WIN32 +__declspec(dllexport) +#endif +QString tr2i18n(const char *text, const char *comment = 0); + +#endif diff --git a/Tests/QtAutoUicInterface/libwidget.cpp b/Tests/QtAutoUicInterface/libwidget.cpp new file mode 100644 index 0000000..8a921b3 --- /dev/null +++ b/Tests/QtAutoUicInterface/libwidget.cpp @@ -0,0 +1,9 @@ + +#include "libwidget.h" + +LibWidget::LibWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::LibWidget) +{ + ui->setupUi(this); +} diff --git a/Tests/QtAutoUicInterface/libwidget.h b/Tests/QtAutoUicInterface/libwidget.h new file mode 100644 index 0000000..8b592ec --- /dev/null +++ b/Tests/QtAutoUicInterface/libwidget.h @@ -0,0 +1,24 @@ + +#ifndef LIBWIDGET_H +#define LIBWIDGET_H + +#include <QWidget> +#include <memory> + +#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) +#include <klocalizedstring.h> +#endif + +#include "ui_libwidget.h" + +class LibWidget : public QWidget +{ + Q_OBJECT +public: + explicit LibWidget(QWidget *parent = 0); + +private: + const std::auto_ptr<Ui::LibWidget> ui; +}; + +#endif diff --git a/Tests/QtAutoUicInterface/libwidget.ui b/Tests/QtAutoUicInterface/libwidget.ui new file mode 100644 index 0000000..897371e --- /dev/null +++ b/Tests/QtAutoUicInterface/libwidget.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LibWidget</class> + <widget class="QWidget" name="LibWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>180</x> + <y>60</y> + <width>57</width> + <height>15</height> + </rect> + </property> + <property name="text"> + <string>LibLabel</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutoUicInterface/main.cpp b/Tests/QtAutoUicInterface/main.cpp new file mode 100644 index 0000000..42d5958 --- /dev/null +++ b/Tests/QtAutoUicInterface/main.cpp @@ -0,0 +1,75 @@ + +#include <fstream> +#include <iostream> +#include <string> + +int main(int argc, char **argv) +{ + std::ifstream f; + f.open(UI_LIBWIDGET_H); + if (!f.is_open()) + { + std::cout << "Could not open \"" UI_LIBWIDGET_H "\"." << std::endl; + return -1; + } + + { + bool gotTr2i18n = false; + + while (!f.eof()) + { + std::string output; + getline(f, output); + if (!gotTr2i18n) + { + gotTr2i18n = output.find("tr2i18n") != std::string::npos; + } + if (output.find("tr2xi18n") != std::string::npos) + { + std::cout << "ui_libwidget,h uses tr2xi18n, though it should not." << std::endl; + return -1; + } + } + + if (!gotTr2i18n) + { + std::cout << "Did not find tr2i18n in ui_libwidget.h" << std::endl; + return -1; + } + } + + f.close(); + f.open(UI_MYWIDGET_H); + if (!f.is_open()) + { + std::cout << "Could not open \"" UI_MYWIDGET_H "\"." << std::endl; + return -1; + } + + { + bool gotTr2xi18n = false; + + while (!f.eof()) + { + std::string output; + getline(f, output); + if (!gotTr2xi18n) + { + gotTr2xi18n = output.find("tr2xi18n") != std::string::npos; + } + if (output.find("tr2i18n") != std::string::npos) + { + std::cout << "ui_mywidget,h uses tr2i18n, though it should not." << std::endl; + return -1; + } + } + if (!gotTr2xi18n) + { + std::cout << "Did not find tr2xi18n in ui_mywidget.h" << std::endl; + return -1; + } + } + f.close(); + + return 0; +} diff --git a/Tests/QtAutoUicInterface/mywidget.cpp b/Tests/QtAutoUicInterface/mywidget.cpp new file mode 100644 index 0000000..b528b1a --- /dev/null +++ b/Tests/QtAutoUicInterface/mywidget.cpp @@ -0,0 +1,9 @@ + +#include "mywidget.h" + +MyWidget::MyWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::MyWidget) +{ + ui->setupUi(this); +} diff --git a/Tests/QtAutoUicInterface/mywidget.h b/Tests/QtAutoUicInterface/mywidget.h new file mode 100644 index 0000000..c96fb98 --- /dev/null +++ b/Tests/QtAutoUicInterface/mywidget.h @@ -0,0 +1,24 @@ + +#ifndef MYWIDGET_H +#define MYWIDGET_H + +#include <QWidget> +#include <memory> + +#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) +#include <klocalizedstring.h> +#endif + +#include "ui_mywidget.h" + +class MyWidget : public QWidget +{ + Q_OBJECT +public: + explicit MyWidget(QWidget *parent = 0); + +private: + const std::auto_ptr<Ui::MyWidget> ui; +}; + +#endif diff --git a/Tests/QtAutoUicInterface/mywidget.ui b/Tests/QtAutoUicInterface/mywidget.ui new file mode 100644 index 0000000..b2b9cc5 --- /dev/null +++ b/Tests/QtAutoUicInterface/mywidget.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MyWidget</class> + <widget class="QWidget" name="MyWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QPushButton" name="pushButton"> + <property name="geometry"> + <rect> + <x>110</x> + <y>40</y> + <width>81</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Special button</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt index a7b0799..711ad0e 100644 --- a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt @@ -1,6 +1,6 @@ CMake Error at CMP0028-NEW.cmake:4 \(add_library\): Target "foo" links to target "External::Library" but the target was not found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or - a ALIAS target is missing\? + an ALIAS target is missing\? Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt index 2ff6927..41d7560 100644 --- a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt @@ -5,7 +5,7 @@ CMake Warning \(dev\) at CMP0028-WARN.cmake:2 \(add_library\): Target "foo" links to target "External::Library" but the target was not found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or - a ALIAS target is missing\? + an ALIAS target is missing\? 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/CMP0041/CMP0041-NEW-result.txt b/Tests/RunCMake/CMP0041/CMP0041-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0041/CMP0041-NEW-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-NEW-stderr.txt new file mode 100644 index 0000000..2ec3aef --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-NEW-stderr.txt @@ -0,0 +1,20 @@ +CMake Error in CMakeLists.txt: + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains relative path: + + "include/\$<TARGET_PROPERTY:NAME>" + + +CMake Error in CMakeLists.txt: + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the source directory. + + +CMake Error in CMakeLists.txt: + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/CMP0041-NEW-build/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the build directory. diff --git a/Tests/RunCMake/CMP0041/CMP0041-NEW.cmake b/Tests/RunCMake/CMP0041/CMP0041-NEW.cmake new file mode 100644 index 0000000..605b79a --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-NEW.cmake @@ -0,0 +1,12 @@ + +cmake_policy(SET CMP0041 NEW) + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME> +) +install(TARGETS foo EXPORT FooExport DESTINATION lib) +install(EXPORT FooExport DESTINATION lib/cmake) diff --git a/Tests/RunCMake/CMP0041/CMP0041-OLD-result.txt b/Tests/RunCMake/CMP0041/CMP0041-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0041/CMP0041-OLD-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0041/CMP0041-OLD.cmake b/Tests/RunCMake/CMP0041/CMP0041-OLD.cmake new file mode 100644 index 0000000..16cbced --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-OLD.cmake @@ -0,0 +1,12 @@ + +cmake_policy(SET CMP0041 OLD) + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME> +) +install(TARGETS foo EXPORT FooExport DESTINATION lib) +install(EXPORT FooExport DESTINATION lib/cmake) diff --git a/Tests/RunCMake/CMP0041/CMP0041-WARN-result.txt b/Tests/RunCMake/CMP0041/CMP0041-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0041/CMP0041-WARN-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-WARN-stderr.txt new file mode 100644 index 0000000..a7d303e --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-WARN-stderr.txt @@ -0,0 +1,32 @@ +CMake Warning in CMakeLists.txt: + Policy CMP0041 is not set: Error on relative include with generator + expression. Run "cmake --help-policy CMP0041" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains relative path: + + "include/\$<TARGET_PROPERTY:NAME>" + + +CMake Warning in CMakeLists.txt: + Policy CMP0041 is not set: Error on relative include with generator + expression. Run "cmake --help-policy CMP0041" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the source directory. + + +CMake Warning in CMakeLists.txt: + Policy CMP0041 is not set: Error on relative include with generator + expression. Run "cmake --help-policy CMP0041" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/CMP0041-WARN-build/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the build directory. diff --git a/Tests/RunCMake/CMP0041/CMP0041-WARN.cmake b/Tests/RunCMake/CMP0041/CMP0041-WARN.cmake new file mode 100644 index 0000000..873cbc7 --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-WARN.cmake @@ -0,0 +1,10 @@ + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME> +) +install(TARGETS foo EXPORT FooExport DESTINATION lib) +install(EXPORT FooExport DESTINATION lib/cmake) diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-NEW-result.txt b/Tests/RunCMake/CMP0041/CMP0041-tid-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-NEW-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-tid-NEW-stderr.txt new file mode 100644 index 0000000..9b0a214 --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-NEW-stderr.txt @@ -0,0 +1,22 @@ +CMake Error in CMakeLists.txt: + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the source directory. + + +CMake Error in CMakeLists.txt: + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the source directory. + + +CMake Error in CMakeLists.txt: + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/CMP0041-tid-NEW-build/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the build directory. diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-NEW.cmake b/Tests/RunCMake/CMP0041/CMP0041-tid-NEW.cmake new file mode 100644 index 0000000..3005108 --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-NEW.cmake @@ -0,0 +1,11 @@ + +cmake_policy(SET CMP0041 NEW) + +add_library(foo empty.cpp) +target_include_directories(foo INTERFACE + include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME> +) +install(TARGETS foo EXPORT FooExport DESTINATION lib) +install(EXPORT FooExport DESTINATION lib/cmake) diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-result.txt b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-OLD.cmake b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD.cmake new file mode 100644 index 0000000..b5c4e7f --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD.cmake @@ -0,0 +1,11 @@ + +cmake_policy(SET CMP0041 OLD) + +add_library(foo empty.cpp) +target_include_directories(foo INTERFACE + include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME> +) +install(TARGETS foo EXPORT FooExport DESTINATION lib) +install(EXPORT FooExport DESTINATION lib/cmake) diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-result.txt b/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-stderr.txt new file mode 100644 index 0000000..aae2c7a --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-stderr.txt @@ -0,0 +1,34 @@ +CMake Warning in CMakeLists.txt: + Policy CMP0041 is not set: Error on relative include with generator + expression. Run "cmake --help-policy CMP0041" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the source directory. + + +CMake Warning in CMakeLists.txt: + Policy CMP0041 is not set: Error on relative include with generator + expression. Run "cmake --help-policy CMP0041" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the source directory. + + +CMake Warning in CMakeLists.txt: + Policy CMP0041 is not set: Error on relative include with generator + expression. Run "cmake --help-policy CMP0041" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "foo" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*/Tests/RunCMake/CMP0041/CMP0041-tid-WARN-build/include/\$<TARGET_PROPERTY:NAME>" + + which is prefixed in the build directory. diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-WARN.cmake b/Tests/RunCMake/CMP0041/CMP0041-tid-WARN.cmake new file mode 100644 index 0000000..ee4c2a6 --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMP0041-tid-WARN.cmake @@ -0,0 +1,9 @@ + +add_library(foo empty.cpp) +target_include_directories(foo INTERFACE + include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_SOURCE_DIR}/include/$<TARGET_PROPERTY:NAME> + ${CMAKE_CURRENT_BINARY_DIR}/include/$<TARGET_PROPERTY:NAME> +) +install(TARGETS foo EXPORT FooExport DESTINATION lib) +install(EXPORT FooExport DESTINATION lib/cmake) diff --git a/Tests/RunCMake/CMP0041/CMakeLists.txt b/Tests/RunCMake/CMP0041/CMakeLists.txt new file mode 100644 index 0000000..11ea636 --- /dev/null +++ b/Tests/RunCMake/CMP0041/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0041/RunCMakeTest.cmake b/Tests/RunCMake/CMP0041/RunCMakeTest.cmake new file mode 100644 index 0000000..a5e2114 --- /dev/null +++ b/Tests/RunCMake/CMP0041/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(CMP0041-OLD) +run_cmake(CMP0041-NEW) +run_cmake(CMP0041-WARN) +run_cmake(CMP0041-tid-OLD) +run_cmake(CMP0041-tid-NEW) +run_cmake(CMP0041-tid-WARN) diff --git a/Tests/RunCMake/CMP0041/empty.cpp b/Tests/RunCMake/CMP0041/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0041/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 209b0b3..96b0543 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -60,6 +60,7 @@ add_RunCMake_test(CMP0037) add_RunCMake_test(CMP0038) add_RunCMake_test(CMP0039) add_RunCMake_test(CMP0040) +add_RunCMake_test(CMP0041) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) @@ -93,11 +94,15 @@ if(NOT WIN32) add_RunCMake_test(VisibilityPreset) endif() endif() +if (QT4_FOUND) + set(CompatibleInterface_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) +endif() add_RunCMake_test(CompatibleInterface) add_RunCMake_test(Syntax) add_RunCMake_test(add_dependencies) add_RunCMake_test(build_command) +add_RunCMake_test(export) add_RunCMake_test(cmake_minimum_required) add_RunCMake_test(find_package) add_RunCMake_test(get_filename_component) diff --git a/Tests/RunCMake/CompatibleInterface/AutoUic-result.txt b/Tests/RunCMake/CompatibleInterface/AutoUic-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/AutoUic-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/AutoUic-stderr.txt b/Tests/RunCMake/CompatibleInterface/AutoUic-stderr.txt new file mode 100644 index 0000000..09f9461 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/AutoUic-stderr.txt @@ -0,0 +1,11 @@ +CMake Error: The INTERFACE_AUTOUIC_OPTIONS property of "OtherI18n" does +not agree with the value of AUTOUIC_OPTIONS already determined +for "LibWidget". + +CMake Debug Log: + String compatibility of property "AUTOUIC_OPTIONS" for target "LibWidget" + \(result: "-tr;ki18n"\): + + \* Target "LibWidget" property not set. + \* Target "KI18n" property value "-tr;ki18n" \(Interface set\) + \* Target "OtherI18n" property value "-tr;otheri18n" \(Disagree\) diff --git a/Tests/RunCMake/CompatibleInterface/AutoUic.cmake b/Tests/RunCMake/CompatibleInterface/AutoUic.cmake new file mode 100644 index 0000000..86bd5a0 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/AutoUic.cmake @@ -0,0 +1,22 @@ + +find_package(Qt4 REQUIRED) + +set(QT_CORE_TARGET Qt4::QtCore) +set(QT_GUI_TARGET Qt4::QtGui) + +set(CMAKE_AUTOUIC ON) + +set(CMAKE_DEBUG_TARGET_PROPERTIES AUTOUIC_OPTIONS) + +add_library(KI18n INTERFACE) +set_property(TARGET KI18n APPEND PROPERTY + INTERFACE_AUTOUIC_OPTIONS -tr ki18n +) + +add_library(OtherI18n INTERFACE) +set_property(TARGET OtherI18n APPEND PROPERTY + INTERFACE_AUTOUIC_OPTIONS -tr otheri18n +) + +add_library(LibWidget empty.cpp) +target_link_libraries(LibWidget KI18n OtherI18n ${QT_GUI_TARGET}) diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-result.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt new file mode 100644 index 0000000..0044564 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt @@ -0,0 +1,73 @@ +CMake Debug Log: + Boolean compatibility of property "BOOL_PROP1" for target + "CompatibleInterface" \(result: "TRUE"\): + + \* Target "CompatibleInterface" property not set. + \* Target "iface1" property value "TRUE" \(Interface set\) ++ +CMake Debug Log: + Boolean compatibility of property "BOOL_PROP2" for target + "CompatibleInterface" \(result: "TRUE"\): + + \* Target "CompatibleInterface" has property content "TRUE" + \* Target "iface1" property value "TRUE" \(Agree\) ++ +CMake Debug Log: + Boolean compatibility of property "BOOL_PROP3" for target + "CompatibleInterface" \(result: "TRUE"\): + + \* Target "CompatibleInterface" has property content "TRUE" ++ +CMake Debug Log: + Boolean compatibility of property "BOOL_PROP4" for target + "CompatibleInterface" \(result: "FALSE"\): + + \* Target "CompatibleInterface" property not set. ++ +CMake Debug Log: + String compatibility of property "STRING_PROP1" for target + "CompatibleInterface" \(result: "prop1"\): + + \* Target "CompatibleInterface" property not set. + \* Target "iface1" property value "prop1" \(Interface set\) ++ +CMake Debug Log: + String compatibility of property "STRING_PROP2" for target + "CompatibleInterface" \(result: "prop2"\): + + \* Target "CompatibleInterface" has property content "prop2" + \* Target "iface1" property value "prop2" \(Agree\) ++ +CMake Debug Log: + String compatibility of property "STRING_PROP3" for target + "CompatibleInterface" \(result: "prop3"\): + + \* Target "CompatibleInterface" has property content "prop3" ++ +CMake Debug Log: + Numeric minimum compatibility of property "NUMBER_MIN_PROP1" for target + "CompatibleInterface" \(result: "50"\): + + \* Target "CompatibleInterface" has property content "50" + \* Target "iface1" property value "100" \(Ignored\) ++ +CMake Debug Log: + Numeric minimum compatibility of property "NUMBER_MIN_PROP2" for target + "CompatibleInterface" \(result: "200"\): + + \* Target "CompatibleInterface" has property content "250" + \* Target "iface1" property value "200" \(Dominant\) ++ +CMake Debug Log: + Numeric maximum compatibility of property "NUMBER_MAX_PROP1" for target + "CompatibleInterface" \(result: "100"\): + + \* Target "CompatibleInterface" has property content "50" + \* Target "iface1" property value "100" \(Dominant\) ++ +CMake Debug Log: + Numeric maximum compatibility of property "NUMBER_MAX_PROP2" for target + "CompatibleInterface" \(result: "250"\): + + \* Target "CompatibleInterface" has property content "250" + \* Target "iface1" property value "200" \(Ignored\) diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake new file mode 100644 index 0000000..3214d8e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake @@ -0,0 +1,60 @@ + +cmake_minimum_required(VERSION 2.8) + +project(CompatibleInterface) + +include(GenerateExportHeader) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(iface1 INTERFACE) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL + BOOL_PROP1 + BOOL_PROP2 + BOOL_PROP3 + BOOL_PROP4 +) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING + STRING_PROP1 + STRING_PROP2 + STRING_PROP3 +) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_NUMBER_MIN + NUMBER_MIN_PROP1 + NUMBER_MIN_PROP2 +) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_NUMBER_MAX + NUMBER_MAX_PROP1 + NUMBER_MAX_PROP2 +) + +set(CMAKE_DEBUG_TARGET_PROPERTIES + BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 BOOL_PROP4 + STRING_PROP1 STRING_PROP2 STRING_PROP3 + NUMBER_MIN_PROP1 NUMBER_MIN_PROP2 + NUMBER_MAX_PROP1 NUMBER_MAX_PROP2 +) + +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) +set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1) +set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP2 prop2) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP1 100) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP2 200) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP1 100) +set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP2 200) + +add_executable(CompatibleInterface empty.cpp) +target_link_libraries(CompatibleInterface iface1) + +set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON) +set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON) +set_property(TARGET CompatibleInterface PROPERTY STRING_PROP2 prop2) +set_property(TARGET CompatibleInterface PROPERTY STRING_PROP3 prop3) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP1 50) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP2 250) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP1 50) +set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP2 250) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake index 9768151..b87adc8 100644 --- a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -9,3 +9,9 @@ run_cmake(InterfaceString-mismatch-depend-self) run_cmake(InterfaceString-mismatched-use) run_cmake(InterfaceString-builtin-prop) run_cmake(InterfaceString-Bool-Conflict) +run_cmake(DebugProperties) + +if (QT_QMAKE_EXECUTABLE}) + set(RunCMake_TEST_OPTIONS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) + run_cmake(AutoUic) +endif() diff --git a/Tests/RunCMake/CompatibleInterface/empty.cpp b/Tests/RunCMake/CompatibleInterface/empty.cpp new file mode 100644 index 0000000..0032329 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/empty.cpp @@ -0,0 +1 @@ +// no content diff --git a/Tests/RunCMake/PositionIndependentCode/Debug-result.txt b/Tests/RunCMake/PositionIndependentCode/Debug-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Debug-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/PositionIndependentCode/Debug-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Debug-stderr.txt new file mode 100644 index 0000000..774445b --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Debug-stderr.txt @@ -0,0 +1,6 @@ +CMake Debug Log: + Boolean compatibility of property "POSITION_INDEPENDENT_CODE" for target + "foo" \(result: "TRUE"\): + + \* Target "foo" has property content "TRUE" + \* Target "iface" property value "TRUE" \(Agree\) diff --git a/Tests/RunCMake/PositionIndependentCode/Debug.cmake b/Tests/RunCMake/PositionIndependentCode/Debug.cmake new file mode 100644 index 0000000..4a8fbac --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Debug.cmake @@ -0,0 +1,8 @@ + +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE ON) + +set(CMAKE_DEBUG_TARGET_PROPERTIES POSITION_INDEPENDENT_CODE) +add_library(foo main.cpp) +target_link_libraries(foo iface) +set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake index 3a2009b..6a67e3c 100644 --- a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake +++ b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake @@ -6,3 +6,4 @@ run_cmake(Conflict3) run_cmake(Conflict4) run_cmake(Conflict5) run_cmake(Conflict6) +run_cmake(Debug) diff --git a/Tests/RunCMake/export/CMakeLists.txt b/Tests/RunCMake/export/CMakeLists.txt new file mode 100644 index 0000000..be9d403 --- /dev/null +++ b/Tests/RunCMake/export/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST}) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake new file mode 100644 index 0000000..b8d3f27 --- /dev/null +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(TargetNotFound) diff --git a/Tests/RunCMake/export/TargetNotFound-result.txt b/Tests/RunCMake/export/TargetNotFound-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/export/TargetNotFound-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/export/TargetNotFound-stderr.txt b/Tests/RunCMake/export/TargetNotFound-stderr.txt new file mode 100644 index 0000000..944a68e --- /dev/null +++ b/Tests/RunCMake/export/TargetNotFound-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TargetNotFound.cmake:1 \(export\): + export given target "nonexistenttarget" which is not built by this project. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/TargetNotFound.cmake b/Tests/RunCMake/export/TargetNotFound.cmake new file mode 100644 index 0000000..a7c398d --- /dev/null +++ b/Tests/RunCMake/export/TargetNotFound.cmake @@ -0,0 +1 @@ +export(TARGETS nonexistenttarget FILE somefile.cmake) diff --git a/Tests/RunCMake/include_directories/CMakeLists.txt b/Tests/RunCMake/include_directories/CMakeLists.txt index 12cd3c7..f452db1 100644 --- a/Tests/RunCMake/include_directories/CMakeLists.txt +++ b/Tests/RunCMake/include_directories/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 2.8.4) -project(${RunCMake_TEST} NONE) +project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index f66823e..c00b924 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -11,3 +11,4 @@ run_cmake(RelativePathInGenex) run_cmake(CMP0021) run_cmake(install_config) run_cmake(incomplete-genex) +run_cmake(export-NOWARN) diff --git a/Tests/RunCMake/include_directories/export-NOWARN-result.txt b/Tests/RunCMake/include_directories/export-NOWARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/export-NOWARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/export-NOWARN-stderr.txt b/Tests/RunCMake/include_directories/export-NOWARN-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/include_directories/export-NOWARN-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/include_directories/export-NOWARN.cmake b/Tests/RunCMake/include_directories/export-NOWARN.cmake new file mode 100644 index 0000000..307ce5a --- /dev/null +++ b/Tests/RunCMake/include_directories/export-NOWARN.cmake @@ -0,0 +1,62 @@ + +add_library(foo empty.cpp) +set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<0:>/include/subdir) +set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_PREFIX>/include/subdir) + +set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/subdir>) +set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:include/subdir>) +set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:include/$<0:>>) +set_property(TARGET foo APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:$<0:>/include>) + +# target_include_directories(foo INTERFACE include/subdir) # Does and should warn. INSTALL_INTERFACE must not list src dir paths. +target_include_directories(foo INTERFACE $<0:>/include/subdir) # Does not and should not should warn, because it starts with a genex. +target_include_directories(foo INTERFACE $<INSTALL_PREFIX>/include/subdir) + +target_include_directories(foo INTERFACE $<INSTALL_INTERFACE:include/subdir>) +target_include_directories(foo INTERFACE $<INSTALL_INTERFACE:include/$<0:>>) + +install(TARGETS foo EXPORT FooTargets DESTINATION lib) +install(EXPORT FooTargets DESTINATION lib/cmake) + +install(TARGETS foo EXPORT FooTargets2 + DESTINATION lib + INCLUDES DESTINATION include # No warning. Implicit install prefix. +) +install(EXPORT FooTargets2 DESTINATION lib/cmake) + +install(TARGETS foo EXPORT FooTargets3 + DESTINATION lib + INCLUDES DESTINATION $<INSTALL_PREFIX>include +) +install(EXPORT FooTargets3 DESTINATION lib/cmake) + +install(TARGETS foo EXPORT FooTargets4 + DESTINATION lib + INCLUDES DESTINATION $<INSTALL_INTERFACE:include> +) +install(EXPORT FooTargets4 DESTINATION lib/cmake) + +install(TARGETS foo EXPORT FooTargets5 + DESTINATION lib + # The $<0:> is evaluated at export time, leaving 'include' behind, which should be treated as above. + INCLUDES DESTINATION $<INSTALL_INTERFACE:$<0:>include> +) +install(EXPORT FooTargets5 DESTINATION lib/cmake) + +install(TARGETS foo EXPORT FooTargets6 + DESTINATION lib + INCLUDES DESTINATION $<INSTALL_INTERFACE:include$<0:>> +) +install(EXPORT FooTargets6 DESTINATION lib/cmake) + +install(TARGETS foo EXPORT FooTargets7 + DESTINATION lib + INCLUDES DESTINATION include$<0:> +) +install(EXPORT FooTargets7 DESTINATION lib/cmake) + +install(TARGETS foo EXPORT FooTargets8 + DESTINATION lib + INCLUDES DESTINATION $<0:>include +) +install(EXPORT FooTargets8 DESTINATION lib/cmake) diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index e257fb3..0d00b71 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -4,3 +4,4 @@ run_cmake(invalid_name) run_cmake(target_commands) run_cmake(no_shared_libs) run_cmake(whitelist) +run_cmake(genex_link) diff --git a/Tests/RunCMake/interface_library/genex_link-result.txt b/Tests/RunCMake/interface_library/genex_link-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/interface_library/genex_link-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/interface_library/genex_link-stderr.txt b/Tests/RunCMake/interface_library/genex_link-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/interface_library/genex_link-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/interface_library/genex_link.cmake b/Tests/RunCMake/interface_library/genex_link.cmake new file mode 100644 index 0000000..0dbf029 --- /dev/null +++ b/Tests/RunCMake/interface_library/genex_link.cmake @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 2.8.12.20131125 FATAL_ERROR) + +project(genex_link) + +set(_main_cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) +file(WRITE ${_main_cpp} + "int main(int argc, char** argv) { return 0; }\n" +) + +add_library(foo::bar INTERFACE IMPORTED) +set_target_properties(foo::bar + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}" + # When not using a generator expression here, no error is generated + INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:foo_bar.lib>" +) + +add_executable(main ${_main_cpp}) +target_include_directories(main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + +target_link_libraries(main foo::bar) diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c index a4dc710..c7c808f 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c @@ -2412,9 +2412,10 @@ tar_atol(const char *p, size_t char_cnt) static int64_t tar_atol_base_n(const char *p, size_t char_cnt, int base) { - int64_t l, limit, last_digit_limit; + int64_t l, maxval, limit, last_digit_limit; int digit, sign; + maxval = INT64_MAX; limit = INT64_MAX / base; last_digit_limit = INT64_MAX % base; @@ -2431,6 +2432,10 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base) sign = -1; p++; char_cnt--; + + maxval = INT64_MIN; + limit = -(INT64_MIN / base); + last_digit_limit = INT64_MIN % base; } l = 0; @@ -2438,8 +2443,7 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base) digit = *p - '0'; while (digit >= 0 && digit < base && char_cnt != 0) { if (l>limit || (l == limit && digit > last_digit_limit)) { - l = INT64_MAX; /* Truncate on overflow. */ - break; + return maxval; /* Truncate on overflow. */ } l = (l * base) + digit; digit = *++p - '0'; @@ -2462,32 +2466,56 @@ tar_atol10(const char *p, size_t char_cnt) } /* - * Parse a base-256 integer. This is just a straight signed binary - * value in big-endian order, except that the high-order bit is - * ignored. + * Parse a base-256 integer. This is just a variable-length + * twos-complement signed binary value in big-endian order, except + * that the high-order bit is ignored. The values here can be up to + * 12 bytes, so we need to be careful about overflowing 64-bit + * (8-byte) integers. + * + * This code unashamedly assumes that the local machine uses 8-bit + * bytes and twos-complement arithmetic. */ static int64_t tar_atol256(const char *_p, size_t char_cnt) { - int64_t l, upper_limit, lower_limit; + uint64_t l; const unsigned char *p = (const unsigned char *)_p; + unsigned char c, neg; + + /* Extend 7-bit 2s-comp to 8-bit 2s-comp, decide sign. */ + c = *p; + if (c & 0x40) { + neg = 0xff; + c |= 0x80; + l = ~ARCHIVE_LITERAL_ULL(0); + } else { + neg = 0; + c &= 0x7f; + l = 0; + } - upper_limit = INT64_MAX / 256; - lower_limit = INT64_MIN / 256; + /* If more than 8 bytes, check that we can ignore + * high-order bits without overflow. */ + while (char_cnt > sizeof(int64_t)) { + --char_cnt; + if (c != neg) + return neg ? INT64_MIN : INT64_MAX; + c = *++p; + } - /* Sign-extend the 7-bit value to 64 bits. */ - if ((0x40 & *p) == 0x40) - l = ~((int64_t)0x3f) | *p++; - else - l = 0x3f & *p++; + /* c is first byte that fits; if sign mismatch, return overflow */ + if ((c ^ neg) & 0x80) { + return neg ? INT64_MIN : INT64_MAX; + } + + /* Accumulate remaining bytes. */ while (--char_cnt > 0) { - if (l > upper_limit) - return (INT64_MAX); /* Truncate on overflow */ - else if (l < lower_limit) - return (INT64_MIN); - l = (l << 8) | (0xff & (int64_t)*p++); + l = (l << 8) | c; + c = *++p; } - return (l); + l = (l << 8) | c; + /* Return signed twos-complement value. */ + return (int64_t)(l); } /* |