diff options
387 files changed, 6653 insertions, 1790 deletions
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index f499be1..d716498 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -53,6 +53,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element" "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast "ld: warning: directory not found for option .-(F|L)" + "ld: warning: in .*/libgcc.a, file is not of required architecture" "warning.*This version of Mac OS X is unsupported" "clang.*: warning: argument unused during compilation: .-g" "note: in expansion of macro" # diagnostic context note @@ -62,6 +63,18 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION # Ignore clang's summary warning, assuming prior text has matched some # other warning expression: "[0-9,]+ warnings? generated." + +# scanbuild exceptions + "char_traits.h:.*: warning: Null pointer argument in call to string length function" + "stl_construct.h:.*: warning: Forming reference to null pointer" + ".*stl_uninitialized.h:75:19: warning: Forming reference to null pointer.*" + ".*stl_vector.h:.*: warning: Returning null reference.*" + "warning: Value stored to 'yymsg' is never read" + "warning: Value stored to 'yytoken' is never read" + "index_encoder.c.241.2. warning: Value stored to .out_start. is never read" + "index.c.*warning: Access to field.*results in a dereference of a null pointer.*loaded from variable.*" + "cm_sha2.*warning: Value stored to.*is never read" + "testProcess.*warning: Dereference of null pointer .loaded from variable .invalidAddress.." ) if(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode") diff --git a/Help/command/add_dependencies.rst b/Help/command/add_dependencies.rst index 10997ec..c3583cf 100644 --- a/Help/command/add_dependencies.rst +++ b/Help/command/add_dependencies.rst @@ -7,13 +7,16 @@ Add a dependency between top-level targets. add_dependencies(<target> [<target-dependency>]...) -Make a top-level <target> depend on other top-level targets to ensure -that they build before <target> does. A top-level target is one -created by ADD_EXECUTABLE, ADD_LIBRARY, or ADD_CUSTOM_TARGET. -Dependencies added to an IMPORTED target are followed transitively in -its place since the target itself does not build. +Make a top-level ``<target>`` depend on other top-level targets to +ensure that they build before ``<target>`` does. A top-level target +is one created by one of the :command:`add_executable`, +:command:`add_library`, or :command:`add_custom_target` commands. -See the DEPENDS option of ADD_CUSTOM_TARGET and ADD_CUSTOM_COMMAND for -adding file-level dependencies in custom rules. See the -OBJECT_DEPENDS option in SET_SOURCE_FILES_PROPERTIES to add file-level -dependencies to object files. +Dependencies added to an :ref:`imported target <Imported Targets>` +or an :ref:`interface library <Interface Libraries>` are followed +transitively in its place since the target itself does not build. + +See the ``DEPENDS`` option of :command:`add_custom_target` and +:command:`add_custom_command` commands for adding file-level +dependencies in custom rules. See the :prop_sf:`OBJECT_DEPENDS` +source file property to add file-level dependencies to object files. diff --git a/Help/command/file.rst b/Help/command/file.rst index 73d4cfa..2fe7414 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -92,9 +92,12 @@ store it in a ``<variable>``. :: - file(GLOB <variable> [RELATIVE <path>] [<globbing-expressions>...]) - file(GLOB_RECURSE <variable> [RELATIVE <path>] - [FOLLOW_SYMLINKS] [<globbing-expressions>...]) + file(GLOB <variable> + [LIST_DIRECTORIES true|false] [RELATIVE <path>] + [<globbing-expressions>...]) + file(GLOB_RECURSE <variable> [FOLLOW_SYMLINKS] + [LIST_DIRECTORIES true|false] [RELATIVE <path>] + [<globbing-expressions>...]) Generate a list of files that match the ``<globbing-expressions>`` and store it into the ``<variable>``. Globbing expressions are similar to @@ -102,6 +105,9 @@ regular expressions, but much simpler. If ``RELATIVE`` flag is specified, the results will be returned as relative paths to the given path. +By default ``GLOB`` lists directories - directories are omited in result if +``LIST_DIRECTORIES`` is set to false. + .. note:: We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is @@ -119,6 +125,11 @@ matched directory and match the files. Subdirectories that are symlinks are only traversed if ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to ``NEW``. +By default ``GLOB_RECURSE`` omits directories from result list - setting +``LIST_DIRECTORIES`` to true adds directories to result list. +If ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to +``OLD`` then ``LIST_DIRECTORIES`` treats symlinks as directories. + Examples of recursive globbing include:: /dir/*.py - match all python files in /dir and subdirectories diff --git a/Help/command/set.rst b/Help/command/set.rst index 7a59550..d04b880 100644 --- a/Help/command/set.rst +++ b/Help/command/set.rst @@ -1,116 +1,89 @@ set --- -Set a CMake, cache or environment variable to a given value. +Set a normal, cache, or environment variable to a given value. +See the :ref:`cmake-language(7) variables <CMake Language Variables>` +documentation for the scopes and interaction of normal variables +and cache entries. + +Signatures of this command that specify a ``<value>...`` placeholder +expect zero or more arguments. Multiple arguments will be joined as +a :ref:`;-list <CMake Language Lists>` to form the actual variable +value to be set. Zero arguments will cause normal variables to be +unset. See the :command:`unset` command to unset variables explicitly. + +Set Normal Variable +^^^^^^^^^^^^^^^^^^^ :: - set(<variable> <value> - [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE]) + set(<variable> <value>... [PARENT_SCOPE]) + +Set the given ``<variable>`` in the current function or directory scope. -Within CMake sets <variable> to the value <value>. <value> is -expanded before <variable> is set to it. Normally, set will set a -regular CMake variable. If CACHE is present, then the <variable> is -put in the cache instead, unless it is already in the cache. See -section 'Variable types in CMake' below for details of regular and -cache variables and their interactions. If CACHE is used, <type> and -<docstring> are required. <type> is used by the CMake GUI to choose a -widget with which the user sets a value. The value for <type> may be -one of +If the ``PARENT_SCOPE`` option is given the variable will be set in +the scope above the current scope. Each new directory or function +creates a new scope. This command will set the value of a variable +into the parent directory or calling function (whichever is applicable +to the case at hand). + +Set Cache Entry +^^^^^^^^^^^^^^^ :: - FILEPATH = File chooser dialog. - PATH = Directory chooser dialog. - STRING = Arbitrary string. - BOOL = Boolean ON/OFF checkbox. - INTERNAL = No GUI entry (used for persistent variables). + set(<variable> <value>... CACHE <type> <docstring> [FORCE]) -If <type> is INTERNAL, the cache variable is marked as internal, and -will not be shown to the user in tools like cmake-gui. This is -intended for values that should be persisted in the cache, but which -users should not normally change. INTERNAL implies FORCE. +Set the given cache ``<variable>`` (cache entry). Since cache entries +are meant to provide user-settable values this does not overwrite +existing cache entries by default. Use the ``FORCE`` option to +overwrite existing entries. -Normally, set(...CACHE...) creates cache variables, but does not -modify them. If FORCE is specified, the value of the cache variable -is set, even if the variable is already in the cache. This should -normally be avoided, as it will remove any changes to the cache -variable's value by the user. +The ``<type>`` must be specified as one of: -If PARENT_SCOPE is present, the variable will be set in the scope -above the current scope. Each new directory or function creates a new -scope. This command will set the value of a variable into the parent -directory or calling function (whichever is applicable to the case at -hand). PARENT_SCOPE cannot be combined with CACHE. +``BOOL`` + Boolean ``ON/OFF`` value. :manual:`cmake-gui(1)` offers a checkbox. -If <value> is not specified then the variable is removed instead of -set. See also: the unset() command. +``FILEPATH`` + Path to a file on disk. :manual:`cmake-gui(1)` offers a file dialog. -:: +``PATH`` + Path to a directory on disk. :manual:`cmake-gui(1)` offers a file dialog. - set(<variable> <value1> ... <valueN>) +``STRING`` + A line of text. :manual:`cmake-gui(1)` offers a text field or a + drop-down selection if the :prop_cache:`STRINGS` cache entry + property is set. -In this case <variable> is set to a semicolon separated list of -values. +``INTERNAL`` + A line of text. :manual:`cmake-gui(1)` does not show internal entries. + They may be used to store variables persistently across runs. + Use of this type implies ``FORCE``. -<variable> can be an environment variable such as: +The ``<docstring>`` must be specified as a line of text providing +a quick summary of the option for presentation to :manual:`cmake-gui(1)` +users. + +If the cache entry does not exist prior to the call or the ``FORCE`` +option is given then the cache entry will be set to the given value. +Furthermore, any normal variable binding in the current scope will +be removed to expose the newly cached value to any immediately +following evaluation. + +It is possible for the cache entry to exist prior to the call but +have no type set if it was created on the :manual:`cmake(1)` command +line by a user through the ``-D<var>=<value>`` option without +specifying a type. In this case the ``set`` command will add the +type. Furthermore, if the ``<type>`` is ``PATH`` or ``FILEPATH`` +and the ``<value>`` provided on the command line is a relative path, +then the ``set`` command will treat the path as relative to the +current working directory and convert it to an absolute path. + +Set Environment Variable +^^^^^^^^^^^^^^^^^^^^^^^^ :: - set( ENV{PATH} /home/martink ) - -in which case the environment variable will be set. - -*** Variable types in CMake *** - -In CMake there are two types of variables: normal variables and cache -variables. Normal variables are meant for the internal use of the -script (just like variables in most programming languages); they are -not persisted across CMake runs. Cache variables (unless set with -INTERNAL) are mostly intended for configuration settings where the -first CMake run determines a suitable default value, which the user -can then override, by editing the cache with tools such as ccmake or -cmake-gui. Cache variables are stored in the CMake cache file, and -are persisted across CMake runs. - -Both types can exist at the same time with the same name but different -values. When ${FOO} is evaluated, CMake first looks for a normal -variable 'FOO' in scope and uses it if set. If and only if no normal -variable exists then it falls back to the cache variable 'FOO'. - -Some examples: - -The code 'set(FOO "x")' sets the normal variable 'FOO'. It does not -touch the cache, but it will hide any existing cache value 'FOO'. - -The code 'set(FOO "x" CACHE ...)' checks for 'FOO' in the cache, -ignoring any normal variable of the same name. If 'FOO' is in the -cache then nothing happens to either the normal variable or the cache -variable. If 'FOO' is not in the cache, then it is added to the -cache. - -Finally, whenever a cache variable is added or modified by a command, -CMake also *removes* the normal variable of the same name from the -current scope so that an immediately following evaluation of it will -expose the newly cached value. - -Normally projects should avoid using normal and cache variables of the -same name, as this interaction can be hard to follow. However, in -some situations it can be useful. One example (used by some -projects): - -A project has a subproject in its source tree. The child project has -its own CMakeLists.txt, which is included from the parent -CMakeLists.txt using add_subdirectory(). Now, if the parent and the -child project provide the same option (for example a compiler option), -the parent gets the first chance to add a user-editable option to the -cache. Normally, the child would then use the same value that the -parent uses. However, it may be necessary to hard-code the value for -the child project's option while still allowing the user to edit the -value used by the parent project. The parent project can achieve this -simply by setting a normal variable with the same name as the option -in a scope sufficient to hide the option's cache variable from the -child completely. The parent has already set the cache variable, so -the child's set(...CACHE...) will do nothing, and evaluating the -option variable will use the value from the normal variable, which -hides the cache variable. + set(ENV{<variable>} <value>...) + +Set the current process environment ``<variable>`` to the given value. diff --git a/Help/command/set_directory_properties.rst b/Help/command/set_directory_properties.rst index 834013a..e485fce 100644 --- a/Help/command/set_directory_properties.rst +++ b/Help/command/set_directory_properties.rst @@ -7,9 +7,6 @@ Set a property of the directory. set_directory_properties(PROPERTIES prop1 value1 prop2 value2) -Set a property for the current directory and subdirectories. If the -property is not found, CMake will report an error. The properties -include: INCLUDE_DIRECTORIES, LINK_DIRECTORIES, -INCLUDE_REGULAR_EXPRESSION, and ADDITIONAL_MAKE_CLEAN_FILES. -ADDITIONAL_MAKE_CLEAN_FILES is a list of files that will be cleaned as -a part of "make clean" stage. +Set a property for the current directory and subdirectories. See +:ref:`Directory Properties` for the list of properties known +to CMake. diff --git a/Help/command/set_source_files_properties.rst b/Help/command/set_source_files_properties.rst index 8ea02a3..b4904e8 100644 --- a/Help/command/set_source_files_properties.rst +++ b/Help/command/set_source_files_properties.rst @@ -10,6 +10,6 @@ Source files can have properties that affect how they are built. [prop2 value2 [...]]) Set properties associated with source files using a key/value paired -list. See properties documentation for those known to CMake. -Unrecognized properties are ignored. Source file properties are -visible only to targets added in the same directory (CMakeLists.txt). +list. See :ref:`Source File Properties` for the list of properties known +to CMake. Source file properties are visible only to targets added +in the same directory (CMakeLists.txt). diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst index afac847..3efb165 100644 --- a/Help/command/set_tests_properties.rst +++ b/Help/command/set_tests_properties.rst @@ -8,29 +8,7 @@ Set a property of the tests. set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2) Set a property for the tests. If the test is not found, CMake -will report an error. Generator expressions will be expanded the same -as supported by the test's add_test call. The properties include: - -WILL_FAIL: If set to true, this will invert the pass/fail flag of the -test. - -PASS_REGULAR_EXPRESSION: If set, the test output will be checked -against the specified regular expressions and at least one of the -regular expressions has to match, otherwise the test will fail. - -:: - - Example: PASS_REGULAR_EXPRESSION "TestPassed;All ok" - -FAIL_REGULAR_EXPRESSION: If set, if the output will match to one of -specified regular expressions, the test will fail. - -:: - - Example: FAIL_REGULAR_EXPRESSION "[^a-z]Error;ERROR;Failed" - -Both PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION expect a list -of regular expressions. - -TIMEOUT: Setting this will limit the test runtime to the number of -seconds specified. +will report an error. +:manual:`Generator expressions <cmake-generator-expressions(7)>` will be +expanded the same as supported by the test's :command:`add_test` call. See +:ref:`Test Properties` for the list of properties known to CMake. diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst index 29a8b41..b66a4ec 100644 --- a/Help/command/target_compile_features.rst +++ b/Help/command/target_compile_features.rst @@ -29,4 +29,4 @@ Arguments to ``target_compile_features`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-compile-features(7)` manual for -information on compile features. +information on compile features and a list of supported compilers. diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst index 3362c5d..73e01e7 100644 --- a/Help/command/target_compile_options.rst +++ b/Help/command/target_compile_options.rst @@ -20,8 +20,8 @@ alternative commands exist to add preprocessor definitions (:command:`target_compile_definitions` and :command:`add_definitions`) or include directories (:command:`target_include_directories` and :command:`include_directories`). See documentation of the -:prop_tgt:`directory <COMPILE_OPTIONS>` and -:prop_tgt:` target <COMPILE_OPTIONS>` ``COMPILE_OPTIONS`` properties. +:prop_dir:`directory <COMPILE_OPTIONS>` and +:prop_tgt:`target <COMPILE_OPTIONS>` ``COMPILE_OPTIONS`` properties. The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC`` diff --git a/Help/command/target_include_directories.rst b/Help/command/target_include_directories.rst index 1d236ce..30ec2cb 100644 --- a/Help/command/target_include_directories.rst +++ b/Help/command/target_include_directories.rst @@ -55,5 +55,8 @@ installation prefix. For example: $<INSTALL_INTERFACE:include/mylib> # <prefix>/include/mylib ) +Creating Relocatable Packages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + .. |INTERFACE_PROPERTY_LINK| replace:: :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` .. include:: /include/INTERFACE_INCLUDE_DIRECTORIES_WARNING.txt diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst index e6a82b6..d903d05 100644 --- a/Help/command/target_link_libraries.rst +++ b/Help/command/target_link_libraries.rst @@ -1,38 +1,113 @@ target_link_libraries --------------------- -Link a target to given libraries. +.. only:: html + + .. contents:: + +Specify libraries or flags to use when linking a given target and/or +its dependents. :ref:`Usage requirements <Target Usage Requirements>` +from linked library targets will be propagated. Usage requirements +of a target's dependencies affect compilation of its own sources. + +Overview +^^^^^^^^ + +This command has several signatures as detailed in subsections below. +All of them have the general form:: + + target_link_libraries(<target> ... <item>... ...) + +The named ``<target>`` must have been created in the current directory by +a command such as :command:`add_executable` or :command:`add_library`. +Repeated calls for the same ``<target>`` append items in the order called. +Each ``<item>`` may be: + +* **A library target name**: The generated link line will have the + full path to the linkable library file associated with the target. + The buildsystem will have a dependency to re-link ``<target>`` if + the library file changes. + + The named target must be created by :command:`add_library` within + the project or as an :ref:`IMPORTED library <Imported Targets>`. + If it is created within the project an ordering dependency will + automatically be added in the build system to make sure the named + library target is up-to-date before the ``<target>`` links. + + If an imported library has the :prop_tgt:`IMPORTED_NO_SONAME` + target property set, CMake may ask the linker to search for + the library instead of using the full path + (e.g. ``/usr/lib/libfoo.so`` becomes ``-lfoo``). + +* **A full path to a library file**: The generated link line will + normally preserve the full path to the file. The buildsystem will + have a dependency to re-link ``<target>`` if the library file changes. + + There are some cases where CMake may ask the linker to search for + the library (e.g. ``/usr/lib/libfoo.so`` becomes ``-lfoo``), such + as when a shared library is detected to have no ``SONAME`` field. + See policy :policy:`CMP0060` for discussion of another case. + + If the library file is in a Mac OSX framework, the ``Headers`` directory + of the framework will also be processed as a + :ref:`usage requirement <Target Usage Requirements>`. This has the same + effect as passing the framework directory as an include directory. + +* **A plain library name**: The generated link line will ask the linker + to search for the library (e.g. ``foo`` becomes ``-lfoo`` or ``foo.lib``). + +* **A link flag**: Item names starting with ``-``, but not ``-l`` or + ``-framework``, are treated as linker flags. Note that such flags will + be treated like any other library link item for purposes of transitive + dependencies, so they are generally safe to specify only as private link + items that will not propagate to dependents. + +* A ``debug``, ``optimized``, or ``general`` keyword immediately followed + by another ``<item>``. The item following such a keyword will be used + only for the corresponding build configuration. The ``debug`` keyword + corresponds to the ``Debug`` configuration (or to configurations named + in the :prop_gbl:`DEBUG_CONFIGURATIONS` global property if it is set). + The ``optimized`` keyword corresponds to all other configurations. The + ``general`` keyword corresponds to all configurations, and is purely + optional. Higher granularity may be achieved for per-configuration + rules by creating and linking to + :ref:`IMPORTED library targets <Imported Targets>`. + +Items containing ``::``, such as ``Foo::Bar``, are assumed to be +:ref:`IMPORTED <Imported Targets>` or :ref:`ALIAS <Alias Targets>` library +target names and will cause an error if no such target exists. +See policy :policy:`CMP0028`. + +Arguments to ``target_link_libraries`` may use "generator expressions" +with the syntax ``$<...>``. Note however, that generator expressions +will not be used in OLD handling of :policy:`CMP0003` or :policy:`CMP0004`. +See the :manual:`cmake-generator-expressions(7)` manual for available +expressions. See the :manual:`cmake-buildsystem(7)` manual for more on +defining buildsystem properties. + +Libraries for a Target and/or its Dependents +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:: + + target_link_libraries(<target> + <PRIVATE|PUBLIC|INTERFACE> <item>... + [<PRIVATE|PUBLIC|INTERFACE> <item>...]...) + +The ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` keywords can be used to +specify both the link dependencies and the link interface in one command. +Libraries and targets following ``PUBLIC`` are linked to, and are made +part of the link interface. Libraries and targets following ``PRIVATE`` +are linked to, but are not made part of the link interface. Libraries +following ``INTERFACE`` are appended to the link interface and are not +used for linking ``<target>``. + +Libraries for both a Target and its Dependents +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: - target_link_libraries(<target> [item1 [item2 [...]]] - [[debug|optimized|general] <item>] ...) - -Specify libraries or flags to use when linking a given target. The -named ``<target>`` must have been created in the current directory by a -command such as :command:`add_executable` or :command:`add_library`. The -remaining arguments specify library names or flags. Repeated calls for -the same ``<target>`` append items in the order called. - -If a library name matches that of another target in the project a -dependency will automatically be added in the build system to make sure -the library being linked is up-to-date before the target links. Item names -starting with ``-``, but not ``-l`` or ``-framework``, are treated as -linker flags. Note that such flags will be treated like any other library -link item for purposes of transitive dependencies, so they are generally -safe to specify only as private link items that will not propagate to -dependents of ``<target>``. - -A ``debug``, ``optimized``, or ``general`` keyword indicates that the -library immediately following it is to be used only for the -corresponding build configuration. The ``debug`` keyword corresponds to -the Debug configuration (or to configurations named in the -:prop_gbl:`DEBUG_CONFIGURATIONS` global property if it is set). The -``optimized`` keyword corresponds to all other configurations. The -``general`` keyword corresponds to all configurations, and is purely -optional (assumed if omitted). Higher granularity may be achieved for -per-configuration rules by creating and linking to -:ref:`IMPORTED library targets <Imported Targets>`. + target_link_libraries(<target> <item>...) Library dependencies are transitive by default with this signature. When this target is linked into another target then the libraries @@ -45,40 +120,34 @@ by setting the property directly. When :policy:`CMP0022` is not set to of this command may set the property making any libraries linked exclusively by this signature private. -CMake will also propagate :ref:`usage requirements <Target Usage Requirements>` -from linked library targets. Usage requirements of dependencies affect -compilation of sources in the ``<target>``. - -.. |INTERFACE_PROPERTY_LINK| replace:: :prop_tgt:`INTERFACE_LINK_LIBRARIES` -.. include:: /include/INTERFACE_LINK_LIBRARIES_WARNING.txt - -If an ``<item>`` is a library in a Mac OX framework, the ``Headers`` -directory of the framework will also be processed as a -:ref:`usage requirement <Target Usage Requirements>`. This has the same -effect as passing the framework directory as an include directory. - --------------------------------------------------------------------------- +Libraries for a Target and/or its Dependents (Legacy) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: target_link_libraries(<target> - <PRIVATE|PUBLIC|INTERFACE> <lib> ... - [<PRIVATE|PUBLIC|INTERFACE> <lib> ... ] ...]) + <LINK_PRIVATE|LINK_PUBLIC> <lib>... + [<LINK_PRIVATE|LINK_PUBLIC> <lib>...]...) -The ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` keywords can be used to -specify both the link dependencies and the link interface in one command. -Libraries and targets following ``PUBLIC`` are linked to, and are made -part of the link interface. Libraries and targets following ``PRIVATE`` -are linked to, but are not made part of the link interface. Libraries -following ``INTERFACE`` are appended to the link interface and are not -used for linking ``<target>``. +The ``LINK_PUBLIC`` and ``LINK_PRIVATE`` modes can be used to specify both +the link dependencies and the link interface in one command. + +This signature is for compatibility only. Prefer the ``PUBLIC`` or +``PRIVATE`` keywords instead. + +Libraries and targets following ``LINK_PUBLIC`` are linked to, and are +made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`. If policy +:policy:`CMP0022` is not ``NEW``, they are also made part of the +:prop_tgt:`LINK_INTERFACE_LIBRARIES`. Libraries and targets following +``LINK_PRIVATE`` are linked to, but are not made part of the +:prop_tgt:`INTERFACE_LINK_LIBRARIES` (or :prop_tgt:`LINK_INTERFACE_LIBRARIES`). --------------------------------------------------------------------------- +Libraries for Dependents Only (Legacy) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: - target_link_libraries(<target> LINK_INTERFACE_LIBRARIES - [[debug|optimized|general] <lib>] ...) + target_link_libraries(<target> LINK_INTERFACE_LIBRARIES <item>...) The ``LINK_INTERFACE_LIBRARIES`` mode appends the libraries to the :prop_tgt:`INTERFACE_LINK_LIBRARIES` target property instead of using them @@ -102,28 +171,8 @@ is not ``NEW``, they are also appended to the ``general`` (or without any keyword) are treated as if specified for both ``debug`` and ``optimized``. --------------------------------------------------------------------------- - -:: - - target_link_libraries(<target> - <LINK_PRIVATE|LINK_PUBLIC> - [[debug|optimized|general] <lib>] ... - [<LINK_PRIVATE|LINK_PUBLIC> - [[debug|optimized|general] <lib>] ...]) - -The ``LINK_PUBLIC`` and ``LINK_PRIVATE`` modes can be used to specify both -the link dependencies and the link interface in one command. - -This signature is for compatibility only. Prefer the ``PUBLIC`` or -``PRIVATE`` keywords instead. - -Libraries and targets following ``LINK_PUBLIC`` are linked to, and are -made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`. If policy -:policy:`CMP0022` is not ``NEW``, they are also made part of the -:prop_tgt:`LINK_INTERFACE_LIBRARIES`. Libraries and targets following -``LINK_PRIVATE`` are linked to, but are not made part of the -:prop_tgt:`INTERFACE_LINK_LIBRARIES` (or :prop_tgt:`LINK_INTERFACE_LIBRARIES`). +Cyclic Dependencies of Static Libraries +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The library dependency graph is normally acyclic (a DAG), but in the case of mutually-dependent ``STATIC`` libraries CMake allows the graph to @@ -142,14 +191,14 @@ For example, the code links ``main`` to ``A B A B``. While one repetition is usually sufficient, pathological object file and symbol arrangements can require -more. One may handle such cases by manually repeating the component in -the last ``target_link_libraries`` call. However, if two archives are -really so interdependent they should probably be combined into a single -archive. +more. One may handle such cases by using the +:prop_tgt:`LINK_INTERFACE_MULTIPLICITY` target property or by manually +repeating the component in the last ``target_link_libraries`` call. +However, if two archives are really so interdependent they should probably +be combined into a single archive, perhaps by using :ref:`Object Libraries`. -Arguments to target_link_libraries may use "generator expressions" -with the syntax ``$<...>``. Note however, that generator expressions -will not be used in OLD handling of :policy:`CMP0003` or :policy:`CMP0004`. -See the :manual:`cmake-generator-expressions(7)` manual for available -expressions. See the :manual:`cmake-buildsystem(7)` manual for more on -defining buildsystem properties. +Creating Relocatable Packages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. |INTERFACE_PROPERTY_LINK| replace:: :prop_tgt:`INTERFACE_LINK_LIBRARIES` +.. include:: /include/INTERFACE_LINK_LIBRARIES_WARNING.txt diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst index 43ee219..e3bd57d 100644 --- a/Help/command/try_run.rst +++ b/Help/command/try_run.rst @@ -73,7 +73,8 @@ When cross compiling, the executable compiled in the first step usually cannot be run on the build host. The ``try_run`` command checks the :variable:`CMAKE_CROSSCOMPILING` variable to detect whether CMake is in cross-compiling mode. If that is the case, it will still try to compile -the executable, but it will not try to run the executable. Instead it +the executable, but it will not try to run the executable unless the +:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable is set. Instead it will create cache variables which must be filled by the user or by presetting them in some CMake script file to the values the executable would have produced if it had been run on its actual target platform. diff --git a/Help/generator/Qbs.rst b/Help/generator/Qbs.rst new file mode 100644 index 0000000..e569b77 --- /dev/null +++ b/Help/generator/Qbs.rst @@ -0,0 +1,25 @@ +Qbs +--- + +Generates Qbs project files. + +Project files for Qbs 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. + +This "extra" generator may be specified as: + +``Qbs - MinGW Makefiles`` + Generate with :generator:`MinGW Makefiles`. + +``Qbs - NMake Makefiles`` + Generate with :generator:`NMake Makefiles`. + +``Qbs - Ninja`` + Generate with :generator:`Ninja`. + +``Qbs - Unix Makefiles`` + Generate with :generator:`Unix Makefiles`. diff --git a/Help/include/INTERFACE_INCLUDE_DIRECTORIES_WARNING.txt b/Help/include/INTERFACE_INCLUDE_DIRECTORIES_WARNING.txt index 33f7183..a54d728 100644 --- a/Help/include/INTERFACE_INCLUDE_DIRECTORIES_WARNING.txt +++ b/Help/include/INTERFACE_INCLUDE_DIRECTORIES_WARNING.txt @@ -1,30 +1,18 @@ Note that it is not advisable to populate the ``INSTALL_INTERFACE`` of the -|INTERFACE_PROPERTY_LINK| of a target with paths for dependencies. -That would hard-code into installed packages the include directory paths -for dependencies **as found on the machine the package was made on**. +|INTERFACE_PROPERTY_LINK| of a target with absolute paths to the include +directories of dependencies. That would hard-code into installed packages +the include directory paths for dependencies +**as found on the machine the package was made on**. The ``INSTALL_INTERFACE`` of the |INTERFACE_PROPERTY_LINK| is only -suitable for specifying the required include directories of the target itself, -not its dependencies. +suitable for specifying the required include directories for headers +provided with the target itself, not those provided by the transitive +dependencies listed in its :prop_tgt:`INTERFACE_LINK_LIBRARIES` target +property. Those dependencies should themselves be targets that specify +their own header locations in |INTERFACE_PROPERTY_LINK|. -That is, code like this is incorrect for targets which will be used to -generate :manual:`cmake-packages(7)`: - -.. code-block:: cmake - - target_include_directories(mylib INTERFACE - $<INSTALL_INTERFACE:${Boost_INCLUDE_DIRS};${OtherDep_INCLUDE_DIRS}> - ) - -Dependencies must provide their own :ref:`IMPORTED targets <Imported Targets>` -which have their own |INTERFACE_PROPERTY_LINK| populated -appropriately. Those :ref:`IMPORTED targets <Imported Targets>` may then be -used with the :command:`target_link_libraries` command for ``mylib``. - -That way, when a consumer uses the installed package, the -consumer will run the appropriate :command:`find_package` command to find -the dependencies on their own machine and populate the -:ref:`IMPORTED targets <Imported Targets>` with appropriate paths. See -:ref:`Creating Packages` for more. Note that many modules currently shipped -with CMake do not currently provide :ref:`IMPORTED targets <Imported Targets>`. +See the :ref:`Creating Relocatable Packages` section of the +:manual:`cmake-packages(7)` manual for discussion of additional care +that must be taken when specifying usage requirements while creating +packages for redistribution. diff --git a/Help/include/INTERFACE_LINK_LIBRARIES_WARNING.txt b/Help/include/INTERFACE_LINK_LIBRARIES_WARNING.txt index ceefa4d..46e84ac 100644 --- a/Help/include/INTERFACE_LINK_LIBRARIES_WARNING.txt +++ b/Help/include/INTERFACE_LINK_LIBRARIES_WARNING.txt @@ -1,23 +1,10 @@ Note that it is not advisable to populate the -|INTERFACE_PROPERTY_LINK| of a target with paths for dependencies. -That would hard-code into installed packages the include directory paths +|INTERFACE_PROPERTY_LINK| of a target with absolute paths to dependencies. +That would hard-code into installed packages the library file paths for dependencies **as found on the machine the package was made on**. -That is, code like this is incorrect for targets which will be used to -generate :manual:`cmake-packages(7)`: - -.. code-block:: cmake - - target_link_libraries(mylib INTERFACE - ${Boost_LIBRARIES};${OtherDep_LIBRARIES} - ) - -Dependencies must provide their own :ref:`IMPORTED targets <Imported Targets>` -which have their own :prop_tgt:`IMPORTED_LOCATION` populated -appropriately. That way, when a consumer uses the installed package, the -consumer will run the appropriate :command:`find_package` command to find -the dependencies on their own machine and populate the -:ref:`IMPORTED targets <Imported Targets>` with appropriate paths. See -:ref:`Creating Packages` for more. Note that many modules currently shipped -with CMake do not currently provide :ref:`IMPORTED targets <Imported Targets>`. +See the :ref:`Creating Relocatable Packages` section of the +:manual:`cmake-packages(7)` manual for discussion of additional care +that must be taken when specifying usage requirements while creating +packages for redistribution. diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index 363d0aa..e4c5873 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -10,7 +10,7 @@ containing SET commands that use the CACHE option, not a cache-format file. -``-D <var>:<type>=<value>`` +``-D <var>:<type>=<value>, -D <var>=<value>`` Create a cmake cache entry. When cmake is first run in an empty build tree, it creates a @@ -19,6 +19,14 @@ takes priority over the project's default value. The option may be repeated for as many cache entries as desired. + If the ``:<type>`` portion is given it must be one of the types + specified by the :command:`set` command documentation for its + ``CACHE`` signature. + If the ``:<type>`` portion is omitted the entry will be created + with no type if it does not exist with a type already. If a + command in the project sets the type to ``PATH`` or ``FILEPATH`` + then the ``<value>`` will be converted to an absolute path. + ``-U <globbing_expr>`` Remove matching entries from CMake cache. @@ -35,7 +43,7 @@ CMake may support multiple native build systems on certain platforms. A generator is responsible for generating a particular build system. Possible generator names are specified in the - Generators section. + :manual:`cmake-generators(7)` manual. ``-T <toolset-name>`` Specify toolset name if supported by generator. diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index 002f2c2..ae5e58e 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -143,6 +143,11 @@ use particular :prop_tgt:`COMPILE_OPTIONS` or the properties must be **requirements**, not merely recommendations or convenience. +See the :ref:`Creating Relocatable Packages` section of the +:manual:`cmake-packages(7)` manual for discussion of additional care +that must be taken when specifying usage requirements while creating +packages for redistribution. + Target Properties ----------------- diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 7a6c249..46a5afb 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -295,3 +295,17 @@ the feature-appropriate include directory add_executable(consumer_no consumer_no.cpp) target_link_libraries(consumer_no foo) + +Supported Compilers +=================== + +CMake is currently aware of the :prop_tgt:`language standards <CXX_STANDARD>` +and :prop_gbl:`compile features <CMAKE_CXX_KNOWN_FEATURES>` available from +the following :variable:`compiler ids <CMAKE_<LANG>_COMPILER_ID>` as of the +versions specified for each: + +* ``AppleClang``: Apple Clang for Xcode versions 4.4 though 6.2. +* ``Clang``: Clang compiler versions 2.9 through 3.4. +* ``GNU``: GNU compiler versions 4.4 through 5.0. +* ``MSVC``: Microsoft Visual Studio versions 2010 through 2015. +* ``SunPro``: Oracle SolarisStudio version 12.4. diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 7bffa42..ab74140 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -605,6 +605,7 @@ have a .cmake file in this directory NOT show up in the modules documentation, simply leave out the ``Help/module/<module-name>.rst`` file and the ``Help/manual/cmake-modules.7.rst`` toctree entry. +.. _`Find Modules`: Find Modules ------------ diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 477a132..189c3ef 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -88,7 +88,7 @@ Available logical expressions are: increases the required :prop_tgt:`C_STANDARD` or :prop_tgt:`CXX_STANDARD` for the 'head' target, an error is reported. See the :manual:`cmake-compile-features(7)` manual for information on - compile features. + compile features and a list of supported compilers. ``$<COMPILE_LANGUAGE:lang>`` ``1`` when the language used for compilation unit matches ``lang``, otherwise ``0``. This expression used to specify compile options for diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index bda7eef..6f76fb1 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -34,6 +34,11 @@ 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. +.. _`Makefile Generators`: + +Makefile Generators +^^^^^^^^^^^^^^^^^^^ + .. toctree:: :maxdepth: 1 @@ -42,10 +47,17 @@ already configured for the chosen compiler and build tool. /generator/MinGW Makefiles /generator/NMake Makefiles /generator/NMake Makefiles JOM - /generator/Ninja /generator/Unix Makefiles /generator/Watcom WMake +Ninja Generator +^^^^^^^^^^^^^^^ + +.. toctree:: + :maxdepth: 1 + + /generator/Ninja + IDE Build Tool Generators ------------------------- @@ -53,6 +65,11 @@ These generators support Integrated Development Environment (IDE) project files. Since the IDEs configure their own environment one may launch CMake from any environment. +.. _`Visual Studio Generators`: + +Visual Studio Generators +^^^^^^^^^^^^^^^^^^^^^^^^ + .. toctree:: :maxdepth: 1 @@ -65,6 +82,13 @@ one may launch CMake from any environment. /generator/Visual Studio 11 2012 /generator/Visual Studio 12 2013 /generator/Visual Studio 14 2015 + +Xcode Generator +^^^^^^^^^^^^^^^ + +.. toctree:: + :maxdepth: 1 + /generator/Xcode Extra Generators @@ -85,3 +109,4 @@ The following extra generators are known to CMake. /generator/KDevelop3 /generator/Kate /generator/Sublime Text 2 + /generator/Qbs diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index 3e0297c..41542c9 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -485,6 +485,8 @@ The :command:`macro`/:command:`endmacro`, and :command:`function`/:command:`endfunction` commands delimit code blocks to be recorded for later invocation as commands. +.. _`CMake Language Variables`: + Variables ========= @@ -538,6 +540,8 @@ The :manual:`cmake-variables(7)` manual documents many variables that are provided by CMake or have meaning to CMake when set by project code. +.. _`CMake Language Lists`: + Lists ===== diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 2b26cc9..c9219d5 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -212,6 +212,7 @@ All Modules /module/FindWish /module/FindwxWidgets /module/FindwxWindows + /module/FindXCTest /module/FindXercesC /module/FindX11 /module/FindXMLRPC diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst index 3367ba4..b9073a5 100644 --- a/Help/manual/cmake-packages.7.rst +++ b/Help/manual/cmake-packages.7.rst @@ -373,38 +373,6 @@ attempt to use version 3 together with version 4. Packages can choose to employ such a pattern if different major versions of the package are designed to be incompatible. -Note that it is not advisable to populate any properties which may contain -paths, such as :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` and -:prop_tgt:`INTERFACE_LINK_LIBRARIES`, with paths relevnt to dependencies. -That would hard-code into installed packages the include directory or library -paths for dependencies **as found on the machine the package was made on**. - -That is, code like this is incorrect for targets which will be used to -generate config file packages: - -.. code-block:: cmake - - target_link_libraries(ClimbingStats INTERFACE - ${Boost_LIBRARIES};${OtherDep_LIBRARIES}> - ) - target_include_directories(ClimbingStats INTERFACE - $<INSTALL_INTERFACE:${Boost_INCLUDE_DIRS};${OtherDep_INCLUDE_DIRS}> - ) - -Dependencies must provide their own :ref:`IMPORTED targets <Imported Targets>` -which have their own :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` and -:prop_tgt:`IMPORTED_LOCATION` populated appropriately. Those -:ref:`IMPORTED targets <Imported Targets>` may then be -used with the :command:`target_link_libraries` command for ``ClimbingStats``. - -That way, when a consumer uses the installed package, the -consumer will run the appropriate :command:`find_package` command (via the -find_dependency macro described below) to find -the dependencies on their own machine and populate the -:ref:`IMPORTED targets <Imported Targets>` with appropriate paths. Note that -many modules currently shipped with CMake do not currently provide -:ref:`IMPORTED targets <Imported Targets>`. - A ``NAMESPACE`` with double-colons is specified when exporting the targets for installation. This convention of double-colons gives CMake a hint that the name is an :prop_tgt:`IMPORTED` target when it is used by downstreams @@ -418,6 +386,9 @@ directory in the :variable:`CMAKE_INSTALL_PREFIX`. When the ``IMPORTED`` target is used by downsteam, it automatically consumes the entries from that property. +Creating a Package Configuration File +------------------------------------- + In this case, the ``ClimbingStatsConfig.cmake`` file could be as simple as: .. code-block:: cmake @@ -429,44 +400,6 @@ should be provided by the ``ClimbingStats`` package, they should be in a separate file which is installed to the same location as the ``ClimbingStatsConfig.cmake`` file, and included from there. -Packages created by :command:`install(EXPORT)` are designed to be relocatable, -using paths relative to the location of the package itself. When defining -the interface of a target for ``EXPORT``, keep in mind that the include -directories should be specified as relative paths which are relative to the -:variable:`CMAKE_INSTALL_PREFIX`: - -.. code-block:: cmake - - target_include_directories(tgt INTERFACE - # Wrong, not relocatable: - $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/TgtName> - ) - - target_include_directories(tgt INTERFACE - # Ok, relocatable: - $<INSTALL_INTERFACE:include/TgtName> - ) - -The ``$<INSTALL_PREFIX>`` -:manual:`generator expression <cmake-generator-expressions(7)>` may be used as -a placeholder for the install prefix without resulting in a non-relocatable -package. This is necessary if complex generator expressions are used: - -.. code-block:: cmake - - target_include_directories(tgt INTERFACE - # Ok, relocatable: - $<INSTALL_INTERFACE:$<$<CONFIG:Debug>:$<INSTALL_PREFIX>/include/TgtName>> - ) - -The :command:`export(EXPORT)` command creates an :prop_tgt:`IMPORTED` targets -definition file which is specific to the build-tree, and is not relocatable. -This can similiarly be used with a suitable package configuration file and -package version file to define a package for the build tree which may be used -without installation. Consumers of the build tree can simply ensure that the -:variable:`CMAKE_PREFIX_PATH` contains the build directory, or set the -``ClimbingStats_DIR`` to ``<build_dir>/ClimbingStats`` in the cache. - This can also be extended to cover dependencies: .. code-block:: cmake @@ -526,6 +459,111 @@ could not be found because an invalid component was specified. This message variable can be set for any case where the ``_FOUND`` variable is set to ``False``, and will be displayed to the user. +Creating a Package Configuration File for the Build Tree +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The :command:`export(EXPORT)` command creates an :prop_tgt:`IMPORTED` targets +definition file which is specific to the build-tree, and is not relocatable. +This can similiarly be used with a suitable package configuration file and +package version file to define a package for the build tree which may be used +without installation. Consumers of the build tree can simply ensure that the +:variable:`CMAKE_PREFIX_PATH` contains the build directory, or set the +``ClimbingStats_DIR`` to ``<build_dir>/ClimbingStats`` in the cache. + +.. _`Creating Relocatable Packages`: + +Creating Relocatable Packages +----------------------------- + +A relocatable package must not reference absolute paths of files on +the machine where the package is built that will not exist on the +machines where the package may be installed. + +Packages created by :command:`install(EXPORT)` are designed to be relocatable, +using paths relative to the location of the package itself. When defining +the interface of a target for ``EXPORT``, keep in mind that the include +directories should be specified as relative paths which are relative to the +:variable:`CMAKE_INSTALL_PREFIX`: + +.. code-block:: cmake + + target_include_directories(tgt INTERFACE + # Wrong, not relocatable: + $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/TgtName> + ) + + target_include_directories(tgt INTERFACE + # Ok, relocatable: + $<INSTALL_INTERFACE:include/TgtName> + ) + +The ``$<INSTALL_PREFIX>`` +:manual:`generator expression <cmake-generator-expressions(7)>` may be used as +a placeholder for the install prefix without resulting in a non-relocatable +package. This is necessary if complex generator expressions are used: + +.. code-block:: cmake + + target_include_directories(tgt INTERFACE + # Ok, relocatable: + $<INSTALL_INTERFACE:$<$<CONFIG:Debug>:$<INSTALL_PREFIX>/include/TgtName>> + ) + +This also applies to paths referencing external dependencies. +It is not advisable to populate any properties which may contain +paths, such as :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` and +:prop_tgt:`INTERFACE_LINK_LIBRARIES`, with paths relevant to dependencies. +For example, this code may not work well for a relocatable package: + +.. code-block:: cmake + + target_link_libraries(ClimbingStats INTERFACE + ${Foo_LIBRARIES} ${Bar_LIBRARIES} + ) + target_include_directories(ClimbingStats INTERFACE + "$<INSTALL_INTERFACE:${Foo_INCLUDE_DIRS};${Bar_INCLUDE_DIRS}>" + ) + +The referenced variables may contain the absolute paths to libraries +and include directories **as found on the machine the package was made on**. +This would create a package with hard-coded paths to dependencies and not +suitable for relocation. + +Ideally such dependencies should be used through their own +:ref:`IMPORTED targets <Imported Targets>` that have their own +:prop_tgt:`IMPORTED_LOCATION` and usage requirement properties +such as :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` populated +appropriately. Those imported targets may then be used with +the :command:`target_link_libraries` command for ``ClimbingStats``: + +.. code-block:: cmake + + target_link_libraries(ClimbingStats INTERFACE Foo::Foo Bar::Bar) + +With this approach the package references its external dependencies +only through the names of :ref:`IMPORTED targets <Imported Targets>`. +When a consumer uses the installed package, the consumer will run the +appropriate :command:`find_package` commands (via the ``find_dependency`` +macro described above) to find the dependencies and populate the +imported targets with appropriate paths on their own machine. + +Unfortunately many :manual:`modules <cmake-modules(7)>` shipped with +CMake do not yet provide :ref:`IMPORTED targets <Imported Targets>` +because their development pre-dated this approach. This may improve +incrementally over time. Workarounds to create relocatable packages +using such modules include: + +* When building the package, specify each ``Foo_LIBRARY`` cache + entry as just a library name, e.g. ``-DFoo_LIBRARY=foo``. This + tells the corresponding find module to populate the ``Foo_LIBRARIES`` + with just ``foo`` to ask the linker to search for the library + instead of hard-coding a path. + +* Or, after installing the package content but before creating the + package installation binary for redistribution, manually replace + the absolute paths with placeholders for substitution by the + installation tool when the package is installed. + .. _`Package Registry`: Package Registry diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 76ca5d4..aff696d 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -115,3 +115,6 @@ All Policies /policy/CMP0055 /policy/CMP0056 /policy/CMP0057 + /policy/CMP0058 + /policy/CMP0059 + /policy/CMP0060 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 19fdf23..02d164b 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -7,6 +7,8 @@ cmake-properties(7) .. contents:: +.. _`Global Properties`: + Properties of Global Scope ========================== @@ -41,6 +43,8 @@ Properties of Global Scope /prop_gbl/TARGET_SUPPORTS_SHARED_LIBS /prop_gbl/USE_FOLDERS +.. _`Directory Properties`: + Properties on Directories ========================= @@ -72,6 +76,8 @@ Properties on Directories /prop_dir/VS_GLOBAL_SECTION_POST_section /prop_dir/VS_GLOBAL_SECTION_PRE_section +.. _`Target Properties`: + Properties on Targets ===================== @@ -113,6 +119,7 @@ Properties on Targets /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX + /prop_tgt/CROSSCOMPILING_EMULATOR /prop_tgt/CXX_EXTENSIONS /prop_tgt/CXX_STANDARD /prop_tgt/CXX_STANDARD_REQUIRED @@ -243,6 +250,9 @@ Properties on Targets /prop_tgt/VS_WINRT_REFERENCES /prop_tgt/WIN32_EXECUTABLE /prop_tgt/XCODE_ATTRIBUTE_an-attribute + /prop_tgt/XCTEST + +.. _`Test Properties`: Properties on Tests =================== @@ -268,6 +278,8 @@ Properties on Tests /prop_test/WILL_FAIL /prop_test/WORKING_DIRECTORY +.. _`Source File Properties`: + Properties on Source Files ========================== @@ -297,10 +309,13 @@ Properties on Source Files /prop_sf/VS_SHADER_FLAGS /prop_sf/VS_SHADER_MODEL /prop_sf/VS_SHADER_TYPE + /prop_sf/VS_XAML_TYPE /prop_sf/WRAP_EXCLUDE /prop_sf/XCODE_EXPLICIT_FILE_TYPE /prop_sf/XCODE_LAST_KNOWN_FILE_TYPE +.. _`Cache Entry Properties`: + Properties on Cache Entries =========================== @@ -314,6 +329,8 @@ Properties on Cache Entries /prop_cache/TYPE /prop_cache/VALUE +.. _`Installed File Properties`: + Properties on Installed Files ============================= @@ -329,7 +346,7 @@ Properties on Installed Files Deprecated Properties on Directories -===================================== +==================================== .. toctree:: :maxdepth: 1 diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index c342dbe..63f704d 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -25,6 +25,7 @@ Variables that Provide Information /variable/CMAKE_CFG_INTDIR /variable/CMAKE_COMMAND /variable/CMAKE_CROSSCOMPILING + /variable/CMAKE_CROSSCOMPILING_EMULATOR /variable/CMAKE_CTEST_COMMAND /variable/CMAKE_CURRENT_BINARY_DIR /variable/CMAKE_CURRENT_LIST_DIR diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index cc132c2..dd3bcfb 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -194,6 +194,11 @@ Options subsequent calls to ctest with the --rerun-failed option will run the set of tests that most recently failed (if any). +``--repeat-until-fail <n>`` + Require each test to run ``<n>`` times without failing in order to pass. + + This is useful in finding sporadic failures in test cases. + ``--max-width <width>`` Set the max width for a test name to output diff --git a/Help/module/FindXCTest.rst b/Help/module/FindXCTest.rst new file mode 100644 index 0000000..ff6273c --- /dev/null +++ b/Help/module/FindXCTest.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindXCTest.cmake diff --git a/Help/policy/CMP0058.rst b/Help/policy/CMP0058.rst new file mode 100644 index 0000000..0f20383 --- /dev/null +++ b/Help/policy/CMP0058.rst @@ -0,0 +1,108 @@ +CMP0058 +------- + +Ninja requires custom command byproducts to be explicit. + +When an intermediate file generated during the build is consumed +by an expensive operation or a large tree of dependents, one may +reduce the work needed for an incremental rebuild by updating the +file timestamp only when its content changes. With this approach +the generation rule must have a separate output file that is always +updated with a new timestamp that is newer than any dependencies of +the rule so that the build tool re-runs the rule only when the input +changes. We refer to the separate output file as a rule's *witness* +and the generated file as a rule's *byproduct*. + +Byproducts may not be listed as outputs because their timestamps are +allowed to be older than the inputs. No build tools (like ``make``) +that existed when CMake was designed have a way to express byproducts. +Therefore CMake versions prior to 3.2 had no way to specify them. +Projects typically left byproducts undeclared in the rules that +generate them. For example: + +.. code-block:: cmake + + add_custom_command( + OUTPUT witness.txt + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/input.txt + byproduct.txt # timestamp may not change + COMMAND ${CMAKE_COMMAND} -E touch witness.txt + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/input.txt + ) + add_custom_target(Provider DEPENDS witness.txt) + add_custom_command( + OUTPUT generated.c + COMMAND expensive-task -i byproduct.txt -o generated.c + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/byproduct.txt + ) + add_library(Consumer generated.c) + add_dependencies(Consumer Provider) + +This works well for all generators except :generator:`Ninja`. +The Ninja build tool sees a rule listing ``byproduct.txt`` +as a dependency and no rule listing it as an output. Ninja then +complains that there is no way to satisfy the dependency and +stops building even though there are order-only dependencies +that ensure ``byproduct.txt`` will exist before its consumers +need it. See discussion of this problem in `Ninja Issue 760`_ +for further details on why Ninja works this way. + +.. _`Ninja Issue 760`: https://github.com/martine/ninja/issues/760 + +Instead of leaving byproducts undeclared in the rules that generate +them, Ninja expects byproducts to be listed along with other outputs. +Such rules may be marked with a ``restat`` option that tells Ninja +to check the timestamps of outputs after the rules run. This +prevents byproducts whose timestamps do not change from causing +their dependents to re-build unnecessarily. + +Since the above approach does not tell CMake what custom command +generates ``byproduct.txt``, the Ninja generator does not have +enough information to add the byproduct as an output of any rule. +CMake 2.8.12 and above work around this problem and allow projects +using the above approach to build by generating ``phony`` build +rules to tell Ninja to tolerate such missing files. However, this +workaround prevents Ninja from diagnosing a dependency that is +really missing. It also works poorly in in-source builds where +every custom command dependency, even on source files, needs to +be treated this way because CMake does not have enough information +to know which files are generated as byproducts of custom commands. + +CMake 3.2 introduced the ``BYPRODUCTS`` option to the +:command:`add_custom_command` and :command:`add_custom_target` +commands. This option allows byproducts to be specified explicitly: + +.. code-block:: cmake + + add_custom_command( + OUTPUT witness.txt + BYPRODUCTS byproduct.txt # explicit byproduct specification + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/input.txt + byproduct.txt # timestamp may not change + ... + +The ``BYPRODUCTS`` option is used by the :generator:`Ninja` generator +to list byproducts among the outputs of the custom commands that +generate them, and is ignored by other generators. + +CMake 3.3 and above prefer to require projects to specify custom +command byproducts explicitly so that it can avoid using the +``phony`` rule workaround altogether. Policy ``CMP0058`` was +introduced to provide compatibility with existing projects that +still need the workaround. + +This policy has no effect on generators other than :generator:`Ninja`. +The ``OLD`` behavior for this policy is to generate Ninja ``phony`` +rules for unknown dependencies in the build tree. The ``NEW`` +behavior for this policy is to not generate these and instead +require projects to specify custom command ``BYPRODUCTS`` explicitly. + +This policy was introduced in CMake version 3.3. +CMake version |release| warns when it sees unknown dependencies in +out-of-source build trees if the policy is not set and then uses +``OLD`` behavior. Use the :command:`cmake_policy` command to set +the policy to ``OLD`` or ``NEW`` explicitly. The policy setting +must be in scope at the end of the top-level ``CMakeLists.txt`` +file of the project and has global effect. diff --git a/Help/policy/CMP0059.rst b/Help/policy/CMP0059.rst new file mode 100644 index 0000000..e40f450 --- /dev/null +++ b/Help/policy/CMP0059.rst @@ -0,0 +1,17 @@ +CMP0059 +------- + +Don't treat ``DEFINITIONS`` as a built-in directory property. + +CMake 3.3 and above no longer make a list of definitions available through +the :prop_dir:`DEFINITIONS` directory property. The +:prop_dir:`COMPILE_DEFINITIONS` directory property may be used instead. + +The ``OLD`` behavior for this policy is to provide the list of flags given +so far to the :command:`add_definitions` command. The ``NEW`` behavior is +to behave as a normal user-defined directory property. + +This policy was introduced in CMake version 3.3. +CMake version |release| warns when the policy is not set and uses +``OLD`` behavior. Use the :command:`cmake_policy` command to set +it to ``OLD`` or ``NEW`` explicitly. diff --git a/Help/policy/CMP0060.rst b/Help/policy/CMP0060.rst new file mode 100644 index 0000000..cc37b1b --- /dev/null +++ b/Help/policy/CMP0060.rst @@ -0,0 +1,63 @@ +CMP0060 +------- + +Link libraries by full path even in implicit directories. + +Policy :policy:`CMP0003` was introduced with the intention of always +linking library files by full path when a full path is given to the +:command:`target_link_libraries` command. However, on some platforms +(e.g. HP-UX) the compiler front-end adds alternative library search paths +for the current architecture (e.g. ``/usr/lib/<arch>`` has alternatives +to libraries in ``/usr/lib`` for the current architecture). +On such platforms the :command:`find_library` may find a library such as +``/usr/lib/libfoo.so`` that does not belong to the current architecture. + +Prior to policy :policy:`CMP0003` projects would still build in such +cases because the incorrect library path would be converted to ``-lfoo`` +on the link line and the linker would find the proper library in the +arch-specific search path provided by the compiler front-end implicitly. +At the time we chose to remain compatible with such projects by always +converting library files found in implicit link directories to ``-lfoo`` +flags to ask the linker to search for them. This approach allowed existing +projects to continue to build while still linking to libraries outside +implicit link directories via full path (such as those in the build tree). + +CMake does allow projects to override this behavior by using an +:ref:`IMPORTED library target <Imported Targets>` with its +:prop_tgt:`IMPORTED_LOCATION` property set to the desired full path to +a library file. In fact, many :ref:`Find Modules` are learning to provide +:ref:`Imported Targets` instead of just the traditional ``Foo_LIBRARIES`` +variable listing library files. However, this makes the link line +generated for a library found by a Find Module depend on whether it +is linked through an imported target or not, which is inconsistent. +Furthermore, this behavior has been a source of confusion because the +generated link line for a library file depends on its location. It is +also problematic for projects trying to link statically because flags +like ``-Wl,-Bstatic -lfoo -Wl,-Bdynamic`` may be used to help the linker +select ``libfoo.a`` instead of ``libfoo.so`` but then leak dynamic linking +to following libraries. (See the :prop_tgt:`LINK_SEARCH_END_STATIC` +target property for a solution typically used for that problem.) + +When the special case for libraries in implicit link directories was first +introduced the list of implicit link directories was simply hard-coded +(e.g. ``/lib``, ``/usr/lib``, and a few others). Since that time, CMake +has learned to detect the implicit link directories used by the compiler +front-end. If necessary, the :command:`find_library` command could be +taught to use this information to help find libraries of the proper +architecture. + +For these reasons, CMake 3.3 and above prefer to drop the special case +and link libraries by full path even when they are in implicit link +directories. Policy ``CMP0060`` provides compatibility for existing +projects. + +The OLD behavior for this policy is to ask the linker to search for +libraries whose full paths are known to be in implicit link directories. +The NEW behavior for this policy is to link libraries by full path even +if they are in implicit link directories. + +This policy was introduced in CMake version 3.3. Unlike most policies, +CMake version |release| does *not* warn by default when this policy +is not set and simply uses OLD behavior. See documentation of the +:variable:`CMAKE_POLICY_WARNING_CMP0060 <CMAKE_POLICY_WARNING_CMP<NNNN>>` +variable to control the warning. diff --git a/Help/prop_dir/COMPILE_OPTIONS.rst b/Help/prop_dir/COMPILE_OPTIONS.rst index 5530860..877deb0 100644 --- a/Help/prop_dir/COMPILE_OPTIONS.rst +++ b/Help/prop_dir/COMPILE_OPTIONS.rst @@ -3,8 +3,8 @@ COMPILE_OPTIONS List of options to pass to the compiler. -This property specifies the list of options given so far to the -:command:`add_compile_options` command. +This property holds a :ref:`;-list <CMake Language Lists>` of options +given so far to the :command:`add_compile_options` command. This property is used to initialize the :prop_tgt:`COMPILE_OPTIONS` target property when a target is created, which is used by the generators to set diff --git a/Help/prop_dir/DEFINITIONS.rst b/Help/prop_dir/DEFINITIONS.rst index 22f7c15..79ac3f3 100644 --- a/Help/prop_dir/DEFINITIONS.rst +++ b/Help/prop_dir/DEFINITIONS.rst @@ -1,8 +1,13 @@ DEFINITIONS ----------- -For CMake 2.4 compatibility only. Use COMPILE_DEFINITIONS instead. +For CMake 2.4 compatibility only. Use :prop_dir:`COMPILE_DEFINITIONS` +instead. This read-only property specifies the list of flags given so far to -the add_definitions command. It is intended for debugging purposes. -Use the COMPILE_DEFINITIONS instead. +the :command:`add_definitions` command. It is intended for debugging +purposes. Use the :prop_dir:`COMPILE_DEFINITIONS` directory property +instead. + +This built-in read-only property does not exist if policy +:policy:`CMP0059` is set to ``NEW``. diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst index 163ae34..3db4f18 100644 --- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst @@ -9,7 +9,7 @@ be listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable. The features listed here may be used with the :command:`target_compile_features` command. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. The features known to this version of CMake are: diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst index 18cd030..a08af00 100644 --- a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst @@ -9,7 +9,7 @@ be listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable. The features listed here may be used with the :command:`target_compile_features` command. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. The features known to this version of CMake are: diff --git a/Help/prop_sf/VS_XAML_TYPE.rst b/Help/prop_sf/VS_XAML_TYPE.rst new file mode 100644 index 0000000..e92191d --- /dev/null +++ b/Help/prop_sf/VS_XAML_TYPE.rst @@ -0,0 +1,6 @@ +VS_XAML_TYPE +------------ + +Mark a XAML source file as a different type than the default ``Page``. +The most common usage would be to set the default App.xaml file as +ApplicationDefinition. diff --git a/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst b/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst index b02d17d..facf902 100644 --- a/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst +++ b/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst @@ -4,5 +4,12 @@ FAIL_REGULAR_EXPRESSION If the output matches this regular expression the test will fail. If set, if the output matches one of specified regular expressions, -the test will fail.For example: FAIL_REGULAR_EXPRESSION -"[^a-z]Error;ERROR;Failed" +the test will fail. Example: + +.. code-block:: cmake + + set_tests_properties(mytest PROPERTIES + FAIL_REGULAR_EXPRESSION "[^a-z]Error;ERROR;Failed" + ) + +``FAIL_REGULAR_EXPRESSION`` expects a list of regular expressions. diff --git a/Help/prop_test/PASS_REGULAR_EXPRESSION.rst b/Help/prop_test/PASS_REGULAR_EXPRESSION.rst index bb35f77..0cd6215 100644 --- a/Help/prop_test/PASS_REGULAR_EXPRESSION.rst +++ b/Help/prop_test/PASS_REGULAR_EXPRESSION.rst @@ -5,4 +5,12 @@ The output must match this regular expression for the test to pass. If set, the test output will be checked against the specified regular expressions and at least one of the regular expressions has to match, -otherwise the test will fail. +otherwise the test will fail. Example: + +.. code-block:: cmake + + set_tests_properties(mytest PROPERTIES + PASS_REGULAR_EXPRESSION "TestPassed;All ok" + ) + +``PASS_REGULAR_EXPRESSION`` expects a list of regular expressions. diff --git a/Help/prop_tgt/COMPILE_FEATURES.rst b/Help/prop_tgt/COMPILE_FEATURES.rst index 225ffee..195215e 100644 --- a/Help/prop_tgt/COMPILE_FEATURES.rst +++ b/Help/prop_tgt/COMPILE_FEATURES.rst @@ -9,4 +9,4 @@ in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable. Contents of ``COMPILE_FEATURES`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-compile-features(7)` manual -for information on compile features. +for information on compile features and a list of supported compilers. diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst index 27cbec1..36d786a 100644 --- a/Help/prop_tgt/COMPILE_OPTIONS.rst +++ b/Help/prop_tgt/COMPILE_OPTIONS.rst @@ -3,12 +3,13 @@ COMPILE_OPTIONS List of options to pass to the compiler. -This property specifies the list of options specified so far for this -property. +This property holds a :ref:`;-list <CMake Language Lists>` of options +specified so far for its target. Use the :command:`target_compile_options` +command to append more options. This property is intialized by the :prop_dir:`COMPILE_OPTIONS` directory -property, which is used by the generators to set the options for the -compiler. +property when a target is created, and is used by the generators to set +the options for the compiler. Contents of ``COMPILE_OPTIONS`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual diff --git a/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst new file mode 100644 index 0000000..3ef8e03 --- /dev/null +++ b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst @@ -0,0 +1,6 @@ +CROSSCOMPILING_EMULATOR +----------------------- + +Use the given emulator to run executables created when crosscompiling. This +command will be added as a prefix to :command:`add_test` test commands for +built target system executables. diff --git a/Help/prop_tgt/CXX_EXTENSIONS.rst b/Help/prop_tgt/CXX_EXTENSIONS.rst index 67c5cb0..0f547e2 100644 --- a/Help/prop_tgt/CXX_EXTENSIONS.rst +++ b/Help/prop_tgt/CXX_EXTENSIONS.rst @@ -9,7 +9,7 @@ as ``-std=gnu++11`` instead of ``-std=c++11`` to the compile line. This property is ``ON`` by default. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. This property is initialized by the value of the :variable:`CMAKE_CXX_EXTENSIONS` variable if it is set when a target diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst index 65b30ec..edc9ba5 100644 --- a/Help/prop_tgt/CXX_STANDARD.rst +++ b/Help/prop_tgt/CXX_STANDARD.rst @@ -24,7 +24,7 @@ flag will not result in an error or warning, but will instead add the with the :prop_tgt:`CXX_STANDARD_REQUIRED` target property. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. This property is initialized by the value of the :variable:`CMAKE_CXX_STANDARD` variable if it is set when a target diff --git a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst index 4e24e5e..697d7f6 100644 --- a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst @@ -11,7 +11,7 @@ not available. For compilers that have no notion of a standard level, such as MSVC, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. This property is initialized by the value of the :variable:`CMAKE_CXX_STANDARD_REQUIRED` variable if it is set when a diff --git a/Help/prop_tgt/C_EXTENSIONS.rst b/Help/prop_tgt/C_EXTENSIONS.rst index dc48cc6..fce67f4 100644 --- a/Help/prop_tgt/C_EXTENSIONS.rst +++ b/Help/prop_tgt/C_EXTENSIONS.rst @@ -9,7 +9,7 @@ as ``-std=gnu11`` instead of ``-std=c11`` to the compile line. This property is ``ON`` by default. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. This property is initialized by the value of the :variable:`CMAKE_C_EXTENSIONS` variable if it is set when a target diff --git a/Help/prop_tgt/C_STANDARD.rst b/Help/prop_tgt/C_STANDARD.rst index 3aa74af..5e36821 100644 --- a/Help/prop_tgt/C_STANDARD.rst +++ b/Help/prop_tgt/C_STANDARD.rst @@ -24,7 +24,7 @@ flag will not result in an error or warning, but will instead add the be controlled with the :prop_tgt:`C_STANDARD_REQUIRED` target property. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. This property is initialized by the value of the :variable:`CMAKE_C_STANDARD` variable if it is set when a target diff --git a/Help/prop_tgt/C_STANDARD_REQUIRED.rst b/Help/prop_tgt/C_STANDARD_REQUIRED.rst index 743d568..acfad98 100644 --- a/Help/prop_tgt/C_STANDARD_REQUIRED.rst +++ b/Help/prop_tgt/C_STANDARD_REQUIRED.rst @@ -11,7 +11,7 @@ not available. For compilers that have no notion of a standard level, such as MSVC, this has no effect. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. This property is initialized by the value of the :variable:`CMAKE_C_STANDARD_REQUIRED` variable if it is set when a diff --git a/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst index 8dfec5f..31b594f 100644 --- a/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst +++ b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst @@ -9,4 +9,4 @@ INTERFACE_COMPILE_FEATURES .. include:: INTERFACE_BUILD_PROPERTY.txt See the :manual:`cmake-compile-features(7)` manual for information on compile -features. +features and a list of supported compilers. diff --git a/Help/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.rst b/Help/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.rst index 1cfd7a8..b1c40b2 100644 --- a/Help/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.rst +++ b/Help/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.rst @@ -22,5 +22,8 @@ installation prefix. For example: $<INSTALL_INTERFACE:include/mylib> # <prefix>/include/mylib ) +Creating Relocatable Packages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + .. |INTERFACE_PROPERTY_LINK| replace:: ``INTERFACE_INCLUDE_DIRECTORIES`` .. include:: /include/INTERFACE_INCLUDE_DIRECTORIES_WARNING.txt diff --git a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst index 55b7b8d..832d12b 100644 --- a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst +++ b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst @@ -17,5 +17,8 @@ with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. +Creating Relocatable Packages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + .. |INTERFACE_PROPERTY_LINK| replace:: ``INTERFACE_LINK_LIBRARIES`` .. include:: /include/INTERFACE_LINK_LIBRARIES_WARNING.txt diff --git a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst index 2e859eb..2dcf45c 100644 --- a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst +++ b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES.rst @@ -24,5 +24,8 @@ property if policy :policy:`CMP0022` is ``NEW``. This property is deprecated. Use :prop_tgt:`INTERFACE_LINK_LIBRARIES` instead. +Creating Relocatable Packages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + .. |INTERFACE_PROPERTY_LINK| replace:: ``LINK_INTERFACE_LIBRARIES`` .. include:: /include/INTERFACE_LINK_LIBRARIES_WARNING.txt diff --git a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst index 7f2b5dd..22ee5a6 100644 --- a/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst +++ b/Help/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG.rst @@ -13,5 +13,8 @@ property if policy :policy:`CMP0022` is ``NEW``. This property is deprecated. Use :prop_tgt:`INTERFACE_LINK_LIBRARIES` instead. +Creating Relocatable Packages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + .. |INTERFACE_PROPERTY_LINK| replace:: ``LINK_INTERFACE_LIBRARIES_<CONFIG>`` .. include:: /include/INTERFACE_LINK_LIBRARIES_WARNING.txt diff --git a/Help/prop_tgt/XCTEST.rst b/Help/prop_tgt/XCTEST.rst new file mode 100644 index 0000000..eb47e60 --- /dev/null +++ b/Help/prop_tgt/XCTEST.rst @@ -0,0 +1,13 @@ +XCTEST +------ + +This target is a XCTest CFBundle on the Mac. + +This property will usually get set via the :command:`xctest_add_bundle` +macro in :module:`FindXCTest` module. + +If a module library target has this property set to true it will be +built as a CFBundle when built on the Mac. It will have the directory +structure required for a CFBundle. + +This property depends on :prop_tgt:`BUNDLE` to be effective. diff --git a/Help/release/dev/ExternalData-recursive-match.rst b/Help/release/dev/ExternalData-recursive-match.rst new file mode 100644 index 0000000..4d8c789 --- /dev/null +++ b/Help/release/dev/ExternalData-recursive-match.rst @@ -0,0 +1,7 @@ +ExternalData-recursive-match +---------------------------- + +* The :module:`ExternalData` module learned a new ``RECURSE:`` + option in ``DATA{}`` references specifying directories. + This allows an entire directory tree of associated files + to be matched. diff --git a/Help/release/dev/FindCUDA-StaticRuntime.rst b/Help/release/dev/FindCUDA-StaticRuntime.rst new file mode 100644 index 0000000..112596c --- /dev/null +++ b/Help/release/dev/FindCUDA-StaticRuntime.rst @@ -0,0 +1,7 @@ +FindCUDA-StaticRuntime +---------------------- + +* The :module:`FindCUDA` module now defaults to using the static + CUDA runtime library if it is available. A new + ``CUDA_USE_STATIC_CUDA_RUNTIME`` option is offered to control + this behavior. diff --git a/Help/release/dev/UseSWIG-no-MAIN_DEPENDENCY.rst b/Help/release/dev/UseSWIG-no-MAIN_DEPENDENCY.rst new file mode 100644 index 0000000..5311cf1 --- /dev/null +++ b/Help/release/dev/UseSWIG-no-MAIN_DEPENDENCY.rst @@ -0,0 +1,9 @@ +UseSWIG-no-MAIN_DEPENDENCY +-------------------------- + +* The :module:`UseSWIG` module ``SWIG_ADD_MODULE`` macro no + longer attaches the swig invocation custom command to the + ``.i`` source file in IDE projects. This is because only + one custom command can be safely attached to a given source + file, and adding multiple modules with the same ``.i`` file + for different languages requires more than one such command. diff --git a/Help/release/dev/add-extra-qbs-generator.rst b/Help/release/dev/add-extra-qbs-generator.rst new file mode 100644 index 0000000..edb441f --- /dev/null +++ b/Help/release/dev/add-extra-qbs-generator.rst @@ -0,0 +1,6 @@ +add-extra-qbs-geneator +---------------------- + +* It is now possible to generate :generator:`Qbs` project files + for use with QtCreator IDE, matching make tool must be used + to build the project through the generated makefiles. diff --git a/Help/release/dev/add_dependencies-INTERFACE-libraries.rst b/Help/release/dev/add_dependencies-INTERFACE-libraries.rst new file mode 100644 index 0000000..dfac2af --- /dev/null +++ b/Help/release/dev/add_dependencies-INTERFACE-libraries.rst @@ -0,0 +1,7 @@ +add_dependencies-INTERFACE-libraries +------------------------------------ + +* The :command:`add_dependencies` command learned to allow dependencies + to be added to :ref:`interface libraries <Interface Libraries>`. + Dependencies added to an interface library are followed transitively + in its place since the target itself does not build. diff --git a/Help/release/dev/cpack-rpm-basic-symlink-handling.rst b/Help/release/dev/cpack-rpm-basic-symlink-handling.rst new file mode 100644 index 0000000..3af4cf1 --- /dev/null +++ b/Help/release/dev/cpack-rpm-basic-symlink-handling.rst @@ -0,0 +1,6 @@ +cpack-rpm-basic-symlink-handling +-------------------------------- + +* The :module:`CPackRPM` module learned to package symbolic links + more cleanly and now supports directory symlinks with recent + ``rpmbuild`` versions. diff --git a/Help/release/dev/ctest-repeat-until-fail.rst b/Help/release/dev/ctest-repeat-until-fail.rst new file mode 100644 index 0000000..8a679c6 --- /dev/null +++ b/Help/release/dev/ctest-repeat-until-fail.rst @@ -0,0 +1,5 @@ +ctest-repeat-until-fail +----------------------- + +* The :manual:`ctest(1)` tool learned a new ``--repeat-until-fail <n>`` + option to help find sporadic test failures. diff --git a/Help/release/dev/emulator-property.rst b/Help/release/dev/emulator-property.rst new file mode 100644 index 0000000..1bc2f2d --- /dev/null +++ b/Help/release/dev/emulator-property.rst @@ -0,0 +1,7 @@ +emulator-property +----------------- + +* A :prop_tgt:`CROSSCOMPILING_EMULATOR` target property and supporting + :variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable were introduced + to allow target platform binaries to run on the host during cross + compiling. diff --git a/Help/release/dev/file-globbing-directory-listing.rst b/Help/release/dev/file-globbing-directory-listing.rst new file mode 100644 index 0000000..c4d7ba5 --- /dev/null +++ b/Help/release/dev/file-globbing-directory-listing.rst @@ -0,0 +1,6 @@ +file-globbing-directory-listing +------------------------------- + +* The :command:`file(GLOB)` and :command:`file(GLOB_RECURSE)` commands + learned a new ``LIST_DIRECTORIES <bool>`` option to specify whether + the glob result should include directories. diff --git a/Help/release/dev/gcov-module-coverage-exclude.rst b/Help/release/dev/gcov-module-coverage-exclude.rst new file mode 100644 index 0000000..ee4ebae --- /dev/null +++ b/Help/release/dev/gcov-module-coverage-exclude.rst @@ -0,0 +1,6 @@ +gcov-module-coverage-exclude +---------------------------- + +* The :module:`CTestCoverageCollectGCOV` module learned to support + the same ``CTEST_CUSTOM_COVERAGE_EXCLUDE`` option as the + :command:`ctest_coverage` command. diff --git a/Help/release/dev/link-implicit-libs-full-path.rst b/Help/release/dev/link-implicit-libs-full-path.rst new file mode 100644 index 0000000..7ed7245 --- /dev/null +++ b/Help/release/dev/link-implicit-libs-full-path.rst @@ -0,0 +1,6 @@ +link-implicit-libs-full-path +---------------------------- + +* Linking to library files by a full path in an implicit linker search + directory (e.g. ``/usr/lib/libfoo.a``) no longer asks the linker to + search for the library (e.g. ``-lfoo``). See policy :policy:`CMP0060`. diff --git a/Help/release/dev/makefile-DELETE_ON_ERROR.rst b/Help/release/dev/makefile-DELETE_ON_ERROR.rst new file mode 100644 index 0000000..c7c45fd --- /dev/null +++ b/Help/release/dev/makefile-DELETE_ON_ERROR.rst @@ -0,0 +1,7 @@ +makefile-DELETE_ON_ERROR +------------------------ + +* The Makefile generators now add ``.DELETE_ON_ERROR`` to the + makefiles that contain the actual build rules for files on disk. + This tells GNU make to remove rule outputs when their recipe + modifies an output but fails. diff --git a/Help/release/dev/mingw-compile-features.rst b/Help/release/dev/mingw-compile-features.rst new file mode 100644 index 0000000..e2ed30b --- /dev/null +++ b/Help/release/dev/mingw-compile-features.rst @@ -0,0 +1,6 @@ +mingw-compile-features +---------------------- + +* The :manual:`Compile Features <cmake-compile-features(7)>` functionality + is now aware of features supported by GNU compilers on Windows, versions + 4.4 through 5.0. diff --git a/Help/release/dev/ninja-require-byproducts.rst b/Help/release/dev/ninja-require-byproducts.rst new file mode 100644 index 0000000..ccde4bc --- /dev/null +++ b/Help/release/dev/ninja-require-byproducts.rst @@ -0,0 +1,9 @@ +ninja-require-byproducts +------------------------ + +* The :generator:`Ninja` generator now requires that calls to the + :command:`add_custom_command` and :command:`add_custom_target` + commands use the ``BYPRODUCTS`` option to explicitly specify any + files generated by the custom commands that are not listed as + outputs (perhaps because their timestamps are allowed to be older + than the inputs). See policy :policy:`CMP0058`. diff --git a/Help/release/dev/remove-DEFINITIONS-directory-property.rst b/Help/release/dev/remove-DEFINITIONS-directory-property.rst new file mode 100644 index 0000000..d8e50f0 --- /dev/null +++ b/Help/release/dev/remove-DEFINITIONS-directory-property.rst @@ -0,0 +1,6 @@ +remove-DEFINITIONS-property +--------------------------- + +* The :command:`add_definitions()` command no longer causes a + :prop_dir:`DEFINITIONS` directory property to be populated. See policy + :policy:`CMP0059`. diff --git a/Help/release/dev/vs-xaml.rst b/Help/release/dev/vs-xaml.rst new file mode 100644 index 0000000..575899f --- /dev/null +++ b/Help/release/dev/vs-xaml.rst @@ -0,0 +1,6 @@ +vs-xaml +------- + +* The :ref:`Visual Studio Generators` learned to support ``.xaml`` + source files and automatically associate them with corresponding + ``.h`` and ``.cpp`` sources. diff --git a/Help/release/dev/xcode-xctest.rst b/Help/release/dev/xcode-xctest.rst new file mode 100644 index 0000000..7a2f07b --- /dev/null +++ b/Help/release/dev/xcode-xctest.rst @@ -0,0 +1,6 @@ +xcode-xctest +------------ + +* On OS X, CMake learned to create XCTest bundles to test Frameworks + and App Bundles within Xcode. The :module:`FindXCTest` module + provides convenience functions to handle :prop_tgt:`XCTEST` bundles. diff --git a/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst new file mode 100644 index 0000000..95d2c7f --- /dev/null +++ b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst @@ -0,0 +1,12 @@ +CMAKE_CROSSCOMPILING_EMULATOR +----------------------------- + +This variable is only used when :variable:`CMAKE_CROSSCOMPILING` is on. It +should point to a command on the host system that can run executable built +for the target system. + +The command will be used to run :command:`try_run` generated executables, +which avoids manual population of the TryRunResults.cmake file. + +It is also used as the default value for the +:prop_tgt:`CROSSCOMPILING_EMULATOR` target property of executables. diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst index 460c78c..f003227 100644 --- a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst @@ -8,4 +8,4 @@ list is a subset of the features listed in the :prop_gbl:`CMAKE_CXX_KNOWN_FEATUR global property. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_EXTENSIONS.rst b/Help/variable/CMAKE_CXX_EXTENSIONS.rst index 6448371..b14d753 100644 --- a/Help/variable/CMAKE_CXX_EXTENSIONS.rst +++ b/Help/variable/CMAKE_CXX_EXTENSIONS.rst @@ -8,4 +8,4 @@ property on all targets. See that target property for additional information. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst index 963a42a..2bc4525 100644 --- a/Help/variable/CMAKE_CXX_STANDARD.rst +++ b/Help/variable/CMAKE_CXX_STANDARD.rst @@ -8,4 +8,4 @@ property on all targets. See that target property for additional information. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst index f7750fa..14ffcd1 100644 --- a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst @@ -8,4 +8,4 @@ property on all targets. See that target property for additional information. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst index 1106246..df66eae 100644 --- a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst +++ b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst @@ -8,4 +8,4 @@ list is a subset of the features listed in the :prop_gbl:`CMAKE_C_KNOWN_FEATURES global property. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_EXTENSIONS.rst b/Help/variable/CMAKE_C_EXTENSIONS.rst index 5e935fc..25bec12 100644 --- a/Help/variable/CMAKE_C_EXTENSIONS.rst +++ b/Help/variable/CMAKE_C_EXTENSIONS.rst @@ -8,4 +8,4 @@ property on all targets. See that target property for additional information. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_STANDARD.rst b/Help/variable/CMAKE_C_STANDARD.rst index 3098ce5..2eb4e43 100644 --- a/Help/variable/CMAKE_C_STANDARD.rst +++ b/Help/variable/CMAKE_C_STANDARD.rst @@ -8,4 +8,4 @@ property on all targets. See that target property for additional information. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst index c24eea4..5e415da 100644 --- a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst @@ -8,4 +8,4 @@ property on all targets. See that target property for additional information. See the :manual:`cmake-compile-features(7)` manual for information on -compile features. +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index a83c807..092fe3e 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -11,6 +11,8 @@ warn by default: policy :policy:`CMP0047`. * ``CMAKE_POLICY_WARNING_CMP0056`` controls the warning for policy :policy:`CMP0056`. +* ``CMAKE_POLICY_WARNING_CMP0060`` controls the warning for + policy :policy:`CMP0060`. This variable should not be set by a project in CMake code. Project developers running CMake may set this variable in their cache to diff --git a/Modules/CPackBundle.cmake b/Modules/CPackBundle.cmake index d26a0b3..b412216 100644 --- a/Modules/CPackBundle.cmake +++ b/Modules/CPackBundle.cmake @@ -52,6 +52,11 @@ # list the main application folder, or the main executable. You should # list any frameworks and plugins that are included in your app bundle. # +# .. variable:: CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER +# +# Additional parameter that will passed to codesign. +# Default value: "--deep -f" +# # .. variable:: CPACK_COMMAND_CODESIGN # # Path to the codesign(1) command used to sign applications with an diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index fce8236..b8d518c 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -408,6 +408,51 @@ # # May be used to set per component CPACK_PACKAGING_INSTALL_PREFIX for # relocatable RPM packages. +# +# .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION +# CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION +# +# * Mandatory : NO +# * Default : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX +# are treated as one of relocation paths +# +# May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX +# from relocatable RPM prefix paths. +# +# Packaging of Symbolic Links +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# CPackRPM supports packaging of symbolic links:: +# +# execute_process(COMMAND ${CMAKE_COMMAND} +# -E create_symlink <relative_path_location> <symlink_name>) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name> +# DESTINATION <symlink_location> COMPONENT libraries) +# +# Symbolic links will be optimized (paths will be shortened if possible) +# before being added to the package or if multiple relocation paths are +# detected, a post install symlink relocation script will be generated. +# +# Symbolic links may point to locations that are not packaged by the same +# package (either a different component or even not packaged at all) but +# those locations will be treated as if they were a part of the package +# while determining if symlink should be either created or present in a +# post install script - depending on relocation paths. +# +# Currenty there are a few limitations though: +# +# * Only symbolic links with relative path can be packaged. +# +# * For component based packaging component interdependency is not checked +# when processing symbolic links. Symbolic links pointing to content of +# a different component are treated the same way as if pointing to location +# that will not be packaged. +# +# * Symbolic links pointing to a location through one or more intermediate +# symbolic links will not be handled differently - if the intermediate +# symbolic link(s) is also on a relocatable path, relocating it during +# package installation may cause initial symbolic link to point to an +# invalid location. #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -437,8 +482,15 @@ function(cpack_rpm_prepare_relocation_paths) # set base path prefix if(EXISTS "${WDIR}/${PATH_PREFIX}") - set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n") - list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}") + if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND + NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION) + set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n") + list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}") + + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: removing '${PATH_PREFIX}' from relocation paths") + endif() + endif() endif() # set other path prefixes @@ -486,717 +538,979 @@ function(cpack_rpm_prepare_relocation_paths) set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE) endfunction() -if(CMAKE_BINARY_DIR) - message(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.") -endif() +function(cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE) + foreach(PKG_PREFIX IN LISTS PACKAGE_PREFIXES) + string(REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}") + if(FOUND_) + list(APPEND TMP_PREFIXES "${PKG_PREFIX}") + endif() + endforeach() -if(NOT UNIX) - message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") -endif() + set(${RETURN_VARIABLE} "${TMP_PREFIXES}" PARENT_SCOPE) +endfunction() -# rpmbuild is the basic command for building RPM package -# it may be a simple (symbolic) link to rpm command. -find_program(RPMBUILD_EXECUTABLE rpmbuild) - -# Check version of the rpmbuild tool this would be easier to -# track bugs with users and CPackRPM debug mode. -# We may use RPM version in order to check for available version dependent features -if(RPMBUILD_EXECUTABLE) - execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version - OUTPUT_VARIABLE _TMP_VERSION - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^.* " "" - RPMBUILD_EXECUTABLE_VERSION - ${_TMP_VERSION}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>") - endif() -endif() +function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES) + list(LENGTH PACKAGE_PREFIXES LAST_INDEX) + set(SORTED_PACKAGE_PREFIXES "${PACKAGE_PREFIXES}") + list(SORT SORTED_PACKAGE_PREFIXES) + list(REVERSE SORTED_PACKAGE_PREFIXES) + math(EXPR LAST_INDEX ${LAST_INDEX}-1) + + foreach(SYMLINK_INDEX RANGE ${LAST_INDEX}) + list(GET SORTED_PACKAGE_PREFIXES ${SYMLINK_INDEX} SRC_PATH) + list(FIND PACKAGE_PREFIXES "${SRC_PATH}" SYMLINK_INDEX) # reverse magic + string(LENGTH "${SRC_PATH}" SRC_PATH_LEN) + + set(PARTS_CNT 0) + set(SCRIPT_PART "if [ \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}\" != \"${SRC_PATH}\" ]; then\n") + + # both paths relocated + foreach(POINT_INDEX RANGE ${LAST_INDEX}) + list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH) + list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic + string(LENGTH "${POINT_PATH}" POINT_PATH_LEN) + + if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}) + if("${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}") + set(INDENT "") + else() + set(SCRIPT_PART "${SCRIPT_PART} if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") + set(INDENT " ") + endif() -if(NOT RPMBUILD_EXECUTABLE) - message(FATAL_ERROR "RPM package requires rpmbuild executable") -endif() + foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}) + math(EXPR PARTS_CNT ${PARTS_CNT}+1) -# Display lsb_release output if DEBUG mode enable -# This will help to diagnose problem with CPackRPM -# because we will know on which kind of Linux we are -if(CPACK_RPM_PACKAGE_DEBUG) - find_program(LSB_RELEASE_EXECUTABLE lsb_release) - if(LSB_RELEASE_EXECUTABLE) - execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a - OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "\n" ", " - LSB_RELEASE_OUTPUT - ${_TMP_LSB_RELEASE_OUTPUT}) - else () - set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!") - endif() - message("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}") -endif() + math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) + list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) + string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) -# We may use RPM version in the future in order -# to shut down warning about space in buildtree -# some recent RPM version should support space in different places. -# not checked [yet]. -if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") - message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") -endif() + math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN}) + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_) -# If rpmbuild is found -# we try to discover alien since we may be on non RPM distro like Debian. -# In this case we may try to to use more advanced features -# like generating RPM directly from DEB using alien. -# FIXME feature not finished (yet) -find_program(ALIEN_EXECUTABLE alien) -if(ALIEN_EXECUTABLE) - message(STATUS "alien found, we may be on a Debian based distro.") -endif() + math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN}) + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) -# Are we packaging components ? -if(CPACK_RPM_PACKAGE_COMPONENT) - set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") - string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} CPACK_RPM_PACKAGE_COMPONENT_UPPER) -else() - set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") -endif() + set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") + set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") + set(SCRIPT_PART "${SCRIPT_PART} ${INDENT}fi\n") + endforeach() + + if(NOT "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}") + set(SCRIPT_PART "${SCRIPT_PART} fi\n") + endif() + endif() + endforeach() -set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}") + # source path relocated + if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X) + foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X) + math(EXPR PARTS_CNT ${PARTS_CNT}+1) -# -# Use user-defined RPM specific variables value -# or generate reasonable default value from -# CPACK_xxx generic values. -# The variables comes from the needed (mandatory or not) -# values found in the RPM specification file aka ".spec" file. -# The variables which may/should be defined are: -# + math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) + list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) + string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) -# CPACK_RPM_PACKAGE_SUMMARY (mandatory) + math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN}) + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_) -# CPACK_RPM_PACKAGE_SUMMARY_ is used only locally so that it can be unset each time before use otherwise -# component packaging could leak variable content between components -unset(CPACK_RPM_PACKAGE_SUMMARY_) -if(CPACK_RPM_PACKAGE_SUMMARY) - set(CPACK_RPM_PACKAGE_SUMMARY_ ${CPACK_RPM_PACKAGE_SUMMARY}) - unset(CPACK_RPM_PACKAGE_SUMMARY) -endif() + math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1) + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) -#Check for component summary first. -#If not set, it will use regular package summary logic. -if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY) - set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY}) - endif() -endif() + set(SCRIPT_PART "${SCRIPT_PART} if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + set(SCRIPT_PART "${SCRIPT_PART} ln -s \"${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n") + set(SCRIPT_PART "${SCRIPT_PART} CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") + set(SCRIPT_PART "${SCRIPT_PART} fi\n") + endforeach() + endif() -if(NOT CPACK_RPM_PACKAGE_SUMMARY) - if(CPACK_RPM_PACKAGE_SUMMARY_) - set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_PACKAGE_SUMMARY_}) - elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY) - set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) - else() - # if neither var is defined lets use the name as summary - string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY) + if(PARTS_CNT) + set(SCRIPT "${SCRIPT_PART}") + set(SCRIPT "${SCRIPT}fi\n") + endif() + endforeach() + + # point path relocated + foreach(POINT_INDEX RANGE ${LAST_INDEX}) + list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH) + list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic + string(LENGTH "${POINT_PATH}" POINT_PATH_LEN) + + if(_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}) + set(SCRIPT "${SCRIPT}if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n") + + foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}) + math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) + list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) + string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) + + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_) + + math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN}) + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) + + set(SCRIPT "${SCRIPT} if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + set(SCRIPT "${SCRIPT} ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"${SYMLINK_}\"\n") + set(SCRIPT "${SCRIPT} CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n") + set(SCRIPT "${SCRIPT} fi\n") + endforeach() + + set(SCRIPT "${SCRIPT}fi\n") + endif() + endforeach() + + # no path relocated + if(_RPM_RELOCATION_SCRIPT_X_X) + foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_X) + math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1) + list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR) + string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX) + + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_) + + math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1) + string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_) + + set(SCRIPT "${SCRIPT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n") + set(SCRIPT "${SCRIPT} ln -s \"${POINT_}\" \"${SYMLINK_}\"\n") + set(SCRIPT "${SCRIPT}fi\n") + endforeach() endif() -endif() -# CPACK_RPM_PACKAGE_NAME (mandatory) -if(NOT CPACK_RPM_PACKAGE_NAME) - string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) -endif() + set(RPM_SYMLINK_POSTINSTALL "${SCRIPT}" PARENT_SCOPE) +endfunction() + +function(cpack_rpm_symlink_add_for_relocation_script PACKAGE_PREFIXES SYMLINK SYMLINK_RELOCATION_PATHS POINT POINT_RELOCATION_PATHS) + list(LENGTH SYMLINK_RELOCATION_PATHS SYMLINK_PATHS_COUTN) + list(LENGTH POINT_RELOCATION_PATHS POINT_PATHS_COUNT) + + list(APPEND _RPM_RELOCATION_SCRIPT_PAIRS "${SYMLINK}:${POINT}") + list(LENGTH _RPM_RELOCATION_SCRIPT_PAIRS PAIR_NO) + + if(SYMLINK_PATHS_COUTN) + foreach(SYMLINK_RELOC_PATH IN LISTS SYMLINK_RELOCATION_PATHS) + list(FIND PACKAGE_PREFIXES "${SYMLINK_RELOC_PATH}" SYMLINK_INDEX) + + # source path relocated + list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X "${PAIR_NO}") + list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X") + + foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS) + list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX) + + # both paths relocated + list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX} "${PAIR_NO}") + list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}") + + # point path relocated + list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}") + list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}") + endforeach() + endforeach() + elseif(POINT_PATHS_COUNT) + foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS) + list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX) -# CPACK_RPM_PACKAGE_VERSION (mandatory) -if(NOT CPACK_RPM_PACKAGE_VERSION) - if(NOT CPACK_PACKAGE_VERSION) - message(FATAL_ERROR "RPM package requires a package version") + # point path relocated + list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}") + list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}") + endforeach() endif() - set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) -endif() -# Replace '-' in version with '_' -# '-' character is an Illegal RPM version character -# it is illegal because it is used to separate -# RPM "Version" from RPM "Release" -string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) - -# CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory) -if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE) - execute_process(COMMAND uname "-m" - OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE + + # no path relocated + list(APPEND _RPM_RELOCATION_SCRIPT_X_X "${PAIR_NO}") + list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_X") + + # place variables into parent scope + foreach(VAR IN LISTS RELOCATION_VARS) + set(${VAR} "${${VAR}}" PARENT_SCOPE) + endforeach() + set(_RPM_RELOCATION_SCRIPT_PAIRS "${_RPM_RELOCATION_SCRIPT_PAIRS}" PARENT_SCOPE) + set(REQUIRES_SYMLINK_RELOCATION_SCRIPT "true" PARENT_SCOPE) + set(DIRECTIVE "%ghost " PARENT_SCOPE) +endfunction() + +function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXES IS_RELOCATABLE) + # Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir + # This is necessary to avoid duplicate files since rpmbuild does + # recursion on its own when encountering a pathname which is a directory + # which is not flagged as %dir + string(STRIP "${INSTALL_FILES_LIST}" INSTALL_FILES_LIST) + string(REPLACE "\n" ";" INSTALL_FILES_LIST + "${INSTALL_FILES_LIST}") + string(REPLACE "\"" "" INSTALL_FILES_LIST + "${INSTALL_FILES_LIST}") + string(LENGTH "${WDIR}" WDR_LEN_) + + list(SORT INSTALL_FILES_LIST) # make file order consistent on all platforms + + foreach(F IN LISTS INSTALL_FILES_LIST) + unset(DIRECTIVE) + + if(IS_SYMLINK "${WDIR}/${F}") + if(IS_RELOCATABLE) + # check that symlink has relocatable format + get_filename_component(SYMLINK_LOCATION_ "${WDIR}/${F}" DIRECTORY) + execute_process(COMMAND ls -la "${WDIR}/${F}" + WORKING_DIRECTORY "${WDIR}" + OUTPUT_VARIABLE SYMLINK_POINT_ OUTPUT_STRIP_TRAILING_WHITESPACE) -else() - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") + + string(FIND "${SYMLINK_POINT_}" "->" SYMLINK_POINT_INDEX_ REVERSE) + math(EXPR SYMLINK_POINT_INDEX_ ${SYMLINK_POINT_INDEX_}+3) + string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_) + + # get destination path + string(SUBSTRING "${SYMLINK_POINT_}" ${SYMLINK_POINT_INDEX_} ${SYMLINK_POINT_LENGTH_} SYMLINK_POINT_) + + # check if path is relative or absolute + string(SUBSTRING "${SYMLINK_POINT_}" 0 1 SYMLINK_IS_ABSOLUTE_) + + if(${SYMLINK_IS_ABSOLUTE_} STREQUAL "/") + # prevent absolute paths from having /../ or /./ section inside of them + get_filename_component(SYMLINK_POINT_ "${SYMLINK_POINT_}" ABSOLUTE) + else() + # handle relative path + get_filename_component(SYMLINK_POINT_ "${SYMLINK_LOCATION_}/${SYMLINK_POINT_}" ABSOLUTE) + endif() + + string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_) + + cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS") + cpack_rpm_symlink_get_relocation_prefixes("${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS") + + list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT) + list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT) + + if(SYMLINK_RELOCATIONS_COUNT AND POINT_RELOCATIONS_COUNT) + # find matching + foreach(SYMLINK_RELOCATION_PREFIX IN LISTS SYMLINK_RELOCATIONS) + list(FIND POINT_RELOCATIONS "${SYMLINK_RELOCATION_PREFIX}" FOUND_INDEX) + if(NOT ${FOUND_INDEX} EQUAL -1) + break() + endif() + endforeach() + + if(NOT ${FOUND_INDEX} EQUAL -1) + # symlinks have the same subpath + if(${SYMLINK_RELOCATIONS_COUNT} EQUAL 1 AND ${POINT_RELOCATIONS_COUNT} EQUAL 1) + # permanent symlink + get_filename_component(SYMLINK_LOCATION_ "${F}" DIRECTORY) + file(RELATIVE_PATH FINAL_PATH_ ${SYMLINK_LOCATION_} ${SYMLINK_POINT_WD_}) + execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${FINAL_PATH_}" "${WDIR}/${F}") + else() + # relocation subpaths + cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}" + "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}") + endif() + else() + # not on the same relocation path + cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}" + "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}") + endif() + elseif(POINT_RELOCATIONS_COUNT) + # point is relocatable + cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}" + "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}") + else() + # is not relocatable or points to non relocatable path - permanent symlink + execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${SYMLINK_POINT_WD_}" "${WDIR}/${F}") + endif() + endif() + elseif(IS_DIRECTORY "${WDIR}/${F}") + set(DIRECTIVE "%dir ") + endif() + + set(INSTALL_FILES "${INSTALL_FILES}${DIRECTIVE}\"${F}\"\n") + endforeach() + + if(REQUIRES_SYMLINK_RELOCATION_SCRIPT) + cpack_rpm_symlink_create_relocation_script("${PACKAGE_PREFIXES}") endif() + + set(RPM_SYMLINK_POSTINSTALL "${RPM_SYMLINK_POSTINSTALL}" PARENT_SCOPE) + set(CPACK_RPM_INSTALL_FILES "${INSTALL_FILES}" PARENT_SCOPE) +endfunction() + +if(CMAKE_BINARY_DIR) + message(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.") endif() -set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE}) +if(NOT UNIX) + message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") +endif() -#prefer component architecture -if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE) - set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE}) +function(cpack_rpm_generate_package) + # rpmbuild is the basic command for building RPM package + # it may be a simple (symbolic) link to rpm command. + find_program(RPMBUILD_EXECUTABLE rpmbuild) + + # Check version of the rpmbuild tool this would be easier to + # track bugs with users and CPackRPM debug mode. + # We may use RPM version in order to check for available version dependent features + if(RPMBUILD_EXECUTABLE) + execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version + OUTPUT_VARIABLE _TMP_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE "^.* " "" + RPMBUILD_EXECUTABLE_VERSION + ${_TMP_VERSION}) if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: using component build arch = ${_CPACK_RPM_PACKAGE_ARCHITECTURE}") + message("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>") endif() endif() -endif() -if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch") - set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}") -else() - set(TMP_RPM_BUILDARCH "") -endif() -# CPACK_RPM_PACKAGE_RELEASE -# The RPM release is the numbering of the RPM package ITSELF -# this is the version of the PACKAGING and NOT the version -# of the CONTENT of the package. -# You may well need to generate a new RPM package release -# without changing the version of the packaged software. -# This is the case when the packaging is buggy (not) the software :=) -# If not set, 1 is a good candidate -if(NOT CPACK_RPM_PACKAGE_RELEASE) - set(CPACK_RPM_PACKAGE_RELEASE 1) -endif() + if(NOT RPMBUILD_EXECUTABLE) + message(FATAL_ERROR "RPM package requires rpmbuild executable") + endif() -# CPACK_RPM_PACKAGE_LICENSE -if(NOT CPACK_RPM_PACKAGE_LICENSE) - set(CPACK_RPM_PACKAGE_LICENSE "unknown") -endif() + # Display lsb_release output if DEBUG mode enable + # This will help to diagnose problem with CPackRPM + # because we will know on which kind of Linux we are + if(CPACK_RPM_PACKAGE_DEBUG) + find_program(LSB_RELEASE_EXECUTABLE lsb_release) + if(LSB_RELEASE_EXECUTABLE) + execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a + OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE "\n" ", " + LSB_RELEASE_OUTPUT + ${_TMP_LSB_RELEASE_OUTPUT}) + else () + set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!") + endif() + message("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}") + endif() -# CPACK_RPM_PACKAGE_GROUP -if(NOT CPACK_RPM_PACKAGE_GROUP) - set(CPACK_RPM_PACKAGE_GROUP "unknown") -endif() + # We may use RPM version in the future in order + # to shut down warning about space in buildtree + # some recent RPM version should support space in different places. + # not checked [yet]. + if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") + message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") + endif() + + # If rpmbuild is found + # we try to discover alien since we may be on non RPM distro like Debian. + # In this case we may try to to use more advanced features + # like generating RPM directly from DEB using alien. + # FIXME feature not finished (yet) + find_program(ALIEN_EXECUTABLE alien) + if(ALIEN_EXECUTABLE) + message(STATUS "alien found, we may be on a Debian based distro.") + endif() -# CPACK_RPM_PACKAGE_VENDOR -if(NOT CPACK_RPM_PACKAGE_VENDOR) - if(CPACK_PACKAGE_VENDOR) - set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}") + # Are we packaging components ? + if(CPACK_RPM_PACKAGE_COMPONENT) + set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") + string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} CPACK_RPM_PACKAGE_COMPONENT_UPPER) else() - set(CPACK_RPM_PACKAGE_VENDOR "unknown") + set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") endif() -endif() -# CPACK_RPM_PACKAGE_SOURCE -# The name of the source tarball in case we generate a source RPM + set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}") -# CPACK_RPM_PACKAGE_DESCRIPTION -# The variable content may be either -# - explicitly given by the user or -# - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE -# if it is defined -# - set to a default value -# + # + # Use user-defined RPM specific variables value + # or generate reasonable default value from + # CPACK_xxx generic values. + # The variables comes from the needed (mandatory or not) + # values found in the RPM specification file aka ".spec" file. + # The variables which may/should be defined are: + # -# CPACK_RPM_PACKAGE_DESCRIPTION_ is used only locally so that it can be unset each time before use otherwise -# component packaging could leak variable content between components -unset(CPACK_RPM_PACKAGE_DESCRIPTION_) -if(CPACK_RPM_PACKAGE_DESCRIPTION) - set(CPACK_RPM_PACKAGE_DESCRIPTION_ ${CPACK_RPM_PACKAGE_DESCRIPTION}) - unset(CPACK_RPM_PACKAGE_DESCRIPTION) -endif() + # CPACK_RPM_PACKAGE_SUMMARY (mandatory) -#Check for a component description first. -#If not set, it will use regular package description logic. -if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION) - set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION}) - elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION) - set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION}) + #Check for component summary first. + #If not set, it will use regular package summary logic. + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY) + set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY}) + endif() endif() -endif() -if(NOT CPACK_RPM_PACKAGE_DESCRIPTION) - if(CPACK_RPM_PACKAGE_DESCRIPTION_) - set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_DESCRIPTION_}) - elseif(CPACK_PACKAGE_DESCRIPTION_FILE) - file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION) - else () - set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available") - endif () -endif () + if(NOT CPACK_RPM_PACKAGE_SUMMARY) + if(CPACK_PACKAGE_DESCRIPTION_SUMMARY) + set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + else() + # if neither var is defined lets use the name as summary + string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY) + endif() + endif() -# CPACK_RPM_COMPRESSION_TYPE -# -if (CPACK_RPM_COMPRESSION_TYPE) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio") - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") - endif() -else() - set(CPACK_RPM_COMPRESSION_TYPE_TMP "") -endif() + # CPACK_RPM_PACKAGE_NAME (mandatory) + if(NOT CPACK_RPM_PACKAGE_NAME) + string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) + endif() -if(CPACK_PACKAGE_RELOCATABLE) - set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) -endif() -if(CPACK_RPM_PACKAGE_RELOCATABLE) - unset(TMP_RPM_PREFIXES) + # CPACK_RPM_PACKAGE_VERSION (mandatory) + if(NOT CPACK_RPM_PACKAGE_VERSION) + if(NOT CPACK_PACKAGE_VERSION) + message(FATAL_ERROR "RPM package requires a package version") + endif() + set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) + endif() + # Replace '-' in version with '_' + # '-' character is an Illegal RPM version character + # it is illegal because it is used to separate + # RPM "Version" from RPM "Release" + string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) + + # CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory) + if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE) + execute_process(COMMAND uname "-m" + OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") + endif() + endif() - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Trying to build a relocatable package") + set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE}) + + #prefer component architecture + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE) + set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE}) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using component build arch = ${_CPACK_RPM_PACKAGE_ARCHITECTURE}") + endif() + endif() endif() - if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) - message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") + if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch") + set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}") else() - set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files) - cpack_rpm_prepare_relocation_paths() + set(TMP_RPM_BUILDARCH "") endif() -endif() -# Check if additional fields for RPM spec header are given -# There may be some COMPONENT specific variables as well -# If component specific var is not provided we use the global one -# for each component -foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) + # CPACK_RPM_PACKAGE_RELEASE + # The RPM release is the numbering of the RPM package ITSELF + # this is the version of the PACKAGING and NOT the version + # of the CONTENT of the package. + # You may well need to generate a new RPM package release + # without changing the version of the packaged software. + # This is the case when the packaging is buggy (not) the software :=) + # If not set, 1 is a good candidate + if(NOT CPACK_RPM_PACKAGE_RELEASE) + set(CPACK_RPM_PACKAGE_RELEASE 1) + endif() + + # CPACK_RPM_PACKAGE_LICENSE + if(NOT CPACK_RPM_PACKAGE_LICENSE) + set(CPACK_RPM_PACKAGE_LICENSE "unknown") + endif() + + # CPACK_RPM_PACKAGE_GROUP + if(NOT CPACK_RPM_PACKAGE_GROUP) + set(CPACK_RPM_PACKAGE_GROUP "unknown") + endif() + + # CPACK_RPM_PACKAGE_VENDOR + if(NOT CPACK_RPM_PACKAGE_VENDOR) + if(CPACK_PACKAGE_VENDOR) + set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}") + else() + set(CPACK_RPM_PACKAGE_VENDOR "unknown") + endif() + endif() + + # CPACK_RPM_PACKAGE_SOURCE + # The name of the source tarball in case we generate a source RPM + + # CPACK_RPM_PACKAGE_DESCRIPTION + # The variable content may be either + # - explicitly given by the user or + # - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE + # if it is defined + # - set to a default value + # + + #Check for a component description first. + #If not set, it will use regular package description logic. + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION) + set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION}) + elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION) + set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION}) + endif() + endif() + + if(NOT CPACK_RPM_PACKAGE_DESCRIPTION) + if(CPACK_PACKAGE_DESCRIPTION_FILE) + file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION) + else () + set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available") + endif () + endif () + + # CPACK_RPM_COMPRESSION_TYPE + # + if (CPACK_RPM_COMPRESSION_TYPE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") + endif() + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") + endif() + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio") + endif() + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") + endif() + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") + endif() + else() + set(CPACK_RPM_COMPRESSION_TYPE_TMP "") + endif() + + if(CPACK_PACKAGE_RELOCATABLE) + set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) + endif() + if(CPACK_RPM_PACKAGE_RELOCATABLE) if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") + message("CPackRPM:Debug: Trying to build a relocatable package") endif() - if(CPACK_RPM_PACKAGE_COMPONENT) - if(DEFINED CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}") - endif() - set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}}) - else() - if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) + message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") + else() + set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files) + cpack_rpm_prepare_relocation_paths() + endif() + endif() + + # Check if additional fields for RPM spec header are given + # There may be some COMPONENT specific variables as well + # If component specific var is not provided we use the global one + # for each component + foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") + endif() + if(CPACK_RPM_PACKAGE_COMPONENT) + if(DEFINED CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}) if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined") - message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") + message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}") endif() - set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}}) + else() + if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined") + message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") + endif() + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) + endif() + endif() + else() + if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") endif() - endif() - else() - if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) endif() - set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) - endif() - endif() + endif() - # Do not forget to unset previously set header (from previous component) - unset(TMP_RPM_${_RPM_SPEC_HEADER}) - # Treat the RPM Spec keyword iff it has been properly defined - if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) - # Transform NAME --> Name e.g. PROVIDES --> Provides - # The Upper-case first letter and lowercase tail is the - # appropriate value required in the final RPM spec file. - string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL) - string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) - string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) - set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") - # The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file. - set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) - list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND) - if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1) - string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}") - set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})") + # Treat the RPM Spec keyword iff it has been properly defined + if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) + # Transform NAME --> Name e.g. PROVIDES --> Provides + # The Upper-case first letter and lowercase tail is the + # appropriate value required in the final RPM spec file. + string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL) + string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) + string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) + set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") + # The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file. + set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) + list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND) + if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1) + string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}") + set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})") + endif() + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") + endif() + set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") + unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) endif() + endforeach() + + # CPACK_RPM_SPEC_INSTALL_POST + # May be used to define a RPM post intallation script + # for example setting it to "/bin/true" may prevent + # rpmbuild from stripping binaries. + if(CPACK_RPM_SPEC_INSTALL_POST) if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") + message("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}") endif() - set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") - unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) + set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") endif() -endforeach() -# CPACK_RPM_SPEC_INSTALL_POST -# May be used to define a RPM post intallation script -# for example setting it to "/bin/true" may prevent -# rpmbuild from stripping binaries. -if(CPACK_RPM_SPEC_INSTALL_POST) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}") - endif() - set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") -endif() - -# CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE) -# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE) -# May be used to embed a post (un)installation script in the spec file. -# The refered script file(s) will be read and directly -# put after the %post or %postun section -if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE) - set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE}) + # CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE) + # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE) + # May be used to embed a post (un)installation script in the spec file. + # The refered script file(s) will be read and directly + # put after the %post or %postun section + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE}) + else() + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) + endif() + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE}) + else() + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) + endif() else() set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - endif() - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) - set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE}) - else() set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) endif() -else() - set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) -endif() -# Handle post-install file if it has been specified -if(CPACK_RPM_POST_INSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) - file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL) + # Handle post-install file if it has been specified + if(CPACK_RPM_POST_INSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) + file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL) + else() + message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring") + endif() else() - message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring") + # reset SPEC var value if no post install file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_POSTINSTALL "") endif() -else() - # reset SPEC var value if no post install file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_POSTINSTALL "") -endif() -# Handle post-uninstall file if it has been specified -if(CPACK_RPM_POST_UNINSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) - file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) + # Handle post-uninstall file if it has been specified + if(CPACK_RPM_POST_UNINSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) + file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) + else() + message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring") + endif() else() - message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring") + # reset SPEC var value if no post uninstall file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_POSTUNINSTALL "") endif() -else() - # reset SPEC var value if no post uninstall file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_POSTUNINSTALL "") -endif() -# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE) -# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE) -# May be used to embed a pre (un)installation script in the spec file. -# The refered script file(s) will be read and directly -# put after the %pre or %preun section -if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) - set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE}) + # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE) + # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE) + # May be used to embed a pre (un)installation script in the spec file. + # The refered script file(s) will be read and directly + # put after the %pre or %preun section + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE}) + else() + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) + endif() + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE}) + else() + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) + endif() else() set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - endif() - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) - set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE}) - else() set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) endif() -else() - set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) -endif() -# Handle pre-install file if it has been specified -if(CPACK_RPM_PRE_INSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) - file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL) + # Handle pre-install file if it has been specified + if(CPACK_RPM_PRE_INSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) + file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL) + else() + message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring") + endif() else() - message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring") + # reset SPEC var value if no pre-install file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_PREINSTALL "") endif() -else() - # reset SPEC var value if no pre-install file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_PREINSTALL "") -endif() -# Handle pre-uninstall file if it has been specified -if(CPACK_RPM_PRE_UNINSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) - file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL) + # Handle pre-uninstall file if it has been specified + if(CPACK_RPM_PRE_UNINSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) + file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL) + else() + message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring") + endif() else() - message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring") + # reset SPEC var value if no pre-uninstall file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_PREUNINSTALL "") endif() -else() - # reset SPEC var value if no pre-uninstall file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_PREUNINSTALL "") -endif() -# CPACK_RPM_CHANGELOG_FILE -# May be used to embed a changelog in the spec file. -# The refered file will be read and directly put after the %changelog section -if(CPACK_RPM_CHANGELOG_FILE) - if(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) - file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG) + # CPACK_RPM_CHANGELOG_FILE + # May be used to embed a changelog in the spec file. + # The refered file will be read and directly put after the %changelog section + if(CPACK_RPM_CHANGELOG_FILE) + if(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) + file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG) + else() + message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring") + endif() else() - message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring") - endif() -else() - set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <eric.noulard@gmail.com> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)") -endif() - -# CPACK_RPM_SPEC_MORE_DEFINE -# This is a generated spec rpm file spaceholder -if(CPACK_RPM_SPEC_MORE_DEFINE) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}") + set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <eric.noulard@gmail.com> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)") endif() -endif() -# Now we may create the RPM build tree structure -set(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}") -message(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") -# Prepare RPM build tree -file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}) -file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp) -file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD) -file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS) -file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES) -file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS) -file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS) - -#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${_CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") -set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") -# it seems rpmbuild can't handle spaces in the path -# neither escaping (as below) nor putting quotes around the path seem to help -#string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") -set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") - -# if we are creating a relocatable package, omit parent directories of -# CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list" -# which is passed to the find command that generates the content-list -if(CPACK_RPM_PACKAGE_RELOCATABLE) - # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are - # destinct parent paths of other relocation paths and remove the - # final element (so the install-prefix dir itself is not omitted - # from the RPM's content-list) - list(SORT RPM_USED_PACKAGE_PREFIXES) - set(_DISTINCT_PATH "NOT_SET") - foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES}) - if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*") - set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}") - - string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS ".${_RPM_RELOCATION_PREFIX}") - list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1) - unset(_TMP_LIST) - # Now generate all of the parent dirs of the relocation path - foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS}) - list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}") - string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}") - list(FIND _RPM_DIRS_TO_OMIT "${_OMIT_DIR}" _DUPLICATE_FOUND) - if(_DUPLICATE_FOUND EQUAL -1) - set(_OMIT_DIR "-o -path ${_OMIT_DIR}") - separate_arguments(_OMIT_DIR) - list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR}) - endif() - endforeach() + # CPACK_RPM_SPEC_MORE_DEFINE + # This is a generated spec rpm file spaceholder + if(CPACK_RPM_SPEC_MORE_DEFINE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}") endif() - endforeach() -endif() - -if (CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") -endif() + endif() -if (NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) - set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include) - if (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION) - message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") - list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}") + # Now we may create the RPM build tree structure + set(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}") + message(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") + # Prepare RPM build tree + file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}) + file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp) + file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD) + file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS) + file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES) + file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS) + file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS) + + #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${_CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") + set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") + # it seems rpmbuild can't handle spaces in the path + # neither escaping (as below) nor putting quotes around the path seem to help + #string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") + set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") + + # if we are creating a relocatable package, omit parent directories of + # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list" + # which is passed to the find command that generates the content-list + if(CPACK_RPM_PACKAGE_RELOCATABLE) + # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are + # destinct parent paths of other relocation paths and remove the + # final element (so the install-prefix dir itself is not omitted + # from the RPM's content-list) + set(SORTED_RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}") + list(SORT SORTED_RPM_USED_PACKAGE_PREFIXES) + set(_DISTINCT_PATH "NOT_SET") + foreach(_RPM_RELOCATION_PREFIX ${SORTED_RPM_USED_PACKAGE_PREFIXES}) + if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*") + set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}") + + string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS ".${_RPM_RELOCATION_PREFIX}") + list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1) + unset(_TMP_LIST) + # Now generate all of the parent dirs of the relocation path + foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS}) + list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}") + string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}") + list(FIND _RPM_DIRS_TO_OMIT "${_OMIT_DIR}" _DUPLICATE_FOUND) + if(_DUPLICATE_FOUND EQUAL -1) + set(_OMIT_DIR "-o -path ${_OMIT_DIR}") + separate_arguments(_OMIT_DIR) + list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR}) + endif() + endforeach() + endif() + endforeach() endif() -endif() -if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) if (CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}") - endif() - foreach(_DIR ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}) - list(APPEND _RPM_DIRS_TO_OMIT "-o;-path;.${_DIR}") - endforeach() -endif() -if (CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") -endif() + message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") + endif() + + if (NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include) + if (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION) + message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") + list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}") + endif() + endif() -# Use files tree to construct files command (spec file) -# We should not forget to include symlinks (thus -o -type l) -# We should include directory as well (thus -type d) -# but not the main local dir "." (thus -a -not -name ".") -# We must remove the './' due to the local search and escape the -# file name by enclosing it between double quotes (thus the sed) -# Then we must authorize any man pages extension (adding * at the end) -# because rpmbuild may automatically compress those files -execute_process(COMMAND find . -type f -o -type l -o (-type d -a -not ( -name "." ${_RPM_DIRS_TO_OMIT} ) ) - COMMAND sed s:.*/man.*/.*:&*: - COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/ - WORKING_DIRECTORY "${WDIR}" - OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) - -# In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT> -# into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL -# otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES -# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling -if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_ABSOLUTE_DESTINATION_FILES) - set(COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}") - set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}") - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>") - message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") + if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) + if (CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}") endif() + foreach(_DIR ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}) + list(APPEND _RPM_DIRS_TO_OMIT "-o;-path;.${_DIR}") + endforeach() endif() -else() - if(CPACK_ABSOLUTE_DESTINATION_FILES) - set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}") + if (CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") endif() -endif() -# In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST. -if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST) - set(CPACK_RPM_USER_FILELIST_INTERNAL ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") - message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") + # Use files tree to construct files command (spec file) + # We should not forget to include symlinks (thus -o -type l) + # We should include directory as well (thus -type d) + # but not the main local dir "." (thus -a -not -name ".") + # We must remove the './' due to the local search and escape the + # file name by enclosing it between double quotes (thus the sed) + # Then we must authorize any man pages extension (adding * at the end) + # because rpmbuild may automatically compress those files + execute_process(COMMAND find . -type f -o -type l -o (-type d -a -not ( -name "." ${_RPM_DIRS_TO_OMIT} ) ) + COMMAND sed s:.*/man.*/.*:&*: + COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/ + WORKING_DIRECTORY "${WDIR}" + OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) + + # In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT> + # into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL + # otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES + # This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_ABSOLUTE_DESTINATION_FILES) + set(COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}") + set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}") + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>") + message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") + endif() endif() else() - set(CPACK_RPM_USER_FILELIST_INTERNAL "") + if(CPACK_ABSOLUTE_DESTINATION_FILES) + set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}") + endif() endif() -else() - if(CPACK_RPM_USER_FILELIST) - set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}") + + # In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST. + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST) + set(CPACK_RPM_USER_FILELIST_INTERNAL ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST}) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") + message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") + endif() + else() + set(CPACK_RPM_USER_FILELIST_INTERNAL "") + endif() else() - set(CPACK_RPM_USER_FILELIST_INTERNAL "") + if(CPACK_RPM_USER_FILELIST) + set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}") + else() + set(CPACK_RPM_USER_FILELIST_INTERNAL "") + endif() endif() -endif() -# Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL -# Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL -# or CPACK_RPM_INSTALL_FILES, -# hence it must be done before these auto-generated lists are processed. -if(CPACK_RPM_USER_FILELIST_INTERNAL) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") - endif() + # Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL + # Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL + # or CPACK_RPM_INSTALL_FILES, + # hence it must be done before these auto-generated lists are processed. + if(CPACK_RPM_USER_FILELIST_INTERNAL) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") + endif() + + # Create CMake list from CPACK_RPM_INSTALL_FILES + string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) + string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST + "${CPACK_RPM_INSTALL_FILES_LIST}") + string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST + "${CPACK_RPM_INSTALL_FILES_LIST}") + + set(CPACK_RPM_USER_INSTALL_FILES "") + foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL) + string(REGEX REPLACE "%[A-Za-z0-9\(\),-]* " "" F_PATH ${F}) + string(REGEX MATCH "%[A-Za-z0-9\(\),-]*" F_PREFIX ${F}) + + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>") + endif() + if(F_PREFIX) + set(F_PREFIX "${F_PREFIX} ") + endif() + # Rebuild the user list file + set(CPACK_RPM_USER_INSTALL_FILES "${CPACK_RPM_USER_INSTALL_FILES}${F_PREFIX}\"${F_PATH}\"\n") + + # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL + list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH}) + # ABSOLUTE destination files list may not exists at all + if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) + list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) + endif() - # Create CMake list from CPACK_RPM_INSTALL_FILES - string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) - string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST - "${CPACK_RPM_INSTALL_FILES_LIST}") - string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST - "${CPACK_RPM_INSTALL_FILES_LIST}") + endforeach() - set(CPACK_RPM_USER_INSTALL_FILES "") - foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL) - string(REGEX REPLACE "%[A-Za-z0-9\(\),-]* " "" F_PATH ${F}) - string(REGEX MATCH "%[A-Za-z0-9\(\),-]*" F_PREFIX ${F}) + # Rebuild CPACK_RPM_INSTALL_FILES + set(CPACK_RPM_INSTALL_FILES "") + foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) + set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") + endforeach() + else() + set(CPACK_RPM_USER_INSTALL_FILES "") + endif() + if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>") - endif() - if(F_PREFIX) - set(F_PREFIX "${F_PREFIX} ") + message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}") endif() - # Rebuild the user list file - set(CPACK_RPM_USER_INSTALL_FILES "${CPACK_RPM_USER_INSTALL_FILES}${F_PREFIX}\"${F_PATH}\"\n") - - # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL - list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH}) - # ABSOLUTE destination files list may not exists at all - if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) - list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) + # Remove trailing space + string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) + # Transform endline separated - string into CMake List + string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") + # Remove unecessary quotes + string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") + # Remove ABSOLUTE install file from INSTALL FILE LIST + list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}) + # Rebuild INSTALL_FILES + set(CPACK_RPM_INSTALL_FILES "") + foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) + set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") + endforeach() + # Build ABSOLUTE_INSTALL_FILES + set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") + foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) + set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "${CPACK_RPM_ABSOLUTE_INSTALL_FILES}%config \"${F}\"\n") + endforeach() + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}") + message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}") endif() + else() + # reset vars in order to avoid leakage of value(s) from one component to another + set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") + endif() - endforeach() + # Prepare install files + cpack_rpm_prepare_install_files( + "${CPACK_RPM_INSTALL_FILES}" + "${WDIR}" + "${RPM_USED_PACKAGE_PREFIXES}" + "${CPACK_RPM_PACKAGE_RELOCATABLE}" + ) - # Rebuild CPACK_RPM_INSTALL_FILES - set(CPACK_RPM_INSTALL_FILES "") - foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) - set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") - endforeach() -else() - set(CPACK_RPM_USER_INSTALL_FILES "") -endif() + # The name of the final spec file to be used by rpmbuild + set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec") -if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}") - endif() - # Remove trailing space - string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) - # Transform endline separated - string into CMake List - string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") - # Remove unecessary quotes - string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") - # Remove ABSOLUTE install file from INSTALL FILE LIST - list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}) - # Rebuild INSTALL_FILES - set(CPACK_RPM_INSTALL_FILES "") - foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) - set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") - endforeach() - # Build ABSOLUTE_INSTALL_FILES - set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") - foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) - set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "${CPACK_RPM_ABSOLUTE_INSTALL_FILES}%config \"${F}\"\n") - endforeach() + # Print out some debug information if we were asked for that if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}") - message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}") - endif() -else() - # reset vars in order to avoid leakage of value(s) from one component to another - set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") -endif() - -# Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir -# This is necessary to avoid duplicate files since rpmbuild do -# recursion on its own when encountering a pathname which is a directory -# which is not flagged as %dir -string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) -string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST - "${CPACK_RPM_INSTALL_FILES_LIST}") -string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST - "${CPACK_RPM_INSTALL_FILES_LIST}") -set(CPACK_RPM_INSTALL_FILES "") -foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) - if(IS_DIRECTORY "${WDIR}/${F}") - set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}%dir \"${F}\"\n") - else() - set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") + message("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") + message("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") + message("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") + message("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") + message("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") + message("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") + message("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") + message("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") + message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") endif() -endforeach() -set(CPACK_RPM_INSTALL_FILES_LIST "") - -# The name of the final spec file to be used by rpmbuild -set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec") - -# Print out some debug information if we were asked for that -if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") - message("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") - message("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") - message("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") - message("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") - message("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") - message("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") - message("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") - message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") -endif() -# -# USER generated/provided spec file handling. -# + # + # USER generated/provided spec file handling. + # -# We can have a component specific spec file. -if(CPACK_RPM_PACKAGE_COMPONENT AND CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE) - set(CPACK_RPM_USER_BINARY_SPECFILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE}) -endif() + # We can have a component specific spec file. + if(CPACK_RPM_PACKAGE_COMPONENT AND CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE) + set(CPACK_RPM_USER_BINARY_SPECFILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE}) + endif() -# We should generate a USER spec file template: -# - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE -# - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE -if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) - file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in + # We should generate a USER spec file template: + # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE + # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE + if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# -*- rpm-spec -*- BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ @@ -1251,6 +1565,7 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT %clean %post +\@RPM_SYMLINK_POSTINSTALL\@ \@CPACK_RPM_SPEC_POSTINSTALL\@ %postun @@ -1271,63 +1586,54 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT %changelog \@CPACK_RPM_SPEC_CHANGELOG\@ ") - # Stop here if we were asked to only generate a template USER spec file - # The generated file may then be used as a template by user who wants - # to customize their own spec file. - if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) - message(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file templare is: ${CPACK_RPM_BINARY_SPECFILE}.in") + # Stop here if we were asked to only generate a template USER spec file + # The generated file may then be used as a template by user who wants + # to customize their own spec file. + if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) + message(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file templare is: ${CPACK_RPM_BINARY_SPECFILE}.in") + endif() endif() -endif() - -# After that we may either use a user provided spec file -# or generate one using appropriate variables value. -if(CPACK_RPM_USER_BINARY_SPECFILE) - # User may have specified SPECFILE just use it - message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") - # The user provided file is processed for @var replacement - configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) -else() - # No User specified spec file, will use the generated spec file - message("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") - # Note the just created file is processed for @var replacement - configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) -endif() -if(RPMBUILD_EXECUTABLE) - # Now call rpmbuild using the SPECFILE - execute_process( - COMMAND "${RPMBUILD_EXECUTABLE}" -bb - --define "_topdir ${CPACK_RPM_DIRECTORY}" - --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" - --target "${_CPACK_RPM_PACKAGE_ARCHITECTURE}" - "${CPACK_RPM_BINARY_SPECFILE}" - WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" - RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT - ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err" - OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") - if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) - file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err RPMBUILDERR) - file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out RPMBUILDOUT) - message("CPackRPM:Debug: You may consult rpmbuild logs in: ") - message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err") - message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") - message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") - message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") + # After that we may either use a user provided spec file + # or generate one using appropriate variables value. + if(CPACK_RPM_USER_BINARY_SPECFILE) + # User may have specified SPECFILE just use it + message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") + # The user provided file is processed for @var replacement + configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) + else() + # No User specified spec file, will use the generated spec file + message("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") + # Note the just created file is processed for @var replacement + configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) endif() -else() - if(ALIEN_EXECUTABLE) - message(FATAL_ERROR "RPM packaging through alien not done (yet)") + + if(RPMBUILD_EXECUTABLE) + # Now call rpmbuild using the SPECFILE + execute_process( + COMMAND "${RPMBUILD_EXECUTABLE}" -bb + --define "_topdir ${CPACK_RPM_DIRECTORY}" + --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + --target "${_CPACK_RPM_PACKAGE_ARCHITECTURE}" + "${CPACK_RPM_BINARY_SPECFILE}" + WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT + ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err" + OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") + if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) + file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err RPMBUILDERR) + file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out RPMBUILDOUT) + message("CPackRPM:Debug: You may consult rpmbuild logs in: ") + message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err") + message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") + message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") + message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") + endif() + else() + if(ALIEN_EXECUTABLE) + message(FATAL_ERROR "RPM packaging through alien not done (yet)") + endif() endif() -endif() +endfunction() -# reset variables from temporary variables -if(CPACK_RPM_PACKAGE_SUMMARY_) - set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_PACKAGE_SUMMARY_}) -else() - unset(CPACK_RPM_PACKAGE_SUMMARY) -endif() -if(CPACK_RPM_PACKAGE_DESCRIPTION_) - set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_DESCRIPTION_}) -else() - unset(CPACK_RPM_PACKAGE_DESCRIPTION) -endif() +cpack_rpm_generate_package() diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index 4519627..8659a69 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -147,8 +147,37 @@ function(ctest_coverage_collect_gcov) \"Binary\": \"${binary_dir}\" }") # collect the gcov files + set(unfiltered_gcov_files) + file(GLOB_RECURSE unfiltered_gcov_files RELATIVE ${binary_dir} "${coverage_dir}/*.gcov") + set(gcov_files) - file(GLOB_RECURSE gcov_files RELATIVE ${binary_dir} "${coverage_dir}/*.gcov") + foreach(gcov_file ${unfiltered_gcov_files}) + file(STRINGS ${binary_dir}/${gcov_file} first_line LIMIT_COUNT 1 ENCODING UTF-8) + + set(is_excluded false) + if(first_line MATCHES "^ -: 0:Source:(.*)$") + set(source_file ${CMAKE_MATCH_1}) + elseif(NOT GCOV_QUIET) + message(STATUS "Could not determine source file corresponding to: ${gcov_file}") + endif() + + foreach(exclude_entry ${CTEST_CUSTOM_COVERAGE_EXCLUDE}) + if(source_file MATCHES "${exclude_entry}") + set(is_excluded true) + + if(NOT GCOV_QUIET) + message("Excluding coverage for: ${source_file} which matches ${exclude_entry}") + endif() + + break() + endif() + endforeach() + + if(NOT is_excluded) + list(APPEND gcov_files ${gcov_file}) + endif() + endforeach() + # tar up the coverage info with the same date so that the md5 # sum will be the same for the tar file independent of file time # stamps diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 86a31e4..2dc02f0 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -44,10 +44,10 @@ macro(cmake_record_cxx_compile_features) endmacro() set(_result 0) - if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) _get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) endif() - if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) if (_result EQUAL 0) _get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) endif() diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake index dfd7927..e9c8a59 100644 --- a/Modules/Compiler/GNU-Fortran.cmake +++ b/Modules/Compiler/GNU-Fortran.cmake @@ -8,5 +8,8 @@ set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") +# No -isystem for Fortran because it will not find .mod files. +unset(CMAKE_INCLUDE_SYSTEM_FLAG_Fortran) + # Fortran-specific feature flags. set(CMAKE_Fortran_MODDIR_FLAG -J) diff --git a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake index c770211..fcedf3c 100644 --- a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake +++ b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake @@ -16,12 +16,6 @@ set(_cmake_feature_test_cxx_decltype_auto "${MSVC_2015}") # says they will be available in the RTM. set(_cmake_feature_test_cxx_digit_separators "${MSVC_2015}") set(_cmake_feature_test_cxx_func_identifier "${MSVC_2015}") -# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx -# Note 1. While previous version of VisualStudio said they supported these -# they silently produced bad code, and are now marked as having partial -# support in previous versions. The footnote says the support will be complete -# in MSVC 2015, so support the feature for that version, assuming that is true. -set(_cmake_feature_test_cxx_generalized_initializers "${MSVC_2015}") set(_cmake_feature_test_cxx_nonstatic_member_init "${MSVC_2015}") # Microsoft calls this 'rvalue references v3' set(_cmake_feature_test_cxx_defaulted_move_initializers "${MSVC_2015}") @@ -44,6 +38,16 @@ set(_cmake_feature_test_cxx_reference_qualified_functions "${MSVC_2015}") # lists this as 'partial' in 2013 set(_cmake_feature_test_cxx_deleted_functions "${MSVC_2015}") +set(MSVC_2013_v30723 "_MSC_FULL_VER >= 180030723") +# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx +# Note 1. While previous version of VisualStudio said they supported these +# they silently produced bad code, and are now marked as having partial +# support in previous versions. The footnote says the support will be complete +# in MSVC 2015, so support the feature for that version, assuming that is true. +# The blog post also says that VS 2013 Update 3 generates an error in cases +# that previously produced bad code. +set(_cmake_feature_test_cxx_generalized_initializers "${MSVC_2013_v30723}") + set(MSVC_2013 "_MSC_VER >= 1800") set(_cmake_feature_test_cxx_alias_templates "${MSVC_2013}") # Microsoft now states they support contextual conversions in 2013 and above. @@ -101,6 +105,7 @@ set(_cmake_feature_test_cxx_variadic_macros "${MSVC_2010}") # Unset all the variables that we don't need exposed. # _cmake_oldestSupported is required by WriteCompilerDetectionHeader set(MSVC_2015) +set(MSVC_2013_v30723) set(MSVC_2013) set(MSVC_2012) set(MSVC_2010) diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index c5b5203..92252cb 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -1,7 +1,6 @@ set(CMAKE_C_VERBOSE_FLAG "-#") set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_C_COMPILE_OPTIONS_PIE -KPIE) set(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index c7bc734..022b4d4 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -1,7 +1,6 @@ set(CMAKE_CXX_VERBOSE_FLAG "-v") set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC) -set(CMAKE_CXX_COMPILE_OPTIONS_PIE -KPIE) set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC") set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G") set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R") diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index e4db1e8..196aae4 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -2,6 +2,7 @@ set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") +set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC") set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC") set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G") set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-R") diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 7f686a2..20f3da3 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -79,7 +79,6 @@ 1DEB928A08733DD80010E9CD = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ONLY_ACTIVE_ARCH = YES; CODE_SIGNING_REQUIRED = NO; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index b3206be..883ab69 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -244,7 +244,8 @@ associated file options. For example, the argument ``DATA{MyDataDir/,REGEX:.*}`` will pass the full path to a ``MyDataDir`` directory on the command line and ensure that the directory contains files corresponding to every file or content link in the ``MyDataDir`` -source directory. +source directory. In order to match associated files in subdirectories, +specify a ``RECURSE:`` option, e.g. ``DATA{MyDataDir/,RECURSE:,REGEX:.*}``. Hash Algorithms ^^^^^^^^^^^^^^^ @@ -597,6 +598,7 @@ function(_ExternalData_arg target arg options var_file) # Process options. set(series_option "") + set(recurse_option "") set(associated_files "") set(associated_regex "") foreach(opt ${options}) @@ -606,6 +608,9 @@ function(_ExternalData_arg target arg options var_file) elseif(opt STREQUAL ":") # Activate series matching. set(series_option "${opt}") + elseif(opt STREQUAL "RECURSE:") + # Activate recursive matching in directories. + set(recurse_option "${opt}") elseif("x${opt}" MATCHES "^[^][:/*?]+$") # Specific associated file. list(APPEND associated_files "${opt}") @@ -622,6 +627,9 @@ function(_ExternalData_arg target arg options var_file) if(associated_files OR associated_regex) message(FATAL_ERROR "Series option \"${series_option}\" not allowed with associated files.") endif() + if(recurse_option) + message(FATAL_ERROR "Recurse option \"${recurse_option}\" allowed only with directories.") + endif() # Load a whole file series. _ExternalData_arg_series() elseif(data_is_directory) @@ -634,6 +642,9 @@ function(_ExternalData_arg target arg options var_file) "must list associated files.") endif() else() + if(recurse_option) + message(FATAL_ERROR "Recurse option \"${recurse_option}\" allowed only with directories.") + endif() # Load the named data file. _ExternalData_arg_single() if(associated_files OR associated_regex) @@ -681,11 +692,18 @@ macro(_ExternalData_arg_associated) set(reldir "${reldir}/") endif() _ExternalData_exact_regex(reldir_regex "${reldir}") + if(recurse_option) + set(glob GLOB_RECURSE) + set(reldir_regex "${reldir_regex}(.+/)?") + else() + set(glob GLOB) + endif() # Find files named explicitly. foreach(file ${associated_files}) _ExternalData_exact_regex(file_regex "${file}") - _ExternalData_arg_find_files("${reldir}${file}" "${reldir_regex}${file_regex}") + _ExternalData_arg_find_files(${glob} "${reldir}${file}" + "${reldir_regex}${file_regex}") endforeach() # Find files matching the given regular expressions. @@ -695,13 +713,13 @@ macro(_ExternalData_arg_associated) set(all "${all}${sep}${reldir_regex}${regex}") set(sep "|") endforeach() - _ExternalData_arg_find_files("${reldir}" "${all}") + _ExternalData_arg_find_files(${glob} "${reldir}" "${all}") endmacro() macro(_ExternalData_arg_single) # Match only the named data by itself. _ExternalData_exact_regex(data_regex "${reldata}") - _ExternalData_arg_find_files("${reldata}" "${data_regex}") + _ExternalData_arg_find_files(GLOB "${reldata}" "${data_regex}") endmacro() macro(_ExternalData_arg_series) @@ -756,12 +774,15 @@ macro(_ExternalData_arg_series) # Then match base, number, and extension. _ExternalData_exact_regex(series_base "${relbase}") _ExternalData_exact_regex(series_ext "${ext}") - _ExternalData_arg_find_files("${relbase}*${ext}" + _ExternalData_arg_find_files(GLOB "${relbase}*${ext}" "${series_base}${series_match}${series_ext}") endmacro() -function(_ExternalData_arg_find_files pattern regex) - file(GLOB globbed RELATIVE "${top_src}" "${top_src}/${pattern}*") +function(_ExternalData_arg_find_files glob pattern regex) + cmake_policy(PUSH) + cmake_policy(SET CMP0009 NEW) + file(${glob} globbed RELATIVE "${top_src}" "${top_src}/${pattern}*") + cmake_policy(POP) foreach(entry IN LISTS globbed) if("x${entry}" MATCHES "^x(.*)(\\.(${_ExternalData_REGEX_EXT}))$") set(relname "${CMAKE_MATCH_1}") diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index d7b985d..0c73d41 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1197,7 +1197,10 @@ function(_ep_get_build_command name step cmd_var) else() set(cmd "${CMAKE_COMMAND}") endif() - set(args --build ${binary_dir} --config ${CMAKE_CFG_INTDIR}) + set(args --build ".") + if (CMAKE_CFG_INTDIR AND NOT CMAKE_CFG_INTDIR STREQUAL ".") + list(APPEND args --config "${CMAKE_CFG_INTDIR}") + endif () if(step STREQUAL "INSTALL") list(APPEND args --target install) endif() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 7d9f772..ca32559 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -106,6 +106,11 @@ # CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and # CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. # +# CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) +# -- When enabled the static version of the CUDA runtime library will be used +# in CUDA_LIBRARIES. If the version of CUDA configured doesn't support +# this option, then it will be silently disabled. +# # CUDA_VERBOSE_BUILD (Default OFF) # -- Set to ON to see all the commands used when building the CUDA file. When # using a Makefile generator the value defaults to VERBOSE (run make @@ -272,6 +277,8 @@ # CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS # implementation (alterative to: # CUDA_ADD_CUBLAS_TO_TARGET macro). +# CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. +# Only available for CUDA version 5.5+ # CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. # Only available for CUDA version 4.0+. # CUDA_curand_LIBRARY -- CUDA Random Number Generation library. @@ -518,11 +525,12 @@ macro(cuda_unset_include_and_libraries) # This only existed in the 3.0 version of the CUDA toolkit unset(CUDA_CUDARTEMU_LIBRARY CACHE) endif() - unset(CUDA_cupti_LIBRARY CACHE) + unset(CUDA_cudart_static_LIBRARY CACHE) unset(CUDA_cublas_LIBRARY CACHE) unset(CUDA_cublasemu_LIBRARY CACHE) unset(CUDA_cufft_LIBRARY CACHE) unset(CUDA_cufftemu_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) unset(CUDA_curand_LIBRARY CACHE) unset(CUDA_cusolver_LIBRARY CACHE) unset(CUDA_cusparse_LIBRARY CACHE) @@ -532,6 +540,8 @@ macro(cuda_unset_include_and_libraries) unset(CUDA_npps_LIBRARY CACHE) unset(CUDA_nvcuvenc_LIBRARY CACHE) unset(CUDA_nvcuvid_LIBRARY CACHE) + + unset(CUDA_USE_STATIC_CUDA_RUNTIME CACHE) endmacro() # Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, @@ -539,8 +549,8 @@ endmacro() if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") unset(CUDA_TOOLKIT_TARGET_DIR CACHE) unset(CUDA_NVCC_EXECUTABLE CACHE) - unset(CUDA_VERSION CACHE) cuda_unset_include_and_libraries() + unset(CUDA_VERSION CACHE) endif() if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") @@ -696,6 +706,53 @@ if(CUDA_VERSION VERSION_EQUAL "3.0") CUDA_CUDARTEMU_LIBRARY ) endif() +if(NOT CUDA_VERSION VERSION_LESS "5.5") + cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") + mark_as_advanced(CUDA_cudart_static_LIBRARY) +endif() +if(CUDA_cudart_static_LIBRARY) + # Set whether to use the static cuda runtime. + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) +else() + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" OFF) +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + if(UNIX) + # Check for the dependent libraries. Here we look for pthreads. + if (DEFINED CMAKE_THREAD_PREFER_PTHREAD) + set(_cuda_cmake_thread_prefer_pthread ${CMAKE_THREAD_PREFER_PTHREAD}) + endif() + set(CMAKE_THREAD_PREFER_PTHREAD 1) + + # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} + # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and + # -Werror causes the try_compile to fail. We will just temporarily disable other flags + # when doing the find_package command here. + set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) + set(CMAKE_C_FLAGS "-fPIC") + find_package(Threads REQUIRED) + set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) + + if (DEFINED _cuda_cmake_thread_prefer_pthread) + set(CMAKE_THREAD_PREFER_PTHREAD ${_cuda_cmake_thread_prefer_pthread}) + unset(_cuda_cmake_thread_prefer_pthread) + else() + unset(CMAKE_THREAD_PREFER_PTHREAD) + endif() + if (NOT APPLE) + # Here is librt that has things such as, clock_gettime, shm_open, and shm_unlink. + find_library(CUDA_rt_LIBRARY rt) + find_library(CUDA_dl_LIBRARY dl) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") + endif() + if (NOT CUDA_dl_LIBRARY) + message(WARNING "Expecting to find libdl for libcudart_static, but didn't find it.") + endif() + endif() + endif() +endif() # CUPTI library showed up in cuda toolkit 4.0 if(NOT CUDA_VERSION VERSION_LESS "4.0") @@ -703,12 +760,32 @@ if(NOT CUDA_VERSION VERSION_LESS "4.0") mark_as_advanced(CUDA_cupti_LIBRARY) endif() +# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are +# using the CUDA runtime. For the dynamic version of the runtime, most of the +# dependencies are brough in, but for the static version there are additional libraries +# and linker commands needed. +# Initialize to empty +set(CUDA_LIBRARIES) + # If we are using emulation mode and we found the cudartemu library then use # that one instead of cudart. if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) - set(CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + if (CUDA_rt_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) + endif() + if (CUDA_dl_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_dl_LIBRARY}) + endif() + if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) + endif() else() - set(CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) endif() # 1.1 toolkit on linux doesn't appear to have a separate library on diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index 261ebdb..3547628 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -36,7 +36,7 @@ if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW) endif() if(MFC_ATTEMPT_TRY_COMPILE) - if("MFC_HAVE_MFC" MATCHES "^MFC_HAVE_MFC$") + if(NOT DEFINED MFC_HAVE_MFC) set(CHECK_INCLUDE_FILE_VAR "afxwin.h") configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index d08423b..b4beec3 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -228,6 +228,8 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS) endif() set(MATLAB_VERSIONS_MAPPING + "R2015a=8.5" + "R2014b=8.4" "R2014a=8.3" "R2013b=8.2" "R2013a=8.1" diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 2de1fb3..bcbd17d 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -33,7 +33,7 @@ # # :: # -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<NAME> # [FOUND_VAR <resultVar>] # [REQUIRED_VARS <var1>...<varN>] # [VERSION_VAR <versionvar>] diff --git a/Modules/FindXCTest.cmake b/Modules/FindXCTest.cmake new file mode 100644 index 0000000..3cd9c22 --- /dev/null +++ b/Modules/FindXCTest.cmake @@ -0,0 +1,196 @@ +#[=======================================================================[.rst: +FindXCTest +---------- + +Functions to help creating and executing XCTest bundles. + +An XCTest bundle is a CFBundle with a special product-type +and bundle extension. The Mac Developer Library provides more +information in the `Testing with Xcode`_ document. + +.. _Testing with Xcode: http://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/testing_with_xcode/ + +Module Functions +^^^^^^^^^^^^^^^^ + +.. command:: xctest_add_bundle + + The ``xctest_add_bundle`` function creates a XCTest bundle named + <target> which will test the target <testee>. Supported target types + for testee are Frameworks and App Bundles:: + + xctest_add_bundle( + <target> # Name of the XCTest bundle + <testee> # Target name of the testee + ) + +.. command:: xctest_add_test + + The ``xctest_add_test`` function adds an XCTest bundle to the + project to be run by :manual:`ctest(1)`. The test will be named + <name> and tests <bundle>:: + + xctest_add_test( + <name> # Test name + <bundle> # Target name of XCTest bundle + ) + +Module Variables +^^^^^^^^^^^^^^^^ + +The following variables are set by including this module: + +.. variable:: XCTest_FOUND + + True if the XCTest Framework and executable were found. + +.. variable:: XCTest_EXECUTABLE + + The path to the xctest command line tool used to execute XCTest bundles. + +.. variable:: XCTest_INCLUDE_DIRS + + The directory containing the XCTest Framework headers. + +.. variable:: XCTest_LIBRARIES + + The location of the XCTest Framework. + +#]=======================================================================] + +#============================================================================= +# Copyright 2015 Gregor Jasny +# +# 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.) + +find_path(XCTest_INCLUDE_DIR + NAMES "XCTest/XCTest.h" + DOC "XCTest include directory") +mark_as_advanced(XCTest_INCLUDE_DIR) + +find_library(XCTest_LIBRARY + NAMES XCTest + DOC "XCTest Framework library") +mark_as_advanced(XCTest_LIBRARY) + +execute_process( + COMMAND xcrun --find xctest + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _xcrun_err) +if(_xcrun_out) + set(XCTest_EXECUTABLE "${_xcrun_out}" CACHE FILEPATH "XCTest executable") + mark_as_advanced(XCTest_EXECUTABLE) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(XCTest + FOUND_VAR XCTest_FOUND + REQUIRED_VARS XCTest_LIBRARY XCTest_INCLUDE_DIR XCTest_EXECUTABLE) + +if(XCTest_FOUND) + set(XCTest_INCLUDE_DIRS "${XCTest_INCLUDE_DIR}") + set(XCTest_LIBRARIES "${XCTest_LIBRARY}") +endif(XCTest_FOUND) + + +function(xctest_add_bundle target testee) + if(NOT XCTest_FOUND) + message(FATAL_ERROR "XCTest is required to create a XCTest Bundle.") + endif(NOT XCTest_FOUND) + + if(NOT CMAKE_OSX_SYSROOT) + message(FATAL_ERROR "Adding XCTest bundles requires CMAKE_OSX_SYSROOT to be set.") + endif() + + add_library(${target} MODULE ${ARGN}) + + set_target_properties(${target} PROPERTIES + BUNDLE TRUE + XCTEST TRUE + XCTEST_TESTEE ${testee}) + + target_link_libraries(${target} PRIVATE "-framework Foundation") + target_link_libraries(${target} PRIVATE ${XCTest_LIBRARIES}) + target_include_directories(${target} PRIVATE ${XCTest_INCLUDE_DIRS}) + + # retrieve testee target type + if(NOT TARGET ${testee}) + message(FATAL_ERROR "${testee} is not a target.") + endif() + get_property(_testee_type TARGET ${testee} PROPERTY TYPE) + get_property(_testee_framework TARGET ${testee} PROPERTY FRAMEWORK) + get_property(_testee_macosx_bundle TARGET ${testee} PROPERTY MACOSX_BUNDLE) + + if(_testee_type STREQUAL "SHARED_LIBRARY" AND _testee_framework) + # testee is a Framework + target_link_libraries(${target} PRIVATE ${testee}) + + elseif(_testee_type STREQUAL "EXECUTABLE" AND _testee_macosx_bundle) + # testee is an App Bundle + add_dependencies(${target} ${testee}) + if(XCODE) + set_target_properties(${target} PROPERTIES + XCODE_ATTRIBUTE_BUNDLE_LOADER "$(TEST_HOST)" + XCODE_ATTRIBUTE_TEST_HOST "$<TARGET_FILE:${testee}>") + else(XCODE) + target_link_libraries(${target} + PRIVATE -bundle_loader $<TARGET_FILE:${testee}>) + endif(XCODE) + + else() + message(FATAL_ERROR "Testee ${testee} is of unsupported type.") + endif() +endfunction(xctest_add_bundle) + + +function(xctest_add_test name bundle) + if(NOT XCTest_EXECUTABLE) + message(FATAL_ERROR "XCTest executable is required to register a test.") + endif() + + # check that bundle is a XCTest Bundle + + if(NOT TARGET ${bundle}) + message(FATAL_ERROR "${bundle} is not a target.") + endif(NOT TARGET ${bundle}) + + get_property(_test_type TARGET ${bundle} PROPERTY TYPE) + get_property(_test_bundle TARGET ${bundle} PROPERTY BUNDLE) + get_property(_test_xctest TARGET ${bundle} PROPERTY XCTEST) + + if(NOT _test_type STREQUAL "MODULE_LIBRARY" + OR NOT _test_xctest OR NOT _test_bundle) + message(FATAL_ERROR "Test ${bundle} is not an XCTest Bundle") + endif() + + # get and check testee properties + + get_property(_testee TARGET ${bundle} PROPERTY XCTEST_TESTEE) + if(NOT TARGET ${_testee}) + message(FATAL_ERROR "${_testee} is not a target.") + endif() + + get_property(_testee_type TARGET ${_testee} PROPERTY TYPE) + get_property(_testee_framework TARGET ${_testee} PROPERTY FRAMEWORK) + + # register test + + add_test( + NAME ${name} + COMMAND ${XCTest_EXECUTABLE} $<TARGET_LINKER_FILE_DIR:${bundle}>/../..) + + # point loader to testee in case rpath is disabled + + if(_testee_type STREQUAL "SHARED_LIBRARY" AND _testee_framework) + set_property(TEST ${name} APPEND PROPERTY + ENVIRONMENT DYLD_FRAMEWORK_PATH=$<TARGET_LINKER_FILE_DIR:${_testee}>/..) + endif() +endfunction(xctest_add_test) diff --git a/Modules/Platform/BlueGeneQ-base.cmake b/Modules/Platform/BlueGeneQ-base.cmake new file mode 100644 index 0000000..fa8dc52 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-base.cmake @@ -0,0 +1,177 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +# +# Blue Gene/Q base platform file. +# +# NOTE: Do not set your platform to "BlueGeneQ-base". This file is +# included by the real platform files. Use one of these two platforms +# instead: +# +# BlueGeneQ-dynamic For dynamically linked executables +# BlueGeneQ-static For statically linked executables +# +# The platform you choose doesn't affect whether or not you can build +# shared or static libraries -- it ONLY changs whether exeuatbles are linked +# statically or dynamically. +# +# This platform file tries its best to adhere to the behavior of the MPI +# compiler wrappers included with the latest BG/P drivers. +# + +# +# This adds directories that find commands should specifically ignore +# for cross compiles. Most of these directories are the includeand +# lib directories for the frontend on BG/P systems. Not ignoring +# these can cause things like FindX11 to find a frontend PPC version +# mistakenly. We use this on BG instead of re-rooting because backend +# libraries are typically strewn about the filesystem, and we can't +# re-root ALL backend libraries to a single place. +# +set(CMAKE_SYSTEM_IGNORE_PATH + /lib /lib64 /include + /usr/lib /usr/lib64 /usr/include + /usr/local/lib /usr/local/lib64 /usr/local/include + /usr/X11/lib /usr/X11/lib64 /usr/X11/include + /usr/lib/X11 /usr/lib64/X11 /usr/include/X11 + /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/include + /usr/X11R7/lib /usr/X11R7/lib64 /usr/X11R7/include +) + +# +# Indicate that this is a unix-like system +# +set(UNIX 1) + +# +# Library prefixes, suffixes, extra libs. +# +set(CMAKE_LINK_LIBRARY_SUFFIX "") +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # lib +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") # .a + +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so +set(CMAKE_EXECUTABLE_SUFFIX "") # .exe + +set(CMAKE_DL_LIBS "dl") + +# +# BG/Q supports dynamic libraries regardless of whether we're building +# static or dynamic *executables*. +# +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) +set(CMAKE_FIND_LIBRARY_PREFIXES "lib") + +# +# For BGQ builds, we're cross compiling, but we don't want to re-root things +# (e.g. with CMAKE_FIND_ROOT_PATH) because users may have libraries anywhere on +# the shared filesystems, and this may lie outside the root. Instead, we set the +# system directories so that the various system BG CNK library locations are +# searched first. This is not the clearest thing in the world, given IBM's driver +# layout, but this should cover all the standard ones. +# +macro(__BlueGeneQ_common_setup compiler_id lang) + # Need to use the version of the comm lib compiled with the right compiler. + set(__BlueGeneQ_commlib_dir gcc) + if (${compiler_id} STREQUAL XL) + set(__BlueGeneQ_commlib_dir xl) + endif() + + set(CMAKE_SYSTEM_LIBRARY_PATH + /bgsys/drivers/ppcfloor/comm/default/lib # default comm layer (used by mpi compiler wrappers) + /bgsys/drivers/ppcfloor/comm/${__BlueGeneQ_commlib_dir}/lib # PAMI, other lower-level comm libraries + /bgsys/drivers/ppcfloor/gnu-linux/lib # CNK python installation directory + /bgsys/drivers/ppcfloor/gnu-linux/powerpc64-bgq-linux/lib # CNK Linux image -- standard runtime libs, pthread, etc. + ) + + # Add all the system include paths. + set(CMAKE_SYSTEM_INCLUDE_PATH + /bgsys/drivers/ppcfloor/comm/sys/include + /bgsys/drivers/ppcfloor/ + /bgsys/drivers/ppcfloor/spi/include + /bgsys/drivers/ppcfloor/spi/include/kernel/cnk + /bgsys/drivers/ppcfloor/comm/${__BlueGeneQ_commlib_dir}/include + ) + + # Ensure that the system directories are included with the regular compilers, as users will expect this + # to do the same thing as the MPI compilers, which add these flags. + set(BGQ_SYSTEM_INCLUDES "") + foreach(dir ${CMAKE_SYSTEM_INCLUDE_PATH}) + set(BGQ_SYSTEM_INCLUDES "${BGQ_SYSTEM_INCLUDES} -I${dir}") + endforeach() + set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <FLAGS> -o <OBJECT> -c <SOURCE>") + set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <FLAGS> -o <OBJECT> -c <SOURCE>") + + # + # Code below does setup for shared libraries. That this is done + # regardless of whether the platform is static or dynamic -- you can make + # shared libraries even if you intend to make static executables, you just + # can't make a dynamic executable if you use the static platform file. + # + if (${compiler_id} STREQUAL XL) + # Flags for XL compilers if we explicitly detected XL + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") + else() + # Assume flags for GNU compilers (if the ID is GNU *or* anything else). + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + endif() + + # Both toolchains use the GNU linker on BG/P, so these options are shared. + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,") + set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty + +endmacro() + +# +# This macro needs to be called for dynamic library support. Unfortunately on BG, +# We can't support both static and dynamic links in the same platform file. The +# dynamic link platform file needs to call this explicitly to set up dynamic linking. +# +macro(__BlueGeneQ_setup_dynamic compiler_id lang) + __BlueGeneQ_common_setup(${compiler_id} ${lang}) + + if (${compiler_id} STREQUAL XL) + set(BGQ_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") + else() + set(BGQ_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") + endif() + + # For dynamic executables, need to provide special BG/Q arguments. + set(BGQ_${lang}_DEFAULT_EXE_FLAGS + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + set(CMAKE_${lang}_LINK_EXECUTABLE + "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGQ_${lang}_DYNAMIC_EXE_FLAGS} ${BGQ_${lang}_DEFAULT_EXE_FLAGS}") +endmacro() + +# +# This macro needs to be called for static builds. Right now it just adds -Wl,-relax +# to the link line. +# +macro(__BlueGeneQ_setup_static compiler_id lang) + __BlueGeneQ_common_setup(${compiler_id} ${lang}) + + # For static executables, use default link settings. + set(BGQ_${lang}_DEFAULT_EXE_FLAGS + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + set(CMAKE_${lang}_LINK_EXECUTABLE + "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGQ_${lang}_DEFAULT_EXE_FLAGS}") +endmacro() diff --git a/Modules/Platform/BlueGeneQ-dynamic-GNU-C.cmake b/Modules/Platform/BlueGeneQ-dynamic-GNU-C.cmake new file mode 100644 index 0000000..102ac80 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-dynamic-GNU-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_dynamic(GNU C) diff --git a/Modules/Platform/BlueGeneQ-dynamic-GNU-CXX.cmake b/Modules/Platform/BlueGeneQ-dynamic-GNU-CXX.cmake new file mode 100644 index 0000000..cd8ab24 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-dynamic-GNU-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_dynamic(GNU CXX) diff --git a/Modules/Platform/BlueGeneQ-dynamic-GNU-Fortran.cmake b/Modules/Platform/BlueGeneQ-dynamic-GNU-Fortran.cmake new file mode 100644 index 0000000..c029f0f --- /dev/null +++ b/Modules/Platform/BlueGeneQ-dynamic-GNU-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_dynamic(GNU Fortran) diff --git a/Modules/Platform/BlueGeneQ-dynamic-XL-C.cmake b/Modules/Platform/BlueGeneQ-dynamic-XL-C.cmake new file mode 100644 index 0000000..0077313 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-dynamic-XL-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_dynamic(XL C) diff --git a/Modules/Platform/BlueGeneQ-dynamic-XL-CXX.cmake b/Modules/Platform/BlueGeneQ-dynamic-XL-CXX.cmake new file mode 100644 index 0000000..0f43cb2 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-dynamic-XL-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_dynamic(XL CXX) diff --git a/Modules/Platform/BlueGeneQ-dynamic-XL-Fortran.cmake b/Modules/Platform/BlueGeneQ-dynamic-XL-Fortran.cmake new file mode 100644 index 0000000..12e446e --- /dev/null +++ b/Modules/Platform/BlueGeneQ-dynamic-XL-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_dynamic(XL Fortran) diff --git a/Modules/Platform/BlueGeneQ-dynamic.cmake b/Modules/Platform/BlueGeneQ-dynamic.cmake new file mode 100644 index 0000000..0283900 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-dynamic.cmake @@ -0,0 +1,17 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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(Platform/BlueGeneQ-base) +set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") diff --git a/Modules/Platform/BlueGeneQ-static-GNU-C.cmake b/Modules/Platform/BlueGeneQ-static-GNU-C.cmake new file mode 100644 index 0000000..70c84ba --- /dev/null +++ b/Modules/Platform/BlueGeneQ-static-GNU-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_static(GNU C) diff --git a/Modules/Platform/BlueGeneQ-static-GNU-CXX.cmake b/Modules/Platform/BlueGeneQ-static-GNU-CXX.cmake new file mode 100644 index 0000000..8f991de --- /dev/null +++ b/Modules/Platform/BlueGeneQ-static-GNU-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_static(GNU CXX) diff --git a/Modules/Platform/BlueGeneQ-static-GNU-Fortran.cmake b/Modules/Platform/BlueGeneQ-static-GNU-Fortran.cmake new file mode 100644 index 0000000..24dd9e7 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-static-GNU-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_static(GNU Fortran) diff --git a/Modules/Platform/BlueGeneQ-static-XL-C.cmake b/Modules/Platform/BlueGeneQ-static-XL-C.cmake new file mode 100644 index 0000000..5555a68 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-static-XL-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_static(XL C) diff --git a/Modules/Platform/BlueGeneQ-static-XL-CXX.cmake b/Modules/Platform/BlueGeneQ-static-XL-CXX.cmake new file mode 100644 index 0000000..07c3c3d --- /dev/null +++ b/Modules/Platform/BlueGeneQ-static-XL-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_static(XL CXX) diff --git a/Modules/Platform/BlueGeneQ-static-XL-Fortran.cmake b/Modules/Platform/BlueGeneQ-static-XL-Fortran.cmake new file mode 100644 index 0000000..6f99933 --- /dev/null +++ b/Modules/Platform/BlueGeneQ-static-XL-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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.) + +__BlueGeneQ_setup_static(XL Fortran) diff --git a/Modules/Platform/BlueGeneQ-static.cmake b/Modules/Platform/BlueGeneQ-static.cmake new file mode 100644 index 0000000..30b530d --- /dev/null +++ b/Modules/Platform/BlueGeneQ-static.cmake @@ -0,0 +1,17 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# 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(Platform/BlueGeneQ-base) +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index b912d98..4e4810a 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -167,12 +167,20 @@ if(_CMAKE_OSX_SYSROOT_PATH) ${_CMAKE_OSX_SYSROOT_PATH}/System/Library/Frameworks ) # add platform developer framework path if exists - get_filename_component(_CMAKE_OSX_PLATFORM_FRAMEWORK_PATH - ${_CMAKE_OSX_SYSROOT_PATH}/../../Library/Frameworks ABSOLUTE) - if(IS_DIRECTORY ${_CMAKE_OSX_PLATFORM_FRAMEWORK_PATH}) - list(APPEND CMAKE_SYSTEM_FRAMEWORK_PATH - ${_CMAKE_OSX_PLATFORM_FRAMEWORK_PATH}) - endif() + foreach(_path + # Xcode 6 + ${_CMAKE_OSX_SYSROOT_PATH}/../../Library/Frameworks + # Xcode 5 iOS + ${_CMAKE_OSX_SYSROOT_PATH}/Developer/Library/Frameworks + # Xcode 5 OSX + ${_CMAKE_OSX_SYSROOT_PATH}/../../../../../Library/Frameworks + ) + get_filename_component(_abolute_path "${_path}" ABSOLUTE) + if(EXISTS "${_abolute_path}") + list(APPEND CMAKE_SYSTEM_FRAMEWORK_PATH "${_abolute_path}") + break() + endif() + endforeach() endif() list(APPEND CMAKE_SYSTEM_FRAMEWORK_PATH /Library/Frameworks diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake index 3cbb35c..baa2248 100644 --- a/Modules/Platform/Linux-PGI.cmake +++ b/Modules/Platform/Linux-PGI.cmake @@ -21,7 +21,7 @@ set(__LINUX_COMPILER_PGI 1) macro(__linux_compiler_pgi lang) # Shared library compile and link flags. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") - set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") endmacro() diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index fe8e003..e40a74f 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -52,6 +52,6 @@ include(Platform/UnixPaths) # Debian has lib64 paths only for compatibility so they should not be # searched. -if(EXISTS "/etc/debian_version") +if(NOT CMAKE_CROSSCOMPILING AND EXISTS "/etc/debian_version") set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE) endif() diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 3a6acd8..5eb0ca8 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -340,6 +340,13 @@ set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake) function(add_jar _TARGET_NAME) + cmake_parse_arguments(_add_jar + "" + "VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST" + "SOURCES;INCLUDE_JARS" + ${ARGN} + ) + # In CMake < 2.8.12, add_jar used variables which were set prior to calling # add_jar for customizing the behavior of add_jar. In order to be backwards # compatible, check if any of those variables are set, and use them to @@ -347,28 +354,21 @@ function(add_jar _TARGET_NAME) # argument will override the value set here.) # # New features should use named arguments only. - if(DEFINED CMAKE_JAVA_TARGET_VERSION) + if(NOT DEFINED _add_jar_VERSION AND DEFINED CMAKE_JAVA_TARGET_VERSION) set(_add_jar_VERSION "${CMAKE_JAVA_TARGET_VERSION}") endif() - if(DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR) + if(NOT DEFINED _add_jar_OUTPUT_DIR AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR) set(_add_jar_OUTPUT_DIR "${CMAKE_JAVA_TARGET_OUTPUT_DIR}") endif() - if(DEFINED CMAKE_JAVA_TARGET_OUTPUT_NAME) + if(NOT DEFINED _add_jar_OUTPUT_NAME AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_NAME) set(_add_jar_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}") # reset set(CMAKE_JAVA_TARGET_OUTPUT_NAME) endif() - if(DEFINED CMAKE_JAVA_JAR_ENTRY_POINT) + if(NOT DEFINED _add_jar_ENTRY_POINT AND DEFINED CMAKE_JAVA_JAR_ENTRY_POINT) set(_add_jar_ENTRY_POINT "${CMAKE_JAVA_JAR_ENTRY_POINT}") endif() - cmake_parse_arguments(_add_jar - "" - "VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST" - "SOURCES;INCLUDE_JARS" - ${ARGN} - ) - set(_JAVA_SOURCE_FILES ${_add_jar_SOURCES} ${_add_jar_UNPARSED_ARGUMENTS}) if (NOT DEFINED _add_jar_OUTPUT_DIR) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 7939b1f..7423418 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -204,8 +204,7 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ${swig_include_dirs} -o "${swig_generated_file_fullname}" "${swig_source_file_fullname}" - MAIN_DEPENDENCY "${swig_source_file_fullname}" - DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS} + DEPENDS "${swig_source_file_fullname}" ${SWIG_MODULE_${name}_EXTRA_DEPS} COMMENT "Swig source") set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files} PROPERTIES GENERATED 1) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index d18f47c..f4dcb21 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -586,7 +586,7 @@ function(write_compiler_detection_header # if ${def_name} # define ${def_value} nullptr # else -# define ${def_value} static_cast<void*>(0) +# define ${def_value} 0 # endif \n") endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 482bd39..04f6a81 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -229,6 +229,8 @@ set(SRCS cmExtraKateGenerator.h cmExtraSublimeTextGenerator.cxx cmExtraSublimeTextGenerator.h + cmExtraQbsGenerator.cxx + cmExtraQbsGenerator.h cmFileLock.cxx cmFileLock.h cmFileLockPool.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7d81aa9..1e4302e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 2) -set(CMake_VERSION_PATCH 20150319) +set(CMake_VERSION_PATCH 20150409) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 257ce7a..99eabf2 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -430,7 +430,7 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, tmp << name << "=\"" << value << '"'; source.AddProcessingInstruction("define", - cmWIXSourceWriter::WindowsCodepageToUtf8(tmp.str())); + cmWIXSourceWriter::CMakeEncodingToUtf8(tmp.str())); } bool cmCPackWIXGenerator::CreateWiXSourceFiles() diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index ef67b23..e066c28 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -132,8 +132,8 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg) void cmWIXPatchParser::ReportValidationError(std::string const& message) { - ReportError(XML_GetCurrentLineNumber(Parser), - XML_GetCurrentColumnNumber(Parser), + ReportError(XML_GetCurrentLineNumber(static_cast<XML_Parser>(this->Parser)), + XML_GetCurrentColumnNumber(static_cast<XML_Parser>(this->Parser)), message.c_str()); } diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index aad19da..219fca8 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -10,6 +10,8 @@ See the License for more information. ============================================================================*/ +#include "cmStandardIncludes.h" + #include "cmWIXSourceWriter.h" #include <CPack/cmCPackGenerator.h> @@ -118,7 +120,7 @@ void cmWIXSourceWriter::AddProcessingInstruction( void cmWIXSourceWriter::AddAttribute( std::string const& key, std::string const& value) { - std::string utf8 = WindowsCodepageToUtf8(value); + std::string utf8 = CMakeEncodingToUtf8(value); File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; } @@ -132,8 +134,11 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty( } } -std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value) +std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value) { +#ifdef CMAKE_ENCODING_UTF8 + return value; +#else if(value.empty()) { return std::string(); @@ -167,6 +172,7 @@ std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value) &utf8[0], static_cast<int>(utf8.size()), 0, 0); return std::string(&utf8[0], utf8.size()); +#endif } diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 3957d96..3b9999c 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -43,7 +43,7 @@ public: void AddAttributeUnlessEmpty( std::string const& key, std::string const& value); - static std::string WindowsCodepageToUtf8(std::string const& value); + static std::string CMakeEncodingToUtf8(std::string const& value); protected: cmCPackLog* Logger; diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index e2437b5..05b5cd9 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -63,6 +63,14 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME"); filePrefix += "/"; } + const char* installPrefix = + this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); + if(installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0) + { + // add to file prefix and remove the leading '/' + filePrefix += installPrefix+1; + filePrefix += "/"; + } std::vector<std::string>::const_iterator fileIt; for (fileIt = component->Files.begin(); fileIt != component->Files.end(); ++fileIt ) diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 6e7a26b..b2d7019 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -221,6 +221,11 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) bundle_path += ".app"; // A list of additional files to sign, ie. frameworks and plugins. + const std::string sign_parameter = + this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER") + ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER") + : "--deep -f"; + const std::string sign_files = this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : ""; @@ -234,7 +239,8 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) { std::ostringstream temp_sign_file_cmd; temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); - temp_sign_file_cmd << " --deep -f -s \"" << cpack_apple_cert_app; + temp_sign_file_cmd << " " << sign_parameter << " -s \"" + << cpack_apple_cert_app; temp_sign_file_cmd << "\" -i "; temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID"); temp_sign_file_cmd << " \""; @@ -254,7 +260,8 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) // sign main binary std::ostringstream temp_sign_binary_cmd; temp_sign_binary_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); - temp_sign_binary_cmd << " --deep -f -s \"" << cpack_apple_cert_app; + temp_sign_binary_cmd << " " << sign_parameter << " -s \"" + << cpack_apple_cert_app; temp_sign_binary_cmd << "\" \"" << bundle_path << "\""; if(!this->RunCommand(temp_sign_binary_cmd, &output)) @@ -269,7 +276,8 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) // sign app bundle std::ostringstream temp_codesign_cmd; temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); - temp_codesign_cmd << " --deep -f -s \"" << cpack_apple_cert_app << "\""; + temp_codesign_cmd << " " << sign_parameter << " -s \"" + << cpack_apple_cert_app << "\""; if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) { temp_codesign_cmd << " --entitlements "; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0a64bd5..fcf4122 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -507,6 +507,11 @@ int cmCPackDebGenerator::createDeb() //int retVal = -1; res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &retval, toplevel.c_str(), this->GeneratorVerbose, 0); + if ( !res || retval ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running cmake -E md5sum " + << cmd << std::endl); + } // debian md5sums entries are like this: // 014f3604694729f3bf19263bac599765 usr/bin/ccmake // thus strip the full path (with the trailing slash) @@ -800,12 +805,14 @@ static int put_arobj(CF *cfp, struct stat *sb) if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, - sb->st_mode, (long long)sb->st_size + lname, ARFMAG); + (unsigned)sb->st_mode, (long long)sb->st_size + lname, + ARFMAG); else { lname = 0; (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, - sb->st_mode, (long long)sb->st_size, ARFMAG); + (unsigned)sb->st_mode, (long long)sb->st_size, + ARFMAG); } off_t size = sb->st_size; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index ee255af..995eb0d 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -655,26 +655,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths()); // Does this generator require pre-install? - if ( globalGenerator->GetPreinstallTargetName() ) + if (const char* preinstall = globalGenerator->GetPreinstallTargetName()) { - globalGenerator->FindMakeProgram(this->MakefileMap); - std::string cmakeMakeProgram - = this->MakefileMap->GetSafeDefinition("CMAKE_MAKE_PROGRAM"); - std::vector<std::string> buildCommand; - globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram, - installProjectName, installDirectory, - globalGenerator->GetPreinstallTargetName(), - buildConfig, false, false); - std::string buildCommandStr = - cmSystemTools::PrintSingleCommand(buildCommand); + std::string buildCommand = + globalGenerator->GenerateCMakeBuildCommand( + preinstall, buildConfig, "", false); cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Install command: " << buildCommandStr << std::endl); + "- Install command: " << buildCommand << std::endl); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: " << installProjectName << std::endl); std::string output; int retVal = 1; bool resB = - cmSystemTools::RunSingleCommand(buildCommand, + cmSystemTools::RunSingleCommand(buildCommand.c_str(), &output, &retVal, installDirectory.c_str(), @@ -684,12 +677,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << buildCommandStr << std::endl + ofs << "# Run command: " << buildCommand << std::endl << "# Directory: " << installDirectory << std::endl << "# Output:" << std::endl << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << buildCommandStr + "Problem running install command: " << buildCommand << std::endl << "Please check " << tmpFile << " for errors" << std::endl); @@ -1506,7 +1499,10 @@ bool cmCPackGenerator::SupportsComponentInstallation() const //---------------------------------------------------------------------- bool cmCPackGenerator::WantsComponentInstallation() const { - return (!IsOn("CPACK_MONOLITHIC_INSTALL") & SupportsComponentInstallation()); + return (!IsOn("CPACK_MONOLITHIC_INSTALL") + && SupportsComponentInstallation() + // check that package at least has components + && !(this->ComponentGroups.empty() || this->Components.empty())); } //---------------------------------------------------------------------- diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 6106472..00b23cd 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -203,6 +203,9 @@ int main (int argc, char const* const* argv) cmgg.SetCMakeInstance(&cminst); cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator()); cmMakefile* globalMF = cmlg->GetMakefile(); +#if defined(__CYGWIN__) + globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); +#endif bool cpackConfigFileSpecified = true; if ( cpackConfigFile.empty() ) diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 0827037..586070b 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -18,7 +18,6 @@ #include "cmGlobalGenerator.h" #include <cmsys/Process.h> #include "cmCTestTestHandler.h" -#include "cmCacheManager.h" //---------------------------------------------------------------------- cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() @@ -255,7 +254,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cm.SetGeneratorToolset(this->BuildGeneratorToolset); // Load the cache to make CMAKE_MAKE_PROGRAM available. - cm.GetCacheManager()->LoadCache(this->BinaryDir); + cm.LoadCache(this->BinaryDir); } else { diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index eb33d8e..bd090db 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -121,6 +121,11 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) this->RunningCount += GetProcessorsUsed(test); cmCTestRunTest* testRun = new cmCTestRunTest(this->TestHandler); + if(this->CTest->GetRepeatUntilFail()) + { + testRun->SetRunUntilFailOn(); + testRun->SetNumberOfRuns(this->CTest->GetTestRepeat()); + } testRun->SetIndex(test); testRun->SetTestProperties(this->Properties[test]); @@ -289,7 +294,13 @@ bool cmCTestMultiProcessHandler::CheckOutput() cmCTestRunTest* p = *i; int test = p->GetIndex(); - if(p->EndTest(this->Completed, this->Total, true)) + bool testResult = p->EndTest(this->Completed, this->Total, true); + if(p->StartAgain()) + { + this->Completed--; // remove the completed test because run again + continue; + } + if(testResult) { this->Passed->push_back(p->GetTestProperties()->Name); } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 01a7884..d7da2b4 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -33,6 +33,9 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler) this->CompressedOutput = ""; this->CompressionRatio = 2; this->StopTimePassed = false; + this->NumberOfRunsLeft = 1; // default to 1 run of the test + this->RunUntilFail = false; // default to run the test once + this->RunAgain = false; // default to not having to run again } cmCTestRunTest::~cmCTestRunTest() @@ -357,13 +360,50 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) this->MemCheckPostProcess(); this->ComputeWeightedCost(); } - // Always push the current TestResult onto the + // If the test does not need to rerun push the current TestResult onto the // TestHandler vector - this->TestHandler->TestResults.push_back(this->TestResult); + if(!this->NeedsToRerun()) + { + this->TestHandler->TestResults.push_back(this->TestResult); + } delete this->TestProcess; return passed; } +bool cmCTestRunTest::StartAgain() +{ + if(!this->RunAgain) + { + return false; + } + this->RunAgain = false; // reset + // change to tests directory + std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); + cmSystemTools::ChangeDirectory(this->TestProperties->Directory); + this->StartTest(this->TotalNumberOfTests); + // change back + cmSystemTools::ChangeDirectory(current_dir); + return true; +} + +bool cmCTestRunTest::NeedsToRerun() +{ + this->NumberOfRunsLeft--; + if(this->NumberOfRunsLeft == 0) + { + return false; + } + // if number of runs left is not 0, and we are running until + // we find a failed test, then return true so the test can be + // restarted + if(this->RunUntilFail + && this->TestResult.Status == cmCTestTestHandler::COMPLETED) + { + this->RunAgain = true; + return true; + } + return false; +} //---------------------------------------------------------------------- void cmCTestRunTest::ComputeWeightedCost() { @@ -400,6 +440,7 @@ void cmCTestRunTest::MemCheckPostProcess() // Starts the execution of a test. Returns once it has started bool cmCTestRunTest::StartTest(size_t total) { + this->TotalNumberOfTests = total; // save for rerun case cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2*getNumWidth(total) + 8) << "Start " << std::setw(getNumWidth(this->TestHandler->GetMaxIndex())) @@ -494,10 +535,10 @@ bool cmCTestRunTest::StartTest(size_t total) //---------------------------------------------------------------------- void cmCTestRunTest::ComputeArguments() { + this->Arguments.clear(); // reset becaue this might be a rerun std::vector<std::string>::const_iterator j = this->TestProperties->Args.begin(); ++j; // skip test name - // find the test executable if(this->TestHandler->MemCheck) { @@ -697,10 +738,28 @@ bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout, void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total)) - << completed << "/"); - cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total)) - << total << " "); + // if this is the last or only run of this test + // then print out completed / total + // Only issue is if a test fails and we are running until fail + // then it will never print out the completed / total, same would + // got for run until pass. Trick is when this is called we don't + // yet know if we are passing or failing. + if(this->NumberOfRunsLeft == 1) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total)) + << completed << "/"); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total)) + << total << " "); + } + // if this is one of several runs of a test just print blank space + // to keep things neat + else + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total)) + << " " << " "); + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total)) + << " " << " "); + } if ( this->TestHandler->MemCheck ) { diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index 476f3e1..3b5c831 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -27,6 +27,8 @@ public: cmCTestRunTest(cmCTestTestHandler* handler); ~cmCTestRunTest(); + void SetNumberOfRuns(int n) {this->NumberOfRunsLeft = n;} + void SetRunUntilFailOn() { this->RunUntilFail = true;} void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties * prop) { this->TestProperties = prop; } @@ -58,7 +60,10 @@ public: void ComputeArguments(); void ComputeWeightedCost(); + + bool StartAgain(); private: + bool NeedsToRerun(); void DartProcessing(); void ExeNotFound(std::string exe); // Figures out a final timeout which is min(STOP_TIME, NOW+TIMEOUT) @@ -92,6 +97,10 @@ private: std::string ActualCommand; std::vector<std::string> Arguments; bool StopTimePassed; + bool RunUntilFail; + int NumberOfRunsLeft; + bool RunAgain; + size_t TotalNumberOfTests; }; inline int getNumWidth(size_t n) diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 682f95f..4f028c4 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -18,6 +18,9 @@ #include "cmCursesFilePathWidget.h" #include "cmCursesDummyWidget.h" #include "../cmSystemTools.h" +#include "../cmake.h" + +#include <assert.h> cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( const std::string& key, @@ -32,7 +35,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( - const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew, + const std::string& key, cmake *cm, bool isNew, int labelwidth, int entrywidth) : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth) { @@ -47,11 +50,13 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } this->Entry = 0; - switch ( it.GetType() ) + const char* value = cm->GetCacheManager()->GetCacheEntryValue(key); + assert(value); + switch (cm->GetCacheManager()->GetCacheEntryType(key)) { - case cmCacheManager::BOOL: + case cmCacheManager::BOOL: this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); - if (cmSystemTools::IsOn(it.GetValue().c_str())) + if (cmSystemTools::IsOn(value)) { static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true); } @@ -62,40 +67,40 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( break; case cmCacheManager::PATH: this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1); - static_cast<cmCursesPathWidget*>(this->Entry)->SetString( - it.GetValue()); + static_cast<cmCursesPathWidget*>(this->Entry)->SetString(value); break; case cmCacheManager::FILEPATH: this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1); - static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString( - it.GetValue()); + static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value); break; case cmCacheManager::STRING: - if(it.PropertyExists("STRINGS")) + { + const char* stringsProp = cm->GetCacheManager() + ->GetCacheEntryProperty(key, "STRINGS"); + if(stringsProp) { cmCursesOptionsWidget* ow = new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1); this->Entry = ow; std::vector<std::string> options; - cmSystemTools::ExpandListArgument( - std::string(it.GetProperty("STRINGS")), options); + cmSystemTools::ExpandListArgument(stringsProp, options); for(std::vector<std::string>::iterator si = options.begin(); si != options.end(); ++si) { ow->AddOption(*si); } - ow->SetOption(it.GetValue()); + ow->SetOption(value); } else { this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1); - static_cast<cmCursesStringWidget*>(this->Entry)->SetString( - it.GetValue()); + static_cast<cmCursesStringWidget*>(this->Entry)->SetString(value); } break; + } case cmCacheManager::UNINITIALIZED: cmSystemTools::Error("Found an undefined variable: ", - it.GetName().c_str()); + key.c_str()); break; default: // TODO : put warning message here diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 7cdf13b..dc4ee4af 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -21,7 +21,7 @@ public: cmCursesCacheEntryComposite(const std::string& key, int labelwidth, int entrywidth); cmCursesCacheEntryComposite(const std::string& key, - const cmCacheManager::CacheIterator& it, + cmake *cm, bool isNew, int labelwidth, int entrywidth); ~cmCursesCacheEntryComposite(); const char* GetValue(); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index d60062e..833d540 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -111,13 +111,17 @@ void cmCursesMainForm::InitializeUI() // Count non-internal and non-static entries int count=0; - for(cmCacheManager::CacheIterator i = - this->CMakeInstance->GetCacheManager()->NewIterator(); - !i.IsAtEnd(); i.Next()) + std::vector<std::string> cacheKeys = + this->CMakeInstance->GetCacheManager()->GetCacheEntryKeys(); + + for(std::vector<std::string>::const_iterator it = cacheKeys.begin(); + it != cacheKeys.end(); ++it) { - if ( i.GetType() != cmCacheManager::INTERNAL && - i.GetType() != cmCacheManager::STATIC && - i.GetType() != cmCacheManager::UNINITIALIZED) + cmCacheManager::CacheEntryType t = this->CMakeInstance->GetCacheManager() + ->GetCacheEntryType(*it); + if (t != cmCacheManager::INTERNAL && + t != cmCacheManager::STATIC && + t != cmCacheManager::UNINITIALIZED) { ++count; } @@ -139,45 +143,49 @@ void cmCursesMainForm::InitializeUI() // Create the composites. // First add entries which are new - for(cmCacheManager::CacheIterator i = - this->CMakeInstance->GetCacheManager()->NewIterator(); - !i.IsAtEnd(); i.Next()) + for(std::vector<std::string>::const_iterator it = cacheKeys.begin(); + it != cacheKeys.end(); ++it) { - std::string key = i.GetName(); - if ( i.GetType() == cmCacheManager::INTERNAL || - i.GetType() == cmCacheManager::STATIC || - i.GetType() == cmCacheManager::UNINITIALIZED ) + std::string key = *it; + cmCacheManager::CacheEntryType t = this->CMakeInstance->GetCacheManager() + ->GetCacheEntryType(*it); + if (t == cmCacheManager::INTERNAL || + t == cmCacheManager::STATIC || + t == cmCacheManager::UNINITIALIZED ) { continue; } if (!this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite(key, i, - true, 30, - entrywidth)); + newEntries->push_back(new cmCursesCacheEntryComposite(key, + this->CMakeInstance, + true, 30, + entrywidth)); this->OkToGenerate = false; } } // then add entries which are old - for(cmCacheManager::CacheIterator i = - this->CMakeInstance->GetCacheManager()->NewIterator(); - !i.IsAtEnd(); i.Next()) + for(std::vector<std::string>::const_iterator it = cacheKeys.begin(); + it != cacheKeys.end(); ++it) { - std::string key = i.GetName(); - if ( i.GetType() == cmCacheManager::INTERNAL || - i.GetType() == cmCacheManager::STATIC || - i.GetType() == cmCacheManager::UNINITIALIZED ) + std::string key = *it; + cmCacheManager::CacheEntryType t = this->CMakeInstance->GetCacheManager() + ->GetCacheEntryType(*it); + if (t == cmCacheManager::INTERNAL || + t == cmCacheManager::STATIC || + t == cmCacheManager::UNINITIALIZED ) { continue; } if (this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite(key, i, - false, 30, - entrywidth)); + newEntries->push_back(new cmCursesCacheEntryComposite(key, + this->CMakeInstance, + false, 30, + entrywidth)); } } } @@ -216,10 +224,13 @@ void cmCursesMainForm::RePost() std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || - (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) + const char* existingValue = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryValue((*it)->GetValue()); + bool advanced = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED"); + if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -245,10 +256,13 @@ void cmCursesMainForm::RePost() std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || - (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) + const char* existingValue = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryValue((*it)->GetValue()); + bool advanced = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED"); + if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -314,10 +328,13 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || - (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) + const char* existingValue = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryValue((*it)->GetValue()); + bool advanced = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED"); + if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -334,10 +351,13 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || - (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) + const char* existingValue = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryValue((*it)->GetValue()); + bool advanced = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED"); + if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -495,11 +515,12 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) // Get the help string of the current entry // and add it to the help string - cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField); - if (!it.IsAtEnd()) + const char* existingValue = + this->CMakeInstance->GetCacheManager()->GetCacheEntryValue(curField); + if (existingValue) { - const char* hs = it.GetProperty("HELPSTRING"); + const char* hs = this->CMakeInstance->GetCacheManager() + ->GetCacheEntryProperty(curField, "HELPSTRING"); if ( hs ) { strncpy(help, hs, 127); @@ -639,7 +660,7 @@ int cmCursesMainForm::Configure(int noconfigure) // always save the current gui values to disk this->FillCacheManagerFromUI(); - this->CMakeInstance->GetCacheManager()->SaveCache( + this->CMakeInstance->SaveCache( this->CMakeInstance->GetHomeOutputDirectory()); this->LoadCache(0); @@ -792,23 +813,28 @@ void cmCursesMainForm::FillCacheManagerFromUI() size_t size = this->Entries->size(); for(size_t i=0; i < size; i++) { - cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator( - (*this->Entries)[i]->Key.c_str()); - if (!it.IsAtEnd()) + std::string cacheKey = (*this->Entries)[i]->Key; + const char* existingValue = this->CMakeInstance->GetCacheManager() + ->GetCacheEntryValue(cacheKey); + if (existingValue) { - std::string oldValue = it.GetValue(); + std::string oldValue = existingValue; std::string newValue = (*this->Entries)[i]->Entry->GetValue(); std::string fixedOldValue; std::string fixedNewValue; - this->FixValue(it.GetType(), oldValue, fixedOldValue); - this->FixValue(it.GetType(), newValue, fixedNewValue); + cmCacheManager::CacheEntryType t = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryType(cacheKey); + this->FixValue(t, oldValue, fixedOldValue); + this->FixValue(t, newValue, fixedNewValue); if(!(fixedOldValue == fixedNewValue)) { // The user has changed the value. Mark it as modified. - it.SetProperty("MODIFIED", true); - it.SetValue(fixedNewValue.c_str()); + this->CMakeInstance->GetCacheManager() + ->SetCacheEntryBoolProperty(cacheKey, "MODIFIED", true); + this->CMakeInstance->GetCacheManager() + ->SetCacheEntryValue(cacheKey, fixedNewValue); } } } @@ -1017,12 +1043,15 @@ void cmCursesMainForm::HandleInput() cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(field_userptr( this->Fields[findex-2])); const char* curField = lbl->GetValue(); - const char* helpString=0; - cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField); - if (!it.IsAtEnd()) + const char* helpString = 0; + + const char* existingValue = + this->CMakeInstance->GetCacheManager() + ->GetCacheEntryValue(curField); + if (existingValue) { - helpString = it.GetProperty("HELPSTRING"); + helpString = this->CMakeInstance->GetCacheManager() + ->GetCacheEntryProperty(curField, "HELPSTRING"); } if (helpString) { diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index b59af94..9cc993a 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -45,11 +45,11 @@ if (Qt5Widgets_FOUND) get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME) get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH) get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME) - set(_qt_plugin_dest "${CMAKE_INSTALL_PREFIX}/PlugIns/${_qt_plugin_type}") + set(_qt_plugin_dest "PlugIns/${_qt_plugin_type}") install(FILES "${_qt_plugin_path}" DESTINATION "${_qt_plugin_dest}") set(${_qt_plugins_var} - "${${_qt_plugins_var}};${_qt_plugin_dest}/${_qt_plugin_file}") + "${${_qt_plugins_var}};\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_qt_plugin_dest}/${_qt_plugin_file}") else() message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found") endif() diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 996aa75..08d53ce 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -96,7 +96,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) emit this->binaryDirChanged(this->BinaryDirectory); cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); this->setGenerator(QString()); - if(!this->CMakeInstance->GetCacheManager()->LoadCache( + if(!this->CMakeInstance->LoadCache( this->BinaryDirectory.toLocal8Bit().data())) { QDir testDir(this->BinaryDirectory); @@ -110,16 +110,18 @@ void QCMake::setBinaryDirectory(const QString& _dir) QCMakePropertyList props = this->properties(); emit this->propertiesChanged(props); - cmCacheManager::CacheIterator itm = cachem->NewIterator(); - if ( itm.Find("CMAKE_HOME_DIRECTORY")) + const char* homeDir = cachem->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"); + if (homeDir) { - setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str())); + setSourceDirectory(QString::fromLocal8Bit(homeDir)); } - if ( itm.Find("CMAKE_GENERATOR")) + const char* gen = cachem->GetCacheEntryValue("CMAKE_GENERATOR"); + if (gen) { - const char* extraGen = cachem->GetCacheValue("CMAKE_EXTRA_GENERATOR"); + const char* extraGen = cachem + ->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); std::string curGen = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : ""); + CreateFullGeneratorName(gen, extraGen? extraGen : ""); this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); } } @@ -194,33 +196,35 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) // set the value of properties cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); - for(cmCacheManager::CacheIterator i = cachem->NewIterator(); - !i.IsAtEnd(); i.Next()) + std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys(); + for(std::vector<std::string>::const_iterator it = cacheKeys.begin(); + it != cacheKeys.end(); ++it) { - - if(i.GetType() == cmCacheManager::INTERNAL || - i.GetType() == cmCacheManager::STATIC) + cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*it); + if(t == cmCacheManager::INTERNAL || + t == cmCacheManager::STATIC) { continue; } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); + prop.Key = QString::fromLocal8Bit(it->c_str()); int idx = props.indexOf(prop); if(idx == -1) { - toremove.append(QString::fromLocal8Bit(i.GetName().c_str())); + toremove.append(QString::fromLocal8Bit(it->c_str())); } else { prop = props[idx]; if(prop.Value.type() == QVariant::Bool) { - i.SetValue(prop.Value.toBool() ? "ON" : "OFF"); + cachem->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF"); } else { - i.SetValue(prop.Value.toString().toLocal8Bit().data()); + cachem->SetCacheEntryValue(*it, + prop.Value.toString().toLocal8Bit().data()); } props.removeAt(idx); } @@ -270,7 +274,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) } } - cachem->SaveCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data()); } QCMakePropertyList QCMake::properties() const @@ -278,42 +282,47 @@ QCMakePropertyList QCMake::properties() const QCMakePropertyList ret; cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); - for(cmCacheManager::CacheIterator i = cachem->NewIterator(); - !i.IsAtEnd(); i.Next()) + std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys(); + for (std::vector<std::string>::const_iterator i = cacheKeys.begin(); + i != cacheKeys.end(); ++i) { - - if(i.GetType() == cmCacheManager::INTERNAL || - i.GetType() == cmCacheManager::STATIC || - i.GetType() == cmCacheManager::UNINITIALIZED) + cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*i); + if(t == cmCacheManager::INTERNAL || + t == cmCacheManager::STATIC || + t == cmCacheManager::UNINITIALIZED) { continue; } - QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); - prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING")); - prop.Value = QString::fromLocal8Bit(i.GetValue().c_str()); - prop.Advanced = i.GetPropertyAsBool("ADVANCED"); + const char* cachedValue = cachem->GetCacheEntryValue(*i); - if(i.GetType() == cmCacheManager::BOOL) + QCMakeProperty prop; + prop.Key = QString::fromLocal8Bit(i->c_str()); + prop.Help = QString::fromLocal8Bit( + cachem->GetCacheEntryProperty(*i, "HELPSTRING")); + prop.Value = QString::fromLocal8Bit(cachedValue); + prop.Advanced = cachem->GetCacheEntryPropertyAsBool(*i, "ADVANCED"); + if(t == cmCacheManager::BOOL) { prop.Type = QCMakeProperty::BOOL; - prop.Value = cmSystemTools::IsOn(i.GetValue().c_str()); + prop.Value = cmSystemTools::IsOn(cachedValue); } - else if(i.GetType() == cmCacheManager::PATH) + else if(t == cmCacheManager::PATH) { prop.Type = QCMakeProperty::PATH; } - else if(i.GetType() == cmCacheManager::FILEPATH) + else if(t == cmCacheManager::FILEPATH) { prop.Type = QCMakeProperty::FILEPATH; } - else if(i.GetType() == cmCacheManager::STRING) + else if(t == cmCacheManager::STRING) { prop.Type = QCMakeProperty::STRING; - if (i.PropertyExists("STRINGS")) + const char* stringsProperty = + cachem->GetCacheEntryProperty(*i, "STRINGS"); + if (stringsProperty) { - prop.Strings = QString::fromLocal8Bit(i.GetProperty("STRINGS")).split(";"); + prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";"); } } @@ -397,9 +406,9 @@ QStringList QCMake::availableGenerators() const void QCMake::deleteCache() { // delete cache - this->CMakeInstance->GetCacheManager()->DeleteCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data()); // reload to make our cache empty - this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); // emit no generator and no properties this->setGenerator(QString()); QCMakePropertyList props = this->properties(); @@ -412,7 +421,7 @@ void QCMake::reloadCache() QCMakePropertyList props; emit this->propertiesChanged(props); // reload - this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); // emit new cache properties props = this->properties(); emit this->propertiesChanged(props); diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index b560452..3a74946 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -33,15 +33,6 @@ bool cmAddDependenciesCommand } if(cmTarget* target = this->Makefile->FindTargetToUse(target_name)) { - if (target->GetType() == cmTarget::INTERFACE_LIBRARY) - { - std::ostringstream e; - e << "Cannot add target-level dependencies to INTERFACE library " - "target \"" << target_name << "\".\n"; - this->SetError(e.str()); - return false; - } - std::vector<std::string>::const_iterator s = args.begin(); ++s; // skip over target_name for (; s != args.end(); ++s) diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 01598bc..9d55c1a 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -122,7 +122,7 @@ bool cmAddSubDirectoryCommand::InitialPass // Add the subdirectory using the computed full paths. this->Makefile->AddSubDirectory(srcPath, binPath, - excludeFromAll, false, true); + excludeFromAll, true); return true; } diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index a30d992..b8238f8 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -26,7 +26,6 @@ bool cmAuxSourceDirectoryCommand::InitialPass std::string sourceListValue; std::string templateDirectory = args[0]; - this->Makefile->AddExtraDirectory(templateDirectory.c_str()); std::string tdir; if(!cmSystemTools::FileIsFullPath(templateDirectory.c_str())) { diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 691d80d..987a7b1 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -51,12 +51,14 @@ void CCONV cmSetError(void *info, const char *err) unsigned int CCONV cmGetCacheMajorVersion(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); - return mf->GetCacheMajorVersion(); + cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager(); + return manager->GetCacheMajorVersion(); } unsigned int CCONV cmGetCacheMinorVersion(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); - return mf->GetCacheMinorVersion(); + cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager(); + return manager->GetCacheMinorVersion(); } unsigned int CCONV cmGetMajorVersion(void *) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 1d0df69..1db057b 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -329,6 +329,8 @@ cmCTest::cmCTest() this->OutputTestOutputOnTestFailure = false; this->ComputedCompressTestOutput = false; this->ComputedCompressMemCheckOutput = false; + this->RepeatTests = 1; // default to run each test once + this->RepeatUntilFail = false; if(cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE")) { this->OutputTestOutputOnTestFailure = true; @@ -1341,16 +1343,21 @@ int cmCTest::RunTest(std::vector<const char*> argv, } *retVal = inst.Run(args, output); - *output += oss.str(); - if ( log ) + if(output) + { + *output += oss.str(); + } + if ( log && output) { *log << *output; } cmSystemTools::ChangeDirectory(oldpath); - - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, - "Internal cmCTest object used to run test." << std::endl - << *output << std::endl); + if(output) + { + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + "Internal cmCTest object used to run test." << std::endl + << *output << std::endl); + } return cmsysProcess_State_Exited; } @@ -1420,7 +1427,10 @@ int cmCTest::RunTest(std::vector<const char*> argv, *retVal = cmsysProcess_GetExitException(cp); std::string outerr = "\n*** Exception executing: "; outerr += cmsysProcess_GetExceptionString(cp); - *output += outerr; + if(output) + { + *output += outerr; + } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl << std::flush); } @@ -1428,7 +1438,10 @@ int cmCTest::RunTest(std::vector<const char*> argv, { std::string outerr = "\n*** ERROR executing: "; outerr += cmsysProcess_GetErrorString(cp); - *output += outerr; + if(output) + { + *output += outerr; + } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl << std::flush); } @@ -1984,11 +1997,11 @@ bool cmCTest::CheckArgument(const std::string& arg, const char* varg1, //---------------------------------------------------------------------- // Processes one command line argument (and its arguments if any) // for many simple options and then returns -void cmCTest::HandleCommandLineArguments(size_t &i, - std::vector<std::string> &args) +bool cmCTest::HandleCommandLineArguments(size_t &i, + std::vector<std::string> &args, + std::string& errormsg) { std::string arg = args[i]; - if(this->CheckArgument(arg, "-F")) { this->Failover = true; @@ -2006,6 +2019,27 @@ void cmCTest::HandleCommandLineArguments(size_t &i, this->SetParallelLevel(plevel); this->ParallelLevelSetInCli = true; } + if(this->CheckArgument(arg, "--repeat-until-fail")) + { + if( i >= args.size() - 1) + { + errormsg = "'--repeat-until-fail' requires an argument"; + return false; + } + i++; + long repeat = 1; + if(!cmSystemTools::StringToLong(args[i].c_str(), &repeat)) + { + errormsg = "'--repeat-until-fail' given non-integer value '" + + args[i] + "'"; + return false; + } + this->RepeatTests = static_cast<int>(repeat); + if(repeat > 1) + { + this->RepeatUntilFail = true; + } + } if(this->CheckArgument(arg, "--no-compress-output")) { @@ -2191,6 +2225,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i, this->GetHandler("test")->SetPersistentOption("RerunFailed", "true"); this->GetHandler("memcheck")->SetPersistentOption("RerunFailed", "true"); } + return true; } //---------------------------------------------------------------------- @@ -2246,7 +2281,7 @@ bool cmCTest::AddVariableDefinition(const std::string &arg) std::string value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if (cmCacheManager::ParseEntry(arg, name, value, type)) + if (cmake::ParseCacheEntry(arg, name, value, type)) { this->Definitions[name] = value; return true; @@ -2273,7 +2308,12 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) for(size_t i=1; i < args.size(); ++i) { // handle the simple commandline arguments - this->HandleCommandLineArguments(i,args); + std::string errormsg; + if(!this->HandleCommandLineArguments(i,args, errormsg)) + { + cmSystemTools::Error(errormsg.c_str()); + return 1; + } // handle the script arguments -S -SR -SP this->HandleScriptArguments(i,args,SRArgumentSpecified); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 88191c4..3f033d9 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -429,8 +429,13 @@ public: { return this->Definitions; } - + // return the number of times a test should be run + int GetTestRepeat() { return this->RepeatTests;} + // return true if test should run until fail + bool GetRepeatUntilFail() { return this->RepeatUntilFail;} private: + int RepeatTests; + bool RepeatUntilFail; std::string ConfigType; std::string ScheduleType; std::string StopTime; @@ -535,8 +540,9 @@ private: bool AddVariableDefinition(const std::string &arg); //! parse and process most common command line arguments - void HandleCommandLineArguments(size_t &i, - std::vector<std::string> &args); + bool HandleCommandLineArguments(size_t &i, + std::vector<std::string> &args, + std::string& errormsg); //! hande the -S -SP and -SR arguments void HandleScriptArguments(size_t &i, diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 0c77891..5387d0c 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -12,7 +12,6 @@ #include "cmCacheManager.h" #include "cmSystemTools.h" -#include "cmCacheManager.h" #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmake.h" @@ -76,22 +75,10 @@ bool cmCacheManager::IsType(const char* s) return false; } -bool cmCacheManager::LoadCache(cmMakefile* mf) -{ - return this->LoadCache(mf->GetHomeOutputDirectory()); -} - - bool cmCacheManager::LoadCache(const std::string& path) { - return this->LoadCache(path,true); -} - -bool cmCacheManager::LoadCache(const std::string& path, - bool internal) -{ std::set<std::string> emptySet; - return this->LoadCache(path, internal, emptySet, emptySet); + return this->LoadCache(path, true, emptySet, emptySet); } static bool ParseEntryWithoutType(const std::string& entry, @@ -296,14 +283,16 @@ bool cmCacheManager::LoadCache(const std::string& path, } this->CacheMajorVersion = 0; this->CacheMinorVersion = 0; - if(const char* cmajor = this->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION")) + if(const char* cmajor = + this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) { unsigned int v=0; if(sscanf(cmajor, "%u", &v) == 1) { this->CacheMajorVersion = v; } - if(const char* cminor = this->GetCacheValue("CMAKE_CACHE_MINOR_VERSION")) + if(const char* cminor = + this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) { if(sscanf(cminor, "%u", &v) == 1) { @@ -325,10 +314,11 @@ bool cmCacheManager::LoadCache(const std::string& path, } // check to make sure the cache directory has not // been moved - if ( internal && this->GetCacheValue("CMAKE_CACHEFILE_DIR") ) + const char* oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"); + if (internal && oldDir) { std::string currentcwd = path; - std::string oldcwd = this->GetCacheValue("CMAKE_CACHEFILE_DIR"); + std::string oldcwd = oldDir; cmSystemTools::ConvertToUnixSlashes(currentcwd); currentcwd += "/CMakeCache.txt"; oldcwd += "/CMakeCache.txt"; @@ -337,7 +327,7 @@ bool cmCacheManager::LoadCache(const std::string& path, std::string message = std::string("The current CMakeCache.txt directory ") + currentcwd + std::string(" is different than the directory ") + - std::string(this->GetCacheValue("CMAKE_CACHEFILE_DIR")) + + std::string(this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) + std::string(" where CMakeCache.txt was created. This may result " "in binaries being created in the wrong place. If you " "are not sure, reedit the CMakeCache.txt"); @@ -418,12 +408,6 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os, } } -bool cmCacheManager::SaveCache(cmMakefile* mf) -{ - return this->SaveCache(mf->GetHomeOutputDirectory()); -} - - bool cmCacheManager::SaveCache(const std::string& path) { std::string cacheFile = path; @@ -673,7 +657,8 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator( return CacheIterator(*this, key); } -const char* cmCacheManager::GetCacheValue(const std::string& key) const +const char* +cmCacheManager::GetInitializedCacheValue(const std::string& key) const { CacheEntryMap::const_iterator i = this->Cache.find(key); if(i != this->Cache.end() && @@ -914,21 +899,3 @@ bool cmCacheManager::CacheIterator::PropertyExists( { return this->GetProperty(prop)? true:false; } - -//---------------------------------------------------------------------------- -bool cmCacheManager::NeedCacheCompatibility(int major, int minor) -{ - // Compatibility is not needed if the cache version is zero because - // the cache was created or modified by the user. - if(this->CacheMajorVersion == 0) - { - return false; - } - - // Compatibility is needed if the cache version is equal to or lower - // than the given version. - cmIML_INT_uint64_t actual_compat = - CMake_VERSION_ENCODE(this->CacheMajorVersion, this->CacheMinorVersion, 0); - return (actual_compat && - actual_compat <= CMake_VERSION_ENCODE(major, minor, 0)); -} diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index d9a9112..3b02fa6 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -65,7 +65,7 @@ public: void AppendProperty(const std::string& property, const char* value, bool asString=false); void SetProperty(const std::string& property, bool value); - std::string GetValue() const { return this->GetEntry().Value; } + const char* GetValue() const { return this->GetEntry().Value.c_str(); } bool GetValueAsBool() const; void SetValue(const char*); CacheEntryType GetType() const { return this->GetEntry().Type; } @@ -105,17 +105,12 @@ public: static const char* TypeToString(CacheEntryType); static bool IsType(const char*); - ///! Load a cache for given makefile. Loads from ouput home. - bool LoadCache(cmMakefile*); ///! Load a cache for given makefile. Loads from path/CMakeCache.txt. bool LoadCache(const std::string& path); - bool LoadCache(const std::string& path, bool internal); bool LoadCache(const std::string& path, bool internal, std::set<std::string>& excludes, std::set<std::string>& includes); - ///! Save cache for given makefile. Saves to ouput home CMakeCache.txt. - bool SaveCache(cmMakefile*) ; ///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt bool SaveCache(const std::string& path) ; @@ -142,14 +137,88 @@ public: CacheEntryType& type); ///! Get a value from the cache given a key - const char* GetCacheValue(const std::string& key) const; + const char* GetInitializedCacheValue(const std::string& key) const; + + const char* GetCacheEntryValue(const std::string& key) + { + cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str()); + if (it.IsAtEnd()) + { + return 0; + } + return it.GetValue(); + } + + const char* GetCacheEntryProperty(std::string const& key, + std::string const& propName) + { + return this->GetCacheIterator(key.c_str()).GetProperty(propName); + } + + CacheEntryType GetCacheEntryType(std::string const& key) + { + return this->GetCacheIterator(key.c_str()).GetType(); + } + + bool GetCacheEntryPropertyAsBool(std::string const& key, + std::string const& propName) + { + return this->GetCacheIterator(key.c_str()).GetPropertyAsBool(propName); + } + + void SetCacheEntryProperty(std::string const& key, + std::string const& propName, + std::string const& value) + { + this->GetCacheIterator(key.c_str()).SetProperty(propName, value.c_str()); + } + + void SetCacheEntryBoolProperty(std::string const& key, + std::string const& propName, + bool value) + { + this->GetCacheIterator(key.c_str()).SetProperty(propName, value); + } + + void SetCacheEntryValue(std::string const& key, + std::string const& value) + { + this->GetCacheIterator(key.c_str()).SetValue(value.c_str()); + } + + void RemoveCacheEntryProperty(std::string const& key, + std::string const& propName) + { + this->GetCacheIterator(key.c_str()).SetProperty(propName, (void*)0); + } + + void AppendCacheEntryProperty(std::string const& key, + std::string const& propName, + std::string const& value, + bool asString = false) + { + this->GetCacheIterator(key.c_str()).AppendProperty(propName, + value.c_str(), + asString); + } + + std::vector<std::string> GetCacheEntryKeys() + { + std::vector<std::string> definitions; + definitions.reserve(this->GetSize()); + cmCacheManager::CacheIterator cit = this->GetCacheIterator(); + for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) + { + definitions.push_back(cit.GetName()); + } + return definitions; + } /** Get the version of CMake that wrote the cache. */ unsigned int GetCacheMajorVersion() const { return this->CacheMajorVersion; } unsigned int GetCacheMinorVersion() const { return this->CacheMinorVersion; } - bool NeedCacheCompatibility(int major, int minor); protected: ///! Add an entry into the cache diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 747b7e4..99bf5f5 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -90,7 +90,8 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, } if ( strcmp(key, "CACHE") == 0 ) { - if(const char* c = this->Makefile->GetCacheManager()->GetCacheValue(var)) + if(const char* c = this->Makefile->GetCacheManager() + ->GetInitializedCacheValue(var)) { if(this->EscapeQuotes) { diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index b0e0f36..8880667 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -411,6 +411,10 @@ cmComputeLinkInformation std::vector<std::string> const& dirs = this->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } + + this->CMP0060Warn = + this->Makefile->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0060"); } //---------------------------------------------------------------------------- @@ -548,6 +552,22 @@ bool cmComputeLinkInformation::Compute() // Add implicit language runtime libraries and directories. this->AddImplicitLinkInfo(); + if (!this->CMP0060WarnItems.empty()) + { + std::ostringstream w; + w << (this->Makefile->GetCMakeInstance()->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0060)) << "\n" + "Some library files are in directories implicitly searched by " + "the linker when invoked for " << this->LinkLanguage << ":\n" + " " << cmJoin(this->CMP0060WarnItems, "\n ") << "\n" + "For compatibility with older versions of CMake, the generated " + "link line will ask the linker to search for these by library " + "name." + ; + this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + this->Target->GetBacktrace()); + } + return true; } @@ -1190,6 +1210,28 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) return false; } + // Check the policy for whether we should use the approach below. + switch (this->Target->GetPolicyStatusCMP0060()) + { + case cmPolicies::WARN: + if (this->CMP0060Warn) + { + // Print the warning at most once for this item. + std::string const& wid = "CMP0060-WARNING-GIVEN-" + item; + if (!this->CMakeInstance->GetPropertyAsBool(wid)) + { + this->CMakeInstance->SetProperty(wid, "1"); + this->CMP0060WarnItems.insert(item); + } + } + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + return false; + } + // Many system linkers support multiple architectures by // automatically selecting the implicit linker search path for the // current architecture. If the library appears in an implicit link diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index e5d674a..8847141 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -175,6 +175,10 @@ private: std::vector<std::string> OldUserFlagItems; bool OldLinkDirMode; + // CMP0060 warnings. + bool CMP0060Warn; + std::set<std::string> CMP0060WarnItems; + // Runtime path computation. cmOrderDirectories* OrderRuntimeSearchPath; void AddLibraryRuntimeInfo(std::string const& fullPath, diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index cf2b88e..bbffd5d 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -418,9 +418,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, cmTarget const* dependee, bool linking) { - if(dependee->IsImported()) + if(dependee->IsImported() || + dependee->GetType() == cmTarget::INTERFACE_LIBRARY) { - // Skip imported targets but follow their utility dependencies. + // Skip IMPORTED and INTERFACE targets but follow their utility + // dependencies. std::set<cmLinkItem> const& utils = dependee->GetUtilityItems(); for(std::set<cmLinkItem>::const_iterator i = utils.begin(); i != utils.end(); ++i) diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 63d8fa6..6cdd4c1 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -242,13 +242,22 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, cmsys::ifstream fin(fullName.c_str()); if(fin) { - // Add this file as a dependency. - dependencies.insert(fullName); + cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin); + if(bom == cmsys::FStream::BOM_None || + bom == cmsys::FStream::BOM_UTF8) + { + // Add this file as a dependency. + dependencies.insert(fullName); - // Scan this file for new dependencies. Pass the directory - // containing the file to handle double-quote includes. - std::string dir = cmSystemTools::GetFilenamePath(fullName); - this->Scan(fin, dir.c_str(), fullName); + // Scan this file for new dependencies. Pass the directory + // containing the file to handle double-quote includes. + std::string dir = cmSystemTools::GetFilenamePath(fullName); + this->Scan(fin, dir.c_str(), fullName); + } + else + { + // Skip file with encoding we do not implement. + } } } } diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 4de59c0..6869e2f 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -204,7 +204,7 @@ void cmDocumentationFormatter if(!op->Name.empty()) { os << " " << op->Name; - this->TextIndent = " "; + this->TextIndent = " "; int align = static_cast<int>(strlen(this->TextIndent))-4; for(int i = static_cast<int>(op->Name.size()); i < align; ++i) { diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d64b0d7..0d32e4b 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -205,7 +205,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; cacheEntryName += envVar; - const char* cacheValue = mf->GetCacheManager()->GetCacheValue( + const char* cacheValue = mf->GetCacheManager()->GetInitializedCacheValue( cacheEntryName); // now we have both, decide which one to use @@ -223,7 +223,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); - mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); } else if (envVarValue==0 && cacheValue!=0) { @@ -244,7 +244,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); - mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); } } diff --git a/Source/cmExtraQbsGenerator.cxx b/Source/cmExtraQbsGenerator.cxx new file mode 100644 index 0000000..5a1f9ef --- /dev/null +++ b/Source/cmExtraQbsGenerator.cxx @@ -0,0 +1,260 @@ +#include "cmExtraQbsGenerator.h" + +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmGeneratedFileStream.h" +#include "cmSourceFile.h" + +cmExtraQbsGenerator::cmExtraQbsGenerator() +{ +#if defined(_WIN32) + this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); + this->SupportedGlobalGenerators.push_back("NMake Makefiles"); +#endif + this->SupportedGlobalGenerators.push_back("Ninja"); + this->SupportedGlobalGenerators.push_back("Unix Makefiles"); +} + +cmExtraQbsGenerator::~cmExtraQbsGenerator() {} + +void cmExtraQbsGenerator::GetDocumentation(cmDocumentationEntry &entry, + const std::string &) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Qbs project files."; +} + +void cmExtraQbsGenerator::Generate() +{ + for (std::map<std::string, std::vector<cmLocalGenerator *> >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it != this->GlobalGenerator->GetProjectMap().end(); ++it) + { + // create a project file + this->CreateProjectFile(it->first, it->second); + } +} + +void cmExtraQbsGenerator::CreateProjectFile( + const std::string &name, + const std::vector<cmLocalGenerator *> &lgs) +{ + const cmMakefile *mf = lgs[0]->GetMakefile(); + std::string outputDir = mf->GetStartOutputDirectory(); + + const std::string filename = outputDir + "/" + name + ".qbs"; + + this->CreateNewProjectFile(name, lgs, filename); +} + +void cmExtraQbsGenerator::CreateNewProjectFile( + const std::string &projectName, const std::vector<cmLocalGenerator *> &lgs, + const std::string &filename) +{ + cmGeneratedFileStream fout(filename.c_str()); + if (!fout) + { + return; + } + + fout << "import qbs\n" + << "import qbs.File\n\n" + << "Project {\n" + << "\tname:\"" << projectName << "\"\n"; + std::vector<cmLocalGenerator *>::const_iterator itr = lgs.begin(); + for (; itr != lgs.end(); ++itr) + { + cmLocalGenerator *lg = (*itr); + this->AppendSubProject(fout, lg); + } + fout << "}\n"; +} + +void cmExtraQbsGenerator::AppendSubProject(cmGeneratedFileStream &fout, + cmLocalGenerator *lg) +{ + const cmMakefile *mk = lg->GetMakefile(); + if (!mk || mk->GetTargets().size() == 0) + { + return; + } + + const std::string &relativePath = cmSystemTools::RelativePath( + mk->GetHomeDirectory(), mk->GetCurrentDirectory()); + fout << "\tProject {\n" + << "\t\tname:\"" << relativePath << "\"\n"; + this->AppendProduct(fout, lg); + fout << "\t}\n"; +} + +void cmExtraQbsGenerator::AppendProduct(cmGeneratedFileStream &fout, + cmLocalGenerator *lg) +{ + const cmMakefile *mk = lg->GetMakefile(); + const cmTargets &ts = mk->GetTargets(); + std::string cfg = mk->GetSafeDefinition("CMAKE_BUILD_TYPE"); + cmTargets::const_iterator itr = ts.begin(); + for (; itr != ts.end(); ++itr) + { + const cmTarget &t = itr->second; + this->AppendTarget(fout, lg, t, cfg); + } +} + +void cmExtraQbsGenerator::AppendTarget(cmGeneratedFileStream &fout, + cmLocalGenerator *lg, const cmTarget &t, + const std::string &cfg) +{ + std::string type; + bool isBuildable = true; + switch (t.GetType()) + { + case cmTarget::EXECUTABLE: + type = "application"; + break; + case cmTarget::SHARED_LIBRARY: + type = "dynamiclibrary"; + break; + case cmTarget::STATIC_LIBRARY: + type = "staticlibrary"; + break; + default: + isBuildable = false; + break; + } + + if (type.empty()) + { + fout << "\t\tProject {\n"; + } + else + { + fout << "\t\tProduct {\n"; + fout << "\t\t\tdestinationDirectory: \"" << t.GetDirectory(cfg) << "\"\n"; + } + fout << "\t\t\tname:\"" << t.GetName() << "\"\n"; + + if (!type.empty()) + { + fout << "\t\t\ttype: \"" << type << "\"\n"; + fout << "\t\t\ttargetName: \"" << t.GetName() << "\"\n"; + } + + if (isBuildable) + { + fout << "\t\t\tDepends { name: \"cpp\" }\n"; + cmGeneratorTarget *gt = this->GlobalGenerator->GetGeneratorTarget(&t); + this->AppendSources(fout, gt, t, cfg); + + std::set<std::string> langs, incPaths, defs; + t.GetLanguages(langs, cfg); + for (std::set<std::string>::const_iterator lang = langs.begin(); + lang != langs.end(); + ++ lang) + { + const std::vector<std::string> &paths = + gt->GetIncludeDirectories(cfg, *lang); + std::copy(paths.begin(), paths.end(), + std::inserter(incPaths, incPaths.end())); + + lg->AddCompileDefinitions(defs, &t, cfg, *lang); + } + this->AppendIncludePaths(fout, incPaths); + this->AppendCompileDefinitions(fout, defs); + } + + fout << "\t\t}\n"; +} + +void cmExtraQbsGenerator::AppendSources(cmGeneratedFileStream &fout, + cmGeneratorTarget *gt, + const cmTarget &t, + const std::string &cfg) +{ + std::vector<cmSourceFile *> sources; + gt->GetSourceFiles(sources, cfg); + if (sources.empty()) + { + return; + } + + std::vector<cmSourceFile *> genSources; + std::vector<cmSourceFile *>::const_iterator itr = sources.begin(); + fout << "\t\t\tfiles: [\n" + << "\t\t\t\t\"" << t.GetMakefile()->GetCurrentListFile() << "\",\n"; + for (; itr != sources.end(); ++itr) + { + if (!(*itr)->GetPropertyAsBool("GENERATED")) + { + fout << "\t\t\t\t\"" << (*itr)->GetFullPath() << "\",\n"; + } + else + { + genSources.push_back(*itr); + } + } + fout << "\t\t\t]\n"; + + if (!genSources.empty()) + { + fout << "\t\t\tGroup {\n" + << "\t\t\t\tname:\"Generated\"\n" + << "\t\t\t\tfiles: [\n"; + itr = genSources.begin(); + std::string groupCondition; + bool initialCondition = true; + for (; itr != genSources.end(); ++itr) + { + const std::string &path = (*itr)->GetFullPath(); + fout << "\t\t\t\t\t\"" << path << "\",\n"; + if (initialCondition) + { + initialCondition = false; + } + else + { + groupCondition += "\t\t\t\t\t && "; + } + groupCondition += "File.exists(\"" + path + "\")\n"; + } + fout << "\t\t\t\t]\n" + << "\t\t\t\tcondition: " << groupCondition << "\t\t\t}\n"; + } +} + +void cmExtraQbsGenerator::AppendIncludePaths( + cmGeneratedFileStream &fout, + const std::set<std::string> &paths) +{ + if (paths.empty()) + { + return; + } + + std::set<std::string>::const_iterator itr = paths.begin(); + fout << "\t\t\tcpp.includePaths: [\n"; + for (; itr != paths.end(); ++ itr) + { + fout << "\t\t\t\t\"" << (*itr) << "\",\n"; + } + fout << "\t\t\t]\n"; +} + +void cmExtraQbsGenerator::AppendCompileDefinitions( + cmGeneratedFileStream &fout, + const std::set<std::string> &defs) +{ + if (defs.empty()) + { + return; + } + + std::set<std::string>::const_iterator itr = defs.begin(); + fout << "\t\t\tcpp.defines: [\n"; + for (; itr != defs.end(); ++ itr) + { + fout << "\t\t\t\t'" << (*itr) << "',\n"; + } + fout << "\t\t\t]\n"; +} diff --git a/Source/cmExtraQbsGenerator.h b/Source/cmExtraQbsGenerator.h new file mode 100644 index 0000000..531ccc9 --- /dev/null +++ b/Source/cmExtraQbsGenerator.h @@ -0,0 +1,48 @@ +#ifndef CMEXTRAQBSGENERATOR_H +#define CMEXTRAQBSGENERATOR_H + +#include "cmExternalMakefileProjectGenerator.h" + +class cmGeneratorTarget; + +class cmExtraQbsGenerator : public cmExternalMakefileProjectGenerator +{ +public: + cmExtraQbsGenerator(); + ~cmExtraQbsGenerator(); + + virtual std::string GetName() const + { return cmExtraQbsGenerator::GetActualName(); } + static std::string GetActualName() { return "Qbs"; } + static cmExternalMakefileProjectGenerator *New() + { return new cmExtraQbsGenerator; } + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry &entry, + const std::string &fullName) const; + + virtual void Generate(); + +private: + void CreateProjectFile(const std::string &name, + const std::vector<cmLocalGenerator *> &lgs); + void CreateNewProjectFile(const std::string &projectName, + const std::vector<cmLocalGenerator *> &lgs, + const std::string &filename); + void AppendSubProject(cmGeneratedFileStream &fout, cmLocalGenerator *lg); + void AppendProduct(cmGeneratedFileStream &fout, cmLocalGenerator *lg); + void AppendTarget(cmGeneratedFileStream &fout, + cmLocalGenerator *lg, + const cmTarget &t, + const std::string &cfg); + void AppendSources(cmGeneratedFileStream &fout, + cmGeneratorTarget *gt, + const cmTarget &t, + const std::string &cfg); + void AppendIncludePaths(cmGeneratedFileStream &fout, + const std::set<std::string> &paths); + void AppendCompileDefinitions(cmGeneratedFileStream &fout, + const std::set<std::string> &defs); +}; + +#endif // CMEXTRAQBSGENERATOR_H diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index ec22ea0..93e3ac4 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -920,6 +920,35 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, bool first = true; for ( ; i != args.end(); ++i ) { + if( *i == "LIST_DIRECTORIES" ) + { + ++i; + if(i != args.end()) + { + if(cmSystemTools::IsOn(i->c_str())) + { + g.SetListDirs(true); + g.SetRecurseListDirs(true); + } + else if(cmSystemTools::IsOff(i->c_str())) + { + g.SetListDirs(false); + g.SetRecurseListDirs(false); + } + else + { + this->SetError("LIST_DIRECTORIES missing bool value."); + return false; + } + } + else + { + this->SetError("LIST_DIRECTORIES missing bool value."); + return false; + } + ++i; + } + if ( recurse && (*i == "FOLLOW_SYMLINKS") ) { explicitFollowSymlinks = true; @@ -950,6 +979,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, } } + cmsys::Glob::GlobMessages globMessages; if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) ) { std::string expr = this->Makefile->GetCurrentDirectory(); @@ -957,16 +987,42 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, if (!expr.empty()) { expr += "/" + *i; - g.FindFiles(expr); + g.FindFiles(expr, &globMessages); } else { - g.FindFiles(*i); + g.FindFiles(*i, &globMessages); } } else { - g.FindFiles(*i); + g.FindFiles(*i, &globMessages); + } + + if(!globMessages.empty()) + { + bool shouldExit = false; + for(cmsys::Glob::GlobMessagesIterator it=globMessages.begin(); + it != globMessages.end(); ++it) + { + if(it->type == cmsys::Glob::cyclicRecursion) + { + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + "Cyclic recursion detected while globbing for '" + + *i + "':\n" + it->content); + } + else + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "Error has occured while globbing for '" + + *i + "' - " + it->content); + shouldExit = true; + } + } + if(shouldExit) + { + return false; + } } std::vector<std::string>::size_type cc; @@ -3366,6 +3422,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) // enable HTTP ERROR parsing ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); + check_curl_result(res, "UPLOAD cannot set fail on error flag: "); // enable uploading res = ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx index fc18a64..36a2d72 100644 --- a/Source/cmFileLockUnix.cxx +++ b/Source/cmFileLockUnix.cxx @@ -15,6 +15,7 @@ #include <errno.h> // errno #include <stdio.h> // SEEK_SET #include <fcntl.h> +#include <unistd.h> #include "cmSystemTools.h" cmFileLock::cmFileLock(): File(-1) @@ -31,6 +32,9 @@ cmFileLockResult cmFileLock::Release() this->Filename = ""; + ::close(this->File); + this->File = -1; + if (lockResult == 0) { return cmFileLockResult::MakeOk(); diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx index 4691689..dc65948 100644 --- a/Source/cmFileLockWin32.cxx +++ b/Source/cmFileLockWin32.cxx @@ -38,6 +38,9 @@ cmFileLockResult cmFileLock::Release() this->Filename = ""; + CloseHandle(this->File); + this->File = INVALID_HANDLE_VALUE; + if (unlockResult) { return cmFileLockResult::MakeOk(); diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index f63df61..cc08052 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -366,18 +366,18 @@ bool cmFindBase::CheckForVariableInCache() if(const char* cacheValue = this->Makefile->GetDefinition(this->VariableName)) { - cmCacheManager::CacheIterator it = - this->Makefile->GetCacheManager()-> - GetCacheIterator(this->VariableName.c_str()); + cmCacheManager* manager = this->Makefile->GetCacheManager(); + const char* cacheEntry = manager->GetCacheEntryValue(this->VariableName); bool found = !cmSystemTools::IsNOTFOUND(cacheValue); - bool cached = !it.IsAtEnd(); + bool cached = cacheEntry ? true : false; if(found) { // If the user specifies the entry on the command line without a // type we should add the type and docstring but keep the // original value. Tell the subclass implementations to do // this. - if(cached && it.GetType() == cmCacheManager::UNINITIALIZED) + if(cached && manager->GetCacheEntryType(this->VariableName) + == cmCacheManager::UNINITIALIZED) { this->AlreadyInCacheWithoutMetaInfo = true; } @@ -385,7 +385,8 @@ bool cmFindBase::CheckForVariableInCache() } else if(cached) { - const char* hs = it.GetProperty("HELPSTRING"); + const char* hs = manager->GetCacheEntryProperty(this->VariableName, + "HELPSTRING"); this->VariableDocumentation = hs?hs:"(none)"; } } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 87f9037..4d7fd60 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -679,7 +679,6 @@ bool cmFindPackageCommand::HandlePackageMode() if(cmSystemTools::IsOff(def) || !fileFound) { fileFound = this->FindConfig(); - def = this->Makefile->GetDefinition(this->Variable); } // Sanity check. @@ -1598,7 +1597,6 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) if ((haveResult == false) && (this->Version.empty())) { result = true; - haveResult = true; } ConfigFileInfo configFileInfo; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 673dcb9..2654851 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1554,7 +1554,6 @@ class ArtifactPdbTag; class ArtifactPathTag; class ArtifactDirTag; -class ArtifactNameTag; //---------------------------------------------------------------------------- template<typename ArtifactT> diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e0af47a..41d12d7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -56,6 +56,7 @@ struct ResxTag {}; struct ModuleDefinitionFileTag {}; struct AppManifestTag{}; struct CertificatesTag{}; +struct XamlTag{}; template<typename Tag, typename OtherTag> struct IsSameTag @@ -98,6 +99,20 @@ struct DoAccept<true> data.ExpectedResxHeaders.insert(hFileName); data.ResxSources.push_back(f); } + static void Do(cmGeneratorTarget::XamlData& data, cmSourceFile* f) + { + // Build and save the name of the corresponding .h and .cpp file + // This relationship will be used later when building the project files. + // Both names would have been auto generated from Visual Studio + // where the user supplied the file name and Visual Studio + // appended the suffix. + std::string xaml = f->GetFullPath(); + std::string hFileName = xaml + ".h"; + std::string cppFileName = xaml + ".cpp"; + data.ExpectedXamlHeaders.insert(hFileName); + data.ExpectedXamlSources.insert(cppFileName); + data.XamlSources.push_back(f); + } static void Do(std::string& data, cmSourceFile* f) { data = f->GetFullPath(); @@ -186,6 +201,10 @@ struct TagVisitor { DoAccept<IsSameTag<Tag, CertificatesTag>::Result>::Do(this->Data, sf); } + else if (ext == "xaml") + { + DoAccept<IsSameTag<Tag, XamlTag>::Result>::Do(this->Data, sf); + } else if(this->Header.find(sf->GetFullPath().c_str())) { DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf); @@ -438,6 +457,36 @@ cmGeneratorTarget } //---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetExpectedXamlHeaders(std::set<std::string>& headers, + const std::string& config) const +{ + XamlData data; + IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) + headers = data.ExpectedXamlHeaders; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs, + const std::string& config) const +{ + XamlData data; + IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) + srcs = data.ExpectedXamlSources; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget +::GetXamlSources(std::vector<cmSourceFile const*>& srcs, + const std::string& config) const +{ + XamlData data; + IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) + srcs = data.XamlSources; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c329cf5..c79aa72 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -58,6 +58,12 @@ public: const std::string& config) const; void GetCertificates(std::vector<cmSourceFile const*>&, const std::string& config) const; + void GetXamlSources(std::vector<cmSourceFile const*>&, + const std::string& config) const; + void GetExpectedXamlHeaders(std::set<std::string>&, + const std::string& config) const; + void GetExpectedXamlSources(std::set<std::string>&, + const std::string& config) const; void ComputeObjectMapping(); @@ -132,6 +138,13 @@ public: mutable std::set<std::string> ExpectedResxHeaders; mutable std::vector<cmSourceFile const*> ResxSources; }; + + struct XamlData { + std::set<std::string> ExpectedXamlHeaders; + std::set<std::string> ExpectedXamlSources; + std::vector<cmSourceFile const*> XamlSources; + }; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector<cmSourceFile*> Depends; }; diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index f0b2686..0e6e0c2 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -391,11 +391,10 @@ bool cmGetPropertyCommand::HandleCacheMode() } const char* value = 0; - cmCacheManager::CacheIterator it = - this->Makefile->GetCacheManager()->GetCacheIterator(this->Name.c_str()); - if(!it.IsAtEnd()) + if(this->Makefile->GetCacheManager()->GetCacheEntryValue(this->Name)) { - value = it.GetProperty(this->PropertyName); + value = this->Makefile->GetCacheManager() + ->GetCacheEntryProperty(this->Name, this->PropertyName); } this->StoreResult(value); return true; diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 120d2f8..005f0d6 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -46,6 +46,7 @@ public: cmMakefile *, bool optional); virtual bool AllowNotParallel() const { return false; } + virtual bool AllowDeleteOnError() const { return false; } }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8123c99..35394b8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -179,7 +179,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, return; } const char* cname = this->GetCMakeInstance()-> - GetCacheManager()->GetCacheValue(langComp); + GetCacheManager()->GetInitializedCacheValue(langComp); std::string changeVars; if(cname && !optional) { @@ -1537,10 +1537,9 @@ void cmGlobalGenerator::CheckLocalGenerators() std::map<std::string, std::string> notFoundMap; // std::set<std::string> notFoundMap; // after it is all done do a ConfigureFinalPass - cmCacheManager* manager = 0; + cmCacheManager* manager = this->GetCMakeInstance()->GetCacheManager(); for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager(); this->LocalGenerators[i]->ConfigureFinalPass(); cmTargets &targets = this->LocalGenerators[i]->GetMakefile()->GetTargets(); @@ -1560,9 +1559,7 @@ void cmGlobalGenerator::CheckLocalGenerators() cmSystemTools::IsNOTFOUND(lib->first.c_str())) { std::string varName = lib->first.substr(0, lib->first.size()-9); - cmCacheManager::CacheIterator it = - manager->GetCacheIterator(varName.c_str()); - if(it.GetPropertyAsBool("ADVANCED")) + if(manager->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) { varName += " (ADVANCED)"; } @@ -1593,9 +1590,7 @@ void cmGlobalGenerator::CheckLocalGenerators() cmSystemTools::IsNOTFOUND(incDir->c_str())) { std::string varName = incDir->substr(0, incDir->size()-9); - cmCacheManager::CacheIterator it = - manager->GetCacheIterator(varName.c_str()); - if(it.GetPropertyAsBool("ADVANCED")) + if(manager->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) { varName += " (ADVANCED)"; } @@ -1642,7 +1637,7 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir, // and there is a good chance that the try compile stuff will // take the bulk of the time, so try and guess some progress // by getting closer and closer to 100 without actually getting there. - if (!this->CMakeInstance->GetCacheManager()->GetCacheValue + if (!this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue ("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) { // If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set @@ -1840,7 +1835,7 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) // update progress // estimate how many lg there will be const char *numGenC = - this->CMakeInstance->GetCacheManager()->GetCacheValue + this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue ("CMAKE_NUMBER_OF_LOCAL_GENERATORS"); if (!numGenC) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 69b1a9d..f74f1e0 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -17,6 +17,7 @@ #include "cmLocalNinjaGenerator.h" #include "cmMakefile.h" #include "cmVersion.h" +#include "cmAlgorithms.h" #include <algorithm> #include <assert.h> @@ -183,7 +184,10 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, i != outputs.end(); ++i) { build += " " + EncodeIdent(EncodePath(*i), os); - this->CombinedBuildOutputs.insert( EncodePath(*i) ); + if (this->ComputingUnknownDependencies) + { + this->CombinedBuildOutputs.insert( EncodePath(*i) ); + } } build += ":"; @@ -281,11 +285,14 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, orderOnly, vars); - //we need to track every dependency that comes in, since we are trying - //to find dependencies that are side effects of build commands - for(cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i) + if (this->ComputingUnknownDependencies) { - this->CombinedCustomCommandExplicitDependencies.insert( EncodePath(*i) ); + //we need to track every dependency that comes in, since we are trying + //to find dependencies that are side effects of build commands + for(cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i) + { + this->CombinedCustomCommandExplicitDependencies.insert(EncodePath(*i)); + } } } @@ -477,6 +484,8 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() , CompileCommandsStream(0) , Rules() , AllDependencies() + , ComputingUnknownDependencies(false) + , PolicyCMP0058(cmPolicies::WARN) { // // Ninja is not ported to non-Unix OS yet. // this->ForceUnixPaths = true; @@ -510,6 +519,13 @@ void cmGlobalNinjaGenerator::Generate() this->OpenBuildFileStream(); this->OpenRulesFileStream(); + this->PolicyCMP0058 = + this->LocalGenerators[0]->GetMakefile() + ->GetPolicyStatus(cmPolicies::CMP0058); + this->ComputingUnknownDependencies = + (this->PolicyCMP0058 == cmPolicies::OLD || + this->PolicyCMP0058 == cmPolicies::WARN); + this->cmGlobalGenerator::Generate(); this->WriteAssumedSourceDependencies(); @@ -955,6 +971,18 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) { + if (!this->ComputingUnknownDependencies) + { + return; + } + + // We need to collect the set of known build outputs. + // Start with those generated by WriteBuild calls. + // No other method needs this so we can take ownership + // of the set locally and throw it out when we are done. + std::set<std::string> knownDependencies; + knownDependencies.swap(this->CombinedBuildOutputs); + //now write out the unknown explicit dependencies. //union the configured files, evaluations files and the CombinedBuildOutputs, @@ -971,7 +999,6 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); - std::set<std::string> knownDependencies; for (std::vector<cmLocalGenerator *>::const_iterator i = this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) { @@ -1026,36 +1053,29 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) knownDependencies.insert( ng->ConvertToNinjaPath(i->first) ); } - //insert outputs from all WirteBuild commands - //these paths have already be encoded when added to CombinedBuildOutputs - knownDependencies.insert(this->CombinedBuildOutputs.begin(), - this->CombinedBuildOutputs.end()); - - //after we have combined the data into knownDependencies we have no need - //to keep this data around - this->CombinedBuildOutputs.clear(); - //now we difference with CombinedCustomCommandExplicitDependencies to find //the list of items we know nothing about. //We have encoded all the paths in CombinedCustomCommandExplicitDependencies //and knownDependencies so no matter if unix or windows paths they //should all match now. - std::vector<std::string> unkownExplicitDepends; + std::vector<std::string> unknownExplicitDepends; this->CombinedCustomCommandExplicitDependencies.erase("all"); std::set_difference(this->CombinedCustomCommandExplicitDependencies.begin(), this->CombinedCustomCommandExplicitDependencies.end(), knownDependencies.begin(), knownDependencies.end(), - std::back_inserter(unkownExplicitDepends)); - + std::back_inserter(unknownExplicitDepends)); std::string const rootBuildDirectory = this->GetCMakeInstance()->GetHomeOutputDirectory(); + bool const inSourceBuild = + (rootBuildDirectory == this->GetCMakeInstance()->GetHomeDirectory()); + std::vector<std::string> warnExplicitDepends; for (std::vector<std::string>::const_iterator - i = unkownExplicitDepends.begin(); - i != unkownExplicitDepends.end(); + i = unknownExplicitDepends.begin(); + i != unknownExplicitDepends.end(); ++i) { //verify the file is in the build directory @@ -1069,9 +1089,35 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) this->WritePhonyBuild(os, "", deps, - deps); + cmNinjaDeps()); + if (this->PolicyCMP0058 == cmPolicies::WARN && + !inSourceBuild && warnExplicitDepends.size() < 10) + { + warnExplicitDepends.push_back(*i); + } } } + + if (!warnExplicitDepends.empty()) + { + std::ostringstream w; + w << + (this->GetCMakeInstance()->GetPolicies()-> + GetPolicyWarning(cmPolicies::CMP0058)) << "\n" + "This project specifies custom command DEPENDS on files " + "in the build tree that are not specified as the OUTPUT or " + "BYPRODUCTS of any add_custom_command or add_custom_target:\n" + " " << cmJoin(warnExplicitDepends, "\n ") << + "\n" + "For compatibility with versions of CMake that did not have " + "the BYPRODUCTS option, CMake is generating phony rules for " + "such files to convince 'ninja' to build." + "\n" + "Project authors should add the missing BYPRODUCTS or OUTPUT " + "options to the custom commands that produce these files." + ; + this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } } void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index c7bb782..6aa76f9 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -368,6 +368,11 @@ private: /// The set of custom command outputs we have seen. std::set<std::string> CustomCommandOutputs; + /// Whether we are collecting known build outputs and needed + /// dependencies to determine unknown dependencies. + bool ComputingUnknownDependencies; + cmPolicies::PolicyStatus PolicyCMP0058; + /// The combined explicit dependencies of custom build commands std::set<std::string> CombinedCustomCommandExplicitDependencies; @@ -381,8 +386,6 @@ private: typedef std::map<std::string, cmTarget*> TargetAliasMap; TargetAliasMap TargetAliases; - static cmLocalGenerator* LocalGenerator; - static bool UsingMinGW; }; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 50a901e..a76a835 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -128,6 +128,9 @@ public: /** Does the make tool tolerate .NOTPARALLEL? */ virtual bool AllowNotParallel() const { return true; } + /** Does the make tool tolerate .DELETE_ON_ERROR? */ + virtual bool AllowDeleteOnError() const { return true; } + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: void WriteMainMakefile2(); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 18d40e1..1c6ac88 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -71,8 +71,11 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = vs10generatorName; - entry.Brief = "Generates Visual Studio 10 (VS 2010) project files."; + entry.Name = std::string(vs10generatorName) + " [arch]"; + entry.Brief = + "Generates Visual Studio 2010 project files. " + "Optional [arch] can be \"Win64\" or \"IA64\"." + ; } virtual void GetGenerators(std::vector<std::string>& names) const diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index ed828b6..5d3ae16 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -78,8 +78,11 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = vs11generatorName; - entry.Brief = "Generates Visual Studio 11 (VS 2012) project files."; + entry.Name = std::string(vs11generatorName) + " [arch]"; + entry.Brief = + "Generates Visual Studio 2012 project files. " + "Optional [arch] can be \"Win64\" or \"ARM\"." + ; } virtual void GetGenerators(std::vector<std::string>& names) const diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index c2e6f47..e70e082 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -66,8 +66,11 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = vs12generatorName; - entry.Brief = "Generates Visual Studio 12 (VS 2013) project files."; + entry.Name = std::string(vs12generatorName) + " [arch]"; + entry.Brief = + "Generates Visual Studio 2013 project files. " + "Optional [arch] can be \"Win64\" or \"ARM\"." + ; } virtual void GetGenerators(std::vector<std::string>& names) const diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index b551c65..7b1dd24 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -66,8 +66,11 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = vs14generatorName; - entry.Brief = "Generates Visual Studio 14 (VS 2015) project files."; + entry.Name = std::string(vs14generatorName) + " [arch]"; + entry.Brief = + "Generates Visual Studio 2015 project files. " + "Optional [arch] can be \"Win64\" or \"ARM\"." + ; } virtual void GetGenerators(std::vector<std::string>& names) const diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e6ce45d..726db0f 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -66,8 +66,11 @@ public: } virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = vs8generatorName; - entry.Brief = "Generates Visual Studio 8 2005 project files."; + entry.Name = std::string(vs8generatorName) + " [arch]"; + entry.Brief = + "Generates Visual Studio 2005 project files. " + "Optional [arch] can be \"Win64\"." + ; } virtual void GetGenerators(std::vector<std::string>& names) const { diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 1d73b5c..1bc627f 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -70,8 +70,11 @@ public: } virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = vs9generatorName; - entry.Brief = "Generates Visual Studio 9 2008 project files."; + entry.Name = std::string(vs9generatorName) + " [arch]"; + entry.Brief = + "Generates Visual Studio 2008 project files. " + "Optional [arch] can be \"Win64\" or \"IA64\"." + ; } virtual void GetGenerators(std::vector<std::string>& names) const { diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 0e577b5..7bc209b 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -45,6 +45,7 @@ public: cmMakefile *, bool optional); virtual bool AllowNotParallel() const { return false; } + virtual bool AllowDeleteOnError() const { return false; } }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bd8a1f5..0561a05 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -21,6 +21,7 @@ #include "cmCustomCommandGenerator.h" #include "cmGeneratorTarget.h" #include "cmGlobalGeneratorFactory.h" +#include "cmAlgorithms.h" #include <cmsys/auto_ptr.hxx> @@ -804,6 +805,10 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, { sourcecode = "compiled.mach-o.objfile"; } + else if(ext == "xctest") + { + sourcecode = "wrapper.cfbundle"; + } else if(ext == "xib") { keepLastKnownFileType = true; @@ -860,6 +865,10 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, { sourcecode += ".asm"; } + else if (ext == "metal") + { + sourcecode += ".metal"; + } //else // { // // Already specialized above or we leave sourcecode == "sourcecode" @@ -2598,7 +2607,9 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) case cmTarget::STATIC_LIBRARY: return "archive.ar"; case cmTarget::MODULE_LIBRARY: - if (cmtarget.IsCFBundleOnApple()) + if (cmtarget.IsXCTestOnApple()) + return "wrapper.cfbundle"; + else if (cmtarget.IsCFBundleOnApple()) return "wrapper.plug-in"; else return ((this->XcodeVersion >= 22)? @@ -2622,7 +2633,9 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget) case cmTarget::STATIC_LIBRARY: return "com.apple.product-type.library.static"; case cmTarget::MODULE_LIBRARY: - if (cmtarget.IsCFBundleOnApple()) + if (cmtarget.IsXCTestOnApple()) + return "com.apple.product-type.bundle.unit-test"; + else if (cmtarget.IsCFBundleOnApple()) return "com.apple.product-type.bundle"; else return ((this->XcodeVersion >= 22)? @@ -3372,53 +3385,33 @@ bool cmGlobalXCodeGenerator this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); const char* osxArch = this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); - if(!osxArch || strlen(osxArch) == 0) - { - if(this->XcodeVersion >= 32) - { - osxArch = "$(ARCHS_STANDARD_32_64_BIT)"; - } - else if(this->XcodeVersion == 31) - { - osxArch = "$(ARCHS_STANDARD_32_BIT)"; - } - else if(this->XcodeVersion <= 30) - { -#ifdef __ppc__ - osxArch = "ppc"; -#endif -#ifdef __i386 - osxArch = "i386"; -#endif - } - buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", - this->CreateString("YES")); - } - const char* sysroot = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT"); const char* deploymentTarget = this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); - if(osxArch && sysroot) + std::string archs; + if(sysroot) { - // recompute this as it may have been changed since enable language - this->Architectures.clear(); - cmSystemTools::ExpandListArgument(std::string(osxArch), - this->Architectures); - buildSettings->AddAttribute("SDKROOT", - this->CreateString(sysroot)); - std::string archString; - const char* sep = ""; - for( std::vector<std::string>::iterator i = - this->Architectures.begin(); - i != this->Architectures.end(); ++i) + if(osxArch) { - archString += sep; - archString += *i; - sep = " "; + // recompute this as it may have been changed since enable language + this->Architectures.clear(); + cmSystemTools::ExpandListArgument(std::string(osxArch), + this->Architectures); + archs = cmJoin(this->Architectures, " "); } - buildSettings->AddAttribute("ARCHS", - this->CreateString(archString.c_str())); + buildSettings->AddAttribute("SDKROOT", + this->CreateString(sysroot)); + } + if (archs.empty()) + { + // Tell Xcode to use NATIVE_ARCH instead of ARCHS. + buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES")); + } + else + { + // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO). + buildSettings->AddAttribute("ARCHS", this->CreateString(archs.c_str())); } if(deploymentTarget && *deploymentTarget) { @@ -3710,7 +3703,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, // Since this call may have created new cache entries, save the cache: // - root->GetMakefile()->GetCacheManager()->SaveCache( + root->GetMakefile()->GetCMakeInstance()->SaveCache( root->GetMakefile()->GetHomeOutputDirectory()); } diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 3e26349..ddcea9b 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -146,18 +146,12 @@ bool cmListFile::ParseFile(const char* filename, } bool parseError = false; - this->ModifiedTime = cmSystemTools::ModifiedTime(filename); { cmListFileParser parser(this, mf, filename); parseError = !parser.ParseFile(); } - if(parseError) - { - this->ModifiedTime = 0; - } - // do we need a cmake_policy(VERSION call? if(topLevel) { diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 2ca9b8e..544ff1b 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -85,15 +85,10 @@ class cmListFileBacktrace: public std::vector<cmListFileContext> struct cmListFile { - cmListFile() - :ModifiedTime(0) - { - } bool ParseFile(const char* path, bool topLevel, cmMakefile *mf); - long int ModifiedTime; std::vector<cmListFileFunction> Functions; }; diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 93aec32..e2ae901 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -81,8 +81,8 @@ bool cmLoadCacheCommand { break; } - this->Makefile->GetCacheManager()->LoadCache(args[i], false, - excludes, includes); + this->Makefile->GetCMakeInstance()->LoadCache(args[i], false, + excludes, includes); } @@ -173,7 +173,7 @@ void cmLoadCacheCommand::CheckLine(const char* line) std::string var; std::string value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if(cmCacheManager::ParseEntry(line, var, value, type)) + if(cmake::ParseCacheEntry(line, var, value, type)) { // Found a real entry. See if this one was requested. if(this->VariablesToRead.find(var) != this->VariablesToRead.end()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 2b999eb..6844fee 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -14,7 +14,6 @@ #include "cmMakefile.h" #include "cmSystemTools.h" #include "cmSourceFile.h" -#include "cmCacheManager.h" #include "cmGeneratorTarget.h" #include "cmCustomCommandGenerator.h" #include "cmake.h" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index eeb9c72..34b4621 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -101,7 +101,6 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->AddDefaultDefinitions(); this->Initialize(); - this->PreOrder = false; this->GeneratingBuildSystem = false; this->SuppressWatches = false; @@ -113,8 +112,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->Internal->VarInitStack.push(mf.Internal->VarInitStack.top()); this->Internal->VarUsageStack.push(mf.Internal->VarUsageStack.top()); - this->Prefix = mf.Prefix; - this->AuxSourceDirectories = mf.AuxSourceDirectories; this->cmStartDirectory = mf.cmStartDirectory; this->StartOutputDirectory = mf.StartOutputDirectory; this->cmHomeDirectory = mf.cmHomeDirectory; @@ -145,9 +142,7 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->LocalGenerator = mf.LocalGenerator; this->FunctionBlockers = mf.FunctionBlockers; this->MacrosList = mf.MacrosList; - this->SubDirectoryOrder = mf.SubDirectoryOrder; this->Properties = mf.Properties; - this->PreOrder = mf.PreOrder; this->WarnUnused = mf.WarnUnused; this->Initialize(); this->CheckSystemVars = mf.CheckSystemVars; @@ -179,21 +174,6 @@ void cmMakefile::Initialize() this->CheckCMP0000 = false; } -unsigned int cmMakefile::GetCacheMajorVersion() const -{ - return this->GetCacheManager()->GetCacheMajorVersion(); -} - -unsigned int cmMakefile::GetCacheMinorVersion() const -{ - return this->GetCacheManager()->GetCacheMinorVersion(); -} - -bool cmMakefile::NeedCacheCompatibility(int major, int minor) const -{ - return this->GetCacheManager()->NeedCacheCompatibility(major, minor); -} - cmMakefile::~cmMakefile() { cmDeleteAll(this->InstallGenerators); @@ -1697,7 +1677,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) } void cmMakefile::AddSubDirectory(const std::string& sub, - bool excludeFromAll, bool preorder) + bool excludeFromAll) { // the source path must be made full if it isn't already std::string srcPath = sub; @@ -1719,13 +1699,13 @@ void cmMakefile::AddSubDirectory(const std::string& sub, this->AddSubDirectory(srcPath, binPath, - excludeFromAll, preorder, false); + excludeFromAll, false); } void cmMakefile::AddSubDirectory(const std::string& srcPath, const std::string& binPath, - bool excludeFromAll, bool preorder, + bool excludeFromAll, bool immediate) { // Make sure the binary directory is unique. @@ -1747,7 +1727,6 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, { lg2->GetMakefile()->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } - lg2->GetMakefile()->SetPreOrder(preorder); if (immediate) { @@ -1831,16 +1810,17 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, { bool haveVal = value ? true : false; std::string val = haveVal ? value : ""; - cmCacheManager::CacheIterator it = - this->GetCacheManager()->GetCacheIterator(name.c_str()); - if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) && - it.Initialized()) + const char* existingValue = + this->GetCacheManager()->GetInitializedCacheValue(name); + if(existingValue + && (this->GetCacheManager()->GetCacheEntryType(name) + == cmCacheManager::UNINITIALIZED)) { // if this is not a force, then use the value from the cache // if it is a force, then use the value being passed in if(!force) { - val = it.GetValue(); + val = existingValue; haveVal = true; } if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH ) @@ -1863,13 +1843,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, } this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type); - val = it.GetValue(); + val = this->GetCacheManager()->GetInitializedCacheValue(name); haveVal = true; } } - this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, - type); + this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, + doc, type); // if there was a definition then remove it this->Internal->VarStack.top().Set(name, 0); } @@ -2208,7 +2188,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, if(i==lastElement) { // group already exists, replace its regular expression - if ( regex ) + if ( regex && sg) { // We only want to set the regular expression. If there are already // source files in the group, we don't want to remove them. @@ -2224,7 +2204,11 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, sg = this->GetSourceGroup(currentName); i = 0; // last component found } - + if(!sg) + { + cmSystemTools::Error("Could not create source group "); + return; + } // build the whole source group path const char* fullname = sg->GetFullName(); cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); @@ -2252,11 +2236,6 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, #endif -void cmMakefile::AddExtraDirectory(const char* dir) -{ - this->AuxSourceDirectories.push_back(dir); -} - static bool mightExpandVariablesCMP0019(const char* s) { return s && *s && strstr(s,"${") && strchr(s,'}'); @@ -2454,7 +2433,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const this->Internal->VarUsageStack.top().insert(name); if(!def) { - def = this->GetCacheManager()->GetCacheValue(name); + def = this->GetCacheManager()->GetInitializedCacheValue(name); } #ifdef CMAKE_BUILD_WITH_CMAKE if(cmVariableWatch* vv = this->GetVariableWatch()) @@ -2479,7 +2458,7 @@ const char* cmMakefile::GetDefinition(const std::string& name) const const char* def = this->Internal->VarStack.top().Get(name); if(!def) { - def = this->GetCacheManager()->GetCacheValue(name); + def = this->GetCacheManager()->GetInitializedCacheValue(name); } #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -2513,20 +2492,18 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const std::vector<std::string> cmMakefile ::GetDefinitions(int cacheonly /* = 0 */) const { - std::set<std::string> definitions; + std::vector<std::string> res; if ( !cacheonly ) { - definitions = this->Internal->VarStack.top().ClosureKeys(); - } - cmCacheManager::CacheIterator cit = - this->GetCacheManager()->GetCacheIterator(); - for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) - { - definitions.insert(cit.GetName()); + std::set<std::string> definitions = + this->Internal->VarStack.top().ClosureKeys(); + res.insert(res.end(), definitions.begin(), definitions.end()); } + std::vector<std::string> cacheKeys = + this->GetCacheManager()->GetCacheEntryKeys(); + res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); - std::vector<std::string> res; - res.insert(res.end(), definitions.begin(), definitions.end()); + std::sort(res.begin(), res.end()); return res; } @@ -2857,7 +2834,8 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( value = cmSystemTools::GetEnv(lookup.c_str()); break; case CACHE: - value = this->GetCacheManager()->GetCacheValue(lookup); + value = this->GetCacheManager() + ->GetInitializedCacheValue(lookup); break; } // Get the string we're meant to append to. @@ -4216,8 +4194,19 @@ const char *cmMakefile::GetProperty(const std::string& prop, } else if (prop == "DEFINITIONS") { - output += this->DefineFlagsOrig; - return output.c_str(); + switch(this->GetPolicyStatus(cmPolicies::CMP0059)) + { + case cmPolicies::WARN: + this->IssueMessage(cmake::AUTHOR_WARNING, this->GetPolicies()-> + GetPolicyWarning(cmPolicies::CMP0059)); + case cmPolicies::OLD: + output += this->DefineFlagsOrig; + return output.c_str(); + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } } else if (prop == "LINK_DIRECTORIES") { @@ -4914,7 +4903,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, (status == cmPolicies::WARN || status == cmPolicies::OLD)) { if(!(this->GetCacheManager() - ->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) + ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) { // Set it to 2.4 because that is the last version where the // variable had meaning. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e98f1d9..5209891 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -62,14 +62,6 @@ class cmMakefile class Internals; cmsys::auto_ptr<Internals> Internal; public: - /** - * Return the major and minor version of the cmake that - * was used to write the currently loaded cache, note - * this method will not work before the cache is loaded. - */ - unsigned int GetCacheMajorVersion() const; - unsigned int GetCacheMinorVersion() const; - /* Check for unused variables in this scope */ void CheckForUnusedVariables() const; /* Mark a variable as used */ @@ -78,9 +70,6 @@ public: bool VariableInitialized(const std::string& ) const; /* return true if a variable has been used */ bool VariableUsed(const std::string& ) const; - /** Return whether compatibility features needed for a version of - the cache or lower should be enabled. */ - bool NeedCacheCompatibility(int major, int minor) const; /** * Construct an empty makefile. @@ -292,11 +281,10 @@ public: /** * Add a subdirectory to the build. */ - void AddSubDirectory(const std::string&, bool excludeFromAll=false, - bool preorder = false); + void AddSubDirectory(const std::string&, bool excludeFromAll=false); void AddSubDirectory(const std::string& fullSrcDir, const std::string& fullBinDir, - bool excludeFromAll, bool preorder, + bool excludeFromAll, bool immediate); /** @@ -433,15 +421,6 @@ public: bool HasCMP0054AlreadyBeenReported( cmListFileContext context) const; - /** - * Add an auxiliary directory to the build. - */ - void AddExtraDirectory(const char* dir); - - - /** - * Add an auxiliary directory to the build. - */ void MakeStartDirectoriesCurrent() { this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", @@ -620,12 +599,6 @@ public: cmSourceFile* GetOrCreateSource(const std::string& sourceName, bool generated = false); - /** - * Obtain a list of auxiliary source directories. - */ - const std::vector<std::string>& GetAuxSourceDirectories() const - {return this->AuxSourceDirectories;} - //@{ /** * Return a list of extensions associated with source and header @@ -792,10 +765,6 @@ public: ///enabled. void EnableLanguage(std::vector<std::string>const& languages, bool optional); - /** - * Set/Get the name of the parent directories CMakeLists file - * given a current CMakeLists file name - */ cmCacheManager *GetCacheManager() const; /** @@ -879,10 +848,6 @@ public: ///! Initialize a makefile from its parent void InitializeFromParent(); - ///! Set/Get the preorder flag - void SetPreOrder(bool p) { this->PreOrder = p; } - bool GetPreOrder() const { return this->PreOrder; } - void AddInstallGenerator(cmInstallGenerator* g) { if(g) this->InstallGenerators.push_back(g); } std::vector<cmInstallGenerator*>& GetInstallGenerators() @@ -976,9 +941,6 @@ protected: // Check for a an unused variable void CheckForUnused(const char* reason, const std::string& name) const; - std::string Prefix; - std::vector<std::string> AuxSourceDirectories; // - std::string cmStartDirectory; std::string StartOutputDirectory; std::string cmHomeDirectory; @@ -1008,9 +970,8 @@ protected: // directories. std::set<std::string> SystemIncludeDirectories; - std::vector<std::string> ListFiles; // list of command files loaded - std::vector<std::string> OutputFiles; // list of command files loaded - + std::vector<std::string> ListFiles; + std::vector<std::string> OutputFiles; cmTarget::LinkLibraryVectorType LinkLibraries; @@ -1067,8 +1028,6 @@ private: std::vector<std::string> MacrosList; - std::map<std::string, bool> SubDirectoryOrder; - mutable cmsys::RegularExpression cmDefineRegex; mutable cmsys::RegularExpression cmDefine01Regex; mutable cmsys::RegularExpression cmAtVarRegex; @@ -1076,9 +1035,6 @@ private: cmPropertyMap Properties; - // should this makefile be processed before or after processing the parent - bool PreOrder; - // Unused variable flags bool WarnUnused; bool CheckSystemVars; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 641cd23..2cd2d3e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -122,6 +122,14 @@ void cmMakefileTargetGenerator::CreateRuleFile() return; } this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream); + if (this->GlobalGenerator->AllowDeleteOnError()) + { + std::vector<std::string> no_depends; + std::vector<std::string> no_commands; + this->LocalGenerator->WriteMakeRule( + *this->BuildFileStream, "Delete rule output on recipe failure.", + ".DELETE_ON_ERROR", no_depends, no_commands, false); + } this->LocalGenerator->WriteSpecialTargetsTop(*this->BuildFileStream); } diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index f6a2c26..cc094b1 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -37,24 +37,19 @@ bool cmMarkAsAdvancedCommand { std::string variable = args[i]; cmCacheManager* manager = this->Makefile->GetCacheManager(); - cmCacheManager::CacheIterator it = - manager->GetCacheIterator(variable.c_str()); - if ( it.IsAtEnd() ) + if (!manager->GetCacheEntryValue(variable)) { - this->Makefile->GetCacheManager() - ->AddCacheEntry(variable, 0, 0, - cmCacheManager::UNINITIALIZED); + manager->AddCacheEntry(variable, 0, 0, cmCacheManager::UNINITIALIZED); overwrite = true; } - it.Find(variable); - if ( it.IsAtEnd() ) + if (!manager->GetCacheEntryValue(variable)) { cmSystemTools::Error("This should never happen..."); return false; } - if ( !it.PropertyExists("ADVANCED") || overwrite ) + if (!manager->GetCacheEntryProperty(variable, "ADVANCED") || overwrite) { - it.SetProperty("ADVANCED", value); + manager->SetCacheEntryProperty(variable, "ADVANCED", value); } } return true; diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index 60728ea..baf5b1e 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -42,16 +42,16 @@ bool cmOptionCommand std::string initialValue = "Off"; // Now check and see if the value has been stored in the cache // already, if so use that value and don't look for the program - cmCacheManager::CacheIterator it = - this->Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str()); - if(!it.IsAtEnd()) + cmCacheManager* manager = this->Makefile->GetCacheManager(); + const char* existingValue = manager->GetCacheEntryValue(args[0]); + if(existingValue) { - if ( it.GetType() != cmCacheManager::UNINITIALIZED ) + if (manager->GetCacheEntryType(args[0]) != cmCacheManager::UNINITIALIZED) { - it.SetProperty("HELPSTRING", args[1].c_str()); + manager->SetCacheEntryProperty(args[0], "HELPSTRING", args[1]); return true; } - initialValue = it.GetValue(); + initialValue = existingValue; } if(args.size() == 3) { diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 720030b..e7678cb 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -380,6 +380,21 @@ cmPolicies::cmPolicies() CMP0057, "CMP0057", "Disallow multiple MAIN_DEPENDENCY specifications for the same file.", 3,3,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0058, "CMP0058", + "Ninja requires custom command byproducts to be explicit.", + 3,3,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0059, "CMP0059", + "Do no treat DEFINITIONS as a built-in directory property.", + 3,3,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0060, "CMP0060", + "Link libraries by full path even in implicit directories.", + 3,3,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 854b132..1d108c1 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -115,6 +115,10 @@ public: CMP0056, ///< Honor link flags in try_compile() source-file signature. CMP0057, ///< Disallow multiple MAIN_DEPENDENCY specifications /// for the same file. + CMP0058, ///< Ninja requires custom command byproducts to be explicit + CMP0059, ///< Do not treat ``DEFINITIONS`` as a built-in directory + /// property. + CMP0060, ///< Link libraries by full path even in implicit directories. /** \brief Always the last entry. * diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 42c18f7..4cb49c8 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -22,6 +22,8 @@ # include "cmLocalVisualStudioGenerator.h" #endif +#include <sys/stat.h> + #include <cmsys/Terminal.h> #include <cmsys/ios/sstream> #include <cmsys/FStream.hxx> @@ -372,7 +374,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) #endif std::vector<std::string> rcc_output; - if(makefile->GetLocalGenerator()->GetGlobalGenerator()->GetName() == "Ninja" + bool const isNinja = + makefile->GetLocalGenerator()->GetGlobalGenerator()->GetName() == "Ninja"; + if(isNinja #if defined(_WIN32) && !defined(__CYGWIN__) || usePRE_BUILD #endif @@ -442,7 +446,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) #endif { cmTarget* autogenTarget = 0; - if (!rcc_output.empty()) + if (!rcc_output.empty() && !isNinja) { std::vector<std::string> no_byproducts; makefile->AddCustomCommandToOutput(rcc_output, no_byproducts, @@ -462,7 +466,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) { autogenTarget = makefile->AddUtilityCommand( autogenTargetName, true, - workingDirectory.c_str(), depends, + workingDirectory.c_str(), + /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); } @@ -582,6 +587,18 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), false, true, false); + // Ensure we have write permission in case .in was read-only. + mode_t perm = 0; +#if defined(WIN32) && !defined(__CYGWIN__) + mode_t mode_write = S_IWRITE; +#else + mode_t mode_write = S_IWUSR; +#endif + cmSystemTools::GetPermissions(outputFile, perm); + if (!(perm & mode_write)) + { + cmSystemTools::SetPermissions(outputFile, perm | mode_write); + } if (!configDefines.empty() || !configIncludes.empty() || !configUicOptions.empty()) diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 204d95b..e17474b 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -136,9 +136,10 @@ bool cmSetCommand } // see if this is already in the cache - cmCacheManager::CacheIterator it = - this->Makefile->GetCacheManager()->GetCacheIterator(variable); - if(!it.IsAtEnd() && (it.GetType() != cmCacheManager::UNINITIALIZED)) + cmCacheManager* manager = this->Makefile->GetCacheManager(); + const char* existingValue = manager->GetCacheEntryValue(variable); + if(existingValue && + (manager->GetCacheEntryType(variable) != cmCacheManager::UNINITIALIZED)) { // if the set is trying to CACHE the value but the value // is already in the cache and the type is not internal diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 1150bc7..77f9fb9 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -452,11 +452,11 @@ bool cmSetPropertyCommand::HandleCacheMode() // Get the source file. cmMakefile* mf = this->GetMakefile(); cmake* cm = mf->GetCMakeInstance(); - cmCacheManager::CacheIterator it = - cm->GetCacheManager()->GetCacheIterator(ni->c_str()); - if(!it.IsAtEnd()) + const char* existingValue + = cm->GetCacheManager()->GetCacheEntryValue(*ni); + if(existingValue) { - if(!this->HandleCacheEntry(it)) + if(!this->HandleCacheEntry(*ni)) { return false; } @@ -474,22 +474,25 @@ bool cmSetPropertyCommand::HandleCacheMode() } //---------------------------------------------------------------------------- -bool cmSetPropertyCommand::HandleCacheEntry(cmCacheManager::CacheIterator& it) +bool cmSetPropertyCommand::HandleCacheEntry(std::string const& cacheKey) { // Set or append the property. const char* name = this->PropertyName.c_str(); const char* value = this->PropertyValue.c_str(); + cmCacheManager* manager = this->Makefile->GetCacheManager(); if (this->Remove) { - value = 0; + manager->RemoveCacheEntryProperty(cacheKey, name); + return true; } if(this->AppendMode) { - it.AppendProperty(name, value, this->AppendAsString); + manager->AppendCacheEntryProperty(cacheKey, name, value, + this->AppendAsString); } else { - it.SetProperty(name, value); + manager->SetCacheEntryProperty(cacheKey, name, value); } return true; diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index b06cb68..3285e60 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -61,7 +61,7 @@ private: bool HandleTestMode(); bool HandleTest(cmTest* test); bool HandleCacheMode(); - bool HandleCacheEntry(cmCacheManager::CacheIterator&); + bool HandleCacheEntry(std::string const&); bool HandleInstallMode(); bool HandleInstall(cmInstalledFile* file); }; diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index e41a0ca..06217bb 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -25,14 +25,12 @@ bool cmSetTargetPropertiesCommand // first collect up the list of files std::vector<std::string> propertyPairs; - bool doingFiles = true; int numFiles = 0; std::vector<std::string>::const_iterator j; for(j= args.begin(); j != args.end();++j) { if(*j == "PROPERTIES") { - doingFiles = false; // now loop through the rest of the arguments, new style ++j; if (std::distance(j, args.end()) % 2 != 0) @@ -43,15 +41,9 @@ bool cmSetTargetPropertiesCommand propertyPairs.insert(propertyPairs.end(), j, args.end()); break; } - else if (doingFiles) - { - numFiles++; - } else { - this->SetError("called with illegal arguments, maybe missing " - "a PROPERTIES specifier?"); - return false; + numFiles++; } } if(propertyPairs.empty()) diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index d079a19..e9cfacc 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -26,14 +26,12 @@ bool cmSetTestsPropertiesCommand // first collect up the list of files std::vector<std::string> propertyPairs; - bool doingFiles = true; int numFiles = 0; std::vector<std::string>::const_iterator j; for(j= args.begin(); j != args.end();++j) { if(*j == "PROPERTIES") { - doingFiles = false; // now loop through the rest of the arguments, new style ++j; if (std::distance(j, args.end()) % 2 != 0) @@ -44,15 +42,9 @@ bool cmSetTestsPropertiesCommand propertyPairs.insert(propertyPairs.end(), j, args.end()); break; } - else if (doingFiles) - { - numFiles++; - } else { - this->SetError("called with illegal arguments, maybe " - "missing a PROPERTIES specifier?"); - return false; + numFiles++; } } if(propertyPairs.empty()) @@ -62,7 +54,6 @@ bool cmSetTestsPropertiesCommand return false; } - // now loop over all the targets int i; for(i = 0; i < numFiles; ++i) diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index 93ad4f3..7cb2edc 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -22,7 +22,6 @@ bool cmSubdirCommand } bool res = true; bool excludeFromAll = false; - bool preorder = false; for(std::vector<std::string>::const_iterator i = args.begin(); i != args.end(); ++i) @@ -34,7 +33,7 @@ bool cmSubdirCommand } if(*i == "PREORDER") { - preorder = true; + // Ignored continue; } @@ -48,7 +47,7 @@ bool cmSubdirCommand std::string(this->Makefile->GetCurrentOutputDirectory()) + "/" + i->c_str(); this->Makefile->AddSubDirectory(srcPath, binPath, - excludeFromAll, preorder, false); + excludeFromAll, false); } // otherwise it is a full path else if ( cmSystemTools::FileIsDirectory(*i) ) @@ -59,7 +58,7 @@ bool cmSubdirCommand std::string(this->Makefile->GetCurrentOutputDirectory()) + "/" + cmSystemTools::GetFilenameName(*i); this->Makefile->AddSubDirectory(*i, binPath, - excludeFromAll, preorder, false); + excludeFromAll, false); } else { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b70f60d..85e5165 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -442,6 +442,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) if(this->TargetTypeValue == cmTarget::EXECUTABLE) { this->SetPropertyDefault("ANDROID_GUI", 0); + this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", 0); } if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY || this->TargetTypeValue == cmTarget::MODULE_LIBRARY) @@ -616,6 +617,13 @@ bool cmTarget::IsCFBundleOnApple() const } //---------------------------------------------------------------------------- +bool cmTarget::IsXCTestOnApple() const +{ + return (this->IsCFBundleOnApple() && + this->GetPropertyAsBool("XCTEST")); +} + +//---------------------------------------------------------------------------- bool cmTarget::IsBundleOnApple() const { return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || @@ -6791,7 +6799,14 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, const char *ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { - ext = "bundle"; + if (this->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } } fpath += ext; fpath += "/Contents"; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 5170b31..55bf234 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -34,7 +34,8 @@ F(CMP0041) \ F(CMP0042) \ F(CMP0046) \ - F(CMP0052) + F(CMP0052) \ + F(CMP0060) class cmake; class cmMakefile; @@ -527,6 +528,9 @@ public: /** Return whether this target is a CFBundle (plugin) on Apple. */ bool IsCFBundleOnApple() const; + /** Return whether this target is a XCTest on Apple. */ + bool IsXCTestOnApple() const; + /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index f87a535..add80fa 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -82,11 +82,31 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // be translated. std::string exe = command[0]; cmMakefile* mf = this->Test->GetMakefile(); + cmLocalGenerator* lg = mf->GetLocalGenerator(); cmTarget* target = mf->FindTargetToUse(exe); if(target && target->GetType() == cmTarget::EXECUTABLE) { // Use the target file on disk. exe = target->GetFullPath(config); + + // Prepend with the emulator when cross compiling if required. + const char * emulator = + target->GetProperty("CROSSCOMPILING_EMULATOR"); + if (emulator != 0) + { + std::vector<std::string> emulatorWithArgs; + cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); + std::string emulatorExe(emulatorWithArgs[0]); + cmSystemTools::ConvertToUnixSlashes(emulatorExe); + os << lg->EscapeForCMake(emulatorExe) << " "; + for(std::vector<std::string>::const_iterator ei = + emulatorWithArgs.begin()+1; + ei != emulatorWithArgs.end(); + ++ei) + { + os << lg->EscapeForCMake(*ei) << " "; + } + } } else { @@ -96,7 +116,6 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, } // Generate the command line with full escapes. - cmLocalGenerator* lg = mf->GetLocalGenerator(); os << lg->EscapeForCMake(exe); for(std::vector<std::string>::const_iterator ci = command.begin()+1; ci != command.end(); ++ci) diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index b5280cf..63109e0 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -149,7 +149,8 @@ bool cmTryRunCommand { // "run" it and capture the output std::string runOutputContents; - if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) + if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING") && + !this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR")) { this->DoNotRunExecutable(runArgs, argv[3], @@ -195,7 +196,28 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, std::string* out) { int retVal = -1; - std::string finalCommand = cmSystemTools::ConvertToRunCommandPath( + + std::string finalCommand; + const std::string emulator = + this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR"); + if (!emulator.empty()) + { + std::vector<std::string> emulatorWithArgs; + cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); + finalCommand += cmSystemTools::ConvertToRunCommandPath( + emulatorWithArgs[0].c_str()); + finalCommand += " "; + for (std::vector<std::string>::const_iterator ei = + emulatorWithArgs.begin()+1; + ei != emulatorWithArgs.end(); ++ei) + { + finalCommand += "\""; + finalCommand += *ei; + finalCommand += "\""; + finalCommand += " "; + } + } + finalCommand += cmSystemTools::ConvertToRunCommandPath( this->OutputFile.c_str()); if (!runArgs.empty()) { @@ -264,11 +286,12 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment.c_str(), cmCacheManager::STRING); - cmCacheManager::CacheIterator it = this->Makefile->GetCacheManager()-> - GetCacheIterator(this->RunResultVariable.c_str()); - if ( !it.IsAtEnd() ) + cmCacheManager* manager = this->Makefile->GetCacheManager(); + const char* existingValue + = manager->GetCacheEntryValue(this->RunResultVariable); + if (existingValue) { - it.SetProperty("ADVANCED", "1"); + manager->SetCacheEntryProperty(this->RunResultVariable, "ADVANCED", "1"); } error = true; @@ -290,11 +313,13 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(), cmCacheManager::STRING); - cmCacheManager::CacheIterator it = this->Makefile->GetCacheManager()-> - GetCacheIterator(internalRunOutputName.c_str()); - if ( !it.IsAtEnd() ) + cmCacheManager* manager = this->Makefile->GetCacheManager(); + const char* existing = + manager->GetCacheEntryValue(internalRunOutputName); + if (existing) { - it.SetProperty("ADVANCED", "1"); + manager->SetCacheEntryProperty(internalRunOutputName, + "ADVANCED", "1"); } error = true; diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index ee1ff29..2799a9b 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -52,11 +52,13 @@ bool cmUtilitySourceCommand } else { + cmCacheManager *manager = + this->Makefile->GetCMakeInstance()->GetCacheManager(); haveCacheValue = (cacheValue && (strstr(cacheValue, "(IntDir)") == 0 || (intDir && strcmp(intDir, "$(IntDir)") == 0)) && - (this->Makefile->GetCacheMajorVersion() != 0 && - this->Makefile->GetCacheMinorVersion() != 0 )); + (manager->GetCacheMajorVersion() != 0 && + manager->GetCacheMinorVersion() != 0 )); } if(haveCacheValue) diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 80c1286..dd2a682 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -41,9 +41,9 @@ bool cmVariableRequiresCommand requirementsMet = false; notSet += args[i]; notSet += "\n"; - cmCacheManager::CacheIterator it = - this->Makefile->GetCacheManager()->GetCacheIterator(args[i].c_str()); - if(!it.IsAtEnd() && it.GetPropertyAsBool("ADVANCED")) + cmCacheManager* manager = this->Makefile->GetCacheManager(); + if(manager->GetCacheEntryValue(args[i]) && + manager->GetCacheEntryPropertyAsBool(args[i], "ADVANCED")) { hasAdvanced = true; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 19444ed..dad6f93 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -461,6 +461,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteAllSources(); this->WriteDotNetReferences(); this->WriteEmbeddedResourceGroup(); + this->WriteXamlFilesGroup(); this->WriteWinRTReferences(); this->WriteProjectReferences(); this->WriteString( @@ -522,8 +523,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() this->WriteString("<DependentUpon>", 3); std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h"; - (*this->BuildFileStream ) << hFileName; - this->WriteString("</DependentUpon>\n", 3); + (*this->BuildFileStream) << hFileName << "</DependentUpon>\n"; std::vector<std::string> const * configs = this->GlobalGenerator->GetConfigurations(); @@ -546,6 +546,38 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() } } +void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup() +{ + std::vector<cmSourceFile const*> xamlObjs; + this->GeneratorTarget->GetXamlSources(xamlObjs, ""); + if (!xamlObjs.empty()) + { + this->WriteString("<ItemGroup>\n", 1); + for (std::vector<cmSourceFile const*>::const_iterator + oi = xamlObjs.begin(); oi != xamlObjs.end(); ++oi) + { + std::string obj = (*oi)->GetFullPath(); + std::string xamlType; + const char * xamlTypeProperty = (*oi)->GetProperty("VS_XAML_TYPE"); + if (xamlTypeProperty) + { + xamlType = xamlTypeProperty; + } + else + { + xamlType = "Page"; + } + + this->WriteSource(xamlType, *oi, ">\n"); + this->WriteString("<SubType>Designer</SubType>\n", 3); + this->WriteString("</", 2); + (*this->BuildFileStream) << xamlType << ">\n"; + + } + this->WriteString("</ItemGroup>\n", 1); + } +} + void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences() { if(this->MSTools) @@ -1192,12 +1224,21 @@ WriteGroupSources(const char* name, void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf) { - if(this->IsResxHeader(sf->GetFullPath())) + std::string const& fileName = sf->GetFullPath(); + if (this->IsResxHeader(fileName)) { this->WriteSource("ClInclude", sf, ">\n"); this->WriteString("<FileType>CppForm</FileType>\n", 3); this->WriteString("</ClInclude>\n", 2); } + else if (this->IsXamlHeader(fileName)) + { + this->WriteSource("ClInclude", sf, ">\n"); + this->WriteString("<DependentUpon>", 3); + std::string xamlFileName = fileName.substr(0, fileName.find_last_of(".")); + (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n"; + this->WriteString("</ClInclude>\n", 2); + } else { this->WriteSource("ClInclude", sf); @@ -1669,6 +1710,17 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( " ", "\n", lang); } } + if (this->IsXamlSource(source->GetFullPath())) + { + (*this->BuildFileStream) << firstString; + firstString = ""; // only do firstString once + hasFlags = true; + this->WriteString("<DependentUpon>", 3); + const std::string& fileName = source->GetFullPath(); + std::string xamlFileName = fileName.substr(0, fileName.find_last_of(".")); + (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n"; + } + return hasFlags; } @@ -2749,6 +2801,28 @@ bool cmVisualStudio10TargetGenerator:: return it != expectedResxHeaders.end(); } +bool cmVisualStudio10TargetGenerator:: +IsXamlHeader(const std::string& headerFile) +{ + std::set<std::string> expectedXamlHeaders; + this->GeneratorTarget->GetExpectedXamlHeaders(expectedXamlHeaders, ""); + + std::set<std::string>::const_iterator it = + expectedXamlHeaders.find(headerFile); + return it != expectedXamlHeaders.end(); +} + +bool cmVisualStudio10TargetGenerator:: +IsXamlSource(const std::string& sourceFile) +{ + std::set<std::string> expectedXamlSources; + this->GeneratorTarget->GetExpectedXamlSources(expectedXamlSources, ""); + + std::set<std::string>::const_iterator it = + expectedXamlSources.find(sourceFile); + return it != expectedXamlSources.end(); +} + void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() { bool isAppContainer = false; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index a02dfa8..a2776de 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -69,6 +69,7 @@ private: void WriteEmbeddedResourceGroup(); void WriteWinRTReferences(); void WriteWinRTPackageCertificateKeyFile(); + void WriteXamlFilesGroup(); void WritePathAndIncrementalLinkOptions(); void WriteItemDefinitionGroups(); void VerifyNecessaryFiles(); @@ -119,6 +120,8 @@ private: void AddMissingSourceGroups(std::set<cmSourceGroup*>& groupsUsed, const std::vector<cmSourceGroup>& allGroups); bool IsResxHeader(const std::string& headerFile); + bool IsXamlHeader(const std::string& headerFile); + bool IsXamlSource(const std::string& headerFile); cmIDEFlagTable const* GetClFlagTable() const; cmIDEFlagTable const* GetRcFlagTable() const; diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 3302a8d..5a90fd9 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -242,6 +242,7 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) // considered special by the Xcode project file parser. bool needQuote = (String.empty() || + String.find("//") != String.npos || String.find_first_of(" <>.+-=@$[],") != String.npos); const char* quote = needQuote? "\"" : ""; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 11196e4..7595155 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -86,6 +86,8 @@ # include "cmGlobalKdevelopGenerator.h" #endif +#include "cmExtraQbsGenerator.h" + #ifdef CMAKE_USE_ECLIPSE # include "cmExtraEclipseCDT4Generator.h" #endif @@ -186,7 +188,6 @@ void cmake::InitializeProperties() { this->Properties.clear(); this->Properties.SetCMakeInstance(this); - this->AccessedProperties.clear(); this->PropertyDefinitions.clear(); // initialize properties @@ -211,7 +212,7 @@ void cmake::CleanupCommandsAndMacros() delete j->second; } } - this->Commands.erase(this->Commands.begin(), this->Commands.end()); + this->Commands.clear(); std::vector<cmCommand*>::iterator it; for ( it = commands.begin(); it != commands.end(); ++ it ) @@ -343,7 +344,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) std::string cachedValue; if(this->WarnUnusedCli) { - if(const char *v = this->CacheManager->GetCacheValue(var)) + if(const char *v = this->CacheManager + ->GetInitializedCacheValue(var)) { haveValue = true; cachedValue = v; @@ -356,7 +358,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) if(this->WarnUnusedCli) { if (!haveValue || - cachedValue != this->CacheManager->GetCacheValue(var)) + cachedValue != this->CacheManager + ->GetInitializedCacheValue(var)) { this->WatchUnusedCli(var); } @@ -400,17 +403,18 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str()); //go through all cache entries and collect the vars which will be removed std::vector<std::string> entriesToDelete; - cmCacheManager::CacheIterator it = - this->CacheManager->GetCacheIterator(); - for ( it.Begin(); !it.IsAtEnd(); it.Next() ) + std::vector<std::string> cacheKeys = + this->CacheManager->GetCacheEntryKeys(); + for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); + it != cacheKeys.end(); ++it) { - cmCacheManager::CacheEntryType t = it.GetType(); + cmCacheManager::CacheEntryType t = + this->CacheManager->GetCacheEntryType(*it); if(t != cmCacheManager::STATIC) { - std::string entryName = it.GetName(); - if (regex.find(entryName.c_str())) + if (regex.find(it->c_str())) { - entriesToDelete.push_back(entryName); + entriesToDelete.push_back(*it); } } } @@ -914,16 +918,18 @@ void cmake::SetDirectoriesFromFile(const char* arg) // If there is a CMakeCache.txt file, use its settings. if(!cachePath.empty()) { - cmCacheManager* cachem = this->GetCacheManager(); - cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(cachem->LoadCache(cachePath) && - it.Find("CMAKE_HOME_DIRECTORY")) + if(this->LoadCache(cachePath)) { - this->SetHomeOutputDirectory(cachePath); - this->SetStartOutputDirectory(cachePath); - this->SetHomeDirectory(it.GetValue()); - this->SetStartDirectory(it.GetValue()); - return; + const char* existingValue = + this->CacheManager->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"); + if (existingValue) + { + this->SetHomeOutputDirectory(cachePath); + this->SetStartOutputDirectory(cachePath); + this->SetHomeDirectory(existingValue); + this->SetStartDirectory(existingValue); + return; + } } } @@ -1029,6 +1035,8 @@ void cmake::AddDefaultExtraGenerators() &cmExtraSublimeTextGenerator::New); this->AddExtraGenerator(cmExtraKateGenerator::GetActualName(), &cmExtraKateGenerator::New); + this->AddExtraGenerator(cmExtraQbsGenerator::GetActualName(), + &cmExtraQbsGenerator::New); #ifdef CMAKE_USE_ECLIPSE this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(), @@ -1200,10 +1208,10 @@ int cmake::DoPreConfigureChecks() } // do a sanity check on some values - if(this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY")) + if(this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) { std::string cacheStart = - this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); + this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); currentStart += "/CMakeLists.txt"; @@ -1352,9 +1360,9 @@ int cmake::ActualConfigure() if(!this->GlobalGenerator) { const char* genName = - this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); + this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR"); const char* extraGenName = - this->CacheManager->GetCacheValue("CMAKE_EXTRA_GENERATOR"); + this->CacheManager->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); if(genName) { std::string fullName = cmExternalMakefileProjectGenerator:: @@ -1432,7 +1440,8 @@ int cmake::ActualConfigure() } } - const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); + const char* genName = this->CacheManager + ->GetInitializedCacheValue("CMAKE_GENERATOR"); if(genName) { if(!this->GlobalGenerator->MatchesGeneratorName(genName)) @@ -1448,7 +1457,7 @@ int cmake::ActualConfigure() return -2; } } - if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR")) + if(!this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR")) { this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", this->GlobalGenerator->GetName().c_str(), @@ -1461,7 +1470,7 @@ int cmake::ActualConfigure() } if(const char* platformName = - this->CacheManager->GetCacheValue("CMAKE_GENERATOR_PLATFORM")) + this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) { if(this->GeneratorPlatform.empty()) { @@ -1489,7 +1498,7 @@ int cmake::ActualConfigure() } if(const char* tsName = - this->CacheManager->GetCacheValue("CMAKE_GENERATOR_TOOLSET")) + this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) { if(this->GeneratorToolset.empty()) { @@ -1543,16 +1552,18 @@ int cmake::ActualConfigure() // project requires compatibility with CMake 2.4. We detect this // here by looking for the old CMAKE_BACKWARDS_COMPATIBILITY // variable created when CMP0001 is not set to NEW. - if(this->GetCacheManager()->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) + if(this->GetCacheManager() + ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) { - if(!this->CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH")) + if(!this->CacheManager->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) { this->CacheManager->AddCacheEntry ("LIBRARY_OUTPUT_PATH", "", "Single output directory for building all libraries.", cmCacheManager::PATH); } - if(!this->CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH")) + if(!this->CacheManager + ->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) { this->CacheManager->AddCacheEntry ("EXECUTABLE_OUTPUT_PATH", "", @@ -1560,24 +1571,25 @@ int cmake::ActualConfigure() cmCacheManager::PATH); } } - if(!this->CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS")) + if(!this->CacheManager + ->GetInitializedCacheValue("CMAKE_USE_RELATIVE_PATHS")) { this->CacheManager->AddCacheEntry ("CMAKE_USE_RELATIVE_PATHS", "OFF", "If true, cmake will use relative paths in makefiles and projects.", cmCacheManager::BOOL); - cmCacheManager::CacheIterator it = - this->CacheManager->GetCacheIterator("CMAKE_USE_RELATIVE_PATHS"); - if ( !it.PropertyExists("ADVANCED") ) + if (!this->CacheManager->GetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS", + "ADVANCED")) { - it.SetProperty("ADVANCED", "1"); + this->CacheManager->SetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS", + "ADVANCED", "1"); } } if(cmSystemTools::GetFatalErrorOccured() && - (!this->CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") || + (!this->CacheManager->GetInitializedCacheValue("CMAKE_MAKE_PROGRAM") || cmSystemTools::IsOff(this->CacheManager-> - GetCacheValue("CMAKE_MAKE_PROGRAM")))) + GetInitializedCacheValue("CMAKE_MAKE_PROGRAM")))) { // We must have a bad generator selection. Wipe the cache entry so the // user can select another. @@ -1793,7 +1805,7 @@ void cmake::AddCacheEntry(const std::string& key, const char* value, const char* cmake::GetCacheDefinition(const std::string& name) const { - return this->CacheManager->GetCacheValue(name); + return this->CacheManager->GetInitializedCacheValue(name); } void cmake::AddDefaultCommands() @@ -1814,23 +1826,23 @@ void cmake::AddDefaultGenerators() #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) this->Generators.push_back( - cmGlobalVisualStudio6Generator::NewFactory()); - this->Generators.push_back( - cmGlobalVisualStudio7Generator::NewFactory()); + cmGlobalVisualStudio14Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio10Generator::NewFactory()); + cmGlobalVisualStudio12Generator::NewFactory()); this->Generators.push_back( cmGlobalVisualStudio11Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio12Generator::NewFactory()); + cmGlobalVisualStudio10Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio14Generator::NewFactory()); + cmGlobalVisualStudio9Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio8Generator::NewFactory()); this->Generators.push_back( cmGlobalVisualStudio71Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio8Generator::NewFactory()); + cmGlobalVisualStudio7Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio9Generator::NewFactory()); + cmGlobalVisualStudio6Generator::NewFactory()); this->Generators.push_back( cmGlobalBorlandMakefileGenerator::NewFactory()); this->Generators.push_back( @@ -1857,10 +1869,18 @@ void cmake::AddDefaultGenerators() #endif } +bool cmake::ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + cmCacheManager::CacheEntryType& type) +{ + return cmCacheManager::ParseEntry(entry, var, value, type); +} + int cmake::LoadCache() { // could we not read the cache - if (!this->CacheManager->LoadCache(this->GetHomeOutputDirectory())) + if (!this->LoadCache(this->GetHomeOutputDirectory())) { // if it does exist, but isn't readable then warn the user std::string cacheFile = this->GetHomeOutputDirectory(); @@ -1883,6 +1903,28 @@ int cmake::LoadCache() return 0; } +bool cmake::LoadCache(const std::string& path) +{ + return this->CacheManager->LoadCache(path); +} + +bool cmake::LoadCache(const std::string& path, bool internal, + std::set<std::string>& excludes, + std::set<std::string>& includes) +{ + return this->CacheManager->LoadCache(path, internal, excludes, includes); +} + +bool cmake::SaveCache(const std::string& path) +{ + return this->CacheManager->SaveCache(path); +} + +bool cmake::DeleteCache(const std::string& path) +{ + return this->CacheManager->DeleteCache(path); +} + void cmake::SetProgressCallback(ProgressCallbackType f, void *cd) { this->ProgressCallback = f; @@ -1923,7 +1965,8 @@ void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: const char* tablepath = - this->CacheManager->GetCacheValue("CMAKE_PATH_TRANSLATION_FILE"); + this->CacheManager + ->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if(tablepath) { @@ -2157,7 +2200,7 @@ void cmake::TruncateOutputLog(const char* fname) { return; } - if ( !this->CacheManager->GetCacheValue("CMAKE_CACHEFILE_DIR") ) + if ( !this->CacheManager->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR") ) { cmSystemTools::RemoveFile(fullPath); return; @@ -2270,23 +2313,13 @@ const char *cmake::GetProperty(const std::string& prop) const char *cmake::GetProperty(const std::string& prop, cmProperty::ScopeType scope) { - bool chain = false; - // watch for special properties std::string output = ""; if ( prop == "CACHE_VARIABLES" ) { - cmCacheManager::CacheIterator cit = - this->GetCacheManager()->GetCacheIterator(); - for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) - { - if (!output.empty()) - { - output += ";"; - } - output += cit.GetName(); - } - this->SetProperty("CACHE_VARIABLES", output.c_str()); + std::vector<std::string> cacheKeys = + this->CacheManager->GetCacheEntryKeys(); + this->SetProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str()); } else if ( prop == "COMMANDS" ) { @@ -2329,7 +2362,8 @@ const char *cmake::GetProperty(const std::string& prop, return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; } #undef STRING_LIST_ELEMENT - return this->Properties.GetPropertyValue(prop, scope, chain); + bool dummy = false; + return this->Properties.GetPropertyValue(prop, scope, dummy); } bool cmake::GetPropertyAsBool(const std::string& prop) @@ -2437,7 +2471,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // we have to find the module directory, so we can copy the files this->AddCMakePaths(); std::string modulesPath = - this->CacheManager->GetCacheValue("CMAKE_ROOT"); + this->CacheManager->GetInitializedCacheValue("CMAKE_ROOT"); modulesPath += "/Modules"; std::string inFile = modulesPath; inFile += "/SystemInformation.cmake"; @@ -2647,9 +2681,9 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, if(t == cmake::AUTHOR_WARNING) { // Allow suppression of these warnings. - cmCacheManager::CacheIterator it = this->CacheManager - ->GetCacheIterator("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); - if(!it.IsAtEnd() && it.GetValueAsBool()) + const char* suppress = this->CacheManager->GetCacheEntryValue( + "CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); + if(suppress && cmSystemTools::IsOn(suppress)) { return; } @@ -2762,38 +2796,42 @@ int cmake::Build(const std::string& dir, } std::string cachePath = dir; cmSystemTools::ConvertToUnixSlashes(cachePath); - cmCacheManager* cachem = this->GetCacheManager(); - cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(!cachem->LoadCache(cachePath)) + if(!this->LoadCache(cachePath)) { std::cerr << "Error: could not load cache\n"; return 1; } - if(!it.Find("CMAKE_GENERATOR")) + const char* cachedGenerator = + this->CacheManager->GetCacheEntryValue("CMAKE_GENERATOR"); + if(!cachedGenerator) { std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n"; return 1; } cmsys::auto_ptr<cmGlobalGenerator> gen( - this->CreateGlobalGenerator(it.GetValue())); + this->CreateGlobalGenerator(cachedGenerator)); if(!gen.get()) { std::cerr << "Error: could create CMAKE_GENERATOR \"" - << it.GetValue() << "\"\n"; + << cachedGenerator << "\"\n"; return 1; } std::string output; std::string projName; - if(!it.Find("CMAKE_PROJECT_NAME")) + const char* cachedProjectName = + this->CacheManager->GetCacheEntryValue("CMAKE_PROJECT_NAME"); + if(!cachedProjectName) { std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n"; return 1; } - projName = it.GetValue(); + projName = cachedProjectName; bool verbose = false; - if(it.Find("CMAKE_VERBOSE_MAKEFILE")) + const char* cachedVerbose = + this->CacheManager->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE"); + if(cachedVerbose) { - verbose = it.GetValueAsBool(); + verbose = cmSystemTools::IsOn(cachedVerbose); } return gen->Build("", dir, projName, target, diff --git a/Source/cmake.h b/Source/cmake.h index 60ffcd4..3acf4a8 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -18,11 +18,11 @@ #include "cmPropertyDefinitionMap.h" #include "cmPropertyMap.h" #include "cmInstalledFile.h" +#include "cmCacheManager.h" class cmGlobalGeneratorFactory; class cmGlobalGenerator; class cmLocalGenerator; -class cmCacheManager; class cmMakefile; class cmCommand; class cmVariableWatch; @@ -173,7 +173,19 @@ class cmake int Configure(); int ActualConfigure(); + ///! Break up a line like VAR:type="value" into var, type and value + static bool ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + cmCacheManager::CacheEntryType& type); + int LoadCache(); + bool LoadCache(const std::string& path); + bool LoadCache(const std::string& path, bool internal, + std::set<std::string>& excludes, + std::set<std::string>& includes); + bool SaveCache(const std::string& path); + bool DeleteCache(const std::string& path); void PreLoadCMakeFiles(); ///! Create a GlobalGenerator @@ -287,9 +299,6 @@ class cmake cmProperty::ScopeType scope); bool GetPropertyAsBool(const std::string& prop); - // Get the properties - cmPropertyMap &GetProperties() { return this->Properties; } - ///! Get or create an cmInstalledFile instance and return a pointer to it cmInstalledFile *GetOrCreateInstalledFile( cmMakefile* mf, const std::string& name); @@ -383,7 +392,6 @@ protected: void InitializeProperties(); int HandleDeleteCacheVariables(const std::string& var); cmPropertyMap Properties; - std::set<std::pair<std::string,cmProperty::ScopeType> > AccessedProperties; std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index ac73ad0..3b518be 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -328,25 +328,31 @@ int do_cmake(int ac, char const* const* av) int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) { - cmCacheManager::CacheIterator it = - cm.GetCacheManager()->GetCacheIterator(); std::cout << "-- Cache values" << std::endl; - for ( it.Begin(); !it.IsAtEnd(); it.Next() ) + std::vector<std::string> keys = + cm.GetCacheManager()->GetCacheEntryKeys(); + for (std::vector<std::string>::const_iterator it = keys.begin(); + it != keys.end(); ++it) { - cmCacheManager::CacheEntryType t = it.GetType(); + cmCacheManager::CacheEntryType t = + cm.GetCacheManager()->GetCacheEntryType(*it); if ( t != cmCacheManager::INTERNAL && t != cmCacheManager::STATIC && t != cmCacheManager::UNINITIALIZED ) { - bool advanced = it.PropertyExists("ADVANCED"); - if ( list_all_cached || !advanced) + const char* advancedProp = + cm.GetCacheManager()->GetCacheEntryProperty(*it, "ADVANCED"); + if ( list_all_cached || !advancedProp) { if ( list_help ) { - std::cout << "// " << it.GetProperty("HELPSTRING") << std::endl; + std::cout << "// " + << cm.GetCacheManager()->GetCacheEntryProperty(*it, + "HELPSTRING") << std::endl; } - std::cout << it.GetName() << ":" << - cmCacheManager::TypeToString(it.GetType()) - << "=" << it.GetValue() << std::endl; + std::cout << *it << ":" << + cmCacheManager::TypeToString(t) + << "=" << cm.GetCacheManager()->GetCacheEntryValue(*it) + << std::endl; if ( list_help ) { std::cout << std::endl; diff --git a/Source/ctest.cxx b/Source/ctest.cxx index c0eb8ac..0fc47b7 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -75,6 +75,8 @@ static const char * cmDocumentationOptions[][2] = "Run a specific number of tests by number."}, {"-U, --union", "Take the Union of -I and -R"}, {"--rerun-failed", "Run only the tests that failed previously"}, + {"--repeat-until-fail <n>", "Require each test to run <n> " + "times without failing in order to pass"}, {"--max-width <width>", "Set the max width for a test name to output"}, {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1."}, {"--no-label-summary", "Disable timing summary information for labels."}, diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 9c7ceee..b0434f4 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -1234,6 +1234,7 @@ void StacktraceSignalHandler( case ILL_ILLTRP: oss << "illegal trap"; + break; case ILL_PRVOPC: oss << "privileged opcode"; @@ -1823,6 +1824,7 @@ const char * SystemInformationImplementation::GetVendorID() return "Motorola"; case HP: return "Hewlett-Packard"; + case UnknownManufacturer: default: return "Unknown Manufacturer"; } @@ -3064,6 +3066,12 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() case NSC: this->ChipID.ProcessorName = "Cx486SLC \\ DLC \\ Cx486S A-Step"; break; + + case Sun: + case IBM: + case Motorola: + case HP: + case UnknownManufacturer: default: this->ChipID.ProcessorName = "Unknown family"; // We cannot identify the processor. return false; diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx index b861a5b..ac5cf74 100644 --- a/Source/kwsys/testHashSTL.cxx +++ b/Source/kwsys/testHashSTL.cxx @@ -34,7 +34,7 @@ template class kwsys::hash_map<const char*, int>; template class kwsys::hash_set<int>; -bool test_hash_map() +static bool test_hash_map() { typedef kwsys::hash_map<const char*, int> mtype; mtype m; @@ -51,7 +51,7 @@ bool test_hash_map() return sum == 3; } -bool test_hash_set() +static bool test_hash_set() { typedef kwsys::hash_set<int> stype; stype s; diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt index 818b8c9..741c73e 100644 --- a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt @@ -22,8 +22,18 @@ generate_export_header(staticlib1) add_library(staticlib2 STATIC staticlib2.cpp) generate_export_header(staticlib2) target_link_libraries(staticlib1 LINK_PUBLIC staticlib2) + +# Try adding a private link item to be propagated out of a static lib. +set(private_link "") if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang) - target_link_libraries(staticlib1 LINK_PRIVATE "-Wl,-v") + if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(private_link "-Wl,-V") + else() + set(private_link "-Wl,-v") + endif() +endif() +if(private_link) + target_link_libraries(staticlib1 LINK_PRIVATE "${private_link}") endif() add_executable(staticlib_exe staticlib_exe.cpp) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 40bea51..f80191b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -172,6 +172,7 @@ if(BUILD_TESTING) ON) mark_as_advanced(CTEST_TEST_CPACK) set(CTEST_TEST_OSX_ARCH 0) + set(CMake_TEST_XCODE_VERSION 0) if(APPLE) execute_process( COMMAND sw_vers -productVersion @@ -185,6 +186,17 @@ if(BUILD_TESTING) else() set(CTEST_TEST_OSX_ARCH 1) endif() + if(XCODE_VERSION) + set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}") + else() + execute_process( + COMMAND xcodebuild -version + OUTPUT_VARIABLE _version ERROR_VARIABLE _version + ) + if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)") + set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}") + endif() + endif() endif() # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value, @@ -560,7 +572,21 @@ if(BUILD_TESTING) --test-command Simple) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator") endif () - + # check for the Qbs generator + if ("${cmakeOutput}" MATCHES Qbs) + add_test(Simple_QbsGenerator ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Simple" + "${CMake_BINARY_DIR}/Tests/Simple_QbsGenerator" + --build-two-config + --build-generator "Qbs - Unix Makefiles" + --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" + --build-project Simple + --build-options ${build_options} + --test-command Simple) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_QbsGenerator") + endif () endif() # test for correct sub-project generation @@ -836,6 +862,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set(CTEST_RUN_CPackComponents ${CTEST_TEST_CPACK}) set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK}) set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK}) + set(CTEST_RUN_CPackComponentsPrefix ${CTEST_TEST_CPACK}) # Do not try to build RPM if (NOT RPMBUILD_EXECUTABLE) @@ -964,6 +991,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ${build_generator_args} --build-project CPackComponentsForAll --build-options ${build_options} + -DCPACK_GENERATOR:STRING=${CPackGen} -DCPACK_BINARY_${CPackGen}:BOOL=ON ${CPackRun_CPackComponentWay} ${CPackComponentsForAll_BUILD_OPTIONS} @@ -1009,6 +1037,33 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators") endif() + if(CTEST_RUN_CPackComponentsPrefix) + set(CPackComponents_BUILD_OPTIONS) + if(APPLE) + set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON) + endif() + if(NOT NSIS_MAKENSIS_EXECUTABLE) + set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS} + -DCPACK_BINARY_NSIS:BOOL=OFF) + endif() + + add_test(CPackComponentsPrefix ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackComponentsPrefix" + "${CMake_BINARY_DIR}/Tests/CPackComponentsPrefix" + ${build_generator_args} + --build-project CPackComponentsPrefix + --build-two-config + --build-target package + --build-options ${build_options} + -DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB} + -DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM} + -DCPACK_BINARY_ZIP:BOOL=ON + ${CPackComponents_BUILD_OPTIONS} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponentsPrefix") + endif() + if(CTEST_package_X11_TEST) set(X11_build_target_arg --build-target package) else() @@ -1493,6 +1548,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) endif() + if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5 + AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") + set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1}) + ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> -V) + endif() + add_test(linkorder1 ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/LinkLineOrder" @@ -1866,6 +1927,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1) add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013 ARM" WindowsStore 8.1) add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013 Win64" WindowsStore 8.1) + + add_test(NAME VSXaml COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSXaml" + "${CMake_BINARY_DIR}/Tests/VSXaml" + --build-generator "Visual Studio 12 2013" + --build-project VSXaml + --build-config $<CONFIGURATION> + --build-options -DCMAKE_SYSTEM_NAME=WindowsStore + -DCMAKE_SYSTEM_VERSION=8.1 + ) endif() if(vs11 AND wp80) add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0) @@ -2284,12 +2356,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake" @ONLY ESCAPE_QUOTES) add_test(CTestCoverageCollectGCOV ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} -S "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake" -VV --output-log "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/testOut.log" ) set_tests_properties(CTestCoverageCollectGCOV PROPERTIES PASS_REGULAR_EXPRESSION - "PASSED with correct output.*Testing/CoverageInfo/echoargs.gcov") + "PASSED with correct output.*Testing/CoverageInfo/main.cpp.gcov") configure_file( "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in" diff --git a/Tests/CMakeTests/ELFTest.cmake.in b/Tests/CMakeTests/ELFTest.cmake.in index 0271abb..4635778 100644 --- a/Tests/CMakeTests/ELFTest.cmake.in +++ b/Tests/CMakeTests/ELFTest.cmake.in @@ -11,7 +11,7 @@ set(out "@CMAKE_CURRENT_BINARY_DIR@/ELF-Out") file(REMOVE_RECURSE "${out}") file(MAKE_DIRECTORY "${out}") foreach(f ${names}) - file(COPY ${in}/${f} DESTINATION ${out}) + file(COPY ${in}/${f} DESTINATION ${out} NO_SOURCE_PERMISSIONS) list(APPEND files "${out}/${f}") endforeach() diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt index 51af297..1cc34b0 100644 --- a/Tests/CPackComponentsForAll/CMakeLists.txt +++ b/Tests/CPackComponentsForAll/CMakeLists.txt @@ -49,6 +49,44 @@ install(FILES mylib.h DESTINATION include COMPONENT headers) +if("${CPACK_GENERATOR}" MATCHES "RPM") + # Package symbolic links + install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two/depth_three COMPONENT libraries) + install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two/different_relocatable/bar COMPONENT libraries) + install(DIRECTORY DESTINATION other_relocatable/depth_two COMPONENT libraries) + install(DIRECTORY DESTINATION non_relocatable/depth_two COMPONENT libraries) + # test symbolic links to same dir + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink depth_three symlink_samedir_path) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_samedir_path DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two COMPONENT libraries) + # test symbolic links to same dir with current dir ./ prefix + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ./depth_three symlink_samedir_path_current_dir) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_samedir_path_current_dir DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two COMPONENT libraries) + # test symbolic links to same dir with longer relative path + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../${CMAKE_INSTALL_LIBDIR}/.././${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/./depth_two/depth_three symlink_samedir_path_longer) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_samedir_path_longer DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two COMPONENT libraries) + # test symbolic links to sub dir + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../../${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two/depth_three symlink_subdir_path) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_subdir_path DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one COMPONENT libraries) + # test symbolic links to parent dir + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink .././../../../${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/./depth_two symlink_parentdir_path) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_parentdir_path DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two/depth_three COMPONENT libraries) + # test symbolic link to another relocatable path + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink .././.././../other_relocatable/./depth_two symlink_other_relocatable_path) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_other_relocatable_path DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two COMPONENT libraries) + # test symbolic link to non relocatable path + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink .././../../non_relocatable/./depth_two symlink_to_non_relocatable_path) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_to_non_relocatable_path DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two COMPONENT libraries) + # test symbolic link from non relocatable path + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink .././../${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two symlink_from_non_relocatable_path) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_from_non_relocatable_path DESTINATION non_relocatable/depth_two COMPONENT libraries) + # test symbolic link relocatable path to its relocatable subpath + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../../inside_relocatable_two/depth_two/different_relocatable/bar symlink_relocatable_subpath) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_relocatable_subpath DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two COMPONENT libraries) + # test symbolic link to location outside package + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ./outside_package symlink_outside_package) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_outside_package DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two COMPONENT libraries) +endif() + # CPack boilerplate for this project set(CPACK_PACKAGE_NAME "MyLib") set(CPACK_PACKAGE_CONTACT "None") @@ -114,7 +152,8 @@ set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full) # can not be used in CPack scripts due to CMAKE_SIZEOF_VOID_P # variable not being set set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}" - "${CMAKE_INSTALL_LIBDIR}" "${CMAKE_INSTALL_BINDIR}") + "${CMAKE_INSTALL_LIBDIR}" "${CMAKE_INSTALL_BINDIR}" "other_relocatable" + "${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two/different_relocatable") # We may use the CPack specific config file in order # to tailor CPack behavior on a CPack generator specific way diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in index e4780d3..ac9b552 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in @@ -22,12 +22,16 @@ if(CPACK_GENERATOR MATCHES "RPM") # test cross-built rpm set(CPACK_RPM_applications_PACKAGE_ARCHITECTURE "armv7hf") - # test package summary override + # test package summary override - headers rpm is generated in the middle set(CPACK_RPM_PACKAGE_SUMMARY "default summary") - set(CPACK_RPM_libraries_PACKAGE_SUMMARY "libraries summary") + set(CPACK_RPM_headers_PACKAGE_SUMMARY "headers summary") - # test package description override - set(CPACK_RPM_libraries_PACKAGE_DESCRIPTION "libraries description") + # test package description override - headers rpm is generated in the middle + set(CPACK_RPM_headers_PACKAGE_DESCRIPTION "headers description") + + # test package do not use CPACK_PACKAGING_INSTALL_PREFIX + # as relocation path + set(CPACK_RPM_NO_libraries_INSTALL_PREFIX_RELOCATION true) endif() if(CPACK_GENERATOR MATCHES "DEB") diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index 9261d11..e747052 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -1,3 +1,7 @@ +# prevent older policies from interfearing with this script +cmake_policy(PUSH) +cmake_policy(VERSION ${CMAKE_VERSION}) + message(STATUS "=============================================================================") message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") message(STATUS "") @@ -132,12 +136,13 @@ if(CPackGen MATCHES "RPM") endif() set(CPACK_RPM_PACKAGE_SUMMARY "default summary") - set(CPACK_RPM_libraries_PACKAGE_SUMMARY "libraries summary") - set(CPACK_RPM_libraries_PACKAGE_DESCRIPTION "libraries description") + set(CPACK_RPM_headers_PACKAGE_SUMMARY "headers summary") + set(CPACK_RPM_headers_PACKAGE_DESCRIPTION "headers description") set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "An extremely useful application that makes use of MyLib") - set(CPACK_COMPONENT_HEADERS_DESCRIPTION - "C/C\\+\\+ header files for use with MyLib") + set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION + "Static libraries used to build programs with MyLib") + set(LIB_SUFFIX "6?4?") # test package info if(${CPackComponentWay} STREQUAL "IgnoreGroup") @@ -172,15 +177,37 @@ if(CPackGen MATCHES "RPM") set(whitespaces "[\\t\\n\\r ]*") if(check_file_libraries_match) - set(check_file_match_expected_summary ".*${CPACK_RPM_libraries_PACKAGE_SUMMARY}.*") - set(check_file_match_expected_description ".*${CPACK_RPM_libraries_PACKAGE_DESCRIPTION}.*") - set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*") + set(check_file_match_expected_description ".*${CPACK_COMPONENT_LIBRARIES_DESCRIPTION}.*") + set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/other_relocatable${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}/inside_relocatable_two/depth_two/different_relocatable") set(check_file_match_expected_architecture "") # we don't explicitly set this value so it is different on each platform - ignore it set(spec_regex "*libraries*") - set(check_content_list "^/usr/foo/bar\n/usr/foo/bar/lib.*\n/usr/foo/bar/lib.*/libmylib.a$") + set(check_content_list "^/usr/foo/bar/lib${LIB_SUFFIX} +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/depth_three +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/depth_three/symlink_parentdir_path +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_outside_package +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_relocatable_subpath +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path_current_dir +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path_longer +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/symlink_subdir_path +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/different_relocatable +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/different_relocatable/bar +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/symlink_other_relocatable_path +/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/symlink_to_non_relocatable_path +/usr/foo/bar/lib${LIB_SUFFIX}/libmylib.a +/usr/foo/bar/non_relocatable +/usr/foo/bar/non_relocatable/depth_two +/usr/foo/bar/non_relocatable/depth_two/symlink_from_non_relocatable_path +/usr/foo/bar/other_relocatable +/usr/foo/bar/other_relocatable/depth_two$") elseif(check_file_headers_match) - set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*") - set(check_file_match_expected_description ".*${CPACK_COMPONENT_HEADERS_DESCRIPTION}.*") + set(check_file_match_expected_summary ".*${CPACK_RPM_headers_PACKAGE_SUMMARY}.*") + set(check_file_match_expected_description ".*${CPACK_RPM_headers_PACKAGE_DESCRIPTION}.*") set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") set(check_file_match_expected_architecture "noarch") set(spec_regex "*headers*") @@ -188,10 +215,12 @@ if(CPackGen MATCHES "RPM") elseif(check_file_applications_match) set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*") set(check_file_match_expected_description ".*${CPACK_COMPONENT_APPLICATIONS_DESCRIPTION}.*") - set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}.*") + set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") set(check_file_match_expected_architecture "armv7hf") set(spec_regex "*applications*") - set(check_content_list "^/usr/foo/bar\n/usr/foo/bar/bin\n/usr/foo/bar/bin/mylibapp$") + set(check_content_list "^/usr/foo/bar +/usr/foo/bar/bin +/usr/foo/bar/bin/mylibapp$") elseif(check_file_Unspecified_match) set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*") set(check_file_match_expected_description ".*DESCRIPTION.*") @@ -269,5 +298,59 @@ if(CPackGen MATCHES "RPM") message(FATAL_ERROR "error: '${check_file}' rpm package content does not match expected value - regex '${check_content_list}'; RPM output: '${check_package_content}'; generated spec file: '${spec_file_content}'") endif() endforeach() + + ####################### + # verify generated symbolic links + ####################### + file(GLOB_RECURSE symlink_files RELATIVE "${CPackComponentsForAll_BINARY_DIR}" "${CPackComponentsForAll_BINARY_DIR}/*/symlink_*") + + foreach(check_symlink IN LISTS symlink_files) + get_filename_component(symlink_name "${check_symlink}" NAME) + execute_process(COMMAND ls -la "${check_symlink}" + WORKING_DIRECTORY "${CPackComponentsForAll_BINARY_DIR}" + OUTPUT_VARIABLE SYMLINK_POINT_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if("${symlink_name}" STREQUAL "symlink_samedir_path" + OR "${symlink_name}" STREQUAL "symlink_samedir_path_current_dir" + OR "${symlink_name}" STREQUAL "symlink_samedir_path_longer") + string(REGEX MATCH "^.*${whitespaces}->${whitespaces}depth_three$" check_symlink "${SYMLINK_POINT_}") + elseif("${symlink_name}" STREQUAL "symlink_subdir_path") + string(REGEX MATCH "^.*${whitespaces}->${whitespaces}depth_two/depth_three$" check_symlink "${SYMLINK_POINT_}") + elseif("${symlink_name}" STREQUAL "symlink_parentdir_path") + string(REGEX MATCH "^.*${whitespaces}->${whitespaces}../$" check_symlink "${SYMLINK_POINT_}") + elseif("${symlink_name}" STREQUAL "symlink_to_non_relocatable_path") + string(REGEX MATCH "^.*${whitespaces}->${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/non_relocatable/depth_two$" check_symlink "${SYMLINK_POINT_}") + elseif("${symlink_name}" STREQUAL "symlink_outside_package") + string(REGEX MATCH "^.*${whitespaces}->${whitespaces}outside_package$" check_symlink "${SYMLINK_POINT_}") + elseif("${symlink_name}" STREQUAL "symlink_other_relocatable_path" + OR "${symlink_name}" STREQUAL "symlink_from_non_relocatable_path" + OR "${symlink_name}" STREQUAL "symlink_relocatable_subpath") + # these links were not canged - post install script only - ignore them + else() + message(FATAL_ERROR "error: unexpected rpm symbolic link '${check_symlink}'") + endif() + + if(NOT check_symlink) + message(FATAL_ERROR "symlink points to unexpected location '${SYMLINK_POINT_}'") + endif() + endforeach() + + # verify post install symlink relocation script + file(GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/*libraries*.spec") + file(READ ${spec_file} spec_file_content) + file(READ "${CMAKE_CURRENT_LIST_DIR}/symlink_postinstall_expected.txt" symlink_postinstall_expected) + # prepare regex + string(STRIP "${symlink_postinstall_expected}" symlink_postinstall_expected) + string(REPLACE "[" "\\[" symlink_postinstall_expected "${symlink_postinstall_expected}") + string(REPLACE "$" "\\$" symlink_postinstall_expected "${symlink_postinstall_expected}") + string(REPLACE "lib" "lib${LIB_SUFFIX}" symlink_postinstall_expected "${symlink_postinstall_expected}") + # compare + string(REGEX MATCH ".*${symlink_postinstall_expected}.*" symlink_postinstall_expected_matches "${spec_file_content}") + if(NOT symlink_postinstall_expected_matches) + message(FATAL_ERROR "error: unexpected rpm symbolic link postinstall script! generated spec file: '${spec_file_content}'") + endif() endif() endif() + +cmake_policy(POP) diff --git a/Tests/CPackComponentsForAll/symlink_postinstall_expected.txt b/Tests/CPackComponentsForAll/symlink_postinstall_expected.txt new file mode 100644 index 0000000..ba46792 --- /dev/null +++ b/Tests/CPackComponentsForAll/symlink_postinstall_expected.txt @@ -0,0 +1,57 @@ +if [ "$RPM_INSTALL_PREFIX0" != "/usr/foo/bar/lib" ]; then + if [ "$RPM_INSTALL_PREFIX1" != "/usr/foo/bar/other_relocatable" ]; then + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_1" ]; then + ln -s "$RPM_INSTALL_PREFIX1/depth_two" "$RPM_INSTALL_PREFIX0/inside_relocatable_two/depth_two/symlink_other_relocatable_path" + CPACK_RPM_RELOCATED_SYMLINK_1=true + fi + fi + if [ "$RPM_INSTALL_PREFIX2" != "/usr/foo/bar/lib/inside_relocatable_two/depth_two/different_relocatable" ]; then + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_0" ]; then + ln -s "$RPM_INSTALL_PREFIX2/bar" "$RPM_INSTALL_PREFIX0/inside_relocatable_one/depth_two/symlink_relocatable_subpath" + CPACK_RPM_RELOCATED_SYMLINK_0=true + fi + fi + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_0" ]; then + ln -s "$RPM_INSTALL_PREFIX0/inside_relocatable_two/depth_two/different_relocatable/bar" "$RPM_INSTALL_PREFIX0/inside_relocatable_one/depth_two/symlink_relocatable_subpath" + CPACK_RPM_RELOCATED_SYMLINK_0=true + fi + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_0" ]; then + ln -s "/usr/foo/bar/lib/inside_relocatable_two/depth_two/different_relocatable/bar" "$RPM_INSTALL_PREFIX0/inside_relocatable_one/depth_two/symlink_relocatable_subpath" + CPACK_RPM_RELOCATED_SYMLINK_0=true + fi + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_1" ]; then + ln -s "/usr/foo/bar/other_relocatable/depth_two" "$RPM_INSTALL_PREFIX0/inside_relocatable_two/depth_two/symlink_other_relocatable_path" + CPACK_RPM_RELOCATED_SYMLINK_1=true + fi +fi +if [ "$RPM_INSTALL_PREFIX1" != "/usr/foo/bar/other_relocatable" ]; then + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_1" ]; then + ln -s "$RPM_INSTALL_PREFIX1/depth_two" "/usr/foo/bar/lib/inside_relocatable_two/depth_two/symlink_other_relocatable_path" + CPACK_RPM_RELOCATED_SYMLINK_1=true + fi +fi +if [ "$RPM_INSTALL_PREFIX2" != "/usr/foo/bar/lib/inside_relocatable_two/depth_two/different_relocatable" ]; then + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_0" ]; then + ln -s "$RPM_INSTALL_PREFIX2/bar" "/usr/foo/bar/lib/inside_relocatable_one/depth_two/symlink_relocatable_subpath" + CPACK_RPM_RELOCATED_SYMLINK_0=true + fi +fi +if [ "$RPM_INSTALL_PREFIX0" != "/usr/foo/bar/lib" ]; then + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_0" ]; then + ln -s "$RPM_INSTALL_PREFIX0/inside_relocatable_two/depth_two/different_relocatable/bar" "/usr/foo/bar/lib/inside_relocatable_one/depth_two/symlink_relocatable_subpath" + CPACK_RPM_RELOCATED_SYMLINK_0=true + fi + if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_2" ]; then + ln -s "$RPM_INSTALL_PREFIX0/inside_relocatable_two/depth_two" "/usr/foo/bar/non_relocatable/depth_two/symlink_from_non_relocatable_path" + CPACK_RPM_RELOCATED_SYMLINK_2=true + fi +fi +if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_0" ]; then + ln -s "/usr/foo/bar/lib/inside_relocatable_two/depth_two/different_relocatable/bar" "/usr/foo/bar/lib/inside_relocatable_one/depth_two/symlink_relocatable_subpath" +fi +if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_1" ]; then + ln -s "/usr/foo/bar/other_relocatable/depth_two" "/usr/foo/bar/lib/inside_relocatable_two/depth_two/symlink_other_relocatable_path" +fi +if [ -z "$CPACK_RPM_RELOCATED_SYMLINK_2" ]; then + ln -s "/usr/foo/bar/lib/inside_relocatable_two/depth_two" "/usr/foo/bar/non_relocatable/depth_two/symlink_from_non_relocatable_path" +fi diff --git a/Tests/CPackComponentsPrefix/CMakeLists.txt b/Tests/CPackComponentsPrefix/CMakeLists.txt new file mode 100644 index 0000000..207dae8 --- /dev/null +++ b/Tests/CPackComponentsPrefix/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.2) +project(CPackComponentsPrefix NONE) + +install(FILES file-runtime.txt + DESTINATION bin COMPONENT Runtime) +install(FILES file-development.txt + DESTINATION lib COMPONENT Development) + +set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 1) +set(CPACK_COMPONENTS_ALL Development) +set(CPACK_ARCHIVE_COMPONENT_INSTALL 1) +set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/My-1.0") +include(CPack) diff --git a/Tests/CPackComponentsPrefix/file-development.txt b/Tests/CPackComponentsPrefix/file-development.txt new file mode 100644 index 0000000..df22d2f --- /dev/null +++ b/Tests/CPackComponentsPrefix/file-development.txt @@ -0,0 +1 @@ +This file is installed with the Development component. diff --git a/Tests/CPackComponentsPrefix/file-runtime.txt b/Tests/CPackComponentsPrefix/file-runtime.txt new file mode 100644 index 0000000..135c13d --- /dev/null +++ b/Tests/CPackComponentsPrefix/file-runtime.txt @@ -0,0 +1 @@ +This file is installed with the Runtime component. diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp new file mode 100644 index 0000000..85e6cd8 --- /dev/null +++ b/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp @@ -0,0 +1 @@ +void foo() {} diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt b/Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt new file mode 100644 index 0000000..ce6fac4 --- /dev/null +++ b/Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.2) + +project(TestProject CXX) + +include(CTest) + +set(SOURCES + main.cpp + 3rdparty/foo.cpp + extra/extra.cpp +) + +add_executable(myexecutable ${SOURCES}) + +set_property(SOURCE main.cpp APPEND PROPERTY LABELS SourceLabel) +set_property(TARGET myexecutable APPEND PROPERTY LABELS TargetLabel) + +set(MYEXECUTABLE_INFO_FILE "${CMAKE_CURRENT_BINARY_DIR}/myexecutable_info.cmake") + +file(WRITE "${MYEXECUTABLE_INFO_FILE}" " + set(TARGET myexecutable) + set(SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\") + set(SOURCES \"${SOURCES}\") +") + +add_custom_command(TARGET myexecutable + POST_BUILD + COMMAND ${CMAKE_COMMAND} + "-DINFO_FILE=${MYEXECUTABLE_INFO_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/fake_compile_time_gcno.cmake" + VERBATIM +) + +add_test(NAME mytest + COMMAND ${CMAKE_COMMAND} + "-DMYEXECUTABLE=$<TARGET_FILE:myexecutable>" + "-DTARGETDIR=${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/myexecutable.dir" + -P "${CMAKE_CURRENT_SOURCE_DIR}/fake_run_time_gcda.cmake" +) + +set_property(TEST mytest APPEND PROPERTY LABELS TestLabel) diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp new file mode 100644 index 0000000..c3a2c12 --- /dev/null +++ b/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp @@ -0,0 +1 @@ +void extra() {} diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/fake_compile_time_gcno.cmake b/Tests/CTestCoverageCollectGCOV/TestProject/fake_compile_time_gcno.cmake new file mode 100644 index 0000000..881460b --- /dev/null +++ b/Tests/CTestCoverageCollectGCOV/TestProject/fake_compile_time_gcno.cmake @@ -0,0 +1,7 @@ +include("${INFO_FILE}") + +foreach(source ${SOURCES}) + file(WRITE "CMakeFiles/${TARGET}.dir/${source}.gcno" + "${SOURCE_DIR}/${source}" + ) +endforeach() diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/fake_run_time_gcda.cmake b/Tests/CTestCoverageCollectGCOV/TestProject/fake_run_time_gcda.cmake new file mode 100644 index 0000000..26ce2bd --- /dev/null +++ b/Tests/CTestCoverageCollectGCOV/TestProject/fake_run_time_gcda.cmake @@ -0,0 +1,12 @@ +execute_process(COMMAND ${MYEXECUTABLE} RESULT_VARIABLE RESULT) + +if(NOT RESULT_VARIABLE STREQUAL "0") + message("Test failure") +endif() + +file(GLOB_RECURSE gcno_files "${TARGETDIR}/*.gcno") + +foreach(gcno_file ${gcno_files}) + string(REPLACE ".gcno" ".gcda" gcda_file "${gcno_file}") + configure_file(${gcno_file} ${gcda_file} COPYONLY) +endforeach() diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp new file mode 100644 index 0000000..237c8ce --- /dev/null +++ b/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake index e704f14..b0c3a9b 100644 --- a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake +++ b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake @@ -3,6 +3,12 @@ foreach(I RANGE 0 ${CMAKE_ARGC}) set(gcda_file "${CMAKE_ARGV${I}}") endif() endforeach() -get_filename_component(gcda_file ${gcda_file} NAME_WE) -file(WRITE "${CMAKE_SOURCE_DIR}/${gcda_file}.gcov" -"fake gcov file") + +get_filename_component(gcda_name ${gcda_file} NAME) +string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}") + +file(STRINGS "${gcda_file}" source_file LIMIT_COUNT 1 ENCODING UTF-8) + +file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}" + " -: 0:Source:${source_file}" +) diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in index 4bdcb10..29f7e7f 100644 --- a/Tests/CTestCoverageCollectGCOV/test.cmake.in +++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in @@ -1,16 +1,21 @@ cmake_minimum_required(VERSION 2.8.12) -set(CTEST_PROJECT_NAME "SmallAndFast") -set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTest/SmallAndFast") -set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestCoverageCollectGCOV") +set(CTEST_PROJECT_NAME "TestProject") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/TestProject") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestCoverageCollectGCOV/TestProject") set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") + +ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) + ctest_start(Experimental) ctest_configure() ctest_build() ctest_test() -file(WRITE ${CTEST_BINARY_DIRECTORY}/CMakeFiles/echoargs.dir/echoargs.gcda -"dummy -") +list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE + "/foo/something" + "/3rdparty/" + "/bar/somethingelse" +) include(CTestCoverageCollectGCOV) set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tar) @@ -22,15 +27,21 @@ ctest_coverage_collect_gcov( GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake") execute_process(COMMAND - ${CMAKE_COMMAND} -E tar tf ${tar_file} - OUTPUT_VARIABLE out - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) + ${CMAKE_COMMAND} -E tar tf ${tar_file} + OUTPUT_VARIABLE out + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +string(REPLACE "\n" ";" out "${out}") +list(SORT out) set(expected_out -"Testing/CoverageInfo/echoargs.gcov -Testing/CoverageInfo/data.json -CMakeFiles/echoargs.dir/Labels.json -") + CMakeFiles/myexecutable.dir/Labels.json + Testing/CoverageInfo/data.json + Testing/CoverageInfo/extra.cpp.gcov + Testing/CoverageInfo/main.cpp.gcov +) if("${out}" STREQUAL "${expected_out}") message("PASSED with correct output: ${out}") diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp index 7bf356b..ad05f12 100644 --- a/Tests/CompileFeatures/cxx_generalized_initializers.cpp +++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp @@ -1,3 +1,6 @@ +#if defined(_MSC_VER) && _MSC_VER == 1800 && _MSC_FULL_VER < 180030723 +# error "VS 2013 safely supports this only with Update 3 or greater" +#endif // Dummy implementation. Test only the compiler feature. namespace std { @@ -7,8 +10,9 @@ namespace std { { const _E* __begin_; size_t __size_; - - initializer_list(const int*, long unsigned int) {} + public: + template <typename T1, typename T2> + initializer_list(T1, T2) {} }; } diff --git a/Tests/InterfaceLibrary/headerdir/CMakeLists.txt b/Tests/InterfaceLibrary/headerdir/CMakeLists.txt index 98f521e..826a9ed 100644 --- a/Tests/InterfaceLibrary/headerdir/CMakeLists.txt +++ b/Tests/InterfaceLibrary/headerdir/CMakeLists.txt @@ -3,6 +3,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) add_library(headeriface INTERFACE) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/iface_header_builddir.h" - "#define IFACE_HEADER_BUILDDIR\n" -) +add_custom_target(headeriface_gen + COMMENT "Generating iface_header_builddir.h" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/iface_header_builddir.h.in + ${CMAKE_CURRENT_BINARY_DIR}/iface_header_builddir.h + VERBATIM + ) +add_dependencies(headeriface headeriface_gen) diff --git a/Tests/InterfaceLibrary/headerdir/iface_header_builddir.h.in b/Tests/InterfaceLibrary/headerdir/iface_header_builddir.h.in new file mode 100644 index 0000000..42dd6df --- /dev/null +++ b/Tests/InterfaceLibrary/headerdir/iface_header_builddir.h.in @@ -0,0 +1 @@ +#define IFACE_HEADER_BUILDDIR diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index 6c5e59c..b6e24d2 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -44,6 +44,7 @@ ExternalData_Add_Test(Data1 -D Paired=DATA{PairedA.dat,PairedB.dat} -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat} -D Directory=DATA{Directory/,A.dat,REGEX:[BC].dat} + -D DirRecurse=DATA{DirRecurse/,RECURSE:,A.dat,REGEX:[BC].dat} -D "Semicolons=DATA{Data.dat}\\;DATA{Data.dat}" -P ${CMAKE_CURRENT_SOURCE_DIR}/Data1Check.cmake ) diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake index 9845a3b..f60c209 100644 --- a/Tests/Module/ExternalData/Data1Check.cmake +++ b/Tests/Module/ExternalData/Data1Check.cmake @@ -90,6 +90,12 @@ foreach(n A B C) message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") endif() endforeach() +foreach(n A Sub1/A Sub2/Dir/A B Sub1/B Sub2/Dir/B C Sub1/C Sub2/Dir/C) + set(file "${DirRecurse}/${n}.dat") + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() +endforeach() list(LENGTH Semicolons len) if("${len}" EQUAL 2) foreach(file ${Semicolons}) diff --git a/Tests/Module/ExternalData/DirRecurse/A.dat.md5 b/Tests/Module/ExternalData/DirRecurse/A.dat.md5 new file mode 100644 index 0000000..4a78fc7 --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/A.dat.md5 @@ -0,0 +1 @@ +9d980b06c2f0fec3d4872d68175b9822 diff --git a/Tests/Module/ExternalData/DirRecurse/B.dat.md5 b/Tests/Module/ExternalData/DirRecurse/B.dat.md5 new file mode 100644 index 0000000..4557a21 --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/B.dat.md5 @@ -0,0 +1 @@ +8f4add4581551facf27237e6577fd662 diff --git a/Tests/Module/ExternalData/DirRecurse/C.dat.md5 b/Tests/Module/ExternalData/DirRecurse/C.dat.md5 new file mode 100644 index 0000000..a7f23dd --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/C.dat.md5 @@ -0,0 +1 @@ +c1030719c95f3435d8abc39c0d442946 diff --git a/Tests/Module/ExternalData/DirRecurse/Sub1/A.dat.md5 b/Tests/Module/ExternalData/DirRecurse/Sub1/A.dat.md5 new file mode 100644 index 0000000..4a78fc7 --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/Sub1/A.dat.md5 @@ -0,0 +1 @@ +9d980b06c2f0fec3d4872d68175b9822 diff --git a/Tests/Module/ExternalData/DirRecurse/Sub1/B.dat.md5 b/Tests/Module/ExternalData/DirRecurse/Sub1/B.dat.md5 new file mode 100644 index 0000000..4557a21 --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/Sub1/B.dat.md5 @@ -0,0 +1 @@ +8f4add4581551facf27237e6577fd662 diff --git a/Tests/Module/ExternalData/DirRecurse/Sub1/C.dat.md5 b/Tests/Module/ExternalData/DirRecurse/Sub1/C.dat.md5 new file mode 100644 index 0000000..a7f23dd --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/Sub1/C.dat.md5 @@ -0,0 +1 @@ +c1030719c95f3435d8abc39c0d442946 diff --git a/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/A.dat.md5 b/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/A.dat.md5 new file mode 100644 index 0000000..4a78fc7 --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/A.dat.md5 @@ -0,0 +1 @@ +9d980b06c2f0fec3d4872d68175b9822 diff --git a/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/B.dat.md5 b/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/B.dat.md5 new file mode 100644 index 0000000..4557a21 --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/B.dat.md5 @@ -0,0 +1 @@ +8f4add4581551facf27237e6577fd662 diff --git a/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/C.dat.md5 b/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/C.dat.md5 new file mode 100644 index 0000000..a7f23dd --- /dev/null +++ b/Tests/Module/ExternalData/DirRecurse/Sub2/Dir/C.dat.md5 @@ -0,0 +1 @@ +c1030719c95f3435d8abc39c0d442946 diff --git a/Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt b/Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-NEW-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0059/CMP0059-NEW-stderr.txt b/Tests/RunCMake/CMP0059/CMP0059-NEW-stderr.txt new file mode 100644 index 0000000..76992d8 --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-NEW-stderr.txt @@ -0,0 +1,2 @@ +DEFS: +CUSTOM CONTENT:CUSTOM_CONTENT diff --git a/Tests/RunCMake/CMP0059/CMP0059-NEW.cmake b/Tests/RunCMake/CMP0059/CMP0059-NEW.cmake new file mode 100644 index 0000000..f7b9303 --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-NEW.cmake @@ -0,0 +1,17 @@ + +cmake_policy(SET CMP0059 NEW) + +add_definitions(-DSOME_DEF) + +get_property(defs DIRECTORY . + PROPERTY DEFINITIONS +) +message("DEFS:${defs}") + +set_property(DIRECTORY . + PROPERTY DEFINITIONS CUSTOM_CONTENT +) +get_property(content DIRECTORY . + PROPERTY DEFINITIONS +) +message("CUSTOM CONTENT:${content}") diff --git a/Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt b/Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt b/Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt new file mode 100644 index 0000000..e35e8c5 --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-OLD-stderr.txt @@ -0,0 +1,2 @@ +DEFS: -DSOME_DEF +CUSTOM CONTENT: -DSOME_DEF diff --git a/Tests/RunCMake/CMP0059/CMP0059-OLD.cmake b/Tests/RunCMake/CMP0059/CMP0059-OLD.cmake new file mode 100644 index 0000000..2555774 --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-OLD.cmake @@ -0,0 +1,17 @@ + +cmake_policy(SET CMP0059 OLD) + +add_definitions(-DSOME_DEF) + +get_property(defs DIRECTORY . + PROPERTY DEFINITIONS +) +message("DEFS:${defs}") + +set_property(DIRECTORY . + PROPERTY DEFINITIONS CUSTOM_CONTENT +) +get_property(content DIRECTORY . + PROPERTY DEFINITIONS +) +message("CUSTOM CONTENT:${content}") diff --git a/Tests/RunCMake/CMP0059/CMP0059-WARN-result.txt b/Tests/RunCMake/CMP0059/CMP0059-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt b/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt new file mode 100644 index 0000000..4e04d15 --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt @@ -0,0 +1,18 @@ +CMake Warning \(dev\) at CMP0059-WARN.cmake:6 \(get_property\): + Policy CMP0059 is not set: Do no treat DEFINITIONS as a built-in directory + property. Run "cmake --help-policy CMP0059" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +DEFS: -DSOME_DEF +CMake Warning \(dev\) at CMP0059-WARN.cmake:14 \(get_property\): + Policy CMP0059 is not set: Do no treat DEFINITIONS as a built-in directory + property. Run "cmake --help-policy CMP0059" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CUSTOM CONTENT: -DSOME_DEF diff --git a/Tests/RunCMake/CMP0059/CMP0059-WARN.cmake b/Tests/RunCMake/CMP0059/CMP0059-WARN.cmake new file mode 100644 index 0000000..9d0b49c --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMP0059-WARN.cmake @@ -0,0 +1,17 @@ + + + +add_definitions(-DSOME_DEF) + +get_property(defs DIRECTORY . + PROPERTY DEFINITIONS +) +message("DEFS:${defs}") + +set_property(DIRECTORY . + PROPERTY DEFINITIONS CUSTOM_CONTENT +) +get_property(content DIRECTORY . + PROPERTY DEFINITIONS +) +message("CUSTOM CONTENT:${content}") diff --git a/Tests/RunCMake/CMP0059/CMakeLists.txt b/Tests/RunCMake/CMP0059/CMakeLists.txt new file mode 100644 index 0000000..ef2163c --- /dev/null +++ b/Tests/RunCMake/CMP0059/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0059/RunCMakeTest.cmake b/Tests/RunCMake/CMP0059/RunCMakeTest.cmake new file mode 100644 index 0000000..9b57579 --- /dev/null +++ b/Tests/RunCMake/CMP0059/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0059-OLD) +run_cmake(CMP0059-NEW) +run_cmake(CMP0059-WARN) diff --git a/Tests/RunCMake/CMP0060/CMP0060-Common.cmake b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake new file mode 100644 index 0000000..e0a56e6 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake @@ -0,0 +1,35 @@ +# Always build in a predictable configuration. For multi-config +# generators we depend on RunCMakeTest.cmake to do this for us. +if(NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Debug) +endif() + +# Convince CMake that it can instruct the linker to search for the +# library of the proper linkage type, but do not really pass flags. +set(CMAKE_EXE_LINK_STATIC_C_FLAGS " ") +set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS " ") + +# Make a link line asking for the linker to search for the library +# look like a missing object file so we will get predictable content +# in the error message. This also ensures that cases expected to use +# the full path can be verified by confirming that they link. +set(CMAKE_LINK_LIBRARY_FLAG LINKFLAG_) +set(CMAKE_LINK_LIBRARY_SUFFIX _LINKSUFFIX${CMAKE_C_OUTPUT_EXTENSION}) + +# Convince CMake that our library is in an implicit linker search directory. +list(APPEND CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/lib) + +# Create a simple library file. Place it in our library directory. +add_library(CMP0060 STATIC cmp0060.c) +set_property(TARGET CMP0060 PROPERTY + ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/lib) + +# Add a target to link the library file by full path. +add_executable(main1 main.c) +target_link_libraries(main1 $<TARGET_FILE:CMP0060>) +add_dependencies(main1 CMP0060) + +# Add a second target to verify the warning only appears once. +add_executable(main2 main.c) +target_link_libraries(main2 $<TARGET_FILE:CMP0060>) +add_dependencies(main2 CMP0060) diff --git a/Tests/RunCMake/CMP0060/CMP0060-NEW.cmake b/Tests/RunCMake/CMP0060/CMP0060-NEW.cmake new file mode 100644 index 0000000..0414e4b --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0060 NEW) +include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-result.txt b/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-stdout.txt b/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-stdout.txt new file mode 100644 index 0000000..240764c --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-OLD-Build-stdout.txt @@ -0,0 +1 @@ +LINKFLAG_CMP0060_LINKSUFFIX diff --git a/Tests/RunCMake/CMP0060/CMP0060-OLD.cmake b/Tests/RunCMake/CMP0060/CMP0060-OLD.cmake new file mode 100644 index 0000000..a9cffef --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0060 OLD) +include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-result.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-stdout.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-stdout.txt new file mode 100644 index 0000000..240764c --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF-Build-stdout.txt @@ -0,0 +1 @@ +LINKFLAG_CMP0060_LINKSUFFIX diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake new file mode 100644 index 0000000..6b84565 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-OFF.cmake @@ -0,0 +1 @@ +include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-result.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-stdout.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-stdout.txt new file mode 100644 index 0000000..240764c --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-Build-stdout.txt @@ -0,0 +1 @@ +LINKFLAG_CMP0060_LINKSUFFIX diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt new file mode 100644 index 0000000..f6cc978 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt @@ -0,0 +1,16 @@ +^CMake Warning \(dev\) at CMP0060-Common.cmake:[0-9]+ \(add_executable\): + Policy CMP0060 is not set: Link libraries by full path even in implicit + directories. Run "cmake --help-policy CMP0060" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. + + Some library files are in directories implicitly searched by the linker + when invoked for C: + + .*/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-build/lib/(lib)?CMP0060.(a|lib) + + For compatibility with older versions of CMake, the generated link line + will ask the linker to search for these by library name. +Call Stack \(most recent call first\): + CMP0060-WARN-ON.cmake:[0-9]+ \(include\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake new file mode 100644 index 0000000..a0a7950 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON.cmake @@ -0,0 +1,2 @@ +set(CMAKE_POLICY_WARNING_CMP0060 1) +include(CMP0060-Common.cmake) diff --git a/Tests/RunCMake/CMP0060/CMakeLists.txt b/Tests/RunCMake/CMP0060/CMakeLists.txt new file mode 100644 index 0000000..db6b701 --- /dev/null +++ b/Tests/RunCMake/CMP0060/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} C) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0060/RunCMakeTest.cmake b/Tests/RunCMake/CMP0060/RunCMakeTest.cmake new file mode 100644 index 0000000..445156f --- /dev/null +++ b/Tests/RunCMake/CMP0060/RunCMakeTest.cmake @@ -0,0 +1,19 @@ +include(RunCMake) + +function(run_cmake_CMP0060 CASE) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0060-${CASE}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(CMP0060-${CASE}) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(CMP0060-${CASE}-Build + ${CMAKE_COMMAND} --build . --config Debug + ) +endfunction() + +run_cmake_CMP0060(OLD) +run_cmake_CMP0060(WARN-OFF) +run_cmake_CMP0060(WARN-ON) +run_cmake_CMP0060(NEW) diff --git a/Tests/RunCMake/CMP0060/cmp0060.c b/Tests/RunCMake/CMP0060/cmp0060.c new file mode 100644 index 0000000..a2da227 --- /dev/null +++ b/Tests/RunCMake/CMP0060/cmp0060.c @@ -0,0 +1,4 @@ +int libCMP0060(void) +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0060/main.c b/Tests/RunCMake/CMP0060/main.c new file mode 100644 index 0000000..91848c2 --- /dev/null +++ b/Tests/RunCMake/CMP0060/main.c @@ -0,0 +1,5 @@ +extern int libCMP0060(void); +int main(void) +{ + return libCMP0060(); +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 7cbc9fe..3709913 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -64,6 +64,11 @@ add_RunCMake_test(CMP0053) add_RunCMake_test(CMP0054) add_RunCMake_test(CMP0055) add_RunCMake_test(CMP0057) +add_RunCMake_test(CMP0059) +add_RunCMake_test(CMP0060) +if(CMAKE_GENERATOR STREQUAL "Ninja") + add_RunCMake_test(Ninja) +endif() add_RunCMake_test(CTest) if(NOT CMake_TEST_EXTERNAL_CMAKE) @@ -199,6 +204,12 @@ add_RunCMake_test(CommandLine) add_RunCMake_test(install) add_RunCMake_test(CPackInstallProperties) add_RunCMake_test(ExternalProject) +add_RunCMake_test(CTestCommandLine) +# Only run this test on unix platforms that support +# symbolic links +if(UNIX) + add_RunCMake_test(CPackSymlinks) +endif() set(IfacePaths_INCLUDE_DIRECTORIES_ARGS -DTEST_PROP=INCLUDE_DIRECTORIES) add_RunCMake_test(IfacePaths_INCLUDE_DIRECTORIES TEST_DIR IfacePaths) @@ -216,3 +227,7 @@ add_RunCMake_test(COMPILE_LANGUAGE-genex) if(CMake_TEST_FindMatlab) add_RunCMake_test(FindMatlab) endif() + +add_executable(pseudo_emulator pseudo_emulator.c) +add_RunCMake_test(CrosscompilingEmulator + -DPSEUDO_EMULATOR=$<TARGET_FILE:pseudo_emulator>) diff --git a/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake b/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake index 3ace6a8..31e729b 100644 --- a/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake +++ b/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake @@ -1,5 +1,4 @@ install(FILES CMakeLists.txt DESTINATION /not_relocatable COMPONENT static) -install(FILES CMakeLists.txt DESTINATION relocatable COMPONENT relocatable) set(CPACK_PACKAGE_RELOCATABLE TRUE) set(CPACK_PACKAGING_INSTALL_PREFIX "/opt") diff --git a/Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake b/Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake new file mode 100644 index 0000000..439d95e --- /dev/null +++ b/Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake @@ -0,0 +1,20 @@ +include(RunCMake) + +function(run_cpack_symlink_test) + set(RunCMake_TEST_NO_CLEAN TRUE) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/SrcSymlinks-build") + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/SrcSymlinks") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}") + run_cmake_command(SrcSymlinksTar + ${CMAKE_COMMAND} -E chdir ${RunCMake_TEST_SOURCE_DIR} + ${CMAKE_COMMAND} -E tar xvf ${RunCMake_SOURCE_DIR}/testcpacksym.tar + ) + run_cmake(SrcSymlinksCMake) + run_cmake_command(SrcSymlinksCPack + ${CMAKE_CPACK_COMMAND} --config CPackSourceConfig.cmake + ) +endfunction() + +run_cpack_symlink_test() diff --git a/Tests/RunCMake/CPackSymlinks/SrcSymlinksTar-stdout.txt b/Tests/RunCMake/CPackSymlinks/SrcSymlinksTar-stdout.txt new file mode 100644 index 0000000..24ad124 --- /dev/null +++ b/Tests/RunCMake/CPackSymlinks/SrcSymlinksTar-stdout.txt @@ -0,0 +1,10 @@ +^x CMakeLists.txt +x cygwin/ +x cygwin/build.sh +x cygwin/setup.patch +x include/ +x include/src.h +x link.h +x real.h +x src/ +x src/src.h$ diff --git a/Tests/RunCMake/CPackSymlinks/testcpacksym.tar b/Tests/RunCMake/CPackSymlinks/testcpacksym.tar Binary files differnew file mode 100644 index 0000000..a44c656 --- /dev/null +++ b/Tests/RunCMake/CPackSymlinks/testcpacksym.tar diff --git a/Tests/RunCMake/CTestCommandLine/CMakeLists.txt b/Tests/RunCMake/CTestCommandLine/CMakeLists.txt new file mode 100644 index 0000000..2897109 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake new file mode 100644 index 0000000..2e5156c --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -0,0 +1,25 @@ +include(RunCMake) + +run_cmake_command(repeat-until-fail-bad1 + ${CMAKE_CTEST_COMMAND} --repeat-until-fail + ) +run_cmake_command(repeat-until-fail-bad2 + ${CMAKE_CTEST_COMMAND} --repeat-until-fail foo + ) +run_cmake_command(repeat-until-fail-good + ${CMAKE_CTEST_COMMAND} --repeat-until-fail 2 + ) + +function(run_repeat_until_fail_tests) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/repeat-until-fail-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(repeat-until-fail-cmake) + run_cmake_command(repeat-until-fail-ctest + ${CMAKE_CTEST_COMMAND} -C Debug --repeat-until-fail 3 + ) +endfunction() +run_repeat_until_fail_tests() diff --git a/Tests/RunCMake/CTestCommandLine/init.cmake b/Tests/RunCMake/CTestCommandLine/init.cmake new file mode 100644 index 0000000..a900f67 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/init.cmake @@ -0,0 +1,3 @@ +# This is run by test initialization in repeat-until-fail-cmake.cmake +# with cmake -P. It creates TEST_OUTPUT_FILE with a 0 in it. +file(WRITE "${TEST_OUTPUT_FILE}" "0") diff --git a/Tests/RunCMake/interface_library/add_dependencies-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad1-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/interface_library/add_dependencies-result.txt +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad1-result.txt diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad1-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad1-stderr.txt new file mode 100644 index 0000000..5ea8816 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad1-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--repeat-until-fail' requires an argument$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad2-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad2-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad2-stderr.txt new file mode 100644 index 0000000..a79faae --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-bad2-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--repeat-until-fail' given non-integer value 'foo'$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-cmake.cmake b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-cmake.cmake new file mode 100644 index 0000000..4654416 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-cmake.cmake @@ -0,0 +1,15 @@ +enable_testing() + +set(TEST_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_output.txt") +add_test(NAME initialization + COMMAND ${CMAKE_COMMAND} + "-DTEST_OUTPUT_FILE=${TEST_OUTPUT_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/init.cmake") +add_test(NAME test1 + COMMAND ${CMAKE_COMMAND} + "-DTEST_OUTPUT_FILE=${TEST_OUTPUT_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/test1.cmake") +set_tests_properties(test1 PROPERTIES DEPENDS "initialization") + +add_test(hello ${CMAKE_COMMAND} -E echo hello) +add_test(goodbye ${CMAKE_COMMAND} -E echo goodbye) diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-stderr.txt new file mode 100644 index 0000000..7593783 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-stderr.txt @@ -0,0 +1 @@ +^Errors while running CTest$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-stdout.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-stdout.txt new file mode 100644 index 0000000..6e133cd --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-stdout.txt @@ -0,0 +1,30 @@ +^Test project .*/Tests/RunCMake/CTestCommandLine/repeat-until-fail-build + Start 1: initialization + Test #1: initialization ................... Passed +[0-9.]+ sec + Start 1: initialization + Test #1: initialization ................... Passed +[0-9.]+ sec + Start 1: initialization +1/4 Test #1: initialization ................... Passed +[0-9.]+ sec + Start 2: test1 + Test #2: test1 ............................ Passed +[0-9.]+ sec + Start 2: test1 + Test #2: test1 ............................\*\*\*Failed +[0-9.]+ sec + Start 3: hello + Test #3: hello ............................ Passed +[0-9.]+ sec + Start 3: hello + Test #3: hello ............................ Passed +[0-9.]+ sec + Start 3: hello +3/4 Test #3: hello ............................ Passed +[0-9.]+ sec + Start 4: goodbye + Test #4: goodbye .......................... Passed +[0-9.]+ sec + Start 4: goodbye + Test #4: goodbye .......................... Passed +[0-9.]+ sec + Start 4: goodbye +4/4 Test #4: goodbye .......................... Passed +[0-9.]+ sec ++ +75% tests passed, 1 tests failed out of 4 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[ ]+2 - test1 \(Failed\)$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-good-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-good-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-good-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/test1.cmake b/Tests/RunCMake/CTestCommandLine/test1.cmake new file mode 100644 index 0000000..eeae7a2 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/test1.cmake @@ -0,0 +1,13 @@ +# This is run by test test1 in repeat-until-fail-cmake.cmake with cmake -P. +# It reads the file TEST_OUTPUT_FILE and increments the number +# found in the file by 1. When the number is 2, then the +# code sends out a cmake error causing the test to fail +# the second time it is run. +message("TEST_OUTPUT_FILE = ${TEST_OUTPUT_FILE}") +file(READ "${TEST_OUTPUT_FILE}" COUNT) +message("COUNT= ${COUNT}") +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${TEST_OUTPUT_FILE}" "${COUNT}") +if(${COUNT} EQUAL 2) + message(FATAL_ERROR "this test fails on the 2nd run") +endif() diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index a9c49e7..e8b4584 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -80,3 +80,29 @@ run_cmake(D_nested_cache) set(RunCMake_TEST_OPTIONS "-DFOO:STRING=-DBAR:BOOL=BAZ") run_cmake(D_typed_nested_cache) + +function(run_cmake_depends) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_SOURCE_DIR}/cmake_depends") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/cmake_depends-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/DepTarget.dir/DependInfo.cmake" " +set(CMAKE_DEPENDS_LANGUAGES \"C\") +set(CMAKE_DEPENDS_CHECK_C + \"${RunCMake_TEST_SOURCE_DIR}/test.c\" + \"${RunCMake_TEST_BINARY_DIR}/CMakeFiles/DepTarget.dir/test.c.o\" + ) +") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/CMakeDirectoryInformation.cmake" " +set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"${RunCMake_TEST_SOURCE_DIR}\") +set(CMAKE_RELATIVE_PATH_TOP_BINARY \"${RunCMake_TEST_BINARY_DIR}\") +") + run_cmake_command(cmake_depends ${CMAKE_COMMAND} -E cmake_depends + "Unix Makefiles" + ${RunCMake_TEST_SOURCE_DIR} ${RunCMake_TEST_SOURCE_DIR} + ${RunCMake_TEST_BINARY_DIR} ${RunCMake_TEST_BINARY_DIR} + ${RunCMake_TEST_BINARY_DIR}/CMakeFiles/DepTarget.dir/DependInfo.cmake + ) +endfunction() +run_cmake_depends() diff --git a/Tests/RunCMake/CommandLine/cmake_depends-check.cmake b/Tests/RunCMake/CommandLine/cmake_depends-check.cmake new file mode 100644 index 0000000..031478b --- /dev/null +++ b/Tests/RunCMake/CommandLine/cmake_depends-check.cmake @@ -0,0 +1,13 @@ +set(depend_make "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/DepTarget.dir/depend.make") +if(EXISTS "${depend_make}") + file(READ "${depend_make}" depend_make_content) + string(REGEX REPLACE "\n+$" "" depend_make_content "${depend_make_content}") + if(NOT depend_make_content MATCHES " +CMakeFiles/DepTarget.dir/test.c.o: .*/Tests/RunCMake/CommandLine/cmake_depends/test.c +CMakeFiles/DepTarget.dir/test.c.o: .*/Tests/RunCMake/CommandLine/cmake_depends/test.h$") + string(REPLACE "\n" "\n " depend_make_content " ${depend_make_content}") + set(RunCMake_TEST_FAILED "depend.make does not have expected content:\n${depend_make_content}") + endif() +else() + set(RunCMake_TEST_FAILED "depend.make missing:\n ${depend_make}") +endif() diff --git a/Tests/RunCMake/CommandLine/cmake_depends-stdout.txt b/Tests/RunCMake/CommandLine/cmake_depends-stdout.txt new file mode 100644 index 0000000..8fe092b --- /dev/null +++ b/Tests/RunCMake/CommandLine/cmake_depends-stdout.txt @@ -0,0 +1 @@ +^Scanning dependencies of target DepTarget$ diff --git a/Tests/RunCMake/CommandLine/cmake_depends/test.c b/Tests/RunCMake/CommandLine/cmake_depends/test.c new file mode 100644 index 0000000..92c056f --- /dev/null +++ b/Tests/RunCMake/CommandLine/cmake_depends/test.c @@ -0,0 +1,2 @@ +#include "test.h" +#include "test_UTF-16LE.h" diff --git a/Tests/RunCMake/CommandLine/cmake_depends/test.h b/Tests/RunCMake/CommandLine/cmake_depends/test.h new file mode 100644 index 0000000..fd87388 --- /dev/null +++ b/Tests/RunCMake/CommandLine/cmake_depends/test.h @@ -0,0 +1 @@ +void test(void) {} diff --git a/Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h b/Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h Binary files differnew file mode 100644 index 0000000..bf56ec6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake new file mode 100644 index 0000000..0aae06c --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake @@ -0,0 +1,12 @@ +set(testfile "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake") +if(EXISTS "${testfile}") + file(READ "${testfile}" testfile_contents) +else() + message(FATAL_ERROR "Could not find expected CTestTestfile.cmake.") +endif() +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator ^(pseudo_emulator)+$") + message(SEND_ERROR "Used emulator when it should not be used.") +endif() +if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator .+pseudo_emulator.+$") + message(SEND_ERROR "Did not use emulator when it should be used.") +endif() diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake new file mode 100644 index 0000000..41850f2 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake @@ -0,0 +1,8 @@ +set(CMAKE_CROSSCOMPILING 1) +enable_testing() +add_test(NAME DoesNotUseEmulator + COMMAND ${CMAKE_COMMAND} -E echo "Hi") + +add_executable(generated_exe simple_src.cxx) +add_test(NAME UsesEmulator + COMMAND generated_exe) diff --git a/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt b/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt new file mode 100644 index 0000000..2d75985 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake new file mode 100644 index 0000000..22d537c --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake @@ -0,0 +1,28 @@ +# This tests setting the CROSSCOMPILING_EMULATOR target property from the +# CMAKE_CROSSCOMPILING_EMULATOR variable. + +# -DCMAKE_CROSSCOMPILING_EMULATOR=/path/to/pseudo_emulator is passed to this +# test +add_executable(target_with_emulator simple_src.cxx) +get_property(emulator TARGET target_with_emulator + PROPERTY CROSSCOMPILING_EMULATOR) +if(NOT "${emulator}" MATCHES "pseudo_emulator") + message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set") +endif() + +set_property(TARGET target_with_emulator + PROPERTY CROSSCOMPILING_EMULATOR "another_emulator") +get_property(emulator TARGET target_with_emulator + PROPERTY CROSSCOMPILING_EMULATOR) +if(NOT "${emulator}" MATCHES "another_emulator") + message(SEND_ERROR + "set_property/get_property CROSSCOMPILING_EMULATOR is not consistent") +endif() + +unset(CMAKE_CROSSCOMPILING_EMULATOR CACHE) +add_executable(target_without_emulator simple_src.cxx) +get_property(emulator TARGET target_without_emulator + PROPERTY CROSSCOMPILING_EMULATOR) +if(NOT "${emulator}" STREQUAL "") + message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set to null") +endif() diff --git a/Tests/RunCMake/CrosscompilingEmulator/InitialCache.txt.in b/Tests/RunCMake/CrosscompilingEmulator/InitialCache.txt.in new file mode 100644 index 0000000..c95fd8b --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/InitialCache.txt.in @@ -0,0 +1 @@ +CMAKE_EMULATOR:STRING=@PSEUDO_EMULATOR@ diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake new file mode 100644 index 0000000..2581cfc --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS + "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR}") + +run_cmake(CrosscompilingEmulatorProperty) +run_cmake(TryRun) +run_cmake(AddTest) diff --git a/Tests/RunCMake/CrosscompilingEmulator/TryRun-stdout.txt b/Tests/RunCMake/CrosscompilingEmulator/TryRun-stdout.txt new file mode 100644 index 0000000..d012974 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/TryRun-stdout.txt @@ -0,0 +1 @@ +run_result: 42 diff --git a/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake new file mode 100644 index 0000000..4851cc7 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake @@ -0,0 +1,18 @@ +set(CMAKE_CROSSCOMPILING 1) + +try_run(run_result compile_result + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx + RUN_OUTPUT_VARIABLE run_output) + +message(STATUS "run_output: ${run_output}") +message(STATUS "run_result: ${run_result}") + +set(CMAKE_CROSSCOMPILING_EMULATOR ${CMAKE_CROSSCOMPILING_EMULATOR} + --flag + "multi arg") +try_run(run_result compile_result + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx + RUN_OUTPUT_VARIABLE run_output) +message(STATUS "Emulator with arguments run_output: ${run_output}") diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx new file mode 100644 index 0000000..e5e94f2 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx @@ -0,0 +1,4 @@ +int main(int, char **) +{ + return 13; +} diff --git a/Tests/RunCMake/ExternalData/BadRecurse1-result.txt b/Tests/RunCMake/ExternalData/BadRecurse1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt new file mode 100644 index 0000000..aedc330 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Recurse option "RECURSE:" allowed only with directories. +Call Stack \(most recent call first\): + .* + BadRecurse1.cmake:2 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadRecurse1.cmake b/Tests/RunCMake/ExternalData/BadRecurse1.cmake new file mode 100644 index 0000000..f70b9f9 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse1.cmake @@ -0,0 +1,2 @@ +include(ExternalData) +ExternalData_Expand_Arguments(Data args DATA{Series.txt,:,RECURSE:}) diff --git a/Tests/RunCMake/ExternalData/BadRecurse2-result.txt b/Tests/RunCMake/ExternalData/BadRecurse2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt new file mode 100644 index 0000000..3f809ca --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Recurse option "RECURSE:" allowed only with directories. +Call Stack \(most recent call first\): + .* + BadRecurse2.cmake:2 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadRecurse2.cmake b/Tests/RunCMake/ExternalData/BadRecurse2.cmake new file mode 100644 index 0000000..c4dc35d --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse2.cmake @@ -0,0 +1,2 @@ +include(ExternalData) +ExternalData_Expand_Arguments(Data args DATA{Data.txt,RECURSE:}) diff --git a/Tests/RunCMake/ExternalData/BadRecurse3-result.txt b/Tests/RunCMake/ExternalData/BadRecurse3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt new file mode 100644 index 0000000..37740e0 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Unknown option "RECURSE:x" in argument + + DATA{Directory1/,RECURSE:x,Data.dat} + +Call Stack \(most recent call first\): + .* + BadRecurse3.cmake:2 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadRecurse3.cmake b/Tests/RunCMake/ExternalData/BadRecurse3.cmake new file mode 100644 index 0000000..9a22f62 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadRecurse3.cmake @@ -0,0 +1,2 @@ +include(ExternalData) +ExternalData_Expand_Arguments(Data args DATA{Directory1/,RECURSE:x,Data.dat}) diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake index 241fa1f..b5ab22d 100644 --- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake @@ -9,6 +9,9 @@ run_cmake(BadCustom4) run_cmake(BadHashAlgo1) run_cmake(BadOption1) run_cmake(BadOption2) +run_cmake(BadRecurse1) +run_cmake(BadRecurse2) +run_cmake(BadRecurse3) run_cmake(BadSeries1) run_cmake(BadSeries2) run_cmake(BadSeries3) diff --git a/Tests/RunCMake/Ninja/CMP0058-NEW-by-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-NEW-by-build-stdout.txt new file mode 100644 index 0000000..8646a13 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-NEW-by-build-stdout.txt @@ -0,0 +1,4 @@ +^[^ +]* Generating output1 +[^ +]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake b/Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake new file mode 100644 index 0000000..0f77930 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-NEW-by.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0058 NEW) +set(byproducts BYPRODUCTS byproduct1a byproduct1b) +include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-NEW-no-build-result.txt b/Tests/RunCMake/Ninja/CMP0058-NEW-no-build-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-NEW-no-build-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Ninja/CMP0058-NEW-no-build-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-NEW-no-build-stderr.txt new file mode 100644 index 0000000..fa10109 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-NEW-no-build-stderr.txt @@ -0,0 +1 @@ +ninja: error: 'byproduct1a', needed by 'output2', missing and no known rule to make it diff --git a/Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake b/Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake new file mode 100644 index 0000000..582e3d5 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-NEW-no.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0058 NEW) +include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-by-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-by-build-stdout.txt new file mode 100644 index 0000000..8646a13 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-OLD-by-build-stdout.txt @@ -0,0 +1,4 @@ +^[^ +]* Generating output1 +[^ +]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-by.cmake b/Tests/RunCMake/Ninja/CMP0058-OLD-by.cmake new file mode 100644 index 0000000..92a3a0f --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-OLD-by.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0058 OLD) +set(byproducts BYPRODUCTS byproduct1a byproduct1b) +include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-no-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-no-build-stdout.txt new file mode 100644 index 0000000..8646a13 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-OLD-no-build-stdout.txt @@ -0,0 +1,4 @@ +^[^ +]* Generating output1 +[^ +]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-no.cmake b/Tests/RunCMake/Ninja/CMP0058-OLD-no.cmake new file mode 100644 index 0000000..0326e07 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-OLD-no.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0058 OLD) +include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-by-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-by-build-stdout.txt new file mode 100644 index 0000000..8646a13 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-WARN-by-build-stdout.txt @@ -0,0 +1,4 @@ +^[^ +]* Generating output1 +[^ +]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake b/Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake new file mode 100644 index 0000000..6128167 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-WARN-by.cmake @@ -0,0 +1,2 @@ +set(byproducts BYPRODUCTS byproduct1a byproduct1b) +include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-no-build-stdout.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-no-build-stdout.txt new file mode 100644 index 0000000..8646a13 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-WARN-no-build-stdout.txt @@ -0,0 +1,4 @@ +^[^ +]* Generating output1 +[^ +]* Generating output2$ diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt new file mode 100644 index 0000000..439a2d9 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt @@ -0,0 +1,19 @@ +^CMake Warning \(dev\): + Policy CMP0058 is not set: Ninja requires custom command byproducts to be + explicit. Run "cmake --help-policy CMP0058" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + This project specifies custom command DEPENDS on files in the build tree + that are not specified as the OUTPUT or BYPRODUCTS of any + add_custom_command or add_custom_target: + + byproduct1a + byproduct1b + + For compatibility with versions of CMake that did not have the BYPRODUCTS + option, CMake is generating phony rules for such files to convince 'ninja' + to build. + + Project authors should add the missing BYPRODUCTS or OUTPUT options to the + custom commands that produce these files. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake b/Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake new file mode 100644 index 0000000..7bc66ef --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-WARN-no.cmake @@ -0,0 +1 @@ +include(CMP0058-common.cmake) diff --git a/Tests/RunCMake/Ninja/CMP0058-common.cmake b/Tests/RunCMake/Ninja/CMP0058-common.cmake new file mode 100644 index 0000000..9274d58 --- /dev/null +++ b/Tests/RunCMake/Ninja/CMP0058-common.cmake @@ -0,0 +1,17 @@ +add_custom_command( + OUTPUT output1 + ${byproducts} + COMMAND ${CMAKE_COMMAND} -E touch output1 + COMMAND ${CMAKE_COMMAND} -E touch byproduct1a + COMMAND ${CMAKE_COMMAND} -E touch byproduct1b + ) +add_custom_target(Drive1 ALL DEPENDS output1) +add_custom_command( + OUTPUT output2 + COMMAND ${CMAKE_COMMAND} -E copy output1 output2 + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/output1 + ${CMAKE_CURRENT_BINARY_DIR}/byproduct1a + ${CMAKE_CURRENT_BINARY_DIR}/byproduct1b + ) +add_custom_target(Drive2 ALL DEPENDS output2) +add_dependencies(Drive2 Drive1) diff --git a/Tests/RunCMake/Ninja/CMakeLists.txt b/Tests/RunCMake/Ninja/CMakeLists.txt new file mode 100644 index 0000000..2a0591e --- /dev/null +++ b/Tests/RunCMake/Ninja/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake new file mode 100644 index 0000000..64f97bc --- /dev/null +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -0,0 +1,18 @@ +include(RunCMake) + +function(run_CMP0058 case) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(CMP0058-${case}) + run_cmake_command(CMP0058-${case}-build ${CMAKE_COMMAND} --build .) +endfunction() + +run_CMP0058(OLD-no) +run_CMP0058(OLD-by) +run_CMP0058(WARN-no) +run_CMP0058(WARN-by) +run_CMP0058(NEW-no) +run_CMP0058(NEW-by) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index abac66e..6333703 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -54,12 +54,18 @@ function(run_cmake test) if(RunCMake_MAKE_PROGRAM) list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}") endif() + if(RunCMake_TEST_OUTPUT_MERGE) + set(actual_stderr_var actual_stdout) + set(actual_stderr "") + else() + set(actual_stderr_var actual_stderr) + endif() if(RunCMake_TEST_COMMAND) execute_process( COMMAND ${RunCMake_TEST_COMMAND} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" OUTPUT_VARIABLE actual_stdout - ERROR_VARIABLE actual_stderr + ERROR_VARIABLE ${actual_stderr_var} RESULT_VARIABLE actual_result ) else() @@ -73,7 +79,7 @@ function(run_cmake test) ${RunCMake_TEST_OPTIONS} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" OUTPUT_VARIABLE actual_stdout - ERROR_VARIABLE actual_stderr + ERROR_VARIABLE ${actual_stderr_var} RESULT_VARIABLE actual_result ) endif() diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index f4b744b..1da1623 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -17,6 +17,7 @@ \* CMP0042 \* CMP0046 \* CMP0052 + \* CMP0060 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 03d3cd3..b7de614 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(XcodeFileType) run_cmake(XcodeAttributeGenex) run_cmake(XcodeAttributeGenexError) +run_cmake(XcodeObjectNeedsQuote) if (NOT XCODE_VERSION VERSION_LESS 6) run_cmake(XcodePlatformFrameworks) endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote-check.cmake b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote-check.cmake new file mode 100644 index 0000000..be7d96a --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote-check.cmake @@ -0,0 +1,7 @@ +set(expect "path = \"") +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeObjectNeedsQuote.xcodeproj/project.pbxproj actual + REGEX "path = [^;]*someFileWithoutSpecialChars[^;]*;" LIMIT_COUNT 1) +if(NOT "${actual}" MATCHES "${expect}") + message(SEND_ERROR "The actual project contains the line:\n ${actual}\n" + "which does not match expected regex:\n ${expect}\n") +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote.cmake b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote.cmake new file mode 100644 index 0000000..ecc56ab --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeObjectNeedsQuote.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_library(some /${CMAKE_CURRENT_SOURCE_DIR}/someFileWithoutSpecialChars) +set_property(SOURCE /${CMAKE_CURRENT_SOURCE_DIR}/someFileWithoutSpecialChars PROPERTY LANGUAGE C) diff --git a/Tests/RunCMake/XcodeProject/someFileWithoutSpecialChars b/Tests/RunCMake/XcodeProject/someFileWithoutSpecialChars new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/someFileWithoutSpecialChars diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-result.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-stderr.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-stderr.txt new file mode 100644 index 0000000..9629cfd --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg-stderr.txt @@ -0,0 +1 @@ +.*file LIST_DIRECTORIES missing bool value\. diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg.cmake b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg.cmake new file mode 100644 index 0000000..a8e15f2 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-no-arg.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST LIST_DIRECTORIES) diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-result.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-stderr.txt b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-stderr.txt new file mode 100644 index 0000000..9629cfd --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean-stderr.txt @@ -0,0 +1 @@ +.*file LIST_DIRECTORIES missing bool value\. diff --git a/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean.cmake b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean.cmake new file mode 100644 index 0000000..f735433 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-LIST_DIRECTORIES-not-boolean.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST LIST_DIRECTORIES 13) diff --git a/Tests/RunCMake/file/GLOB-stderr.txt b/Tests/RunCMake/file/GLOB-stderr.txt new file mode 100644 index 0000000..c47dc40 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-stderr.txt @@ -0,0 +1,6 @@ +content: 6[ ] +.*/test/dir 1/dir 1 file;.*/test/dir 1/empty_dir;.*/test/dir 1/non_empty_dir;.*/test/dir 2/dir 2 file;.*/test/dir 2/empty_dir;.*/test/dir 2/non_empty_dir +content: 6[ ] +.*/test/dir 1/dir 1 file;.*/test/dir 1/empty_dir;.*/test/dir 1/non_empty_dir;.*/test/dir 2/dir 2 file;.*/test/dir 2/empty_dir;.*/test/dir 2/non_empty_dir +content: 2[ ] +.*/test/dir 1/dir 1 file;.*/test/dir 2/dir 2 file diff --git a/Tests/RunCMake/file/GLOB.cmake b/Tests/RunCMake/file/GLOB.cmake new file mode 100644 index 0000000..3d577e3 --- /dev/null +++ b/Tests/RunCMake/file/GLOB.cmake @@ -0,0 +1,28 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/dir 1 file" "test file") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir/dir 1 subdir file" "test file") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/dir 2 file" "test file") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir file" "test file") + +file(GLOB CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") + +file(GLOB CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") + +file(GLOB CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") diff --git a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion-stderr.txt new file mode 100644 index 0000000..f73aa83 --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion-stderr.txt @@ -0,0 +1,15 @@ +.*Cyclic recursion detected while globbing for.* +.*/test/depth1/depth2/depth3.* +.*/test/depth1/depth2/depth3/recursion.* +content: 4[ ] +.*/test/abc;.*/test/depth1/depth2/depth3/file_symlink;.*/test/depth1/depth2/depth3/recursion/abc;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3/file_symlink +.*Cyclic recursion detected while globbing for.* +.*/test/depth1/depth2/depth3.* +.*/test/depth1/depth2/depth3/recursion.* +content: 4[ ] +.*/test/abc;.*/test/depth1/depth2/depth3/file_symlink;.*/test/depth1/depth2/depth3/recursion/abc;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3/file_symlink +.*Cyclic recursion detected while globbing for.* +.*/test/depth1/depth2/depth3.* +.*/test/depth1/depth2/depth3/recursion.* +content: 11[ ] +.*/test/abc;.*/test/depth1;.*/test/depth1/depth2;.*/test/depth1/depth2/depth3;.*/test/depth1/depth2/depth3/file_symlink;.*/test/depth1/depth2/depth3/recursion;.*/test/depth1/depth2/depth3/recursion/abc;.*/test/depth1/depth2/depth3/recursion/depth1;.*/test/depth1/depth2/depth3/recursion/depth1/depth2;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3;.*/test/depth1/depth2/depth3/recursion/depth1/depth2/depth3/file_symlink diff --git a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake new file mode 100644 index 0000000..a8c6784 --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake @@ -0,0 +1,23 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/depth1/depth2/depth3") +execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/test" "${CMAKE_CURRENT_BINARY_DIR}/test/depth1/depth2/depth3/recursion") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/abc" "message to write") +execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/test/abc" "${CMAKE_CURRENT_BINARY_DIR}/test/depth1/depth2/depth3/file_symlink") + +file(GLOB_RECURSE CONTENT_LIST FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") + +file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") + +file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") diff --git a/Tests/RunCMake/file/GLOB_RECURSE-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-stderr.txt new file mode 100644 index 0000000..5d48e47 --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-stderr.txt @@ -0,0 +1,6 @@ +content: 4[ ] +.*/test/dir 1/dir 1 file;.*/test/dir 1/non_empty_dir/dir 1 subdir file;.*/test/dir 2/dir 2 file;.*/test/dir 2/non_empty_dir/dir 2 subdir file +content: 4[ ] +.*/test/dir 1/dir 1 file;.*/test/dir 1/non_empty_dir/dir 1 subdir file;.*/test/dir 2/dir 2 file;.*/test/dir 2/non_empty_dir/dir 2 subdir file +content: 8[ ] +.*/test/dir 1/dir 1 file;.*/test/dir 1/empty_dir;.*/test/dir 1/non_empty_dir;.*/test/dir 1/non_empty_dir/dir 1 subdir file;.*/test/dir 2/dir 2 file;.*/test/dir 2/empty_dir;.*/test/dir 2/non_empty_dir;.*/test/dir 2/non_empty_dir/dir 2 subdir file diff --git a/Tests/RunCMake/file/GLOB_RECURSE.cmake b/Tests/RunCMake/file/GLOB_RECURSE.cmake new file mode 100644 index 0000000..6db377b --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE.cmake @@ -0,0 +1,28 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/dir 1 file" "test file") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir/dir 1 subdir file" "test file") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/dir 2 file" "test file") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir file" "test file") + +file(GLOB_RECURSE CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") + +file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") + +file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*") +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +list(SORT CONTENT_LIST) +message("${CONTENT_LIST}") diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 14819e7..d3dfb1b 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -17,3 +17,13 @@ run_cmake(LOCK-error-no-result-variable) run_cmake(LOCK-error-no-timeout) run_cmake(LOCK-error-timeout) run_cmake(LOCK-error-unknown-option) +run_cmake(GLOB) +run_cmake(GLOB_RECURSE) +# test is valid both for GLOB and GLOB_RECURSE +run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean) +# test is valid both for GLOB and GLOB_RECURSE +run_cmake(GLOB-error-LIST_DIRECTORIES-no-arg) + +if(NOT WIN32 OR CYGWIN) + run_cmake(GLOB_RECURSE-cyclic-recursion) +endif() diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index 08e81c6..201daa7 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -7,5 +7,4 @@ run_cmake(whitelist) run_cmake(invalid_signature) run_cmake(global-interface) run_cmake(genex_link) -run_cmake(add_dependencies) run_cmake(add_custom_command-TARGET) diff --git a/Tests/RunCMake/interface_library/add_dependencies-stderr.txt b/Tests/RunCMake/interface_library/add_dependencies-stderr.txt deleted file mode 100644 index c550b68..0000000 --- a/Tests/RunCMake/interface_library/add_dependencies-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at add_dependencies.cmake:4 \(add_dependencies\): - add_dependencies Cannot add target-level dependencies to INTERFACE library - target "iface". - -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/add_dependencies.cmake b/Tests/RunCMake/interface_library/add_dependencies.cmake deleted file mode 100644 index 12cdfb4..0000000 --- a/Tests/RunCMake/interface_library/add_dependencies.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -add_library(foo empty.cpp) -add_library(iface INTERFACE) -add_dependencies(iface foo) diff --git a/Tests/RunCMake/pseudo_emulator.c b/Tests/RunCMake/pseudo_emulator.c new file mode 100644 index 0000000..9308f75 --- /dev/null +++ b/Tests/RunCMake/pseudo_emulator.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main(int argc, char * argv[] ) +{ + int ii; + + printf("Command:"); + for(ii = 1; ii < argc; ++ii) + { + printf(" \"%s\"", argv[ii]); + } + printf("\n"); + + return 42; +} diff --git a/Tests/VSWindowsFormsResx/CMakeLists.txt b/Tests/VSWindowsFormsResx/CMakeLists.txt index 4373810..43c4833 100644 --- a/Tests/VSWindowsFormsResx/CMakeLists.txt +++ b/Tests/VSWindowsFormsResx/CMakeLists.txt @@ -14,7 +14,7 @@ include(CheckCXXSourceCompiles) include(CheckIncludeFile) # Note: The designable form is assumed to have a .h extension as is default in Visual Studio. -# Node: The designable form is assumed to have a .resx file with the same name and path (save extension) as is default in Visual Studio +# Note: The designable form is assumed to have a .resx file with the same name and path (save extension) as is default in Visual Studio set(TARGET_H WindowsFormsResx/MyForm.h diff --git a/Tests/VSXaml/App.xaml b/Tests/VSXaml/App.xaml new file mode 100644 index 0000000..eecf2c1 --- /dev/null +++ b/Tests/VSXaml/App.xaml @@ -0,0 +1,7 @@ +<Application + x:Class="VSXaml.App" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="using:VSXaml"> + +</Application> diff --git a/Tests/VSXaml/App.xaml.cpp b/Tests/VSXaml/App.xaml.cpp new file mode 100644 index 0000000..334dc1f --- /dev/null +++ b/Tests/VSXaml/App.xaml.cpp @@ -0,0 +1,125 @@ +// +// App.xaml.cpp +// Implementation of the App class. +// + +#include "pch.h" +#include "MainPage.xaml.h" + +using namespace VSXaml; + +using namespace Platform; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Interop; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 + +/// <summary> +/// Initializes the singleton application object. This is the first line of authored code +/// executed, and as such is the logical equivalent of main() or WinMain(). +/// </summary> +App::App() +{ + InitializeComponent(); + Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); +} + +/// <summary> +/// Invoked when the application is launched normally by the end user. Other entry points +/// will be used such as when the application is launched to open a specific file. +/// </summary> +/// <param name="e">Details about the launch request and process.</param> +void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) +{ + +#if _DEBUG + // Show graphics profiling information while debugging. + if (IsDebuggerPresent()) + { + // Display the current frame rate counters + DebugSettings->EnableFrameRateCounter = true; + } +#endif + + auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content); + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == nullptr) + { + // Create a Frame to act as the navigation context and associate it with + // a SuspensionManager key + rootFrame = ref new Frame(); + + // Set the default language + rootFrame->Language = Windows::Globalization::ApplicationLanguages::Languages->GetAt(0); + + rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed); + + if (e->PreviousExecutionState == ApplicationExecutionState::Terminated) + { + // TODO: Restore the saved session state only when appropriate, scheduling the + // final launch steps after the restore is complete + + } + + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); + } + // Place the frame in the current Window + Window::Current->Content = rootFrame; + // Ensure the current window is active + Window::Current->Activate(); + } + else + { + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); + } + // Ensure the current window is active + Window::Current->Activate(); + } +} + +/// <summary> +/// Invoked when application execution is being suspended. Application state is saved +/// without knowing whether the application will be terminated or resumed with the contents +/// of memory still intact. +/// </summary> +/// <param name="sender">The source of the suspend request.</param> +/// <param name="e">Details about the suspend request.</param> +void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e) +{ + (void) sender; // Unused parameter + (void) e; // Unused parameter + + //TODO: Save application state and stop any background activity +} + +/// <summary> +/// Invoked when Navigation to a certain page fails +/// </summary> +/// <param name="sender">The Frame which failed navigation</param> +/// <param name="e">Details about the navigation failure</param> +void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e) +{ + throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name); +}
\ No newline at end of file diff --git a/Tests/VSXaml/App.xaml.h b/Tests/VSXaml/App.xaml.h new file mode 100644 index 0000000..1f65bda --- /dev/null +++ b/Tests/VSXaml/App.xaml.h @@ -0,0 +1,27 @@ +// +// App.xaml.h +// Declaration of the App class. +// + +#pragma once + +#include "App.g.h" + +namespace VSXaml +{ + /// <summary> + /// Provides application-specific behavior to supplement the default Application class. + /// </summary> + ref class App sealed + { + protected: + virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; + + internal: + App(); + + private: + void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); + void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e); + }; +} diff --git a/Tests/VSXaml/Assets/Logo.scale-100.png b/Tests/VSXaml/Assets/Logo.scale-100.png Binary files differnew file mode 100644 index 0000000..e26771c --- /dev/null +++ b/Tests/VSXaml/Assets/Logo.scale-100.png diff --git a/Tests/VSXaml/Assets/SmallLogo.scale-100.png b/Tests/VSXaml/Assets/SmallLogo.scale-100.png Binary files differnew file mode 100644 index 0000000..1eb0d9d --- /dev/null +++ b/Tests/VSXaml/Assets/SmallLogo.scale-100.png diff --git a/Tests/VSXaml/Assets/SplashScreen.scale-100.png b/Tests/VSXaml/Assets/SplashScreen.scale-100.png Binary files differnew file mode 100644 index 0000000..c951e03 --- /dev/null +++ b/Tests/VSXaml/Assets/SplashScreen.scale-100.png diff --git a/Tests/VSXaml/Assets/StoreLogo.scale-100.png b/Tests/VSXaml/Assets/StoreLogo.scale-100.png Binary files differnew file mode 100644 index 0000000..dcb6727 --- /dev/null +++ b/Tests/VSXaml/Assets/StoreLogo.scale-100.png diff --git a/Tests/VSXaml/CMakeLists.txt b/Tests/VSXaml/CMakeLists.txt new file mode 100644 index 0000000..f384c82 --- /dev/null +++ b/Tests/VSXaml/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.2) +project(VSXaml) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +set(SOURCE_FILES + App.xaml.cpp + MainPage.xaml.cpp + pch.cpp + ) + +set(HEADER_FILES + App.xaml.h + MainPage.xaml.h + pch.h + ) + +set(XAML_FILES + App.xaml + MainPage.xaml + ) + +set(ASSET_FILES + Assets/Logo.scale-100.png + Assets/SmallLogo.scale-100.png + Assets/SplashScreen.scale-100.png + Assets/StoreLogo.scale-100.png + ) + +set(CONTENT_FILES + Package.appxmanifest + ) + +set(RESOURCE_FILES + ${CONTENT_FILES} ${ASSET_FILES} + VSXaml_TemporaryKey.pfx) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) +set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) +set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets") + +set_property(SOURCE "App.xaml" PROPERTY VS_XAML_TYPE "ApplicationDefinition") + +source_group("Source Files" FILES ${SOURCE_FILES}) +source_group("Header Files" FILES ${HEADER_FILES}) +source_group("Resource Files" FILES ${RESOURCE_FILES}) +source_group("Xaml Files" FILES ${XAML_FILES}) + +add_executable(VSXaml WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES} ${XAML_FILES}) +set_property(TARGET VSXaml PROPERTY VS_WINRT_COMPONENT TRUE) diff --git a/Tests/VSXaml/MainPage.xaml b/Tests/VSXaml/MainPage.xaml new file mode 100644 index 0000000..62139ca --- /dev/null +++ b/Tests/VSXaml/MainPage.xaml @@ -0,0 +1,14 @@ +<Page + x:Class="VSXaml.MainPage" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="using:VSXaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="d"> + + <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> + <TextBlock Text="I'm a CMake XAML App" HorizontalAlignment="Center" VerticalAlignment="Center" + Style="{StaticResource HeaderTextBlockStyle}"/> + </Grid> +</Page> diff --git a/Tests/VSXaml/MainPage.xaml.cpp b/Tests/VSXaml/MainPage.xaml.cpp new file mode 100644 index 0000000..d0a64e8 --- /dev/null +++ b/Tests/VSXaml/MainPage.xaml.cpp @@ -0,0 +1,27 @@ +// +// MainPage.xaml.cpp +// Implementation of the MainPage class. +// + +#include "pch.h" +#include "MainPage.xaml.h" + +using namespace VSXaml; + +using namespace Platform; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 + +MainPage::MainPage() +{ + InitializeComponent(); +} diff --git a/Tests/VSXaml/MainPage.xaml.h b/Tests/VSXaml/MainPage.xaml.h new file mode 100644 index 0000000..ccc781b --- /dev/null +++ b/Tests/VSXaml/MainPage.xaml.h @@ -0,0 +1,21 @@ +// +// MainPage.xaml.h +// Declaration of the MainPage class. +// + +#pragma once + +#include "MainPage.g.h" + +namespace VSXaml +{ + /// <summary> + /// An empty page that can be used on its own or navigated to within a Frame. + /// </summary> + public ref class MainPage sealed + { + public: + MainPage(); + + }; +} diff --git a/Tests/VSXaml/Package.appxmanifest b/Tests/VSXaml/Package.appxmanifest new file mode 100644 index 0000000..873a64a --- /dev/null +++ b/Tests/VSXaml/Package.appxmanifest @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest"> + + <Identity Name="19ff96f1-8379-4e14-8b9d-04648b3b36a9" + Publisher="CN=Microsoft" + Version="1.0.0.0" /> + + <Properties> + <DisplayName>VSXaml</DisplayName> + <PublisherDisplayName>Microsoft</PublisherDisplayName> + <Logo>Assets\StoreLogo.png</Logo> + </Properties> + + <Prerequisites> + <OSMinVersion>6.3.0</OSMinVersion> + <OSMaxVersionTested>6.3.0</OSMaxVersionTested> + </Prerequisites> + + <Resources> + <Resource Language="x-generate"/> + </Resources> + + <Applications> + <Application Id="App" + Executable="$targetnametoken$.exe" + EntryPoint="VSXaml.App"> + <m2:VisualElements + DisplayName="VSXaml" + Square150x150Logo="Assets\Logo.png" + Square30x30Logo="Assets\SmallLogo.png" + Description="VSXaml" + ForegroundText="light" + BackgroundColor="#464646"> + <m2:SplashScreen Image="Assets\SplashScreen.png" /> + </m2:VisualElements> + </Application> + </Applications> + <Capabilities> + <Capability Name="internetClient" /> + </Capabilities> +</Package>
\ No newline at end of file diff --git a/Tests/VSXaml/VSXaml_TemporaryKey.pfx b/Tests/VSXaml/VSXaml_TemporaryKey.pfx Binary files differnew file mode 100644 index 0000000..1cad999 --- /dev/null +++ b/Tests/VSXaml/VSXaml_TemporaryKey.pfx diff --git a/Tests/VSXaml/pch.cpp b/Tests/VSXaml/pch.cpp new file mode 100644 index 0000000..01484ff --- /dev/null +++ b/Tests/VSXaml/pch.cpp @@ -0,0 +1,6 @@ +// +// pch.cpp +// Include the standard header and generate the precompiled header. +// + +#include "pch.h" diff --git a/Tests/VSXaml/pch.h b/Tests/VSXaml/pch.h new file mode 100644 index 0000000..2c4354d --- /dev/null +++ b/Tests/VSXaml/pch.h @@ -0,0 +1,11 @@ +// +// pch.h +// Header for standard system include files. +// + +#pragma once + +#include <collection.h> +#include <ppltasks.h> + +#include "App.xaml.h" diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt new file mode 100644 index 0000000..e866623 --- /dev/null +++ b/Tests/XCTest/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.1) +project(XCTest) +enable_testing() + +find_package(XCTest REQUIRED) + +# Framework + +add_library(FrameworkExample SHARED + FrameworkExample/FrameworkExample.c + FrameworkExample/FrameworkExample.h + FrameworkExample/Info.plist) + +target_include_directories(FrameworkExample PUBLIC .) + +set_target_properties(FrameworkExample PROPERTIES + FRAMEWORK TRUE + VERSION "1.0.0" + SOVERSION "1.0.0" + FRAMEWORK_VERSION "A" + MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/FrameworkExample/Info.plist + PUBLIC_HEADER FrameworkExample/FrameworkExample.h) + +# XCTest for Framework + +xctest_add_bundle(FrameworkExampleTests FrameworkExample + FrameworkExampleTests/FrameworkExampleTests.m + FrameworkExampleTests/Info.plist) + +set_target_properties(FrameworkExampleTests PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/FrameworkExampleTests/Info.plist + ) + +xctest_add_test(XCTest.FrameworkExample FrameworkExampleTests) + +# Cocoa App Bundle + +add_executable(CocoaExample MACOSX_BUNDLE + CocoaExample/main.m + CocoaExample/AppDelegate.m + CocoaExample/AppDelegate.h + CocoaExample/MainMenu.xib +) + +target_link_libraries(CocoaExample PRIVATE "-framework Foundation") +target_link_libraries(CocoaExample PRIVATE "-framework AppKit") + +set_target_properties(CocoaExample PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/CocoaExample/Info.plist + RESOURCE "CocoaExample/MainMenu.xib") + +# XCTest for Cocoa App Bundle + +xctest_add_bundle(CocoaExampleTests CocoaExample + CocoaExampleTests/CocoaExampleTests.m) + +xctest_add_test(XCTest.CocoaExample CocoaExampleTests) diff --git a/Tests/XCTest/CocoaExample/AppDelegate.h b/Tests/XCTest/CocoaExample/AppDelegate.h new file mode 100644 index 0000000..4bf4101 --- /dev/null +++ b/Tests/XCTest/CocoaExample/AppDelegate.h @@ -0,0 +1,6 @@ +#import <Cocoa/Cocoa.h> + +@interface AppDelegate : NSObject <NSApplicationDelegate> + + +@end diff --git a/Tests/XCTest/CocoaExample/AppDelegate.m b/Tests/XCTest/CocoaExample/AppDelegate.m new file mode 100644 index 0000000..07af62f --- /dev/null +++ b/Tests/XCTest/CocoaExample/AppDelegate.m @@ -0,0 +1,18 @@ +#import "AppDelegate.h" + +@interface AppDelegate () + +@property (assign) IBOutlet NSWindow *window; +@end + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // Insert code here to initialize your application +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + // Insert code here to tear down your application +} + +@end diff --git a/Tests/XCTest/CocoaExample/Info.plist b/Tests/XCTest/CocoaExample/Info.plist new file mode 100644 index 0000000..5267c63 --- /dev/null +++ b/Tests/XCTest/CocoaExample/Info.plist @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>CocoaExample</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>org.cmake.CocoaExample</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>CocoaExample</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>NSMainNibFile</key> + <string>MainMenu</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> +</dict> +</plist> diff --git a/Tests/XCTest/CocoaExample/MainMenu.xib b/Tests/XCTest/CocoaExample/MainMenu.xib new file mode 100644 index 0000000..9498a0a --- /dev/null +++ b/Tests/XCTest/CocoaExample/MainMenu.xib @@ -0,0 +1,680 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6233" systemVersion="14A329f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6233"/> + </dependencies> + <objects> + <customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> + <connections> + <outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/> + </connections> + </customObject> + <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> + <customObject id="-3" userLabel="Application" customClass="NSObject"/> + <customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider=""> + <connections> + <outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/> + </connections> + </customObject> + <customObject id="YLy-65-1bz" customClass="NSFontManager"/> + <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6"> + <items> + <menuItem title="CocoaExample" id="1Xt-HY-uBw"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="CocoaExample" systemMenu="apple" id="uQy-DD-JDr"> + <items> + <menuItem title="About CocoaExample" id="5kV-Vb-QxS"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/> + <menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/> + <menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/> + <menuItem title="Services" id="NMo-om-nkz"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/> + </menuItem> + <menuItem isSeparatorItem="YES" id="4je-JR-u6R"/> + <menuItem title="Hide CocoaExample" keyEquivalent="h" id="Olw-nP-bQN"> + <connections> + <action selector="hide:" target="-1" id="PnN-Uc-m68"/> + </connections> + </menuItem> + <menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO"> + <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> + <connections> + <action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/> + </connections> + </menuItem> + <menuItem title="Show All" id="Kd2-mp-pUS"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/> + <menuItem title="Quit CocoaExample" keyEquivalent="q" id="4sb-4s-VLi"> + <connections> + <action selector="terminate:" target="-1" id="Te7-pn-YzF"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="File" id="dMs-cI-mzQ"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="File" id="bib-Uj-vzu"> + <items> + <menuItem title="New" keyEquivalent="n" id="Was-JA-tGl"> + <connections> + <action selector="newDocument:" target="-1" id="4Si-XN-c54"/> + </connections> + </menuItem> + <menuItem title="Open…" keyEquivalent="o" id="IAo-SY-fd9"> + <connections> + <action selector="openDocument:" target="-1" id="bVn-NM-KNZ"/> + </connections> + </menuItem> + <menuItem title="Open Recent" id="tXI-mr-wws"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ"> + <items> + <menuItem title="Clear Menu" id="vNY-rz-j42"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="clearRecentDocuments:" target="-1" id="Daa-9d-B3U"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem isSeparatorItem="YES" id="m54-Is-iLE"/> + <menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG"> + <connections> + <action selector="performClose:" target="-1" id="HmO-Ls-i7Q"/> + </connections> + </menuItem> + <menuItem title="Save…" keyEquivalent="s" id="pxx-59-PXV"> + <connections> + <action selector="saveDocument:" target="-1" id="teZ-XB-qJY"/> + </connections> + </menuItem> + <menuItem title="Save As…" keyEquivalent="S" id="Bw7-FT-i3A"> + <connections> + <action selector="saveDocumentAs:" target="-1" id="mDf-zr-I0C"/> + </connections> + </menuItem> + <menuItem title="Revert to Saved" id="KaW-ft-85H"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="revertDocumentToSaved:" target="-1" id="iJ3-Pv-kwq"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="aJh-i4-bef"/> + <menuItem title="Page Setup…" keyEquivalent="P" id="qIS-W8-SiK"> + <modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/> + <connections> + <action selector="runPageLayout:" target="-1" id="Din-rz-gC5"/> + </connections> + </menuItem> + <menuItem title="Print…" keyEquivalent="p" id="aTl-1u-JFS"> + <connections> + <action selector="print:" target="-1" id="qaZ-4w-aoO"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Edit" id="5QF-Oa-p0T"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Edit" id="W48-6f-4Dl"> + <items> + <menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg"> + <connections> + <action selector="undo:" target="-1" id="M6e-cu-g7V"/> + </connections> + </menuItem> + <menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam"> + <connections> + <action selector="redo:" target="-1" id="oIA-Rs-6OD"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/> + <menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG"> + <connections> + <action selector="cut:" target="-1" id="YJe-68-I9s"/> + </connections> + </menuItem> + <menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU"> + <connections> + <action selector="copy:" target="-1" id="G1f-GL-Joy"/> + </connections> + </menuItem> + <menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL"> + <connections> + <action selector="paste:" target="-1" id="UvS-8e-Qdg"/> + </connections> + </menuItem> + <menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk"> + <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> + <connections> + <action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/> + </connections> + </menuItem> + <menuItem title="Delete" id="pa3-QI-u2k"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="delete:" target="-1" id="0Mk-Ml-PaM"/> + </connections> + </menuItem> + <menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m"> + <connections> + <action selector="selectAll:" target="-1" id="VNm-Mi-diN"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/> + <menuItem title="Find" id="4EN-yA-p0u"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Find" id="1b7-l0-nxx"> + <items> + <menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W"> + <connections> + <action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/> + </connections> + </menuItem> + <menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz"> + <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> + <connections> + <action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/> + </connections> + </menuItem> + <menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye"> + <connections> + <action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/> + </connections> + </menuItem> + <menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV"> + <connections> + <action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/> + </connections> + </menuItem> + <menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt"> + <connections> + <action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/> + </connections> + </menuItem> + <menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd"> + <connections> + <action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Spelling and Grammar" id="Dv1-io-Yv7"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Spelling" id="3IN-sU-3Bg"> + <items> + <menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI"> + <connections> + <action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/> + </connections> + </menuItem> + <menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7"> + <connections> + <action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="bNw-od-mp5"/> + <menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/> + </connections> + </menuItem> + <menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/> + </connections> + </menuItem> + <menuItem title="Correct Spelling Automatically" id="78Y-hA-62v"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Substitutions" id="9ic-FL-obx"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Substitutions" id="FeM-D8-WVr"> + <items> + <menuItem title="Show Substitutions" id="z6F-FW-3nz"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/> + <menuItem title="Smart Copy/Paste" id="9yt-4B-nSM"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/> + </connections> + </menuItem> + <menuItem title="Smart Quotes" id="hQb-2v-fYv"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/> + </connections> + </menuItem> + <menuItem title="Smart Dashes" id="rgM-f4-ycn"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/> + </connections> + </menuItem> + <menuItem title="Smart Links" id="cwL-P1-jid"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/> + </connections> + </menuItem> + <menuItem title="Data Detectors" id="tRr-pd-1PS"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/> + </connections> + </menuItem> + <menuItem title="Text Replacement" id="HFQ-gK-NFA"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Transformations" id="2oI-Rn-ZJC"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Transformations" id="c8a-y6-VQd"> + <items> + <menuItem title="Make Upper Case" id="vmV-6d-7jI"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/> + </connections> + </menuItem> + <menuItem title="Make Lower Case" id="d9M-CD-aMd"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/> + </connections> + </menuItem> + <menuItem title="Capitalize" id="UEZ-Bs-lqG"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Speech" id="xrE-MZ-jX0"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Speech" id="3rS-ZA-NoH"> + <items> + <menuItem title="Start Speaking" id="Ynk-f8-cLZ"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/> + </connections> + </menuItem> + <menuItem title="Stop Speaking" id="Oyz-dy-DGm"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Format" id="jxT-CU-nIS"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Format" id="GEO-Iw-cKr"> + <items> + <menuItem title="Font" id="Gi5-1S-RQB"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Font" systemMenu="font" id="aXa-aM-Jaq"> + <items> + <menuItem title="Show Fonts" keyEquivalent="t" id="Q5e-8K-NDq"> + <connections> + <action selector="orderFrontFontPanel:" target="YLy-65-1bz" id="WHr-nq-2xA"/> + </connections> + </menuItem> + <menuItem title="Bold" tag="2" keyEquivalent="b" id="GB9-OM-e27"> + <connections> + <action selector="addFontTrait:" target="YLy-65-1bz" id="hqk-hr-sYV"/> + </connections> + </menuItem> + <menuItem title="Italic" tag="1" keyEquivalent="i" id="Vjx-xi-njq"> + <connections> + <action selector="addFontTrait:" target="YLy-65-1bz" id="IHV-OB-c03"/> + </connections> + </menuItem> + <menuItem title="Underline" keyEquivalent="u" id="WRG-CD-K1S"> + <connections> + <action selector="underline:" target="-1" id="FYS-2b-JAY"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="5gT-KC-WSO"/> + <menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ptp-SP-VEL"> + <connections> + <action selector="modifyFont:" target="YLy-65-1bz" id="Uc7-di-UnL"/> + </connections> + </menuItem> + <menuItem title="Smaller" tag="4" keyEquivalent="-" id="i1d-Er-qST"> + <connections> + <action selector="modifyFont:" target="YLy-65-1bz" id="HcX-Lf-eNd"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="kx3-Dk-x3B"/> + <menuItem title="Kern" id="jBQ-r6-VK2"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Kern" id="tlD-Oa-oAM"> + <items> + <menuItem title="Use Default" id="GUa-eO-cwY"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="useStandardKerning:" target="-1" id="6dk-9l-Ckg"/> + </connections> + </menuItem> + <menuItem title="Use None" id="cDB-IK-hbR"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="turnOffKerning:" target="-1" id="U8a-gz-Maa"/> + </connections> + </menuItem> + <menuItem title="Tighten" id="46P-cB-AYj"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="tightenKerning:" target="-1" id="hr7-Nz-8ro"/> + </connections> + </menuItem> + <menuItem title="Loosen" id="ogc-rX-tC1"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="loosenKerning:" target="-1" id="8i4-f9-FKE"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Ligatures" id="o6e-r0-MWq"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Ligatures" id="w0m-vy-SC9"> + <items> + <menuItem title="Use Default" id="agt-UL-0e3"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="useStandardLigatures:" target="-1" id="7uR-wd-Dx6"/> + </connections> + </menuItem> + <menuItem title="Use None" id="J7y-lM-qPV"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="turnOffLigatures:" target="-1" id="iX2-gA-Ilz"/> + </connections> + </menuItem> + <menuItem title="Use All" id="xQD-1f-W4t"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="useAllLigatures:" target="-1" id="KcB-kA-TuK"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Baseline" id="OaQ-X3-Vso"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Baseline" id="ijk-EB-dga"> + <items> + <menuItem title="Use Default" id="3Om-Ey-2VK"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="unscript:" target="-1" id="0vZ-95-Ywn"/> + </connections> + </menuItem> + <menuItem title="Superscript" id="Rqc-34-cIF"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="superscript:" target="-1" id="3qV-fo-wpU"/> + </connections> + </menuItem> + <menuItem title="Subscript" id="I0S-gh-46l"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="subscript:" target="-1" id="Q6W-4W-IGz"/> + </connections> + </menuItem> + <menuItem title="Raise" id="2h7-ER-AoG"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="raiseBaseline:" target="-1" id="4sk-31-7Q9"/> + </connections> + </menuItem> + <menuItem title="Lower" id="1tx-W0-xDw"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="lowerBaseline:" target="-1" id="OF1-bc-KW4"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem isSeparatorItem="YES" id="Ndw-q3-faq"/> + <menuItem title="Show Colors" keyEquivalent="C" id="bgn-CT-cEk"> + <connections> + <action selector="orderFrontColorPanel:" target="-1" id="mSX-Xz-DV3"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="iMs-zA-UFJ"/> + <menuItem title="Copy Style" keyEquivalent="c" id="5Vv-lz-BsD"> + <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> + <connections> + <action selector="copyFont:" target="-1" id="GJO-xA-L4q"/> + </connections> + </menuItem> + <menuItem title="Paste Style" keyEquivalent="v" id="vKC-jM-MkH"> + <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> + <connections> + <action selector="pasteFont:" target="-1" id="JfD-CL-leO"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Text" id="Fal-I4-PZk"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Text" id="d9c-me-L2H"> + <items> + <menuItem title="Align Left" keyEquivalent="{" id="ZM1-6Q-yy1"> + <connections> + <action selector="alignLeft:" target="-1" id="zUv-R1-uAa"/> + </connections> + </menuItem> + <menuItem title="Center" keyEquivalent="|" id="VIY-Ag-zcb"> + <connections> + <action selector="alignCenter:" target="-1" id="spX-mk-kcS"/> + </connections> + </menuItem> + <menuItem title="Justify" id="J5U-5w-g23"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="alignJustified:" target="-1" id="ljL-7U-jND"/> + </connections> + </menuItem> + <menuItem title="Align Right" keyEquivalent="}" id="wb2-vD-lq4"> + <connections> + <action selector="alignRight:" target="-1" id="r48-bG-YeY"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="4s2-GY-VfK"/> + <menuItem title="Writing Direction" id="H1b-Si-o9J"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Writing Direction" id="8mr-sm-Yjd"> + <items> + <menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH"> + <modifierMask key="keyEquivalentModifierMask"/> + </menuItem> + <menuItem id="YGs-j5-SAR"> + <string key="title"> Default</string> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="makeBaseWritingDirectionNatural:" target="-1" id="qtV-5e-UBP"/> + </connections> + </menuItem> + <menuItem id="Lbh-J2-qVU"> + <string key="title"> Left to Right</string> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="makeBaseWritingDirectionLeftToRight:" target="-1" id="S0X-9S-QSf"/> + </connections> + </menuItem> + <menuItem id="jFq-tB-4Kx"> + <string key="title"> Right to Left</string> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="makeBaseWritingDirectionRightToLeft:" target="-1" id="5fk-qB-AqJ"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="swp-gr-a21"/> + <menuItem title="Selection" enabled="NO" id="cqv-fj-IhA"> + <modifierMask key="keyEquivalentModifierMask"/> + </menuItem> + <menuItem id="Nop-cj-93Q"> + <string key="title"> Default</string> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="makeTextWritingDirectionNatural:" target="-1" id="lPI-Se-ZHp"/> + </connections> + </menuItem> + <menuItem id="BgM-ve-c93"> + <string key="title"> Left to Right</string> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="makeTextWritingDirectionLeftToRight:" target="-1" id="caW-Bv-w94"/> + </connections> + </menuItem> + <menuItem id="RB4-Sm-HuC"> + <string key="title"> Right to Left</string> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="makeTextWritingDirectionRightToLeft:" target="-1" id="EXD-6r-ZUu"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem isSeparatorItem="YES" id="fKy-g9-1gm"/> + <menuItem title="Show Ruler" id="vLm-3I-IUL"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="toggleRuler:" target="-1" id="FOx-HJ-KwY"/> + </connections> + </menuItem> + <menuItem title="Copy Ruler" keyEquivalent="c" id="MkV-Pr-PK5"> + <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/> + <connections> + <action selector="copyRuler:" target="-1" id="71i-fW-3W2"/> + </connections> + </menuItem> + <menuItem title="Paste Ruler" keyEquivalent="v" id="LVM-kO-fVI"> + <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/> + <connections> + <action selector="pasteRuler:" target="-1" id="cSh-wd-qM2"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="View" id="H8h-7b-M4v"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="View" id="HyV-fh-RgO"> + <items> + <menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5"> + <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> + <connections> + <action selector="toggleToolbarShown:" target="-1" id="BXY-wc-z0C"/> + </connections> + </menuItem> + <menuItem title="Customize Toolbar…" id="1UK-8n-QPP"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="runToolbarCustomizationPalette:" target="-1" id="pQI-g3-MTW"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Window" id="aUF-d1-5bR"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo"> + <items> + <menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV"> + <connections> + <action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/> + </connections> + </menuItem> + <menuItem title="Zoom" id="R4o-n2-Eq4"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="performZoom:" target="-1" id="DIl-cC-cCs"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/> + <menuItem title="Bring All to Front" id="LE2-aR-0XJ"> + <modifierMask key="keyEquivalentModifierMask"/> + <connections> + <action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + <menuItem title="Help" id="wpr-3q-Mcd"> + <modifierMask key="keyEquivalentModifierMask"/> + <menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ"> + <items> + <menuItem title="CocoaExample Help" keyEquivalent="?" id="FKE-Sm-Kum"> + <connections> + <action selector="showHelp:" target="-1" id="y7X-2Q-9no"/> + </connections> + </menuItem> + </items> + </menu> + </menuItem> + </items> + </menu> + <window title="CocoaExample" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g"> + <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> + <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> + <rect key="contentRect" x="335" y="390" width="480" height="360"/> + <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/> + <view key="contentView" id="EiT-Mj-1SZ"> + <rect key="frame" x="0.0" y="0.0" width="480" height="360"/> + <autoresizingMask key="autoresizingMask"/> + </view> + </window> + </objects> +</document> diff --git a/Tests/XCTest/CocoaExample/main.m b/Tests/XCTest/CocoaExample/main.m new file mode 100644 index 0000000..8a6799b --- /dev/null +++ b/Tests/XCTest/CocoaExample/main.m @@ -0,0 +1,5 @@ +#import <Cocoa/Cocoa.h> + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} diff --git a/Tests/XCTest/CocoaExampleTests/CocoaExampleTests.m b/Tests/XCTest/CocoaExampleTests/CocoaExampleTests.m new file mode 100644 index 0000000..70d61d6 --- /dev/null +++ b/Tests/XCTest/CocoaExampleTests/CocoaExampleTests.m @@ -0,0 +1,13 @@ +#import <XCTest/XCTest.h> + +@interface CocoaExampleTests : XCTestCase + +@end + +@implementation CocoaExampleTests + +- (void)testExample { + XCTAssert(YES, @"Pass"); +} + +@end diff --git a/Tests/XCTest/FrameworkExample/FrameworkExample.c b/Tests/XCTest/FrameworkExample/FrameworkExample.c new file mode 100644 index 0000000..2da78da --- /dev/null +++ b/Tests/XCTest/FrameworkExample/FrameworkExample.c @@ -0,0 +1,6 @@ +#include "FrameworkExample.h" + +int FourtyTwo() +{ + return 42; +} diff --git a/Tests/XCTest/FrameworkExample/FrameworkExample.h b/Tests/XCTest/FrameworkExample/FrameworkExample.h new file mode 100644 index 0000000..2e0b499 --- /dev/null +++ b/Tests/XCTest/FrameworkExample/FrameworkExample.h @@ -0,0 +1 @@ +int FourtyTwo(); diff --git a/Tests/XCTest/FrameworkExample/Info.plist b/Tests/XCTest/FrameworkExample/Info.plist new file mode 100644 index 0000000..a22acea --- /dev/null +++ b/Tests/XCTest/FrameworkExample/Info.plist @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>FrameworkExample</string> + <key>CFBundleIdentifier</key> + <string>org.cmake.FrameworkExample</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>FrameworkExample</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string></string> + <key>NSHumanReadableCopyright</key> + <string></string> + <key>NSPrincipalClass</key> + <string></string> +</dict> +</plist> diff --git a/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m b/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m new file mode 100644 index 0000000..7cba23e --- /dev/null +++ b/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m @@ -0,0 +1,16 @@ +#import <XCTest/XCTest.h> + +#import "FrameworkExample/FrameworkExample.h" + +@interface FrameworkExampleTests : XCTestCase + +@end + +@implementation FrameworkExampleTests + +- (void)testFourtyTwo { + // This is an example of a functional test case. + XCTAssertEqual(42, FourtyTwo()); +} + +@end diff --git a/Tests/XCTest/FrameworkExampleTests/Info.plist b/Tests/XCTest/FrameworkExampleTests/Info.plist new file mode 100644 index 0000000..293921b --- /dev/null +++ b/Tests/XCTest/FrameworkExampleTests/Info.plist @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>FrameworkExampleTests</string> + <key>CFBundleIdentifier</key> + <string>org.cmake.FrameworkExampleTests</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>FrameworkExampleTests</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> +</dict> +</plist> diff --git a/Utilities/KWIML/ABI.h.in b/Utilities/KWIML/ABI.h.in index 21c9139..6300ada 100644 --- a/Utilities/KWIML/ABI.h.in +++ b/Utilities/KWIML/ABI.h.in @@ -432,6 +432,12 @@ suppression macro @KWIML@_ABI_NO_VERIFY was defined. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG # endif +/* Xtensa */ +#elif defined(__XTENSA_EB__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(__XTENSA_EL__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + /* Unknown CPU */ #elif !defined(@KWIML@_ABI_NO_ERROR_ENDIAN) # error "Byte order of target CPU unknown." diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index a58604e..da81752 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -159,7 +159,6 @@ if(SPHINX_HTML) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_DOC_DIR} PATTERN .buildinfo EXCLUDE - PATTERN objects.inv EXCLUDE ) endif() @@ -167,7 +166,6 @@ if(SPHINX_SINGLEHTML) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/singlehtml DESTINATION ${CMAKE_DOC_DIR} PATTERN .buildinfo EXCLUDE - PATTERN objects.inv EXCLUDE ) endif() diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 08bdff5..32e4561 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -524,12 +524,18 @@ check_include_file("features.h" HAVE_FEATURES_H) if(NOT UNIX) check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) -endif(NOT UNIX) +else() + set(HAVE_WS2TCPIP_H 0) + set(HAVE_WINSOCK2_H 0) +endif() check_include_file_concat("stdio.h" HAVE_STDIO_H) if(NOT UNIX) check_include_file_concat("windows.h" HAVE_WINDOWS_H) check_include_file_concat("winsock.h" HAVE_WINSOCK_H) -endif(NOT UNIX) +else() + set(HAVE_WINDOWS_H 0) + set(HAVE_WINSOCK_H 0) +endif() check_include_file_concat("inttypes.h" HAVE_INTTYPES_H) check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H) diff --git a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp index 7f8e6f1..15222d6 100644 --- a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp +++ b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp @@ -27,6 +27,20 @@ # define isfinite finite #endif +// AIX +#if defined(_AIX) +# if !defined(isfinite) +# define isfinite finite +# endif +#endif + +// HP-UX +#if defined(__hpux) +# if !defined(isfinite) +# define isfinite finite +# endif +#endif + // Ancient glibc #if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 2 # if !defined(isfinite) diff --git a/Utilities/cmliblzma/config.h.in b/Utilities/cmliblzma/config.h.in index 017c435..9c53150 100644 --- a/Utilities/cmliblzma/config.h.in +++ b/Utilities/cmliblzma/config.h.in @@ -280,4 +280,10 @@ typedef uint64_t uintmax_t; /* Define to 1 if the system supports fast unaligned access to 16-bit and 32-bit integers. */ -#define TUKLIB_FAST_UNALIGNED_ACCESS 1 +#if defined(__i386) || defined(__i386__) || defined(_M_IX86) \ + || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \ + || defined(__amd64) || defined(__amd64__) \ + || defined(__powerpc) || defined(__powerpc__) \ + || defined(__ppc) || defined(__ppc__) || defined(__POWERPC__) +# define TUKLIB_FAST_UNALIGNED_ACCESS 1 +#endif diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c index d3a6348..fc54d8d 100644 --- a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c +++ b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c @@ -8,6 +8,9 @@ // You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// +#if defined(__IBMC__) +# pragma options optimize=0 +#endif #include "lzma_encoder_private.h" #include "fastpos.h" |