diff options
-rw-r--r-- | Help/manual/cmake-modules.7.rst | 1 | ||||
-rw-r--r-- | Help/module/FindOpenACC.rst | 1 | ||||
-rw-r--r-- | Help/release/dev/FindOpenACC.rst | 5 | ||||
-rw-r--r-- | Help/release/dev/cpackifw-options.rst | 6 | ||||
-rw-r--r-- | Help/release/dev/graphviz-line-styles.rst | 6 | ||||
-rw-r--r-- | Help/variable/MSVC_VERSION.rst | 22 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 9 | ||||
-rw-r--r-- | Modules/CMakeGraphVizOptions.cmake | 3 | ||||
-rw-r--r-- | Modules/CPackIFW.cmake | 34 | ||||
-rw-r--r-- | Modules/CompilerId/Xcode-3.pbxproj.in | 1 | ||||
-rw-r--r-- | Modules/FindOpenACC.cmake | 252 | ||||
-rw-r--r-- | Modules/FindOpenMP.cmake | 1 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.cxx | 37 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.h | 6 | ||||
-rw-r--r-- | Source/cmAlgorithms.h | 3 | ||||
-rw-r--r-- | Source/cmCPluginAPI.cxx | 35 | ||||
-rw-r--r-- | Source/cmGraphVizWriter.cxx | 103 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 3 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 4 | ||||
-rw-r--r-- | Source/cmcmd.cxx | 94 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 44 |
22 files changed, 575 insertions, 97 deletions
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index fdc3597..8f4b252 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -153,6 +153,7 @@ All Modules /module/FindMPEG2 /module/FindMPEG /module/FindMPI + /module/FindOpenACC /module/FindOpenAL /module/FindOpenCL /module/FindOpenGL diff --git a/Help/module/FindOpenACC.rst b/Help/module/FindOpenACC.rst new file mode 100644 index 0000000..dda3308 --- /dev/null +++ b/Help/module/FindOpenACC.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindOpenACC.cmake diff --git a/Help/release/dev/FindOpenACC.rst b/Help/release/dev/FindOpenACC.rst new file mode 100644 index 0000000..f6acbdf --- /dev/null +++ b/Help/release/dev/FindOpenACC.rst @@ -0,0 +1,5 @@ +FindOpenACC +----------- + +* A :module:`FindOpenACC` module was added to detect compiler support + for OpenACC. Currently only supports PGI, GNU and Cray compilers. diff --git a/Help/release/dev/cpackifw-options.rst b/Help/release/dev/cpackifw-options.rst new file mode 100644 index 0000000..7c471f4 --- /dev/null +++ b/Help/release/dev/cpackifw-options.rst @@ -0,0 +1,6 @@ +cpackifw-options +---------------- + +* The :module:`CPackIFW` module :command:`cpack_ifw_configure_component` and + :command:`cpack_ifw_configure_component_group` commands gained a new + ``REPLACES`` and ``CHECKABLE`` options. diff --git a/Help/release/dev/graphviz-line-styles.rst b/Help/release/dev/graphviz-line-styles.rst new file mode 100644 index 0000000..d24f236 --- /dev/null +++ b/Help/release/dev/graphviz-line-styles.rst @@ -0,0 +1,6 @@ +graphviz-line-styles +------------------------- + +* The graphviz output now distinguishes between the different dependency types + ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` and represents them in the output graph + as solid, dashed and dotted edges. diff --git a/Help/variable/MSVC_VERSION.rst b/Help/variable/MSVC_VERSION.rst index 8932147..0a3a7a6 100644 --- a/Help/variable/MSVC_VERSION.rst +++ b/Help/variable/MSVC_VERSION.rst @@ -5,13 +5,15 @@ The version of Microsoft Visual C/C++ being used if any. Known version numbers are:: - 1200 = VS 6.0 - 1300 = VS 7.0 - 1310 = VS 7.1 - 1400 = VS 8.0 - 1500 = VS 9.0 - 1600 = VS 10.0 - 1700 = VS 11.0 - 1800 = VS 12.0 - 1900 = VS 14.0 - 1910 = VS 15.0 + 1200 = VS 6.0 + 1300 = VS 7.0 + 1310 = VS 7.1 + 1400 = VS 8.0 (v80 toolset) + 1500 = VS 9.0 (v90 toolset) + 1600 = VS 10.0 (v100 toolset) + 1700 = VS 11.0 (v110 toolset) + 1800 = VS 12.0 (v120 toolset) + 1900 = VS 14.0 (v140 toolset) + 1910-1919 = VS 15.0 (v141 toolset) + +See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 0a93e5f..cddc966 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -321,12 +321,19 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_product_type "com.apple.product-type.tool") if(CMAKE_OSX_SYSROOT) set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";") - if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]") + if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]" OR + CMAKE_OSX_SYSROOT MATCHES "(^|/)[Aa][Pp][Pp][Ll][Ee][Tt][Vv]") set(id_product_type "com.apple.product-type.bundle.unit-test") endif() else() set(id_sdkroot "") endif() + if(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM) + set(id_development_team + "DEVELOPMENT_TEAM = \"${CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}\";") + else() + set(id_development_team "") + endif() configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in ${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY) unset(_ENV_MACOSX_DEPLOYMENT_TARGET) diff --git a/Modules/CMakeGraphVizOptions.cmake b/Modules/CMakeGraphVizOptions.cmake index 3976581..0d7f1d9 100644 --- a/Modules/CMakeGraphVizOptions.cmake +++ b/Modules/CMakeGraphVizOptions.cmake @@ -20,6 +20,9 @@ # * a ``foo.dot.<target>`` file for each target, file showing on which other targets the respective target depends # * a ``foo.dot.<target>.dependers`` file, showing which other targets depend on the respective target # +# The different dependency types ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` +# are represented as solid, dashed and dotted edges. +# # This can result in huge graphs. Using the file # ``CMakeGraphVizOptions.cmake`` the look and content of the generated # graphs can be influenced. This file is searched first in diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 0b42c83..8d8b070 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -323,7 +323,9 @@ # [LICENSES <display_name> <file_path> ...] # [DEFAULT <value>] # [USER_INTERFACES <file_path> <file_path> ...] -# [TRANSLATIONS <file_path> <file_path> ...]) +# [TRANSLATIONS <file_path> <file_path> ...] +# [REPLACES <comp_id> ...] +# [CHECKABLE <value>]) # # This command should be called after :command:`cpack_add_component` command. # @@ -404,6 +406,15 @@ # ``TRANSLATIONS`` # is a list of <file_path> ('.qm' files) representing translations to load. # +# ``REPLACES`` +# list of identifiers of component or component group to replace. +# +# ``CHECKABLE`` +# Possible values are: TRUE, FALSE. +# Set to FALSE if you want to hide the checkbox for an item. +# This is useful when only a few subcomponents should be selected +# instead of all. +# # # .. command:: cpack_ifw_configure_component_group # @@ -426,7 +437,9 @@ # [LICENSES <display_name> <file_path> ...] # [DEFAULT <value>] # [USER_INTERFACES <file_path> <file_path> ...] -# [TRANSLATIONS <file_path> <file_path> ...]) +# [TRANSLATIONS <file_path> <file_path> ...] +# [REPLACES <comp_id> ...] +# [CHECKABLE <value>]) # # This command should be called after :command:`cpack_add_component_group` # command. @@ -499,6 +512,15 @@ # ``TRANSLATIONS`` # is a list of <file_path> ('.qm' files) representing translations to load. # +# ``REPLACES`` +# list of identifiers of component or component group to replace. +# +# ``CHECKABLE`` +# Possible values are: TRUE, FALSE. +# Set to FALSE if you want to hide the checkbox for an item. +# This is useful when only a few subcomponents should be selected +# instead of all. +# # # .. command:: cpack_ifw_add_repository # @@ -882,8 +904,8 @@ macro(cpack_ifw_configure_component compname) string(TOUPPER ${compname} _CPACK_IFWCOMP_UNAME) set(_IFW_OPT COMMON ESSENTIAL VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS) - set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT) - set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS) + set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT CHECKABLE) + set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS REPLACES) cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN}) _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT) @@ -923,8 +945,8 @@ macro(cpack_ifw_configure_component_group grpname) string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME) set(_IFW_OPT VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS) - set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT) - set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS) + set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT CHECKABLE) + set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS REPLACES) cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN}) _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_SCRIPT) diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 84f48ae..1cbaa57 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -72,6 +72,7 @@ 1DEB928608733DD80010E9CD = { isa = XCBuildConfiguration; buildSettings = { + @id_development_team@ PRODUCT_NAME = CompilerId@id_lang@; }; name = Debug; diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake new file mode 100644 index 0000000..775cc18 --- /dev/null +++ b/Modules/FindOpenACC.cmake @@ -0,0 +1,252 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindOpenACC +----------- + +Detect OpenACC support by the compiler. + +This module can be used to detect OpenACC support in a compiler. +If the compiler supports OpenACC, the flags required to compile with +OpenACC support are returned in variables for the different languages. +Currently, only PGI, GNU and Cray compilers are supported. + +Variables +^^^^^^^^^ + +This module will set the following variables per language in your +project, where ``<lang>`` is one of C, CXX, or Fortran: + +``OpenACC_<lang>_FOUND`` + Variable indicating if OpenACC support for ``<lang>`` was detected. +``OpenACC_<lang>_FLAGS`` + OpenACC compiler flags for ``<lang>``, separated by spaces. + +The module will also try to provide the OpenACC version variables: + +``OpenACC_<lang>_SPEC_DATE`` + Date of the OpenACC specification implemented by the ``<lang>`` compiler. +``OpenACC_<lang>_VERSION_MAJOR`` + Major version of OpenACC implemented by the ``<lang>`` compiler. +``OpenACC_<lang>_VERSION_MINOR`` + Minor version of OpenACC implemented by the ``<lang>`` compiler. +``OpenACC_<lang>_VERSION`` + OpenACC version implemented by the ``<lang>`` compiler. + +The specification date is formatted as given in the OpenACC standard: +``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of +the OpenACC specification implemented by the ``<lang>`` compiler. + +Input Variables +^^^^^^^^^^^^^^^ + +``OpenACC_ACCEL_TARGET=<target>`` +If set, will the correct target accelerator flag set to the <target> will +be returned with OpenACC_<lang>_FLAGS. +#]=======================================================================] + +set(OpenACC_C_CXX_TEST_SOURCE +" +int main(){ +#ifndef _OPENACC + breaks_on_purpose +#endif +} +" +) +set(OpenACC_Fortran_TEST_SOURCE +" +program test +#ifndef _OPENACC + breaks_on_purpose +#endif +endprogram test +" +) +set(OpenACC_C_CXX_CHECK_VERSION_SOURCE +" +#include <stdio.h> +const char accver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'A', + 'C', 'C', '-', 'd', 'a', 't', 'e', '[', + ('0' + ((_OPENACC/100000)%10)), + ('0' + ((_OPENACC/10000)%10)), + ('0' + ((_OPENACC/1000)%10)), + ('0' + ((_OPENACC/100)%10)), + ('0' + ((_OPENACC/10)%10)), + ('0' + ((_OPENACC/1)%10)), + ']', '\\0' }; +int main() +{ + puts(accver_str); +} +") +set(OpenACC_Fortran_CHECK_VERSION_SOURCE +" + program acc_ver + implicit none + integer, parameter :: zero = ichar('0') + character, dimension(25), parameter :: accver_str =& + (/ 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'A', 'C', 'C', '-',& + 'd', 'a', 't', 'e', '[',& + char(zero + mod(_OPENACC/100000, 10)),& + char(zero + mod(_OPENACC/10000, 10)),& + char(zero + mod(_OPENACC/1000, 10)),& + char(zero + mod(_OPENACC/100, 10)),& + char(zero + mod(_OPENACC/10, 10)),& + char(zero + mod(_OPENACC/1, 10)), ']' /) + print *, accver_str + end program acc_ver +" +) + + +function(_OPENACC_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_FILE_FULLPATH) + set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC) + if("${LANG}" STREQUAL "C") + set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.c") + file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}") + elseif("${LANG}" STREQUAL "CXX") + set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.cpp") + file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}") + elseif("${LANG}" STREQUAL "Fortran") + set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.F90") + file(WRITE "${SRC_FILE}_in" "${OpenACC_Fortran_${SRC_FILE_CONTENT_VAR}}") + configure_file("${SRC_FILE}_in" "${SRC_FILE}" @ONLY) + endif() + set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE) +endfunction() + + +function(_OPENACC_GET_FLAGS_CANDIDATE LANG FLAG_VAR) + set(ACC_FLAG_PGI "-acc") + set(ACC_FLAG_GNU "-fopenacc") + set(ACC_FLAG_Cray "-h acc") + + if(DEFINED ACC_FLAG_${CMAKE_${LANG}_COMPILER_ID}) + set("${FLAG_VAR}" "${ACC_FLAG_${CMAKE_${LANG}_COMPILER_ID}}" PARENT_SCOPE) + else() + # Fall back to a few common flags. + set("${FLAG_VAR}" ${ACC_FLAG_GNU} ${ACC_FLAG_PGI}) + endif() + +endfunction() + + +function(_OPENACC_GET_ACCEL_TARGET_FLAG LANG TARGET FLAG_VAR) + # Find target accelerator flags. + set(ACC_TARGET_FLAG_PGI "-ta") + if(DEFINED ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID}) + set("${FLAG_VAR}" "${ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID}}=${TARGET}" PARENT_SCOPE) + endif() +endfunction() + + +function(_OPENACC_GET_VERBOSE_FLAG LANG FLAG_VAR) + # Find compiler's verbose flag for OpenACC. + set(ACC_VERBOSE_FLAG_PGI "-Minfo=accel") + if(DEFINED ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID}) + set("${FLAG_VAR}" "${ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID}}" PARENT_SCOPE) + endif() +endfunction() + + +function(_OPENACC_GET_FLAGS LANG FLAG_VAR) + set(FLAG_CANDIDATES "") + _OPENACC_GET_FLAGS_CANDIDATE("${LANG}" FLAG_CANDIDATES) + _OPENACC_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenACCTryFlag _OPENACC_TEST_SRC) + + foreach(FLAG IN LISTS FLAG_CANDIDATES) + try_compile(OpenACC_FLAG_TEST_RESULT ${CMAKE_BINARY_DIR} ${_OPENACC_TEST_SRC} + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${FLAG}" + OUTPUT_VARIABLE OpenACC_TRY_COMPILE_OUTPUT + ) + if(OpenACC_FLAG_TEST_RESULT) + set("${FLAG_VAR}" "${FLAG}") + if(DEFINED OpenACC_ACCEL_TARGET) + _OPENACC_GET_ACCEL_TARGET_FLAG("${LANG}" "${OpenACC_ACCEL_TARGET}" TARGET_FLAG) + string(APPEND "${FLAG_VAR}" " ${TARGET_FLAG}") + endif() + + if(CMAKE_VERBOSE_MAKEFILE) + # -Minfo=accel prints out OpenACC's messages on optimizations. + _OPENACC_GET_VERBOSE_FLAG("${LANG}" OpenACC_VERBOSE_FLAG) + string(APPEND "${FLAG_VAR}" " ${OpenACC_VERBOSE_FLAG}") + endif() + set("${FLAG_VAR}" "${${FLAG_VAR}}" PARENT_SCOPE) + break() + endif() + endforeach() + +endfunction() + + +function(_OPENACC_GET_SPEC_DATE LANG SPEC_DATE) + _OPENACC_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenACCCheckVersion _OPENACC_TEST_SRC) + + set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC/accver_${LANG}.bin") + try_compile(OpenACC_SPECTEST_${LANG} "${CMAKE_BINARY_DIR}" "${_OPENACC_TEST_SRC}" + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenACC_${LANG}_FLAGS}" + COPY_FILE ${BIN_FILE} + OUTPUT_VARIABLE OUTPUT) + + if(${OpenACC_SPECTEST_${LANG}}) + file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenACC-date") + set(regex_spec_date ".*INFO:OpenACC-date\\[0*([^]]*)\\].*") + if("${specstr}" MATCHES "${regex_spec_date}") + set(${SPEC_DATE} "${CMAKE_MATCH_1}" PARENT_SCOPE) + endif() + endif() +endfunction() + + +macro(_OPENACC_SET_VERSION_BY_SPEC_DATE LANG) + set(OpenACC_SPEC_DATE_MAP + # Combined versions, 2.5 onwards + "201510=2.5" + # 2013 08 is the corrected version. + "201308=2.0" + "201306=2.0" + "201111=1.0" + ) + + string(REGEX MATCHALL "${OpenACC_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" _version_match "${OpenACC_SPEC_DATE_MAP}") + if(NOT _version_match STREQUAL "") + set(OpenACC_${LANG}_VERSION_MAJOR ${CMAKE_MATCH_1}) + set(OpenACC_${LANG}_VERSION_MINOR ${CMAKE_MATCH_2}) + set(OpenACC_${LANG}_VERSION "${OpenACC_${LANG}_VERSION_MAJOR}.${OpenACC_${LANG}_VERSION_MINOR}") + else() + unset(OpenACC_${LANG}_VERSION_MAJOR) + unset(OpenACC_${LANG}_VERSION_MINOR) + unset(OpenACC_${LANG}_VERSION) + endif() + unset(_version_match) + unset(OpenACC_SPEC_DATE_MAP) +endmacro() + + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +foreach (LANG IN ITEMS C CXX Fortran) + if(CMAKE_${LANG}_COMPILER_LOADED) + set(OpenACC_${LANG}_FIND_QUIETLY ${OpenACC_FIND_QUIETLY}) + set(OpenACC_${LANG}_FIND_REQUIRED ${OpenACC_FIND_REQUIRED}) + set(OpenACC_${LANG}_FIND_VERSION ${OpenACC_FIND_VERSION}) + set(OpenACC_${LANG}_FIND_VERSION_EXACT ${OpenACC_FIND_VERSION_EXACT}) + + if(NOT DEFINED OpenACC_${LANG}_FLAGS) + _OPENACC_GET_FLAGS("${LANG}" OpenACC_${LANG}_FLAGS) + endif() + _OPENACC_GET_SPEC_DATE("${LANG}" OpenACC_${LANG}_SPEC_DATE) + _OPENACC_SET_VERSION_BY_SPEC_DATE("${LANG}") + + find_package_handle_standard_args(OpenACC_${LANG} + REQUIRED_VARS OpenACC_${LANG}_FLAGS + VERSION_VAR OpenACC_${LANG}_VERSION + ) + endif() +endforeach() + +unset(OpenACC_C_CXX_TEST_SOURCE) +unset(OpenACC_Fortran_TEST_SOURCE) +unset(OpenACC_C_CXX_CHECK_VERSION_SOURCE) +unset(OpenACC_Fortran_CHECK_VERSION_SOURCE) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 4a3edf9..595b0b3 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -75,6 +75,7 @@ # the OpenMP specification implemented by the ``<lang>`` compiler. cmake_policy(PUSH) +cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced cmake_policy(SET CMP0057 NEW) # if IN_LIST function(_OPENMP_FLAG_CANDIDATES LANG) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 666293c..d5dc2ba 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 9) -set(CMake_VERSION_PATCH 20170922) +set(CMake_VERSION_PATCH 20170927) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index 7b23005..d3ce15c 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -482,6 +482,15 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) this->ForcedInstallation = "false"; } + // Replaces + option = prefix + "REPLACES"; + if (this->IsSetToEmpty(option)) { + this->Replaces.clear(); + } else if (const char* value = this->GetOption(option)) { + this->Replaces.clear(); + cmSystemTools::ExpandListArgument(value, this->Replaces); + } + // Requires admin rights option = prefix + "REQUIRES_ADMIN_RIGHTS"; if (this->IsSetToEmpty(option)) { @@ -492,6 +501,16 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) this->RequiresAdminRights = "false"; } + // Checkable + option = prefix + "CHECKABLE"; + if (this->IsSetToEmpty(option)) { + this->Checkable.clear(); + } else if (this->IsOn(option)) { + this->Checkable = "true"; + } else if (this->IsSetToOff(option)) { + this->Checkable = "false"; + } + return 1; } @@ -652,6 +671,19 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.Element("ForcedInstallation", this->ForcedInstallation); } + // Replaces + if (!this->Replaces.empty()) { + std::ostringstream replaces; + std::vector<std::string>::iterator it = this->Replaces.begin(); + replaces << *it; + ++it; + while (it != this->Replaces.end()) { + replaces << "," << *it; + ++it; + } + xout.Element("Replaces", replaces.str()); + } + if (!this->RequiresAdminRights.empty()) { xout.Element("RequiresAdminRights", this->RequiresAdminRights); } @@ -672,6 +704,11 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.Element("SortingPriority", this->SortingPriority); } + // Checkable + if (!this->Checkable.empty()) { + xout.Element("Checkable", this->Checkable); + } + xout.EndElement(); xout.EndDocument(); } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h index cec59b0..ae41146 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.h +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -114,9 +114,15 @@ public: /// Determines that the package must always be installed std::string ForcedInstallation; + /// List of components to replace + std::vector<std::string> Replaces; + /// Package needs to be installed with elevated permissions std::string RequiresAdminRights; + /// Set to false if you want to hide the checkbox for an item + std::string Checkable; + public: // Internal implementation diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index b6ea75a..69d0ed6 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -370,8 +370,7 @@ std::string cmWrap(char prefix, Range const& r, char suffix, template <typename Range, typename T> typename Range::const_iterator cmFindNot(Range const& r, T const& t) { - return std::find_if(r.begin(), r.end(), - std::bind1st(std::not_equal_to<T>(), t)); + return std::find_if(r.begin(), r.end(), [&t](T const& i) { return i != t; }); } template <typename Range> diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index e259f4d..e1e11af 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -405,14 +405,8 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source, { cmMakefile* mf = static_cast<cmMakefile*>(arg); std::string barf = source; - std::string result = mf->ExpandVariablesInString( - barf, (escapeQuotes ? true : false), (atOnly ? true : false)); - char* res = static_cast<char*>(malloc(result.size() + 1)); - if (!result.empty()) { - strcpy(res, result.c_str()); - } - res[result.size()] = '\0'; - return res; + std::string result = mf->ExpandVariablesInString(barf, escapeQuotes, atOnly); + return strdup(result.c_str()); } int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs, @@ -460,9 +454,7 @@ void CCONV cmFreeArguments(int argc, char** argv) for (i = 0; i < argc; ++i) { free(argv[i]); } - if (argv) { - free(argv); - } + free(argv); } int CCONV cmGetTotalArgumentSize(int argc, char** argv) @@ -513,13 +505,12 @@ cmCPluginAPISourceFileMap cmCPluginAPISourceFiles; void* CCONV cmCreateSourceFile(void) { - return (void*)new cmCPluginAPISourceFile; + return new cmCPluginAPISourceFile; } void* CCONV cmCreateNewSourceFile(void*) { - cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile; - return (void*)sf; + return new cmCPluginAPISourceFile; } void CCONV cmDestroySourceFile(void* arg) @@ -552,7 +543,7 @@ void CCONV* cmGetSource(void* arg, const char* name) cmCPluginAPISourceFileMap::value_type entry(rsf, sf); i = cmCPluginAPISourceFiles.insert(entry).first; } - return (void*)i->second; + return i->second; } return nullptr; } @@ -581,7 +572,7 @@ void* CCONV cmAddSource(void* arg, void* arg2) // Store the proxy in the map so it can be re-used and deleted later. cmCPluginAPISourceFiles[rsf] = sf; - return (void*)sf; + return sf; } const char* CCONV cmSourceFileGetSourceName(void* arg) @@ -762,25 +753,19 @@ void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir, char* CCONV cmGetFilenameWithoutExtension(const char* name) { std::string sres = cmSystemTools::GetFilenameWithoutExtension(name); - char* result = (char*)malloc(sres.size() + 1); - strcpy(result, sres.c_str()); - return result; + return strdup(sres.c_str()); } char* CCONV cmGetFilenamePath(const char* name) { std::string sres = cmSystemTools::GetFilenamePath(name); - char* result = (char*)malloc(sres.size() + 1); - strcpy(result, sres.c_str()); - return result; + return strdup(sres.c_str()); } char* CCONV cmCapitalized(const char* name) { std::string sres = cmSystemTools::Capitalized(name); - char* result = (char*)malloc(sres.size() + 1); - strcpy(result, sres.c_str()); - return result; + return strdup(sres.c_str()); } void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2) diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 967fd2e..ca87cbf 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGraphVizWriter.h" +#include <cstddef> #include <iostream> #include <sstream> #include <utility> @@ -17,7 +18,18 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -static const char* getShapeForTarget(const cmGeneratorTarget* target) +namespace { +enum LinkLibraryScopeType +{ + LLT_SCOPE_PUBLIC, + LLT_SCOPE_PRIVATE, + LLT_SCOPE_INTERFACE +}; + +const char* const GRAPHVIZ_PRIVATE_EDEGE_STYLE = "dashed"; +const char* const GRAPHVIZ_INTERFACE_EDEGE_STYLE = "dotted"; + +const char* getShapeForTarget(const cmGeneratorTarget* target) { if (!target) { return "ellipse"; @@ -39,6 +51,76 @@ static const char* getShapeForTarget(const cmGeneratorTarget* target) return "box"; } +std::map<std::string, LinkLibraryScopeType> getScopedLinkLibrariesFromTarget( + cmTarget* Target) +{ + char sep = ';'; + std::map<std::string, LinkLibraryScopeType> tokens; + size_t start = 0, end = 0; + + const char* pInterfaceLinkLibraries = + Target->GetProperty("INTERFACE_LINK_LIBRARIES"); + const char* pLinkLibraries = Target->GetProperty("LINK_LIBRARIES"); + + if (!pInterfaceLinkLibraries && !pLinkLibraries) { + return tokens; // target is not linked against any other libraries + } + + // make sure we don't touch a null-ptr + auto interfaceLinkLibraries = + std::string(pInterfaceLinkLibraries ? pInterfaceLinkLibraries : ""); + auto linkLibraries = std::string(pLinkLibraries ? pLinkLibraries : ""); + + // first extract interfaceLinkLibraries + while (start < interfaceLinkLibraries.length()) { + + if ((end = interfaceLinkLibraries.find(sep, start)) == std::string::npos) { + end = interfaceLinkLibraries.length(); + } + + std::string element = interfaceLinkLibraries.substr(start, end - start); + if (std::string::npos == element.find("$<LINK_ONLY:", 0)) { + // we assume first, that this library is an interface library. + // if we find it again in the linklibraries property, we promote it to an + // public library. + tokens[element] = LLT_SCOPE_INTERFACE; + } else { + // this is an private linked static library. + // we take care of this case in the second iterator. + } + start = end + 1; + } + + // second extract linkLibraries + start = 0; + while (start < linkLibraries.length()) { + + if ((end = linkLibraries.find(sep, start)) == std::string::npos) { + end = linkLibraries.length(); + } + + std::string element = linkLibraries.substr(start, end - start); + + if (tokens.find(element) == tokens.end()) { + // this library is not found in interfaceLinkLibraries but in + // linkLibraries. + // this results in a private linked library. + tokens[element] = LLT_SCOPE_PRIVATE; + } else if (LLT_SCOPE_INTERFACE == tokens[element]) { + // this library is found in interfaceLinkLibraries and linkLibraries. + // this results in a public linked library. + tokens[element] = LLT_SCOPE_PUBLIC; + } else { + // private and public linked libraries should not be changed anymore. + } + + start = end + 1; + } + + return tokens; +} +} + cmGraphVizWriter::cmGraphVizWriter( const std::vector<cmLocalGenerator*>& localGenerators) : GraphType("digraph") @@ -273,11 +355,10 @@ void cmGraphVizWriter::WriteConnections( } std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; + std::map<std::string, LinkLibraryScopeType> ll = + getScopedLinkLibrariesFromTarget(targetPtrIt->second->Target); - const cmTarget::LinkLibraryVectorType* ll = - &(targetPtrIt->second->Target->GetOriginalLinkLibraries()); - - for (auto const& llit : *ll) { + for (auto const& llit : ll) { const char* libName = llit.first.c_str(); std::map<std::string, std::string>::const_iterator libNameIt = this->TargetNamesNodes.find(libName); @@ -297,6 +378,18 @@ void cmGraphVizWriter::WriteConnections( insertedNodes, str); str << " \"" << myNodeName << "\" -> \"" << libNameIt->second << "\""; + + switch (llit.second) { + case LLT_SCOPE_PRIVATE: + str << "[style = " << GRAPHVIZ_PRIVATE_EDEGE_STYLE << "]"; + break; + case LLT_SCOPE_INTERFACE: + str << "[style = " << GRAPHVIZ_INTERFACE_EDEGE_STYLE << "]"; + break; + default: + break; + } + str << " // " << targetName << " -> " << libName << std::endl; this->WriteConnections(libName, insertedNodes, insertedConnections, str); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index df02f84..50ed0ed 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -5,7 +5,6 @@ #include "cmsys/FStream.hxx" #include "cmsys/Terminal.h" #include <algorithm> -#include <functional> #include <sstream> #include <stdio.h> #include <utility> @@ -2073,7 +2072,7 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand( std::string outputForExisting = this->ConvertToOutputForExisting(tgtDir); std::string prefix = cd_cmd + outputForExisting + " && "; std::transform(commands.begin(), commands.end(), commands.begin(), - std::bind1st(std::plus<std::string>(), prefix)); + [&prefix](std::string const& s) { return prefix + s; }); } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 58adc43..4fd10a4 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -803,6 +803,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, } if (captureStdErr) { captureStdErr->append(exception_str, strlen(exception_str)); + } else if (captureStdOut) { + captureStdOut->append(exception_str, strlen(exception_str)); } result = false; } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) { @@ -812,6 +814,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, } if (captureStdErr) { captureStdErr->append(error_str, strlen(error_str)); + } else if (captureStdOut) { + captureStdOut->append(error_str, strlen(error_str)); } result = false; } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index e152cdb..62a0094 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1537,8 +1537,34 @@ int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type) return vsLink.Link(); } +enum NumberFormat +{ + FORMAT_DECIMAL, + FORMAT_HEX +}; +struct NumberFormatter +{ + NumberFormat Format; + int Value; + NumberFormatter(NumberFormat format, int value) + : Format(format) + , Value(value) + { + } +}; +std::ostream& operator<<(std::ostream& stream, + NumberFormatter const& formatter) +{ + if (formatter.Format == FORMAT_DECIMAL) { + stream << formatter.Value; + } else { + stream << "0x" << std::hex << formatter.Value; + } + return stream; +} static bool RunCommand(const char* comment, std::vector<std::string>& command, - bool verbose, int* retCodeOut = nullptr) + bool verbose, NumberFormat exitFormat, + int* retCodeOut = nullptr) { if (verbose) { std::cout << comment << ":\n"; @@ -1546,31 +1572,33 @@ static bool RunCommand(const char* comment, std::vector<std::string>& command, } std::string output; int retCode = 0; - // use rc command to create .res file - bool res = cmSystemTools::RunSingleCommand( + bool commandResult = cmSystemTools::RunSingleCommand( command, &output, &output, &retCode, nullptr, cmSystemTools::OUTPUT_NONE); - // always print the output of the command, unless - // it is the dumb rc command banner, but if the command - // returned an error code then print the output anyway as - // the banner may be mixed with some other important information. - if (output.find("Resource Compiler Version") == std::string::npos || !res || - retCode) { - std::cout << output; - } - if (!res) { - std::cout << comment << " failed to run." << std::endl; - return false; - } - // if retCodeOut is requested then always return true - // and set the retCodeOut to retCode + bool returnValue; if (retCodeOut) { - *retCodeOut = retCode; - return true; - } - if (retCode != 0) { - std::cout << comment << " failed. with " << retCode << "\n"; - } - return retCode == 0; + if (!commandResult) { + *retCodeOut = (retCode == 0) ? -1 : retCode; + } else { + *retCodeOut = retCode; + } + returnValue = true; // always return true if retCodeOut is requested + } else { + returnValue = commandResult && (retCode == 0); + } + if (!commandResult || retCode) { + std::cout << comment << ": command \"" << cmJoin(command, " ") + << "\" failed (exit code " + << NumberFormatter(exitFormat, retCode) + << ") with the following output:\n" + << output; + } else { + // always print the output of the command, unless + // it is the dumb rc command banner + if (output.find("Resource Compiler Version") == std::string::npos) { + std::cout << output; + } + } + return returnValue; } bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg, @@ -1720,10 +1748,10 @@ int cmVSLink::LinkIncremental() // Compile the resource file. std::vector<std::string> rcCommand; - rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); + rcCommand.push_back("rc"); rcCommand.push_back("/fo" + this->ManifestFileRes); rcCommand.push_back(this->ManifestFileRC); - if (!RunCommand("RC Pass 1", rcCommand, this->Verbose)) { + if (!RunCommand("RC Pass 1", rcCommand, this->Verbose, FORMAT_DECIMAL)) { return -1; } @@ -1731,7 +1759,8 @@ int cmVSLink::LinkIncremental() this->LinkCommand.push_back(this->ManifestFileRes); // Run the link command (possibly generates intermediate manifest). - if (!RunCommand("LINK Pass 1", this->LinkCommand, this->Verbose)) { + if (!RunCommand("LINK Pass 1", this->LinkCommand, this->Verbose, + FORMAT_DECIMAL)) { return -1; } @@ -1745,12 +1774,13 @@ int cmVSLink::LinkIncremental() } // Compile the resource file again. - if (!RunCommand("RC Pass 2", rcCommand, this->Verbose)) { + if (!RunCommand("RC Pass 2", rcCommand, this->Verbose, FORMAT_DECIMAL)) { return -1; } // Link incrementally again to use the updated resource. - if (!RunCommand("FINAL LINK", this->LinkCommand, this->Verbose)) { + if (!RunCommand("FINAL LINK", this->LinkCommand, this->Verbose, + FORMAT_DECIMAL)) { return -1; } return 0; @@ -1759,7 +1789,7 @@ int cmVSLink::LinkIncremental() int cmVSLink::LinkNonIncremental() { // Run the link command (possibly generates intermediate manifest). - if (!RunCommand("LINK", this->LinkCommand, this->Verbose)) { + if (!RunCommand("LINK", this->LinkCommand, this->Verbose, FORMAT_DECIMAL)) { return -1; } @@ -1777,7 +1807,7 @@ int cmVSLink::LinkNonIncremental() int cmVSLink::RunMT(std::string const& out, bool notify) { std::vector<std::string> mtCommand; - mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); + mtCommand.push_back("mt"); mtCommand.push_back("/nologo"); mtCommand.push_back("/manifest"); if (this->LinkGeneratesManifest) { @@ -1792,7 +1822,7 @@ int cmVSLink::RunMT(std::string const& out, bool notify) mtCommand.push_back("/notify_update"); } int mtRet = 0; - if (!RunCommand("MT", mtCommand, this->Verbose, &mtRet)) { + if (!RunCommand("MT", mtCommand, this->Verbose, FORMAT_HEX, &mtRet)) { return -1; } return mtRet; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 73fa8fb..aa4c5ac 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -227,20 +227,38 @@ add_RunCMake_test(separate_arguments) add_RunCMake_test(set_property) add_RunCMake_test(string) add_RunCMake_test(test_include_dirs) -foreach(var - CMAKE_C_COMPILER_ID - CMAKE_C_COMPILER_VERSION - CMAKE_C_STANDARD_DEFAULT - CMAKE_CXX_COMPILER_ID - CMAKE_CXX_COMPILER_VERSION - CMAKE_CXX_STANDARD_DEFAULT - CMake_TEST_CUDA - ) - if(DEFINED ${var}) - list(APPEND try_compile_ARGS -D${var}=${${var}}) + +function(add_RunCMake_test_try_compile) + if(CMAKE_VERSION VERSION_LESS 3.9.20170907 AND "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + # Older CMake versions do not know about MSVC language standards. + # Approximate our logic from MSVC-CXX.cmake. + if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10.25017) + set(CMAKE_CXX_STANDARD_DEFAULT 14) + elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) + set(CMAKE_CXX_STANDARD_DEFAULT "") + else() + unset(CMAKE_CXX_STANDARD_DEFAULT) + endif() endif() -endforeach() -add_RunCMake_test(try_compile) + foreach(var + CMAKE_C_COMPILER_ID + CMAKE_C_COMPILER_VERSION + CMAKE_C_STANDARD_DEFAULT + CMAKE_CXX_COMPILER_ID + CMAKE_CXX_COMPILER_VERSION + CMAKE_CXX_STANDARD_DEFAULT + CMake_TEST_CUDA + ) + if(DEFINED ${var}) + list(APPEND try_compile_ARGS -D${var}=${${var}}) + endif() + endforeach() + add_RunCMake_test(try_compile) +endfunction() +add_RunCMake_test_try_compile() + add_RunCMake_test(try_run) add_RunCMake_test(set) add_RunCMake_test(variable_watch) |