diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/BundleUtilities.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeFindCodeBlocks.cmake | 15 | ||||
-rw-r--r-- | Modules/CMakeFindEclipseCDT4.cmake | 4 | ||||
-rw-r--r-- | Modules/CMakeTestCompilerCommon.cmake | 6 | ||||
-rw-r--r-- | Modules/CPackDeb.cmake | 6 | ||||
-rw-r--r-- | Modules/CPackRPM.cmake | 311 | ||||
-rw-r--r-- | Modules/CPackWIX.cmake | 6 | ||||
-rw-r--r-- | Modules/CTestCoverageCollectGCOV.cmake | 64 | ||||
-rw-r--r-- | Modules/Compiler/GNU.cmake | 2 | ||||
-rw-r--r-- | Modules/Compiler/IAR-C.cmake | 3 | ||||
-rw-r--r-- | Modules/Compiler/IAR-CXX.cmake | 3 | ||||
-rw-r--r-- | Modules/FindCUDA/make2cmake.cmake | 18 | ||||
-rw-r--r-- | Modules/FindCUDA/run_nvcc.cmake | 1 | ||||
-rw-r--r-- | Modules/FindProtobuf.cmake | 104 | ||||
-rw-r--r-- | Modules/FindwxWidgets.cmake | 30 | ||||
-rw-r--r-- | Modules/FortranCInterface.cmake | 313 |
16 files changed, 525 insertions, 363 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 45dda40..4b52afa 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -479,7 +479,7 @@ function(set_bundle_key_values keys_var context item exepath dirs copyflag) get_item_rpaths("${resolved_item}" item_rpaths) - if(item MATCHES "[^/]+\\.framework/") + if((NOT item MATCHES "\\.dylib$") AND (item MATCHES "[^/]+\\.framework/")) # For frameworks, construct the name under the embedded path from the # opening "${item_name}.framework/" to the closing "/${item_name}": # diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake index f8d8d59..bf85ea0 100644 --- a/Modules/CMakeFindCodeBlocks.cmake +++ b/Modules/CMakeFindCodeBlocks.cmake @@ -23,3 +23,18 @@ endif() # Determine builtin macros and include dirs: include(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake) + +# Try to find out how many CPUs we have and set the -j argument for make accordingly +set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "") + +include(ProcessorCount) +processorcount(_CMAKE_CODEBLOCKS_PROCESSOR_COUNT) + +# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name +# (we may also get here in the future e.g. for ninja) +if("${_CMAKE_CODEBLOCKS_PROCESSOR_COUNT}" GREATER 1 AND CMAKE_HOST_UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) + set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "-j${_CMAKE_CODEBLOCKS_PROCESSOR_COUNT}") +endif() + +# This variable is used by the CodeBlocks generator and appended to the make invocation commands. +set(CMAKE_CODEBLOCKS_MAKE_ARGUMENTS "${_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when CodeBlocks invokes make. Enter e.g. -j<some_number> to get parallel builds") diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index 85c1fdf..5bf738a 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -30,6 +30,8 @@ function(_FIND_ECLIPSE_VERSION) set(_ECLIPSE_VERSION_NAME_3.7 "Indigo" ) set(_ECLIPSE_VERSION_NAME_4.2 "Juno" ) set(_ECLIPSE_VERSION_NAME_4.3 "Kepler" ) + set(_ECLIPSE_VERSION_NAME_4.4 "Luna" ) + set(_ECLIPSE_VERSION_NAME_4.5 "Mars" ) if(NOT DEFINED CMAKE_ECLIPSE_VERSION) if(CMAKE_ECLIPSE_EXECUTABLE) @@ -65,6 +67,8 @@ function(_FIND_ECLIPSE_VERSION) "3.7 (${_ECLIPSE_VERSION_NAME_3.7})" "4.2 (${_ECLIPSE_VERSION_NAME_4.2})" "4.3 (${_ECLIPSE_VERSION_NAME_4.3})" + "4.4 (${_ECLIPSE_VERSION_NAME_4.4})" + "4.5 (${_ECLIPSE_VERSION_NAME_4.5})" ) endfunction() diff --git a/Modules/CMakeTestCompilerCommon.cmake b/Modules/CMakeTestCompilerCommon.cmake index d51b503..e0d45e7 100644 --- a/Modules/CMakeTestCompilerCommon.cmake +++ b/Modules/CMakeTestCompilerCommon.cmake @@ -13,9 +13,5 @@ # License text for the above reference.) function(PrintTestCompilerStatus LANG MSG) - if(CMAKE_GENERATOR MATCHES Make) - message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") - else() - message(STATUS "Check for working ${LANG} compiler using: ${CMAKE_GENERATOR}${MSG}") - endif() + message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") endfunction() diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 2aaef61..b41d926 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -504,6 +504,9 @@ function(cpack_deb_prepare_package_vars) file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian) file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "") + # Create a DEBIAN directory so that dpkg-shlibdeps can find the package dir when resolving $ORIGIN. + file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN") + # Add --ignore-missing-info if the tool supports it execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help OUTPUT_VARIABLE _TMP_HELP @@ -544,6 +547,9 @@ function(cpack_deb_prepare_package_vars) # Remove blank control file # Might not be safe if package actual contain file or directory named debian file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian") + + # remove temporary directory that was created only for dpkg-shlibdeps execution + file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN") else() if(CPACK_DEBIAN_PACKAGE_DEBUG) message(AUTHOR_WARNING "CPackDeb Debug: Using only user-provided depends because package does not contain executable files that link to shared libraries.") diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 7fb11c3..7ffec13 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -7,25 +7,35 @@ # Variables specific to CPack RPM generator # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # -# CPackRPM may be used to create RPM package using CPack. CPackRPM is a -# CPack generator thus it uses the CPACK_XXX variables used by CPack : -# https://cmake.org/Wiki/CMake:CPackConfiguration -# -# However CPackRPM has specific features which are controlled by the -# specifics CPACK_RPM_XXX variables. CPackRPM is a component aware -# generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more -# CPACK_RPM_<ComponentName>_XXXX variables may be used in order to have -# component specific values. Note however that <componentName> refers -# to the **grouping name**. This may be either a component name or a -# component GROUP name. Usually those vars correspond to RPM spec file -# entities, one may find information about spec files here -# http://www.rpm.org/wiki/Docs. You'll find a detailed usage of -# CPackRPM on the wiki: -# -# :: +# CPackRPM may be used to create RPM package using CPack. +# CPackRPM is a CPack generator thus it uses the ``CPACK_XXX`` variables +# used by CPack : https://cmake.org/Wiki/CMake:CPackConfiguration. # -# https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29 +# CPackRPM has specific features which are controlled by the specifics +# :code:`CPACK_RPM_XXX` variables. # +# :code:`CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have +# **component** specific values. Note however that ``<COMPONENT>`` refers to the +# **grouping name** written in upper case. It may be either a component name or +# a component GROUP name. Usually those vars correspond to RPM spec file +# entities, one may find information about spec files here +# http://www.rpm.org/wiki/Docs +# +# .. note:: +# +# `<COMPONENT>` part of variables is prefered to be in upper case (for e.g. if +# component is named `foo` then use `CPACK_RPM_FOO_XXXX` variable name format) +# as is with other `CPACK_<COMPONENT>_XXXX` variables. +# For the purposes of back compatibility (CMake/CPack version 3.5 and lower) +# support for same cased component (e.g. `fOo` would be used as +# `CPACK_RPM_fOo_XXXX`) is still supported for variables defined in older +# versions of CMake/CPack but is not guaranteed for variables that +# will be added in the future. For the sake of back compatibility same cased +# component variables also override upper cased versions where both are +# present. +# +# List of CPack/RPM specific variables: +# https://cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29 . # However as a handy reminder here comes the list of specific variables: # # .. variable:: CPACK_RPM_PACKAGE_SUMMARY @@ -557,7 +567,7 @@ # invalid location. #============================================================================= -# Copyright 2007-2009 Kitware, Inc. +# Copyright 2007-2016 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -575,6 +585,8 @@ function(cpack_rpm_prepare_relocation_paths) # set appropriate prefix, remove possible trailing slash and convert backslashes to slashes if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX) file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX) + elseif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX) + file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX}" PATH_PREFIX) else() file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX) endif() @@ -585,7 +597,8 @@ function(cpack_rpm_prepare_relocation_paths) # set base path prefix if(EXISTS "${WDIR}/${PATH_PREFIX}") if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND - NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION) + NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND + NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION) set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n") list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}") @@ -1044,6 +1057,17 @@ if(NOT UNIX) message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.") endif() +function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME) + set(FALLBACK_VAR_NAMES ${ARGN}) + + foreach(variable_name IN LISTS FALLBACK_VAR_NAMES) + if(${variable_name}) + set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE) + break() + endif() + endforeach() +endfunction() + function(cpack_rpm_generate_package) # rpmbuild is the basic command for building RPM package # it may be a simple (symbolic) link to rpm command. @@ -1124,12 +1148,10 @@ function(cpack_rpm_generate_package) # CPACK_RPM_PACKAGE_SUMMARY (mandatory) - #Check for component summary first. - #If not set, it will use regular package summary logic. if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY) - set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY}) - endif() + cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_SUMMARY" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_SUMMARY") endif() if(NOT CPACK_RPM_PACKAGE_SUMMARY) @@ -1142,17 +1164,15 @@ function(cpack_rpm_generate_package) endif() # CPACK_RPM_PACKAGE_NAME (mandatory) - if(NOT CPACK_RPM_PACKAGE_NAME) string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) endif() if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME) - set(CPACK_RPM_PACKAGE_NAME ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME}) - else() - set(CPACK_RPM_PACKAGE_NAME ${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT}) - endif() + set(CPACK_RPM_PACKAGE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT}") + cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME") endif() # CPACK_RPM_PACKAGE_VERSION (mandatory) @@ -1179,19 +1199,18 @@ function(cpack_rpm_generate_package) endif() endif() - set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE}) - - #prefer component architecture if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE) - set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: using component build arch = ${_CPACK_RPM_PACKAGE_ARCHITECTURE}") - endif() + cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_ARCHITECTURE" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_ARCHITECTURE") + + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") endif() endif() - if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch") - set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}") + + if(${CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch") + set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}") else() set(TMP_RPM_BUILDARCH "") endif() @@ -1214,13 +1233,10 @@ function(cpack_rpm_generate_package) endif() # CPACK_RPM_PACKAGE_GROUP - - #Check for component group first. - #If not set, it will use regular package group logic. if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP) - set(CPACK_RPM_PACKAGE_GROUP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP}) - endif() + cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_GROUP" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_GROUP") endif() if(NOT CPACK_RPM_PACKAGE_GROUP) @@ -1247,14 +1263,11 @@ function(cpack_rpm_generate_package) # - set to a default value # - #Check for a component description first. - #If not set, it will use regular package description logic. if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION) - set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION}) - elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION) - set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION}) - endif() + cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_DESCRIPTION" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_DESCRIPTION" + "CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION") endif() if(NOT CPACK_RPM_PACKAGE_DESCRIPTION) @@ -1306,32 +1319,21 @@ function(cpack_rpm_generate_package) # If component specific var is not provided we use the global one # for each component foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") + endif() + if(CPACK_RPM_PACKAGE_COMPONENT) + cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_${_RPM_SPEC_HEADER}") + endif() + + if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") - endif() - if(CPACK_RPM_PACKAGE_COMPONENT) - if(DEFINED CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}") - endif() - set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}}) - else() - if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined") - message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") - endif() - set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) - endif() - endif() - else() - if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") - endif() - set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) - endif() + message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") endif() + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) + endif() # Treat the RPM Spec keyword iff it has been properly defined if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) @@ -1373,94 +1375,38 @@ function(cpack_rpm_generate_package) # May be used to embed a post (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %post or %postun section - if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE) - set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE}) - else() - set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - endif() - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) - set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE}) - else() - set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) - endif() - else() - set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) - endif() - - # Handle post-install file if it has been specified - if(CPACK_RPM_POST_INSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) - file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL) - else() - message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring") - endif() - else() - # reset SPEC var value if no post install file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_POSTINSTALL "") - endif() - - # Handle post-uninstall file if it has been specified - if(CPACK_RPM_POST_UNINSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) - file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) - else() - message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring") - endif() - else() - # reset SPEC var value if no post uninstall file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_POSTUNINSTALL "") - endif() - + # ---------------------------------------------------------------- # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE) # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE) # May be used to embed a pre (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %pre or %preun section - if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) - set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE}) - else() - set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - endif() - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) - set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE}) - else() - set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) - endif() - else() - set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) - endif() + foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL") + foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST") + set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE" + "${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}") - # Handle pre-install file if it has been specified - if(CPACK_RPM_PRE_INSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) - file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL) - else() - message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring") - endif() - else() - # reset SPEC var value if no pre-install file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_PREINSTALL "") - endif() + if(CPACK_RPM_PACKAGE_COMPONENT) + cpack_rpm_variable_fallback("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE") + endif() - # Handle pre-uninstall file if it has been specified - if(CPACK_RPM_PRE_UNINSTALL_READ_FILE) - if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) - file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL) - else() - message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring") - endif() - else() - # reset SPEC var value if no pre-uninstall file has been specified - # (either globally or component-wise) - set(CPACK_RPM_SPEC_PREUNINSTALL "") - endif() + # Handle file if it has been specified + if(CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE) + if(EXISTS ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}) + file(READ ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE} + "CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}") + else() + message("CPackRPM:Warning: CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE <${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}> does not exists - ignoring") + endif() + else() + # reset SPEC var value if no file has been specified + # (either globally or component-wise) + set("CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "") + endif() + endforeach() + endforeach() # CPACK_RPM_CHANGELOG_FILE # May be used to embed a changelog in the spec file. @@ -1495,7 +1441,7 @@ function(cpack_rpm_generate_package) file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS) file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS) - #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${_CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") + #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") # it seems rpmbuild can't handle spaces in the path # neither escaping (as below) nor putting quotes around the path seem to help @@ -1510,12 +1456,14 @@ function(cpack_rpm_generate_package) # This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_ABSOLUTE_DESTINATION_FILES) - set(COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}") - set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}") - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>") - message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") - endif() + cpack_rpm_variable_fallback("COMPONENT_FILES_TAG" + "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}" + "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}") + set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}") + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>") + message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") + endif() endif() else() if(CPACK_ABSOLUTE_DESTINATION_FILES) @@ -1524,22 +1472,18 @@ function(cpack_rpm_generate_package) endif() # In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST. + set(CPACK_RPM_USER_FILELIST_INTERNAL "") if(CPACK_RPM_PACKAGE_COMPONENT) - if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST) - set(CPACK_RPM_USER_FILELIST_INTERNAL ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST}) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") - message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") - endif() - else() - set(CPACK_RPM_USER_FILELIST_INTERNAL "") - endif() - else() - if(CPACK_RPM_USER_FILELIST) - set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}") - else() - set(CPACK_RPM_USER_FILELIST_INTERNAL "") + cpack_rpm_variable_fallback("CPACK_RPM_USER_FILELIST_INTERNAL" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_FILELIST") + + if(CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL) + message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") + message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") endif() + elseif(CPACK_RPM_USER_FILELIST) + set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}") endif() # Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL @@ -1578,7 +1522,6 @@ function(cpack_rpm_generate_package) if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) endif() - endforeach() # Rebuild CPACK_RPM_INSTALL_FILES @@ -1650,8 +1593,10 @@ function(cpack_rpm_generate_package) # # We can have a component specific spec file. - if(CPACK_RPM_PACKAGE_COMPONENT AND CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE) - set(CPACK_RPM_USER_BINARY_SPECFILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE}) + if(CPACK_RPM_PACKAGE_COMPONENT) + cpack_rpm_variable_fallback("CPACK_RPM_USER_BINARY_SPECFILE" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE") endif() # We should generate a USER spec file template: @@ -1762,7 +1707,7 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT COMMAND "${RPMBUILD_EXECUTABLE}" -bb --define "_topdir ${CPACK_RPM_DIRECTORY}" --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" - --target "${_CPACK_RPM_PACKAGE_ARCHITECTURE}" + --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}" "${CPACK_RPM_BINARY_SPECFILE}" WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 4994005..3c90561 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -234,7 +234,7 @@ # * ARPCOMMENTS - Comments # * ARPHELPLINK - Help and support information URL # * ARPURLINFOABOUT - General information URL -# * URLUPDATEINFO - Update information URL +# * ARPURLUPDATEINFO - Update information URL # * ARPHELPTELEPHONE - Help and support telephone number # * ARPSIZE - Size (in kilobytes) of the application @@ -256,14 +256,14 @@ if(NOT CPACK_WIX_ROOT) endif() find_program(CPACK_WIX_CANDLE_EXECUTABLE candle - PATHS "${CPACK_WIX_ROOT}/bin") + PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin") if(NOT CPACK_WIX_CANDLE_EXECUTABLE) message(FATAL_ERROR "Could not find the WiX candle executable.") endif() find_program(CPACK_WIX_LIGHT_EXECUTABLE light - PATHS "${CPACK_WIX_ROOT}/bin") + PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin") if(NOT CPACK_WIX_LIGHT_EXECUTABLE) message(FATAL_ERROR "Could not find the WiX light executable.") diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index ef3aa76..f31e432 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -46,6 +46,13 @@ # is run as ``gcov <options>... -o <gcov-dir> <file>.gcda``. # If not specified, the default option is just ``-b``. # +# ``GLOB`` +# Recursively search for .gcda files in build_dir rather than +# determining search locations by reading TargetDirectories.txt. +# +# ``DELETE`` +# Delete coverage files after they've been packaged into the .tar. +# # ``QUIET`` # Suppress non-error messages that otherwise would have been # printed out by this function. @@ -64,7 +71,7 @@ # License text for the above reference.) include(CMakeParseArguments) function(ctest_coverage_collect_gcov) - set(options QUIET) + set(options QUIET GLOB DELETE) set(oneValueArgs TARBALL SOURCE BUILD GCOV_COMMAND) set(multiValueArgs GCOV_OPTIONS) cmake_parse_arguments(GCOV "${options}" "${oneValueArgs}" @@ -91,22 +98,32 @@ function(ctest_coverage_collect_gcov) # run gcov on each gcda file in the binary tree set(gcda_files) set(label_files) - # look for gcda files in the target directories - # could do a glob from the top of the binary tree but - # this will be faster and only look where the files will be - file(STRINGS "${binary_dir}/CMakeFiles/TargetDirectories.txt" target_dirs - ENCODING UTF-8) - foreach(target_dir ${target_dirs}) - file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${target_dir}/*.gcda") - list(LENGTH gfiles len) - # if we have gcda files then also grab the labels file for that target - if(${len} GREATER 0) - file(GLOB_RECURSE lfiles RELATIVE ${binary_dir} - "${target_dir}/Labels.json") - list(APPEND gcda_files ${gfiles}) - list(APPEND label_files ${lfiles}) - endif() - endforeach() + if (GCOV_GLOB) + file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "*.gcda") + list(LENGTH gfiles len) + # if we have gcda files then also grab the labels file for that target + if(${len} GREATER 0) + file(GLOB_RECURSE lfiles RELATIVE ${binary_dir} "Labels.json") + list(APPEND gcda_files ${gfiles}) + list(APPEND label_files ${lfiles}) + endif() + else() + # look for gcda files in the target directories + # this will be faster and only look where the files will be + file(STRINGS "${binary_dir}/CMakeFiles/TargetDirectories.txt" target_dirs + ENCODING UTF-8) + foreach(target_dir ${target_dirs}) + file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${target_dir}/*.gcda") + list(LENGTH gfiles len) + # if we have gcda files then also grab the labels file for that target + if(${len} GREATER 0) + file(GLOB_RECURSE lfiles RELATIVE ${binary_dir} + "${target_dir}/Labels.json") + list(APPEND gcda_files ${gfiles}) + list(APPEND label_files ${lfiles}) + endif() + endforeach() + endif() # return early if no coverage files were found list(LENGTH gcda_files len) if(len EQUAL 0) @@ -134,6 +151,11 @@ function(ctest_coverage_collect_gcov) OUTPUT_VARIABLE out RESULT_VARIABLE res WORKING_DIRECTORY ${coverage_dir}) + + if (GCOV_DELETE) + file(REMOVE ${gcda_file}) + endif() + endforeach() if(NOT "${res}" EQUAL 0) if (NOT GCOV_QUIET) @@ -201,4 +223,12 @@ ${label_files} "--format=gnutar" --files-from=${coverage_dir}/coverage_file_list.txt WORKING_DIRECTORY ${binary_dir}) + + if (GCOV_DELETE) + string(REPLACE "\n" ";" gcov_files "${gcov_files}") + foreach(gcov_file ${gcov_files}) + file(REMOVE ${binary_dir}/${gcov_file}) + endforeach() + endif() + endfunction() diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 764fbf9..d1ca85e 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -52,7 +52,7 @@ macro(__compiler_gnu lang) set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") - if(NOT APPLE) + if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462 set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") endif() endmacro() diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake index d2c7df9..f1b6ff7 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -7,6 +7,9 @@ set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <I set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy") +set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "-f") +set(CMAKE_DEPFILE_FLAGS_C "--dependencies=ns <DEPFILE>") + # The toolchains for ARM and AVR are quite different: if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM") diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index 03ecdf1..ffb144f 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -7,7 +7,8 @@ set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>") set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy") - +set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "-f") +set(CMAKE_DEPFILE_FLAGS_CXX "--dependencies=ns <DEPFILE>") if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM") diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake index c433fa8..802f93a 100644 --- a/Modules/FindCUDA/make2cmake.cmake +++ b/Modules/FindCUDA/make2cmake.cmake @@ -35,6 +35,16 @@ # This converts a file written in makefile syntax into one that can be included # by CMake. +# Input variables +# +# verbose:BOOL=<> OFF: Be as quiet as possible (default) +# ON : Extra output +# +# input_file:FILEPATH=<> Path to dependecy file in makefile format +# +# output_file:FILEPATH=<> Path to file with dependencies in CMake readable variable +# + file(READ ${input_file} depend_text) if (NOT "${depend_text}" STREQUAL "") @@ -62,12 +72,16 @@ if (NOT "${depend_text}" STREQUAL "") if (EXISTS "/${file}") set(file "/${file}") else() - message(WARNING " Removing non-existent dependency file: ${file}") + if(verbose) + message(WARNING " Removing non-existent dependency file: ${file}") + endif() set(file "") endif() endif() - if(NOT IS_DIRECTORY "${file}") + # Make sure we check to see if we have a file, before asking if it is not a directory. + # if(NOT IS_DIRECTORY "") will return TRUE. + if(file AND NOT IS_DIRECTORY "${file}") # If softlinks start to matter, we should change this to REALPATH. For now we need # to flatten paths, because nvcc can generate stuff like /bin/../include instead of # just /include. diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index 8032309..12b83e0 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -207,6 +207,7 @@ cuda_execute_process( COMMAND "${CMAKE_COMMAND}" -D "input_file:FILEPATH=${NVCC_generated_dependency_file}" -D "output_file:FILEPATH=${cmake_dependency_file}.tmp" + -D "verbose=${verbose}" -P "${CUDA_make2cmake}" ) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 2f13b09..95e3b1e 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -15,12 +15,16 @@ # ``PROTOBUF_IMPORT_DIRS`` # List of additional directories to be searched for # imported .proto files. +# ``PROTOBUF_DEBUG`` +# Show debug messages. # # Defines the following variables: # # ``PROTOBUF_FOUND`` # Found the Google Protocol Buffers library # (libprotobuf & header files) +# ``PROTOBUF_VERSION`` +# Version of package found. # ``PROTOBUF_INCLUDE_DIRS`` # Include directories for Google Protocol Buffers # ``PROTOBUF_LIBRARIES`` @@ -210,32 +214,33 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_PROTOBUF_ARCH_DIR x64/) endif() +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + # Internal function: search for normal library as well as a debug one # if the debug one is specified also include debug/optimized keywords # in *_LIBRARIES variable function(_protobuf_find_libraries name filename) - find_library(${name}_LIBRARY - NAMES ${filename} - PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release) - mark_as_advanced(${name}_LIBRARY) - - find_library(${name}_LIBRARY_DEBUG - NAMES ${filename} - PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug) - mark_as_advanced(${name}_LIBRARY_DEBUG) - - if(NOT ${name}_LIBRARY_DEBUG) - # There is no debug library - set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE) - set(${name}_LIBRARIES ${${name}_LIBRARY} PARENT_SCOPE) - else() - # There IS a debug library - set(${name}_LIBRARIES - optimized ${${name}_LIBRARY} - debug ${${name}_LIBRARY_DEBUG} - PARENT_SCOPE - ) - endif() + if(${name}_LIBRARIES) + # Use result recorded by a previous call. + return() + elseif(${name}_LIBRARY) + # Honor cache entry used by CMake 3.5 and lower. + set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE) + else() + find_library(${name}_LIBRARY_RELEASE + NAMES ${filename} + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release) + mark_as_advanced(${name}_LIBRARY_RELEASE) + + find_library(${name}_LIBRARY_DEBUG + NAMES ${filename} + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug) + mark_as_advanced(${name}_LIBRARY_DEBUG) + + select_library_configurations(${name}) + set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE) + set(${name}_LIBRARIES "${${name}_LIBRARIES}" PARENT_SCOPE) + endif() endfunction() # Internal function: find threads library @@ -303,10 +308,61 @@ find_program(PROTOBUF_PROTOC_EXECUTABLE ) mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE) +if(PROTOBUF_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "requested version of Google Protobuf is ${Protobuf_FIND_VERSION}") +endif() + +if(PROTOBUF_INCLUDE_DIR) + set(_PROTOBUF_COMMON_HEADER ${PROTOBUF_INCLUDE_DIR}/google/protobuf/stubs/common.h) + + if(PROTOBUF_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "location of common.h: ${_PROTOBUF_COMMON_HEADER}") + endif() + + set(PROTOBUF_VERSION "") + set(PROTOBUF_LIB_VERSION "") + file(STRINGS ${_PROTOBUF_COMMON_HEADER} _PROTOBUF_COMMON_H_CONTENTS REGEX "#define[ \t]+GOOGLE_PROTOBUF_VERSION[ \t]+") + if(_PROTOBUF_COMMON_H_CONTENTS MATCHES "#define[ \t]+GOOGLE_PROTOBUF_VERSION[ \t]+([0-9]+)") + set(PROTOBUF_LIB_VERSION "${CMAKE_MATCH_1}") + endif() + unset(_PROTOBUF_COMMON_H_CONTENTS) + + math(EXPR _PROTOBUF_MAJOR_VERSION "${PROTOBUF_LIB_VERSION} / 1000000") + math(EXPR _PROTOBUF_MINOR_VERSION "${PROTOBUF_LIB_VERSION} / 1000 % 1000") + math(EXPR _PROTOBUF_SUBMINOR_VERSION "${PROTOBUF_LIB_VERSION} % 1000") + set(PROTOBUF_VERSION "${_PROTOBUF_MAJOR_VERSION}.${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}") + + if(PROTOBUF_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "${_PROTOBUF_COMMON_HEADER} reveals protobuf ${PROTOBUF_VERSION}") + endif() + + # Check Protobuf compiler version to be aligned with libraries version + execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version + OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION) + + if("${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" MATCHES "libprotoc ([0-9.]+)") + set(_PROTOBUF_PROTOC_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") + endif() + + if(PROTOBUF_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "${PROTOBUF_PROTOC_EXECUTABLE} reveals version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}") + endif() + + if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${PROTOBUF_VERSION}") + message(WARNING "Protobuf compiler version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" + " doesn't match library version ${PROTOBUF_VERSION}") + endif() +endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf DEFAULT_MSG - PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf + REQUIRED_VARS PROTOBUF_LIBRARIES PROTOBUF_INCLUDE_DIR + VERSION_VAR PROTOBUF_VERSION +) if(PROTOBUF_FOUND) set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR}) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 49ce57e..8c07e6c 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -835,6 +835,36 @@ else() endif() endif() + # When using wx-config in MSYS, the include paths are UNIX style paths which may or may + # not work correctly depending on you MSYS/MinGW configuration. CMake expects native + # paths internally. + if(wxWidgets_FOUND AND MSYS) + find_program(_cygpath_exe cygpath ONLY_CMAKE_FIND_ROOT_PATH) + DBG_MSG_V("_cygpath_exe: ${_cygpath_exe}") + if(_cygpath_exe) + set(_tmp_path "") + foreach(_path ${wxWidgets_INCLUDE_DIRS}) + execute_process( + COMMAND cygpath -w ${_path} + OUTPUT_VARIABLE _native_path + RESULT_VARIABLE _retv + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + if(_retv EQUAL 0) + file(TO_CMAKE_PATH ${_native_path} _native_path) + DBG_MSG_V("Path ${_path} converted to ${_native_path}") + set(_tmp_path "${_tmp_path} ${_native_path}") + endif() + endforeach() + DBG_MSG("Setting wxWidgets_INCLUDE_DIRS = ${_tmp_path}") + set(wxWidgets_INCLUDE_DIRS ${_tmp_path}) + separate_arguments(wxWidgets_INCLUDE_DIRS) + list(REMOVE_ITEM wxWidgets_INCLUDE_DIRS "") + endif() + unset(_cygpath_exe CACHE) + endif() + #===================================================================== # Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE #===================================================================== diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 70c3fd7..c12dd4c 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -1,129 +1,190 @@ -#.rst: -# FortranCInterface -# ----------------- -# -# Fortran/C Interface Detection -# -# This module automatically detects the API by which C and Fortran -# languages interact. Variables indicate if the mangling is found: -# -# :: -# -# FortranCInterface_GLOBAL_FOUND = Global subroutines and functions -# FortranCInterface_MODULE_FOUND = Module subroutines and functions -# (declared by "MODULE PROCEDURE") -# -# A function is provided to generate a C header file containing macros -# to mangle symbol names: -# -# :: -# -# FortranCInterface_HEADER(<file> -# [MACRO_NAMESPACE <macro-ns>] -# [SYMBOL_NAMESPACE <ns>] -# [SYMBOLS [<module>:]<function> ...]) -# -# It generates in <file> definitions of the following macros: -# -# :: -# -# #define FortranCInterface_GLOBAL (name,NAME) ... -# #define FortranCInterface_GLOBAL_(name,NAME) ... -# #define FortranCInterface_MODULE (mod,name, MOD,NAME) ... -# #define FortranCInterface_MODULE_(mod,name, MOD,NAME) ... -# -# These macros mangle four categories of Fortran symbols, respectively: -# -# :: -# -# - Global symbols without '_': call mysub() -# - Global symbols with '_' : call my_sub() -# - Module symbols without '_': use mymod; call mysub() -# - Module symbols with '_' : use mymod; call my_sub() -# -# If mangling for a category is not known, its macro is left undefined. -# All macros require raw names in both lower case and upper case. The -# MACRO_NAMESPACE option replaces the default "FortranCInterface_" -# prefix with a given namespace "<macro-ns>". -# -# The SYMBOLS option lists symbols to mangle automatically with C -# preprocessor definitions: -# -# :: -# -# <function> ==> #define <ns><function> ... -# <module>:<function> ==> #define <ns><module>_<function> ... -# -# If the mangling for some symbol is not known then no preprocessor -# definition is created, and a warning is displayed. The -# SYMBOL_NAMESPACE option prefixes all preprocessor definitions -# generated by the SYMBOLS option with a given namespace "<ns>". -# -# Example usage: -# -# :: -# -# include(FortranCInterface) -# FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_") -# -# This creates a "FC.h" header that defines mangling macros FC_GLOBAL(), -# FC_GLOBAL_(), FC_MODULE(), and FC_MODULE_(). -# -# Example usage: -# -# :: -# -# include(FortranCInterface) -# FortranCInterface_HEADER(FCMangle.h -# MACRO_NAMESPACE "FC_" -# SYMBOL_NAMESPACE "FC_" -# SYMBOLS mysub mymod:my_sub) -# -# This creates a "FCMangle.h" header that defines the same FC_*() -# mangling macros as the previous example plus preprocessor symbols -# FC_mysub and FC_mymod_my_sub. -# -# Another function is provided to verify that the Fortran and C/C++ -# compilers work together: -# -# :: -# -# FortranCInterface_VERIFY([CXX] [QUIET]) -# -# It tests whether a simple test executable using Fortran and C (and C++ -# when the CXX option is given) compiles and links successfully. The -# result is stored in the cache entry FortranCInterface_VERIFIED_C (or -# FortranCInterface_VERIFIED_CXX if CXX is given) as a boolean. If the -# check fails and QUIET is not given the function terminates with a -# FATAL_ERROR message describing the problem. The purpose of this check -# is to stop a build early for incompatible compiler combinations. The -# test is built in the Release configuration. -# -# FortranCInterface is aware of possible GLOBAL and MODULE manglings for -# many Fortran compilers, but it also provides an interface to specify -# new possible manglings. Set the variables -# -# :: -# -# FortranCInterface_GLOBAL_SYMBOLS -# FortranCInterface_MODULE_SYMBOLS -# -# before including FortranCInterface to specify manglings of the symbols -# "MySub", "My_Sub", "MyModule:MySub", and "My_Module:My_Sub". For -# example, the code: -# -# :: -# -# set(FortranCInterface_GLOBAL_SYMBOLS mysub_ my_sub__ MYSUB_) -# # ^^^^^ ^^^^^^ ^^^^^ -# set(FortranCInterface_MODULE_SYMBOLS -# __mymodule_MOD_mysub __my_module_MOD_my_sub) -# # ^^^^^^^^ ^^^^^ ^^^^^^^^^ ^^^^^^ -# include(FortranCInterface) -# -# tells FortranCInterface to try given GLOBAL and MODULE manglings. -# (The carets point at raw symbol names for clarity in this example but -# are not needed.) +#[=======================================================================[.rst: +FortranCInterface +----------------- + +Fortran/C Interface Detection + +This module automatically detects the API by which C and Fortran +languages interact. + +Module Variables +^^^^^^^^^^^^^^^^ + +Variables that indicate if the mangling is found: + +``FortranCInterface_GLOBAL_FOUND`` + Global subroutines and functions. + +``FortranCInterface_MODULE_FOUND`` + Module subroutines and functions (declared by "MODULE PROCEDURE"). + +This module also provides the following variables to specify +the detected mangling, though a typical use case does not need +to reference them and can use the `Module Functions`_ below. + +``FortranCInterface_GLOBAL_PREFIX`` + Prefix for a global symbol without an underscore. + +``FortranCInterface_GLOBAL_SUFFIX`` + Suffix for a global symbol without an underscore. + +``FortranCInterface_GLOBAL_CASE`` + The case for a global symbol without an underscore, + either ``UPPER`` or ``LOWER``. + +``FortranCInterface_GLOBAL__PREFIX`` + Prefix for a global symbol with an underscore. + +``FortranCInterface_GLOBAL__SUFFIX`` + Suffix for a global symbol with an underscore. + +``FortranCInterface_GLOBAL__CASE`` + The case for a global symbol with an underscore, + either ``UPPER`` or ``LOWER``. + +``FortranCInterface_MODULE_PREFIX`` + Prefix for a module symbol without an underscore. + +``FortranCInterface_MODULE_MIDDLE`` + Middle of a module symbol without an underscore that appears + between the name of the module and the name of the symbol. + +``FortranCInterface_MODULE_SUFFIX`` + Suffix for a module symbol without an underscore. + +``FortranCInterface_MODULE_CASE`` + The case for a module symbol without an underscore, + either ``UPPER`` or ``LOWER``. + +``FortranCInterface_MODULE__PREFIX`` + Prefix for a module symbol with an underscore. + +``FortranCInterface_MODULE__MIDDLE`` + Middle of a module symbol with an underscore that appears + between the name of the module and the name of the symbol. + +``FortranCInterface_MODULE__SUFFIX`` + Suffix for a module symbol with an underscore. + +``FortranCInterface_MODULE__CASE`` + The case for a module symbol with an underscore, + either ``UPPER`` or ``LOWER``. + +Module Functions +^^^^^^^^^^^^^^^^ + +.. command:: FortranCInterface_HEADER + + The ``FortranCInterface_HEADER`` function is provided to generate a + C header file containing macros to mangle symbol names:: + + FortranCInterface_HEADER(<file> + [MACRO_NAMESPACE <macro-ns>] + [SYMBOL_NAMESPACE <ns>] + [SYMBOLS [<module>:]<function> ...]) + + It generates in ``<file>`` definitions of the following macros:: + + #define FortranCInterface_GLOBAL (name,NAME) ... + #define FortranCInterface_GLOBAL_(name,NAME) ... + #define FortranCInterface_MODULE (mod,name, MOD,NAME) ... + #define FortranCInterface_MODULE_(mod,name, MOD,NAME) ... + + These macros mangle four categories of Fortran symbols, respectively: + + * Global symbols without '_': ``call mysub()`` + * Global symbols with '_' : ``call my_sub()`` + * Module symbols without '_': ``use mymod; call mysub()`` + * Module symbols with '_' : ``use mymod; call my_sub()`` + + If mangling for a category is not known, its macro is left undefined. + All macros require raw names in both lower case and upper case. + + The options are: + + ``MACRO_NAMESPACE`` + Replace the default ``FortranCInterface_`` prefix with a given + namespace ``<macro-ns>``. + + ``SYMBOLS`` + List symbols to mangle automatically with C preprocessor definitions:: + + <function> ==> #define <ns><function> ... + <module>:<function> ==> #define <ns><module>_<function> ... + + If the mangling for some symbol is not known then no preprocessor + definition is created, and a warning is displayed. + + ``SYMBOL_NAMESPACE`` + Prefix all preprocessor definitions generated by the ``SYMBOLS`` + option with a given namespace ``<ns>``. + +.. command:: FortranCInterface_VERIFY + + The ``FortranCInterface_VERIFY`` function is provided to verify + that the Fortran and C/C++ compilers work together:: + + FortranCInterface_VERIFY([CXX] [QUIET]) + + It tests whether a simple test executable using Fortran and C (and C++ + when the CXX option is given) compiles and links successfully. The + result is stored in the cache entry ``FortranCInterface_VERIFIED_C`` + (or ``FortranCInterface_VERIFIED_CXX`` if ``CXX`` is given) as a boolean. + If the check fails and ``QUIET`` is not given the function terminates with a + fatal error message describing the problem. The purpose of this check + is to stop a build early for incompatible compiler combinations. The + test is built in the ``Release`` configuration. + +Example Usage +^^^^^^^^^^^^^ + +.. code-block:: cmake + + include(FortranCInterface) + FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_") + +This creates a "FC.h" header that defines mangling macros ``FC_GLOBAL()``, +``FC_GLOBAL_()``, ``FC_MODULE()``, and ``FC_MODULE_()``. + +.. code-block:: cmake + + include(FortranCInterface) + FortranCInterface_HEADER(FCMangle.h + MACRO_NAMESPACE "FC_" + SYMBOL_NAMESPACE "FC_" + SYMBOLS mysub mymod:my_sub) + +This creates a "FCMangle.h" header that defines the same ``FC_*()`` +mangling macros as the previous example plus preprocessor symbols +``FC_mysub`` and ``FC_mymod_my_sub``. + +Additional Manglings +^^^^^^^^^^^^^^^^^^^^ + +FortranCInterface is aware of possible ``GLOBAL`` and ``MODULE`` manglings +for many Fortran compilers, but it also provides an interface to specify +new possible manglings. Set the variables:: + + FortranCInterface_GLOBAL_SYMBOLS + FortranCInterface_MODULE_SYMBOLS + +before including FortranCInterface to specify manglings of the symbols +``MySub``, ``My_Sub``, ``MyModule:MySub``, and ``My_Module:My_Sub``. +For example, the code: + +.. code-block:: cmake + + set(FortranCInterface_GLOBAL_SYMBOLS mysub_ my_sub__ MYSUB_) + # ^^^^^ ^^^^^^ ^^^^^ + set(FortranCInterface_MODULE_SYMBOLS + __mymodule_MOD_mysub __my_module_MOD_my_sub) + # ^^^^^^^^ ^^^^^ ^^^^^^^^^ ^^^^^^ + include(FortranCInterface) + +tells FortranCInterface to try given ``GLOBAL`` and ``MODULE`` manglings. +(The carets point at raw symbol names for clarity in this example but +are not needed.) +#]=======================================================================] #============================================================================= # Copyright 2008-2009 Kitware, Inc. |