diff options
37 files changed, 1044 insertions, 147 deletions
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 184497c..971b3e2 100644 --- a/Help/release/3.11.rst +++ b/Help/release/3.11.rst @@ -292,3 +292,9 @@ Changes made since CMake 3.11.0 include the following. 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. + +* The :module:`FindQt4` module ``qt4_wrap_cpp``, ``qt4_wrap_ui`` and + ``qt4_add_resources`` macros now set :prop_sf:`SKIP_AUTOMOC` and + :prop_sf:`SKIP_AUTOUIC` on their generated files. These files never + need to be processed by moc or uic, and we must say so explicitly to + account for policy :policy:`CMP0071`. diff --git a/Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst b/Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst new file mode 100644 index 0000000..b915556 --- /dev/null +++ b/Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst @@ -0,0 +1,6 @@ +FindPkgConfig-LINK_LIBRARIES +---------------------------- + +* The :module:`FindPkgConfig` module has learned to export the found libraries + with full path for direct consumption with the :command:`target_link_libraries` + command. 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/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/FindBLAS.cmake b/Modules/FindBLAS.cmake index 5223b1d..5ee703a 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -88,16 +88,9 @@ endif() if(BLA_PREFER_PKGCONFIG) find_package(PkgConfig) - pkg_check_modules(PKGC_BLAS IMPORTED_TARGET blas) + pkg_check_modules(PKGC_BLAS blas) if(PKGC_BLAS_FOUND) - # FIXME: We should not interpret the INTERFACE_LINK_LIBRARIES property - # because it could have generator expressions and such. This is a - # workaround for pkg_check_modules not providing a first-class way to - # get the list of libraries. - get_property(BLAS_LIBRARIES TARGET PkgConfig::PKGC_BLAS PROPERTY INTERFACE_LINK_LIBRARIES) - find_package_handle_standard_args(BLAS - REQUIRED_VARS BLAS_LIBRARIES - VERSION_VAR PKGC_BLAS_VERSION) + set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}") return() endif() endif() 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/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 95af0bf..775a9d7 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -183,8 +183,8 @@ endfunction() # scan the LDFLAGS returned by pkg-config for library directories and # libraries, figure out the absolute paths of that libraries in the -# given directories, and create an imported target from them -function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_path) +# given directories +function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) unset(_libs) unset(_find_opts) @@ -221,18 +221,23 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}") endforeach() + set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE) +endfunction() + +# create an imported target from all the information returned by pkg-config +function(_pkg_create_imp_target _prefix) # only create the target if it is linkable, i.e. no executables if (NOT TARGET PkgConfig::${_prefix} - AND ( ${_prefix}_INCLUDE_DIRS OR _libs OR ${_prefix}_CFLAGS_OTHER )) + AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_CFLAGS_OTHER )) add_library(PkgConfig::${_prefix} INTERFACE IMPORTED) if(${_prefix}_INCLUDE_DIRS) set_property(TARGET PkgConfig::${_prefix} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}") endif() - if(_libs) + if(${_prefix}_LINK_LIBRARIES) set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_LINK_LIBRARIES "${_libs}") + INTERFACE_LINK_LIBRARIES "${${_prefix}_LINK_LIBRARIES}") endif() if(${_prefix}_CFLAGS_OTHER) set_property(TARGET PkgConfig::${_prefix} PROPERTY @@ -241,6 +246,15 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat endif() endfunction() +# recalculate the dynamic output +# this is a macro and not a function so the result of _pkg_find_libs is automatically propagated +macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target) + _pkg_find_libs(${_prefix} ${_no_cmake_path} ${_no_cmake_environment_path}) + if(${_imp_target}) + _pkg_create_imp_target(${_prefix}) + endif() +endmacro() + ### macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix) _pkgconfig_unset(${_prefix}_FOUND) @@ -460,9 +474,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) - if (_imp_target) - _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path}) - endif() + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target}) endif() if(NOT "${_extra_paths}" STREQUAL "") @@ -525,6 +537,7 @@ endmacro() <XXX>_FOUND ... set to 1 if module(s) exist <XXX>_LIBRARIES ... only the libraries (without the '-l') + <XXX>_LINK_LIBRARIES ... the libraries and their absolute paths <XXX>_LIBRARY_DIRS ... the paths of the libraries (without the '-L') <XXX>_LDFLAGS ... all required linker flags <XXX>_LDFLAGS_OTHER ... all other linker flags @@ -592,8 +605,10 @@ macro(pkg_check_modules _prefix _module0) if (${_prefix}_FOUND) _pkgconfig_set(__pkg_config_arguments_${_prefix} "${_module0};${ARGN}") endif() - elseif (${_prefix}_FOUND AND ${_imp_target}) - _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path}) + else() + if (${_prefix}_FOUND) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target}) + endif() endif() endmacro() @@ -646,8 +661,8 @@ macro(pkg_search_module _prefix _module0) endif() _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) - elseif (${_prefix}_FOUND AND ${_imp_target}) - _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path}) + elseif (${_prefix}_FOUND) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target}) endif() endmacro() diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 0fd76c0..36dd0a0 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -584,8 +584,10 @@ if(_IRSL_HAVE_Intel) foreach(__Intel_lib IN ITEMS libchkp.dylib libcilkrts.5.dylib libcilkrts.dylib libimf.dylib libintlc.dylib libirc.dylib libirng.dylib libsvml.dylib) list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}") endforeach() - if(_Intel_compiler_ver VERSION_LESS 17) - list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.dylib") + if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel) + if(_Intel_compiler_ver VERSION_LESS 17) + list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.dylib") + endif() endif() if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) foreach(__Intel_lib IN ITEMS libifcore.dylib libifcoremt.dylib libifport.dylib libifportmt.dylib) @@ -594,8 +596,7 @@ if(_IRSL_HAVE_Intel) endforeach() endif() else() - set(__install_dirs "${_Intel_redistdir}/irml") - foreach(__Intel_lib IN ITEMS cilk_db.so libchkp.so libcilkrts.so libcilkrts.so.5 libimf.so libintlc.so libintlc.so.5 libirc.so libpdbx.so libpdbx.so.5 libsvml.so) + foreach(__Intel_lib IN ITEMS libchkp.so libcilkrts.so libcilkrts.so.5 libimf.so libintlc.so libintlc.so.5 libirc.so libpdbx.so libpdbx.so.5 libsvml.so) list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}") endforeach() @@ -605,10 +606,11 @@ if(_IRSL_HAVE_Intel) list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}") endforeach() endif() - if(_Intel_compiler_ver VERSION_GREATER_EQUAL 15) - list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.so") - if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel) - list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.so") + if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel) + set(__install_dirs "${_Intel_redistdir}/irml") + list(APPEND __install_libs "${_Intel_redistdir}/cilk_db.so") + if(_Intel_compiler_ver VERSION_GREATER_EQUAL 15) + list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.so" "${_Intel_redistdir}/libgfxoffload.so") endif() endif() if(_Intel_compiler_ver VERSION_GREATER_EQUAL 16) diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index aee4028..a2c8d85 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -151,7 +151,8 @@ macro (QT4_GENERATE_MOC infile outfile ) set(moc_target ${ARGV3}) endif() QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}") - set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # don't run automoc on this file + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file endmacro () @@ -166,6 +167,8 @@ macro (QT4_WRAP_CPP outfiles ) get_filename_component(it ${it} ABSOLUTE) QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile) QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}") + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file set(${outfiles} ${${outfiles}} ${outfile}) endforeach() @@ -185,6 +188,8 @@ macro (QT4_WRAP_UI outfiles ) COMMAND Qt4::uic ARGS ${ui_options} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} VERBATIM) + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file set(${outfiles} ${${outfiles}} ${outfile}) endforeach () @@ -233,6 +238,8 @@ macro (QT4_ADD_RESOURCES outfiles ) ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM) + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file + set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file set(${outfiles} ${${outfiles}} ${outfile}) endforeach () @@ -245,19 +252,19 @@ macro(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp") set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc") - get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE) + get_property(_nonamespace SOURCE ${_interface} PROPERTY NO_NAMESPACE) if(_nonamespace) set(_params -N -m) else() set(_params -m) endif() - get_source_file_property(_classname ${_interface} CLASSNAME) + get_property(_classname SOURCE ${_interface} PROPERTY CLASSNAME) if(_classname) set(_params ${_params} -c ${_classname}) endif() - get_source_file_property(_include ${_interface} INCLUDE) + get_property(_include SOURCE ${_interface} PROPERTY INCLUDE) if(_include) set(_params ${_params} -i ${_include}) endif() @@ -266,7 +273,8 @@ macro(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) COMMAND Qt4::qdbusxml2cpp ${_params} -p ${_basename} ${_infile} DEPENDS ${_infile} VERBATIM) - set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE) + set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file + set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file QT4_GENERATE_MOC("${_header}" "${_moc}") @@ -350,7 +358,8 @@ macro(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional endif() QT4_GENERATE_MOC("${_header}" "${_moc}") - set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE) + set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file + set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file MACRO_ADD_FILE_DEPENDENCIES("${_impl}" "${_moc}") list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}") @@ -374,7 +383,7 @@ macro(QT4_AUTOMOC) # cmake is run for the very first time on them -> however the .cpp files might # exist at a later run. at that time we need to skip them, so that we don't add two # different rules for the same moc file - get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC) + get_property(_skip SOURCE ${_abs_FILE} PROPERTY SKIP_AUTOMOC) if ( NOT _skip AND EXISTS ${_abs_FILE} ) @@ -454,7 +463,7 @@ macro(QT4_ADD_TRANSLATION _qm_files) foreach (_current_FILE ${ARGN}) get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE) get_filename_component(qm ${_abs_FILE} NAME_WE) - get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION) + get_property(output_location SOURCE ${_abs_FILE} PROPERTY OUTPUT_LOCATION) if(output_location) file(MAKE_DIRECTORY "${output_location}") set(qm "${output_location}/${qm}.qm") 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 e1fea03..6f9e5f0 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 20180511) +set(CMake_VERSION_PATCH 20180516) #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/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 30f76a9..e078645 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -347,28 +347,27 @@ void cmCTestLaunch::WriteXML() // Use cmGeneratedFileStream to atomically create the report file. cmGeneratedFileStream fxml(logXML.c_str()); cmXMLWriter xml(fxml, 2); - xml.StartElement("Failure"); - xml.Attribute("type", this->IsError() ? "Error" : "Warning"); - this->WriteXMLAction(xml); - this->WriteXMLCommand(xml); - this->WriteXMLResult(xml); - this->WriteXMLLabels(xml); - xml.EndElement(); // Failure + cmXMLElement e2(xml, "Failure"); + e2.Attribute("type", this->IsError() ? "Error" : "Warning"); + this->WriteXMLAction(e2); + this->WriteXMLCommand(e2); + this->WriteXMLResult(e2); + this->WriteXMLLabels(e2); } -void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml) +void cmCTestLaunch::WriteXMLAction(cmXMLElement& e2) { - xml.Comment("Meta-information about the build action"); - xml.StartElement("Action"); + e2.Comment("Meta-information about the build action"); + cmXMLElement e3(e2, "Action"); // TargetName if (!this->OptionTargetName.empty()) { - xml.Element("TargetName", this->OptionTargetName); + e3.Element("TargetName", this->OptionTargetName); } // Language if (!this->OptionLanguage.empty()) { - xml.Element("Language", this->OptionLanguage); + e3.Element("Language", this->OptionLanguage); } // SourceFile @@ -383,12 +382,12 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml) source = cmSystemTools::RelativePath(this->SourceDir, source); } - xml.Element("SourceFile", source); + e3.Element("SourceFile", source); } // OutputFile if (!this->OptionOutput.empty()) { - xml.Element("OutputFile", this->OptionOutput); + e3.Element("OutputFile", this->OptionOutput); } // OutputType @@ -407,97 +406,88 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml) outputType = "object file"; } if (outputType) { - xml.Element("OutputType", outputType); + e3.Element("OutputType", outputType); } - - xml.EndElement(); // Action } -void cmCTestLaunch::WriteXMLCommand(cmXMLWriter& xml) +void cmCTestLaunch::WriteXMLCommand(cmXMLElement& e2) { - xml.Comment("Details of command"); - xml.StartElement("Command"); + e2.Comment("Details of command"); + cmXMLElement e3(e2, "Command"); if (!this->CWD.empty()) { - xml.Element("WorkingDirectory", this->CWD); + e3.Element("WorkingDirectory", this->CWD); } for (std::string const& realArg : this->RealArgs) { - xml.Element("Argument", realArg); + e3.Element("Argument", realArg); } - xml.EndElement(); // Command } -void cmCTestLaunch::WriteXMLResult(cmXMLWriter& xml) +void cmCTestLaunch::WriteXMLResult(cmXMLElement& e2) { - xml.Comment("Result of command"); - xml.StartElement("Result"); + e2.Comment("Result of command"); + cmXMLElement e3(e2, "Result"); // StdOut - xml.StartElement("StdOut"); - this->DumpFileToXML(xml, this->LogOut); - xml.EndElement(); // StdOut + this->DumpFileToXML(e3, "StdOut", this->LogOut); // StdErr - xml.StartElement("StdErr"); - this->DumpFileToXML(xml, this->LogErr); - xml.EndElement(); // StdErr + this->DumpFileToXML(e3, "StdErr", this->LogErr); // ExitCondition - xml.StartElement("ExitCondition"); + cmXMLElement e4(e3, "ExitCondition"); cmsysProcess* cp = this->Process; switch (cmsysProcess_GetState(cp)) { case cmsysProcess_State_Starting: - xml.Content("No process has been executed"); + e4.Content("No process has been executed"); break; case cmsysProcess_State_Executing: - xml.Content("The process is still executing"); + e4.Content("The process is still executing"); break; case cmsysProcess_State_Disowned: - xml.Content("Disowned"); + e4.Content("Disowned"); break; case cmsysProcess_State_Killed: - xml.Content("Killed by parent"); + e4.Content("Killed by parent"); break; case cmsysProcess_State_Expired: - xml.Content("Killed when timeout expired"); + e4.Content("Killed when timeout expired"); break; case cmsysProcess_State_Exited: - xml.Content(this->ExitCode); + e4.Content(this->ExitCode); break; case cmsysProcess_State_Exception: - xml.Content("Terminated abnormally: "); - xml.Content(cmsysProcess_GetExceptionString(cp)); + e4.Content("Terminated abnormally: "); + e4.Content(cmsysProcess_GetExceptionString(cp)); break; case cmsysProcess_State_Error: - xml.Content("Error administrating child process: "); - xml.Content(cmsysProcess_GetErrorString(cp)); + e4.Content("Error administrating child process: "); + e4.Content(cmsysProcess_GetErrorString(cp)); break; - }; - xml.EndElement(); // ExitCondition - - xml.EndElement(); // Result + } } -void cmCTestLaunch::WriteXMLLabels(cmXMLWriter& xml) +void cmCTestLaunch::WriteXMLLabels(cmXMLElement& e2) { this->LoadLabels(); if (!this->Labels.empty()) { - xml.Comment("Interested parties"); - xml.StartElement("Labels"); + e2.Comment("Interested parties"); + cmXMLElement e3(e2, "Labels"); for (std::string const& label : this->Labels) { - xml.Element("Label", label); + e3.Element("Label", label); } - xml.EndElement(); // Labels } } -void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml, std::string const& fname) +void cmCTestLaunch::DumpFileToXML(cmXMLElement& e3, const char* tag, + std::string const& fname) { cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); std::string line; const char* sep = ""; + cmXMLElement e4(e3, tag); while (cmSystemTools::GetLineFromStream(fin, line)) { if (MatchesFilterPrefix(line)) { continue; @@ -507,8 +497,8 @@ void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml, std::string const& fname) } else if (this->Match(line, this->RegexWarning)) { line = "[CTest: warning matched] " + line; } - xml.Content(sep); - xml.Content(line); + e4.Content(sep); + e4.Content(line); sep = "\n"; } } diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index 29986ff..debbe59 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -10,7 +10,7 @@ #include <string> #include <vector> -class cmXMLWriter; +class cmXMLElement; /** \class cmCTestLaunch * \brief Launcher for make rules to report results for ctest @@ -89,11 +89,11 @@ private: // Methods to generate the xml fragment. void WriteXML(); - void WriteXMLAction(cmXMLWriter& xml); - void WriteXMLCommand(cmXMLWriter& xml); - void WriteXMLResult(cmXMLWriter& xml); - void WriteXMLLabels(cmXMLWriter& xml); - void DumpFileToXML(cmXMLWriter& xml, std::string const& fname); + void WriteXMLAction(cmXMLElement&); + void WriteXMLCommand(cmXMLElement&); + void WriteXMLResult(cmXMLElement&); + void WriteXMLLabels(cmXMLElement&); + void DumpFileToXML(cmXMLElement&, const char* tag, std::string const& fname); // Configuration void LoadConfig(); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 136cf39..6c9f9d6 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -40,6 +40,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, argv.push_back(std::move(parsed_arg)); } } + + // Later code assumes at least one entry exists, but expanding + // lists on an empty command may have left this empty. + // FIXME: Should we define behavior for removing empty commands? + if (argv.empty()) { + argv.push_back(std::string()); + } + this->CommandLines.push_back(std::move(argv)); } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 93c78b5..566a2a9 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -994,6 +994,9 @@ void cmQtAutoGenInitializer::SetupCustomTargets() // Generate auto RCC info files if (this->RccEnabled) { for (Qrc const& qrc : this->Qrcs) { + // Register rcc info file as generated + makefile->AddCMakeOutputFile(qrc.InfoFile); + cmGeneratedFileStream ofs; ofs.SetCopyIfDifferent(true); ofs.Open(qrc.InfoFile.c_str(), false, true); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 6c81d76..05f00da 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3287,9 +3287,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( "CUDA") != linkClosure->Languages.end()) { switch (this->CudaOptions[config]->GetCudaRuntime()) { case cmVisualStudioGeneratorOptions::CudaRuntimeStatic: + libVec.push_back("cudadevrt.lib"); libVec.push_back("cudart_static.lib"); break; case cmVisualStudioGeneratorOptions::CudaRuntimeShared: + libVec.push_back("cudadevrt.lib"); libVec.push_back("cudart.lib"); break; case cmVisualStudioGeneratorOptions::CudaRuntimeNone: diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index ff0df18..d124907 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -181,6 +181,12 @@ public: { xmlwr.Content(content); } + template <typename T> + void Element(std::string const& name, T const& value) + { + xmlwr.Element(name, value); + } + void Comment(const char* comment) { xmlwr.Comment(comment); } private: cmXMLWriter& xmlwr; diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 4fc176b..96088c8 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -196,6 +196,11 @@ IF(KWSYS_STANDALONE) ENDIF() ENDIF() +# Choose default shared/static build if not specified. +IF(NOT DEFINED KWSYS_BUILD_SHARED) + SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS}) +ENDIF() + # Include helper macros. INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake) INCLUDE(CheckTypeSize) @@ -230,13 +235,14 @@ ENDIF() # Setup library install rules. SET(KWSYS_INSTALL_LIBRARY_RULE) +SET(KWSYS_INSTALL_NAMELINK_RULE) IF(KWSYS_INSTALL_LIB_DIR) IF(KWSYS_INSTALL_EXPORT_NAME) LIST(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME}) ENDIF() # Install the shared library to the lib directory. SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} - LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} + LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_SKIP ) # Assign the shared library to the runtime component. IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) @@ -244,6 +250,17 @@ IF(KWSYS_INSTALL_LIB_DIR) COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) ENDIF() + IF(KWSYS_BUILD_SHARED) + SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE} + LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_ONLY + ) + # Assign the namelink to the development component. + IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) + SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE} + COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} + ) + ENDIF() + ENDIF() # Install the archive to the lib directory. SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} @@ -427,11 +444,6 @@ ELSE() SET(KWSYS_NAME_IS_KWSYS 0) ENDIF() -# Choose default shared/static build if not specified. -IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$") - SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS}) -ENDIF() - IF(KWSYS_BUILD_SHARED) SET(KWSYS_BUILD_SHARED 1) SET(KWSYS_LIBRARY_TYPE SHARED) @@ -933,6 +945,9 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) IF(KWSYS_INSTALL_LIBRARY_RULE) INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE}) ENDIF() + IF(KWSYS_INSTALL_NAMELINK_RULE) + INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_NAMELINK_RULE}) + ENDIF() ENDIF() # Add a C-only library if requested. diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in index 3cbbeb8..92e4b36 100644 --- a/Source/kwsys/RegularExpression.hxx.in +++ b/Source/kwsys/RegularExpression.hxx.in @@ -218,7 +218,7 @@ inline std::string RegularExpressionMatch::match(int n) const * object as an argument and creates an object initialized with the * information from the given RegularExpression object. * - * The find member function finds the first occurrence of the regular + * The find member function finds the first occurrence of the regular * expression of that object in the string given to find as an argument. Find * returns a boolean, and if true, mutates the private data appropriately. * Find sets pointers to the beginning and end of the thing last found, they @@ -230,9 +230,9 @@ inline std::string RegularExpressionMatch::match(int n) const * the to see if the compiled regular expression is the same, and the * deep_equal functions also checks to see if the start and end pointers are * the same. The is_valid function returns false if program is set to NULL, - * (i.e. there is no valid compiled exression). The set_invalid function sets - * the program to NULL (Warning: this deletes the compiled expression). The - * following examples may help clarify regular expression usage: + * (i.e. there is no valid compiled expression). The set_invalid function + * sets the program to NULL (Warning: this deletes the compiled expression). + * The following examples may help clarify regular expression usage: * * * The regular expression "^hello" matches a "hello" only at the * beginning of a line. It would match "hello there" but not "hi, @@ -270,13 +270,13 @@ inline std::string RegularExpressionMatch::match(int n) const * * * The regular expression "(..p)b" matches something ending with pb * and beginning with whatever the two characters before the first p - * encounterd in the line were. It would find "repb" in "rep drepa + * encountered in the line were. It would find "repb" in "rep drepa * qrepb". The regular expression "(..p)a" would find "repa qrepb" * in "rep drepa qrepb" * * * The regular expression "d(..p)" matches something ending with p, * beginning with d, and having two characters in between that are - * the same as the two characters before the first p encounterd in + * the same as the two characters before the first p encountered in * the line. It would match "drepa qrepb" in "rep drepa qrepb". * * All methods of RegularExpression can be called simultaneously from diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 7426816..37dec13 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -1270,7 +1270,7 @@ public: long GetLineNumber() const { return this->LineNumber; } // Description: - // Set the address where the biinary image is mapped + // Set the address where the binary image is mapped // into memory. void SetBinaryBaseAddress(void* address) { @@ -4061,7 +4061,7 @@ bool SystemInformationImplementation::QueryLinuxMemory() if (linuxMajor >= 3 || ((linuxMajor >= 2) && (linuxMinor >= 6))) { // new /proc/meminfo format since kernel 2.6.x - // Rigorously, this test should check from the developping version 2.5.x + // Rigorously, this test should check from the developing version 2.5.x // that introduced the new format... enum diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx index 78baed9..58f861c 100644 --- a/Source/kwsys/testCommandLineArguments.cxx +++ b/Source/kwsys/testCommandLineArguments.cxx @@ -136,7 +136,7 @@ int testCommandLineArguments(int argc, char* argv[]) arg.AddCallback("-C", argT::EQUAL_ARGUMENT, argument, random_ptr, "Option -C takes argument after ="); arg.AddCallback("-D", argT::CONCAT_ARGUMENT, argument, random_ptr, - "This option takes concatinated argument"); + "This option takes concatenated argument"); arg.AddCallback("--long1", argT::NO_ARGUMENT, argument, random_ptr, "-A"); arg.AddCallback("--long2", argT::SPACE_ARGUMENT, argument, random_ptr, "-B"); arg.AddCallback("--long3", argT::EQUAL_ARGUMENT, argument, random_ptr, 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/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index 606b1df..1150568 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -85,3 +85,15 @@ pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakep if (NOT TARGET PkgConfig::FakePackage2) message(FATAL_ERROR "No import target for fake package 2 with prefix path") endif() + +# check that the full library path is also returned +if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") + message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}") +endif() + +# the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run +unset(FakePackage2_LINK_LIBRARIES) +pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2) +if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") + message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}") +endif() diff --git a/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake new file mode 100644 index 0000000..bc899a4 --- /dev/null +++ b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake @@ -0,0 +1 @@ +add_custom_target(EmptyCustom COMMAND "" COMMAND_EXPAND_LISTS) diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake index 6c4e91b..2caed03 100644 --- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(CommandExpandsEmpty) run_cmake(NoArguments) run_cmake(BadTargetName) run_cmake(ByproductsNoCommand) |