diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPack.NuGet.nuspec.in | 24 | ||||
-rw-r--r-- | Modules/CPack.cmake | 11 | ||||
-rw-r--r-- | Modules/CPackNuGet.cmake | 556 | ||||
-rw-r--r-- | Modules/FindBLAS.cmake | 11 | ||||
-rw-r--r-- | Modules/FindJPEG.cmake | 2 | ||||
-rw-r--r-- | Modules/FindPkgConfig.cmake | 39 | ||||
-rw-r--r-- | Modules/FindQt4.cmake | 46 | ||||
-rw-r--r-- | Modules/InstallRequiredSystemLibraries.cmake | 18 | ||||
-rw-r--r-- | Modules/Qt4Macros.cmake | 25 |
9 files changed, 663 insertions, 69 deletions
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/FindQt4.cmake b/Modules/FindQt4.cmake index 5a7eadb..847a798 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -547,15 +547,11 @@ if (QT_QMAKE_EXECUTABLE AND if(NOT WIN32) string(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") endif() - set(qt_cross_paths) - foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) - set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/mkspecs") - endforeach() - set(QT_MKSPECS_DIR NOTFOUND) + find_path(QT_MKSPECS_DIR NAMES qconfig.pri - HINTS ${qt_cross_paths} ${qt_mkspecs_dirs} - DOC "The location of the Qt mkspecs containing qconfig.pri" - NO_CMAKE_FIND_ROOT_PATH) + HINTS ${qt_mkspecs_dirs} + PATH_SUFFIXES mkspecs share/qt4/mkspecs + DOC "The location of the Qt mkspecs containing qconfig.pri") endif() if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") @@ -709,14 +705,15 @@ if (QT_QMAKE_EXECUTABLE AND # ask qmake for the plugins directory if (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) _qt4_query_qmake(QT_INSTALL_PLUGINS qt_plugins_dir) - set(QT_PLUGINS_DIR NOTFOUND) - foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) - set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/plugins") - endforeach() - find_path(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer - HINTS ${qt_cross_paths} ${qt_plugins_dir} - DOC "The location of the Qt plugins" - NO_CMAKE_FIND_ROOT_PATH) + if(CMAKE_CROSSCOMPILING OR NOT qt_plugins_dir) + find_path(QT_PLUGINS_DIR + NAMES accessible bearer codecs designer graphicssystems iconengines imageformats inputmethods qmltooling script sqldrivers + HINTS ${qt_plugins_dir} + PATH_SUFFIXES plugins lib/qt4/plugins + DOC "The location of the Qt plugins") + else() + set(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins") + endif() endif () # ask qmake for the translations directory @@ -728,18 +725,13 @@ if (QT_QMAKE_EXECUTABLE AND # ask qmake for the imports directory if (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR OR QT_QMAKE_CHANGED) _qt4_query_qmake(QT_INSTALL_IMPORTS qt_imports_dir) - if(qt_imports_dir) - set(QT_IMPORTS_DIR NOTFOUND) - foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) - set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/imports") - endforeach() + if(CMAKE_CROSSCOMPILING OR NOT qt_imports_dir) find_path(QT_IMPORTS_DIR NAMES Qt - HINTS ${qt_cross_paths} ${qt_imports_dir} - DOC "The location of the Qt imports" - NO_CMAKE_FIND_ROOT_PATH - NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - mark_as_advanced(QT_IMPORTS_DIR) + HINTS ${qt_imports_dir} + PATH_SUFFIXES imports lib/qt4/imports + DOC "The location of the Qt imports") + else() + set(QT_IMPORTS_DIR ${qt_imports_dir} CACHE PATH "The location of the Qt imports") endif() endif () 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") |