diff options
60 files changed, 1330 insertions, 237 deletions
diff --git a/Help/command/ctest_start.rst b/Help/command/ctest_start.rst index 63db32f..6db9a48 100644 --- a/Help/command/ctest_start.rst +++ b/Help/command/ctest_start.rst @@ -5,21 +5,78 @@ Starts the testing for a given model :: - ctest_start(Model [TRACK <track>] [APPEND] [source [binary]] [QUIET]) + ctest_start(<model> [<source> [<binary>]] [TRACK <track>] [QUIET]) + + ctest_start([<model> [<source> [<binary>]]] [TRACK <track>] APPEND [QUIET]) Starts the testing for a given model. The command should be called -after the binary directory is initialized. If the 'source' and -'binary' directory are not specified, it reads the -:variable:`CTEST_SOURCE_DIRECTORY` and :variable:`CTEST_BINARY_DIRECTORY`. -If the track is -specified, the submissions will go to the specified track. If APPEND -is used, the existing TAG is used rather than creating a new one based -on the current time stamp. If ``QUIET`` is used, CTest will suppress any -non-error messages that it otherwise would have printed to the console. - -If the :variable:`CTEST_CHECKOUT_COMMAND` variable -(or the :variable:`CTEST_CVS_CHECKOUT` variable) -is set, its content is treated as command-line. The command is -invoked with the current working directory set to the parent of the source -directory, even if the source directory already exists. This can be used -to create the source tree from a version control repository. +after the binary directory is initialized. + +The parameters are as follows: + +``<model>`` + Set the dashboard model. Must be one of ``Experimental``, ``Continuous``, or + ``Nightly``. This parameter is required unless ``APPEND`` is specified. + +``<source>`` + Set the source directory. If not specified, the value of + :variable:`CTEST_SOURCE_DIRECTORY` is used instead. + +``<binary>`` + Set the binary directory. If not specified, the value of + :variable:`CTEST_BINARY_DIRECTORY` is used instead. + +``TRACK <track>`` + If ``TRACK`` is used, the submissions will go to the specified track on the + CDash server. If no ``TRACK`` is specified, the name of the model is used by + default. + +``APPEND`` + If ``APPEND`` is used, the existing ``TAG`` is used rather than creating a new + one based on the current time stamp. If you use ``APPEND``, you can omit the + ``<model>`` and ``TRACK <track>`` parameters, because they will be read from + the generated ``TAG`` file. For example: + + .. code-block:: cmake + + ctest_start(Experimental TRACK TrackExperimental) + + Later, in another ``ctest -S`` script: + + .. code-block:: cmake + + ctest_start(APPEND) + + When the second script runs ``ctest_start(APPEND)``, it will read the + ``Experimental`` model and ``TrackExperimental`` track from the ``TAG`` file + generated by the first ``ctest_start()`` command. Please note that if you + call ``ctest_start(APPEND)`` and specify a different model or track than + in the first ``ctest_start()`` command, a warning will be issued, and the + new model and track will be used. + +``QUIET`` + If ``QUIET`` is used, CTest will suppress any non-error messages that it + otherwise would have printed to the console. + +The parameters for ``ctest_start()`` can be issued in any order, with the +exception that ``<model>``, ``<source>``, and ``<binary>`` have to appear +in that order with respect to each other. The following are all valid and +equivalent: + +.. code-block:: cmake + + ctest_start(Experimental path/to/source path/to/binary TRACK SomeTrack QUIET APPEND) + + ctest_start(TRACK SomeTrack Experimental QUIET path/to/source APPEND path/to/binary) + + ctest_start(APPEND QUIET Experimental path/to/source TRACK SomeTrack path/to/binary) + +However, for the sake of readability, it is recommended that you order your +parameters in the order listed at the top of this page. + +If the :variable:`CTEST_CHECKOUT_COMMAND` variable (or the +:variable:`CTEST_CVS_CHECKOUT` variable) is set, its content is treated as +command-line. The command is invoked with the current working directory set +to the parent of the source directory, even if the source directory already +exists. This can be used to create the source tree from a version control +repository. diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 070c6ed..3bfaa54 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -64,6 +64,7 @@ All Modules /module/CPackIFW /module/CPackIFWConfigureFile /module/CPackNSIS + /module/CPackNuGet /module/CPackPackageMaker /module/CPackProductBuild /module/CPackRPM diff --git a/Help/module/CPackNuGet.rst b/Help/module/CPackNuGet.rst new file mode 100644 index 0000000..a4cbb59 --- /dev/null +++ b/Help/module/CPackNuGet.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CPackNuGet.cmake diff --git a/Help/release/3.11.rst b/Help/release/3.11.rst index dbaa8af..184497c 100644 --- a/Help/release/3.11.rst +++ b/Help/release/3.11.rst @@ -283,3 +283,12 @@ Changes made since CMake 3.11.0 include the following. CMake 3.11.0. This has been reverted due to changing behavior of checks for existing projects. It may be restored in the future with a policy for compatibility. + +3.11.2 +------ + +* Calling :command:`add_library` to create an alias of an imported + target that is not globally visible now causes an error again as + it did prior to 3.11.0. This diagnostic was accidentally dropped + from CMake 3.11.0 and 3.11.1 by the change to allow globally visible + imported targets to be aliased. diff --git a/Help/release/dev/cpack-nuget.rst b/Help/release/dev/cpack-nuget.rst new file mode 100644 index 0000000..03cb101 --- /dev/null +++ b/Help/release/dev/cpack-nuget.rst @@ -0,0 +1,7 @@ +cpack-nuget +----------- + +* :manual:`cpack(1)` gained basic support for `NuGet`_. + See the :module:`CPackNuGet` module. + +.. _NuGet: https://docs.microsoft.com/en-us/nuget/what-is-nuget diff --git a/Help/release/dev/ctest-start-args-rework.rst b/Help/release/dev/ctest-start-args-rework.rst new file mode 100644 index 0000000..cbe6652 --- /dev/null +++ b/Help/release/dev/ctest-start-args-rework.rst @@ -0,0 +1,7 @@ +ctest-start-args-rework +----------------------- + +* The :command:`ctest_start` command has been reworked so that you can simply + call ``ctest_start(APPEND)`` and it will read all the needed information from + the TAG file. The argument parsing has also been relaxed so that the order of + the arguments is less significant. diff --git a/Modules/CPack.NuGet.nuspec.in b/Modules/CPack.NuGet.nuspec.in new file mode 100644 index 0000000..b7beb5d --- /dev/null +++ b/Modules/CPack.NuGet.nuspec.in @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> + <metadata> + <!-- Required elements--> + <id>@CPACK_NUGET_PACKAGE_NAME@</id> + <version>@CPACK_NUGET_PACKAGE_VERSION@</version> + <description>@CPACK_NUGET_PACKAGE_DESCRIPTION@</description> + <authors>@CPACK_NUGET_PACKAGE_AUTHORS@</authors> + + <!-- Optional elements --> + @_CPACK_NUGET_TITLE_TAG@ + @_CPACK_NUGET_OWNERS_TAG@ + @_CPACK_NUGET_PROJECTURL_TAG@ + @_CPACK_NUGET_LICENSEURL_TAG@ + @_CPACK_NUGET_ICONURL_TAG@ + @_CPACK_NUGET_REQUIRELICENSEACCEPTANCE_TAG@ + @_CPACK_NUGET_SUMMARY_TAG@ + @_CPACK_NUGET_RELEASENOTES_TAG@ + @_CPACK_NUGET_COPYRIGHT_TAG@ + @_CPACK_NUGET_TAGS_TAG@ + @_CPACK_NUGET_DEPENDENCIES_TAG@ + </metadata> + @_CPACK_NUGET_FILES_TAG@ +</package> diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 05fb78a..8070869 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -544,10 +544,11 @@ if(NOT CPACK_GENERATOR) option(CPACK_BINARY_TXZ "Enable to build TXZ packages" OFF) endif() else() - option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF) - option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON) - option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF) - option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF) + option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF) + option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON) + option(CPACK_BINARY_NUGET "Enable to build NuGet packages" OFF) + option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF) + option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF) endif() option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF) @@ -559,6 +560,7 @@ if(NOT CPACK_GENERATOR) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_FREEBSD FREEBSD) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_IFW IFW) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS) + cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NUGET NuGet) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild) @@ -611,6 +613,7 @@ mark_as_advanced( CPACK_BINARY_FREEBSD CPACK_BINARY_IFW CPACK_BINARY_NSIS + CPACK_BINARY_NUGET CPACK_BINARY_OSXX11 CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_PRODUCTBUILD diff --git a/Modules/CPackNuGet.cmake b/Modules/CPackNuGet.cmake new file mode 100644 index 0000000..29d4296 --- /dev/null +++ b/Modules/CPackNuGet.cmake @@ -0,0 +1,556 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CPackNuGet +---------- + +When build a NuGet pacakge there is no direct way to control an output +filename due a lack of the corresponding CLI option of NuGet, so there +is no ``CPACK_NUGET_PACKAGE_FILENAME`` variable. To form the output filename +NuGet uses the package name and the version according to its built-in rules. + +Also, be aware that including a top level directory +(``CPACK_INCLUDE_TOPLEVEL_DIRECTORY``) is ignored by this generator. + + +Variables specific to CPack NuGet generator +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +CPackNuGet may be used to create NuGet packages using :module:`CPack`. +CPackNuGet is a :module:`CPack` generator thus it uses the ``CPACK_XXX`` +variables used by :module:`CPack`. + +CPackNuGet has specific features which are controlled by the specifics +:code:`CPACK_NUGET_XXX` variables. In the "one per group" mode +(see :variable:`CPACK_COMPONENTS_GROUPING`), ``<compName>`` placeholder +in the variables below would contain a group name (uppercased and turned into +a "C" identifier). + +List of CPackNuGet specific variables: + +.. variable:: CPACK_NUGET_COMPONENT_INSTALL + + Enable component packaging for CPackNuGet + + * Mandatory : NO + * Default : OFF + +.. variable:: CPACK_NUGET_PACKAGE_NAME + CPACK_NUGET_<compName>_PACKAGE_NAME + + The NUGET package name. + + * Mandatory : YES + * Default : :variable:`CPACK_PACKAGE_NAME` + +.. variable:: CPACK_NUGET_PACKAGE_VERSION + CPACK_NUGET_<compName>_PACKAGE_VERSION + + The NuGet package version. + + * Mandatory : YES + * Default : :variable:`CPACK_PACKAGE_VERSION` + +.. variable:: CPACK_NUGET_PACKAGE_DESCRIPTION + CPACK_NUGET_<compName>_PACKAGE_DESCRIPTION + + A long description of the package for UI display. + + * Mandatory : YES + * Default : + - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION`, + - ``CPACK_COMPONENT_GROUP_<groupName>_DESCRIPTION``, + - :variable:`CPACK_PACKAGE_DESCRIPTION` + + .. variable:: CPACK_NUGET_PACKAGE_AUTHORS + CPACK_NUGET_<compName>_PACKAGE_AUTHORS + + A comma-separated list of packages authors, matching the profile names + on nuget.org_. These are displayed in the NuGet Gallery on + nuget.org_ and are used to cross-reference packages by the same + authors. + + * Mandatory : YES + * Default : :variable:`CPACK_PACKAGE_VENDOR` + +.. variable:: CPACK_NUGET_PACKAGE_TITLE + CPACK_NUGET_<compName>_PACKAGE_TITLE + + A human-friendly title of the package, typically used in UI displays + as on nuget.org_ and the Package Manager in Visual Studio. If not + specified, the package ID is used. + + * Mandatory : NO + * Default : + - :variable:`CPACK_COMPONENT_<compName>_DISPLAY_NAME`, + - ``CPACK_COMPONENT_GROUP_<groupName>_DISPLAY_NAME`` + +.. variable:: CPACK_NUGET_PACKAGE_OWNERS + CPACK_NUGET_<compName>_PACKAGE_OWNERS + + A comma-separated list of the package creators using profile names + on nuget.org_. This is often the same list as in authors, + and is ignored when uploading the package to nuget.org_. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_HOMEPAGE_URL + CPACK_NUGET_<compName>_PACKAGE_HOMEPAGE_URL + + A URL for the package's home page, often shown in UI displays as well + as nuget.org_. + + * Mandatory : NO + * Default : :variable:`CPACK_PACKAGE_HOMEPAGE_URL` + +.. variable:: CPACK_NUGET_PACKAGE_LICENSEURL + CPACK_NUGET_<compName>_PACKAGE_LICENSEURL + + A URL for the package's license, often shown in UI displays as well + as nuget.org_. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_ICONURL + CPACK_NUGET_<compName>_PACKAGE_ICONURL + + A URL for a 64x64 image with transparency background to use as the + icon for the package in UI display. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_DESCRIPTION_SUMMARY + CPACK_NUGET_<compName>_PACKAGE_DESCRIPTION_SUMMARY + + A short description of the package for UI display. If omitted, a + truncated version of description is used. + + * Mandatory : NO + * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` + +.. variable:: CPACK_NUGET_PACKAGE_RELEASE_NOTES + CPACK_NUGET_<compName>_PACKAGE_RELEASE_NOTES + + A description of the changes made in this release of the package, + often used in UI like the Updates tab of the Visual Studio Package + Manager in place of the package description. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_COPYRIGHT + CPACK_NUGET_<compName>_PACKAGE_COPYRIGHT + + Copyright details for the package. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_TAGS + CPACK_NUGET_<compName>_PACKAGE_TAGS + + A space-delimited list of tags and keywords that describe the + package and aid discoverability of packages through search and + filtering. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES + CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES + + A list of package dependencies. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES_<dependency>_VERSION + CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES_<dependency>_VERSION + + A `version specification`_ for the particular dependency, where + ``<dependency>`` is an item of the dependency list (see above) + transformed with ``MAKE_C_IDENTIFIER`` function of :command:`string` + command. + + * Mandatory : NO + * Default : - + +.. variable:: CPACK_NUGET_PACKAGE_DEBUG + + Enable debug messages while executing ``CPackNuGet.cmake``. + + * Mandatory : NO + * Default : OFF + + +.. _nuget.org: http://nuget.org +.. _version specification: https://docs.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards + +.. NuGet spec docs https://docs.microsoft.com/en-us/nuget/reference/nuspec + +#]=======================================================================] + +# Author: Alex Turbov + +if(CMAKE_BINARY_DIR) + message(FATAL_ERROR "CPackNuGet.cmake may only be used by CPack internally.") +endif() + +function(_cpack_nuget_debug) + if(CPACK_NUGET_PACKAGE_DEBUG) + message("CPackNuGet:Debug: " ${ARGN}) + endif() +endfunction() + +function(_cpack_nuget_debug_var NAME) + if(CPACK_NUGET_PACKAGE_DEBUG) + message("CPackNuGet:Debug: ${NAME}=`${${NAME}}`") + endif() +endfunction() + +function(_cpack_nuget_variable_fallback OUTPUT_VAR_NAME NUGET_VAR_NAME) + if(ARGN) + list(JOIN ARGN "`, `" _va_args) + set(_va_args ", ARGN: `${_va_args}`") + endif() + _cpack_nuget_debug( + "_cpack_nuget_variable_fallback: " + "OUTPUT_VAR_NAME=`${OUTPUT_VAR_NAME}`, " + "NUGET_VAR_NAME=`${NUGET_VAR_NAME}`" + "${_va_args}" + ) + + set(_options USE_CDATA) + set(_one_value_args LIST_GLUE) + set(_multi_value_args FALLBACK_VARS) + cmake_parse_arguments(PARSE_ARGV 0 _args "${_options}" "${_one_value_args}" "${_multi_value_args}") + + if(CPACK_NUGET_PACKAGE_COMPONENT) + string( + TOUPPER "${CPACK_NUGET_PACKAGE_COMPONENT}" + CPACK_NUGET_PACKAGE_COMPONENT_UPPER + ) + endif() + + if(CPACK_NUGET_PACKAGE_COMPONENT + AND CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_PACKAGE_${NUGET_VAR_NAME} + ) + set( + _result + "${CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_PACKAGE_${NUGET_VAR_NAME}}" + ) + _cpack_nuget_debug( + " CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_PACKAGE_${NUGET_VAR_NAME}: " + "OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`" + ) + + elseif(CPACK_NUGET_PACKAGE_COMPONENT_UPPER + AND CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_${NUGET_VAR_NAME} + ) + set( + _result + "${CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_${NUGET_VAR_NAME}}" + ) + _cpack_nuget_debug( + " CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_${NUGET_VAR_NAME}: " + "OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`" + ) + + elseif(CPACK_NUGET_PACKAGE_${NUGET_VAR_NAME}) + set(_result "${CPACK_NUGET_PACKAGE_${NUGET_VAR_NAME}}") + _cpack_nuget_debug( + " CPACK_NUGET_PACKAGE_${NUGET_VAR_NAME}: " + "OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`" + ) + + else() + foreach(_var IN LISTS _args_FALLBACK_VARS) + _cpack_nuget_debug(" Fallback: ${_var} ...") + if(${_var}) + _cpack_nuget_debug(" ${_var}=`${${_var}}`") + set(_result "${${_var}}") + _cpack_nuget_debug( + " ${_var}: OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`" + ) + break() + endif() + endforeach() + endif() + + if(_result) + if(_args_USE_CDATA) + set(_value_before "<![CDATA[") + set(_value_after "]]>") + endif() + + list(LENGTH _result _result_len) + if(_result_len GREATER 1 AND _args_LIST_GLUE) + list(JOIN _result "${_args_LIST_GLUE}" _result) + endif() + + set(${OUTPUT_VAR_NAME} "${_value_before}${_result}${_value_after}" PARENT_SCOPE) + endif() + +endfunction() + +function(_cpack_nuget_variable_fallback_and_wrap_into_element ELEMENT NUGET_VAR_NAME) + set(_options) + set(_one_value_args) + set(_multi_value_args FALLBACK_VARS) + cmake_parse_arguments(PARSE_ARGV 0 _args "${_options}" "${_one_value_args}" "${_multi_value_args}") + + _cpack_nuget_variable_fallback(_value ${NUGET_VAR_NAME} ${ARGN} USE_CDATA) + + if(_value) + string(TOUPPER "${ELEMENT}" _ELEMENT_UP) + set( + _CPACK_NUGET_${_ELEMENT_UP}_TAG + "<${ELEMENT}>${_value}</${ELEMENT}>" + PARENT_SCOPE + ) + endif() +endfunction() + +# Print some debug info +_cpack_nuget_debug("---[CPack NuGet Input Variables]---") +_cpack_nuget_debug_var(CPACK_PACKAGE_NAME) +_cpack_nuget_debug_var(CPACK_PACKAGE_VERSION) +_cpack_nuget_debug_var(CPACK_TOPLEVEL_TAG) +_cpack_nuget_debug_var(CPACK_TOPLEVEL_DIRECTORY) +_cpack_nuget_debug_var(CPACK_TEMPORARY_DIRECTORY) +_cpack_nuget_debug_var(CPACK_NUGET_GROUPS) +if(CPACK_NUGET_GROUPS) + foreach(_group IN LISTS CPACK_NUGET_GROUPS) + string(MAKE_C_IDENTIFIER "${_group}" _group_up) + string(TOUPPER "${_group_up}" _group_up) + _cpack_nuget_debug_var(CPACK_NUGET_${_group_up}_GROUP_COMPONENTS) + endforeach() +endif() +_cpack_nuget_debug_var(CPACK_NUGET_COMPONENTS) +_cpack_nuget_debug_var(CPACK_NUGET_ALL_IN_ONE) +_cpack_nuget_debug_var(CPACK_NUGET_ORDINAL_MONOLITIC) +_cpack_nuget_debug("-----------------------------------") + +function(_cpack_nuget_render_spec) + # Make a variable w/ upper-cased component name + if(CPACK_NUGET_PACKAGE_COMPONENT) + string(TOUPPER "${CPACK_NUGET_PACKAGE_COMPONENT}" CPACK_NUGET_PACKAGE_COMPONENT_UPPER) + endif() + + # Set mandatory variables (not wrapped into XML elements) + # https://docs.microsoft.com/en-us/nuget/reference/nuspec#required-metadata-elements + if(CPACK_NUGET_PACKAGE_COMPONENT) + if(CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME) + set( + CPACK_NUGET_PACKAGE_NAME + "${CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME}" + ) + elseif(NOT CPACK_NUGET_PACKAGE_COMPONENT STREQUAL "Unspecified") + set( + CPACK_NUGET_PACKAGE_NAME + "${CPACK_PACKAGE_NAME}.${CPACK_NUGET_PACKAGE_COMPONENT}" + ) + else() + set(CPACK_NUGET_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") + endif() + elseif(NOT CPACK_NUGET_PACKAGE_NAME) + set(CPACK_NUGET_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") + endif() + + _cpack_nuget_variable_fallback( + CPACK_NUGET_PACKAGE_VERSION VERSION + FALLBACK_VARS + CPACK_PACKAGE_VERSION + ) + _cpack_nuget_variable_fallback( + CPACK_NUGET_PACKAGE_DESCRIPTION DESCRIPTION + FALLBACK_VARS + CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT}_DESCRIPTION + CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DESCRIPTION + CPACK_COMPONENT_GROUP_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DESCRIPTION + CPACK_PACKAGE_DESCRIPTION + USE_CDATA + ) + _cpack_nuget_variable_fallback( + CPACK_NUGET_PACKAGE_AUTHORS AUTHORS + FALLBACK_VARS + CPACK_PACKAGE_VENDOR + USE_CDATA + LIST_GLUE "," + ) + + # Set optional variables (wrapped into XML elements) + # https://docs.microsoft.com/en-us/nuget/reference/nuspec#optional-metadata-elements + _cpack_nuget_variable_fallback_and_wrap_into_element( + title + TITLE + FALLBACK_VARS + CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT}_DISPLAY_NAME + CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DISPLAY_NAME + CPACK_COMPONENT_GROUP_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DISPLAY_NAME + ) + _cpack_nuget_variable_fallback_and_wrap_into_element(owners OWNERS LIST_GLUE ",") + _cpack_nuget_variable_fallback_and_wrap_into_element( + projectUrl + HOMEPAGE_URL + FALLBACK_VARS + CPACK_PACKAGE_HOMEPAGE_URL + ) + _cpack_nuget_variable_fallback_and_wrap_into_element(licenseUrl LICENSEURL) + _cpack_nuget_variable_fallback_and_wrap_into_element(iconUrl ICONURL) + _cpack_nuget_variable_fallback_and_wrap_into_element( + summary DESCRIPTION_SUMMARY + FALLBACK_VARS + CPACK_PACKAGE_DESCRIPTION_SUMMARY + ) + if(CPACK_NUGET_PACKAGE_REQUIRE_LICENSE_ACCEPTANCE) + set( + _CPACK_NUGET_REQUIRELICENSEACCEPTANCE_TAG + "<requireLicenseAcceptance>true</requireLicenseAcceptance>" + ) + endif() + _cpack_nuget_variable_fallback_and_wrap_into_element(releaseNotes RELEASE_NOTES) + _cpack_nuget_variable_fallback_and_wrap_into_element(copyright COPYRIGHT) + _cpack_nuget_variable_fallback_and_wrap_into_element(tags TAGS LIST_GLUE " ") + + # Handle dependencies + _cpack_nuget_variable_fallback(_deps DEPENDENCIES) + set(_collected_deps) + foreach(_dep IN LISTS _deps) + _cpack_nuget_debug(" checking dependency `${_dep}`") + + string(MAKE_C_IDENTIFIER "${_dep}" _dep_id) + + _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep_id}_VERSION) + + if(NOT _ver) + string(TOUPPER "${_dep_id}" _dep_id) + _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep_id}_VERSION) + endif() + + if(_ver) + _cpack_nuget_debug(" got `${_dep}` dependency version ${_ver}") + list(APPEND _collected_deps "<dependency id=\"${_dep}\" version=\"${_ver}\" />") + endif() + endforeach() + + # Render deps into the variable + if(_collected_deps) + set(_CPACK_NUGET_DEPENDENCIES_TAG "<dependencies>\n") + foreach(_line IN LISTS _collected_deps) + string( + APPEND _CPACK_NUGET_DEPENDENCIES_TAG + " ${_line}\n" + ) + endforeach() + string(APPEND _CPACK_NUGET_DEPENDENCIES_TAG " </dependencies>") + endif() + + # Render the spec file + # NOTE The spec filename doesn't matter. Being included into a package, + # NuGet will name it properly. + _cpack_nuget_debug("Rendering `${CPACK_TEMPORARY_DIRECTORY}/CPack.NuGet.nuspec` file...") + configure_file( + "${CMAKE_CURRENT_LIST_DIR}/CPack.NuGet.nuspec.in" + "${CPACK_TEMPORARY_DIRECTORY}/CPack.NuGet.nuspec" + @ONLY + ) +endfunction() + +function(_cpack_nuget_make_files_tag) + set(_files) + foreach(_comp IN LISTS ARGN) + string(APPEND _files " <file src=\"${_comp}\\**\" target=\".\" />\n") + endforeach() + set(_CPACK_NUGET_FILES_TAG "<files>\n${_files} </files>" PARENT_SCOPE) +endfunction() + +find_program(NUGET_EXECUTABLE NuGet) +_cpack_nuget_debug_var(NUGET_EXECUTABLE) +if(NOT NUGET_EXECUTABLE) + message(FATAL_ERROR "NuGet executable not found") +endif() + +# Add details for debug run +if(CPACK_NUGET_PACKAGE_DEBUG) + list(APPEND CPACK_NUGET_PACK_ADDITIONAL_OPTIONS "-Verbosity" "detailed") +endif() + +# Case one: ordinal all-in-one package +if(CPACK_NUGET_ORDINAL_MONOLITIC) + # This variable `CPACK_NUGET_ALL_IN_ONE` set by C++ code: + # Meaning to pack all installed files into a single package + _cpack_nuget_debug("---[Making an ordinal monolitic package]---") + _cpack_nuget_render_spec() + execute_process( + COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + ) + +elseif(CPACK_NUGET_ALL_IN_ONE) + # This variable `CPACK_NUGET_ALL_IN_ONE` set by C++ code: + # Meaning to pack all installed components into a single package + _cpack_nuget_debug("---[Making a monolitic package from installed components]---") + + # Prepare the `files` element which include files from several components + _cpack_nuget_make_files_tag(${CPACK_NUGET_COMPONENTS}) + _cpack_nuget_render_spec() + execute_process( + COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + ) + +else() + # Is there any grouped component? + if(CPACK_NUGET_GROUPS) + _cpack_nuget_debug("---[Making grouped component(s) package(s)]---") + foreach(_group IN LISTS CPACK_NUGET_GROUPS) + _cpack_nuget_debug("Starting to make the pacakge for group `${_group}`") + string(MAKE_C_IDENTIFIER "${_group}" _group_up) + string(TOUPPER "${_group_up}" _group_up) + + # Render a spec file which includes all components in the current group + unset(_CPACK_NUGET_FILES_TAG) + _cpack_nuget_make_files_tag(${CPACK_NUGET_${_group_up}_GROUP_COMPONENTS}) + # Temporary set `CPACK_NUGET_PACKAGE_COMPONENT` to the group name + # to properly collect various per group settings + set(CPACK_NUGET_PACKAGE_COMPONENT ${_group}) + _cpack_nuget_render_spec() + unset(CPACK_NUGET_PACKAGE_COMPONENT) + execute_process( + COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + ) + endforeach() + endif() + # Is there any single component package needed? + if(CPACK_NUGET_COMPONENTS) + _cpack_nuget_debug("---[Making single-component(s) package(s)]---") + foreach(_comp IN LISTS CPACK_NUGET_COMPONENTS) + _cpack_nuget_debug("Starting to make the pacakge for component `${_comp}`") + # Render a spec file which includes only given component + unset(_CPACK_NUGET_FILES_TAG) + _cpack_nuget_make_files_tag(${_comp}) + # Temporary set `CPACK_NUGET_PACKAGE_COMPONENT` to the the current + # component name to properly collect various per group settings + set(CPACK_NUGET_PACKAGE_COMPONENT ${_comp}) + _cpack_nuget_render_spec() + unset(CPACK_NUGET_PACKAGE_COMPONENT) + execute_process( + COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + ) + endforeach() + endif() +endif() + +file(GLOB_RECURSE GEN_CPACK_OUTPUT_FILES "${CPACK_TEMPORARY_DIRECTORY}/*.nupkg") +if(NOT GEN_CPACK_OUTPUT_FILES) + message(FATAL_ERROR "NuGet package was not generated at `${CPACK_TEMPORARY_DIRECTORY}`!") +endif() + +_cpack_nuget_debug("Generated files: ${GEN_CPACK_OUTPUT_FILES}") diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 5b5002a..08d9762 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -585,7 +585,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_WAVE_DEPENDENCIES filesystem system thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(NOT Boost_VERSION VERSION_LESS 103600 AND Boost_VERSION VERSION_LESS 103800) @@ -593,7 +593,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_WAVE_DEPENDENCIES filesystem system thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(NOT Boost_VERSION VERSION_LESS 103800 AND Boost_VERSION VERSION_LESS 104300) @@ -601,7 +601,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) @@ -610,7 +610,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) @@ -619,7 +619,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random serialization) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES serialization filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) @@ -628,7 +628,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) @@ -638,7 +638,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) @@ -648,7 +648,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) @@ -659,7 +659,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time) @@ -671,7 +671,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time) @@ -684,7 +684,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) @@ -697,7 +697,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) @@ -710,7 +710,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) @@ -724,7 +724,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) @@ -738,7 +738,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) @@ -753,7 +753,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) @@ -768,7 +768,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) @@ -784,28 +784,28 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(NOT Boost_VERSION VERSION_LESS 106500 AND Boost_VERSION VERSION_LESS 106700) - set(_Boost_CHRONO_DEPENDENCIES system) - set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) - set(_Boost_COROUTINE_DEPENDENCIES context system) - set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) - set(_Boost_FILESYSTEM_DEPENDENCIES system) - set(_Boost_IOSTREAMS_DEPENDENCIES regex) - set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) - set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) - set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) - set(_Boost_NUMPY_DEPENDENCIES python) - set(_Boost_RANDOM_DEPENDENCIES system) - set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) - set(_Boost_TIMER_DEPENDENCIES chrono system) - set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) - set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + set(_Boost_CHRONO_DEPENDENCIES system) + set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) + set(_Boost_COROUTINE_DEPENDENCIES context system) + set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) + set(_Boost_FILESYSTEM_DEPENDENCIES system) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) + set(_Boost_RANDOM_DEPENDENCIES system) + set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_TIMER_DEPENDENCIES chrono system) + set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() if(NOT Boost_VERSION VERSION_LESS 106700) set(_Boost_CHRONO_DEPENDENCIES system) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index dc55e86..874fb89 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -557,10 +557,10 @@ else() set(c_compiler_realpath "") endif() set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") - elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache") - # NVCC does not think it will work if it is passed clcache.exe as the host - # compiler, which means that builds with CC=cl.exe won't work. Best to just - # feed it whatever the actual cl.exe is as the host compiler. + elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") + # NVCC does not think it will work if it is passed clcache.exe or sccache.exe + # as the host compiler, which means that builds with CC=cl.exe won't work. + # Best to just feed it whatever the actual cl.exe is as the host compiler. set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") else() set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 9542f69..61a2213 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -51,7 +51,7 @@ find_path(JPEG_INCLUDE_DIR jpeglib.h) -set(jpeg_names ${JPEG_NAMES} jpeg libjpeg) +set(jpeg_names ${JPEG_NAMES} jpeg jpeg-static libjpeg libjpeg-static) foreach(name ${JPEG_NAMES}) list(APPEND jpeg_names_debug "${name}d") endforeach() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d9e07e5..316d50b 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -886,6 +886,7 @@ set(CPACK_SRCS CPack/cmCPackGenerator.cxx CPack/cmCPackLog.cxx CPack/cmCPackNSISGenerator.cxx + CPack/cmCPackNuGetGenerator.cxx CPack/cmCPackSTGZGenerator.cxx CPack/cmCPackTGZGenerator.cxx CPack/cmCPackTXZGenerator.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8758f34..bc45d57 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 11) -set(CMake_VERSION_PATCH 20180509) +set(CMake_VERSION_PATCH 20180514) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 47e7527..a395a8f 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -15,6 +15,7 @@ #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmCPackNSISGenerator.h" +#include "cmCPackNuGetGenerator.h" #include "cmCPackSTGZGenerator.h" #include "cmCPackTGZGenerator.h" #include "cmCPackTXZGenerator.h" @@ -105,6 +106,10 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("DEB", "Debian packages", cmCPackDebGenerator::CreateGenerator); } + if (cmCPackNuGetGenerator::CanGenerate()) { + this->RegisterGenerator("NuGet", "NuGet packages", + cmCPackNuGetGenerator::CreateGenerator); + } #ifdef __APPLE__ if (cmCPackDragNDropGenerator::CanGenerate()) { this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop", diff --git a/Source/CPack/cmCPackNuGetGenerator.cxx b/Source/CPack/cmCPackNuGetGenerator.cxx new file mode 100644 index 0000000..2ebfb3d --- /dev/null +++ b/Source/CPack/cmCPackNuGetGenerator.cxx @@ -0,0 +1,140 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCPackNuGetGenerator.h" + +#include "cmAlgorithms.h" +#include "cmCPackComponentGroup.h" +#include "cmCPackLog.h" +#include "cmSystemTools.h" + +#include <algorithm> +#include <iterator> +#include <map> +#include <ostream> +#include <string> +#include <utility> +#include <vector> + +bool cmCPackNuGetGenerator::SupportsComponentInstallation() const +{ + return IsOn("CPACK_NUGET_COMPONENT_INSTALL"); +} + +int cmCPackNuGetGenerator::PackageFiles() +{ + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl); + + /* Reset package file name list it will be populated after the + * `CPackNuGet.cmake` run */ + packageFileNames.clear(); + + /* Are we in the component packaging case */ + if (WantsComponentInstallation()) { + if (componentPackageMethod == ONE_PACKAGE) { + // CASE 1 : COMPONENT ALL-IN-ONE package + // Meaning that all per-component pre-installed files + // goes into the single package. + this->SetOption("CPACK_NUGET_ALL_IN_ONE", "TRUE"); + SetupGroupComponentVariables(true); + } else { + // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) + // There will be 1 package for each component group + // however one may require to ignore component group and + // in this case you'll get 1 package for each component. + SetupGroupComponentVariables(componentPackageMethod == + ONE_PACKAGE_PER_COMPONENT); + } + } else { + // CASE 3 : NON COMPONENT package. + this->SetOption("CPACK_NUGET_ORDINAL_MONOLITIC", "TRUE"); + } + + auto retval = this->ReadListFile("CPackNuGet.cmake"); + if (retval) { + AddGeneratedPackageNames(); + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackNuGet.cmake" << std::endl); + } + + return retval; +} + +void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup) +{ + // The default behavior is to have one package by component group + // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. + if (!ignoreGroup) { + std::vector<std::string> groups; + for (auto const& compG : this->ComponentGroups) { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging component group: " << compG.first << std::endl); + groups.push_back(compG.first); + auto compGUp = + cmSystemTools::UpperCase(cmSystemTools::MakeCidentifier(compG.first)); + + // Collect components for this group + std::vector<std::string> components; + std::transform(begin(compG.second.Components), + end(compG.second.Components), + std::back_inserter(components), + [](cmCPackComponent const* comp) { return comp->Name; }); + this->SetOption("CPACK_NUGET_" + compGUp + "_GROUP_COMPONENTS", + cmJoin(components, ";").c_str()); + } + if (!groups.empty()) { + this->SetOption("CPACK_NUGET_GROUPS", cmJoin(groups, ";").c_str()); + } + + // Handle Orphan components (components not belonging to any groups) + std::vector<std::string> components; + for (auto const& comp : this->Components) { + // Does the component belong to a group? + if (comp.second.Group == nullptr) { + cmCPackLogger( + cmCPackLog::LOG_VERBOSE, "Component <" + << comp.second.Name + << "> does not belong to any group, package it separately." + << std::endl); + components.push_back(comp.first); + } + } + if (!components.empty()) { + this->SetOption("CPACK_NUGET_COMPONENTS", + cmJoin(components, ";").c_str()); + } + + } else { + std::vector<std::string> components; + components.reserve(this->Components.size()); + std::transform(begin(this->Components), end(this->Components), + std::back_inserter(components), + [](std::pair<std::string, cmCPackComponent> const& comp) { + return comp.first; + }); + this->SetOption("CPACK_NUGET_COMPONENTS", cmJoin(components, ";").c_str()); + } +} + +void cmCPackNuGetGenerator::AddGeneratedPackageNames() +{ + const char* const files_list = this->GetOption("GEN_CPACK_OUTPUT_FILES"); + if (!files_list) { + cmCPackLogger( + cmCPackLog::LOG_ERROR, + "Error while execution CPackNuGet.cmake: No NuGet package has generated" + << std::endl); + return; + } + // add the generated packages to package file names list + std::string fileNames{ files_list }; + const char sep = ';'; + std::string::size_type pos1 = 0; + std::string::size_type pos2 = fileNames.find(sep, pos1 + 1); + while (pos2 != std::string::npos) { + packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1)); + pos1 = pos2 + 1; + pos2 = fileNames.find(sep, pos1 + 1); + } + packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1)); +} diff --git a/Source/CPack/cmCPackNuGetGenerator.h b/Source/CPack/cmCPackNuGetGenerator.h new file mode 100644 index 0000000..a59db2d --- /dev/null +++ b/Source/CPack/cmCPackNuGetGenerator.h @@ -0,0 +1,37 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCPackNuGetGenerator_h +#define cmCPackNuGetGenerator_h + +#include "cmCPackGenerator.h" + +/** \class cmCPackNuGetGenerator + * \brief A generator for RPM packages + */ +class cmCPackNuGetGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackNuGetGenerator, cmCPackGenerator); + + // NOTE In fact, it is possible to have NuGet not only for Windows... + // https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools + static bool CanGenerate() { return true; } + +protected: + bool SupportsComponentInstallation() const override; + int PackageFiles() override; + + const char* GetOutputExtension() override { return ".nupkg"; } + bool SupportsAbsoluteDestination() const override { return false; } + /** + * The method used to prepare variables when component + * install is used. + */ + void SetupGroupComponentVariables(bool ignoreGroup); + /** + * Populate \c packageFileNames vector of built packages. + */ + void AddGeneratedPackageNames(); +}; + +#endif diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 38ee623..367616c 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -28,41 +28,41 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, } size_t cnt = 0; - const char* smodel = args[cnt].c_str(); + const char* smodel = nullptr; const char* src_dir = nullptr; const char* bld_dir = nullptr; - cnt++; - - this->CTest->SetSpecificTrack(nullptr); - if (cnt < args.size() - 1) { + while (cnt < args.size()) { if (args[cnt] == "TRACK") { cnt++; + if (cnt >= args.size() || args[cnt] == "APPEND" || + args[cnt] == "QUIET") { + this->SetError("TRACK argument missing track name"); + return false; + } this->CTest->SetSpecificTrack(args[cnt].c_str()); cnt++; - } - } - - if (cnt < args.size()) { - if (args[cnt] == "APPEND") { + } else if (args[cnt] == "APPEND") { cnt++; this->CreateNewTag = false; - } - } - if (cnt < args.size()) { - if (args[cnt] == "QUIET") { + } else if (args[cnt] == "QUIET") { cnt++; this->Quiet = true; - } - } - - if (cnt < args.size()) { - src_dir = args[cnt].c_str(); - cnt++; - if (cnt < args.size()) { + } else if (!smodel) { + smodel = args[cnt].c_str(); + cnt++; + } else if (!src_dir) { + src_dir = args[cnt].c_str(); + cnt++; + } else if (!bld_dir) { bld_dir = args[cnt].c_str(); + cnt++; + } else { + this->SetError("Too many arguments"); + return false; } } + if (!src_dir) { src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"); } @@ -79,6 +79,11 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, "as an argument or set CTEST_BINARY_DIRECTORY"); return false; } + if (!smodel && this->CreateNewTag) { + this->SetError("no test model specified and APPEND not specified. Specify " + "either a test model or the APPEND argument"); + return false; + } cmSystemTools::AddKeepPath(src_dir); cmSystemTools::AddKeepPath(bld_dir); @@ -92,11 +97,20 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(), this->Quiet); - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model " - << smodel << std::endl - << " Source directory: " << src_dir << std::endl - << " Build directory: " << bld_dir << std::endl, - this->Quiet); + if (smodel) { + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model " + << smodel << std::endl + << " Source directory: " << src_dir << std::endl + << " Build directory: " << bld_dir << std::endl, + this->Quiet); + } else { + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with " + "to-be-determined model" + << std::endl + << " Source directory: " << src_dir << std::endl + << " Build directory: " << bld_dir << std::endl, + this->Quiet); + } const char* track = this->CTest->GetSpecificTrack(); if (track) { cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, @@ -128,7 +142,12 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, this->CTest->SetRunCurrentScript(false); this->CTest->SetSuppressUpdatingCTestConfiguration(true); - int model = this->CTest->GetTestModelFromString(smodel); + int model; + if (smodel) { + model = this->CTest->GetTestModelFromString(smodel); + } else { + model = cmCTest::UNKNOWN; + } this->CTest->SetTestModel(model); this->CTest->SetProduceXML(true); diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 1278232..7792235 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -228,6 +228,14 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, this->SetError(e.str()); return false; } + if (aliasedTarget->IsImported() && + !aliasedTarget->IsImportedGloballyVisible()) { + std::ostringstream e; + e << "cannot create ALIAS target \"" << libName << "\" because target \"" + << aliasedName << "\" is imported but not globally visible."; + this->SetError(e.str()); + return false; + } this->Makefile->AddAlias(libName, aliasedName); return true; } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 3fccc38..2c32dea 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -474,11 +474,13 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) day != lctime->tm_mday) { tag.clear(); } - std::string tagmode; - if (cmSystemTools::GetLineFromStream(tfin, tagmode)) { - if (tagmode.size() > 4 && !this->Parts[PartStart]) { - this->TestModel = cmCTest::GetTestModelFromString(tagmode.c_str()); - } + std::string track; + if (cmSystemTools::GetLineFromStream(tfin, track)) { + this->SpecificTrack = track; + } + std::string model; + if (cmSystemTools::GetLineFromStream(tfin, model)) { + this->TestModel = GetTestModelFromString(model.c_str()); } tfin.close(); } @@ -502,6 +504,17 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) if (ofs) { ofs << tag << std::endl; ofs << this->GetTestModelString() << std::endl; + switch (this->TestModel) { + case cmCTest::EXPERIMENTAL: + ofs << "Experimental" << std::endl; + break; + case cmCTest::NIGHTLY: + ofs << "Nightly" << std::endl; + break; + case cmCTest::CONTINUOUS: + ofs << "Continuous" << std::endl; + break; + } } ofs.close(); if (nullptr == command) { @@ -512,8 +525,16 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) } } } else { + std::string track; + std::string modelStr; + int model = cmCTest::UNKNOWN; + if (tfin) { cmSystemTools::GetLineFromStream(tfin, tag); + cmSystemTools::GetLineFromStream(tfin, track); + if (cmSystemTools::GetLineFromStream(tfin, modelStr)) { + model = GetTestModelFromString(modelStr.c_str()); + } tfin.close(); } @@ -523,6 +544,35 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) return 0; } + if (this->TestModel == cmCTest::UNKNOWN) { + if (model == cmCTest::UNKNOWN) { + cmCTestLog(this, ERROR_MESSAGE, + "TAG file does not contain model and " + "no model specified in start command" + << std::endl); + return 0; + } + + this->SetTestModel(model); + } + + if (model != this->TestModel && model != cmCTest::UNKNOWN && + this->TestModel != cmCTest::UNKNOWN) { + cmCTestOptionalLog(this, WARNING, "Model given in TAG does not match " + "model given in ctest_start()" + << std::endl, + quiet); + } + + if (!this->SpecificTrack.empty() && track != this->SpecificTrack) { + cmCTestOptionalLog(this, WARNING, "Track given in TAG does not match " + "track given in ctest_start()" + << std::endl, + quiet); + } else { + this->SpecificTrack = track; + } + cmCTestOptionalLog(this, OUTPUT, " Use existing tag: " << tag << " - " << this->GetTestModelString() << std::endl, diff --git a/Source/cmCTest.h b/Source/cmCTest.h index b2f4f25..603bb41 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -295,9 +295,10 @@ public: enum { - EXPERIMENTAL, - NIGHTLY, - CONTINUOUS + UNKNOWN = -1, + EXPERIMENTAL = 0, + NIGHTLY = 1, + CONTINUOUS = 2, }; /** provide some more detailed info on the return code for ctest */ diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cfdf2d8..2d3465f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -103,6 +103,9 @@ struct cmVisualStudio10TargetGenerator::Elem } } void EndElement() { this->WriteEndTag(this->Tag); } + + void WritePlatformConfigTag(const char* tag, const std::string& cond, + const std::string& content); }; class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions @@ -123,10 +126,11 @@ public: if (!this->GetConfiguration().empty()) { // if there are configuration specific flags, then // use the configuration specific tag for PreprocessorDefinitions - this->TargetGenerator->WritePlatformConfigTag( - tag, this->GetConfiguration(), *Parent, content); + const std::string cond = + this->TargetGenerator->CalcCondition(this->GetConfiguration()); + this->Parent->WritePlatformConfigTag(tag, cond, content); } else { - Parent->Element(tag, content); + this->Parent->Element(tag, content); } } @@ -268,13 +272,10 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition( return oss.str(); } -void cmVisualStudio10TargetGenerator::WritePlatformConfigTag( - const char* tag, const std::string& config, Elem& parent, - const std::string& content) +void cmVisualStudio10TargetGenerator::Elem::WritePlatformConfigTag( + const char* tag, const std::string& cond, const std::string& content) { - Elem(parent, tag) - .Attribute("Condition", this->CalcCondition(config)) - .Content(content); + Elem(*this, tag).Attribute("Condition", cond).Content(content); } std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString( @@ -288,12 +289,6 @@ std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString( return this->S; } -void cmVisualStudio10TargetGenerator::WriteString(const char* line, - int indentLevel) -{ - Elem(*this->BuildFileStream, indentLevel).WriteString(line); -} - #define VS10_CXX_DEFAULT_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.Default.props" #define VS10_CXX_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.props" #define VS10_CXX_USER_PROPS \ @@ -689,17 +684,19 @@ void cmVisualStudio10TargetGenerator::Generate() } // make sure custom commands are executed before build (if necessary) Elem e1(e0, "PropertyGroup"); - e1.SetHasElements(); - this->WriteString("<BuildDependsOn>\n", 2); - for (std::string const& i : this->CSharpCustomCommandNames) { - this->WriteString(i.c_str(), 3); - (*this->BuildFileStream) << ";\n"; + { + std::ostringstream oss; + oss << "\n"; + for (std::string const& i : this->CSharpCustomCommandNames) { + oss << " " << i << ";\n"; + } + oss << " " + << "$(BuildDependsOn)\n"; + e1.Element("BuildDependsOn", oss.str()); } - this->WriteString("$(BuildDependsOn)\n", 3); - this->WriteString("</BuildDependsOn>\n", 2); e1.EndElement(); } - this->WriteString("</Project>", 0); + e0.WriteString("</Project>"); // The groups are stored in a separate file for VS 10 this->WriteGroups(); } @@ -844,7 +841,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) s = "$(RootNamespace)."; } s += "%(Filename).resources"; - this->WritePlatformConfigTag("LogicalName", i, e2, s); + e2.WritePlatformConfigTag("LogicalName", CalcCondition(i), s); } } else { std::string binDir = this->Makefile->GetCurrentBinaryDirectory(); @@ -1336,16 +1333,15 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp( std::string const& comment) { const std::string cond = this->CalcCondition(config); - Elem(e2, "Message").Attribute("Condition", cond).Content(comment); - Elem(e2, "Command").Attribute("Condition", cond).Content(script); - Elem(e2, "AdditionalInputs") - .Attribute("Condition", cond) - .Content(inputs + ";%(AdditionalInputs)"); - Elem(e2, "Outputs").Attribute("Condition", cond).Content(outputs); + e2.WritePlatformConfigTag("Message", cond, comment); + e2.WritePlatformConfigTag("Command", cond, script); + e2.WritePlatformConfigTag("AdditionalInputs", cond, + inputs + ";%(AdditionalInputs)"); + e2.WritePlatformConfigTag("Outputs", cond, outputs); if (this->LocalGenerator->GetVersion() > cmGlobalVisualStudioGenerator::VS10) { // VS >= 11 let us turn off linking of custom command outputs. - Elem(e2, "LinkObjects").Attribute("Condition", cond).Content("false"); + e2.WritePlatformConfigTag("LinkObjects", cond, "false"); } } @@ -1774,15 +1770,15 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, if (0 == strcmp(cge->Evaluate(this->LocalGenerator, this->Configurations[i]), "1")) { - Elem e3(e2, "DeploymentContent"); - e3.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + this->Platform + "'"); - e3.Content("true"); + e2.WritePlatformConfigTag( + "DeploymentContent", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'", + "true"); } else { - Elem e3(e2, "ExcludedFromBuild"); - e3.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + this->Platform + "'"); - e3.Content("true"); + e2.WritePlatformConfigTag( + "ExcludedFromBuild", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'", + "true"); } } } @@ -1797,18 +1793,18 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } if (!outputHeaderFile.empty()) { for (size_t i = 0; i != this->Configurations.size(); ++i) { - Elem e3(e2, "HeaderFileOutput"); - e3.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + this->Platform + "'"); - e3.Content(outputHeaderFile); + e2.WritePlatformConfigTag( + "HeaderFileOutput", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'", + outputHeaderFile); } } if (!variableName.empty()) { for (size_t i = 0; i != this->Configurations.size(); ++i) { - Elem e3(e2, "VariableName"); - e3.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + this->Platform + "'"); - e3.Content(variableName); + e2.WritePlatformConfigTag( + "VariableName", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'", + variableName); } } if (!shaderEnableDebug.empty()) { @@ -1820,10 +1816,10 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, const char* enableDebug = cge->Evaluate(this->LocalGenerator, this->Configurations[i]); if (strlen(enableDebug) > 0) { - Elem e3(e2, "EnableDebuggingInformation"); - e3.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + this->Platform + "'"); - e3.Content(cmSystemTools::IsOn(enableDebug) ? "true" : "false"); + e2.WritePlatformConfigTag( + "EnableDebuggingInformation", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'", + cmSystemTools::IsOn(enableDebug) ? "true" : "false"); } } } @@ -1836,11 +1832,10 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, const char* disableOptimizations = cge->Evaluate(this->LocalGenerator, this->Configurations[i]); if (strlen(disableOptimizations) > 0) { - Elem e3(e2, "DisableOptimizations"); - e3.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + this->Platform + "'"); - e3.Content(cmSystemTools::IsOn(disableOptimizations) ? "true" - : "false"); + e2.WritePlatformConfigTag( + "DisableOptimizations", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + this->Platform + "'", + (cmSystemTools::IsOn(disableOptimizations) ? "true" : "false")); } } } @@ -2225,10 +2220,10 @@ void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild( Elem& e2, std::vector<size_t> const& exclude_configs) { for (size_t ci : exclude_configs) { - Elem e3(e2, "ExcludedFromBuild"); - e3.Attribute("Condition", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[ci] + "|" + this->Platform + "'"); - e3.Content("true"); + e2.WritePlatformConfigTag( + "ExcludedFromBuild", "'$(Configuration)|$(Platform)'=='" + + this->Configurations[ci] + "|" + this->Platform + "'", + "true"); } } @@ -2246,10 +2241,10 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( Elem e1(e0, "PropertyGroup"); e1.Element("_ProjectFileVersion", "10.0.20506.1"); for (std::string const& config : this->Configurations) { + const std::string cond = this->CalcCondition(config); if (ttype >= cmStateEnums::UTILITY) { - this->WritePlatformConfigTag( - "IntDir", config, e1, - "$(Platform)\\$(Configuration)\\$(ProjectName)\\"); + e1.WritePlatformConfigTag( + "IntDir", cond, "$(Platform)\\$(Configuration)\\$(ProjectName)\\"); } else { std::string intermediateDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); @@ -2269,67 +2264,63 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( ConvertToWindowsSlash(intermediateDir); ConvertToWindowsSlash(outDir); - this->WritePlatformConfigTag("OutDir", config, e1, outDir); + e1.WritePlatformConfigTag("OutDir", cond, outDir); - this->WritePlatformConfigTag("IntDir", config, e1, intermediateDir); + e1.WritePlatformConfigTag("IntDir", cond, intermediateDir); if (const char* sdkExecutableDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES")) { - this->WritePlatformConfigTag("ExecutablePath", config, e1, - sdkExecutableDirectories); + e1.WritePlatformConfigTag("ExecutablePath", cond, + sdkExecutableDirectories); } if (const char* sdkIncludeDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_INCLUDE_DIRECTORIES")) { - this->WritePlatformConfigTag("IncludePath", config, e1, - sdkIncludeDirectories); + e1.WritePlatformConfigTag("IncludePath", cond, sdkIncludeDirectories); } if (const char* sdkReferenceDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_REFERENCE_DIRECTORIES")) { - this->WritePlatformConfigTag("ReferencePath", config, e1, - sdkReferenceDirectories); + e1.WritePlatformConfigTag("ReferencePath", cond, + sdkReferenceDirectories); } if (const char* sdkLibraryDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_LIBRARY_DIRECTORIES")) { - this->WritePlatformConfigTag("LibraryPath", config, e1, - sdkLibraryDirectories); + e1.WritePlatformConfigTag("LibraryPath", cond, sdkLibraryDirectories); } if (const char* sdkLibraryWDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES")) { - this->WritePlatformConfigTag("LibraryWPath", config, e1, - sdkLibraryWDirectories); + e1.WritePlatformConfigTag("LibraryWPath", cond, + sdkLibraryWDirectories); } if (const char* sdkSourceDirectories = this->Makefile->GetDefinition("CMAKE_VS_SDK_SOURCE_DIRECTORIES")) { - this->WritePlatformConfigTag("SourcePath", config, e1, - sdkSourceDirectories); + e1.WritePlatformConfigTag("SourcePath", cond, sdkSourceDirectories); } if (const char* sdkExcludeDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_EXCLUDE_DIRECTORIES")) { - this->WritePlatformConfigTag("ExcludePath", config, e1, - sdkExcludeDirectories); + e1.WritePlatformConfigTag("ExcludePath", cond, sdkExcludeDirectories); } if (const char* workingDir = this->GeneratorTarget->GetProperty( "VS_DEBUGGER_WORKING_DIRECTORY")) { - this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", config, - e1, workingDir); + e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond, + workingDir); } if (const char* debuggerCommand = this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) { - this->WritePlatformConfigTag("LocalDebuggerCommand", config, e1, - debuggerCommand); + e1.WritePlatformConfigTag("LocalDebuggerCommand", cond, + debuggerCommand); } std::string name = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); - this->WritePlatformConfigTag("TargetName", config, e1, name); + e1.WritePlatformConfigTag("TargetName", cond, name); std::string ext = cmSystemTools::GetFilenameLastExtension(targetNameFull); @@ -2338,7 +2329,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( // A single "." appears to be treated as an empty extension. ext = "."; } - this->WritePlatformConfigTag("TargetExt", config, e1, ext); + e1.WritePlatformConfigTag("TargetExt", cond, ext); this->OutputLinkIncremental(e1, config); } @@ -2362,15 +2353,16 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( return; } Options& linkOptions = *(this->LinkOptions[configName]); + const std::string cond = this->CalcCondition(configName); const char* incremental = linkOptions.GetFlag("LinkIncremental"); - this->WritePlatformConfigTag("LinkIncremental", configName, e1, - (incremental ? incremental : "true")); + e1.WritePlatformConfigTag("LinkIncremental", cond, + (incremental ? incremental : "true")); linkOptions.RemoveFlag("LinkIncremental"); const char* manifest = linkOptions.GetFlag("GenerateManifest"); - this->WritePlatformConfigTag("GenerateManifest", configName, e1, - (manifest ? manifest : "true")); + e1.WritePlatformConfigTag("GenerateManifest", cond, + (manifest ? manifest : "true")); linkOptions.RemoveFlag("GenerateManifest"); // Some link options belong here. Use them now and remove them so that @@ -2379,7 +2371,7 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( for (const char** f = flags; *f; ++f) { const char* flag = *f; if (const char* value = linkOptions.GetFlag(flag)) { - this->WritePlatformConfigTag(flag, configName, e1, value); + e1.WritePlatformConfigTag(flag, cond, value); linkOptions.RemoveFlag(flag); } } @@ -3809,6 +3801,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) } if (referenceNotManaged) { e2.Element("ReferenceOutputAssembly", "false"); + e2.Element("CopyToOutputDirectory", "Never"); } } e2.EndElement(); @@ -3839,24 +3832,17 @@ void cmVisualStudio10TargetGenerator::WritePlatformExtensions(Elem& e1) void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension( Elem& e1, std::string const& extension, std::string const& version) { + const std::string s = "$([Microsoft.Build.Utilities.ToolLocationHelper]" + "::GetPlatformExtensionSDKLocation(`" + + extension + ", Version=" + version + + "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, " + "$(ExtensionSDKDirectoryRoot), null))" + "\\DesignTime\\CommonConfiguration\\Neutral\\" + + extension + ".props"; + Elem e2(e1, "Import"); - e2.Attribute( - "Project", "$([Microsoft.Build.Utilities.ToolLocationHelper]" - "::GetPlatformExtensionSDKLocation(`" + - extension + ", Version=" + version + - "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, " - "$(ExtensionSDKDirectoryRoot), null))" - "\\DesignTime\\CommonConfiguration\\Neutral\\" + - extension + ".props"); - e2.Attribute( - "Condition", "exists('$(" - "[Microsoft.Build.Utilities.ToolLocationHelper]" - "::GetPlatformExtensionSDKLocation(`" + - extension + ", Version=" + version + - "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, " - "$(ExtensionSDKDirectoryRoot), null))" - "\\DesignTime\\CommonConfiguration\\Neutral\\" + - extension + ".props')"); + e2.Attribute("Project", s); + e2.Attribute("Condition", "exists('" + s + "')"); e2.EndElement(); } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 38c7725..8c0b6ca 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -53,10 +53,7 @@ private: struct OptionsHelper; std::string ConvertPath(std::string const& path, bool forceRelative); - void WriteString(const char* line, int indentLevel); std::string CalcCondition(const std::string& config) const; - void WritePlatformConfigTag(const char* tag, const std::string& config, - Elem& parent, const std::string& content); void WriteProjectConfigurations(Elem& e0); void WriteProjectConfigurationValues(Elem& e0); void WriteMSToolConfigurationValues(Elem& e1, std::string const& config); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ea64646..fe8f2cc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -145,8 +145,7 @@ if(BUILD_TESTING) set(CPACK_BINARY_RPM OFF) endif() - # Look for rpmbuild to use for tests. - # The tool does not work with spaces in the path. + # Look for dpkg to use for tests. find_program(DPKG_EXECUTABLE NAMES dpkg) if(DPKG_EXECUTABLE) @@ -155,6 +154,15 @@ if(BUILD_TESTING) set(CPACK_BINARY_DEB OFF) endif() + # Look for NuGet to use for tests. + find_program(NUGET_EXECUTABLE NAMES NuGet nuget) + + if(NUGET_EXECUTABLE) + set(CPACK_BINARY_NUGET ON) + else() + set(CPACK_BINARY_NUGET OFF) + endif() + #--------------------------------------------------------------------------- # Add tests below here. @@ -1033,6 +1041,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(CPACK_BINARY_DEB) list(APPEND ACTIVE_CPACK_GENERATORS DEB) endif() + # Check whether if NuGet command is found + # before adding NuGet tests + if(CPACK_BINARY_NUGET) + list(APPEND ACTIVE_CPACK_GENERATORS NUGET) + set(CPACK_GENERATOR_STRING_NUGET NuGet) + endif() # ACTIVE_CPACK_GENERATORS variable # now contains the list of 'active generators' @@ -1052,7 +1066,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release list(APPEND CWAYLST "IgnoreGroup") list(APPEND CWAYLST "AllInOne") foreach(CPackGen IN LISTS ACTIVE_CPACK_GENERATORS) - set(CPackRun_CPackGen "-DCPackGen=${CPackGen}") + if(NOT DEFINED CPACK_GENERATOR_STRING_${CPackGen}) + set(CPACK_GENERATOR_STRING_${CPackGen} ${CPackGen}) + endif() + set(CPackRun_CPackGen "-DCPackGen=${CPACK_GENERATOR_STRING_${CPackGen}}") foreach(CPackComponentWay ${CWAYLST}) set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}") add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay} @@ -1063,7 +1080,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_GENERATOR:STRING=${CPACK_GENERATOR_STRING_${CPackGen}} -DCPACK_BINARY_${CPackGen}:BOOL=ON ${CPackRun_CPackComponentWay} ${CPackComponentsForAll_BUILD_OPTIONS} diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt index 3440843..f2e4fcd 100644 --- a/Tests/CPackComponentsForAll/CMakeLists.txt +++ b/Tests/CPackComponentsForAll/CMakeLists.txt @@ -168,6 +168,18 @@ set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}" # set CPACK_DEBIAN_FILE_NAME to use default package name format set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +# set some tags for NuGet packages +# 1. all in one pacakge +set(CPACK_NUGET_PACKAGE_TAGS "nuget" "unit" "test" "all-in-one") +# 2. per component packages +set(CPACK_NUGET_APPLICATIONS_PACKAGE_TAGS "nuget" "unit" "test" "applications") +set(CPACK_NUGET_LIBRARIES_PACKAGE_TAGS "nuget" "unit" "test" "libraries") +set(CPACK_NUGET_HEADERS_PACKAGE_TAGS "nuget" "unit" "test" "headers") +set(CPACK_NUGET_UNSPECIFIED_PACKAGE_TAGS "nuget" "unit" "test" "uNsP3c1FiEd") +# 3. per group packages +set(CPACK_NUGET_RUNTIME_PACKAGE_TAGS "nuget" "unit" "test" "run-time") +set(CPACK_NUGET_DEVELOPMENT_PACKAGE_TAGS "nuget" "unit" "test" "development") + # We may use the CPack specific config file in order # to tailor CPack behavior on a CPack generator specific way # (Behavior would be different for RPM or TGZ or DEB ...) diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in index 0bfbf14..1b9e658 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in @@ -13,6 +13,10 @@ if(CPACK_GENERATOR MATCHES "DEB") set(CPACK_DEB_COMPONENT_INSTALL "ON") endif() +if(CPACK_GENERATOR MATCHES "NuGet") + set(CPACK_NUGET_COMPONENT_INSTALL "ON") +endif() + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in index 0ffe44d..a6f6ea9 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in @@ -52,6 +52,10 @@ if(CPACK_GENERATOR MATCHES "DEB") set(CPACK_DEB_COMPONENT_INSTALL "ON") endif() +if(CPACK_GENERATOR MATCHES "NuGet") + set(CPACK_NUGET_COMPONENT_INSTALL "ON") +endif() + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in index ac65dc9..d41225d 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in @@ -18,6 +18,10 @@ if(CPACK_GENERATOR MATCHES "DragNDrop") set(CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP") endif() +if(CPACK_GENERATOR MATCHES "NuGet") + set(CPACK_NUGET_COMPONENT_INSTALL "ON") +endif() + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index 2c3a849..253d128 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -38,57 +38,69 @@ set(config_verbose ) if(CPackGen MATCHES "ZIP") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip") - if (${CPackComponentWay} STREQUAL "default") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () -elseif (CPackGen MATCHES "RPM") + endif() +elseif(CPackGen MATCHES "RPM") set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm") - if (${CPackComponentWay} STREQUAL "default") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () -elseif (CPackGen MATCHES "DEB") + endif() +elseif(CPackGen MATCHES "DEB") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2_*.deb") - if (${CPackComponentWay} STREQUAL "default") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () + endif() +elseif(CPackGen MATCHES "NuGet") + set(config_verbose -D "CPACK_NUGET_PACKAGE_DEBUG=1") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib*1.0.2.nupkg") + if(${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif(${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif() endif() if(CPackGen MATCHES "DragNDrop") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg") - if (${CPackComponentWay} STREQUAL "default") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () + endif() endif() # clean-up previously CPack generated files if(expected_file_mask) file(GLOB expected_file "${expected_file_mask}") - if (expected_file) + if(expected_file) file(REMOVE ${expected_file}) endif() endif() @@ -101,7 +113,7 @@ execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${config_verbose} -G ${CPackGen} ERROR_VARIABLE CPack_error WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR}) -if (CPack_result) +if(CPack_result) message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}") else () message(STATUS "CPack_output=${CPack_output}") diff --git a/Tests/RunCMake/alias_targets/imported-target-stderr.txt b/Tests/RunCMake/alias_targets/imported-target-stderr.txt index 12ffbc2..465de03 100644 --- a/Tests/RunCMake/alias_targets/imported-target-stderr.txt +++ b/Tests/RunCMake/alias_targets/imported-target-stderr.txt @@ -3,7 +3,13 @@ \"test-exe\" is imported but not globally visible. Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) - - ++ 'alias-test-exe' does not exist![?] +* +CMake Error at imported-target.cmake:[0-9]+ \(add_library\): + add_library cannot create ALIAS target "alias-test-lib" because target + "test-lib" is imported but not globally visible. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ 'alias-test-lib' does not exist![?]$ diff --git a/Tests/RunCMake/ctest_start/AppendDifferentModel-check.cmake b/Tests/RunCMake/ctest_start/AppendDifferentModel-check.cmake new file mode 100644 index 0000000..d71b1cf --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendDifferentModel-check.cmake @@ -0,0 +1 @@ +check_tag_contents("^19551112-2204\nContinuousTrack\nContinuous\n$") diff --git a/Tests/RunCMake/ctest_start/AppendDifferentModel-stderr.txt b/Tests/RunCMake/ctest_start/AppendDifferentModel-stderr.txt new file mode 100644 index 0000000..a523f3f --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendDifferentModel-stderr.txt @@ -0,0 +1 @@ +^Model given in TAG does not match model given in ctest_start\(\)$ diff --git a/Tests/RunCMake/ctest_start/AppendDifferentModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendDifferentModel-stdout.txt new file mode 100644 index 0000000..bc9a4c8 --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendDifferentModel-stdout.txt @@ -0,0 +1,8 @@ +Run dashboard with model Experimental + Source directory: .*/Tests/RunCMake/ctest_start/AppendDifferentModel + Build directory: .*/Tests/RunCMake/ctest_start/AppendDifferentModel-build + Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/AppendDifferentModel/CTestConfig.cmake + Site: test-site + Build name: test-build-name + Use existing tag: 19551112-2204 - ContinuousTrack + Use ContinuousTrack tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_start/AppendDifferentTrack-stderr.txt b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stderr.txt new file mode 100644 index 0000000..0d6d19d --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stderr.txt @@ -0,0 +1 @@ +^Track given in TAG does not match track given in ctest_start\(\)$ diff --git a/Tests/RunCMake/ctest_start/AppendDifferentTrack-stdout.txt b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stdout.txt new file mode 100644 index 0000000..ab1c1f7 --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stdout.txt @@ -0,0 +1,9 @@ +Run dashboard with to-be-determined model + Source directory: .*/Tests/RunCMake/ctest_start/AppendDifferentTrack + Build directory: .*/Tests/RunCMake/ctest_start/AppendDifferentTrack-build + Track: ExperimentalDifferent + Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/AppendDifferentTrack/CTestConfig.cmake + Site: test-site + Build name: test-build-name + Use existing tag: 19551112-2204 - ExperimentalDifferent + Use ExperimentalDifferent tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-stdout.txt b/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-stdout.txt new file mode 100644 index 0000000..55f2d8e --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-stdout.txt @@ -0,0 +1,8 @@ +Run dashboard with model Continuous + Source directory: .*/Tests/RunCMake/ctest_start/AppendNoMatchingTrack + Build directory: .*/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-build + Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/AppendNoMatchingTrack/CTestConfig.cmake + Site: test-site + Build name: test-build-name + Use existing tag: 19551112-2204 - SomeWeirdTrackName + Use SomeWeirdTrackName tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_start/AppendNoModel-check.cmake b/Tests/RunCMake/ctest_start/AppendNoModel-check.cmake new file mode 100644 index 0000000..d71b1cf --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendNoModel-check.cmake @@ -0,0 +1 @@ +check_tag_contents("^19551112-2204\nContinuousTrack\nContinuous\n$") diff --git a/Tests/RunCMake/ctest_start/AppendNoModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendNoModel-stdout.txt new file mode 100644 index 0000000..f909a44 --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendNoModel-stdout.txt @@ -0,0 +1,8 @@ +Run dashboard with to-be-determined model + Source directory: .*/Tests/RunCMake/ctest_start/AppendNoModel + Build directory: .*/Tests/RunCMake/ctest_start/AppendNoModel-build + Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/AppendNoModel/CTestConfig.cmake + Site: test-site + Build name: test-build-name + Use existing tag: 19551112-2204 - ContinuousTrack + Use ContinuousTrack tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_start/AppendOldContinuous-stdout.txt b/Tests/RunCMake/ctest_start/AppendOldContinuous-stdout.txt new file mode 100644 index 0000000..0660f5d --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendOldContinuous-stdout.txt @@ -0,0 +1,8 @@ +Run dashboard with model Continuous + Source directory: .*/Tests/RunCMake/ctest_start/AppendOldContinuous + Build directory: .*/Tests/RunCMake/ctest_start/AppendOldContinuous-build + Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/AppendOldContinuous/CTestConfig.cmake + Site: test-site + Build name: test-build-name + Use existing tag: 19551112-2204 - ContinuousTrack + Use ContinuousTrack tag: 19551112-2204 diff --git a/Tests/RunCMake/ctest_start/AppendOldNoModel-result.txt b/Tests/RunCMake/ctest_start/AppendOldNoModel-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendOldNoModel-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_start/AppendOldNoModel-stderr.txt b/Tests/RunCMake/ctest_start/AppendOldNoModel-stderr.txt new file mode 100644 index 0000000..c7ca1e7 --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendOldNoModel-stderr.txt @@ -0,0 +1,3 @@ +^TAG file does not contain model and no model specified in start command +CMake Error at .*/Tests/RunCMake/ctest_start/AppendOldNoModel/test.cmake:[0-9]+ \(ctest_start\): + ctest_start unknown error.$ diff --git a/Tests/RunCMake/ctest_start/AppendOldNoModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendOldNoModel-stdout.txt new file mode 100644 index 0000000..0bdf9e4 --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendOldNoModel-stdout.txt @@ -0,0 +1,6 @@ +Run dashboard with to-be-determined model + Source directory: .*/Tests/RunCMake/ctest_start/AppendOldNoModel + Build directory: .*/Tests/RunCMake/ctest_start/AppendOldNoModel-build + Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/AppendOldNoModel/CTestConfig.cmake + Site: test-site + Build name: test-build-name diff --git a/Tests/RunCMake/ctest_start/AppendSameModel-check.cmake b/Tests/RunCMake/ctest_start/AppendSameModel-check.cmake new file mode 100644 index 0000000..d71b1cf --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendSameModel-check.cmake @@ -0,0 +1 @@ +check_tag_contents("^19551112-2204\nContinuousTrack\nContinuous\n$") diff --git a/Tests/RunCMake/ctest_start/AppendSameModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendSameModel-stdout.txt new file mode 100644 index 0000000..4f43626 --- /dev/null +++ b/Tests/RunCMake/ctest_start/AppendSameModel-stdout.txt @@ -0,0 +1,8 @@ +Run dashboard with model Continuous + Source directory: .*/Tests/RunCMake/ctest_start/AppendSameModel + Build directory: .*/Tests/RunCMake/ctest_start/AppendSameModel-build + Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/AppendSameModel/CTestConfig.cmake + Site: test-site + Build name: test-build-name + Use existing tag: 19551112-2204 - ContinuousTrack + Use ContinuousTrack tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_start/MissingTrackArg-result.txt b/Tests/RunCMake/ctest_start/MissingTrackArg-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_start/MissingTrackArg-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_start/MissingTrackArg-stderr.txt b/Tests/RunCMake/ctest_start/MissingTrackArg-stderr.txt new file mode 100644 index 0000000..7b42bc9 --- /dev/null +++ b/Tests/RunCMake/ctest_start/MissingTrackArg-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at .*/Tests/RunCMake/ctest_start/MissingTrackArg/test\.cmake:[0-9]+ \(ctest_start\): + ctest_start TRACK argument missing track name$ diff --git a/Tests/RunCMake/ctest_start/MissingTrackArgAppend-result.txt b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_start/MissingTrackArgAppend-stderr.txt b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-stderr.txt new file mode 100644 index 0000000..695bfad --- /dev/null +++ b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at .*/Tests/RunCMake/ctest_start/MissingTrackArgAppend/test\.cmake:[0-9]+ \(ctest_start\): + ctest_start TRACK argument missing track name$ diff --git a/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-result.txt b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-stderr.txt b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-stderr.txt new file mode 100644 index 0000000..9438522 --- /dev/null +++ b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at .*/Tests/RunCMake/ctest_start/MissingTrackArgQuiet/test\.cmake:[0-9]+ \(ctest_start\): + ctest_start TRACK argument missing track name$ diff --git a/Tests/RunCMake/ctest_start/NoModel-result.txt b/Tests/RunCMake/ctest_start/NoModel-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_start/NoModel-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_start/NoModel-stderr.txt b/Tests/RunCMake/ctest_start/NoModel-stderr.txt new file mode 100644 index 0000000..a516cf8 --- /dev/null +++ b/Tests/RunCMake/ctest_start/NoModel-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error at .*/Tests/RunCMake/ctest_start/NoModel/test\.cmake:[0-9]+ \(ctest_start\): + ctest_start no test model specified and APPEND not specified. Specify + either a test model or the APPEND argument$ diff --git a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake index bf47256..2e8aa75 100644 --- a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake @@ -7,11 +7,40 @@ function(run_ctest_start CASE_NAME) run_ctest(${CASE_NAME}) endfunction() -run_ctest_start(StartQuiet Experimental QUIET) +function(check_tag_contents EXPECTED) + set(_tag_file "${RunCMake_BINARY_DIR}/${CASE_NAME}-build/Testing/TAG") + if(EXISTS "${_tag_file}") + file(READ "${_tag_file}" _tag_contents) + if(NOT _tag_contents MATCHES "${EXPECTED}") + set(RunCMake_TEST_FAILED "Testing/TAG file does not match expected value.\nActual TAG file:\n${_tag_contents}\nExpected TAG file:\n${EXPECTED}\n" PARENT_SCOPE) + endif() + else() + set(RunCMake_TEST_FAILED "Testing/TAG file does not exist." PARENT_SCOPE) + endif() +endfunction() +run_ctest_start(StartQuiet Experimental QUIET) run_ctest_start(ConfigInSource Experimental) - run_ctest_start(FunctionScope Experimental QUIET) +run_ctest_start(WriteModelToTagExperimental Experimental QUIET) +run_ctest_start(WriteModelToTagContinuous Continuous QUIET) +run_ctest_start(WriteModelToTagNightly Nightly QUIET) +run_ctest_start(WriteModelToTagNoMatchingTrack Continuous TRACK SomeWeirdTrackName QUIET) +run_ctest_start(AppendSameModel Continuous APPEND) +run_ctest_start(AppendDifferentModel Experimental APPEND) +run_ctest_start(AppendNoModel APPEND) +run_ctest_start(AppendDifferentTrack TRACK ExperimentalDifferent APPEND) +run_ctest_start(AppendNoMatchingTrack Continuous APPEND) +run_ctest_start(AppendOldContinuous Continuous APPEND) +run_ctest_start(AppendOldNoModel APPEND) +run_ctest_start(NoModel QUIET) +run_ctest_start(MissingTrackArg Experimental TRACK) +run_ctest_start(MissingTrackArgAppend Experimental TRACK APPEND) +run_ctest_start(MissingTrackArgQuiet Experimental TRACK QUIET) +run_ctest_start(TooManyArgs Experimental + ${RunCMake_BINARY_DIR}/TooManyArgs-build + ${RunCMake_BINARY_DIR}/TooManyArgs-build + ${RunCMake_BINARY_DIR}/TooManyArgs-build) function(run_ConfigInBuild) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ConfigInBuild-build) diff --git a/Tests/RunCMake/ctest_start/TooManyArgs-result.txt b/Tests/RunCMake/ctest_start/TooManyArgs-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_start/TooManyArgs-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_start/TooManyArgs-stderr.txt b/Tests/RunCMake/ctest_start/TooManyArgs-stderr.txt new file mode 100644 index 0000000..c1d5f22 --- /dev/null +++ b/Tests/RunCMake/ctest_start/TooManyArgs-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at .*/Tests/RunCMake/ctest_start/TooManyArgs/test\.cmake:[0-9]+ \(ctest_start\): + ctest_start Too many arguments$ diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagContinuous-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagContinuous-check.cmake new file mode 100644 index 0000000..4e67bf5 --- /dev/null +++ b/Tests/RunCMake/ctest_start/WriteModelToTagContinuous-check.cmake @@ -0,0 +1 @@ +check_tag_contents("^[0-9-]+\nContinuous\nContinuous\n$") diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagExperimental-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagExperimental-check.cmake new file mode 100644 index 0000000..b5bf2cf --- /dev/null +++ b/Tests/RunCMake/ctest_start/WriteModelToTagExperimental-check.cmake @@ -0,0 +1 @@ +check_tag_contents("^[0-9-]+\nExperimental\nExperimental\n$") diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagNightly-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagNightly-check.cmake new file mode 100644 index 0000000..35d0566 --- /dev/null +++ b/Tests/RunCMake/ctest_start/WriteModelToTagNightly-check.cmake @@ -0,0 +1 @@ +check_tag_contents("^[0-9-]+\nNightly\nNightly\n$") diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingTrack-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingTrack-check.cmake new file mode 100644 index 0000000..bd2862d --- /dev/null +++ b/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingTrack-check.cmake @@ -0,0 +1 @@ +check_tag_contents("^[0-9-]+\nSomeWeirdTrackName\nContinuous\n$") diff --git a/Tests/RunCMake/ctest_start/test.cmake.in b/Tests/RunCMake/ctest_start/test.cmake.in index 0a27942..172baf7 100644 --- a/Tests/RunCMake/ctest_start/test.cmake.in +++ b/Tests/RunCMake/ctest_start/test.cmake.in @@ -8,11 +8,23 @@ set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") function(setup_tests) ctest_start(${ctest_start_args}) endfunction() +if("@CASE_NAME@" MATCHES "^Append") + if("@CASE_NAME@" MATCHES "^AppendNoMatchingTrack$") + file(WRITE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "19551112-2204\nSomeWeirdTrackName\n") + else() + file(WRITE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "19551112-2204\nContinuousTrack\n") + endif() + if(NOT "@CASE_NAME@" MATCHES "^AppendOld") + file(APPEND "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "Continuous\n") + endif() +endif() + set(ctest_start_args "@CASE_CTEST_START_ARGS@") if("@CASE_NAME@" STREQUAL "FunctionScope") setup_tests() |