diff options
329 files changed, 6289 insertions, 1213 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 6feed94..79d2319 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -230,26 +230,13 @@ the indentation. Otherwise it retains the same position on the line" ;; (defvar cmake-tab-width 2) -;; -;; Keymap. -;; -(defvar cmake-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-ch" 'cmake-help-command) - (define-key map "\C-cl" 'cmake-help-list-commands) - (define-key map "\C-cu" 'unscreamify-cmake-buffer) - map) - "Keymap used in cmake-mode buffers.") - ;------------------------------------------------------------------------------ ;; ;; CMake mode startup function. ;; (defun cmake-mode () - "Major mode for editing CMake listfiles. - -\\{cmake-mode-map}" + "Major mode for editing CMake listfiles." (interactive) (kill-all-local-variables) (setq major-mode 'cmake-mode) @@ -276,9 +263,6 @@ the indentation. Otherwise it retains the same position on the line" (make-local-variable 'comment-start) (setq comment-start "#") - ; Setup keymap. - (use-local-map cmake-mode-map) - ; Run user hooks. (run-hooks 'cmake-mode-hook)) diff --git a/Help/command/FIND_XXX_ROOT.txt b/Help/command/FIND_XXX_ROOT.txt index 407375a..b5cab68 100644 --- a/Help/command/FIND_XXX_ROOT.txt +++ b/Help/command/FIND_XXX_ROOT.txt @@ -1,14 +1,23 @@ -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. By -default it is empty. It is especially useful when cross-compiling to +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 :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 +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 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 will be searched. +directories and directories below :variable:`CMAKE_STAGING_PREFIX` will be searched. diff --git a/Help/command/ctest_submit.rst b/Help/command/ctest_submit.rst index 29d2f5d..ed801bb 100644 --- a/Help/command/ctest_submit.rst +++ b/Help/command/ctest_submit.rst @@ -22,6 +22,7 @@ Valid part names are: MemCheck = ctest_memcheck results, in DynamicAnalysis.xml Notes = Files listed by CTEST_NOTES_FILES, in Notes.xml ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES + Upload = Files prepared for upload by ctest_upload(), in Upload.xml Submit = nothing The FILES option explicitly lists specific files to be submitted. 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/foreach.rst b/Help/command/foreach.rst index 8f9710c..348ebd8 100644 --- a/Help/command/foreach.rst +++ b/Help/command/foreach.rst @@ -42,5 +42,6 @@ three types of this iteration: Iterates over a precise list of items. The LISTS option names list-valued variables to be traversed, including empty elements (an -empty string is a zero-length list). The ITEMS option ends argument +empty string is a zero-length list). (Note macro +arguments are not variables.) The ITEMS option ends argument parsing and includes all arguments following it in the iteration. diff --git a/Help/command/if.rst b/Help/command/if.rst index b879ae1..0279be7 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -166,7 +166,8 @@ 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. +variable is true or false just if it has been set. (Note macro +arguments are not variables.) :: diff --git a/Help/command/list.rst b/Help/command/list.rst index f044dba..aeb1e94 100644 --- a/Help/command/list.rst +++ b/Help/command/list.rst @@ -50,7 +50,8 @@ propagation. NOTES: A list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set(var a b c d e) creates a list with a;b;c;d;e, and set(var "a b c d e") creates a -string or a list with one item in it. +string or a list with one item in it. (Note macro arguments are not +variables, and therefore cannot be used in LIST commands.) When specifying index values, if <element index> is 0 or greater, it is indexed from the beginning of the list, with 0 representing the diff --git a/Help/command/macro.rst b/Help/command/macro.rst index aa16352..258dc50 100644 --- a/Help/command/macro.rst +++ b/Help/command/macro.rst @@ -15,19 +15,53 @@ Define a macro named <name> that takes arguments named arg1 arg2 arg3 (...). Commands listed after macro, but before the matching endmacro, are not invoked until the macro is invoked. When it is invoked, the commands recorded in the macro are first modified by replacing formal -parameters (${arg1}) with the arguments passed, and then invoked as +parameters (``${arg1}``) with the arguments passed, and then invoked as normal commands. In addition to referencing the formal parameters you -can reference the values ${ARGC} which will be set to the number of -arguments passed into the function as well as ${ARGV0} ${ARGV1} -${ARGV2} ... which will have the actual values of the arguments +can reference the values ``${ARGC}`` which will be set to the number of +arguments passed into the function as well as ``${ARGV0}`` ``${ARGV1}`` +``${ARGV2}`` ... which will have the actual values of the arguments passed in. This facilitates creating macros with optional arguments. -Additionally ${ARGV} holds the list of all arguments given to the -macro and ${ARGN} holds the list of arguments past the last expected -argument. Note that the parameters to a macro and values such as ARGN -are not variables in the usual CMake sense. They are string -replacements much like the C preprocessor would do with a macro. If -you want true CMake variables and/or better CMake scope control you -should look at the function command. +Additionally ``${ARGV}`` holds the list of all arguments given to the +macro and ``${ARGN}`` holds the list of arguments past the last expected +argument. See the cmake_policy() command documentation for the behavior of policies inside macros. + +Macro Argument Caveats +^^^^^^^^^^^^^^^^^^^^^^ + +Note that the parameters to a macro and values such as ``ARGN`` are +not variables in the usual CMake sense. They are string +replacements much like the C preprocessor would do with a macro. +Therefore you will NOT be able to use commands like:: + + if(ARGV1) # ARGV1 is not a variable + foreach(loop_var IN LISTS ARGN) # ARGN is not a variable + +In the first case you can use ``if(${ARGV1})``, in the second case, you can +use ``foreach(loop_var ${ARGN})`` but this will skip empty arguments. +If you need to include them, you can use:: + + set(list_var "${ARGN}") + foreach(loop_var IN LISTS list_var) + +Note that if you have a variable with the same name in the scope from +which the macro is called, using unreferenced names will use the +existing variable instead of the arguments. For example:: + + macro(_BAR) + foreach(arg IN LISTS ARGN) + [...] + endforeach() + endmacro() + + function(_FOO) + _bar(x y z) + endfunction() + + _foo(a b c) + +Will loop over ``a;b;c`` and not over ``x;y;z`` as one might be expecting. +If you want true CMake variables and/or better CMake scope control you +should look at the function command. diff --git a/Help/generator/CodeBlocks - NMake Makefiles.rst b/Help/generator/CodeBlocks - NMake Makefiles.rst deleted file mode 100644 index c7f944a..0000000 --- a/Help/generator/CodeBlocks - NMake Makefiles.rst +++ /dev/null @@ -1,11 +0,0 @@ -CodeBlocks - NMake Makefiles ----------------------------- - -Generates CodeBlocks project files. - -Project files for CodeBlocks will be created in the top directory and -in every subdirectory which features a CMakeLists.txt file containing -a PROJECT() call. Additionally a hierarchy of makefiles is generated -into the build tree. The appropriate make program can build the -project through the default make target. A "make install" target is -also provided. diff --git a/Help/generator/CodeBlocks - Ninja.rst b/Help/generator/CodeBlocks - Ninja.rst deleted file mode 100644 index 0253af6..0000000 --- a/Help/generator/CodeBlocks - Ninja.rst +++ /dev/null @@ -1,11 +0,0 @@ -CodeBlocks - Ninja ------------------- - -Generates CodeBlocks project files. - -Project files for CodeBlocks will be created in the top directory and -in every subdirectory which features a CMakeLists.txt file containing -a PROJECT() call. Additionally a hierarchy of makefiles is generated -into the build tree. The appropriate make program can build the -project through the default make target. A "make install" target is -also provided. diff --git a/Help/generator/CodeBlocks - Unix Makefiles.rst b/Help/generator/CodeBlocks - Unix Makefiles.rst deleted file mode 100644 index 0a29835..0000000 --- a/Help/generator/CodeBlocks - Unix Makefiles.rst +++ /dev/null @@ -1,11 +0,0 @@ -CodeBlocks - Unix Makefiles ---------------------------- - -Generates CodeBlocks project files. - -Project files for CodeBlocks will be created in the top directory and -in every subdirectory which features a CMakeLists.txt file containing -a PROJECT() call. Additionally a hierarchy of makefiles is generated -into the build tree. The appropriate make program can build the -project through the default make target. A "make install" target is -also provided. diff --git a/Help/generator/CodeBlocks - MinGW Makefiles.rst b/Help/generator/CodeBlocks.rst index f54eb11..01798c7 100644 --- a/Help/generator/CodeBlocks - MinGW Makefiles.rst +++ b/Help/generator/CodeBlocks.rst @@ -1,5 +1,5 @@ -CodeBlocks - MinGW Makefiles ----------------------------- +CodeBlocks +---------- Generates CodeBlocks project files. @@ -9,3 +9,17 @@ a PROJECT() call. Additionally a hierarchy of makefiles is generated into the build tree. The appropriate make program can build the project through the default make target. A "make install" target is also provided. + +This "extra" generator may be specified as: + +``CodeBlocks - MinGW Makefiles`` + Generate with :generator:`MinGW Makefiles`. + +``CodeBlocks - NMake Makefiles`` + Generate with :generator:`NMake Makefiles`. + +``CodeBlocks - Ninja`` + Generate with :generator:`Ninja`. + +``CodeBlocks - Unix Makefiles`` + Generate with :generator:`Unix Makefiles`. diff --git a/Help/generator/Eclipse CDT4 - NMake Makefiles.rst b/Help/generator/Eclipse CDT4 - NMake Makefiles.rst deleted file mode 100644 index b5133ad..0000000 --- a/Help/generator/Eclipse CDT4 - NMake Makefiles.rst +++ /dev/null @@ -1,11 +0,0 @@ -Eclipse CDT4 - NMake Makefiles ------------------------------- - -Generates Eclipse CDT 4.0 project files. - -Project files for Eclipse will be created in the top directory. In -out of source builds, a linked resource to the top level source -directory will be created. Additionally a hierarchy of makefiles is -generated into the build tree. The appropriate make program can build -the project through the default make target. A "make install" target -is also provided. diff --git a/Help/generator/Eclipse CDT4 - Ninja.rst b/Help/generator/Eclipse CDT4 - Ninja.rst deleted file mode 100644 index 270011f..0000000 --- a/Help/generator/Eclipse CDT4 - Ninja.rst +++ /dev/null @@ -1,11 +0,0 @@ -Eclipse CDT4 - Ninja --------------------- - -Generates Eclipse CDT 4.0 project files. - -Project files for Eclipse will be created in the top directory. In -out of source builds, a linked resource to the top level source -directory will be created. Additionally a hierarchy of makefiles is -generated into the build tree. The appropriate make program can build -the project through the default make target. A "make install" target -is also provided. diff --git a/Help/generator/Eclipse CDT4 - Unix Makefiles.rst b/Help/generator/Eclipse CDT4 - Unix Makefiles.rst deleted file mode 100644 index c3449a7..0000000 --- a/Help/generator/Eclipse CDT4 - Unix Makefiles.rst +++ /dev/null @@ -1,11 +0,0 @@ -Eclipse CDT4 - Unix Makefiles ------------------------------ - -Generates Eclipse CDT 4.0 project files. - -Project files for Eclipse will be created in the top directory. In -out of source builds, a linked resource to the top level source -directory will be created. Additionally a hierarchy of makefiles is -generated into the build tree. The appropriate make program can build -the project through the default make target. A "make install" target -is also provided. diff --git a/Help/generator/Eclipse CDT4 - MinGW Makefiles.rst b/Help/generator/Eclipse CDT4.rst index 9e7a26e..eb68bf0 100644 --- a/Help/generator/Eclipse CDT4 - MinGW Makefiles.rst +++ b/Help/generator/Eclipse CDT4.rst @@ -1,5 +1,5 @@ -Eclipse CDT4 - MinGW Makefiles ------------------------------- +Eclipse CDT4 +------------ Generates Eclipse CDT 4.0 project files. @@ -9,3 +9,17 @@ directory will be created. Additionally a hierarchy of makefiles is generated into the build tree. The appropriate make program can build the project through the default make target. A "make install" target is also provided. + +This "extra" generator may be specified as: + +``Eclipse CDT4 - MinGW Makefiles`` + Generate with :generator:`MinGW Makefiles`. + +``Eclipse CDT4 - NMake Makefiles`` + Generate with :generator:`NMake Makefiles`. + +``Eclipse CDT4 - Ninja`` + Generate with :generator:`Ninja`. + +``Eclipse CDT4 - Unix Makefiles`` + Generate with :generator:`Unix Makefiles`. diff --git a/Help/generator/KDevelop3 - Unix Makefiles.rst b/Help/generator/KDevelop3 - Unix Makefiles.rst deleted file mode 100644 index 2a29a2e..0000000 --- a/Help/generator/KDevelop3 - Unix Makefiles.rst +++ /dev/null @@ -1,13 +0,0 @@ -KDevelop3 - Unix Makefiles --------------------------- - -Generates KDevelop 3 project files. - -Project files for KDevelop 3 will be created in the top directory and -in every subdirectory which features a CMakeLists.txt file containing -a PROJECT() call. If you change the settings using KDevelop cmake -will try its best to keep your changes when regenerating the project -files. Additionally a hierarchy of UNIX makefiles is generated into -the build tree. Any standard UNIX-style make program can build the -project through the default make target. A "make install" target is -also provided. diff --git a/Help/generator/KDevelop3.rst b/Help/generator/KDevelop3.rst index 788d557..eaa218b 100644 --- a/Help/generator/KDevelop3.rst +++ b/Help/generator/KDevelop3.rst @@ -11,3 +11,15 @@ files. Additionally a hierarchy of UNIX makefiles is generated into the build tree. Any standard UNIX-style make program can build the project through the default make target. A "make install" target is also provided. + +This "extra" generator may be specified as: + +``KDevelop3 - Unix Makefiles`` + Generate with :generator:`Unix Makefiles`. + +``KDevelop3`` + Generate with :generator:`Unix Makefiles`. + + For historical reasons this extra generator may be specified + directly as the main generator and it will be used as the + extra generator with :generator:`Unix Makefiles` automatically. 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/generator/Sublime Text 2 - NMake Makefiles.rst b/Help/generator/Sublime Text 2 - NMake Makefiles.rst deleted file mode 100644 index 5e02fd4..0000000 --- a/Help/generator/Sublime Text 2 - NMake Makefiles.rst +++ /dev/null @@ -1,11 +0,0 @@ -Sublime Text 2 - NMake Makefiles --------------------------------- - -Generates Sublime Text 2 project files. - -Project files for Sublime Text 2 will be created in the top directory -and in every subdirectory which features a CMakeLists.txt file -containing a PROJECT() call. Additionally Makefiles (or build.ninja -files) are generated into the build tree. The appropriate make -program can build the project through the default make target. A -"make install" target is also provided. diff --git a/Help/generator/Sublime Text 2 - Ninja.rst b/Help/generator/Sublime Text 2 - Ninja.rst deleted file mode 100644 index b7a2b88..0000000 --- a/Help/generator/Sublime Text 2 - Ninja.rst +++ /dev/null @@ -1,11 +0,0 @@ -Sublime Text 2 - Ninja ----------------------- - -Generates Sublime Text 2 project files. - -Project files for Sublime Text 2 will be created in the top directory -and in every subdirectory which features a CMakeLists.txt file -containing a PROJECT() call. Additionally Makefiles (or build.ninja -files) are generated into the build tree. The appropriate make -program can build the project through the default make target. A -"make install" target is also provided. diff --git a/Help/generator/Sublime Text 2 - Unix Makefiles.rst b/Help/generator/Sublime Text 2 - Unix Makefiles.rst deleted file mode 100644 index 67d329e..0000000 --- a/Help/generator/Sublime Text 2 - Unix Makefiles.rst +++ /dev/null @@ -1,11 +0,0 @@ -Sublime Text 2 - Unix Makefiles -------------------------------- - -Generates Sublime Text 2 project files. - -Project files for Sublime Text 2 will be created in the top directory -and in every subdirectory which features a CMakeLists.txt file -containing a PROJECT() call. Additionally Makefiles (or build.ninja -files) are generated into the build tree. The appropriate make -program can build the project through the default make target. A -"make install" target is also provided. diff --git a/Help/generator/Sublime Text 2 - MinGW Makefiles.rst b/Help/generator/Sublime Text 2.rst index 6e2ed02..0597a95 100644 --- a/Help/generator/Sublime Text 2 - MinGW Makefiles.rst +++ b/Help/generator/Sublime Text 2.rst @@ -1,5 +1,5 @@ -Sublime Text 2 - MinGW Makefiles --------------------------------- +Sublime Text 2 +-------------- Generates Sublime Text 2 project files. @@ -9,3 +9,17 @@ containing a PROJECT() call. Additionally Makefiles (or build.ninja files) are generated into the build tree. The appropriate make program can build the project through the default make target. A "make install" target is also provided. + +This "extra" generator may be specified as: + +``Sublime Text 2 - MinGW Makefiles`` + Generate with :generator:`MinGW Makefiles`. + +``Sublime Text 2 - NMake Makefiles`` + Generate with :generator:`NMake Makefiles`. + +``Sublime Text 2 - Ninja`` + Generate with :generator:`Ninja`. + +``Sublime Text 2 - Unix Makefiles`` + Generate with :generator:`Unix Makefiles`. diff --git a/Help/index.rst b/Help/index.rst index 0d33825..4ef5c3f 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-policies.7 /manual/cmake-properties.7 diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index ddde183..ed28abd 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -7,80 +7,180 @@ cmake-generator-expressions(7) .. contents:: -Generator Expressions -===================== - -Generator expressions are evaluated during build -system generation to produce information specific to each build -configuration. Valid expressions are: - -:: - - $<0:...> = empty string (ignores "...") - $<1:...> = content of "..." - $<CONFIG:cfg> = '1' if config is "cfg", else '0' - $<CONFIGURATION> = configuration name - $<BOOL:...> = '1' if the '...' is true, else '0' - $<STREQUAL:a,b> = '1' if a is STREQUAL b, else '0' - $<ANGLE-R> = A literal '>'. Used to compare strings which contain a '>' for example. - $<COMMA> = A literal ','. Used to compare strings which contain a ',' for example. - $<SEMICOLON> = A literal ';'. Used to prevent list expansion on an argument with ';'. - $<JOIN:list,...> = joins the list with the content of "..." - $<TARGET_NAME:...> = Marks ... as being the name of a target. This is required if exporting targets to multiple dependent export sets. The '...' must be a literal name of a target- it may not contain generator expressions. - $<INSTALL_INTERFACE:...> = content of "..." when the property is exported using install(EXPORT), and empty otherwise. - $<BUILD_INTERFACE:...> = content of "..." when the property is exported using export(), or when the target is used by another target in the same buildsystem. Expands to the empty string otherwise. - $<PLATFORM_ID> = The CMake-id of the platform $<PLATFORM_ID:comp> = '1' if the The CMake-id of the platform matches comp, otherwise '0'. - $<C_COMPILER_ID> = The CMake-id of the C compiler used. - $<C_COMPILER_ID:comp> = '1' if the CMake-id of the C compiler matches comp, otherwise '0'. - $<CXX_COMPILER_ID> = The CMake-id of the CXX compiler used. - $<CXX_COMPILER_ID:comp> = '1' if the CMake-id of the CXX compiler matches comp, otherwise '0'. - $<VERSION_GREATER:v1,v2> = '1' if v1 is a version greater than v2, else '0'. - $<VERSION_LESS:v1,v2> = '1' if v1 is a version less than v2, else '0'. - $<VERSION_EQUAL:v1,v2> = '1' if v1 is the same version as v2, else '0'. - $<C_COMPILER_VERSION> = The version of the C compiler used. - $<C_COMPILER_VERSION:ver> = '1' if the version of the C compiler matches ver, otherwise '0'. - $<CXX_COMPILER_VERSION> = The version of the CXX compiler used. - $<CXX_COMPILER_VERSION:ver> = '1' if the version of the CXX compiler matches ver, otherwise '0'. - $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a) - $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so) - $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3) - -where "tgt" is the name of a target. Target file expressions produce -a full path, but _DIR and _NAME versions can produce the directory and -file name components: - -:: - - $<TARGET_FILE_DIR:tgt>/$<TARGET_FILE_NAME:tgt> - $<TARGET_LINKER_FILE_DIR:tgt>/$<TARGET_LINKER_FILE_NAME:tgt> - $<TARGET_SONAME_FILE_DIR:tgt>/$<TARGET_SONAME_FILE_NAME:tgt> - - - -:: - - $<TARGET_PROPERTY:tgt,prop> = The value of the property prop on the target tgt. - -Note that tgt is not added as a dependency of the target this -expression is evaluated on. - -:: - - $<TARGET_POLICY:pol> = '1' if the policy was NEW when the 'head' target was created, else '0'. If the policy was not set, the warning message for the policy will be emitted. This generator expression only works for a subset of policies. - $<INSTALL_PREFIX> = Content of the install prefix when the target is exported via INSTALL(EXPORT) and empty otherwise. - -Boolean expressions: - -:: - - $<AND:?[,?]...> = '1' if all '?' are '1', else '0' - $<OR:?[,?]...> = '0' if all '?' are '0', else '1' - $<NOT:?> = '0' if '?' is '1', else '1' - -where '?' is always either '0' or '1'. - -Expressions with an implicit 'this' target: - -:: - - $<TARGET_PROPERTY:prop> = The value of the property prop on the target on which the generator expression is evaluated. +Introduction +============ + +Generator expressions are evaluated during build system generation to produce +information specific to each build configuration. + +Generator expressions are allowed in the context of many target properties, +such as :prop_tgt:`LINK_LIBRARIES`, :prop_tgt:`INCLUDE_DIRECTORIES`, +:prop_tgt:`COMPILE_DEFINITIONS` and others. They may also be used when using +commands to populate those properties, such as :command:`target_link_libraries`, +:command:`target_include_directories`, :command:`target_compile_definitions` +and others. + +This means that they enable conditional linking, conditional +definitions used when compiling, and conditional include directories and +more. The conditions may be based on the build configuration, target +properties, platform information or any other queryable information. + +Logical Expressions +=================== + +Logical expressions are used to create conditional output. The basic +expressions are the ``0`` and ``1`` expressions. Because other logical +expressions evaluate to either ``0`` or ``1``, they can be composed to +create conditional output:: + + $<$<CONFIG:Debug>:DEBUG_MODE> + +expands to ``DEBUG_MODE`` when the ``Debug`` configuration is used, and +otherwise expands to nothing. + +``$<0:...>`` + Empty string (ignores ``...``) +``$<1:...>`` + Content of ``...`` +``$<BOOL:...>`` + ``1`` if the ``...`` is true, else ``0`` +``$<AND:?[,?]...>`` + ``1`` if all ``?`` are ``1``, else ``0`` + + The ``?`` must always be either ``0`` or ``1`` in boolean expressions. + +``$<OR:?[,?]...>`` + ``0`` if all ``?`` are ``0``, else ``1`` +``$<NOT:?>`` + ``0`` if ``?`` is ``1``, else ``1`` +``$<STREQUAL:a,b>`` + ``1`` if ``a`` is STREQUAL ``b``, else ``0`` +``$<CONFIG:cfg>`` + ``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison. + The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by + this expression when it is evaluated on a property on an :prop_tgt:`IMPORTED` + target. +``$<PLATFORM_ID:comp>`` + ``1`` if the CMake-id of the platform matches ``comp``, otherwise ``0``. +``$<C_COMPILER_ID:comp>`` + ``1`` if the CMake-id of the C compiler matches ``comp``, otherwise ``0``. +``$<CXX_COMPILER_ID:comp>`` + ``1`` if the CMake-id of the CXX compiler matches ``comp``, otherwise ``0``. +``$<VERSION_GREATER:v1,v2>`` + ``1`` if ``v1`` is a version greater than ``v2``, else ``0``. +``$<VERSION_LESS:v1,v2>`` + ``1`` if ``v1`` is a version less than ``v2``, else ``0``. +``$<VERSION_EQUAL:v1,v2>`` + ``1`` if ``v1`` is the same version as ``v2``, else ``0``. +``$<C_COMPILER_VERSION:ver>`` + ``1`` if the version of the C compiler matches ``ver``, otherwise ``0``. +``$<CXX_COMPILER_VERSION:ver>`` + ``1`` if the version of the CXX compiler matches ``ver``, otherwise ``0``. +``$<TARGET_POLICY:pol>`` + ``1`` if the policy ``pol`` was NEW when the 'head' target was created, + else ``0``. If the policy was not set, the warning message for the policy + will be emitted. This generator expression only works for a subset of + policies. + +Informational Expressions +========================= + +These expressions expand to some information. The information may be used +directly, eg:: + + include_directories(/usr/include/$<CXX_COMPILER_ID>/) + +expands to ``/usr/include/GNU/`` or ``/usr/include/Clang/`` etc, depending on +the Id of the compiler. + +These expressions may also may be combined with logical expressions:: + + $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,4.2.0>:OLD_COMPILER> + +expands to ``OLD_COMPILER`` if the +:variable:`CMAKE_CXX_COMPILER_VERSION <CMAKE_<LANG>_COMPILER_VERSION>` is less +than 4.2.0. + +``$<CONFIGURATION>`` + Configuration name +``$<PLATFORM_ID>`` + The CMake-id of the platform +``$<C_COMPILER_ID>`` + The CMake-id of the C compiler used. +``$<CXX_COMPILER_ID>`` + The CMake-id of the CXX compiler used. +``$<C_COMPILER_VERSION>`` + The version of the C compiler used. +``$<CXX_COMPILER_VERSION>`` + The version of the CXX compiler used. +``$<TARGET_FILE:tgt>`` + Full path to main file (.exe, .so.1.2, .a) where ``tgt`` is the name of a target. +``$<TARGET_FILE_NAME:tgt>`` + Name of main file (.exe, .so.1.2, .a). +``$<TARGET_FILE_DIR:tgt>`` + Directory of main file (.exe, .so.1.2, .a). +``$<TARGET_LINKER_FILE:tgt>`` + File used to link (.a, .lib, .so) where ``tgt`` is the name of a target. +``$<TARGET_LINKER_FILE_NAME:tgt>`` + Name of file used to link (.a, .lib, .so). +``$<TARGET_LINKER_FILE_DIR:tgt>`` + Directory of file used to link (.a, .lib, .so). +``$<TARGET_SONAME_FILE:tgt>`` + File with soname (.so.3) where ``tgt`` is the name of a target. +``$<TARGET_SONAME_FILE_NAME:tgt>`` + Name of file with soname (.so.3). +``$<TARGET_SONAME_FILE_DIR:tgt>`` + Directory of with soname (.so.3). +``$<TARGET_PROPERTY:tgt,prop>`` + Value of the property ``prop`` on the target ``tgt``. + + Note that ``tgt`` is not added as a dependency of the target this + expression is evaluated on. +``$<TARGET_PROPERTY:prop>`` + Value of the property ``prop`` on the target on which the generator + expression is evaluated. +``$<INSTALL_PREFIX>`` + Content of the install prefix when the target is exported via + :command:`install(EXPORT)` and empty otherwise. + +Output Expressions +================== + +These expressions generate output, in some cases depending on an input. These +expressions may be combined with other expressions for information or logical +comparison:: + + -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I> + +generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target +property with each entry preceeded by ``-I``. Note that a more-complete use +in this situation would require first checking if the INCLUDE_DIRECTORIES +property is non-empty:: + + $<$<BOOL:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>>:-I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I>> + +``$<JOIN:list,...>`` + Joins the list with the content of ``...`` +``$<ANGLE-R>`` + A literal ``>``. Used to compare strings which contain a ``>`` for example. +``$<COMMA>`` + A literal ``,``. Used to compare strings which contain a ``,`` for example. +``$<SEMICOLON>`` + A literal ``;``. Used to prevent list expansion on an argument with ``;``. +``$<TARGET_NAME:...>`` + Marks ``...`` as being the name of a target. This is required if exporting + targets to multiple dependent export sets. The ``...`` must be a literal + name of a target- it may not contain generator expressions. +``$<INSTALL_INTERFACE:...>`` + Content of ``...`` when the property is exported using :command:`install(EXPORT)`, + and empty otherwise. +``$<BUILD_INTERFACE:...>`` + 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 ec1f58a..b72c7ef 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -7,40 +7,79 @@ cmake-generators(7) .. contents:: -All Generators -============== +Introduction +============ + +A *CMake Generator* is responsible for writing the input files for +a native build system. Exactly one of the `CMake Generators`_ must be +selected for a build tree to determine what native build system is to +be used. Optionally one of the `Extra Generators`_ may be selected +as a variant of some of the `Command-Line Build Tool Generators`_ to +produce project files for an auxiliary IDE. + +CMake Generators are platform-specific so each may be available only +on certain platforms. The :manual:`cmake(1)` command-line tool ``--help`` +output lists available generators on the current platform. Use its ``-G`` +option to specify the generator for a new build tree. +The :manual:`cmake-gui(1)` offers interactive selection of a generator +when creating a new build tree. + +CMake Generators +================ + +Command-Line Build Tool Generators +---------------------------------- + +These generators support command-line build tools. In order to use them, +one must launch CMake from a command-line prompt whose environment is +already configured for the chosen compiler and build tool. .. toctree:: :maxdepth: 1 /generator/Borland Makefiles - /generator/CodeBlocks - MinGW Makefiles - /generator/CodeBlocks - Ninja - /generator/CodeBlocks - NMake Makefiles - /generator/CodeBlocks - Unix Makefiles - /generator/Eclipse CDT4 - MinGW Makefiles - /generator/Eclipse CDT4 - Ninja - /generator/Eclipse CDT4 - NMake Makefiles - /generator/Eclipse CDT4 - Unix Makefiles - /generator/KDevelop3 - /generator/KDevelop3 - Unix Makefiles - /generator/MinGW Makefiles /generator/MSYS Makefiles - /generator/Ninja - /generator/NMake Makefiles JOM + /generator/MinGW Makefiles /generator/NMake Makefiles - /generator/Sublime Text 2 - MinGW Makefiles - /generator/Sublime Text 2 - Ninja - /generator/Sublime Text 2 - NMake Makefiles - /generator/Sublime Text 2 - Unix Makefiles + /generator/NMake Makefiles JOM + /generator/Ninja /generator/Unix Makefiles - /generator/Visual Studio 10 2010 - /generator/Visual Studio 11 2012 - /generator/Visual Studio 12 2013 + /generator/Watcom WMake + +IDE Build Tool Generators +------------------------- + +These generators support Integrated Development Environment (IDE) +project files. Since the IDEs configure their own environment +one may launch CMake from any environment. + +.. toctree:: + :maxdepth: 1 + /generator/Visual Studio 6 - /generator/Visual Studio 7 .NET 2003 /generator/Visual Studio 7 + /generator/Visual Studio 7 .NET 2003 /generator/Visual Studio 8 2005 /generator/Visual Studio 9 2008 - /generator/Watcom WMake + /generator/Visual Studio 10 2010 + /generator/Visual Studio 11 2012 + /generator/Visual Studio 12 2013 /generator/Xcode + +Extra Generators +================ + +Some of the `CMake Generators`_ listed in the :manual:`cmake(1)` +command-line tool ``--help`` output may have variants that specify +an extra generator for an auxiliary IDE tool. Such generator +names have the form ``<extra-generator> - <main-generator>``. +The following extra generators are known to CMake. + +.. toctree:: + :maxdepth: 1 + + /generator/CodeBlocks + /generator/Eclipse CDT4 + /generator/KDevelop3 + /generator/Kate + /generator/Sublime Text 2 diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index 7285897..61d0a42 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -312,6 +312,9 @@ inside out, e.g. ``${outer_${inner_variable}_variable}``. The `Variables`_ section documents the scope of variable names and how their values are set. +An *environment variable reference* has the form ``$ENV{VAR}`` and +is evaluated in the same contexts as a normal variable reference. + Comments -------- diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 01efcf7..f148a51 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -74,6 +74,7 @@ All Modules /module/FindAVIFile /module/FindBISON /module/FindBLAS + /module/FindBacktrace /module/FindBoost /module/FindBullet /module/FindBZip2 diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 2430ee9..5e94f89 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -73,3 +73,5 @@ All Policies /policy/CMP0037 /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 d6d42ad..d569e31 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -27,7 +27,9 @@ Properties of Global Scope /prop_gbl/IN_TRY_COMPILE /prop_gbl/PACKAGES_FOUND /prop_gbl/PACKAGES_NOT_FOUND + /prop_gbl/JOB_POOLS /prop_gbl/PREDEFINED_TARGETS_FOLDER + /prop_gbl/ECLIPSE_EXTRA_NATURES /prop_gbl/REPORT_UNDEFINED_PROPERTIES /prop_gbl/RULE_LAUNCH_COMPILE /prop_gbl/RULE_LAUNCH_CUSTOM @@ -79,6 +81,7 @@ Properties on Targets /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY /prop_tgt/ARCHIVE_OUTPUT_NAME_CONFIG /prop_tgt/ARCHIVE_OUTPUT_NAME + /prop_tgt/AUTOGEN_TARGET_DEPENDS /prop_tgt/AUTOMOC_MOC_OPTIONS /prop_tgt/AUTOMOC /prop_tgt/AUTOUIC @@ -138,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 @@ -146,6 +150,8 @@ Properties on Targets /prop_tgt/INTERFACE_SYSTEM_INCLUDE_DIRECTORIES /prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_tgt/INTERPROCEDURAL_OPTIMIZATION + /prop_tgt/JOB_POOL_COMPILE + /prop_tgt/JOB_POOL_LINK /prop_tgt/LABELS /prop_tgt/LANG_VISIBILITY_PRESET /prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG 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 d1176ad..d86db37 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -41,6 +41,8 @@ Variables that Provide Information /variable/CMAKE_HOME_DIRECTORY /variable/CMAKE_IMPORT_LIBRARY_PREFIX /variable/CMAKE_IMPORT_LIBRARY_SUFFIX + /variable/CMAKE_JOB_POOL_COMPILE + /variable/CMAKE_JOB_POOL_LINK /variable/CMAKE_LINK_LIBRARY_SUFFIX /variable/CMAKE_MAJOR_VERSION /variable/CMAKE_MAKE_PROGRAM @@ -62,6 +64,7 @@ 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 @@ -94,10 +97,16 @@ Variables that Change Behavior /variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName /variable/CMAKE_ERROR_DEPRECATED /variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION + /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 @@ -112,6 +121,7 @@ Variables that Change Behavior /variable/CMAKE_PREFIX_PATH /variable/CMAKE_PROGRAM_PATH /variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY + /variable/CMAKE_STAGING_PREFIX /variable/CMAKE_SYSTEM_IGNORE_PATH /variable/CMAKE_SYSTEM_INCLUDE_PATH /variable/CMAKE_SYSTEM_LIBRARY_PATH @@ -203,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 @@ -237,6 +248,8 @@ Variables for Languages /variable/CMAKE_LANG_COMPILER_ID /variable/CMAKE_LANG_COMPILER_LOADED /variable/CMAKE_LANG_COMPILER + /variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN + /variable/CMAKE_LANG_COMPILER_TARGET /variable/CMAKE_LANG_COMPILER_VERSION /variable/CMAKE_LANG_CREATE_SHARED_LIBRARY /variable/CMAKE_LANG_CREATE_SHARED_MODULE diff --git a/Help/module/FindBacktrace.rst b/Help/module/FindBacktrace.rst new file mode 100644 index 0000000..e1ca48c --- /dev/null +++ b/Help/module/FindBacktrace.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindBacktrace.cmake diff --git a/Help/policy/CMP0037.rst b/Help/policy/CMP0037.rst index 5df3c00..059b2e6 100644 --- a/Help/policy/CMP0037.rst +++ b/Help/policy/CMP0037.rst @@ -1,19 +1,24 @@ CMP0037 ------- -Target names should match a validity pattern. +Target names should not be reserved and should match a validity pattern. -CMake 2.8.12 and lower allowed creating targets using :command:`add_library` and -:command:`add_executable` with unrestricted choice for the target name. Newer -cmake features such as :manual:`cmake-generator-expressions(7)` and some +CMake 2.8.12 and lower allowed creating targets using :command:`add_library`, +:command:`add_executable` and :command:`add_custom_target` with unrestricted +choice for the target name. Newer cmake features such +as :manual:`cmake-generator-expressions(7)` and some diagnostics expect target names to match a restricted pattern. Target names may contain upper and lower case letters, numbers, the underscore character (_), dot(.), plus(+) and minus(-). As a special case, ALIAS targets and INTERFACE library targets may contain two consequtive colons. -The OLD behavior for this policy is to allow creating targets which do not match -the validity pattern. The NEW behavior for this policy is to report an error +Target names reserved by one or more CMake generators are not allowed. +Among others these include "all", "help" and "test". + +The OLD behavior for this policy is to allow creating targets with +reserved names or which do not match the validity pattern. +The NEW behavior for this policy is to report an error if an add_* command is used with an invalid target name. This policy was introduced in CMake version 3.0.0. CMake version diff --git a/Help/policy/CMP0040.rst b/Help/policy/CMP0040.rst new file mode 100644 index 0000000..5d27f62 --- /dev/null +++ b/Help/policy/CMP0040.rst @@ -0,0 +1,16 @@ +CMP0040 +------- + +The target in the TARGET signature of add_custom_command() must exist. + +CMake 2.8.12 and lower silently ignored a custom command created with +the TARGET signature of :command:`add_custom_command` +if the target is unknown. + +The OLD behavior for this policy is to ignore custom commands +for unknown targets. The NEW behavior for this policy is to report an error +if the target referenced in :command:`add_custom_command` is unknown. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/policy/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_gbl/ECLIPSE_EXTRA_NATURES.rst b/Help/prop_gbl/ECLIPSE_EXTRA_NATURES.rst new file mode 100644 index 0000000..6d1529d --- /dev/null +++ b/Help/prop_gbl/ECLIPSE_EXTRA_NATURES.rst @@ -0,0 +1,8 @@ +ECLIPSE_EXTRA_NATURES +--------------------- + +List of natures to add to the generated Eclipse project file. + +Eclipse projects specify language plugins by using natures. This property +should be set to the unique identifier for a nature (which looks like a Java +package name). diff --git a/Help/prop_gbl/JOB_POOLS.rst b/Help/prop_gbl/JOB_POOLS.rst new file mode 100644 index 0000000..98b9f7e --- /dev/null +++ b/Help/prop_gbl/JOB_POOLS.rst @@ -0,0 +1,20 @@ +JOB_POOLS +--------- + +Ninja only: List of available pools. + +A pool is a named integer property and defines the maximum number +of concurrent jobs which can be started by a rule assigned to the pool. +The :prop_gbl:`JOB_POOLS` property is a semicolon-separated list of +pairs using the syntax NAME=integer (without a space after the equality sign). + +For instance: + +.. code-block:: cmake + + set_property(GLOBAL PROPERTY JOB_POOLS two_jobs=2 ten_jobs=10) + +Defined pools could be used globally by setting +:variable:`CMAKE_JOB_POOL_COMPILE` and :variable:`CMAKE_JOB_POOL_LINK` +or per target by setting the target properties +:prop_tgt:`JOB_POOL_COMPILE` and :prop_tgt:`JOB_POOL_LINK`. diff --git a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst new file mode 100644 index 0000000..006c83a --- /dev/null +++ b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst @@ -0,0 +1,14 @@ +AUTOGEN_TARGET_DEPENDS +---------------------- + +Target dependencies of the corresponding ``_automoc`` target. + +Targets which have their :prop_tgt:`AUTOMOC` target set to true have a +corresponding ``_automoc`` target which is used to autogenerate generate moc +files. As this ``_automoc`` target is created at generate-time, it is not +possible to define dependencies of it, such as to create inputs for the moc +executable. + +The ``AUTOGEN_TARGET_DEPENDS`` target can be set instead to a list of dependencies +for the ``_automoc`` target. The buildsystem will be generated to depend on its +contents. 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/JOB_POOL_COMPILE.rst b/Help/prop_tgt/JOB_POOL_COMPILE.rst new file mode 100644 index 0000000..5d8e940 --- /dev/null +++ b/Help/prop_tgt/JOB_POOL_COMPILE.rst @@ -0,0 +1,17 @@ +JOB_POOL_COMPILE +---------------- + +Ninja only: Pool used for compiling. + +The number of parallel compile processes could be limited by defining +pools with the global :prop_gbl:`JOB_POOLS` +property and then specifying here the pool name. + +For instance: + +.. code-block:: cmake + + set_property(TARGET myexe PROPERTY JOB_POOL_COMPILE ten_jobs) + +This property is initialized by the value of +:variable:`CMAKE_JOB_POOL_COMPILE`. diff --git a/Help/prop_tgt/JOB_POOL_LINK.rst b/Help/prop_tgt/JOB_POOL_LINK.rst new file mode 100644 index 0000000..716f53f --- /dev/null +++ b/Help/prop_tgt/JOB_POOL_LINK.rst @@ -0,0 +1,16 @@ +JOB_POOL_LINK +------------- + +Ninja only: Pool used for linking. + +The number of parallel link processes could be limited by defining +pools with the global :prop_gbl:`JOB_POOLS` +property and then specifing here the pool name. + +For instance: + +.. code-block:: cmake + + set_property(TARGET myexe PROPERTY JOB_POOL_LINK two_jobs) + +This property is initialized by the value of :variable:`CMAKE_JOB_POOL_LINK`. 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/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index 2ded823..6b17f6e 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -6,6 +6,6 @@ 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. +COMPILE_DEFINITIONS, COMPILE_OPTIONS and AUTOUIC_OPTIONS target properties. +In that case, it outputs a backtrace for each entry in the target property. Default is unset. diff --git a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst index 91231b0..70d920b 100644 --- a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst @@ -3,11 +3,13 @@ CMAKE_FIND_NO_INSTALL_PREFIX Ignore the :variable:`CMAKE_INSTALL_PREFIX` when searching for assets. -CMake adds the :variable:`CMAKE_INSTALL_PREFIX` to the +CMake adds the :variable:`CMAKE_INSTALL_PREFIX` and the +:variable:`CMAKE_STAGING_PREFIX` variable to the :variable:`CMAKE_SYSTEM_PREFIX_PATH` by default. This variable may be set on the command line to control that behavior. Set :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` to TRUE to tell find_package not -to search in the :variable:`CMAKE_INSTALL_PREFIX` by default. Note that the +to search in the :variable:`CMAKE_INSTALL_PREFIX` or +:variable:`CMAKE_STAGING_PREFIX` by default. Note that the prefix may still be searched for other reasons, such as being the same prefix as the CMake installation, or for being a built-in system prefix. 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_JOB_POOL_COMPILE.rst b/Help/variable/CMAKE_JOB_POOL_COMPILE.rst new file mode 100644 index 0000000..e5c2d9a --- /dev/null +++ b/Help/variable/CMAKE_JOB_POOL_COMPILE.rst @@ -0,0 +1,6 @@ +CMAKE_JOB_POOL_COMPILE +---------------------- + +This variable is used to initialize the :prop_tgt:`JOB_POOL_COMPILE` +property on all the targets. See :prop_tgt:`JOB_POOL_COMPILE` +for additional information. diff --git a/Help/variable/CMAKE_JOB_POOL_LINK.rst b/Help/variable/CMAKE_JOB_POOL_LINK.rst new file mode 100644 index 0000000..338f771 --- /dev/null +++ b/Help/variable/CMAKE_JOB_POOL_LINK.rst @@ -0,0 +1,6 @@ +CMAKE_JOB_POOL_LINK +---------------------- + +This variable is used to initialize the :prop_tgt:`JOB_POOL_LINK` +property on all the targets. See :prop_tgt:`JOB_POOL_LINK` +for additional information. diff --git a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst new file mode 100644 index 0000000..033998d --- /dev/null +++ b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst @@ -0,0 +1,13 @@ +CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN +---------------------------------------- + +The external toolchain for cross-compiling, if supported. + +Some compiler toolchains do not ship their own auxilliary utilities such as +archivers and linkers. The compiler driver may support a command-line argument +to specify the location of such tools. CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN +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 :variable:`CMAKE_TOOLCHAIN_FILE` variable. diff --git a/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst b/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst new file mode 100644 index 0000000..656c57d --- /dev/null +++ b/Help/variable/CMAKE_LANG_COMPILER_TARGET.rst @@ -0,0 +1,11 @@ +CMAKE_<LANG>_COMPILER_TARGET +---------------------------- + +The target for cross-compiling, if supported. + +Some compiler drivers are inherently cross-compilers, such as clang and +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 :variable:`CMAKE_TOOLCHAIN_FILE` variable. 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_STAGING_PREFIX.rst b/Help/variable/CMAKE_STAGING_PREFIX.rst new file mode 100644 index 0000000..c4de7da --- /dev/null +++ b/Help/variable/CMAKE_STAGING_PREFIX.rst @@ -0,0 +1,13 @@ +CMAKE_STAGING_PREFIX +-------------------- + +This variable may be set to a path to install to when cross-compiling. This can +be useful if the path in :variable:`CMAKE_SYSROOT` is read-only, or otherwise +should remain pristine. + +The CMAKE_STAGING_PREFIX location is also used as a search prefix by the ``find_*`` +commands. This can be controlled by setting the :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` +variable. + +If any RPATH/RUNPATH entries passed to the linker contain the CMAKE_STAGING_PREFIX, +the matching path fragments are replaced with the :variable:`CMAKE_INSTALL_PREFIX`. diff --git a/Help/variable/CMAKE_SYSROOT.rst b/Help/variable/CMAKE_SYSROOT.rst new file mode 100644 index 0000000..7aa0450 --- /dev/null +++ b/Help/variable/CMAKE_SYSROOT.rst @@ -0,0 +1,12 @@ +CMAKE_SYSROOT +------------- + +Path to pass to the compiler in the ``--sysroot`` flag. + +The ``CMAKE_SYSROOT`` content is passed to the compiler in the ``--sysroot`` +flag, if supported. The path is also stripped from the RPATH/RUNPATH if +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 :variable:`CMAKE_TOOLCHAIN_FILE` variable. diff --git a/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst b/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst index 2dbae1f..537eaba 100644 --- a/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst +++ b/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst @@ -9,8 +9,8 @@ appropriate subdirectories to the base directories. So FIND_PROGRAM() adds /bin to each of the directories in the path, FIND_LIBRARY() appends /lib to each of the directories, and FIND_PATH() and FIND_FILE() append /include . By default this contains the standard -directories for the current system and the CMAKE_INSTALL_PREFIX. It -is NOT intended to be modified by the project, use CMAKE_PREFIX_PATH -for this. See also CMAKE_SYSTEM_INCLUDE_PATH, +directories for the current system, the CMAKE_INSTALL_PREFIX and +the :variable:`CMAKE_STAGING_PREFIX`. It is NOT intended to be modified by +the project, use CMAKE_PREFIX_PATH for this. See also CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_SYSTEM_LIBRARY_PATH, CMAKE_SYSTEM_PROGRAM_PATH, and CMAKE_SYSTEM_IGNORE_PATH. 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/Licenses/LGPLv2.1.txt b/Licenses/LGPLv2.1.txt new file mode 100644 index 0000000..4362b49 --- /dev/null +++ b/Licenses/LGPLv2.1.txt @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/Licenses/README.rst b/Licenses/README.rst new file mode 100644 index 0000000..e798f78 --- /dev/null +++ b/Licenses/README.rst @@ -0,0 +1,7 @@ +Licenses +======== + +The CMake source tree is distributed under terms of the BSD 3-Clause license. + +This directory contains other license files that need to be packaged with +binary distributions when certain third-party libraries are included. 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/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 0d47a60..438a98a 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -158,6 +158,12 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-) + elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$") + if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$") + set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) + endif() endif () # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index e882189..5f9d9bf 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -156,6 +156,12 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-) + elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$") + if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$") + set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) + endif() endif () # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 93358c7..518b8c6 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -85,7 +85,7 @@ endfunction() #----------------------------------------------------------------------------- # Function to write the compiler id source file. function(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src) - find_file(src_in ${src}.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH) + find_file(src_in ${src}.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) file(READ ${src_in} ID_CONTENT_IN) unset(src_in CACHE) string(CONFIGURE "${ID_CONTENT_IN}" ID_CONTENT_OUT @ONLY) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 315d57e..829b6ff 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -43,7 +43,12 @@ if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC" # in all other cases search for ar, ranlib, etc. else() - + if(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN) + set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}/bin) + endif() + if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) + set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}/bin) + endif() find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index b67e0f0..85c1fdf 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -78,7 +78,7 @@ processorcount(_CMAKE_ECLIPSE_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_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) +if("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND CMAKE_HOST_UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) set(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}") endif() 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/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/CPackComponent.cmake b/Modules/CPackComponent.cmake index a55a01e..1433d9e 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -375,17 +375,17 @@ endmacro() # Macro that adds a component to the CPack installer macro(cpack_add_component compname) - string(TOUPPER ${compname} CPACK_ADDCOMP_UNAME) - cpack_parse_arguments(CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME} + string(TOUPPER ${compname} _CPACK_ADDCOMP_UNAME) + cpack_parse_arguments(CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME} "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE" "HIDDEN;REQUIRED;DISABLED;DOWNLOADED" ${ARGN} ) - if (CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED) - set(CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n") + if (CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DOWNLOADED) + set(_CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n") else () - set(CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n") + set(_CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n") endif () if(NOT CPACK_MONOLITHIC_INSTALL) @@ -394,51 +394,51 @@ macro(cpack_add_component compname) # take care of any components that have been added after the CPack # moduled was included. if(NOT CPACK_COMPONENTS_ALL_SET_BY_USER) - get_cmake_property(CPACK_ADDCOMP_COMPONENTS COMPONENTS) - set(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL") - foreach(COMP ${CPACK_ADDCOMP_COMPONENTS}) - set(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR} ${COMP}") + get_cmake_property(_CPACK_ADDCOMP_COMPONENTS COMPONENTS) + set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL") + foreach(COMP ${_CPACK_ADDCOMP_COMPONENTS}) + set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR} ${COMP}") endforeach() - set(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR})\n") + set(_CPACK_ADDCOMP_STR "${_CPACK_ADDCOMP_STR})\n") endif() endif() cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISPLAY_NAME - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DISPLAY_NAME + _CPACK_ADDCOMP_STR) cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DESCRIPTION - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DESCRIPTION + _CPACK_ADDCOMP_STR) cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_GROUP - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_GROUP + _CPACK_ADDCOMP_STR) cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DEPENDS - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DEPENDS + _CPACK_ADDCOMP_STR) cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_INSTALL_TYPES - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_INSTALL_TYPES + _CPACK_ADDCOMP_STR) cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_HIDDEN - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_HIDDEN + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_REQUIRED - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_REQUIRED + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISABLED - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DISABLED + _CPACK_ADDCOMP_STR) cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED - CPACK_ADDCOMP_STR) + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DOWNLOADED + _CPACK_ADDCOMP_STR) # Backward compatibility issue. # Write to config iff the macros is used after CPack.cmake has been # included, other it's not necessary because the variables # will be encoded by cpack_encode_variables. if(CPack_CMake_INCLUDED) - file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDCOMP_STR}") + file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_ADDCOMP_STR}") endif() endmacro() @@ -446,7 +446,7 @@ endmacro() macro(cpack_add_component_group grpname) string(TOUPPER ${grpname} CPACK_ADDGRP_UNAME) cpack_parse_arguments(CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME} - "DISPLAY_NAME;DESCRIPTION" + "DISPLAY_NAME;DESCRIPTION;PARENT_GROUP" "EXPANDED;BOLD_TITLE" ${ARGN} ) diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 3f0978d..237c5bc 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 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/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 7d7be5c..eeba119 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -30,5 +30,12 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0) + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") + set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "-gcc-toolchain ") + else() + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") + set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "--gcc-toolchain=") + endif() endmacro() endif() diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 504704d..f01255c 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -30,6 +30,7 @@ macro(__compiler_gnu lang) endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=") # Older versions of gcc (< 4.5) contain a bug causing them to report a missing # header file as a warning if depfiles are enabled, causing check_header_file diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 84fa613..63f1180 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -4,11 +4,11 @@ # # Create custom targets to build projects in external trees # -# The 'ExternalProject_Add' function creates a custom target to drive +# The ``ExternalProject_Add`` function creates a custom target to drive # download, update/patch, configure, build, install and test steps of an # external project: # -# :: +# .. code-block:: cmake # # ExternalProject_Add(<name> # Name for custom target # [DEPENDS projects...] # Targets on which the project depends @@ -72,46 +72,42 @@ # ) # # The ``*_DIR`` options specify directories for the project, with default -# directories computed as follows. If the PREFIX option is given to -# ExternalProject_Add() or the EP_PREFIX directory property is set, then -# an external project is built and installed under the specified prefix: +# directories computed as follows. If the ``PREFIX`` option is given to +# ``ExternalProject_Add()`` or the ``EP_PREFIX`` directory property is set, +# then an external project is built and installed under the specified prefix:: # -# :: +# TMP_DIR = <prefix>/tmp +# STAMP_DIR = <prefix>/src/<name>-stamp +# DOWNLOAD_DIR = <prefix>/src +# SOURCE_DIR = <prefix>/src/<name> +# BINARY_DIR = <prefix>/src/<name>-build +# INSTALL_DIR = <prefix> # -# TMP_DIR = <prefix>/tmp -# STAMP_DIR = <prefix>/src/<name>-stamp -# DOWNLOAD_DIR = <prefix>/src -# SOURCE_DIR = <prefix>/src/<name> -# BINARY_DIR = <prefix>/src/<name>-build -# INSTALL_DIR = <prefix> +# Otherwise, if the ``EP_BASE`` directory property is set then components +# of an external project are stored under the specified base:: # -# Otherwise, if the EP_BASE directory property is set then components of -# an external project are stored under the specified base: +# TMP_DIR = <base>/tmp/<name> +# STAMP_DIR = <base>/Stamp/<name> +# DOWNLOAD_DIR = <base>/Download/<name> +# SOURCE_DIR = <base>/Source/<name> +# BINARY_DIR = <base>/Build/<name> +# INSTALL_DIR = <base>/Install/<name> # -# :: +# If no ``PREFIX``, ``EP_PREFIX``, or ``EP_BASE`` is specified then the +# default is to set ``PREFIX`` to ``<name>-prefix``. Relative paths are +# interpreted with respect to the build directory corresponding to the +# source directory in which ``ExternalProject_Add`` is invoked. # -# TMP_DIR = <base>/tmp/<name> -# STAMP_DIR = <base>/Stamp/<name> -# DOWNLOAD_DIR = <base>/Download/<name> -# SOURCE_DIR = <base>/Source/<name> -# BINARY_DIR = <base>/Build/<name> -# INSTALL_DIR = <base>/Install/<name> -# -# If no PREFIX, EP_PREFIX, or EP_BASE is specified then the default is -# to set PREFIX to "<name>-prefix". Relative paths are interpreted with -# respect to the build directory corresponding to the source directory -# in which ExternalProject_Add is invoked. -# -# If SOURCE_DIR is explicitly set to an existing directory the project +# If ``SOURCE_DIR`` is explicitly set to an existing directory the project # will be built from it. Otherwise a download step must be specified -# using one of the DOWNLOAD_COMMAND, CVS_*, SVN_*, or URL options. The -# URL option may refer locally to a directory or source tarball, or -# refer to a remote tarball (e.g. http://.../src.tgz). +# using one of the ``DOWNLOAD_COMMAND``, ``CVS_*``, ``SVN_*``, or ``URL`` +# options. The ``URL`` option may refer locally to a directory or source +# tarball, or refer to a remote tarball (e.g. ``http://.../src.tgz``). # -# The 'ExternalProject_Add_Step' function adds a custom step to an +# The ``ExternalProject_Add_Step`` function adds a custom step to an # external project: # -# :: +# .. code-block:: cmake # # ExternalProject_Add_Step(<name> <step> # Names of project and custom step # [COMMAND cmd...] # Command line invoked by this step @@ -125,51 +121,45 @@ # ) # # The command line, comment, and working directory of every standard and -# custom step is processed to replace tokens <SOURCE_DIR>, <BINARY_DIR>, -# <INSTALL_DIR>, and <TMP_DIR> with corresponding property values. +# custom step is processed to replace tokens ``<SOURCE_DIR>``, +# ``<BINARY_DIR>``, ``<INSTALL_DIR>``, and ``<TMP_DIR>`` with +# corresponding property values. # -# Any builtin step that specifies a "<step>_COMMAND cmd..." or custom -# step that specifies a "COMMAND cmd..." may specify additional command -# lines using the form "COMMAND cmd...". At build time the commands -# will be executed in order and aborted if any one fails. For example: +# Any builtin step that specifies a ``<step>_COMMAND cmd...`` or custom +# step that specifies a ``COMMAND cmd...`` may specify additional command +# lines using the form ``COMMAND cmd...``. At build time the commands +# will be executed in order and aborted if any one fails. For example:: # -# :: +# ... BUILD_COMMAND make COMMAND echo done ... # -# ... BUILD_COMMAND make COMMAND echo done ... -# -# specifies to run "make" and then "echo done" during the build step. +# specifies to run ``make`` and then ``echo done`` during the build step. # Whether the current working directory is preserved between commands is -# not defined. Behavior of shell operators like "&&" is not defined. -# -# The 'ExternalProject_Get_Property' function retrieves external project -# target properties: +# not defined. Behavior of shell operators like ``&&`` is not defined. # -# :: +# The ``ExternalProject_Get_Property`` function retrieves external project +# target properties:: # -# ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]]) +# ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]]) # # It stores property values in variables of the same name. Property # names correspond to the keyword argument names of -# 'ExternalProject_Add'. +# ``ExternalProject_Add``. # -# The 'ExternalProject_Add_StepTargets' function generates custom -# targets for the steps listed: +# The ``ExternalProject_Add_StepTargets`` function generates custom +# targets for the steps listed:: # -# :: +# ExternalProject_Add_StepTargets(<name> [step1 [step2 [...]]]) # -# ExternalProject_Add_StepTargets(<name> [step1 [step2 [...]]]) -# -# -# -# If STEP_TARGETS is set then ExternalProject_Add_StepTargets is +# If ``STEP_TARGETS`` is set then ``ExternalProject_Add_StepTargets`` is # automatically called at the end of matching calls to -# ExternalProject_Add_Step. Pass STEP_TARGETS explicitly to individual -# ExternalProject_Add calls, or implicitly to all ExternalProject_Add -# calls by setting the directory property EP_STEP_TARGETS. +# ``ExternalProject_Add_Step``. Pass ``STEP_TARGETS`` explicitly to +# individual ``ExternalProject_Add`` calls, or implicitly to all +# ``ExternalProject_Add`` calls by setting the directory property +# ``EP_STEP_TARGETS``. # -# If STEP_TARGETS is not set, clients may still manually call -# ExternalProject_Add_StepTargets after calling ExternalProject_Add or -# ExternalProject_Add_Step. +# If ``STEP_TARGETS`` is not set, clients may still manually call +# ``ExternalProject_Add_StepTargets`` after calling +# ``ExternalProject_Add`` or ``ExternalProject_Add_Step``. # # This functionality is provided to make it easy to drive the steps # independently of each other by specifying targets on build command @@ -181,15 +171,14 @@ # will also run to ensure everything is up to date. # # For example, to drive configure, build and test steps independently -# for each ExternalProject_Add call in your project, write the following -# line prior to any ExternalProject_Add calls in your CMakeLists file: -# -# :: +# for each ``ExternalProject_Add`` call in your project, write the following +# line prior to any ``ExternalProject_Add`` calls in your ``CMakeLists.txt`` +# file:: # -# set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) +# set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) #============================================================================= -# Copyright 2008-2012 Kitware, Inc. +# Copyright 2008-2013 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake new file mode 100644 index 0000000..56e739e --- /dev/null +++ b/Modules/FindBacktrace.cmake @@ -0,0 +1,91 @@ +#.rst: +# FindBacktrace +# ------------- +# +# Find provider for backtrace(3). +# +# Checks if OS supports backtrace(3) via either libc or custom library. +# This module defines the following variables:: +# +# Backtrace_HEADER - The header file needed for backtrace(3). Cached. +# Could be forcibly set by user. +# Backtrace_INCLUDE_DIRS - The include directories needed to use backtrace(3) header. +# Backtrace_LIBRARIES - The libraries (linker flags) needed to use backtrace(3), if any. +# Backtrace_FOUND - Is set if and only if backtrace(3) support detected. +# +# The following cache variables are also available to set or use:: +# +# Backtrace_LIBRARY - The external library providing backtrace, if any. +# Backtrace_INCLUDE_DIR - The directory holding the backtrace(3) header. +# +# Typical usage is to generate of header file using configure_file() with the +# contents like the following:: +# +# #cmakedefine01 Backtrace_FOUND +# #if Backtrace_FOUND +# # include <${Backtrace_HEADER}> +# #endif +# +# And then reference that generated header file in actual source. + +#============================================================================= +# Copyright 2013 Vadim Zhukov +# +# 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.) + + +include(CMakePushCheckState) +include(CheckSymbolExists) +include(FindPackageHandleStandardArgs) + +# List of variables to be provided to find_package_handle_standard_args() +set(_Backtrace_STD_ARGS Backtrace_INCLUDE_DIR) + +if(Backtrace_HEADER) + set(_Backtrace_HEADER_TRY "${Backtrace_HEADER}") +else(Backtrace_HEADER) + set(_Backtrace_HEADER_TRY "execinfo.h") +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(_Backtrace_SYM_FOUND) + set(Backtrace_LIBRARY) + if(NOT Backtrace_FIND_QUIETLY) + message(STATUS "backtrace facility detected in default set of libraries") + endif() +else() + # Check for external library, for non-glibc systems + if(Backtrace_INCLUDE_DIR) + # OpenBSD has libbacktrace renamed to libexecinfo + find_library(Backtrace_LIBRARY "execinfo") + elseif() # respect user wishes + set(_Backtrace_HEADER_TRY "backtrace.h") + find_path(Backtrace_INCLUDE_DIR ${_Backtrace_HEADER_TRY}) + find_library(Backtrace_LIBRARY "backtrace") + endif() + + # Prepend list with library path as it's more common practice + set(_Backtrace_STD_ARGS Backtrace_LIBRARY ${_Backtrace_STD_ARGS}) +endif() + +set(Backtrace_LIBRARIES ${Backtrace_LIBRARY}) +set(Backtrace_HEADER "${_Backtrace_HEADER_TRY}" CACHE STRING "Header providing backtrace(3) facility") + +find_package_handle_standard_args(Backtrace FOUND_VAR Backtrace_FOUND REQUIRED_VARS ${_Backtrace_STD_ARGS}) +mark_as_advanced(Backtrace_HEADER Backtrace_INCLUDE_DIR Backtrace_LIBRARY) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 25c482e..bc66337 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -689,7 +689,12 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GDK gdk/gdk.h) _GTK2_FIND_INCLUDE_DIR(GDKCONFIG gdkconfig.h) if(UNIX) - _GTK2_FIND_LIBRARY (GDK gdk-x11 false true) + if(APPLE) + _GTK2_FIND_LIBRARY (GDK gdk-quartz false true) + endif() + if(NOT GTK2_GDK_FOUND) + _GTK2_FIND_LIBRARY (GDK gdk-x11 false true) + endif() else() _GTK2_FIND_LIBRARY (GDK gdk-win32 false true) endif() @@ -698,7 +703,12 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GTK gtk/gtk.h) if(UNIX) - _GTK2_FIND_LIBRARY (GTK gtk-x11 false true) + if(APPLE) + _GTK2_FIND_LIBRARY (GTK gtk-quartz false true) + endif() + if(NOT GTK2_GTK_FOUND) + _GTK2_FIND_LIBRARY (GTK gtk-x11 false true) + endif() else() _GTK2_FIND_LIBRARY (GTK gtk-win32 false true) endif() diff --git a/Modules/FindLATEX.cmake b/Modules/FindLATEX.cmake index e78d5bf..62eedd6 100644 --- a/Modules/FindLATEX.cmake +++ b/Modules/FindLATEX.cmake @@ -104,8 +104,9 @@ find_program(DVIPDF_CONVERTER if (WIN32) find_program(PS2PDF_CONVERTER - NAMES ps2pdf14.bat + NAMES ps2pdf14.bat ps2pdf PATHS ${GHOSTSCRIPT_LIBRARY_PATH} + ${MIKTEX_BINARY_PATH} ) else () find_program(PS2PDF_CONVERTER diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 6d418fd..ec1f881 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -90,13 +90,19 @@ find_path(SDL_INCLUDE_DIR SDL.h include/SDL include/SDL12 include/SDL11 include ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + # SDL-1.1 is the name used by FreeBSD ports... # don't confuse it for the version number. find_library(SDL_LIBRARY_TEMP NAMES SDL SDL-1.1 HINTS ENV SDLDIR - PATH_SUFFIXES lib + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} ) if(NOT SDL_BUILDING_LIBRARY) @@ -109,7 +115,7 @@ if(NOT SDL_BUILDING_LIBRARY) NAMES SDLmain SDLmain-1.1 HINTS ENV SDLDIR - PATH_SUFFIXES lib + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} PATHS /sw /opt/local diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake index 2ec6e50..e5173e3 100644 --- a/Modules/FindSDL_image.cmake +++ b/Modules/FindSDL_image.cmake @@ -57,6 +57,12 @@ find_path(SDL_IMAGE_INCLUDE_DIR SDL_image.h PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + if(NOT SDL_IMAGE_LIBRARY AND SDLIMAGE_LIBRARY) set(SDL_IMAGE_LIBRARY ${SDLIMAGE_LIBRARY} CACHE FILEPATH "file cache entry initialized from old variable name") @@ -66,7 +72,7 @@ find_library(SDL_IMAGE_LIBRARY HINTS ENV SDLIMAGEDIR ENV SDLDIR - PATH_SUFFIXES lib + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} ) if(SDL_IMAGE_INCLUDE_DIR AND EXISTS "${SDL_IMAGE_INCLUDE_DIR}/SDL_image.h") diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake index d17c907..8f2f066 100644 --- a/Modules/FindSDL_mixer.cmake +++ b/Modules/FindSDL_mixer.cmake @@ -57,6 +57,12 @@ find_path(SDL_MIXER_INCLUDE_DIR SDL_mixer.h PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + if(NOT SDL_MIXER_LIBRARY AND SDLMIXER_LIBRARY) set(SDL_MIXER_LIBRARY ${SDLMIXER_LIBRARY} CACHE FILEPATH "file cache entry initialized from old variable name") @@ -66,7 +72,7 @@ find_library(SDL_MIXER_LIBRARY HINTS ENV SDLMIXERDIR ENV SDLDIR - PATH_SUFFIXES lib + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} ) if(SDL_MIXER_INCLUDE_DIR AND EXISTS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h") diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake index c545189..e5c2cdb 100644 --- a/Modules/FindSDL_net.cmake +++ b/Modules/FindSDL_net.cmake @@ -57,6 +57,12 @@ find_path(SDL_NET_INCLUDE_DIR SDL_net.h PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + if(NOT SDL_NET_LIBRARY AND SDLNET_LIBRARY) set(SDL_NET_LIBRARY ${SDLNET_LIBRARY} CACHE FILEPATH "file cache entry initialized from old variable name") @@ -66,7 +72,7 @@ find_library(SDL_NET_LIBRARY HINTS ENV SDLNETDIR ENV SDLDIR - PATH_SUFFIXES lib + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} ) if(SDL_NET_INCLUDE_DIR AND EXISTS "${SDL_NET_INCLUDE_DIR}/SDL_net.h") diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index 863699a..3a6ab7b 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -106,7 +106,7 @@ find_library(SDL_SOUND_LIBRARY HINTS ENV SDLSOUNDDIR ENV SDLDIR - PATH_SUFFIXES lib + PATH_SUFFIXES lib VisualC/win32lib ) if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake index 8f72b1a..3f58ac1 100644 --- a/Modules/FindSDL_ttf.cmake +++ b/Modules/FindSDL_ttf.cmake @@ -57,6 +57,12 @@ find_path(SDL_TTF_INCLUDE_DIR SDL_ttf.h PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + if(NOT SDL_TTF_LIBRARY AND SDLTTF_LIBRARY) set(SDL_TTF_LIBRARY ${SDLTTF_LIBRARY} CACHE FILEPATH "file cache entry initialized from old variable name") @@ -66,7 +72,7 @@ find_library(SDL_TTF_LIBRARY HINTS ENV SDLTTFDIR ENV SDLDIR - PATH_SUFFIXES lib + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} ) if(SDL_TTF_INCLUDE_DIR AND EXISTS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h") diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index bb78bc2..8bd4048 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -52,11 +52,9 @@ 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}) + find_path(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output} NO_CMAKE_FIND_ROOT_PATH) if(SWIG_DIR) - set(SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake) + set(SWIG_USE_FILE ${CMAKE_CURRENT_LIST_DIR}/UseSWIG.cmake) execute_process(COMMAND ${SWIG_EXECUTABLE} -version OUTPUT_VARIABLE SWIG_version_output ERROR_VARIABLE SWIG_version_output @@ -75,3 +73,5 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR VERSION_VAR SWIG_VERSION ) + +mark_as_advanced(SWIG_DIR SWIG_VERSION) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 4ecab62..3c664e7 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -303,6 +303,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") # Find wxWidgets multilib base libraries. find_library(WX_base${_DBG} NAMES + wxbase30${_UCD}${_DBG} wxbase29${_UCD}${_DBG} wxbase28${_UCD}${_DBG} wxbase27${_UCD}${_DBG} @@ -315,6 +316,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") foreach(LIB net odbc xml) find_library(WX_${LIB}${_DBG} NAMES + wxbase30${_UCD}${_DBG}_${LIB} wxbase29${_UCD}${_DBG}_${LIB} wxbase28${_UCD}${_DBG}_${LIB} wxbase27${_UCD}${_DBG}_${LIB} @@ -329,6 +331,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") # Find wxWidgets monolithic library. find_library(WX_mono${_DBG} NAMES + wxmsw${_UNV}30${_UCD}${_DBG} wxmsw${_UNV}29${_UCD}${_DBG} wxmsw${_UNV}28${_UCD}${_DBG} wxmsw${_UNV}27${_UCD}${_DBG} @@ -344,6 +347,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") stc ribbon propgrid webview) find_library(WX_${LIB}${_DBG} NAMES + wxmsw${_UNV}30${_UCD}${_DBG}_${LIB} wxmsw${_UNV}29${_UCD}${_DBG}_${LIB} wxmsw${_UNV}28${_UCD}${_DBG}_${LIB} wxmsw${_UNV}27${_UCD}${_DBG}_${LIB} @@ -457,6 +461,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") D:/ ENV ProgramFiles PATH_SUFFIXES + wxWidgets-3.0.0 + wxWidgets-2.9.5 wxWidgets-2.9.4 wxWidgets-2.9.3 wxWidgets-2.9.2 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/QNX.cmake b/Modules/Platform/QNX.cmake index 068799f..9afde05 100644 --- a/Modules/Platform/QNX.cmake +++ b/Modules/Platform/QNX.cmake @@ -16,6 +16,9 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") +# http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples +set(CMAKE_C_COMPILE_OPTIONS_TARGET "-V") +set(CMAKE_CXX_COMPILE_OPTIONS_TARGET "-V") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index 7a424c4..eca3280 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -43,6 +43,12 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) # Project install destination. "${CMAKE_INSTALL_PREFIX}" ) + if(CMAKE_STAGING_PREFIX) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH + # User-supplied staging prefix. + "${CMAKE_STAGING_PREFIX}" + ) + endif() endif() # List common include file locations not under the common prefixes. diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake index c231495..3240c23 100644 --- a/Modules/Platform/WindowsPaths.cmake +++ b/Modules/Platform/WindowsPaths.cmake @@ -79,6 +79,12 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) # Project install destination. "${CMAKE_INSTALL_PREFIX}" ) + if (CMAKE_STAGING_PREFIX) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH + # User-supplied staging prefix. + "${CMAKE_STAGING_PREFIX}" + ) + endif() endif() if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") @@ -94,6 +100,11 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) list(APPEND CMAKE_SYSTEM_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/bin" ) + if (CMAKE_STAGING_PREFIX) + list(APPEND CMAKE_SYSTEM_LIBRARY_PATH + "${CMAKE_STAGING_PREFIX}/bin" + ) + endif() endif() list(APPEND CMAKE_SYSTEM_LIBRARY_PATH "${_CMAKE_INSTALL_DIR}/bin" 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/UseSWIG.cmake b/Modules/UseSWIG.cmake index 00f3e21..67cab4a 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -59,15 +59,22 @@ 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") + elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "CSHARP") + # This makes sure that the name used in the generated DllImport + # matches the library name created by CMake + set(SWIG_MODULE_${name}_EXTRA_FLAGS "-dllimport;${name}") endif() endmacro() @@ -94,7 +101,6 @@ endmacro() # macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) set(swig_full_infile ${infile}) - get_filename_component(swig_source_file_path "${infile}" PATH) get_filename_component(swig_source_file_name_we "${infile}" NAME_WE) get_source_file_property(swig_source_file_generated ${infile} GENERATED) get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS) @@ -102,35 +108,8 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) if("${swig_source_file_flags}" STREQUAL "NOTFOUND") set(swig_source_file_flags "") endif() - set(swig_source_file_fullname "${infile}") - if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_SOURCE_DIR}") - string(REGEX REPLACE - "^${CMAKE_CURRENT_SOURCE_DIR}" "" - swig_source_file_relative_path - "${swig_source_file_path}") - else() - if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_BINARY_DIR}") - string(REGEX REPLACE - "^${CMAKE_CURRENT_BINARY_DIR}" "" - swig_source_file_relative_path - "${swig_source_file_path}") - set(swig_source_file_generated 1) - else() - set(swig_source_file_relative_path "${swig_source_file_path}") - if(swig_source_file_generated) - set(swig_source_file_fullname "${CMAKE_CURRENT_BINARY_DIR}/${infile}") - else() - set(swig_source_file_fullname "${CMAKE_CURRENT_SOURCE_DIR}/${infile}") - endif() - endif() - endif() + get_filename_component(swig_source_file_fullname "${infile}" ABSOLUTE) - set(swig_generated_file_fullname - "${CMAKE_CURRENT_BINARY_DIR}") - if(swig_source_file_relative_path) - set(swig_generated_file_fullname - "${swig_generated_file_fullname}/${swig_source_file_relative_path}") - endif() # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir if(CMAKE_SWIG_OUTDIR) set(swig_outdir ${CMAKE_SWIG_OUTDIR}) @@ -142,7 +121,7 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) "${swig_outdir}" "${infile}") set(swig_generated_file_fullname - "${swig_generated_file_fullname}/${swig_source_file_name_we}") + "${swig_outdir}/${swig_source_file_name_we}") # add the language into the name of the file (i.e. TCL_wrap) # this allows for the same .i file to be wrapped into different languages set(swig_generated_file_fullname @@ -159,6 +138,7 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) #message("Full path to source file: ${swig_source_file_fullname}") #message("Full path to the output file: ${swig_generated_file_fullname}") get_directory_property(cmake_include_directories INCLUDE_DIRECTORIES) + list(REMOVE_DUPLICATES cmake_include_directories) set(swig_include_dirs) foreach(it ${cmake_include_directories}) set(swig_include_dirs ${swig_include_dirs} "-I${it}") @@ -223,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"); @@ -233,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" @@ -248,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..17fb52d 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 diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4340ad7..d507535 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 20131114) +set(CMake_VERSION_TWEAK 20131205) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1d7681b..91701c2 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -198,6 +198,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); @@ -296,6 +308,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 +414,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 +494,12 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() } directoryDefinitions.EndElement("Directory"); + + if(hasShortcuts) + { + CreateStartMenuFolder(directoryDefinitions); + } + directoryDefinitions.EndElement("Directory"); directoryDefinitions.EndElement("Fragment"); @@ -475,16 +531,154 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() 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 +691,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 +725,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 +741,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 +759,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 +833,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,7 +868,8 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( directoryDefinitions, fileDefinitions, featureDefinitions, - packageExecutables); + packageExecutables, + shortcutMap); directoryDefinitions.EndElement("Directory"); } @@ -922,3 +1129,18 @@ 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"); +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 481a07d..84f68b6 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -56,7 +56,7 @@ protected: virtual bool SupportsComponentInstallation() const { - return false; + return true; } private: @@ -79,9 +79,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 +127,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,10 +158,11 @@ private: void AddCustomFlags( const std::string& variableName, std::ostream& stream); + void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions); + 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; 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/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 5475c2f..cd2fcc7 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -580,7 +580,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( * (this works at CPack time too) */ if (this->SupportsComponentInstallation() & - !(this->IsSet("CPACK_MONOLITHIC_INSTALL"))) + !(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) { // Determine the installation types for this project (if provided). std::string installTypesVar = "CPACK_" @@ -1532,13 +1532,13 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) component->DisplayName = component->Name; } component->IsHidden - = this->IsSet((macroPrefix + "_HIDDEN").c_str()); + = this->IsOn((macroPrefix + "_HIDDEN").c_str()); component->IsRequired - = this->IsSet((macroPrefix + "_REQUIRED").c_str()); + = this->IsOn((macroPrefix + "_REQUIRED").c_str()); component->IsDisabledByDefault - = this->IsSet((macroPrefix + "_DISABLED").c_str()); + = this->IsOn((macroPrefix + "_DISABLED").c_str()); component->IsDownloaded - = this->IsSet((macroPrefix + "_DOWNLOADED").c_str()) + = this->IsOn((macroPrefix + "_DOWNLOADED").c_str()) || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); const char* archiveFile = this->GetOption((macroPrefix + @@ -1635,9 +1635,9 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) group->Description = description; } group->IsBold - = this->IsSet((macroPrefix + "_BOLD_TITLE").c_str()); + = this->IsOn((macroPrefix + "_BOLD_TITLE").c_str()); group->IsExpandedByDefault - = this->IsSet((macroPrefix + "_EXPANDED").c_str()); + = this->IsOn((macroPrefix + "_EXPANDED").c_str()); const char* parentGroupName = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str()); if (parentGroupName && *parentGroupName) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 39eeb70..e480fff 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -763,7 +763,7 @@ void cmCTestBuildHandler::GenerateXMLLaunchedFragment(std::ostream& os, bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname) { // error-{hash}.xml - return (strncmp(fname, "error-", 6) == 0 && + return (cmHasLiteralPrefix(fname, "error-") && strcmp(fname+strlen(fname)-4, ".xml") == 0); } @@ -771,7 +771,7 @@ bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname) bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname) { // warning-{hash}.xml - return (strncmp(fname, "warning-", 8) == 0 && + return (cmHasLiteralPrefix(fname, "warning-") && strcmp(fname+strlen(fname)-4, ".xml") == 0); } diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 5b34491..725f613 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -536,11 +536,11 @@ private: void DoHeaderLine() { // Look for header fields that we need. - if(strncmp(this->Line.c_str(), "commit ", 7) == 0) + if(cmHasLiteralPrefix(this->Line.c_str(), "commit ")) { this->Rev.Rev = this->Line.c_str()+7; } - else if(strncmp(this->Line.c_str(), "author ", 7) == 0) + else if(cmHasLiteralPrefix(this->Line.c_str(), "author ")) { Person author; this->ParsePerson(this->Line.c_str()+7, author); @@ -548,7 +548,7 @@ private: this->Rev.EMail = author.EMail; this->Rev.Date = this->FormatDateTime(author); } - else if(strncmp(this->Line.c_str(), "committer ", 10) == 0) + else if(cmHasLiteralPrefix(this->Line.c_str(), "committer ")) { Person committer; this->ParsePerson(this->Line.c_str()+10, committer); 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/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index f1f4649..4308a4d 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -102,6 +102,13 @@ if(APPLE) MACOSX_PACKAGE_LOCATION Resources) endif() +if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) + install(FILES ${CMake_SOURCE_DIR}/Licenses/LGPLv2.1.txt + DESTINATION ${CMAKE_DATA_DIR}/Licenses) + set_property(SOURCE CMakeSetupDialog.cxx + PROPERTY COMPILE_DEFINITIONS CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) +endif() + set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index a7665c8..1903c02 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -34,6 +34,7 @@ #include "QCMakeCacheView.h" #include "AddCacheEntry.h" #include "FirstConfigure.h" +#include "cmSystemTools.h" #include "cmVersion.h" QCMakeThread::QCMakeThread(QObject* p) @@ -807,12 +808,26 @@ void CMakeSetupDialog::doDeleteCache() void CMakeSetupDialog::doAbout() { - QString msg = tr("CMake %1\n" - "Using Qt %2\n" - "www.cmake.org"); - + QString msg = tr( + "CMake %1 (cmake.org).\n" + "CMake suite maintained by Kitware, Inc. (kitware.com).\n" + "Distributed under terms of the BSD 3-Clause License.\n" + "\n" + "CMake GUI maintained by csimsoft,\n" + "built using Qt %2 (qt-project.org).\n" +#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL + "\n" + "The Qt Toolkit is Copyright (C) Digia Plc and/or its subsidiary(-ies).\n" + "Qt is licensed under terms of the GNU LGPLv2.1, available at:\n" + " \"%3\"" +#endif + ); msg = msg.arg(cmVersion::GetCMakeVersion()); msg = msg.arg(qVersion()); +#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL + std::string lgpl = cmSystemTools::GetCMakeRoot()+"/Licenses/LGPLv2.1.txt"; + msg = msg.arg(lgpl.c_str()); +#endif QDialog dialog; dialog.setWindowTitle(tr("About")); @@ -946,6 +961,7 @@ void CMakeSetupDialog::saveBuildPaths(const QStringList& paths) void CMakeSetupDialog::setCacheModified() { this->CacheModified = true; + this->ConfigureNeeded = true; this->enterState(ReadyConfigure); } diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 2a683a4..ef62523 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -11,6 +11,9 @@ ============================================================================*/ #include "cmAddCustomTargetCommand.h" +#include "cmGeneratorExpression.h" +#include "cmGlobalGenerator.h" + // cmAddCustomTargetCommand bool cmAddCustomTargetCommand ::InitialPass(std::vector<std::string> const& args, @@ -22,11 +25,13 @@ bool cmAddCustomTargetCommand return false; } + std::string targetName = args[0]; + // Check the target name. - if(args[0].find_first_of("/\\") != args[0].npos) + if(targetName.find_first_of("/\\") != targetName.npos) { cmOStringStream e; - e << "called with invalid target name \"" << args[0] + e << "called with invalid target name \"" << targetName << "\". Target names may not contain a slash. " << "Use ADD_CUSTOM_COMMAND to generate files."; this->SetError(e.str().c_str()); @@ -138,16 +143,59 @@ bool cmAddCustomTargetCommand } } - std::string::size_type pos = args[0].find_first_of("#<>"); - if(pos != args[0].npos) + std::string::size_type pos = targetName.find_first_of("#<>"); + if(pos != targetName.npos) { cmOStringStream msg; - msg << "called with target name containing a \"" << args[0][pos] + msg << "called with target name containing a \"" << targetName[pos] << "\". This character is not allowed."; this->SetError(msg.str().c_str()); return false; } + // Some requirements on custom target names already exist + // and have been checked at this point. + // The following restrictions overlap but depend on policy CMP0037. + bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) && + !cmGlobalGenerator::IsReservedTarget(targetName); + if (nameOk) + { + nameOk = targetName.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << targetName << + "\" is reserved or not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // Store the last command line finished. if(!currentLine.empty()) { @@ -158,7 +206,7 @@ bool cmAddCustomTargetCommand // Enforce name uniqueness. { std::string msg; - if(!this->Makefile->EnforceUniqueName(args[0], msg, true)) + if(!this->Makefile->EnforceUniqueName(targetName, msg, true)) { this->SetError(msg.c_str()); return false; @@ -176,7 +224,7 @@ bool cmAddCustomTargetCommand // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = - this->Makefile->AddUtilityCommand(args[0].c_str(), excludeFromAll, + this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll, working_directory.c_str(), depends, commandLines, escapeOldStyle, comment); diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index a93e834..a352be0 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -69,7 +69,9 @@ bool cmAddExecutableCommand } } - bool nameOk = cmGeneratorExpression::IsValidTargetName(exename); + bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) && + !cmGlobalGenerator::IsReservedTarget(exename); + if (nameOk && !importTarget && !isAlias) { nameOk = exename.find(":") == std::string::npos; @@ -95,7 +97,8 @@ bool cmAddExecutableCommand cmOStringStream e; e << (this->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; - e << "The target name \"" << exename << "\" is not valid for certain " + e << "The target name \"" << exename << + "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; this->Makefile->IssueMessage(messageType, e.str().c_str()); diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index e9c5d6b..0f98f35 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -109,7 +109,9 @@ bool cmAddLibraryCommand } } - bool nameOk = cmGeneratorExpression::IsValidTargetName(libName); + bool nameOk = cmGeneratorExpression::IsValidTargetName(libName) && + !cmGlobalGenerator::IsReservedTarget(libName); + if (nameOk && !importTarget && !isAlias) { nameOk = libName.find(":") == std::string::npos; @@ -135,7 +137,8 @@ bool cmAddLibraryCommand cmOStringStream e; e << (this->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; - e << "The target name \"" << libName << "\" is not valid for certain " + e << "The target name \"" << libName << + "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; this->Makefile->IssueMessage(messageType, e.str().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index bfabc9f..125a3bf 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1131,11 +1131,11 @@ int cmCTest::GetTestModelFromString(const char* str) return cmCTest::EXPERIMENTAL; } std::string rstr = cmSystemTools::LowerCase(str); - if ( strncmp(rstr.c_str(), "cont", 4) == 0 ) + if ( cmHasLiteralPrefix(rstr.c_str(), "cont") ) { return cmCTest::CONTINUOUS; } - if ( strncmp(rstr.c_str(), "nigh", 4) == 0 ) + if ( cmHasLiteralPrefix(rstr.c_str(), "nigh") ) { return cmCTest::NIGHTLY; } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index d4644c3..0ef3d2e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1901,6 +1901,12 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, } if(use_build_rpath || use_link_rpath) { + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + const char *stagePath + = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + const char *installPrefix + = this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); for(std::vector<std::string>::const_iterator ri = rdirs.begin(); ri != rdirs.end(); ++ri) @@ -1909,9 +1915,22 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // support or if using the link path as an rpath. if(use_build_rpath) { - if(emitted.insert(*ri).second) + std::string d = *ri; + if (!rootPath.empty() && d.find(rootPath) == 0) { - runtimeDirs.push_back(*ri); + d = d.substr(rootPath.size()); + } + else if (stagePath && *stagePath && d.find(stagePath) == 0) + { + std::string suffix = d.substr(strlen(stagePath)); + d = installPrefix; + d += "/"; + d += suffix; + cmSystemTools::ConvertToUnixSlashes(d); + } + if(emitted.insert(d).second) + { + runtimeDirs.push_back(d); } } else if(use_link_rpath) @@ -1924,9 +1943,22 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - if(emitted.insert(*ri).second) + std::string d = *ri; + if (!rootPath.empty() && d.find(rootPath) == 0) + { + d = d.substr(rootPath.size()); + } + else if (stagePath && *stagePath && d.find(stagePath) == 0) + { + std::string suffix = d.substr(strlen(stagePath)); + d = installPrefix; + d += "/"; + d += suffix; + cmSystemTools::ConvertToUnixSlashes(d); + } + if(emitted.insert(d).second) { - runtimeDirs.push_back(*ri); + runtimeDirs.push_back(d); } } } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 7fd4754..cb9e37e 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -237,7 +237,15 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) it != configs.end(); ++it) { std::vector<std::string> tlibs; - depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); + 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); + } // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 479a699..bbfc427 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -405,6 +405,41 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); cmakeFlags.push_back(flag); } + if (const char *cxxDef + = this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET")) + { + std::string flag="-DCMAKE_CXX_COMPILER_TARGET="; + flag += cxxDef; + cmakeFlags.push_back(flag); + } + if (const char *cDef + = this->Makefile->GetDefinition("CMAKE_C_COMPILER_TARGET")) + { + std::string flag="-DCMAKE_C_COMPILER_TARGET="; + flag += cDef; + cmakeFlags.push_back(flag); + } + if (const char *tcxxDef = this->Makefile->GetDefinition( + "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN")) + { + std::string flag="-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN="; + flag += tcxxDef; + cmakeFlags.push_back(flag); + } + if (const char *tcDef = this->Makefile->GetDefinition( + "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN")) + { + std::string flag="-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN="; + flag += tcDef; + cmakeFlags.push_back(flag); + } + if (const char *rootDef + = this->Makefile->GetDefinition("CMAKE_SYSROOT")) + { + std::string flag="-DCMAKE_SYSROOT="; + flag += rootDef; + cmakeFlags.push_back(flag); + } if(this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE")!=0) { fprintf(fout, "set(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n"); diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 8029577..8576bf2 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -95,8 +95,12 @@ cmDocumentation::~cmDocumentation() //---------------------------------------------------------------------------- bool cmDocumentation::PrintVersion(std::ostream& os) { - os << this->GetNameString() << " version " - << cmVersion::GetCMakeVersion() << "\n"; + os << + this->GetNameString() << + " version " << cmVersion::GetCMakeVersion() << "\n" + "\n" + "CMake suite maintained by Kitware, Inc. (kitware.com).\n" + ; return true; } @@ -195,24 +199,27 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) void cmDocumentation::WarnFormFromFilename( - cmDocumentation::RequestedHelpItem& request) + cmDocumentation::RequestedHelpItem& request, bool& result) { std::string ext = cmSystemTools::GetFilenameLastExtension(request.Filename); ext = cmSystemTools::UpperCase(ext); if ((ext == ".HTM") || (ext == ".HTML")) { request.HelpType = cmDocumentation::None; + result = true; cmSystemTools::Message("Warning: HTML help format no longer supported"); } else if (ext == ".DOCBOOK") { request.HelpType = cmDocumentation::None; + result = true; cmSystemTools::Message("Warning: Docbook help format no longer supported"); } // ".1" to ".9" should be manpages else if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9')) { request.HelpType = cmDocumentation::None; + result = true; cmSystemTools::Message("Warning: Man help format no longer supported"); } } @@ -300,28 +307,28 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-properties.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-policies") == 0) { help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-policies.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-variables") == 0) { help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-variables.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-modules") == 0) { help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-modules.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-custom-modules") == 0) { @@ -335,7 +342,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-commands.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-compatcommands") == 0) { @@ -368,42 +375,42 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); help.Argument = cmSystemTools::LowerCase(help.Argument); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-module") == 0) { help.HelpType = cmDocumentation::OneModule; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-property") == 0) { help.HelpType = cmDocumentation::OneProperty; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-policy") == 0) { help.HelpType = cmDocumentation::OnePolicy; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-variable") == 0) { help.HelpType = cmDocumentation::OneVariable; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-manual") == 0) { help.HelpType = cmDocumentation::OneManual; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-command-list") == 0) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 209cc27..05c0442 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -137,7 +137,7 @@ private: std::vector<RequestedHelpItem> RequestedHelpItems; cmDocumentationFormatter Formatter; - static void WarnFormFromFilename(RequestedHelpItem& request); + static void WarnFormFromFilename(RequestedHelpItem& request, bool& result); }; #endif diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 50835e2..0d0d05b 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 = diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 86ddc3f..3f6bc2e 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -135,6 +135,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() diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index fdc075e..f8b4e28 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; } - if (strncmp(li->c_str(), "${_IMPORT_PREFIX}", 17) == 0) + 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; @@ -388,14 +428,11 @@ void getCompatibleInterfaceProperties(cmTarget *target, if (!info) { - if (target->GetType() != cmTarget::INTERFACE_LIBRARY) - { - cmMakefile* mf = target->GetMakefile(); - cmOStringStream e; - e << "Exporting the target \"" << target->GetName() << "\" is not " - "allowed since its linker language cannot be determined"; - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); - } + cmMakefile* mf = target->GetMakefile(); + cmOStringStream e; + e << "Exporting the target \"" << target->GetName() << "\" is not " + "allowed since its linker language cannot be determined"; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -447,15 +484,18 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX", ifaceProperties); - getCompatibleInterfaceProperties(target, ifaceProperties, 0); + if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + { + getCompatibleInterfaceProperties(target, ifaceProperties, 0); - std::vector<std::string> configNames; - target->GetMakefile()->GetConfigurations(configNames); + std::vector<std::string> configNames; + target->GetMakefile()->GetConfigurations(configNames); - for (std::vector<std::string>::const_iterator ci = configNames.begin(); - ci != configNames.end(); ++ci) - { - getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + for (std::vector<std::string>::const_iterator ci = configNames.begin(); + ci != configNames.end(); ++ci) + { + getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + } } for (std::set<std::string>::const_iterator it = ifaceProperties.begin(); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 133944e..79e78df 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -81,10 +81,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) os << "# Compute the installation prefix relative to this file.\n" << "get_filename_component(_IMPORT_PREFIX" << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; - if(strncmp(absDestS.c_str(), "/lib/", 5) == 0 || - strncmp(absDestS.c_str(), "/lib64/", 7) == 0 || - strncmp(absDestS.c_str(), "/usr/lib/", 9) == 0 || - strncmp(absDestS.c_str(), "/usr/lib64/", 11) == 0) + if(cmHasLiteralPrefix(absDestS.c_str(), "/lib/") || + cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") || + cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") || + cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/")) { // Handle "/usr move" symlinks created by some Linux distros. os << @@ -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 diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index 9c965cc..0d42c35 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -13,6 +13,12 @@ #include "cmExternalMakefileProjectGenerator.h" +void cmExternalMakefileProjectGenerator +::EnableLanguage(std::vector<std::string> const&, + cmMakefile *, bool) +{ +} + std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( const char* globalGenerator, const char* extraGenerator) diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index 182c1a8..bce441d 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -41,6 +41,8 @@ public: /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const = 0; + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool optional); ///! set the global generator which will generate the makefiles virtual void SetGlobalGenerator(cmGlobalGenerator* generator) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 676d4ed..755b445 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -51,6 +51,29 @@ void cmExtraEclipseCDT4Generator } //---------------------------------------------------------------------------- +void cmExtraEclipseCDT4Generator +::EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool) +{ + for (std::vector<std::string>::const_iterator lit = languages.begin(); + lit != languages.end(); ++lit) + { + if (*lit == "CXX") + { + this->Natures.insert("org.eclipse.cdt.core.ccnature"); + } + else if (*lit == "C") + { + this->Natures.insert("org.eclipse.cdt.core.cnature"); + } + else if (*lit == "Java") + { + this->Natures.insert("org.eclipse.jdt.core.javanature"); + } + } +} + +//---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::Generate() { const cmMakefile* mf @@ -433,13 +456,28 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // set natures for c/c++ projects fout << "\t<natures>\n" - // TODO: ccnature only if it is c++ ??? - "\t\t<nature>org.eclipse.cdt.core.ccnature</nature>\n" "\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n" - "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n" - "\t\t<nature>org.eclipse.cdt.core.cnature</nature>\n" - "\t</natures>\n" - ; + "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n"; + + for (std::set<std::string>::const_iterator nit=this->Natures.begin(); + nit != this->Natures.end(); ++nit) + { + fout << "\t\t<nature>" << *nit << "</nature>\n"; + } + + if (const char *extraNaturesProp = mf->GetCMakeInstance()-> + GetProperty("ECLIPSE_EXTRA_NATURES", cmProperty::GLOBAL)) + { + std::vector<std::string> extraNatures; + cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures); + for (std::vector<std::string>::const_iterator nit = extraNatures.begin(); + nit != extraNatures.end(); ++nit) + { + fout << "\t\t<nature>" << *nit << "</nature>\n"; + } + } + + fout << "\t</natures>\n"; fout << "\t<linkedResources>\n"; // create linked resources diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index b31cce7..9c89f85 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -41,6 +41,8 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const; + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool optional); virtual void Generate(); @@ -105,6 +107,7 @@ private: void CreateLinksForTargets(cmGeneratedFileStream& fout); std::vector<std::string> SrcLinkedResources; + std::set<std::string> Natures; std::string HomeDirectory; std::string HomeOutputDirectory; bool IsOutOfSourceBuild; diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx new file mode 100644 index 0000000..f020ddb --- /dev/null +++ b/Source/cmExtraKateGenerator.cxx @@ -0,0 +1,372 @@ +/*============================================================================ + 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->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"); + + this->AppendTarget(fout, "all", make, makeArgs, + mf->GetHomeOutputDirectory()); + this->AppendTarget(fout, "clean", make, makeArgs, + mf->GetHomeOutputDirectory()); + + // 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); + } + } + 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); + 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); + std::string fastTarget = ti->first; + fastTarget += "/fast"; + this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir); + + } + 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); + } + } + + 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 +{ + static char JsonSep = ' '; + + fout << + "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", " + "\"build_cmd\":\"" << make << " -C " << path << " " << 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; +} + + +// Create the command line for building the given target using the selected +// make +std::string cmExtraKateGenerator::BuildMakeCommand(const std::string& make, + const char* makefile, const char* target) const +{ + std::string command = make; + if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) + { + std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); + command += " /NOLOGO /f ""; + command += makefileName; + command += "" "; + command += " VERBOSE=1 "; + command += target; + } + else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) + { + // no escaping of spaces in this case, see + // http://public.kitware.com/Bug/view.php?id=10014 + std::string makefileName = makefile; + command += " -f ""; + command += makefileName; + command += "" "; + command += " VERBOSE=1 "; + command += target; + } + else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) + { + command += " -v "; + command += target; + } + else + { + std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); + command += " -f ""; + command += makefileName; + command += "" "; + command += " VERBOSE=1 "; + command += target; + } + return command; +} diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h new file mode 100644 index 0000000..4979eff --- /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; + + 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 BuildMakeCommand(const std::string& make, + const char* makefile, const char* target) const; + + std::string ProjectName; +}; + +#endif diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 7beeda0..e8c8da3 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -138,22 +138,36 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) { return; } + const char* sysroot = + this->Makefile->GetDefinition("CMAKE_SYSROOT"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - if((rootPath == 0) || (strlen(rootPath) == 0)) + const bool noSysroot = !sysroot || !*sysroot; + const bool noRootPath = !rootPath || !*rootPath; + if(noSysroot && noRootPath) { return; } // Construct the list of path roots with no trailing slashes. std::vector<std::string> roots; - cmSystemTools::ExpandListArgument(rootPath, roots); + if (rootPath) + { + cmSystemTools::ExpandListArgument(rootPath, roots); + } + if (sysroot) + { + roots.push_back(sysroot); + } for(std::vector<std::string>::iterator ri = roots.begin(); ri != roots.end(); ++ri) { cmSystemTools::ConvertToUnixSlashes(*ri); } + const char* stagePrefix = + this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + // Copy the original set of unrooted paths. std::vector<std::string> unrootedPaths = paths; paths.clear(); @@ -168,7 +182,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) // already inside. Skip the unrooted path if it is relative to // a user home directory or is empty. std::string rootedDir; - if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str())) + if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str()) + || (stagePrefix + && cmSystemTools::IsSubDirectory(ui->c_str(), stagePrefix))) { rootedDir = *ui; } 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 92dc054..92f74f3 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -173,8 +173,8 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) return (strcmp(prop, "LINK_LIBRARIES") == 0 || strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 || strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 - || strncmp(prop, "LINK_INTERFACE_LIBRARIES_", 25) == 0 - || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 34) == 0) + || cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") + || cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_")) || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; } @@ -200,7 +200,7 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const const char *prop = this->Property.c_str(); return (strcmp(prop, "COMPILE_DEFINITIONS") == 0 || strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 - || strncmp(prop, "COMPILE_DEFINITIONS_", 20) == 0); + || cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_")); } //---------------------------------------------------------------------------- @@ -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 2ae5a22..0f8c4e3 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -199,6 +199,48 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode } strEqualNode; //---------------------------------------------------------------------------- +static const struct LowerCaseNode : public cmGeneratorExpressionNode +{ + LowerCaseNode() {} + + 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() {} + + 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() {} + + 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() {} @@ -902,8 +944,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME) // Note that the above macro terminates with an else - /* else */ if (strncmp(propertyName.c_str(), - "COMPILE_DEFINITIONS_", 20) == 0) + /* else */ if (cmHasLiteralPrefix(propertyName.c_str(), + "COMPILE_DEFINITIONS_")) { interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; } @@ -954,7 +996,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!prop) { - if (target->IsImported()) + if (target->IsImported() + || target->GetType() == cmTarget::INTERFACE_LIBRARY) { return linkedTargetsContent; } @@ -1441,6 +1484,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") diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b964f71..5a535c7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -611,8 +611,8 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() const } //---------------------------------------------------------------------------- -std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( - const char *config) +std::vector<std::string> +cmGeneratorTarget::GetIncludeDirectories(const char *config) const { return this->Target->GetIncludeDirectories(config); } @@ -692,3 +692,14 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const gg->AddToManifest(config? config:"", f); } } + +bool cmStrictTargetComparison::operator()(cmTarget *t1, cmTarget *t2) const +{ + int nameResult = strcmp(t1->GetName(), t2->GetName()); + if (nameResult == 0) + { + return strcmp(t1->GetMakefile()->GetStartOutputDirectory(), + t2->GetMakefile()->GetStartOutputDirectory()) < 0; + } + return nameResult < 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 177bc25..d2b65b2 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -70,7 +70,7 @@ public: const char* GetCreateRuleVariable() const; /** Get the include directories for this target. */ - std::vector<std::string> GetIncludeDirectories(const char *config); + std::vector<std::string> GetIncludeDirectories(const char *config) const; bool IsSystemIncludeDirectory(const char *dir, const char *config) const; @@ -100,6 +100,12 @@ private: void operator=(cmGeneratorTarget const&); }; -typedef std::map<cmTarget*, cmGeneratorTarget*> cmGeneratorTargetsType; +struct cmStrictTargetComparison { + bool operator()(cmTarget *t1, cmTarget *t2) const; +}; + +typedef std::map<cmTarget*, + cmGeneratorTarget*, + cmStrictTargetComparison> cmGeneratorTargetsType; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b11b274..e6f3d94 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -695,6 +695,11 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { mf->ReadListFile(0,projectCompatibility.c_str()); } + // Inform any extra generator of the new language. + if (this->ExtraGenerator) + { + this->ExtraGenerator->EnableLanguage(languages, mf, false); + } if(fatalError) { @@ -1304,6 +1309,11 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() { cmTarget* t = &ti->second; + if (t->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + t->AppendBuildInterfaceIncludes(); for (std::vector<cmValueWithOrigin>::const_iterator it @@ -1456,6 +1466,10 @@ void cmGlobalGenerator::CheckLocalGenerators() for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } const cmTarget::LinkLibraryVectorType& libs = l->second.GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin(); @@ -1981,7 +1995,7 @@ void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt) } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsAlias(const char *name) +bool cmGlobalGenerator::IsAlias(const char *name) const { return this->AliasTargets.find(name) != this->AliasTargets.end(); } @@ -1989,15 +2003,16 @@ bool cmGlobalGenerator::IsAlias(const char *name) //---------------------------------------------------------------------------- cmTarget* cmGlobalGenerator::FindTarget(const char* project, const char* name, - bool excludeAliases) + bool excludeAliases) const { // if project specific if(project) { - std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; - for(unsigned int i = 0; i < gens->size(); ++i) + std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + gens = this->ProjectMap.find(project); + for(unsigned int i = 0; i < gens->second.size(); ++i) { - cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name, + cmTarget* ret = (gens->second)[i]->GetMakefile()->FindTarget(name, excludeAliases); if(ret) { @@ -2010,14 +2025,14 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name, { if (!excludeAliases) { - std::map<cmStdString, cmTarget*>::iterator ai + std::map<cmStdString, cmTarget*>::const_iterator ai = this->AliasTargets.find(name); if (ai != this->AliasTargets.end()) { return ai->second; } } - std::map<cmStdString,cmTarget *>::iterator i = + std::map<cmStdString,cmTarget *>::const_iterator i = this->TotalTargets.find ( name ); if ( i != this->TotalTargets.end() ) { @@ -2033,7 +2048,8 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) +bool +cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const { if(cmSystemTools::IsPathToFramework(libname.c_str())) { @@ -2407,7 +2423,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( // Store the custom command in the target. cmCustomCommand cc(0, no_outputs, no_depends, *commandLines, 0, workingDirectory); - target.GetPostBuildCommands().push_back(cc); + target.AddPostBuildCommand(cc); target.SetProperty("EchoString", message); std::vector<std::string>::iterator dit; for ( dit = depends.begin(); dit != depends.end(); ++ dit ) @@ -2479,6 +2495,37 @@ void cmGlobalGenerator::AddTarget(cmTarget* t) } } +bool cmGlobalGenerator::IsReservedTarget(std::string const& name) +{ + // The following is a list of targets reserved + // by one or more of the cmake generators. + + // Adding additional targets to this list will require a policy! + const char* reservedTargets[] = + { + "all", "ALL_BUILD", + "help", + "install", "INSTALL", + "preinstall", + "clean", + "edit_cache", + "rebuild_cache", + "test", "RUN_TESTS", + "package", "PACKAGE", + "package_source", + "ZERO_CHECK", + 0 + }; + + for(const char** reservedTarget = reservedTargets; + *reservedTarget; ++reservedTarget) + { + if(name == *reservedTarget) return true; + } + + return false; +} + void cmGlobalGenerator::SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator *extraGenerator) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 6e93609..eb720a8 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -207,14 +207,14 @@ public: ///! Find a target by name by searching the local generators. cmTarget* FindTarget(const char* project, const char* name, - bool excludeAliases = false); + bool excludeAliases = false) const; void AddAlias(const char *name, cmTarget *tgt); - bool IsAlias(const char *name); + bool IsAlias(const char *name) const; /** Determine if a name resolves to a framework on disk or a built target that is a framework. */ - bool NameResolvesToFramework(const std::string& libname); + bool NameResolvesToFramework(const std::string& libname) const; /** If check to see if the target is linked to by any other target in the project */ @@ -244,6 +244,8 @@ public: void AddTarget(cmTarget* t); + static bool IsReservedTarget(std::string const& name); + virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } virtual const char* GetInstallTargetName() const { return "INSTALL"; } virtual const char* GetInstallLocalTargetName() const { return 0; } diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 273d4bb..ab7db51 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -75,7 +75,7 @@ void cmGlobalKdevelopGenerator::Generate() { if (ti->second.GetType()==cmTarget::EXECUTABLE) { - executable = ti->second.GetProperty("LOCATION"); + executable = ti->second.GetLocation(0); break; } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index e1af2f9..6333873 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -471,23 +471,29 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector<std::string> depends; - for(cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); - l != lg->GetMakefile()->GetTargets().end(); ++l) + cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator l = targets.begin(); + l != targets.end(); ++l) { - if((l->second.GetType() == cmTarget::EXECUTABLE) || - (l->second.GetType() == cmTarget::STATIC_LIBRARY) || - (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->GetType() == cmTarget::EXECUTABLE) || + (l->second->GetType() == cmTarget::STATIC_LIBRARY) || + (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()) + { + continue; + } // Add this to the list of depends rules in this directory. - if((!check_all || !l->second.GetPropertyAsBool("EXCLUDE_FROM_ALL")) && + if((!check_all || !l->second->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - l->second.NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))) + l->second->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))) { - std::string tname = lg->GetRelativeTargetDirectory(l->second); + std::string tname = lg->GetRelativeTargetDirectory(*l->second->Target); tname += "/"; tname += pass; depends.push_back(tname); @@ -632,49 +638,55 @@ cmGlobalUnixMakefileGenerator3 lg = static_cast<cmLocalUnixMakefileGenerator3 *> (this->LocalGenerators[i]); // for each target Generate the rule files for each target. - cmTargets& targets = lg->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { + if(t->second->Target->IsImported()) + { + continue; + } // Don't emit the same rule twice (e.g. two targets with the same // simple name) - if(t->second.GetName() && - strlen(t->second.GetName()) && - emitted.insert(t->second.GetName()).second && + if(t->second->GetName() && + strlen(t->second->GetName()) && + emitted.insert(t->second->GetName()).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. - ((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (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))) + ((t->second->GetType() == cmTarget::EXECUTABLE) || + (t->second->GetType() == cmTarget::STATIC_LIBRARY) || + (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. lg->WriteDivider(ruleFileStream); ruleFileStream << "# Target rules for targets named " - << t->second.GetName() << "\n\n"; + << t->second->GetName() << "\n\n"; // Write the rule. commands.clear(); std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); tmp += "Makefile2"; commands.push_back(lg->GetRecursiveMakeCall - (tmp.c_str(),t->second.GetName())); + (tmp.c_str(),t->second->GetName())); depends.clear(); depends.push_back("cmake_check_build_system"); lg->WriteMakeRule(ruleFileStream, "Build rule for target.", - t->second.GetName(), depends, commands, + t->second->GetName(), depends, commands, true); - if (t->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; } // Add a fast rule to build the target - std::string localName = lg->GetRelativeTargetDirectory(t->second); + std::string localName = + lg->GetRelativeTargetDirectory(*t->second->Target); std::string makefileName; makefileName = localName; makefileName += "/build.make"; @@ -682,7 +694,7 @@ cmGlobalUnixMakefileGenerator3 commands.clear(); std::string makeTargetName = localName; makeTargetName += "/build"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/fast"; commands.push_back(lg->GetRecursiveMakeCall (makefileName.c_str(), makeTargetName.c_str())); @@ -691,11 +703,12 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second.NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + if(t->second->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) { - makeTargetName = lg->GetRelativeTargetDirectory(t->second); + makeTargetName = lg->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/preinstall"; depends.clear(); commands.clear(); @@ -729,26 +742,31 @@ cmGlobalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - cmTargets& targets = lg->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - if (t->second.GetName() - && strlen(t->second.GetName()) - && ((t->second.GetType() == cmTarget::EXECUTABLE) - || (t->second.GetType() == cmTarget::STATIC_LIBRARY) - || (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; + } + if (t->second->GetName() + && strlen(t->second->GetName()) + && ((t->second->GetType() == cmTarget::EXECUTABLE) + || (t->second->GetType() == cmTarget::STATIC_LIBRARY) + || (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; // Add a rule to build the target by name. - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); makefileName = localName; makefileName += "/build.make"; - bool needRequiresStep = this->NeedRequiresStep(t->second); + bool needRequiresStep = this->NeedRequiresStep(*t->second->Target); lg->WriteDivider(ruleFileStream); ruleFileStream @@ -757,7 +775,7 @@ cmGlobalUnixMakefileGenerator3 commands.clear(); - if(t->second.GetType() != cmTarget::INTERFACE_LIBRARY) + if(t->second->GetType() != cmTarget::INTERFACE_LIBRARY) { makeTargetName = localName; makeTargetName += "/depend"; @@ -793,7 +811,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::SHELL); progCmd << " "; std::vector<unsigned long>& progFiles = - this->ProgressMap[&t->second].Marks; + this->ProgressMap[t->second->Target].Marks; for (std::vector<unsigned long>::iterator i = progFiles.begin(); i != progFiles.end(); ++i) { @@ -802,14 +820,14 @@ cmGlobalUnixMakefileGenerator3 commands.push_back(progCmd.str()); } progressDir = "Built target "; - progressDir += t->first; + progressDir += t->second->GetName(); lg->AppendEcho(commands,progressDir.c_str()); } else { depends.clear(); } - this->AppendGlobalTargetDepends(depends,t->second); + this->AppendGlobalTargetDepends(depends,*t->second->Target); if(depends.empty() && this->EmptyRuleHackDepends != "") { depends.push_back(this->EmptyRuleHackDepends); @@ -818,7 +836,7 @@ cmGlobalUnixMakefileGenerator3 localName.c_str(), depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], t->second)) + if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) { depends.clear(); depends.push_back(localName); @@ -843,7 +861,7 @@ cmGlobalUnixMakefileGenerator3 // std::set<cmTarget *> emitted; progCmd << " " - << this->CountProgressMarksInTarget(&t->second, emitted); + << this->CountProgressMarksInTarget(t->second->Target, emitted); commands.push_back(progCmd.str()); } std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); @@ -861,7 +879,7 @@ cmGlobalUnixMakefileGenerator3 } depends.clear(); depends.push_back("cmake_check_build_system"); - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); localName += "/rule"; lg->WriteMakeRule(ruleFileStream, "Build rule for subdir invocation for target.", @@ -872,12 +890,13 @@ cmGlobalUnixMakefileGenerator3 depends.clear(); depends.push_back(localName); lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second.GetName(), depends, commands, true); + t->second->GetName(), depends, commands, true); // Add rules to prepare the target for installation. - if(t->second.NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + if(t->second->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) { - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); localName += "/preinstall"; depends.clear(); commands.clear(); @@ -887,7 +906,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName.c_str(), depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], t->second)) + if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) { depends.clear(); depends.push_back(localName); @@ -898,7 +917,7 @@ cmGlobalUnixMakefileGenerator3 } // add the clean rule - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); makeTargetName = localName; makeTargetName += "/clean"; depends.clear(); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index d0fe5d9..6983ef9 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -28,7 +28,7 @@ static const char* cmVS10GenName(const char* name, std::string& genName) return 0; } const char* p = name + sizeof(vs10generatorName) - 6; - if(strncmp(p, " 2010", 5) == 0) + if(cmHasLiteralPrefix(p, " 2010")) { p += 5; } diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index f1d7312..1f0c47a 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -23,7 +23,7 @@ static const char* cmVS11GenName(const char* name, std::string& genName) return 0; } const char* p = name + sizeof(vs11generatorName) - 6; - if(strncmp(p, " 2012", 5) == 0) + if(cmHasLiteralPrefix(p, " 2012")) { p += 5; } diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index edd5567..3074794 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -23,7 +23,7 @@ static const char* cmVS12GenName(const char* name, std::string& genName) return 0; } const char* p = name + sizeof(vs12generatorName) - 6; - if(strncmp(p, " 2013", 5) == 0) + if(cmHasLiteralPrefix(p, " 2013")) { p += 5; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 35d7796..25fe10b 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -335,6 +335,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmTarget* target = *tt; + if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) { @@ -372,6 +376,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmTarget* target = *tt; + if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } bool written = false; // handle external vc project files diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 69b0a7a..e4ce13f 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -442,7 +442,8 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( { if(cmTarget* depTarget = this->FindTarget(0, ui->c_str())) { - if(depTarget->GetProperty("EXTERNAL_MSPROJECT")) + if(depTarget->GetType() != cmTarget::INTERFACE_LIBRARY + && depTarget->GetProperty("EXTERNAL_MSPROJECT")) { // This utility dependency names an external .vcproj target. // We use LinkLibraryDependencies="true" to link to it without diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 6ae8775..98ce685 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -47,7 +47,7 @@ cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() lg->SetDefineWindowsNULL(true); lg->SetWindowsShell(true); lg->SetWatcomWMake(true); - lg->SetMakeSilentFlag("-s -h"); + lg->SetMakeSilentFlag("-s -h -e"); lg->SetGlobalGenerator(this); lg->SetIgnoreLibPrefix(true); lg->SetPassMakeflags(false); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index be0459d..215d483 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -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/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index d309a2a..10578f2 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -645,7 +645,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // generators for them. bool createInstallGeneratorsForTargetFileSets = true; - if(target.IsFrameworkOnApple()) + if(target.IsFrameworkOnApple() + || target.GetType() == cmTarget::INTERFACE_LIBRARY) { createInstallGeneratorsForTargetFileSets = false; } 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/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 63ec576..c3c5299 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -370,6 +370,11 @@ void cmLocalGenerator::GenerateInstallRules() prefix = "/usr/local"; } #endif + if (const char *stagingPrefix + = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX")) + { + prefix = stagingPrefix; + } // Compute the set of configurations. std::vector<std::string> configurationTypes; @@ -536,6 +541,10 @@ void cmLocalGenerator::GenerateTargetManifest() t != targets.end(); ++t) { cmGeneratorTarget& target = *t->second; + if (target.Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } if(configNames.empty()) { target.GenerateTargetManifest(0); @@ -798,6 +807,7 @@ static const char* ruleReplaceVars[] = "CMAKE_CURRENT_BINARY_DIR", "CMAKE_RANLIB", "CMAKE_LINKER", + "CMAKE_CL_SHOWINCLUDES_PREFIX", 0 }; @@ -1043,11 +1053,38 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, // If this is the compiler then look for the extra variable // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; + const char* compilerTarget = 0; + const char* compilerOptionTarget = 0; + const char* compilerExternalToolchain = 0; + const char* compilerOptionExternalToolchain = 0; + const char* compilerSysroot = 0; + const char* compilerOptionSysroot = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { std::string arg1 = actualReplace + "_ARG1"; cmSystemTools::ReplaceString(arg1, "${LANG}", lang); compilerArg1 = this->Makefile->GetDefinition(arg1.c_str()); + compilerTarget + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str()); + compilerOptionTarget + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_TARGET").c_str()); + compilerExternalToolchain + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILER_EXTERNAL_TOOLCHAIN").c_str()); + compilerOptionExternalToolchain + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str()); + compilerSysroot + = this->Makefile->GetDefinition("CMAKE_SYSROOT"); + compilerOptionSysroot + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_SYSROOT").c_str()); } if(actualReplace.find("${LANG}") != actualReplace.npos) { @@ -1068,6 +1105,24 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, ret += " "; ret += compilerArg1; } + if (compilerTarget && compilerOptionTarget) + { + ret += " "; + ret += compilerOptionTarget; + ret += compilerTarget; + } + if (compilerExternalToolchain && compilerOptionExternalToolchain) + { + ret += " "; + ret += compilerOptionExternalToolchain; + ret += this->EscapeForShell(compilerExternalToolchain, true); + } + if (compilerSysroot && compilerOptionSysroot) + { + ret += " "; + ret += compilerOptionSysroot; + ret += this->EscapeForShell(compilerSysroot, true); + } return ret; } return replace; @@ -1462,6 +1517,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, return; } + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + std::vector<std::string> implicitDirs; // Load implicit include directories for this language. std::string impDirVar = "CMAKE_"; @@ -1474,7 +1531,9 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, for(std::vector<std::string>::const_iterator i = impDirVec.begin(); i != impDirVec.end(); ++i) { - emitted.insert(*i); + std::string d = rootPath + *i; + cmSystemTools::ConvertToUnixSlashes(d); + emitted.insert(d); if (!stripImplicitInclDirs) { implicitDirs.push_back(*i); @@ -2775,6 +2834,11 @@ cmLocalGenerator cmTargets& tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 21700e9..9a89f0f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -266,6 +266,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/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index f1d5e2c..cd12c9d 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -53,6 +53,8 @@ void cmLocalNinjaGenerator::Generate() { this->WriteBuildFileTop(); + this->WritePools(this->GetRulesFileStream()); + const std::string showIncludesPrefix = this->GetMakefile() ->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); if (!showIncludesPrefix.empty()) @@ -64,18 +66,24 @@ void cmLocalNinjaGenerator::Generate() } } - cmTargets& targets = this->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = this->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(&t->second); + if (t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY + || t->second->Target->IsImported()) + { + continue; + } + cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(t->second); if(tg) { tg->Generate(); // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - t->second)) - this->GetGlobalNinjaGenerator()->AddDependencyToAll(&t->second); + *t->second->Target)) + this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } } @@ -195,6 +203,39 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) cmGlobalNinjaGenerator::WriteDivider(os); } +void cmLocalNinjaGenerator::WritePools(std::ostream& os) +{ + cmGlobalNinjaGenerator::WriteDivider(os); + + const char* jobpools = this->GetCMakeInstance() + ->GetProperty("JOB_POOLS", cmProperty::GLOBAL); + if (jobpools) + { + cmGlobalNinjaGenerator::WriteComment(os, + "Pools defined by global property JOB_POOLS"); + std::vector<std::string> pools; + cmSystemTools::ExpandListArgument(jobpools, pools); + for (size_t i = 0; i < pools.size(); ++i) + { + const std::string pool = pools[i]; + const std::string::size_type eq = pool.find("="); + unsigned int jobs; + if (eq != std::string::npos && + sscanf(pool.c_str() + eq, "=%u", &jobs) == 1) + { + os << "pool " << pool.substr(0, eq) << std::endl; + os << " depth = " << jobs << std::endl; + os << std::endl; + } + else + { + cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': ", + pool.c_str()); + } + } + } +} + void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); @@ -287,16 +328,32 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( cmOStringStream cmd; for (std::vector<std::string>::const_iterator li = cmdLines.begin(); - li != cmdLines.end(); ++li) { - if (li != cmdLines.begin()) { - cmd << " && "; + li != cmdLines.end(); ++li) #ifdef _WIN32 - } else if (cmdLines.size() > 1) { - cmd << "cmd.exe /c "; -#endif + { + if (li != cmdLines.begin()) + { + cmd << " && "; + } + else if (cmdLines.size() > 1) + { + cmd << "cmd.exe /C \""; + } + cmd << *li; + } + if (cmdLines.size() > 1) + { + cmd << "\""; } +#else + { + if (li != cmdLines.begin()) + { + cmd << " && "; + } cmd << *li; - } + } +#endif return cmd.str(); } diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8eb63c5..ea854c6 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -112,6 +112,7 @@ private: void WriteProjectHeader(std::ostream& os); void WriteNinjaFilesInclusion(std::ostream& os); void WriteProcessedMakefile(std::ostream& os); + void WritePools(std::ostream& os); void SetConfigName(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 8ed8d0a..6ca386c 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -145,13 +145,19 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - cmTargets& targets = this->Makefile->GetTargets(); + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { + if (t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY + || t->second->Target->IsImported()) + { + continue; + } cmsys::auto_ptr<cmMakefileTargetGenerator> tg( - cmMakefileTargetGenerator::New(&(t->second))); + cmMakefileTargetGenerator::New(t->second)); if (tg.get()) { tg->WriteRuleFiles(); @@ -372,22 +378,28 @@ void cmLocalUnixMakefileGenerator3 // for each target we just provide a rule to cd up to the top and do a make // on the target - cmTargets& targets = this->Makefile->GetTargets(); + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); std::string localName; - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) - { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (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)) + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) + { + if((t->second->GetType() == cmTarget::EXECUTABLE) || + (t->second->GetType() == cmTarget::STATIC_LIBRARY) || + (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)) { - emitted.insert(t->second.GetName()); + if (t->second->Target->IsImported()) + { + continue; + } + + emitted.insert(t->second->GetName()); // for subdirs add a rule to build this specific target by name. - localName = this->GetRelativeTargetDirectory(t->second); + localName = this->GetRelativeTargetDirectory(*t->second->Target); localName += "/rule"; commands.clear(); depends.clear(); @@ -404,22 +416,23 @@ void cmLocalUnixMakefileGenerator3 localName.c_str(), depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). - if(localName != t->second.GetName()) + if(localName != t->second->GetName()) { commands.clear(); depends.push_back(localName); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second.GetName(), depends, commands, true); + t->second->GetName(), depends, commands, true); } // Add a fast rule to build the target - std::string makefileName = this->GetRelativeTargetDirectory(t->second); + std::string makefileName = + this->GetRelativeTargetDirectory(*t->second->Target); makefileName += "/build.make"; // make sure the makefile name is suitable for a makefile std::string makeTargetName = - this->GetRelativeTargetDirectory(t->second); + this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/build"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/fast"; depends.clear(); commands.clear(); @@ -433,11 +446,12 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second.NeedRelinkBeforeInstall(this->ConfigurationName.c_str())) + if(t->second->Target + ->NeedRelinkBeforeInstall(this->ConfigurationName.c_str())) { - makeTargetName = this->GetRelativeTargetDirectory(t->second); + makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/preinstall"; depends.clear(); commands.clear(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 30c3d73..2fd1016 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -482,6 +482,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {"AssemblerListingLocation", "Fa", "ASM List Location", "", cmVS7FlagTable::UserValue}, + {"ProgramDataBaseFileName", "Fd", "Program Database File Name", "", + cmVS7FlagTable::UserValue}, // boolean flags {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE", 0}, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ac8381c..30a1557 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -868,6 +868,10 @@ void cmMakefile::ConfigureFinalPass() for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); l++) { + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } l->second.FinishConfigure(); } } @@ -884,34 +888,61 @@ cmMakefile::AddCustomCommandToTarget(const char* target, { // Find the target to which to add the custom command. cmTargets::iterator ti = this->Targets.find(target); - if(ti != this->Targets.end()) + + if(ti == this->Targets.end()) { - if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY) + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->GetPolicyStatus(cmPolicies::CMP0040)) { - cmOStringStream e; - e << "Target \"" << target << "\" is an OBJECT library " - "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; - this->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; } - // Add the command to the appropriate build step for the target. - std::vector<std::string> no_output; - cmCustomCommand cc(this, no_output, depends, - commandLines, comment, workingDir); - cc.SetEscapeOldStyle(escapeOldStyle); - cc.SetEscapeAllowMakeVars(true); - switch(type) + + if(issueMessage) { - case cmTarget::PRE_BUILD: - ti->second.GetPreBuildCommands().push_back(cc); - break; - case cmTarget::PRE_LINK: - ti->second.GetPreLinkCommands().push_back(cc); - break; - case cmTarget::POST_BUILD: - ti->second.GetPostBuildCommands().push_back(cc); - break; + cmOStringStream e; + e << (this->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0040)) << "\n"; + e << "The target name \"" << target << "\" is unknown in this context."; + IssueMessage(messageType, e.str().c_str()); } + + return; + } + + if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY) + { + cmOStringStream e; + e << "Target \"" << target << "\" is an OBJECT library " + "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + // Add the command to the appropriate build step for the target. + std::vector<std::string> no_output; + cmCustomCommand cc(this, no_output, depends, + commandLines, comment, workingDir); + cc.SetEscapeOldStyle(escapeOldStyle); + cc.SetEscapeAllowMakeVars(true); + switch(type) + { + case cmTarget::PRE_BUILD: + ti->second.AddPreBuildCommand(cc); + break; + case cmTarget::PRE_LINK: + ti->second.AddPreLinkCommand(cc); + break; + case cmTarget::POST_BUILD: + ti->second.AddPostBuildCommand(cc); + break; } } @@ -2229,6 +2260,10 @@ void cmMakefile::ExpandVariablesCMP0019() l != this->Targets.end(); ++l) { cmTarget &t = l->second; + if (t.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } includeDirs = t.GetProperty("INCLUDE_DIRECTORIES"); if(mightExpandVariablesCMP0019(includeDirs)) { @@ -3822,21 +3857,19 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config) return 0; } -cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) +cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) const { if (!excludeAliases) { - std::map<std::string, cmTarget*>::iterator i + std::map<std::string, cmTarget*>::const_iterator i = this->AliasTargets.find(name); if (i != this->AliasTargets.end()) { return i->second; } } - cmTargets& tgts = this->GetTargets(); - - cmTargets::iterator i = tgts.find ( name ); - if ( i != tgts.end() ) + cmTargets::iterator i = this->Targets.find( name ); + if ( i != this->Targets.end() ) { return &i->second; } @@ -4061,8 +4094,11 @@ bool cmMakefile::IsAlias(const char *name) //---------------------------------------------------------------------------- cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) { - cmTarget *t = this->FindTargetToUse(name); - return this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(t); + if (cmTarget *t = this->FindTargetToUse(name)) + { + return this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(t); + } + return 0; } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 76958ca..44aaa66 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -533,7 +533,7 @@ public: this->GeneratorTargets = targets; } - cmTarget* FindTarget(const char* name, bool excludeAliases = false); + cmTarget* FindTarget(const char* name, bool excludeAliases = false) const; /** Find a target to use in place of the given name. The target returned may be imported or built within the project. */ @@ -902,7 +902,7 @@ protected: std::string ProjectName; // project name // libraries, classes, and executables - cmTargets Targets; + mutable cmTargets Targets; std::map<std::string, cmTarget*> AliasTargets; cmGeneratorTargetsType GeneratorTargets; std::vector<cmSourceFile*> SourceFiles; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e4219a9..69fe444 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -21,15 +21,15 @@ //---------------------------------------------------------------------------- cmMakefileExecutableTargetGenerator -::cmMakefileExecutableTargetGenerator(cmTarget* target): - cmMakefileTargetGenerator(target) +::cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target): + cmMakefileTargetGenerator(target->Target) { this->CustomCommandDriver = OnDepends; this->Target->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); - this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target, + this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); } diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h index 3b18166..940226b 100644 --- a/Source/cmMakefileExecutableTargetGenerator.h +++ b/Source/cmMakefileExecutableTargetGenerator.h @@ -17,7 +17,7 @@ class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator { public: - cmMakefileExecutableTargetGenerator(cmTarget* target); + cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target); virtual ~cmMakefileExecutableTargetGenerator(); /* the main entry point for this class. Writes the Makefiles associated diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 29365a3..35818ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -21,15 +21,18 @@ //---------------------------------------------------------------------------- cmMakefileLibraryTargetGenerator -::cmMakefileLibraryTargetGenerator(cmTarget* target): - cmMakefileTargetGenerator(target) +::cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target): + cmMakefileTargetGenerator(target->Target) { this->CustomCommandDriver = OnDepends; - this->Target->GetLibraryNames( - this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, - this->TargetNameImport, this->TargetNamePDB, this->ConfigName); + if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + { + this->Target->GetLibraryNames( + this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, + this->TargetNameImport, this->TargetNamePDB, this->ConfigName); + } - this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target, + this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); } diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 07f828b..1487b56 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -18,7 +18,7 @@ class cmMakefileLibraryTargetGenerator: public cmMakefileTargetGenerator { public: - cmMakefileLibraryTargetGenerator(cmTarget* target); + cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target); virtual ~cmMakefileLibraryTargetGenerator(); /* the main entry point for this class. Writes the Makefiles associated diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6770e10..2063a24 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -27,6 +27,7 @@ #include "cmMakefileLibraryTargetGenerator.h" #include "cmMakefileUtilityTargetGenerator.h" +#include <ctype.h> cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target) : OSXBundleGenerator(0) @@ -62,7 +63,7 @@ cmMakefileTargetGenerator::~cmMakefileTargetGenerator() } cmMakefileTargetGenerator * -cmMakefileTargetGenerator::New(cmTarget *tgt) +cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt) { cmMakefileTargetGenerator *result = 0; @@ -1694,10 +1695,42 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, this->Makefile->GetSafeDefinition(removeFlags.c_str()); std::vector<std::string> removeList; cmSystemTools::ExpandListArgument(removeflags, removeList); + for(std::vector<std::string>::iterator i = removeList.begin(); i != removeList.end(); ++i) { - cmSystemTools::ReplaceString(linkFlags, i->c_str(), ""); + std::string tmp; + std::string::size_type lastPosition = 0; + + for(;;) + { + std::string::size_type position = linkFlags.find(*i, lastPosition); + + if(position == std::string::npos) + { + tmp += linkFlags.substr(lastPosition); + break; + } + else + { + std::string::size_type prefixLength = position - lastPosition; + tmp += linkFlags.substr(lastPosition, prefixLength); + lastPosition = position + i->length(); + + bool validFlagStart = position == 0 || + isspace(linkFlags[position - 1]); + + bool validFlagEnd = lastPosition == linkFlags.size() || + isspace(linkFlags[lastPosition]); + + if(!validFlagStart || !validFlagEnd) + { + tmp += *i; + } + } + } + + linkFlags = tmp; } } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index ec2af1c..4f8fafa 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -38,7 +38,7 @@ public: virtual ~cmMakefileTargetGenerator(); // construct using this factory call - static cmMakefileTargetGenerator *New(cmTarget *tgt); + static cmMakefileTargetGenerator *New(cmGeneratorTarget *tgt); /* the main entry point for this class. Writes the Makefiles associated with this target */ diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 1fa4e95..7751ad9 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -20,11 +20,11 @@ //---------------------------------------------------------------------------- cmMakefileUtilityTargetGenerator -::cmMakefileUtilityTargetGenerator(cmTarget* target): - cmMakefileTargetGenerator(target) +::cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target): + cmMakefileTargetGenerator(target->Target) { this->CustomCommandDriver = OnUtility; - this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target, + this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); } diff --git a/Source/cmMakefileUtilityTargetGenerator.h b/Source/cmMakefileUtilityTargetGenerator.h index fc47b38..8f99300 100644 --- a/Source/cmMakefileUtilityTargetGenerator.h +++ b/Source/cmMakefileUtilityTargetGenerator.h @@ -18,7 +18,7 @@ class cmMakefileUtilityTargetGenerator: public cmMakefileTargetGenerator { public: - cmMakefileUtilityTargetGenerator(cmTarget* target); + cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target); virtual ~cmMakefileUtilityTargetGenerator(); /* the main entry point for this class. Writes the Makefiles associated diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 015654b..73ba815 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -17,6 +17,7 @@ #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmOSXBundleGenerator.h" +#include "cmGeneratorTarget.h" #include <assert.h> #include <algorithm> @@ -27,8 +28,8 @@ cmNinjaNormalTargetGenerator:: -cmNinjaNormalTargetGenerator(cmTarget* target) - : cmNinjaTargetGenerator(target) +cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) + : cmNinjaTargetGenerator(target->Target) , TargetNameOut() , TargetNameSO() , TargetNameReal() @@ -36,15 +37,16 @@ cmNinjaNormalTargetGenerator(cmTarget* target) , TargetNamePDB() , TargetLinkLanguage(0) { - this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->Target + ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->GetExecutableNames(this->TargetNameOut, + target->Target->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->GetLibraryNames(this->TargetNameOut, + target->Target->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, @@ -55,7 +57,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target) { // on Windows the output dir is already needed at compile time // ensure the directory exists (OutDir test) - EnsureDirectoryExists(target->GetDirectory(this->GetConfigName())); + EnsureDirectoryExists(target->Target->GetDirectory(this->GetConfigName())); } this->OSXBundleGenerator = new cmOSXBundleGenerator(target, @@ -462,6 +464,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() linkPath, this->GetGeneratorTarget()); + this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars); + this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); vars["LINK_FLAGS"] = cmGlobalNinjaGenerator ::EncodeLiteral(vars["LINK_FLAGS"]); @@ -534,7 +538,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/'); } - std::vector<cmCustomCommand> *cmdLists[3] = { + const std::vector<cmCustomCommand> *cmdLists[3] = { &this->GetTarget()->GetPreBuildCommands(), &this->GetTarget()->GetPreLinkCommands(), &this->GetTarget()->GetPostBuildCommands() diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 284804b..c7a089c 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -21,11 +21,12 @@ class cmSourceFile; class cmOSXBundleGenerator; +class cmGeneratorTarget; class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator { public: - cmNinjaNormalTargetGenerator(cmTarget* target); + cmNinjaNormalTargetGenerator(cmGeneratorTarget* target); ~cmNinjaNormalTargetGenerator(); void Generate(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 26eadbe..e3c058f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -26,7 +26,7 @@ #include <algorithm> cmNinjaTargetGenerator * -cmNinjaTargetGenerator::New(cmTarget* target) +cmNinjaTargetGenerator::New(cmGeneratorTarget* target) { switch (target->GetType()) { @@ -44,7 +44,7 @@ cmNinjaTargetGenerator::New(cmTarget* target) // We only want to process global targets that live in the home // (i.e. top-level) directory. CMake creates copies of these targets // in every directory, which we don't need. - cmMakefile *mf = target->GetMakefile(); + cmMakefile *mf = target->Target->GetMakefile(); if (strcmp(mf->GetStartDirectory(), mf->GetHomeDirectory()) == 0) return new cmNinjaUtilityTargetGenerator(target); // else fallthrough @@ -360,10 +360,11 @@ cmNinjaTargetGenerator cmMakefile* mf = this->GetMakefile(); - const bool usingMSVC = std::string("MSVC") == - (mf->GetDefinition("CMAKE_C_COMPILER_ID") ? - mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") : - mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID")); + const std::string cId = mf->GetDefinition("CMAKE_C_COMPILER_ID") + ? mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") + : mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"); + + const bool usingMSVC = (cId == "MSVC" || cId == "Intel"); // Tell ninja dependency format so all deps can be loaded into a database std::string deptype; @@ -572,6 +573,8 @@ cmNinjaTargetGenerator ConvertToNinjaPath(objectDir.c_str()).c_str(), cmLocalGenerator::SHELL); + this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars); + this->SetMsvcTargetPdbVariable(vars); if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS")) @@ -725,3 +728,14 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( // Add as a dependency of all target so that it gets called. this->Generator->GetGlobalGenerator()->AddDependencyToAll(output); } + +void cmNinjaTargetGenerator::addPoolNinjaVariable(const char* pool_property, + cmTarget* target, + cmNinjaVars& vars) +{ + const char* pool = target->GetProperty(pool_property); + if (pool) + { + vars["pool"] = pool; + } +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 1cf811a..2ce1ed7 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -30,7 +30,7 @@ class cmNinjaTargetGenerator { public: /// Create a cmNinjaTargetGenerator according to the @a target's type. - static cmNinjaTargetGenerator* New(cmTarget* target); + static cmNinjaTargetGenerator* New(cmGeneratorTarget* target); /// Build a NinjaTargetGenerator. cmNinjaTargetGenerator(cmTarget* target); @@ -136,12 +136,15 @@ protected: }; friend struct MacOSXContentGeneratorType; -protected: + MacOSXContentGeneratorType* MacOSXContentGenerator; // Properly initialized by sub-classes. cmOSXBundleGenerator* OSXBundleGenerator; std::set<cmStdString> MacContentFolders; + void addPoolNinjaVariable(const char* pool_property, + cmTarget* target, + cmNinjaVars& vars); private: cmTarget* Target; diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 755ce6e..8556565 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -18,8 +18,9 @@ #include "cmSourceFile.h" #include "cmTarget.h" -cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(cmTarget *target) - : cmNinjaTargetGenerator(target) {} +cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator( + cmGeneratorTarget *target) + : cmNinjaTargetGenerator(target->Target) {} cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h index 8b82ce4..add0291 100644 --- a/Source/cmNinjaUtilityTargetGenerator.h +++ b/Source/cmNinjaUtilityTargetGenerator.h @@ -21,7 +21,7 @@ class cmSourceFile; class cmNinjaUtilityTargetGenerator : public cmNinjaTargetGenerator { public: - cmNinjaUtilityTargetGenerator(cmTarget* target); + cmNinjaUtilityTargetGenerator(cmGeneratorTarget* target); ~cmNinjaUtilityTargetGenerator(); void Generate(); diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index a475c7c..9a340dc 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -18,10 +18,10 @@ //---------------------------------------------------------------------------- cmOSXBundleGenerator:: -cmOSXBundleGenerator(cmTarget* target, +cmOSXBundleGenerator(cmGeneratorTarget* target, const char* configName) - : Target(target) - , Makefile(target->GetMakefile()) + : Target(target->Target) + , Makefile(target->Target->GetMakefile()) , LocalGenerator(Makefile->GetLocalGenerator()) , ConfigName(configName) , MacContentFolders(0) diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index ec82b9a..29b7611 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -21,11 +21,12 @@ class cmTarget; class cmMakefile; class cmLocalGenerator; +class cmGeneratorTarget; class cmOSXBundleGenerator { public: - cmOSXBundleGenerator(cmTarget* target, + cmOSXBundleGenerator(cmGeneratorTarget* target, const char* configName); // create an app bundle at a given root, and return diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 16b2bea..5de36ed 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -32,7 +32,7 @@ void cmLBDepend::DependWalk(cmDependInformation* info) std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) { - if(!strncmp(line.c_str(), "#include", 8)) + if(cmHasLiteralPrefix(line.c_str(), "#include")) { // if it is an include line then create a string class std::string currentline = line; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 7b80d14..0b3018e 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -289,7 +289,7 @@ cmPolicies::cmPolicies() this->DefinePolicy( CMP0037, "CMP0037", - "Target names should match a validity pattern.", + "Target names should not be reserved and should match a validity pattern.", 3,0,0,0, cmPolicies::WARN); this->DefinePolicy( @@ -301,6 +301,16 @@ cmPolicies::cmPolicies() CMP0039, "CMP0039", "Utility targets may not have link dependencies.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + 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 fc239d4..245ec4b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -88,9 +88,13 @@ public: CMP0034, ///< Disallow command: utility_source CMP0035, ///< Disallow command: variable_requires CMP0036, ///< Disallow command: build_name - CMP0037, ///< Target names should match a validity pattern. + CMP0037, ///< Target names should not be reserved and + /// should match a validity pattern. CMP0038, ///< Targets may not link directly to themselves 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 36cb368..835e3b4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -204,6 +204,11 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) "", makefile->GetCurrentOutputDirectory()); std::vector<std::string> depends; + if (const char *autogenDepends = + target->GetProperty("AUTOGEN_TARGET_DEPENDS")) + { + cmSystemTools::ExpandListArgument(autogenDepends, depends); + } std::vector<std::string> toolNames; if (target->GetPropertyAsBool("AUTOMOC")) { @@ -257,7 +262,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) workingDirectory.c_str()); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); - target->GetPreBuildCommands().push_back(cc); + target->AddPreBuildCommand(cc); } else #endif @@ -360,6 +365,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")) { @@ -368,7 +374,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) } if (target->GetPropertyAsBool("AUTOUIC")) { - this->SetupAutoUicTarget(target); + this->SetupAutoUicTarget(target, configUicOptions); } if (target->GetPropertyAsBool("AUTORCC")) { @@ -383,7 +389,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 ) @@ -414,6 +422,16 @@ 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"; + } + } } } @@ -508,7 +526,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()) { @@ -517,7 +535,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()) { @@ -560,6 +578,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, "translate", "postfix", "generator", + "include", // Since Qt 5.3 "g" }; std::vector<std::string> extraOpts; @@ -595,7 +614,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 *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* target, + std::map<std::string, std::string> &configUicOptions) { cmMakefile *makefile = target->GetMakefile(); @@ -644,10 +681,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 = @@ -966,9 +1023,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; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 116f174..e877f7d 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -31,7 +31,8 @@ private: const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines); - void SetupAutoUicTarget(cmTarget* target); + void SetupAutoUicTarget(cmTarget* target, + std::map<std::string, std::string> &configUicOptions); void SetupAutoRccTarget(cmTarget* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index bb193bf..36363a1 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -23,7 +23,7 @@ bool cmSetCommand // watch for ENV signatures const char* variable = args[0].c_str(); // VAR is always first - if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5) + if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) { // what is the variable name char *varName = new char [strlen(variable)]; diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 18d017d..7369fe6 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -377,13 +377,31 @@ static thisClass* SafeDownCast(cmObject *c) \ return 0;\ } +inline bool cmHasLiteralPrefixImpl(const std::string &str1, + const char *str2, + size_t N) +{ + return strncmp(str1.c_str(), str2, N) == 0; +} + +inline bool cmHasLiteralPrefixImpl(const char* str1, + const char *str2, + size_t N) +{ + return strncmp(str1, str2, N) == 0; +} + #if defined(_MSC_VER) && _MSC_VER < 1300 \ - || defined(__GNUC__) && __GNUC__ < 3 + || defined(__GNUC__) && __GNUC__ < 3 \ + || defined(__BORLANDC__) #define cmArrayBegin(a) a #define cmArraySize(a) (sizeof(a)/sizeof(*a)) #define cmArrayEnd(a) a + cmArraySize(a) +#define cmHasLiteralPrefix(STR1, STR2) \ + cmHasLiteralPrefixImpl(STR1, "" STR2 "", sizeof(STR2) - 1) + #else template<typename T, size_t N> @@ -393,6 +411,12 @@ const T* cmArrayEnd(const T (&a)[N]) { return a + N; } template<typename T, size_t N> size_t cmArraySize(const T (&)[N]) { return N; } +template<typename T, size_t N> +bool cmHasLiteralPrefix(T str1, const char (&str2)[N]) +{ + return cmHasLiteralPrefixImpl(str1, str2, N - 1); +} + #endif struct cmStrCmp { @@ -404,6 +428,12 @@ struct cmStrCmp { return strcmp(input, m_test) == 0; } + // For use with binary_search + bool operator()(const char *str1, const char *str2) + { + return strcmp(str1, str2) < 0; + } + private: const char *m_test; }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c9905b6..fe68a8a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -91,8 +91,8 @@ public: } ~cmTargetInternals(); typedef cmTarget::SourceFileFlags SourceFileFlags; - std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; - bool SourceFileFlagsConstructed; + mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; + mutable bool SourceFileFlagsConstructed; // The backtrace when the target was created. cmListFileBacktrace Backtrace; @@ -135,6 +135,7 @@ public: }; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries; + std::vector<TargetPropertyEntry*> AutoUicOptionsEntries; std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries; @@ -143,11 +144,14 @@ public: mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileOptionsEntries; mutable std::map<std::string, std::vector<TargetPropertyEntry*> > + CachedLinkInterfaceAutoUicOptionsEntries; + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileDefinitionsEntries; mutable std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; mutable std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; mutable std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone; + mutable std::map<std::string, bool> CacheLinkInterfaceAutoUicOptionsDone; }; //---------------------------------------------------------------------------- @@ -182,6 +186,7 @@ cmTargetInternals::~cmTargetInternals() { deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries); deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries); + deleteAndClear(this->CachedLinkInterfaceAutoUicOptionsEntries); deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries); } @@ -255,32 +260,34 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->IsApple = this->Makefile->IsOn("APPLE"); // Setup default property values. - this->SetPropertyDefault("INSTALL_NAME_DIR", 0); - this->SetPropertyDefault("INSTALL_RPATH", ""); - this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); - this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); - this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); - this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("Fortran_FORMAT", 0); - this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); - this->SetPropertyDefault("GNUtoMS", 0); - this->SetPropertyDefault("OSX_ARCHITECTURES", 0); - this->SetPropertyDefault("AUTOMOC", 0); - this->SetPropertyDefault("AUTOUIC", 0); - this->SetPropertyDefault("AUTORCC", 0); - this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); - this->SetPropertyDefault("AUTOUIC_OPTIONS", 0); - this->SetPropertyDefault("AUTORCC_OPTIONS", 0); - this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0); - this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); - this->SetPropertyDefault("WIN32_EXECUTABLE", 0); - this->SetPropertyDefault("MACOSX_BUNDLE", 0); - this->SetPropertyDefault("MACOSX_RPATH", 0); - this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0); - + if (this->GetType() != INTERFACE_LIBRARY) + { + this->SetPropertyDefault("INSTALL_NAME_DIR", 0); + this->SetPropertyDefault("INSTALL_RPATH", ""); + this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); + this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); + this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); + this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("Fortran_FORMAT", 0); + this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); + this->SetPropertyDefault("GNUtoMS", 0); + this->SetPropertyDefault("OSX_ARCHITECTURES", 0); + this->SetPropertyDefault("AUTOMOC", 0); + this->SetPropertyDefault("AUTOUIC", 0); + this->SetPropertyDefault("AUTORCC", 0); + this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); + this->SetPropertyDefault("AUTOUIC_OPTIONS", 0); + this->SetPropertyDefault("AUTORCC_OPTIONS", 0); + this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0); + this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); + this->SetPropertyDefault("WIN32_EXECUTABLE", 0); + this->SetPropertyDefault("MACOSX_BUNDLE", 0); + this->SetPropertyDefault("MACOSX_RPATH", 0); + this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0); + } // Collect the set of configuration types. std::vector<std::string> configNames; @@ -300,6 +307,11 @@ void cmTarget::SetMakefile(cmMakefile* mf) std::string configUpper = cmSystemTools::UpperCase(*ci); for(const char** p = configProps; *p; ++p) { + if (this->TargetTypeValue == INTERFACE_LIBRARY + && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) + { + continue; + } std::string property = *p; property += configUpper; this->SetPropertyDefault(property.c_str(), 0); @@ -311,7 +323,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) // did not support this variable. Projects may still specify the // property directly. TODO: Make this depend on backwards // compatibility setting. - if(this->TargetTypeValue != cmTarget::EXECUTABLE) + if(this->TargetTypeValue != cmTarget::EXECUTABLE + && this->TargetTypeValue != cmTarget::INTERFACE_LIBRARY) { std::string property = cmSystemTools::UpperCase(*ci); property += "_POSTFIX"; @@ -352,16 +365,22 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->InsertCompileOption(*it); } - this->SetPropertyDefault("C_VISIBILITY_PRESET", 0); - this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0); - this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0); + if (this->GetType() != INTERFACE_LIBRARY) + { + this->SetPropertyDefault("C_VISIBILITY_PRESET", 0); + this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0); + this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0); + } if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY || this->TargetTypeValue == cmTarget::MODULE_LIBRARY) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } - this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); + if (this->GetType() != INTERFACE_LIBRARY) + { + this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); + } // Record current policies for later use. #define CAPTURE_TARGET_POLICY(POLICY) \ @@ -379,6 +398,9 @@ void cmTarget::SetMakefile(cmMakefile* mf) // so ensure that the conditions don't lead to nonsense. this->PolicyStatusCMP0022 = cmPolicies::NEW; } + + this->SetPropertyDefault("JOB_POOL_COMPILE", 0); + this->SetPropertyDefault("JOB_POOL_LINK", 0); } //---------------------------------------------------------------------------- @@ -438,7 +460,7 @@ bool cmTarget::IsExecutableWithExports() const } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkable() +bool cmTarget::IsLinkable() const { return (this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -560,7 +582,7 @@ cmSourceFile* cmTarget::AddSource(const char* s) //---------------------------------------------------------------------------- void cmTarget::ProcessSourceExpression(std::string const& expr) { - if(strncmp(expr.c_str(), "$<TARGET_OBJECTS:", 17) == 0 && + if(cmHasLiteralPrefix(expr.c_str(), "$<TARGET_OBJECTS:") && expr[expr.size()-1] == '>') { std::string objLibName = expr.substr(17, expr.size()-18); @@ -577,7 +599,7 @@ void cmTarget::ProcessSourceExpression(std::string const& expr) //---------------------------------------------------------------------------- struct cmTarget::SourceFileFlags -cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) +cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const { struct SourceFileFlags flags; this->ConstructSourceFileFlags(); @@ -591,7 +613,7 @@ cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) } //---------------------------------------------------------------------------- -void cmTarget::ConstructSourceFileFlags() +void cmTarget::ConstructSourceFileFlags() const { if(this->Internal->SourceFileFlagsConstructed) { @@ -769,9 +791,9 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, } //---------------------------------------------------------------------------- -bool cmTarget::NameResolvesToFramework(const std::string& libname) +bool cmTarget::NameResolvesToFramework(const std::string& libname) const { - return this->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()-> + return this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> NameResolvesToFramework(libname); } @@ -811,7 +833,7 @@ void cmTarget::GetDirectLinkLibraries(const char *config, //---------------------------------------------------------------------------- void cmTarget::GetInterfaceLinkLibraries(const char *config, - std::vector<std::string> &libs, cmTarget *head) + std::vector<std::string> &libs, cmTarget *head) const { const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (prop) @@ -834,7 +856,7 @@ void cmTarget::GetInterfaceLinkLibraries(const char *config, //---------------------------------------------------------------------------- std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt) + cmTarget::LinkLibraryType llt) const { if (llt == GENERAL) { @@ -1370,12 +1392,63 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, } //---------------------------------------------------------------------------- +static bool whiteListedInterfaceProperty(const char *prop) +{ + if(cmHasLiteralPrefix(prop, "INTERFACE_")) + { + return true; + } + static const char* builtIns[] = { + // ###: This must remain sorted. It is processed with a binary search. + "COMPATIBLE_INTERFACE_BOOL", + "COMPATIBLE_INTERFACE_NUMBER_MAX", + "COMPATIBLE_INTERFACE_NUMBER_MIN", + "COMPATIBLE_INTERFACE_STRING", + "EXCLUDE_FROM_ALL", + "EXCLUDE_FROM_DEFAULT_BUILD", + "EXPORT_NAME", + "IMPORTED_LINK_INTERFACE_LANGUAGES", + "IMPORTED", + "NAME", + "TYPE", + "VERSION" + }; + + if (std::binary_search(cmArrayBegin(builtIns), + cmArrayEnd(builtIns), + prop, + cmStrCmp(prop))) + { + return true; + } + + if (cmHasLiteralPrefix(prop, "EXCLUDE_FROM_DEFAULT_BUILD_") + || cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LANGUAGES_") + || cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) + { + return true; + } + + return false; +} + +//---------------------------------------------------------------------------- void cmTarget::SetProperty(const char* prop, const char* value) { if (!prop) { return; } + if (this->GetType() == INTERFACE_LIBRARY + && !whiteListedInterfaceProperty(prop)) + { + cmOStringStream e; + e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " + "The property \"" << prop << "\" is not allowed."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return; + } + if (strcmp(prop, "NAME") == 0) { cmOStringStream e; @@ -1405,6 +1478,17 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } + if(strcmp(prop,"AUTOUIC_OPTIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + deleteAndClear(this->Internal->AutoUicOptionsEntries); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); + this->Internal->AutoUicOptionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + return; + } if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) { cmListFileBacktrace lfbt; @@ -1445,6 +1529,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value, { return; } + if (this->GetType() == INTERFACE_LIBRARY + && !whiteListedInterfaceProperty(prop)) + { + cmOStringStream e; + e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " + "The property \"" << prop << "\" is not allowed."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return; + } if (strcmp(prop, "NAME") == 0) { cmOStringStream e; @@ -1470,6 +1563,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } + if(strcmp(prop,"AUTOUIC_OPTIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + this->Internal->AutoUicOptionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + return; + } if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) { cmListFileBacktrace lfbt; @@ -1966,6 +2068,106 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- +void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, + const char *config) const +{ + std::set<std::string> uniqueOptions; + cmListFileBacktrace lfbt; + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "AUTOUIC_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugAutoUicOptionsDone = true; + } + + processCompileOptions(this, + this->Internal->AutoUicOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions); + + std::string configString = config ? config : ""; + if (!this->Internal->CacheLinkInterfaceAutoUicOptionsDone[configString]) + { + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->Internal->LinkInterfacePropertyEntries.begin(), + end = this->Internal->LinkInterfacePropertyEntries.end(); + it != end; ++it) + { + if (!cmGeneratorExpression::IsValidTargetName(it->Value) + && cmGeneratorExpression::Find(it->Value) == std::string::npos) + { + continue; + } + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(it->Value); + std::string targetResult = cge->Evaluate(this->Makefile, config, + false, this, 0, 0); + if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + { + continue; + } + } + std::string optionGenex = "$<TARGET_PROPERTY:" + + it->Value + ",INTERFACE_AUTOUIC_OPTIONS>"; + if (cmGeneratorExpression::Find(it->Value) != std::string::npos) + { + // Because it->Value is a generator expression, ensure that it + // evaluates to the non-empty string before being used in the + // TARGET_PROPERTY expression. + optionGenex = "$<$<BOOL:" + it->Value + ">:" + optionGenex + ">"; + } + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( + optionGenex); + + this->Internal + ->CachedLinkInterfaceAutoUicOptionsEntries[configString].push_back( + new cmTargetInternals::TargetPropertyEntry(cge, + it->Value)); + } + } + + processCompileOptions(this, + this->Internal->CachedLinkInterfaceAutoUicOptionsEntries[configString], + result, + uniqueOptions, + &dagChecker, + config, + debugOptions); + + if (!this->Makefile->IsGeneratingBuildSystem()) + { + deleteAndClear(this->Internal->CachedLinkInterfaceAutoUicOptionsEntries); + } + else + { + this->Internal->CacheLinkInterfaceAutoUicOptionsDone[configString] = true; + } +} + +//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, const char *config) const { @@ -2199,11 +2401,11 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, void cmTarget::MaybeInvalidatePropertyCache(const char* prop) { // Wipe out maps caching information affected by this property. - if(this->IsImported() && strncmp(prop, "IMPORTED", 8) == 0) + if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) { this->Internal->ImportInfoMap.clear(); } - if(!this->IsImported() && strncmp(prop, "LINK_INTERFACE_", 15) == 0) + if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) { this->ClearLinkMaps(); } @@ -2276,24 +2478,24 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, } //---------------------------------------------------------------------------- -void cmTarget::CheckProperty(const char* prop, cmMakefile* context) +void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const { // Certain properties need checking. - if(strncmp(prop, "LINK_INTERFACE_LIBRARIES", 24) == 0) + if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); } } - if(strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES", 33) == 0) + if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); } } - if(strncmp(prop, "INTERFACE_LINK_LIBRARIES", 24) == 0) + if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { @@ -2382,7 +2584,7 @@ std::string cmTarget::GetDirectory(const char* config, bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBDirectory(const char* config) +std::string cmTarget::GetPDBDirectory(const char* config) const { if(OutputInfo const* info = this->GetOutputInfo(config)) { @@ -2453,7 +2655,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const } //---------------------------------------------------------------------------- -void cmTarget::GetTargetVersion(int& major, int& minor) +void cmTarget::GetTargetVersion(int& major, int& minor) const { int patch; this->GetTargetVersion(false, major, minor, patch); @@ -2461,7 +2663,7 @@ void cmTarget::GetTargetVersion(int& major, int& minor) //---------------------------------------------------------------------------- void cmTarget::GetTargetVersion(bool soversion, - int& major, int& minor, int& patch) + int& major, int& minor, int& patch) const { // Set the default values. major = 0; @@ -2489,7 +2691,7 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- -const char* cmTarget::GetFeature(const char* feature, const char* config) +const char* cmTarget::GetFeature(const char* feature, const char* config) const { if(config && *config) { @@ -2560,6 +2762,16 @@ const char *cmTarget::GetProperty(const char* prop, return 0; } + if (this->GetType() == INTERFACE_LIBRARY + && !whiteListedInterfaceProperty(prop)) + { + cmOStringStream e; + e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " + "The property \"" << prop << "\" is not allowed."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return 0; + } + if (strcmp(prop, "NAME") == 0) { return this->GetName(); @@ -2595,7 +2807,7 @@ const char *cmTarget::GetProperty(const char* prop, } // Support "LOCATION_<CONFIG>". - if(strncmp(prop, "LOCATION_", 9) == 0) + if(cmHasLiteralPrefix(prop, "LOCATION_")) { if (!this->HandleLocationPropertyPolicy()) { @@ -2662,6 +2874,24 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } + if(strcmp(prop,"AUTOUIC_OPTIONS") == 0) + { + static std::string output; + output = ""; + std::string sep; + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for (std::vector<TargetPropertyEntry*>::const_iterator + it = this->Internal->AutoUicOptionsEntries.begin(), + end = this->Internal->AutoUicOptionsEntries.end(); + it != end; ++it) + { + output += sep; + output += (*it)->ge->GetInput(); + sep = ";"; + } + return output.c_str(); + } if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) { static std::string output; @@ -3145,7 +3375,7 @@ bool cmTarget::HasMacOSXRpath(const char* config) const } //---------------------------------------------------------------------------- -bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) +bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const { if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY) { @@ -3597,14 +3827,14 @@ void cmTarget::GetExecutableNames(std::string& name, } //---------------------------------------------------------------------------- -bool cmTarget::HasImplibGNUtoMS() +bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); } //---------------------------------------------------------------------------- bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, - std::string& out, const char* newExt) + std::string& out, const char* newExt) const { if(this->HasImplibGNUtoMS() && gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") @@ -3976,7 +4206,7 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const } //---------------------------------------------------------------------------- -bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) +bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) const { std::string dir; return this->ComputeOutputDir(config, implib, dir); @@ -4037,7 +4267,7 @@ std::string cmTarget::GetFrameworkVersion() const } //---------------------------------------------------------------------------- -const char* cmTarget::GetExportMacro() +const char* cmTarget::GetExportMacro() const { // Define the symbol for targets that export symbols. if(this->GetType() == cmTarget::SHARED_LIBRARY || @@ -4433,7 +4663,8 @@ bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, const char *config) const { - if (this->TargetTypeValue == OBJECT_LIBRARY) + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) { return false; } @@ -4446,7 +4677,8 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, const char *config) const { - if (this->TargetTypeValue == OBJECT_LIBRARY) + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) { return false; } @@ -4458,7 +4690,8 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, const char *config) const { - if (this->TargetTypeValue == OBJECT_LIBRARY) + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) { return false; } @@ -4470,7 +4703,8 @@ bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const char *config) const { - if (this->TargetTypeValue == OBJECT_LIBRARY) + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) { return false; } @@ -5105,34 +5339,37 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, { emitted.insert(*li); } - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - for(std::vector<std::string>::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { - if(emitted.insert(*li).second) + LinkImplementation const* impl = this->GetLinkImplementation(config, + headTarget); + for(std::vector<std::string>::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { - if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str())) + if(emitted.insert(*li).second) { - // This is a runtime dependency on another shared library. - if(tgt->GetType() == cmTarget::SHARED_LIBRARY) + if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str())) { - iface.SharedDeps.push_back(*li); + // This is a runtime dependency on another shared library. + if(tgt->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. } } - } - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; + if(this->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } } } } @@ -5864,6 +6101,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { deleteAndClear(this->Pointer->IncludeDirectoriesEntries); deleteAndClear(this->Pointer->CompileOptionsEntries); + deleteAndClear(this->Pointer->AutoUicOptionsEntries); deleteAndClear(this->Pointer->CompileDefinitionsEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b516a0a..93e8b99 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; @@ -114,12 +115,18 @@ public: /** * Get the list of the custom commands for this target */ - std::vector<cmCustomCommand> &GetPreBuildCommands() + std::vector<cmCustomCommand> const &GetPreBuildCommands() const {return this->PreBuildCommands;} - std::vector<cmCustomCommand> &GetPreLinkCommands() + std::vector<cmCustomCommand> const &GetPreLinkCommands() const {return this->PreLinkCommands;} - std::vector<cmCustomCommand> &GetPostBuildCommands() + std::vector<cmCustomCommand> const &GetPostBuildCommands() const {return this->PostBuildCommands;} + void AddPreBuildCommand(cmCustomCommand const &cmd) + {this->PreBuildCommands.push_back(cmd);} + void AddPreLinkCommand(cmCustomCommand const &cmd) + {this->PreLinkCommands.push_back(cmd);} + void AddPostBuildCommand(cmCustomCommand const &cmd) + {this->PostBuildCommands.push_back(cmd);} /** * Get the list of the source files used by this target @@ -156,7 +163,8 @@ public: /** * Get the flags for a given source file as used in this target */ - struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf); + struct SourceFileFlags + GetTargetSourceFileFlags(const cmSourceFile* sf) const; /** * Add sources to the target. @@ -179,7 +187,7 @@ public: cmTarget const* head) const; void GetInterfaceLinkLibraries(const char *config, std::vector<std::string> &, - cmTarget *head); + cmTarget *head) const; /** Compute the link type to use for the given configuration. */ LinkLibraryType ComputeLinkType(const char* config) const; @@ -190,7 +198,7 @@ public: void ClearDependencyInformation(cmMakefile& mf, const char* target); // Check to see if a library is a framework and treat it different on Mac - bool NameResolvesToFramework(const std::string& libname); + bool NameResolvesToFramework(const std::string& libname) const; void AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt); @@ -212,14 +220,14 @@ public: * Set the path where this target should be installed. This is relative to * INSTALL_PREFIX */ - std::string GetInstallPath() {return this->InstallPath;} + std::string GetInstallPath() const {return this->InstallPath;} void SetInstallPath(const char *name) {this->InstallPath = name;} /** * Set the path where this target (if it has a runtime part) should be * installed. This is relative to INSTALL_PREFIX */ - std::string GetRuntimeInstallPath() {return this->RuntimeInstallPath;} + std::string GetRuntimeInstallPath() const {return this->RuntimeInstallPath;} void SetRuntimeInstallPath(const char *name) { this->RuntimeInstallPath = name; } @@ -246,9 +254,9 @@ public: const char *GetProperty(const char *prop) const; const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; bool GetPropertyAsBool(const char *prop) const; - void CheckProperty(const char* prop, cmMakefile* context); + void CheckProperty(const char* prop, cmMakefile* context) const; - const char* GetFeature(const char* feature, const char* config); + const char* GetFeature(const char* feature, const char* config) const; bool IsImported() const {return this->IsImportedTarget;} @@ -330,7 +338,7 @@ public: If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical pdb output directory is given. */ - std::string GetPDBDirectory(const char* config = 0); + std::string GetPDBDirectory(const char* config = 0) const; /** Get the location of the target in the build tree for the given configuration. This location is suitable for use as the LOCATION @@ -340,12 +348,13 @@ public: /** Get the target major and minor version numbers interpreted from the VERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ - void GetTargetVersion(int& major, int& minor); + void GetTargetVersion(int& major, int& minor) const; /** Get the target major, minor, and patch version numbers interpreted from the VERSION or SOVERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ - void GetTargetVersion(bool soversion, int& major, int& minor, int& patch); + void + GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; /** * Make sure the full path to all source files is known. @@ -377,7 +386,7 @@ public: /** Test for special case of a third-party shared library that has no soname at all. */ - bool IsImportedSharedLibWithoutSOName(const char* config); + bool IsImportedSharedLibWithoutSOName(const char* config) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -399,12 +408,12 @@ public: std::string& pdbName, const char* config) const; /** Does this target have a GNU implib to convert to MS format? */ - bool HasImplibGNUtoMS(); + bool HasImplibGNUtoMS() const; /** Convert the given GNU import library name (.dll.a) to a name with a new extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, - const char* newExt = 0); + const char* newExt = 0) const; /** * Compute whether this target must be relinked before installing. @@ -442,7 +451,7 @@ public: /** Get the macro to define when building sources in this target. If no macro should be defined null is returned. */ - const char* GetExportMacro(); + const char* GetExportMacro() const; void GetCompileDefinitions(std::vector<std::string> &result, const char *config) const; @@ -459,10 +468,10 @@ public: bool IsExecutableWithExports() const; /** Return whether this target may be used to link another target. */ - bool IsLinkable(); + bool IsLinkable() const; /** Return whether or not the target is for a DLL platform. */ - bool IsDLLPlatform() { return this->DLLPlatform; } + bool IsDLLPlatform() const { return this->DLLPlatform; } /** Return whether or not the target has a DLL import library. */ bool HasImportLibrary() const; @@ -493,7 +502,7 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const char* config, bool implib); + bool UsesDefaultOutputDir(const char* config, bool implib) const; /** @return the mac content directory for this target. */ std::string GetMacContentDirectory(const char* config, @@ -524,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, @@ -546,7 +557,7 @@ public: const char *config) const; std::string GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt); + cmTarget::LinkLibraryType llt) const; void AddSystemIncludeDirectories(const std::set<cmStdString> &incs); void AddSystemIncludeDirectories(const std::vector<std::string> &incs); @@ -671,7 +682,7 @@ private: bool HaveInstallRule; std::string InstallPath; std::string RuntimeInstallPath; - std::string ExportMacro; + mutable std::string ExportMacro; std::set<cmStdString> Utilities; bool RecordDependencies; mutable cmPropertyMap Properties; @@ -681,6 +692,7 @@ private: bool IsImportedTarget; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; + mutable bool DebugAutoUicOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable std::set<std::string> LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; @@ -736,7 +748,7 @@ private: friend class cmTargetTraceDependencies; cmTargetInternalPointer Internal; - void ConstructSourceFileFlags(); + void ConstructSourceFileFlags() const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 46c9666..b567252 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -44,7 +44,7 @@ std::string cmTargetCompileDefinitionsCommand for(std::vector<std::string>::const_iterator it = content.begin(); it != content.end(); ++it) { - if (strncmp(it->c_str(), "-D", 2) == 0) + if (cmHasLiteralPrefix(it->c_str(), "-D")) { defs += sep + it->substr(2); } 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/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 84f3029..053cdfc 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -24,7 +24,7 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, const char* variable = args[0].c_str(); // unset(ENV{VAR}) - if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5) + if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) { // what is the variable name char *envVarName = new char [strlen(variable)]; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ace1eef..10663b7 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -184,7 +184,8 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line, void cmVisualStudio10TargetGenerator::Generate() { // do not generate external ms projects - if(this->Target->GetProperty("EXTERNAL_MSPROJECT")) + if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY + || this->Target->GetProperty("EXTERNAL_MSPROJECT")) { return; } @@ -1794,7 +1795,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName) void cmVisualStudio10TargetGenerator::WriteEvent( const char* name, - std::vector<cmCustomCommand> & commands, + std::vector<cmCustomCommand> const& commands, std::string const& configName) { if(commands.size() == 0) @@ -1807,10 +1808,10 @@ void cmVisualStudio10TargetGenerator::WriteEvent( std::string script; const char* pre = ""; std::string comment; - for(std::vector<cmCustomCommand>::iterator i = commands.begin(); + for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand& command = *i; + const cmCustomCommand& command = *i; comment += pre; comment += lg->ConstructComment(command); script += pre; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 9a480a8..d1f3d19 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -87,7 +87,8 @@ private: void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void WriteLibOptions(std::string const& config); void WriteEvents(std::string const& configName); - void WriteEvent(const char* name, std::vector<cmCustomCommand> & commands, + void WriteEvent(const char* name, + std::vector<cmCustomCommand> const& commands, std::string const& configName); void WriteGroupSources(const char* name, ToolSources const& sources, std::vector<cmSourceGroup>& ); 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/cmakemain.cxx b/Source/cmakemain.cxx index 6ef0579..882b072 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -273,7 +273,7 @@ int do_cmake(int ac, char** av) list_all_cached = true; list_help = true; } - else if (strncmp(av[i], "-P", strlen("-P")) == 0) + else if (cmHasLiteralPrefix(av[i], "-P")) { if ( i == ac -1 ) { @@ -287,8 +287,7 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } } - else if (strncmp(av[i], "--find-package", - strlen("--find-package")) == 0) + else if (cmHasLiteralPrefix(av[i], "--find-package")) { workingMode = cmake::FIND_PACKAGE_MODE; args.push_back(av[i]); 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/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index a9d89d4..3745f78 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -115,6 +115,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_Base64 1) SET(KWSYS_USE_Directory 1) SET(KWSYS_USE_DynamicLoader 1) + SET(KWSYS_USE_Encoding 1) SET(KWSYS_USE_Glob 1) SET(KWSYS_USE_MD5 1) SET(KWSYS_USE_Process 1) @@ -125,6 +126,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_FundamentalType 1) SET(KWSYS_USE_Terminal 1) SET(KWSYS_USE_IOStream 1) + SET(KWSYS_USE_FStream 1) SET(KWSYS_USE_String 1) SET(KWSYS_USE_SystemInformation 1) SET(KWSYS_USE_CPU 1) @@ -133,18 +135,32 @@ ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # Enforce component dependencies. IF(KWSYS_USE_SystemTools) SET(KWSYS_USE_Directory 1) + SET(KWSYS_USE_FStream 1) + SET(KWSYS_USE_Encoding 1) ENDIF(KWSYS_USE_SystemTools) IF(KWSYS_USE_Glob) SET(KWSYS_USE_Directory 1) SET(KWSYS_USE_SystemTools 1) SET(KWSYS_USE_RegularExpression 1) + SET(KWSYS_USE_FStream 1) + SET(KWSYS_USE_Encoding 1) ENDIF(KWSYS_USE_Glob) IF(KWSYS_USE_Process) SET(KWSYS_USE_System 1) + SET(KWSYS_USE_Encoding 1) ENDIF(KWSYS_USE_Process) IF(KWSYS_USE_SystemInformation) SET(KWSYS_USE_Process 1) ENDIF(KWSYS_USE_SystemInformation) +IF(KWSYS_USE_System) + SET(KWSYS_USE_Encoding 1) +ENDIF(KWSYS_USE_System) +IF(KWSYS_USE_Directory) + SET(KWSYS_USE_Encoding 1) +ENDIF(KWSYS_USE_Directory) +IF(KWSYS_USE_FStream) + SET(KWSYS_USE_Encoding 1) +ENDIF(KWSYS_USE_FStream) # Setup the large file support default. IF(KWSYS_LFS_DISABLE) @@ -153,6 +169,11 @@ ELSE(KWSYS_LFS_DISABLE) SET(KWSYS_LFS_REQUESTED 1) ENDIF(KWSYS_LFS_DISABLE) +# Specify default 8 bit encoding for Windows +IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) + SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP) +ENDIF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) + # Enable testing if building standalone. IF(KWSYS_STANDALONE) INCLUDE(Dart) @@ -509,6 +530,12 @@ IF(KWSYS_USE_FundamentalType) "Checking whether char is signed" DIRECT) ENDIF(KWSYS_USE_FundamentalType) +IF(KWSYS_USE_Encoding) + # Look for type size helper macros. + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING + "Checking whether wstring is available" DIRECT) +ENDIF(KWSYS_USE_Encoding) + IF(KWSYS_USE_IOStream) # Determine whether iostreams support long long. SET(KWSYS_PLATFORM_CXX_TEST_DEFINES @@ -864,8 +891,8 @@ SET(KWSYS_HXX_FILES Configure String # Add selected C++ classes. SET(cppclasses - Directory DynamicLoader Glob RegularExpression SystemTools - CommandLineArguments IOStream SystemInformation + Directory DynamicLoader Encoding Glob RegularExpression SystemTools + CommandLineArguments IOStream FStream SystemInformation ) FOREACH(cpp ${cppclasses}) IF(KWSYS_USE_${cpp}) @@ -881,7 +908,7 @@ ENDFOREACH(cpp) # Add selected C components. FOREACH(c - Process Base64 FundamentalType MD5 Terminal System String CPU + Process Base64 Encoding FundamentalType MD5 Terminal System String CPU ) IF(KWSYS_USE_${c}) # Use the corresponding header file. @@ -912,16 +939,24 @@ IF(KWSYS_USE_Process) ENDIF(KWSYS_USE_Process) # Add selected C sources. -FOREACH(c Base64 MD5 Terminal System String) +FOREACH(c Base64 Encoding MD5 Terminal System String) IF(KWSYS_USE_${c}) - SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${c}.c) + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c) + LIST(APPEND KWSYS_C_SRCS ${c}C.c) + ELSE() + LIST(APPEND KWSYS_C_SRCS ${c}.c) + ENDIF() ENDIF(KWSYS_USE_${c}) ENDFOREACH(c) # Configure headers of C++ classes and construct the list of sources. FOREACH(c ${KWSYS_CLASSES}) # Add this source to the list of source files for the library. - SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${c}.cxx) + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx) + LIST(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx) + ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}.cxx) + LIST(APPEND KWSYS_CXX_SRCS ${c}.cxx) + ENDIF() # Configure the header for this class. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx @@ -1047,6 +1082,12 @@ IF(KWSYS_USE_String) COMPILE_FLAGS "-DKWSYS_STRING_C") ENDIF(KWSYS_USE_String) +IF(KWSYS_USE_Encoding) + # Set default 8 bit encoding in "EndcodingC.c". + SET_PROPERTY(SOURCE EncodingC.c APPEND PROPERTY COMPILE_DEFINITIONS + KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) +ENDIF(KWSYS_USE_Encoding) + #----------------------------------------------------------------------------- # Setup testing if not being built as part of another project. IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) @@ -1090,6 +1131,11 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) testCommandLineArguments testCommandLineArguments1 ) + IF(KWSYS_STL_HAS_WSTRING) + SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} + testEncoding + ) + ENDIF(KWSYS_STL_HAS_WSTRING) IF(KWSYS_USE_SystemInformation) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation) ENDIF(KWSYS_USE_SystemInformation) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 716b84f..8f5ace2 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -36,6 +36,9 @@ /* Whether STL is in std namespace. */ #define @KWSYS_NAMESPACE@_STL_HAVE_STD @KWSYS_STL_HAVE_STD@ +/* Whether wstring is available. */ +#define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@ + /* Whether the STL string has operator<< for ostream. */ #define @KWSYS_NAMESPACE@_STL_STRING_HAVE_OSTREAM @KWSYS_STL_STRING_HAVE_OSTREAM@ @@ -170,6 +173,7 @@ # define KWSYS_STL_HAS_ALLOCATOR_TEMPLATE @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_TEMPLATE # define KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE # define KWSYS_STL_HAS_ALLOCATOR_OBJECTS @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_OBJECTS +# define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING #endif #endif diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx index b884747..d54e607 100644 --- a/Source/kwsys/Directory.cxx +++ b/Source/kwsys/Directory.cxx @@ -14,6 +14,8 @@ #include KWSYS_HEADER(Configure.hxx) +#include KWSYS_HEADER(Encoding.hxx) + #include KWSYS_HEADER(stl/string) #include KWSYS_HEADER(stl/vector) @@ -22,6 +24,7 @@ #if 0 # include "Directory.hxx.in" # include "Configure.hxx.in" +# include "Encoding.hxx.in" # include "kwsys_stl.hxx.in" # include "kwsys_stl_string.hxx.in" # include "kwsys_stl_vector.hxx.in" @@ -120,10 +123,10 @@ bool Directory::Load(const char* name) buf = new char[n + 2 + 1]; sprintf(buf, "%s/*", name); } - struct _finddata_t data; // data of current file + struct _wfinddata_t data; // data of current file // Now put them into the file array - srchHandle = _findfirst(buf, &data); + srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data); delete [] buf; if ( srchHandle == -1 ) @@ -134,9 +137,9 @@ bool Directory::Load(const char* name) // Loop through names do { - this->Internal->Files.push_back(data.name); + this->Internal->Files.push_back(Encoding::ToNarrow(data.name)); } - while ( _findnext(srchHandle, &data) != -1 ); + while ( _wfindnext(srchHandle, &data) != -1 ); this->Internal->Path = name; return _findclose(srchHandle) != -1; } @@ -160,10 +163,10 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const char* name) buf = new char[n + 2 + 1]; sprintf(buf, "%s/*", name); } - struct _finddata_t data; // data of current file + struct _wfinddata_t data; // data of current file // Now put them into the file array - srchHandle = _findfirst(buf, &data); + srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data); delete [] buf; if ( srchHandle == -1 ) @@ -177,7 +180,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const char* name) { count++; } - while ( _findnext(srchHandle, &data) != -1 ); + while ( _wfindnext(srchHandle, &data) != -1 ); _findclose(srchHandle); return count; } diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index fd83752..44cf6af 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -186,13 +186,12 @@ namespace KWSYS_NAMESPACE DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname) { DynamicLoader::LibraryHandle lh; -#ifdef UNICODE - wchar_t libn[MB_CUR_MAX]; - mbstowcs(libn, libname, MB_CUR_MAX); - lh = LoadLibrary(libn); -#else - lh = LoadLibrary(libname); -#endif + int length = MultiByteToWideChar(CP_UTF8, 0, libname, -1, NULL, 0); + wchar_t* wchars = new wchar_t[length+1]; + wchars[0] = '\0'; + MultiByteToWideChar(CP_UTF8, 0, libname, -1, wchars, length); + lh = LoadLibraryW(wchars); + delete [] wchars; return lh; } @@ -238,13 +237,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( #else const char *rsym = sym; #endif -#ifdef UNICODE - wchar_t wsym[MB_CUR_MAX]; - mbstowcs(wsym, rsym, MB_CUR_MAX); - result = GetProcAddress(lib, wsym); -#else result = (void*)GetProcAddress(lib, rsym); -#endif #if defined(__BORLANDC__) || defined(__WATCOMC__) delete[] rsym; #endif diff --git a/Source/kwsys/Encoding.h.in b/Source/kwsys/Encoding.h.in new file mode 100644 index 0000000..591c5a8 --- /dev/null +++ b/Source/kwsys/Encoding.h.in @@ -0,0 +1,79 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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 @KWSYS_NAMESPACE@_Encoding_h +#define @KWSYS_NAMESPACE@_Encoding_h + +#include <@KWSYS_NAMESPACE@/Configure.h> +#include <wchar.h> + +/* Redefine all public interface symbol names to be in the proper + namespace. These macros are used internally to kwsys only, and are + not visible to user code. Use kwsysHeaderDump.pl to reproduce + these macros after making changes to the interface. */ +#if !defined(KWSYS_NAMESPACE) +# define kwsys_ns(x) @KWSYS_NAMESPACE@##x +# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT +#endif +#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define kwsysEncoding kwsys_ns(Encoding) +# define kwsysEncoding_mbstowcs kwsys_ns(Encoding_mbstowcs) +# define kwsysEncoding_DupToWide kwsys_ns(Encoding_DupToWide) +# define kwsysEncoding_wcstombs kwsys_ns(Encoding_wcstombs) +# define kwsysEncoding_DupToNarrow kwsys_ns(Encoding_DupToNarrow) +#endif + +#if defined(__cplusplus) +extern "C" +{ +#endif + + +/* Convert a narrow string to a wide string. + On Windows, UTF-8 is assumed, and on other platforms, + the current locale is assumed. + */ +kwsysEXPORT size_t kwsysEncoding_mbstowcs(wchar_t* dest, const char* src, size_t n); + +/* Convert a narrow string to a wide string. + This can return NULL if the conversion fails. */ +kwsysEXPORT wchar_t* kwsysEncoding_DupToWide(const char* src); + + +/* Convert a wide string to a narrow string. + On Windows, UTF-8 is assumed, and on other platforms, + the current locale is assumed. */ +kwsysEXPORT size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* src, size_t n); + +/* Convert a wide string to a narrow string. + This can return NULL if the conversion fails. */ +kwsysEXPORT char* kwsysEncoding_DupToNarrow(const wchar_t* str); + + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +/* If we are building a kwsys .c or .cxx file, let it use these macros. + Otherwise, undefine them to keep the namespace clean. */ +#if !defined(KWSYS_NAMESPACE) +# undef kwsys_ns +# undef kwsysEXPORT +# if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# undef kwsysEncoding +# undef kwsysEncoding_mbstowcs +# undef kwsysEncoding_DupToWide +# undef kwsysEncoding_wcstombs +# undef kwsysEncoding_DupToNarrow +# endif +#endif + +#endif diff --git a/Source/kwsys/Encoding.hxx.in b/Source/kwsys/Encoding.hxx.in new file mode 100644 index 0000000..60a4a8e --- /dev/null +++ b/Source/kwsys/Encoding.hxx.in @@ -0,0 +1,56 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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 @KWSYS_NAMESPACE@_Encoding_hxx +#define @KWSYS_NAMESPACE@_Encoding_hxx + +#include <@KWSYS_NAMESPACE@/Configure.hxx> +#include <@KWSYS_NAMESPACE@/stl/string> + +/* Define these macros temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define kwsys_stl @KWSYS_NAMESPACE@_stl +#endif + +namespace @KWSYS_NAMESPACE@ +{ +class @KWSYS_NAMESPACE@_EXPORT Encoding +{ +public: + /** + * Convert between char and wchar_t + */ + +#if @KWSYS_NAMESPACE@_STL_HAS_WSTRING + + // Convert a narrow string to a wide string. + // On Windows, UTF-8 is assumed, and on other platforms, + // the current locale is assumed. + static kwsys_stl::wstring ToWide(const kwsys_stl::string& str); + static kwsys_stl::wstring ToWide(const char* str); + + // Convert a wide string to a narrow string. + // On Windows, UTF-8 is assumed, and on other platforms, + // the current locale is assumed. + static kwsys_stl::string ToNarrow(const kwsys_stl::wstring& str); + static kwsys_stl::string ToNarrow(const wchar_t* str); + +#endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING + +}; // class Encoding +} // namespace @KWSYS_NAMESPACE@ + +/* Undefine temporary macros. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# undef kwsys_stl +#endif + +#endif diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c new file mode 100644 index 0000000..a36eecc --- /dev/null +++ b/Source/kwsys/EncodingC.c @@ -0,0 +1,79 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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 "kwsysPrivate.h" +#include KWSYS_HEADER(Encoding.h) + +/* Work-around CMake dependency scanning limitation. This must + duplicate the above list of headers. */ +#if 0 +# include "Encoding.h.in" +#endif + +#include <stdlib.h> + +#ifdef _WIN32 +#include <windows.h> +#endif + +size_t kwsysEncoding_mbstowcs(wchar_t* dest, const char* str, size_t n) +{ + if(str == 0) + { + return (size_t)-1; + } +#ifdef _WIN32 + return MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, + str, -1, dest, (int)n) - 1; +#else + return mbstowcs(dest, str, n); +#endif +} + +wchar_t* kwsysEncoding_DupToWide(const char* str) +{ + wchar_t* ret = NULL; + size_t length = kwsysEncoding_mbstowcs(NULL, str, 0) + 1; + if(length > 0) + { + ret = malloc((length)*sizeof(wchar_t)); + ret[0] = 0; + kwsysEncoding_mbstowcs(ret, str, length); + } + return ret; +} + +size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* str, size_t n) +{ + if(str == 0) + { + return (size_t)-1; + } +#ifdef _WIN32 + return WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str, -1, + dest, (int)n, NULL, NULL) - 1; +#else + return wcstombs(dest, str, n); +#endif +} + +char* kwsysEncoding_DupToNarrow(const wchar_t* str) +{ + char* ret = NULL; + size_t length = kwsysEncoding_wcstombs(0, str, 0); + if(length > 0) + { + ret = malloc(length); + ret[0] = 0; + kwsysEncoding_wcstombs(ret, str, length); + } + return ret; +} diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx new file mode 100644 index 0000000..aebc148 --- /dev/null +++ b/Source/kwsys/EncodingCXX.cxx @@ -0,0 +1,88 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ + +#ifdef __osf__ +# define _OSF_SOURCE +# define _POSIX_C_SOURCE 199506L +# define _XOPEN_SOURCE_EXTENDED +#endif + +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Encoding.hxx) +#include KWSYS_HEADER(Encoding.h) +#include KWSYS_HEADER(stl/vector) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Encoding.hxx.in" +# include "Encoding.h.in" +#endif + +#include <stdlib.h> + +#ifdef _MSC_VER +# pragma warning (disable: 4786) +#endif + +// Windows API. +#if defined(_WIN32) +# include <windows.h> +#endif + +namespace KWSYS_NAMESPACE +{ + +#if KWSYS_STL_HAS_WSTRING + +kwsys_stl::wstring Encoding::ToWide(const kwsys_stl::string& str) +{ + return ToWide(str.c_str()); +} + +kwsys_stl::string Encoding::ToNarrow(const kwsys_stl::wstring& str) +{ + return ToNarrow(str.c_str()); +} + +kwsys_stl::wstring Encoding::ToWide(const char* cstr) +{ + kwsys_stl::wstring wstr; + size_t length = kwsysEncoding_mbstowcs(0, cstr, 0) + 1; + if(length > 0) + { + kwsys_stl::vector<wchar_t> wchars(length); + if(kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) + { + wstr = &wchars[0]; + } + } + return wstr; +} + +kwsys_stl::string Encoding::ToNarrow(const wchar_t* wcstr) +{ + kwsys_stl::string str; + size_t length = kwsysEncoding_wcstombs(0, wcstr, 0) + 1; + if(length > 0) + { + std::vector<char> chars(length); + if(kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) + { + str = &chars[0]; + } + } + return str; +} +#endif // KWSYS_STL_HAS_WSTRING + +} // namespace KWSYS_NAMESPACE diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in new file mode 100644 index 0000000..8170fb3 --- /dev/null +++ b/Source/kwsys/FStream.hxx.in @@ -0,0 +1,172 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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 @KWSYS_NAMESPACE@_FStream_hxx +#define @KWSYS_NAMESPACE@_FStream_hxx + +#include <@KWSYS_NAMESPACE@/ios/fstream> +#include <@KWSYS_NAMESPACE@/Encoding.hxx> + +namespace @KWSYS_NAMESPACE@ +{ +#if defined(_MSC_VER) && _MSC_VER >= 1400 + template<typename CharType,typename Traits> + class basic_filebuf : public std::basic_filebuf<CharType,Traits> + { + public: + typedef std::basic_filebuf<CharType,Traits> my_base_type; + basic_filebuf *open(char const *s,std::ios_base::openmode mode) + { + my_base_type::open(Encoding::ToWide(s).c_str(), mode); + return this; + } + }; + + template<typename CharType,typename Traits = std::char_traits<CharType> > + class basic_ifstream : public std::basic_istream<CharType,Traits> + { + public: + typedef basic_filebuf<CharType,Traits> internal_buffer_type; + typedef std::basic_istream<CharType,Traits> internal_stream_type; + + basic_ifstream() : internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + } + explicit basic_ifstream(char const *file_name, + std::ios_base::openmode mode = std::ios_base::in) + : internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + open(file_name,mode); + } + void open(char const *file_name,std::ios_base::openmode mode = std::ios_base::in) + { + if(!buf_->open(file_name,mode | std::ios_base::in)) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + bool is_open() + { + return buf_->is_open(); + } + bool is_open() const + { + return buf_->is_open(); + } + void close() + { + if(!buf_->close()) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + + internal_buffer_type *rdbuf() const + { + return buf_.get(); + } + + ~basic_ifstream() + { + buf_->close(); + delete buf_; + } + + private: + internal_buffer_type* buf_; +}; + +template<typename CharType,typename Traits = std::char_traits<CharType> > +class basic_ofstream : public std::basic_ostream<CharType,Traits> +{ + public: + typedef basic_filebuf<CharType,Traits> internal_buffer_type; + typedef std::basic_ostream<CharType,Traits> internal_stream_type; + + basic_ofstream() : internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + } + explicit basic_ofstream(char const *file_name,std::ios_base::openmode mode = std::ios_base::out) : + internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + open(file_name,mode); + } + void open(char const *file_name,std::ios_base::openmode mode = std::ios_base::out) + { + if(!buf_->open(file_name,mode | std::ios_base::out)) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + bool is_open() + { + return buf_->is_open(); + } + bool is_open() const + { + return buf_->is_open(); + } + void close() + { + if(!buf_->close()) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + + internal_buffer_type *rdbuf() const + { + return buf_.get(); + } + ~basic_ofstream() + { + buf_->close(); + delete buf_; + } + + private: + internal_buffer_type* buf_; +}; + + typedef basic_ifstream<char> ifstream; + typedef basic_ofstream<char> ofstream; + +#else + using @KWSYS_NAMESPACE@_ios_namespace::basic_filebuf; + using @KWSYS_NAMESPACE@_ios_namespace::ofstream; + using @KWSYS_NAMESPACE@_ios_namespace::ifstream; +#endif + +} + + + +#endif diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index c836f9b..c8ec754 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -12,12 +12,14 @@ #include "kwsysPrivate.h" #include KWSYS_HEADER(Process.h) #include KWSYS_HEADER(System.h) +#include KWSYS_HEADER(Encoding.h) /* Work-around CMake dependency scanning limitation. This must duplicate the above list of headers. */ #if 0 # include "Process.h.in" # include "System.h.in" +# include "Encoding_c.h.in" #endif /* @@ -88,9 +90,10 @@ typedef LARGE_INTEGER kwsysProcessTime; typedef struct kwsysProcessCreateInformation_s { /* Windows child startup control data. */ - STARTUPINFO StartupInfo; + STARTUPINFOW StartupInfo; } kwsysProcessCreateInformation; + /*--------------------------------------------------------------------------*/ typedef struct kwsysProcessPipeData_s kwsysProcessPipeData; static DWORD WINAPI kwsysProcessPipeThreadRead(LPVOID ptd); @@ -197,14 +200,14 @@ struct kwsysProcess_s int State; /* The command lines to execute. */ - char** Commands; + wchar_t** Commands; int NumberOfCommands; /* The exit code of each command. */ DWORD* CommandExitCodes; /* The working directory for the child process. */ - char* WorkingDirectory; + wchar_t* WorkingDirectory; /* Whether to create the child as a detached process. */ int OptionDetach; @@ -299,7 +302,7 @@ struct kwsysProcess_s /* Real working directory of our own process. */ DWORD RealWorkingDirectoryLength; - char* RealWorkingDirectory; + wchar_t* RealWorkingDirectory; }; /*--------------------------------------------------------------------------*/ @@ -546,7 +549,7 @@ int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command) int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) { int newNumberOfCommands; - char** newCommands; + wchar_t** newCommands; /* Make sure we have a command to add. */ if(!cp || !command || !*command) @@ -554,9 +557,10 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) return 0; } + /* Allocate a new array for command pointers. */ newNumberOfCommands = cp->NumberOfCommands + 1; - if(!(newCommands = (char**)malloc(sizeof(char*) * newNumberOfCommands))) + if(!(newCommands = (wchar_t**)malloc(sizeof(wchar_t*) * newNumberOfCommands))) { /* Out of memory. */ return 0; @@ -585,8 +589,8 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) /* Allocate enough space for the command. We do not need an extra byte for the terminating null because we allocated a space for the first argument that we will not use. */ - newCommands[cp->NumberOfCommands] = (char*)malloc(length); - if(!newCommands[cp->NumberOfCommands]) + char* new_cmd = malloc(length); + if(!new_cmd) { /* Out of memory. */ free(newCommands); @@ -595,9 +599,13 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) /* Construct the command line in the allocated buffer. */ kwsysProcessComputeCommandLine(cp, command, - newCommands[cp->NumberOfCommands]); + new_cmd); + + newCommands[cp->NumberOfCommands] = kwsysEncoding_DupToWide(new_cmd); + free(new_cmd); } + /* Save the new array of commands. */ free(cp->Commands); cp->Commands = newCommands; @@ -633,22 +641,26 @@ int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir) } if(dir && dir[0]) { + wchar_t* wdir = kwsysEncoding_DupToWide(dir); /* We must convert the working directory to a full path. */ - DWORD length = GetFullPathName(dir, 0, 0, 0); + DWORD length = GetFullPathNameW(wdir, 0, 0, 0); if(length > 0) { - cp->WorkingDirectory = (char*)malloc(length); - if(!cp->WorkingDirectory) + wchar_t* work_dir = malloc(length*sizeof(wchar_t)); + if(!work_dir) { + free(wdir); return 0; } - if(!GetFullPathName(dir, length, cp->WorkingDirectory, 0)) + if(!GetFullPathNameW(wdir, length, work_dir, 0)) { - free(cp->WorkingDirectory); - cp->WorkingDirectory = 0; + free(work_dir); + free(wdir); return 0; } + cp->WorkingDirectory = work_dir; } + free(wdir); } return 1; } @@ -879,13 +891,13 @@ void kwsysProcess_Execute(kwsysProcess* cp) to make pipe file paths evaluate correctly. */ if(cp->WorkingDirectory) { - if(!GetCurrentDirectory(cp->RealWorkingDirectoryLength, + if(!GetCurrentDirectoryW(cp->RealWorkingDirectoryLength, cp->RealWorkingDirectory)) { kwsysProcessCleanup(cp, 1); return; } - SetCurrentDirectory(cp->WorkingDirectory); + SetCurrentDirectoryW(cp->WorkingDirectory); } /* Initialize startup info data. */ @@ -1003,7 +1015,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) /* Restore the working directory. */ if(cp->RealWorkingDirectory) { - SetCurrentDirectory(cp->RealWorkingDirectory); + SetCurrentDirectoryW(cp->RealWorkingDirectory); free(cp->RealWorkingDirectory); cp->RealWorkingDirectory = 0; } @@ -1507,10 +1519,10 @@ int kwsysProcessInitialize(kwsysProcess* cp) /* Allocate space to save the real working directory of this process. */ if(cp->WorkingDirectory) { - cp->RealWorkingDirectoryLength = GetCurrentDirectory(0, 0); + cp->RealWorkingDirectoryLength = GetCurrentDirectoryW(0, 0); if(cp->RealWorkingDirectoryLength > 0) { - cp->RealWorkingDirectory = (char*)malloc(cp->RealWorkingDirectoryLength); + cp->RealWorkingDirectory = malloc(cp->RealWorkingDirectoryLength * sizeof(wchar_t)); if(!cp->RealWorkingDirectory) { return 0; @@ -1547,9 +1559,11 @@ int kwsysProcessCreate(kwsysProcess* cp, int index, else if(cp->PipeFileSTDIN) { /* Create a handle to read a file for stdin. */ - HANDLE fin = CreateFile(cp->PipeFileSTDIN, GENERIC_READ|GENERIC_WRITE, + wchar_t* wstdin = kwsysEncoding_DupToWide(cp->PipeFileSTDIN); + HANDLE fin = CreateFileW(wstdin, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); + free(wstdin); if(fin == INVALID_HANDLE_VALUE) { return 0; @@ -1655,7 +1669,7 @@ int kwsysProcessCreate(kwsysProcess* cp, int index, /* Create the child in a suspended state so we can wait until all children have been created before running any one. */ - if(!CreateProcess(0, cp->Commands[index], 0, 0, TRUE, CREATE_SUSPENDED, 0, + if(!CreateProcessW(0, cp->Commands[index], 0, 0, TRUE, CREATE_SUSPENDED, 0, 0, &si->StartupInfo, &cp->ProcessInformation[index])) { return 0; @@ -1729,6 +1743,7 @@ void kwsysProcessDestroy(kwsysProcess* cp, int event) int kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name) { HANDLE fout; + wchar_t* wname; if(!name) { return 1; @@ -1738,8 +1753,10 @@ int kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name) kwsysProcessCleanupHandle(phandle); /* Create a handle to write a file for the pipe. */ - fout = CreateFile(name, GENERIC_WRITE, FILE_SHARE_READ, 0, + wname = kwsysEncoding_DupToWide(name); + fout = CreateFileW(wname, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0); + free(wname); if(fout == INVALID_HANDLE_VALUE) { return 0; @@ -1883,10 +1900,13 @@ void kwsysProcessCleanup(kwsysProcess* cp, int error) { /* Format the error message. */ DWORD original = GetLastError(); - DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + wchar_t err_msg[KWSYSPE_PIPE_BUFFER_SIZE]; + DWORD length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - cp->ErrorMessage, KWSYSPE_PIPE_BUFFER_SIZE, 0); + err_msg, KWSYSPE_PIPE_BUFFER_SIZE, 0); + WideCharToMultiByte(CP_UTF8, 0, err_msg, -1, cp->ErrorMessage, + KWSYSPE_PIPE_BUFFER_SIZE, NULL, NULL); if(length < 1) { /* FormatMessage failed. Use a default message. */ @@ -1924,7 +1944,7 @@ void kwsysProcessCleanup(kwsysProcess* cp, int error) /* Restore the working directory. */ if(cp->RealWorkingDirectory) { - SetCurrentDirectory(cp->RealWorkingDirectory); + SetCurrentDirectoryW(cp->RealWorkingDirectory); } } @@ -2222,7 +2242,7 @@ static void kwsysProcessSetExitException(kwsysProcess* cp, int code) case STATUS_NO_MEMORY: default: cp->ExitException = kwsysProcess_Exception_Other; - sprintf(cp->ExitExceptionString, "Exit code 0x%x\n", code); + _snprintf(cp->ExitExceptionString, KWSYSPE_PIPE_BUFFER_SIZE, "Exit code 0x%x\n", code); break; } } @@ -2430,7 +2450,7 @@ static int kwsysProcess_List__New_NT4(kwsysProcess_List* self) loaded in this program. This does not actually increment the reference count to the module so we do not need to close the handle. */ - HMODULE hNT = GetModuleHandle("ntdll.dll"); + HMODULE hNT = GetModuleHandleW(L"ntdll.dll"); if(hNT) { /* Get pointers to the needed API functions. */ @@ -2534,7 +2554,7 @@ static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self) loaded in this program. This does not actually increment the reference count to the module so we do not need to close the handle. */ - HMODULE hKernel = GetModuleHandle("kernel32.dll"); + HMODULE hKernel = GetModuleHandleW(L"kernel32.dll"); if(hKernel) { self->P_CreateToolhelp32Snapshot = diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 2672730..2f6c949 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -253,7 +253,7 @@ static bool call_cpuid(int select, int result[4]) _asm { #ifdef CPUID_AWARE_COMPILER ; we must push/pop the registers <<CPUID>> writes to, as the - ; optimiser doesn't know about <<CPUID>>, and so doesn't expect + ; optimiser does not know about <<CPUID>>, and so does not expect ; these registers to change. push eax push ebx @@ -2454,8 +2454,8 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() if (!retrieved) { HKEY hKey = NULL; - LONG err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, + LONG err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &hKey); if (ERROR_SUCCESS == err) @@ -2464,7 +2464,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() DWORD data = 0; DWORD dwSize = sizeof(DWORD); - err = RegQueryValueEx(hKey, "~MHz", 0, + err = RegQueryValueExW(hKey, L"~MHz", 0, &dwType, (LPBYTE) &data, &dwSize); if (ERROR_SUCCESS == err) @@ -5017,19 +5017,19 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSName = "Windows"; - OSVERSIONINFOEX osvi; + OSVERSIONINFOEXW osvi; BOOL bIsWindows64Bit; BOOL bOsVersionInfoEx; char operatingSystem[256]; // Try calling GetVersionEx using the OSVERSIONINFOEX structure. - ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); - bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi); + ZeroMemory (&osvi, sizeof (OSVERSIONINFOEXW)); + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW); + bOsVersionInfoEx = GetVersionExW ((OSVERSIONINFOW*)&osvi); if (!bOsVersionInfoEx) { - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - if (!GetVersionEx ((OSVERSIONINFO *) &osvi)) + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOW); + if (!GetVersionExW((OSVERSIONINFOW*)&osvi)) { return false; } @@ -5115,19 +5115,19 @@ bool SystemInformationImplementation::QueryOSInformation() #endif // VER_NT_WORKSTATION { HKEY hKey; - char szProductType[80]; + wchar_t szProductType[80]; DWORD dwBufLen; // Query the registry to retrieve information. - RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey); - RegQueryValueEx (hKey, "ProductType", NULL, NULL, (LPBYTE) szProductType, &dwBufLen); + RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey); + RegQueryValueExW(hKey, L"ProductType", NULL, NULL, (LPBYTE) szProductType, &dwBufLen); RegCloseKey (hKey); - if (lstrcmpi ("WINNT", szProductType) == 0) + if (lstrcmpiW(L"WINNT", szProductType) == 0) { this->OSRelease += " Professional"; } - if (lstrcmpi ("LANMANNT", szProductType) == 0) + if (lstrcmpiW(L"LANMANNT", szProductType) == 0) { // Decide between Windows 2000 Advanced Server and Windows .NET Enterprise Server. if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) @@ -5139,7 +5139,7 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSRelease += " Server"; } } - if (lstrcmpi ("SERVERNT", szProductType) == 0) + if (lstrcmpiW(L"SERVERNT", szProductType) == 0) { // Decide between Windows 2000 Advanced Server and Windows .NET Enterprise Server. if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) @@ -5172,7 +5172,7 @@ bool SystemInformationImplementation::QueryOSInformation() LPFNPROC DLLProc; // Load the Kernel32 DLL. - hKernelDLL = LoadLibrary ("kernel32"); + hKernelDLL = LoadLibraryW(L"kernel32"); if (hKernelDLL != NULL) { // Only XP and .NET Server support IsWOW64Process so... Load dynamically! DLLProc = (LPFNPROC) GetProcAddress (hKernelDLL, "IsWow64Process"); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 749002d..4649f3b 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -20,6 +20,8 @@ #include KWSYS_HEADER(RegularExpression.hxx) #include KWSYS_HEADER(SystemTools.hxx) #include KWSYS_HEADER(Directory.hxx) +#include KWSYS_HEADER(FStream.hxx) +#include KWSYS_HEADER(Encoding.hxx) #include KWSYS_HEADER(ios/iostream) #include KWSYS_HEADER(ios/fstream) @@ -32,6 +34,8 @@ #if 0 # include "SystemTools.hxx.in" # include "Directory.hxx.in" +# include "FStream.hxx.in" +# include "Encoding.hxx.in" # include "kwsys_ios_iostream.h.in" # include "kwsys_ios_fstream.h.in" # include "kwsys_ios_sstream.h.in" @@ -75,6 +79,9 @@ // Windows API. #if defined(_WIN32) # include <windows.h> +# ifndef INVALID_FILE_ATTRIBUTES +# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +# endif #elif defined (__CYGWIN__) # include <windows.h> # undef _WIN32 @@ -183,22 +190,25 @@ static inline char *realpath(const char *path, char *resolved_path) #if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) inline int Mkdir(const char* dir) { - return _mkdir(dir); + return _wmkdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); } inline int Rmdir(const char* dir) { - return _rmdir(dir); + return _wrmdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); } inline const char* Getcwd(char* buf, unsigned int len) { - if(const char* ret = _getcwd(buf, len)) + std::vector<wchar_t> w_buf(len); + if(const wchar_t* ret = _wgetcwd(&w_buf[0], len)) { // make sure the drive letter is capital - if(strlen(buf) > 1 && buf[1] == ':') + if(wcslen(&w_buf[0]) > 1 && w_buf[1] == L':') { - buf[0] = toupper(buf[0]); + w_buf[0] = towupper(w_buf[0]); } - return ret; + std::string tmp = KWSYS_NAMESPACE::Encoding::ToNarrow(&w_buf[0]); + strcpy(buf, tmp.c_str()); + return buf; } return 0; } @@ -207,16 +217,18 @@ inline int Chdir(const char* dir) #if defined(__BORLANDC__) return chdir(dir); #else - return _chdir(dir); + return _wchdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); #endif } inline void Realpath(const char *path, kwsys_stl::string & resolved_path) { - char *ptemp; - char fullpath[MAX_PATH]; - if( GetFullPathName(path, sizeof(fullpath), fullpath, &ptemp) ) + kwsys_stl::wstring tmp = KWSYS_NAMESPACE::Encoding::ToWide(path); + wchar_t *ptemp; + wchar_t fullpath[MAX_PATH]; + if( GetFullPathNameW(tmp.c_str(), sizeof(fullpath)/sizeof(fullpath[0]), + fullpath, &ptemp) ) { - resolved_path = fullpath; + resolved_path = KWSYS_NAMESPACE::Encoding::ToNarrow(fullpath); KWSYS_NAMESPACE::SystemTools::ConvertToUnixSlashes(resolved_path); } else @@ -591,6 +603,15 @@ const char* SystemTools::GetExecutableExtension() #endif } +FILE* SystemTools::Fopen(const char* file, const char* mode) +{ +#ifdef _WIN32 + return _wfopen(Encoding::ToWide(file).c_str(), + Encoding::ToWide(mode).c_str()); +#else + return fopen(file, mode); +#endif +} bool SystemTools::MakeDirectory(const char* path) { @@ -740,7 +761,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, SystemTools::KeyWOW64 view) { // only add the modes when on a system that supports Wow64. - static FARPROC wow64p = GetProcAddress(GetModuleHandle("kernel32"), + static FARPROC wow64p = GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process"); if(wow64p == NULL) { @@ -774,8 +795,8 @@ SystemTools::GetRegistrySubKeys(const char *key, } HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), + if(RegOpenKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) @@ -784,13 +805,13 @@ SystemTools::GetRegistrySubKeys(const char *key, } else { - char name[1024]; + wchar_t name[1024]; DWORD dwNameSize = sizeof(name)/sizeof(name[0]); DWORD i = 0; - while (RegEnumKey(hKey, i, name, dwNameSize) == ERROR_SUCCESS) + while (RegEnumKeyW(hKey, i, name, dwNameSize) == ERROR_SUCCESS) { - subkeys.push_back(name); + subkeys.push_back(Encoding::ToNarrow(name)); ++i; } @@ -829,8 +850,8 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, } HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), + if(RegOpenKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) @@ -841,9 +862,9 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, { DWORD dwType, dwSize; dwSize = 1023; - char data[1024]; - if(RegQueryValueEx(hKey, - (LPTSTR)valuename.c_str(), + wchar_t data[1024]; + if(RegQueryValueExW(hKey, + Encoding::ToWide(valuename).c_str(), NULL, &dwType, (BYTE *)data, @@ -851,16 +872,17 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, { if (dwType == REG_SZ) { - value = data; + value = Encoding::ToNarrow(data); valueset = true; } else if (dwType == REG_EXPAND_SZ) { - char expanded[1024]; + wchar_t expanded[1024]; DWORD dwExpandedSize = sizeof(expanded)/sizeof(expanded[0]); - if(ExpandEnvironmentStrings(data, expanded, dwExpandedSize)) + if(ExpandEnvironmentStringsW(data, expanded, + dwExpandedSize)) { - value = expanded; + value = Encoding::ToNarrow(expanded); valueset = true; } } @@ -901,9 +923,9 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, HKEY hKey; DWORD dwDummy; - char lpClass[] = ""; - if(RegCreateKeyEx(primaryKey, - second.c_str(), + wchar_t lpClass[] = L""; + if(RegCreateKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, @@ -915,12 +937,13 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, return false; } - if(RegSetValueEx(hKey, - (LPTSTR)valuename.c_str(), + std::wstring wvalue = Encoding::ToWide(value); + if(RegSetValueExW(hKey, + Encoding::ToWide(valuename).c_str(), 0, REG_SZ, - (CONST BYTE *)value, - (DWORD)(strlen(value) + 1)) == ERROR_SUCCESS) + (CONST BYTE *)wvalue.c_str(), + (DWORD)(sizeof(wchar_t) * (wvalue.size() + 1))) == ERROR_SUCCESS) { return true; } @@ -952,8 +975,8 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) } HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), + if(RegOpenKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, SystemToolsMakeRegistryMode(KEY_WRITE, view), &hKey) != ERROR_SUCCESS) @@ -983,7 +1006,7 @@ bool SystemTools::SameFile(const char* file1, const char* file2) #ifdef _WIN32 HANDLE hFile1, hFile2; - hFile1 = CreateFile( file1, + hFile1 = CreateFileW( Encoding::ToWide(file1).c_str(), GENERIC_READ, FILE_SHARE_READ , NULL, @@ -991,7 +1014,7 @@ bool SystemTools::SameFile(const char* file1, const char* file2) FILE_FLAG_BACKUP_SEMANTICS, NULL ); - hFile2 = CreateFile( file2, + hFile2 = CreateFileW( Encoding::ToWide(file2).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, @@ -1040,15 +1063,6 @@ bool SystemTools::SameFile(const char* file1, const char* file2) } //---------------------------------------------------------------------------- -#if defined(_WIN32) || defined(__CYGWIN__) -static bool WindowsFileExists(const char* filename) -{ - WIN32_FILE_ATTRIBUTE_DATA fd; - return GetFileAttributesExA(filename, GetFileExInfoStandard, &fd) != 0; -} -#endif - -//---------------------------------------------------------------------------- bool SystemTools::FileExists(const char* filename) { if(!(filename && *filename)) @@ -1060,11 +1074,12 @@ bool SystemTools::FileExists(const char* filename) char winpath[MAX_PATH]; if(SystemTools::PathCygwinToWin32(filename, winpath)) { - return WindowsFileExists(winpath); + return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES); } return access(filename, R_OK) == 0; #elif defined(_WIN32) - return WindowsFileExists(filename); + return (GetFileAttributesW(Encoding::ToWide(filename).c_str()) + != INVALID_FILE_ATTRIBUTES); #else return access(filename, R_OK) == 0; #endif @@ -1107,7 +1122,7 @@ bool SystemTools::Touch(const char* filename, bool create) { if(create && !SystemTools::FileExists(filename)) { - FILE* file = fopen(filename, "a+b"); + FILE* file = Fopen(filename, "a+b"); if(file) { fclose(file); @@ -1116,7 +1131,8 @@ bool SystemTools::Touch(const char* filename, bool create) return false; } #if defined(_WIN32) && !defined(__CYGWIN__) - HANDLE h = CreateFile(filename, FILE_WRITE_ATTRIBUTES, + HANDLE h = CreateFileW(Encoding::ToWide(filename).c_str(), + FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if(!h) @@ -1220,11 +1236,13 @@ bool SystemTools::FileTimeCompare(const char* f1, const char* f2, // Windows version. Get the modification time from extended file attributes. WIN32_FILE_ATTRIBUTE_DATA f1d; WIN32_FILE_ATTRIBUTE_DATA f2d; - if(!GetFileAttributesEx(f1, GetFileExInfoStandard, &f1d)) + if(!GetFileAttributesExW(Encoding::ToWide(f1).c_str(), + GetFileExInfoStandard, &f1d)) { return false; } - if(!GetFileAttributesEx(f2, GetFileExInfoStandard, &f2d)) + if(!GetFileAttributesExW(Encoding::ToWide(f2).c_str(), + GetFileExInfoStandard, &f2d)) { return false; } @@ -1932,6 +1950,39 @@ bool SystemTools::CopyFileIfDifferent(const char* source, bool SystemTools::FilesDiffer(const char* source, const char* destination) { + +#if defined(_WIN32) + WIN32_FILE_ATTRIBUTE_DATA statSource; + if (GetFileAttributesExW(Encoding::ToWide(source).c_str(), + GetFileExInfoStandard, + &statSource) == 0) + { + return true; + } + + WIN32_FILE_ATTRIBUTE_DATA statDestination; + if (GetFileAttributesExW(Encoding::ToWide(destination).c_str(), + GetFileExInfoStandard, + &statDestination) == 0) + { + return true; + } + + if(statSource.nFileSizeHigh != statDestination.nFileSizeHigh || + statSource.nFileSizeLow != statDestination.nFileSizeLow) + { + return true; + } + + if(statSource.nFileSizeHigh == 0 && statSource.nFileSizeLow == 0) + { + return false; + } + off_t nleft = ((__int64)statSource.nFileSizeHigh << 32) + + statSource.nFileSizeLow; + +#else + struct stat statSource; if (stat(source, &statSource) != 0) { @@ -1953,15 +2004,19 @@ bool SystemTools::FilesDiffer(const char* source, { return false; } + off_t nleft = statSource.st_size; +#endif -#if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ifstream finSource(source, (kwsys_ios::ios::binary | - kwsys_ios::ios::in)); - kwsys_ios::ifstream finDestination(destination, (kwsys_ios::ios::binary | - kwsys_ios::ios::in)); +#if defined(_WIN32) + kwsys::ifstream finSource(source, + (kwsys_ios::ios::binary | + kwsys_ios::ios::in)); + kwsys::ifstream finDestination(destination, + (kwsys_ios::ios::binary | + kwsys_ios::ios::in)); #else - kwsys_ios::ifstream finSource(source); - kwsys_ios::ifstream finDestination(destination); + kwsys::ifstream finSource(source); + kwsys::ifstream finDestination(destination); #endif if(!finSource || !finDestination) { @@ -1971,7 +2026,6 @@ bool SystemTools::FilesDiffer(const char* source, // Compare the files a block at a time. char source_buf[KWSYS_ST_BUFFER]; char dest_buf[KWSYS_ST_BUFFER]; - off_t nleft = statSource.st_size; while(nleft > 0) { // Read a block from each file. @@ -2044,10 +2098,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) // Open files #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ifstream fin(source, - kwsys_ios::ios::binary | kwsys_ios::ios::in); + kwsys::ifstream fin(source, + kwsys_ios::ios::binary | kwsys_ios::ios::in); #else - kwsys_ios::ifstream fin(source); + kwsys::ifstream fin(source); #endif if(!fin) { @@ -2344,7 +2398,11 @@ bool SystemTools::RemoveFile(const char* source) /* Win32 unlink is stupid --- it fails if the file is read-only */ SystemTools::SetPermissions(source, S_IWRITE); #endif +#ifdef _WIN32 + bool res = _wunlink(Encoding::ToWide(source).c_str()) != 0 ? false : true; +#else bool res = unlink(source) != 0 ? false : true; +#endif #ifdef _WIN32 if ( !res ) { @@ -2789,12 +2847,15 @@ bool SystemTools::FileIsDirectory(const char* name) } // Now check the file node type. +#if defined( _WIN32 ) + DWORD attr = GetFileAttributesW(Encoding::ToWide(name).c_str()); + if (attr != INVALID_FILE_ATTRIBUTES) + { + return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0; +#else struct stat fs; if(stat(name, &fs) == 0) { -#if defined( _WIN32 ) && !defined(__CYGWIN__) - return ((fs.st_mode & _S_IFDIR) != 0); -#else return S_ISDIR(fs.st_mode); #endif } @@ -3279,11 +3340,12 @@ static int GetCasePathName(const kwsys_stl::string & pathIn, kwsys_stl::string test_str = casePath; test_str += path_components[idx]; - WIN32_FIND_DATA findData; - HANDLE hFind = ::FindFirstFile(test_str.c_str(), &findData); + WIN32_FIND_DATAW findData; + HANDLE hFind = ::FindFirstFileW(Encoding::ToWide(test_str).c_str(), + &findData); if (INVALID_HANDLE_VALUE != hFind) { - casePath += findData.cFileName; + casePath += Encoding::ToNarrow(findData.cFileName); ::FindClose(hFind); } else @@ -3733,8 +3795,7 @@ bool SystemTools::FileHasSignature(const char *filename, return false; } - FILE *fp; - fp = fopen(filename, "rb"); + FILE *fp = Fopen(filename, "rb"); if (!fp) { return false; @@ -3767,8 +3828,7 @@ SystemTools::DetectFileType(const char *filename, return SystemTools::FileTypeUnknown; } - FILE *fp; - fp = fopen(filename, "rb"); + FILE *fp = Fopen(filename, "rb"); if (!fp) { return SystemTools::FileTypeUnknown; @@ -3958,9 +4018,8 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) { #if defined(WIN32) && !defined(__CYGWIN__) const int size = int(strlen(path)) +1; // size of return - char *buffer = new char[size]; // create a buffer char *tempPath = new char[size]; // create a buffer - int ret; + DWORD ret; // if the path passed in has quotes around it, first remove the quotes if (path[0] == '"' && path[strlen(path)-1] == '"') @@ -3973,19 +4032,20 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) strcpy(tempPath,path); } + kwsys_stl::wstring wtempPath = Encoding::ToWide(tempPath); + kwsys_stl::vector<wchar_t> buffer(wtempPath.size()+1); buffer[0] = 0; - ret = GetShortPathName(tempPath, buffer, size); + ret = GetShortPathNameW(Encoding::ToWide(tempPath).c_str(), + &buffer[0], static_cast<DWORD>(wtempPath.size())); - if(buffer[0] == 0 || ret > size) + if(buffer[0] == 0 || ret > wtempPath.size()) { - delete [] buffer; delete [] tempPath; return false; } else { - shortPath = buffer; - delete [] buffer; + shortPath = Encoding::ToNarrow(&buffer[0]); delete [] tempPath; return true; } @@ -4212,12 +4272,45 @@ bool SystemTools::GetPermissions(const char* file, mode_t& mode) return false; } +#if defined(_WIN32) + DWORD attr = GetFileAttributesW(Encoding::ToWide(file).c_str()); + if(attr == INVALID_FILE_ATTRIBUTES) + { + return false; + } + if((attr & FILE_ATTRIBUTE_READONLY) != 0) + { + mode = (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6)); + } + else + { + mode = (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6)) | + (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6)); + } + if((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) + { + mode |= S_IFDIR | (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6)); + } + else + { + mode |= S_IFREG; + } + const char* ext = strrchr(file, '.'); + if(ext && (Strucmp(ext, ".exe") == 0 || + Strucmp(ext, ".com") == 0 || + Strucmp(ext, ".cmd") == 0 || + Strucmp(ext, ".bat") == 0)) + { + mode |= (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6)); + } +#else struct stat st; if ( stat(file, &st) < 0 ) { return false; } mode = st.st_mode; +#endif return true; } @@ -4231,7 +4324,11 @@ bool SystemTools::SetPermissions(const char* file, mode_t mode) { return false; } +#ifdef _WIN32 + if ( _wchmod(Encoding::ToWide(file).c_str(), mode) < 0 ) +#else if ( chmod(file, mode) < 0 ) +#endif { return false; } @@ -4336,7 +4433,9 @@ void SystemTools::ConvertWindowsCommandLineToUnixArguments( (*argv)[0] = new char [1024]; #ifdef _WIN32 - ::GetModuleFileName(0, (*argv)[0], 1024); + wchar_t tmp[1024]; + ::GetModuleFileNameW(0, tmp, 1024); + strcpy((*argv)[0], Encoding::ToNarrow(tmp).c_str()); #else (*argv)[0][0] = '\0'; #endif @@ -4396,14 +4495,14 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() #ifdef _WIN32 char buffer[256]; - OSVERSIONINFOEX osvi; + OSVERSIONINFOEXA osvi; BOOL bOsVersionInfoEx; // Try calling GetVersionEx using the OSVERSIONINFOEX structure. // If that fails, try using the OSVERSIONINFO structure. - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi); if (!bOsVersionInfoEx) @@ -4546,21 +4645,21 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() { HKEY hKey; #define BUFSIZE 80 - char szProductType[BUFSIZE]; + wchar_t szProductType[BUFSIZE]; DWORD dwBufLen=BUFSIZE; LONG lRet; - lRet = RegOpenKeyEx( + lRet = RegOpenKeyExW( HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", + L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey); if (lRet != ERROR_SUCCESS) { return 0; } - lRet = RegQueryValueEx(hKey, "ProductType", NULL, NULL, - (LPBYTE) szProductType, &dwBufLen); + lRet = RegQueryValueExW(hKey, L"ProductType", NULL, NULL, + (LPBYTE) szProductType, &dwBufLen); if ((lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE)) { @@ -4569,15 +4668,15 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() RegCloseKey(hKey); - if (lstrcmpi("WINNT", szProductType) == 0) + if (lstrcmpiW(L"WINNT", szProductType) == 0) { res += " Workstation"; } - if (lstrcmpi("LANMANNT", szProductType) == 0) + if (lstrcmpiW(L"LANMANNT", szProductType) == 0) { res += " Server"; } - if (lstrcmpi("SERVERNT", szProductType) == 0) + if (lstrcmpiW(L"SERVERNT", szProductType) == 0) { res += " Advanced Server"; } @@ -4593,16 +4692,16 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() // Display service pack (if any) and build number. if (osvi.dwMajorVersion == 4 && - lstrcmpi(osvi.szCSDVersion, "Service Pack 6") == 0) + lstrcmpiA(osvi.szCSDVersion, "Service Pack 6") == 0) { HKEY hKey; LONG lRet; // Test for SP6 versus SP6a. - lRet = RegOpenKeyEx( + lRet = RegOpenKeyExW( HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009", + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009", 0, KEY_QUERY_VALUE, &hKey); if (lRet == ERROR_SUCCESS) diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index d6dae39..9457a4e 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -24,6 +24,8 @@ // Required for va_list #include <stdarg.h> +// Required for FILE* +#include <stdio.h> #if @KWSYS_NAMESPACE@_STL_HAVE_STD && !defined(va_list) // Some compilers move va_list into the std namespace and there is no way to // tell that this has been done. Playing with things being included before or @@ -42,10 +44,6 @@ namespace @KWSYS_NAMESPACE@ } #endif // va_list -#if defined( _MSC_VER ) -typedef unsigned short mode_t; -#endif - /* Define these macros temporarily to keep the code readable. */ #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS # define kwsys_stl @KWSYS_NAMESPACE@_stl @@ -497,6 +495,11 @@ public: */ /** + * Open a file considering unicode. + */ + static FILE* Fopen(const char* file, const char* mode); + + /** * Make a new directory if it is not there. This function * can make a full path even if none of the directories existed * prior to calling this function. @@ -684,6 +687,10 @@ public: */ static long int CreationTime(const char* filename); + #if defined( _MSC_VER ) + typedef unsigned short mode_t; + #endif + /** * Get and set permissions of the file. */ diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index be7a09e..3f947f3 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -674,3 +674,9 @@ int main() return a; } #endif + +#ifdef TEST_KWSYS_STL_HAS_WSTRING +#include <string> +void f(std ::wstring*) {} +int main() { return 0; } +#endif diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx new file mode 100644 index 0000000..8e74a50 --- /dev/null +++ b/Source/kwsys/testEncoding.cxx @@ -0,0 +1,159 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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 "kwsysPrivate.h" + +#if defined(_MSC_VER) +# pragma warning (disable:4786) +#endif + +#include KWSYS_HEADER(Encoding.hxx) +#include KWSYS_HEADER(ios/iostream) + +#include <locale.h> + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Encoding.hxx.in" +# include "kwsys_ios_iostream.h.in" +#endif + +//---------------------------------------------------------------------------- +static const unsigned char helloWorldStrings[][32] = +{ + // English + {'H','e','l','l','o',' ','W','o','r','l','d',0}, + // Japanese + {0xE3, 0x81, 0x93, 0xE3, 0x82, 0x93, 0xE3, 0x81, 0xAB, 0xE3, + 0x81, 0xA1, 0xE3, 0x81, 0xAF, 0xE4, 0xB8, 0x96, 0xE7, 0x95, + 0x8C, 0}, + // Arabic + {0xD9, 0x85, 0xD8, 0xB1, 0xD8, 0xAD, 0xD8, 0xA8, 0xD8, 0xA7, + 0x20, 0xD8, 0xA7, 0xD9, 0x84, 0xD8, 0xB9, 0xD8, 0xA7, 0xD9, + 0x84, 0xD9, 0x85, 0}, + // Yiddish + {0xD7, 0x94, 0xD7, 0xA2, 0xD7, 0x9C, 0xD7, 0x90, 0x20, 0xD7, + 0x95, 0xD7, 0x95, 0xD7, 0xA2, 0xD7, 0x9C, 0xD7, 0x98, 0}, + // Russian + {0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, + 0xD1, 0x82, 0x20, 0xD0, 0xBC, 0xD0, 0xB8, 0xD1, 0x80, 0}, + // Latin + {0x4D, 0x75, 0x6E, 0x64, 0x75, 0x73, 0x20, 0x73, 0x61, 0x6C, + 0x76, 0x65, 0}, + // Swahili + {0x68, 0x75, 0x6A, 0x61, 0x6D, 0x62, 0x6F, 0x20, 0x44, 0x75, + 0x6E, 0x69, 0x61, 0}, + // Icelandic + {0x48, 0x61, 0x6C, 0x6C, 0xC3, 0xB3, 0x20, 0x68, 0x65, 0x69, + 0x6D, 0x75, 0x72, 0}, + {0} +}; + +//---------------------------------------------------------------------------- +static int testHelloWorldEncoding() +{ + int ret = 0; + for(int i=0; helloWorldStrings[i][0] != 0; i++) + { + std::string str = reinterpret_cast<const char*>(helloWorldStrings[i]); + std::cout << str << std::endl; + std::wstring wstr = kwsys::Encoding::ToWide(str); + std::string str2 = kwsys::Encoding::ToNarrow(wstr); + if(!wstr.empty() && str != str2) + { + std::cout << "converted string was different: " << str2 << std::endl; + ret++; + } + } + return ret; +} + +static int testRobustEncoding() +{ + // test that the conversion functions handle invalid + // unicode correctly/gracefully + + int ret = 0; + char cstr[] = {(char)-1, 0}; + // this conversion could fail + std::wstring wstr = kwsys::Encoding::ToWide(cstr); + + wstr = kwsys::Encoding::ToWide(NULL); + if(wstr != L"") + { + const wchar_t* wcstr = wstr.c_str(); + std::cout << "ToWide(NULL) returned"; + for(size_t i=0; i<wstr.size(); i++) + { + std::cout << " " << std::hex << (int)wcstr[i]; + } + std::cout << std::endl; + ret++; + } + wstr = kwsys::Encoding::ToWide(""); + if(wstr != L"") + { + const wchar_t* wcstr = wstr.c_str(); + std::cout << "ToWide(\"\") returned"; + for(size_t i=0; i<wstr.size(); i++) + { + std::cout << " " << std::hex << (int)wcstr[i]; + } + std::cout << std::endl; + ret++; + } + +#ifdef WIN32 + // 16 bit wchar_t - we make an invalid surrogate pair + wchar_t cwstr[] = {0xD801, 0xDA00, 0}; + // this conversion could fail + std::string win_str = kwsys::Encoding::ToNarrow(cwstr); +#endif + + std::string str = kwsys::Encoding::ToNarrow(NULL); + if(str != "") + { + std::cout << "ToNarrow(NULL) returned " << str << std::endl; + ret++; + } + + str = kwsys::Encoding::ToNarrow(L""); + if(wstr != L"") + { + std::cout << "ToNarrow(\"\") returned " << str << std::endl; + ret++; + } + + return ret; +} + + +//---------------------------------------------------------------------------- +int testEncoding(int, char*[]) +{ + const char* loc = setlocale(LC_ALL, ""); + if(loc) + { + std::cout << "Locale: " << loc << std::endl; + } + else + { + std::cout << "Locale: None" << std::endl; + } + + int ret = 0; + + ret |= testHelloWorldEncoding(); + ret |= testRobustEncoding(); + + return ret; +} diff --git a/Tests/BundleUtilities/CMakeLists.txt b/Tests/BundleUtilities/CMakeLists.txt index 5cc7071..3a1cf55 100644 --- a/Tests/BundleUtilities/CMakeLists.txt +++ b/Tests/BundleUtilities/CMakeLists.txt @@ -25,13 +25,11 @@ set_target_properties(shared shared2 framework PROPERTIES # testbundleutils1 will load this at runtime add_library(module1 MODULE module.cpp module.h) set_target_properties(module1 PROPERTIES PREFIX "") -get_target_property(module_loc module1 LOCATION) target_link_libraries(module1 shared2) # a bundle application add_executable(testbundleutils1 MACOSX_BUNDLE testbundleutils1.cpp) target_link_libraries(testbundleutils1 shared framework ${CMAKE_DL_LIBS}) -get_target_property(loc testbundleutils1 LOCATION) set_target_properties(testbundleutils1 module1 PROPERTIES INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir1" @@ -40,8 +38,8 @@ set_target_properties(testbundleutils1 module1 PROPERTIES # add custom target to install and test the app add_custom_target(testbundleutils1_test ALL COMMAND ${CMAKE_COMMAND} - "-DINPUT=${loc}" - "-DMODULE=${module_loc}" + "-DINPUT=$<TARGET_FILE:testbundleutils1>" + "-DMODULE=$<TARGET_FILE:module1>" "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir1" -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" @@ -58,13 +56,11 @@ add_dependencies(testbundleutils1_test testbundleutils1) # testbundleutils2 will load this at runtime add_library(module2 MODULE module.cpp module.h) set_target_properties(module2 PROPERTIES PREFIX "") -get_target_property(module_loc module2 LOCATION) target_link_libraries(module2 shared2) # a non-bundle application add_executable(testbundleutils2 testbundleutils2.cpp) target_link_libraries(testbundleutils2 shared framework ${CMAKE_DL_LIBS}) -get_target_property(loc testbundleutils2 LOCATION) set_target_properties(testbundleutils2 module2 PROPERTIES INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir2" @@ -73,8 +69,8 @@ set_target_properties(testbundleutils2 module2 PROPERTIES # add custom target to install and test the app add_custom_target(testbundleutils2_test ALL COMMAND ${CMAKE_COMMAND} - "-DINPUT=${loc}" - "-DMODULE=${module_loc}" + "-DINPUT=$<TARGET_FILE:testbundleutils2>" + "-DMODULE=$<TARGET_FILE:module2>" "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir2" -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" @@ -106,13 +102,11 @@ if(APPLE AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS 9.0) # testbundleutils1 will load this at runtime add_library(module3 MODULE module.cpp module.h) set_target_properties(module3 PROPERTIES PREFIX "" LINK_FLAGS "-Wl,-rpath,@loader_path/") - get_target_property(module_loc module3 LOCATION) target_link_libraries(module3 shared2-3) # a non-bundle application add_executable(testbundleutils3 testbundleutils3.cpp) target_link_libraries(testbundleutils3 shared-3 framework-3 ${CMAKE_DL_LIBS}) - get_target_property(loc testbundleutils3 LOCATION) set_target_properties(testbundleutils3 module3 PROPERTIES LINK_FLAGS "-Wl,-rpath,@loader_path/") @@ -120,8 +114,8 @@ if(APPLE AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS 9.0) # add custom target to install and test the app add_custom_target(testbundleutils3_test ALL COMMAND ${CMAKE_COMMAND} - "-DINPUT=${loc}" - "-DMODULE=${module_loc}" + "-DINPUT=$<TARGET_FILE:testbundleutils3>" + "-DMODULE=$<TARGET_FILE:module3>" "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir3" -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" 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 48abfae..9e74b7d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -269,6 +269,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CompileOptions CompileOptions) ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) ADD_TEST_MACRO(AliasTarget AliasTarget) + ADD_TEST_MACRO(StagingPrefix StagingPrefix) ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") @@ -1080,8 +1081,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) @@ -1099,6 +1102,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} @@ -1115,6 +1132,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..ecfecdb 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) @@ -56,11 +61,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/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 2408141..bbae387 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -29,9 +29,6 @@ set (EXECUTABLE_OUTPUT_PATH # add the executable that will generate the file add_executable(generator generator.cxx) -get_target_property(generator_PATH generator LOCATION) -message("Location ${generator_PATH}") - ################################################################ # # Test using a wrapper to wrap a header file @@ -189,7 +186,7 @@ add_executable(CustomCommand # generated source in a target. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/generated.c DEPENDS generator - COMMAND ${generator_PATH} + COMMAND generator ARGS ${PROJECT_BINARY_DIR}/generated.c ) 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/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index e0df8c2..edadb87 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:MiXeD> + -Dupper_case=$<UPPER_CASE:MiXeD> + -Dmake_c_identifier=$<MAKE_C_IDENTIFIER:4foo:+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..a86db31 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 "mixed") +check(upper_case "MIXED") +check(make_c_identifier "_4foo__bar__") diff --git a/Tests/LinkDirectory/CMakeLists.txt b/Tests/LinkDirectory/CMakeLists.txt index 7356b27..b8d5a04 100644 --- a/Tests/LinkDirectory/CMakeLists.txt +++ b/Tests/LinkDirectory/CMakeLists.txt @@ -11,13 +11,13 @@ endif() add_library(mylibA STATIC mylibA.c) set_property(TARGET mylibA PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/External/lib") -get_property(mylibA TARGET mylibA PROPERTY LOCATION) +# get_property(mylibA TARGET mylibA PROPERTY LOCATION) # Build a library into our build tree relative to the subproject build tree. add_library(mylibB STATIC mylibB.c) set_property(TARGET mylibB PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/lib") -get_property(mylibB TARGET mylibB PROPERTY LOCATION) +# get_property(mylibB TARGET mylibB PROPERTY LOCATION) # Create a custom target to drive the subproject build. include(ExternalProject) @@ -38,7 +38,7 @@ ExternalProject_Add_Step(ExternalTarget cleanup COMMAND ${CMAKE_COMMAND} -E remove_directory ${LinkDirectory_BINARY_DIR}/bin DEPENDEES download DEPENDERS configure - DEPENDS ${mylibA} ${mylibB} + DEPENDS mylibA mylibB "${LinkDirectory_BINARY_DIR}/External/CMakeLists.txt" "${LinkDirectory_BINARY_DIR}/External/myexe.c" ) diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt index 089fd13..d0e24ce 100644 --- a/Tests/MakeClean/ToClean/CMakeLists.txt +++ b/Tests/MakeClean/ToClean/CMakeLists.txt @@ -5,7 +5,6 @@ project(ToClean) add_executable(toclean toclean.cxx) # List some build-time-generated files. -get_target_property(TOCLEAN_FILES toclean LOCATION) set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") 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/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 7991c4e..9dd5289 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -43,10 +43,17 @@ add_library(codeeditorLib STATIC codeeditor.cpp) add_library(privateSlot OBJECT private_slot.cpp) +add_custom_target(generate_moc_input + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}" + COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h" +) +# set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/myinterface.h" PROPERTIES GENERATED TRUE) + add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot> - test.qrc resourcetester.cpp + test.qrc resourcetester.cpp generated.cpp ) +set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input) set_target_properties(QtAutogen codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) diff --git a/Tests/QtAutogen/generated.cpp b/Tests/QtAutogen/generated.cpp new file mode 100644 index 0000000..f53bf53 --- /dev/null +++ b/Tests/QtAutogen/generated.cpp @@ -0,0 +1,10 @@ + +#include "generated.h" + +Generated::Generated(QObject *parent) + : QObject(parent) +{ + +} + +#include "moc_generated.cpp" diff --git a/Tests/QtAutogen/generated.h b/Tests/QtAutogen/generated.h new file mode 100644 index 0000000..dd22489 --- /dev/null +++ b/Tests/QtAutogen/generated.h @@ -0,0 +1,17 @@ + +#ifndef GENERATED_H +#define GENERATED_H + +#include <QObject> + +#include "myinterface.h" + +class Generated : public QObject, MyInterface +{ + Q_OBJECT + Q_INTERFACES(MyInterface) +public: + explicit Generated(QObject *parent = 0); +}; + +#endif diff --git a/Tests/QtAutogen/myinterface.h.in b/Tests/QtAutogen/myinterface.h.in new file mode 100644 index 0000000..c6c0ba1 --- /dev/null +++ b/Tests/QtAutogen/myinterface.h.in @@ -0,0 +1,14 @@ + +#ifndef MYINTERFACE_H +#define MYINTERFACE_H + +#include <QObject> + +class MyInterface +{ + +}; + +Q_DECLARE_INTERFACE(MyInterface, "org.cmake.example.MyInterface") + +#endif diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt index aadc7d7..9d2c35b 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt @@ -1,19 +1,35 @@ CMake Error at CMP0037-NEW-colon.cmake:4 \(add_library\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "lib:colon" is not valid for certain CMake features, such - as generator expressions, and may result in undefined behavior. + The target name "lib:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Error at CMP0037-NEW-colon.cmake:5 \(add_executable\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "exe:colon" is not valid for certain CMake features, such - as generator expressions, and may result in undefined behavior. + The target name "exe:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-colon.cmake:6 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake index 5c564f3..f4c070d 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake @@ -3,3 +3,4 @@ cmake_policy(SET CMP0037 NEW) add_library("lib:colon" empty.cpp) add_executable("exe:colon" empty.cpp) +add_custom_target("custom:colon") diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt new file mode 100644 index 0000000..13835af --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt @@ -0,0 +1,33 @@ +CMake Error at CMP0037-NEW-reserved.cmake:4 \(add_library\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "all" is reserved or not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-reserved.cmake:5 \(add_executable\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "clean" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-reserved.cmake:6 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "help" is reserved or not valid for certain CMake features, + such as generator expressions, and may result in undefined behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake new file mode 100644 index 0000000..e9f6404 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0037 NEW) + +add_library(all empty.cpp) +add_executable(clean empty.cpp) +add_custom_target(help) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt index 169db86..2525bcd 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt @@ -1,19 +1,35 @@ CMake Error at CMP0037-NEW-space.cmake:4 \(add_library\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "lib with spaces" is not valid for certain CMake features, - such as generator expressions, and may result in undefined behavior. + The target name "lib with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Error at CMP0037-NEW-space.cmake:5 \(add_executable\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "exe with spaces" is not valid for certain CMake features, - such as generator expressions, and may result in undefined behavior. + The target name "exe with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at CMP0037-NEW-space.cmake:6 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake index 9e2faaa..9227986 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake @@ -3,3 +3,4 @@ cmake_policy(SET CMP0037 NEW) add_library("lib with spaces" empty.cpp) add_executable("exe with spaces" empty.cpp) +add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake new file mode 100644 index 0000000..870a286 --- /dev/null +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0037 OLD) + +add_library(all empty.cpp) +add_executable(clean empty.cpp) +add_custom_target(help) diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake index af98f12..46193a1 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake @@ -3,3 +3,4 @@ cmake_policy(SET CMP0037 OLD) add_library("lib with spaces" empty.cpp) add_executable("exe with spaces" empty.cpp) +add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt index c9366fa..d3b0e17 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt @@ -1,21 +1,38 @@ CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:2 \(add_library\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "lib:colon" is not valid for certain CMake features, such - as generator expressions, and may result in undefined behavior. + The target name "lib:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. + CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:3 \(add_executable\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "exe:colon" is not valid for certain CMake features, such - as generator expressions, and may result in undefined behavior. + The target name "exe:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:4 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom:colon" is reserved or not valid for certain CMake + features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake index 17c815e..445e3b2 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake @@ -1,3 +1,4 @@ add_library("lib:colon" empty.cpp) add_executable("exe:colon" empty.cpp) +add_custom_target("custom:colon") diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt index b29aad5..e39477a 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt @@ -1,21 +1,37 @@ CMake Warning \(dev\) at CMP0037-WARN-space.cmake:2 \(add_library\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "lib with spaces" is not valid for certain CMake features, - such as generator expressions, and may result in undefined behavior. + The target name "lib with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. + CMake Warning \(dev\) at CMP0037-WARN-space.cmake:3 \(add_executable\): - Policy CMP0037 is not set: Target names should match a validity pattern. - Run "cmake --help-policy CMP0037" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. - The target name "exe with spaces" is not valid for certain CMake features, - such as generator expressions, and may result in undefined behavior. + The target name "exe with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0037-WARN-space.cmake:4 \(add_custom_target\): + Policy CMP0037 is not set: Target names should not be reserved and should + match a validity pattern. Run "cmake --help-policy CMP0037" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The target name "custom with spaces" is reserved or not valid for certain + CMake features, such as generator expressions, and may result in undefined + behavior. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake index 4a10828..e50a64d 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake @@ -1,3 +1,4 @@ add_library("lib with spaces" empty.cpp) add_executable("exe with spaces" empty.cpp) +add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake index fbb1788..b7d8d7b 100644 --- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -8,3 +8,6 @@ run_cmake(CMP0037-NEW-colon) if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make")) run_cmake(CMP0037-WARN-colon) endif() + +run_cmake(CMP0037-OLD-reserved) +run_cmake(CMP0037-NEW-reserved) diff --git a/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target-result.txt b/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target.cmake b/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target.cmake new file mode 100644 index 0000000..f9c8afd --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-NEW-existing-target.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0040 NEW) + +add_library(foobar empty.cpp) + +add_custom_command(TARGET foobar PRE_BUILD + COMMAND "${CMAKE_COMMAND} -E echo hello world" +) diff --git a/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-result.txt b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-stderr.txt new file mode 100644 index 0000000..03a0217 --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at CMP0040-NEW-missing-target.cmake:3 \(add_custom_command\): + Policy CMP0040 is not set: The target in the TARGET signature of + add_custom_command\(\) must exist. Run "cmake --help-policy CMP0040" for + policy details. Use the cmake_policy command to set the policy and + suppress this warning. ++ + The target name "foobar" is unknown in this context. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target.cmake b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target.cmake new file mode 100644 index 0000000..276863d --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0040 NEW) + +add_custom_command(TARGET foobar PRE_BUILD + COMMAND "${CMAKE_COMMAND} -E hello world" +) diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-result.txt b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target.cmake b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target.cmake new file mode 100644 index 0000000..d7ec50d --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0040 OLD) + +add_library(foobar empty.cpp) + +add_custom_command(TARGET foobar PRE_BUILD + COMMAND "${CMAKE_COMMAND} -E echo hello world" +) diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-result.txt b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target.cmake b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target.cmake new file mode 100644 index 0000000..ef7a0f7 --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0040 OLD) + +add_custom_command(TARGET foobar PRE_BUILD + COMMAND "${CMAKE_COMMAND} -E echo hello world" +) diff --git a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-result.txt b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt new file mode 100644 index 0000000..e791f0a --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at CMP0040-WARN-missing-target.cmake:2 \(add_custom_command\): + Policy CMP0040 is not set: The target in the TARGET signature of + add_custom_command\(\) must exist. Run "cmake --help-policy CMP0040" for + policy details. Use the cmake_policy command to set the policy and + suppress this warning. ++ + The target name "foobar" is unknown in this context. +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/CMP0040/CMP0040-WARN-missing-target.cmake b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target.cmake new file mode 100644 index 0000000..2c3e401 --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target.cmake @@ -0,0 +1,4 @@ + +add_custom_command(TARGET foobar PRE_BUILD + COMMAND "${CMAKE_COMMAND} -E hello world" +) diff --git a/Tests/RunCMake/CMP0040/CMakeLists.txt b/Tests/RunCMake/CMP0040/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0040/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0040/RunCMakeTest.cmake b/Tests/RunCMake/CMP0040/RunCMakeTest.cmake new file mode 100644 index 0000000..13160e3 --- /dev/null +++ b/Tests/RunCMake/CMP0040/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(CMP0040-OLD-missing-target) +run_cmake(CMP0040-NEW-missing-target) +run_cmake(CMP0040-WARN-missing-target) + +run_cmake(CMP0040-OLD-existing-target) +run_cmake(CMP0040-NEW-existing-target) diff --git a/Tests/RunCMake/CMP0040/empty.cpp b/Tests/RunCMake/CMP0040/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0040/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} 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 bb1b909..593921f 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -59,6 +59,8 @@ add_RunCMake_test(CMP0028) 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) @@ -97,6 +99,7 @@ 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/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 7375888..e257fb3 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -3,3 +3,4 @@ include(RunCMake) run_cmake(invalid_name) run_cmake(target_commands) run_cmake(no_shared_libs) +run_cmake(whitelist) diff --git a/Tests/RunCMake/interface_library/whitelist-result.txt b/Tests/RunCMake/interface_library/whitelist-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/interface_library/whitelist-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/whitelist-stderr.txt b/Tests/RunCMake/interface_library/whitelist-stderr.txt new file mode 100644 index 0000000..577c0cc --- /dev/null +++ b/Tests/RunCMake/interface_library/whitelist-stderr.txt @@ -0,0 +1,19 @@ +CMake Error at whitelist.cmake:4 \(set_property\): + INTERFACE_LIBRARY targets may only have whitelisted properties. The + property "OUTPUT_NAME" is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at whitelist.cmake:5 \(set_property\): + INTERFACE_LIBRARY targets may only have whitelisted properties. The + property "OUTPUT_NAME" is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at whitelist.cmake:6 \(get_target_property\): + INTERFACE_LIBRARY targets may only have whitelisted properties. The + property "OUTPUT_NAME" is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake new file mode 100644 index 0000000..98ef05c --- /dev/null +++ b/Tests/RunCMake/interface_library/whitelist.cmake @@ -0,0 +1,6 @@ + +add_library(iface INTERFACE) + +set_property(TARGET iface PROPERTY OUTPUT_NAME output) +set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append) +get_target_property(outname iface OUTPUT_NAME) diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt new file mode 100644 index 0000000..922776d --- /dev/null +++ b/Tests/StagingPrefix/CMakeLists.txt @@ -0,0 +1,89 @@ + +cmake_minimum_required(VERSION 2.8.12) +project(StagingPrefix) + +# Wipe out the install tree +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/CleanupProject + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ConsumerBuild + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ProducerBuild + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/stage + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/prefix + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ignored + ) +add_custom_target(CleanupTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/CleanupProject) +set_property( + SOURCE ${CMAKE_BINARY_DIR}/CleanupProject + PROPERTY SYMBOLIC 1 + ) + +if(CMAKE_CONFIGURATION_TYPES) + set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") +else() + if(CMAKE_BUILD_TYPE) + set(NESTED_CONFIG_TYPE -C "${CMAKE_BUILD_TYPE}") + else() + set(NESTED_CONFIG_TYPE) + endif() +endif() + +# Build and install the producer. +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/ProducerProject + COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE} + --build-and-test + ${CMAKE_SOURCE_DIR}/Producer + ${CMAKE_BINARY_DIR}/ProducerBuild + --build-noclean + --build-project Producer + --build-target install + --build-generator ${CMAKE_GENERATOR} + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" + --build-options + -DCMAKE_VERBOSE_MAKEFILE=1 + "-DCMAKE_STAGING_PREFIX=${CMAKE_BINARY_DIR}/stage" + "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/prefix" + VERBATIM + ) + +add_custom_target(ProducerTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/ProducerProject) +add_dependencies(ProducerTarget CleanupTarget) +set_property( + SOURCE ${CMAKE_BINARY_DIR}/ProducerProject + PROPERTY SYMBOLIC 1 + ) + +if(NOT WIN32) + file(WRITE + "${CMAKE_BINARY_DIR}/ignored/${CMAKE_BINARY_DIR}/stage/include/ignored.h" + "#define IGNORED\n" + ) +endif() + +# Build and install the consumer. +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/ConsumerProject + COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE} + --build-and-test + ${CMAKE_SOURCE_DIR}/Consumer + ${CMAKE_BINARY_DIR}/ConsumerBuild + --build-noclean + --build-project Consumer + --build-target install + --build-generator ${CMAKE_GENERATOR} + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" + --build-options + "-DCMAKE_FIND_ROOT_PATH=${CMAKE_BINARY_DIR}/ignored" + "-DCMAKE_STAGING_PREFIX=${CMAKE_BINARY_DIR}/stage" + -DCMAKE_VERBOSE_MAKEFILE=1 + VERBATIM + ) +add_custom_target(ConsumerTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/ConsumerProject) +add_dependencies(ConsumerTarget ProducerTarget) +set_property( + SOURCE ${CMAKE_BINARY_DIR}/ConsumerProject + PROPERTY SYMBOLIC 1 + ) + +add_executable(StagingPrefix main.cpp) +add_dependencies(StagingPrefix ConsumerTarget) diff --git a/Tests/StagingPrefix/Consumer/CMakeLists.txt b/Tests/StagingPrefix/Consumer/CMakeLists.txt new file mode 100644 index 0000000..a230441 --- /dev/null +++ b/Tests/StagingPrefix/Consumer/CMakeLists.txt @@ -0,0 +1,22 @@ + +cmake_minimum_required (VERSION 2.8.12) +project(Consumer) + + +add_executable(executable main.cpp) +find_package(Foo CONFIG REQUIRED) +target_link_libraries(executable Foo::foo) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +find_package(Bar MODULE REQUIRED) +include_directories(${Bar_INCLUDE_DIRS}) +target_link_libraries(executable ${Bar_LIBRARIES}) + +install(TARGETS executable DESTINATION bin) + +if(NOT WIN32) + find_path(IGNORED_INCLUDE_DIR ignored.h) + if (IGNORED_INCLUDE_DIR) + message(SEND_ERROR "Should not find this file. The search path should be excluded.") + endif() +endif() diff --git a/Tests/StagingPrefix/Consumer/cmake/FindBar.cmake b/Tests/StagingPrefix/Consumer/cmake/FindBar.cmake new file mode 100644 index 0000000..29e4478 --- /dev/null +++ b/Tests/StagingPrefix/Consumer/cmake/FindBar.cmake @@ -0,0 +1,6 @@ + +find_path(_inc_prefix bar.h PATH_SUFFIXES bar) +set(Bar_INCLUDE_DIRS ${_inc_prefix}) + +find_library(Bar_LIBRARY bar) +set(Bar_LIBRARIES ${Bar_LIBRARY}) diff --git a/Tests/StagingPrefix/Consumer/main.cpp b/Tests/StagingPrefix/Consumer/main.cpp new file mode 100644 index 0000000..612ee05 --- /dev/null +++ b/Tests/StagingPrefix/Consumer/main.cpp @@ -0,0 +1,10 @@ + +#include "foo.h" +#include "bar.h" + +int main(int, char **) +{ + Foo f; + Bar b; + return f.foo() + b.bar(); +} diff --git a/Tests/StagingPrefix/Producer/CMakeLists.txt b/Tests/StagingPrefix/Producer/CMakeLists.txt new file mode 100644 index 0000000..eb3d98f --- /dev/null +++ b/Tests/StagingPrefix/Producer/CMakeLists.txt @@ -0,0 +1,26 @@ + +cmake_minimum_required (VERSION 2.8.12) +project(Producer) + +add_library(foo SHARED foo.cpp) + +install(TARGETS foo EXPORT fooTargets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + INCLUDES DESTINATION include/foo +) +install(FILES foo.h DESTINATION include/foo) +install(EXPORT fooTargets + FILE FooConfig.cmake + NAMESPACE Foo:: + DESTINATION lib/cmake/Foo +) + +add_library(bar SHARED bar.cpp) +install(TARGETS bar + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +install(FILES bar.h DESTINATION include/bar) diff --git a/Tests/StagingPrefix/Producer/bar.cpp b/Tests/StagingPrefix/Producer/bar.cpp new file mode 100644 index 0000000..6bb8abe --- /dev/null +++ b/Tests/StagingPrefix/Producer/bar.cpp @@ -0,0 +1,7 @@ + +#include "bar.h" + +int Bar::bar() +{ + return 0; +} diff --git a/Tests/StagingPrefix/Producer/bar.h b/Tests/StagingPrefix/Producer/bar.h new file mode 100644 index 0000000..acd1fae --- /dev/null +++ b/Tests/StagingPrefix/Producer/bar.h @@ -0,0 +1,10 @@ + +class +#ifdef _WIN32 +__declspec(dllexport) +#endif +Bar +{ +public: + int bar(); +}; diff --git a/Tests/StagingPrefix/Producer/foo.cpp b/Tests/StagingPrefix/Producer/foo.cpp new file mode 100644 index 0000000..64ad7cd --- /dev/null +++ b/Tests/StagingPrefix/Producer/foo.cpp @@ -0,0 +1,7 @@ + +#include "foo.h" + +int Foo::foo() +{ + return 0; +} diff --git a/Tests/StagingPrefix/Producer/foo.h b/Tests/StagingPrefix/Producer/foo.h new file mode 100644 index 0000000..614093d --- /dev/null +++ b/Tests/StagingPrefix/Producer/foo.h @@ -0,0 +1,10 @@ + +class +#ifdef _WIN32 +__declspec(dllexport) +#endif +Foo +{ +public: + int foo(); +}; diff --git a/Tests/StagingPrefix/main.cpp b/Tests/StagingPrefix/main.cpp new file mode 100644 index 0000000..341aaaf --- /dev/null +++ b/Tests/StagingPrefix/main.cpp @@ -0,0 +1,5 @@ + +int main(int, char **) +{ + return 0; +} diff --git a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt index 9961e69..70a35f6 100644 --- a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt @@ -1,13 +1,11 @@ # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) -get_target_property(MakeTableLocation MakeTable LOCATION) - # add the command to generate the source code add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h DEPENDS MakeTable - COMMAND ${MakeTableLocation} + COMMAND MakeTable ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) diff --git a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt index 9961e69..70a35f6 100644 --- a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt @@ -1,13 +1,11 @@ # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) -get_target_property(MakeTableLocation MakeTable LOCATION) - # add the command to generate the source code add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h DEPENDS MakeTable - COMMAND ${MakeTableLocation} + COMMAND MakeTable ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) diff --git a/Tests/Wrapping/CMakeLists.txt b/Tests/Wrapping/CMakeLists.txt index 1dc7ffc..cbb28a1 100644 --- a/Tests/Wrapping/CMakeLists.txt +++ b/Tests/Wrapping/CMakeLists.txt @@ -89,9 +89,8 @@ set (FLTK_SRCS fltk1.fl ) add_executable(fakefluid fakefluid.cxx) -get_target_property(FLUID_LOC fakefluid LOCATION) set (FLTK_WRAP_UI "On") -set (FLTK_FLUID_EXECUTABLE "${FLUID_LOC}") +set (FLTK_FLUID_EXECUTABLE fakefluid) fltk_wrap_ui (wraplibFLTK ${FLTK_SRCS}) add_library(wraplibFLTK ${wraplibFLTK_FLTK_UI_SRCS}) add_dependencies(wraplibFLTK fakefluid) diff --git a/Utilities/Release/dash2win64_release.cmake b/Utilities/Release/dash2win64_release.cmake index 6d1ac76..848e2f4 100644 --- a/Utilities/Release/dash2win64_release.cmake +++ b/Utilities/Release/dash2win64_release.cmake @@ -13,6 +13,7 @@ CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CMAKE_Fortran_COMPILER:FILEPATH=FALSE CMAKE_GENERATOR:INTERNAL=Unix Makefiles BUILD_QtDialog:BOOL:=TRUE +CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=c:/Dashboards/Support/qt-build/Qt/bin/qmake.exe ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index 5e57a70b..9d418d9 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -16,6 +16,7 @@ OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libssl.a CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-universal BUILD_QtDialog:BOOL=TRUE +CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.0/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake index 36b0952..aba68f8 100644 --- a/Utilities/Release/dashmacmini5_release.cmake +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -18,6 +18,7 @@ CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin64-universal BUILD_QtDialog:BOOL=TRUE +CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.0/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake index 4783fda..93916e2 100644 --- a/Utilities/Release/magrathea_release.cmake +++ b/Utilities/Release/magrathea_release.cmake @@ -16,6 +16,7 @@ OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1c-install/include OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1c-install/lib/libssl.a CPACK_SYSTEM_NAME:STRING=Linux-i386 BUILD_QtDialog:BOOL:=TRUE +CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.43-install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c index e9523cb..a4dc710 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c @@ -2475,20 +2475,16 @@ tar_atol256(const char *_p, size_t char_cnt) upper_limit = INT64_MAX / 256; lower_limit = INT64_MIN / 256; - /* Pad with 1 or 0 bits, depending on sign. */ + /* Sign-extend the 7-bit value to 64 bits. */ if ((0x40 & *p) == 0x40) - l = (int64_t)-1; + l = ~((int64_t)0x3f) | *p++; else - l = 0; - l = (l << 6) | (0x3f & *p++); + l = 0x3f & *p++; while (--char_cnt > 0) { - if (l > upper_limit) { - l = INT64_MAX; /* Truncate on overflow */ - break; - } else if (l < lower_limit) { - l = INT64_MIN; - break; - } + 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++); } return (l); @@ -318,11 +318,13 @@ CMAKE_C_SOURCES="\ if ${cmake_system_mingw}; then KWSYS_C_SOURCES="\ + EncodingC \ ProcessWin32 \ String \ System" else KWSYS_C_SOURCES="\ + EncodingC \ ProcessUNIX \ String \ System" @@ -330,6 +332,7 @@ fi KWSYS_CXX_SOURCES="\ Directory \ + EncodingCXX \ Glob \ RegularExpression \ SystemTools" @@ -337,6 +340,9 @@ KWSYS_CXX_SOURCES="\ KWSYS_FILES="\ auto_ptr.hxx \ Directory.hxx \ + Encoding.h \ + Encoding.hxx \ + FStream.hxx \ Glob.hxx \ Process.h \ RegularExpression.hxx \ @@ -479,6 +485,7 @@ cmake_kwsys_config_replace_string () s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g; s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g; s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g; + s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g; s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g; s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g; s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g; @@ -1123,6 +1130,7 @@ KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0 KWSYS_STL_HAS_ALLOCATOR_REBIND=0 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0 +KWSYS_STL_HAS_WSTRING=0 KWSYS_CXX_HAS_SETENV=0 KWSYS_CXX_HAS_UNSETENV=0 KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0 @@ -1310,6 +1318,15 @@ else fi if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_WSTRING -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then + KWSYS_STL_HAS_WSTRING=1 + echo "${cmake_cxx_compiler} has stl wstring" +else + echo "${cmake_cxx_compiler} does not have stl wstring" +fi + +if cmake_try_run "${cmake_cxx_compiler}" \ "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \ "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then KWSYS_CXX_HAS_CSTDDEF=1 @@ -1516,6 +1533,9 @@ if [ "x${cmake_cxx_flags}" != "x" ]; then fi cmake_c_flags_String="-DKWSYS_STRING_C" +if ${cmake_system_mingw}; then + cmake_c_flags_EncodingC="-DKWSYS_ENCODING_DEFAULT_CODEPAGE=CP_ACP" +fi cmake_cxx_flags_SystemTools=" -DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} |