diff options
22 files changed, 235 insertions, 162 deletions
diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst index 1806361..ed03448 100644 --- a/Help/guide/tutorial/Adding a Library.rst +++ b/Help/guide/tutorial/Adding a Library.rst @@ -64,8 +64,13 @@ will be stored in the cache so that the user does not need to set the value each time they run CMake on a build directory. The next change is to make building and linking the ``MathFunctions`` library -conditional. To do this we change the end of the top-level ``CMakeLists.txt`` -file to look like the following: +conditional. To do this, we will create an ``if`` statement which checks the +value of the option. Inside the ``if`` block, put the +:command:`add_subdirectory` command from above with some additional list +commands to store information needed to link to the library and add the +subdirectory as an include directory in the ``Tutorial`` target. +The end of the top-level ``CMakeLists.txt`` file will now look like the +following: .. literalinclude:: Step3/CMakeLists.txt :caption: CMakeLists.txt diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake index 7b2e556..9629279 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -1,10 +1,16 @@ -# This file is processed when the IAR compiler is used for a C file - +# This file is processed when the IAR C Compiler is used +# +# C Language Specification support +# - Newer versions of the IAR C Compiler require the --c89 flag to build a file under the C90 standard. +# - Earlier versions of the compiler had C90 by default, not requiring the backward-compatibility flag. +# +# The IAR Language Extensions +# - The IAR Language Extensions can be enabled by -e flag +# include(Compiler/IAR) include(Compiler/CMakeCommonCompilerMacros) -# Common -if(NOT CMAKE_C_COMPILER_VERSION) +if(NOT DEFINED CMAKE_C_COMPILER_VERSION) message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.") endif() @@ -13,46 +19,42 @@ set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 7) set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89) set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e) - set(CMAKE_C99_STANDARD_COMPILE_OPTION "") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e) else() set(CMAKE_C90_STANDARD_COMPILE_OPTION "") set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e) endif() -if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 8) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION -e) -endif() +set(CMAKE_C${CMAKE_C_STANDARD_COMPUTED_DEFAULT}_STANDARD_COMPILE_OPTION "") +set(CMAKE_C${CMAKE_C_STANDARD_COMPUTED_DEFAULT}_EXTENSION_COMPILE_OPTION -e) # Architecture specific if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_LESS 7) - # IAR ARM 4.X uses xlink.exe, detection is not implemented - message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5) + # IAR C Compiler for Arm prior version 5.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C Compiler for Arm version ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") endif() __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 6.10 99 8.10 11) + __compiler_check_default_language_standard(C 5.10 90 6.10 99 8.10 11 8.40 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 2.10 99 4.10 11) + __compiler_check_default_language_standard(C 1.10 90 2.10 99 4.10 11 4.20 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 1.10 99 2.10 11) + __compiler_check_default_language_standard(C 1.10 90 1.10 99 2.10 11 2.21 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78") if(CMAKE_C_COMPILER_VERSION VERSION_LESS 2) - # IAR RL78 1.X uses xlink.exe, detection is not implemented - message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + # IAR C Compiler for RL78 prior version 2.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C Compiler for RL78 version ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") endif() __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 2.10 90 1.10 99 4.10 11) + __compiler_check_default_language_standard(C 2.10 90 2.10 99 4.10 11 4.20 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV") __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 1.10 99 1.10 11) + __compiler_check_default_language_standard(C 1.10 90 1.10 99 1.10 11 1.21 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") __compiler_iar_xlink(C) diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index 4909cc5..b102aa6 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -1,67 +1,65 @@ -# This file is processed when the IAR compiler is used for a C++ file - +# This file is processed when the IAR C++ Compiler is used +# +# C++ Language Specification support +# - Newer versions of the IAR C++ Compiler require the --c++ flag to build a C++ file. +# Earlier versions for non-ARM architectures provided Embedded C++, enabled with the --eec++ flag. +# +# The IAR Language Extensions +# - The IAR Language Extensions can be enabled by -e flag +# include(Compiler/IAR) include(Compiler/CMakeCommonCompilerMacros) -# Common -if(NOT CMAKE_CXX_COMPILER_VERSION) +if(NOT DEFINED CMAKE_CXX_COMPILER_VERSION) message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.") endif() +# Whenever needed, override this default behavior using CMAKE_IAR_CXX_FLAG in your toolchain file. if(NOT CMAKE_IAR_CXX_FLAG) - # The --c++ flag was introduced in platform version 9 for all architectures except ARM where it was introduced already in version 7 - if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8 OR - (CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 6 AND "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") ) - set(CMAKE_IAR_CXX_FLAG --c++) + set(_CMAKE_IAR_MODERNCXX_LIST 14 17) + if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST _CMAKE_IAR_MODERNCXX_LIST OR + ("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" AND ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} EQUAL 98)) + string(PREPEND CMAKE_CXX_FLAGS "--c++ ") else() - set(CMAKE_IAR_CXX_FLAG --eec++) + string(PREPEND CMAKE_CXX_FLAGS "--eec++ ") endif() + unset(_CMAKE_IAR_MODERNCXX_LIST) endif() +set(CMAKE_CXX_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) -if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 7) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e) - set(CMAKE_CXX03_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX03_EXTENSION_COMPILE_OPTION -e) -endif() - -if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -e) - set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -e) -endif() +set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_STANDARD_COMPILE_OPTION "") +set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_EXTENSION_COMPILE_OPTION -e) # Architecture specific if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_LESS 7) - # IAR ARM 4.X uses xlink.exe, detection is not implemented - message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) + # IAR C++ Compiler for Arm prior version 5.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C++ Compiler for Arm version ${CMAKE_CXX_COMPILER_VERSION} not supported by CMake.") endif() __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 6.10 98 8.10 14) + __compiler_check_default_language_standard(CXX 5.10 98 8.10 14 8.40 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 2.10 98 4.10 14) + __compiler_check_default_language_standard(CXX 2.10 98 4.10 14 4.20 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 1.10 98 2.10 14) + __compiler_check_default_language_standard(CXX 1.10 98 2.10 14 2.21 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2) - # IAR RL78 1.X uses xlink.exe, detection is not implemented - message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + # # IAR C++ Compiler for RL78 prior version 2.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C++ Compiler for RL78 version ${CMAKE_CXX_COMPILER_VERSION} not supported by CMake.") endif() __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 2.10 98 4.10 14) + __compiler_check_default_language_standard(CXX 2.10 98 4.10 14 4.20 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV") __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 1.10 98 1.10 14) + __compiler_check_default_language_standard(CXX 1.10 98 1.10 14 1.21 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") __compiler_iar_xlink(CXX) diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake index 443b09c..b03fd1f 100644 --- a/Modules/Compiler/IAR-DetermineCompiler.cmake +++ b/Modules/Compiler/IAR-DetermineCompiler.cmake @@ -1,28 +1,26 @@ -# IAR Systems compiler for ARM embedded systems. -# http://www.iar.com -# http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf +# IAR C/C++ Compiler (https://www.iar.com) +# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850 # -# __IAR_SYSTEMS_ICC__ An integer that identifies the IAR compiler platform: -# 9 and higher means C11 and C++14 as language default -# 8 means C99 and C++03 as language default -# 7 and lower means C89 and EC++ as language default. -# __ICCARM__ An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for ARM -# __VER__ An integer that identifies the version number of the IAR compiler in use. For example, -# version 5.11.3 is returned as 5011003. +# IAR C/C++ Compiler for <arch> internal integer symbols used in CMake: # -# IAR Systems Compiler for AVR embedded systems -# http://supp.iar.com/FilesPublic/UPDINFO/007051/ew/doc/EWAVR_CompilerReference.pdf +# __IAR_SYSTEMS_ICC__ +# Provides the compiler internal platform version +# __ICC<arch>__ +# Provides 1 for the current <arch> in use +# __VER__ +# Provides the current version in use +# The semantic version of the compiler is architecture-dependent +# When <arch> is ARM: +# CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E6) +# CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ / 1E3) % 1E3 +# CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__VER__ % 1E3) +# When <arch> is non-ARM: +# CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E2) +# CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ - ((__VER__/ 1E2) * 1E2)) +# CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__SUBVERSION__) +# __SUBVERSION__ +# Provides the version's patch level for non-ARM <arch> # -# __IAR_SYSTEMS_ICC__ An integer that identifies the IAR compiler platform. -# __ICCAVR__ An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for AVR -# __VER__ An integer that identifies the version number of the IAR compiler in use. -# The value is calculated by (100 * VERSION_MAJOR + VERSION_MINOR). For example the version -# 3.34 is given as 334 -# __SUBVERSION__ An integer that identifies the subversion number of the compiler version number -# for example 3 in 1.2.3.4. THis is used as the patch version, as seen when running iccavr -# from the command line -# - set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)") set(_compiler_id_version_compute " diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake index 9382c3f..53456f5 100644 --- a/Modules/Compiler/IAR.cmake +++ b/Modules/Compiler/IAR.cmake @@ -1,43 +1,11 @@ -# This file is processed when the IAR compiler is used for a C or C++ file -# Documentation can be downloaded here: http://www.iar.com/website1/1.0.1.0/675/1/ -# The initial feature request is here: https://gitlab.kitware.com/cmake/cmake/-/issues/10176 -# It also contains additional links and information. -# See USER GUIDES -> C/C++ Development Guide and ReleaseNotes for EWARM: -# version 6.30.8: http://supp.iar.com/FilesPublic/UPDINFO/006607/arm/doc/infocenter/index.ENU.html -# version 7.60.1: http://supp.iar.com/FilesPublic/UPDINFO/011006/arm/doc/infocenter/index.ENU.html -# version 8.10.1: http://netstorage.iar.com/SuppDB/Public/UPDINFO/011854/arm/doc/infocenter/index.ENU.html - -# The IAR internal compiler platform generations (Predefined symbol __IAR_SYSTEMS_ICC__): -# 9 and higher means C11 and C++14 as language default (EWARM v8.x, EWRX v4.x and higher) -# 8 means C99 and C++03 as language default (EWARM v6.x, v7.x. EWRX v2.x, 3.x) -# 7 and lower means C89 and EC++ as language default. (EWARM v5.x and lower) - -# C/C++ Standard versions -# -# IAR typically only supports one C and C++ Standard version, -# the exception is C89 which is always supported and can be selected -# if its not the default +# This file is processed when the IAR C/C++ Compiler is used # -# C++ is trickier, there were historically 3 switches, -# and some IAR versions support multiple of those. -# they are --eec++, --ec++ and --c++ and where used to -# enable various language features like exceptions +# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850 # -# recent versions only have --c++ for full support -# but can choose to disable features with further arguments +# The compiler user documentation is architecture-dependent +# and it can found with the product installation under <arch>/doc/{EW,BX}<arch>_DevelopmentGuide.ENU.pdf # -# C/C++ Standard compliance # -# IAR has 3 modes: default, strict and extended -# the extended mode is needed for popular libraries like CMSIS -# -# "Silent" Operation -# -# this really is different to most programs I know. -# nothing meaningful from the operation is lost, just some redundant -# code and data size printouts (that can be inspected with common tools). - -# This module is shared by multiple languages; use include blocker. include_guard() macro(__compiler_iar_ilink lang) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 89de691..0359ca6 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 21) -set(CMake_VERSION_PATCH 20210927) +set(CMake_VERSION_PATCH 20210928) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 33ce314..c49cafe 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1309,7 +1309,16 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // Add additional autogen target dependencies to // '_autogen_timestamp_deps'. for (const cmTarget* t : this->AutogenTarget.DependTargets) { - dependencies.push_back(t->GetName()); + std::string depname = t->GetName(); + if (t->IsImported()) { + auto ttype = t->GetType(); + if (ttype == cmStateEnums::TargetType::STATIC_LIBRARY || + ttype == cmStateEnums::TargetType::SHARED_LIBRARY || + ttype == cmStateEnums::TargetType::UNKNOWN_LIBRARY) { + depname = cmStrCat("$<TARGET_LINKER_FILE:", t->GetName(), ">"); + } + } + dependencies.push_back(depname); } cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand( diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-full.cmake b/Tests/RunCMake/Autogen/CMP0111-imported-target-full.cmake new file mode 100644 index 0000000..331da64 --- /dev/null +++ b/Tests/RunCMake/Autogen/CMP0111-imported-target-full.cmake @@ -0,0 +1,12 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0111-imported-target-prelude.cmake") + +set_location(executable LOCATION "${CMAKE_CURRENT_BINARY_DIR}/executable${CMAKE_EXECUTABLE_SUFFIX}") + +set_location(shared LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}shared${CMAKE_SHARED_LIBRARY_SUFFIX}") +if (CMAKE_IMPORT_LIBRARY_SUFFIX) + set_location(shared IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}shared${CMAKE_IMPORT_LIBRARY_SUFFIX}") +endif () + +set_location(static LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}static${CMAKE_STATIC_LIBRARY_SUFFIX}") +set_location(unknown LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}unknown${CMAKE_IMPORT_LIBRARY_SUFFIX}") +set_location(module LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_MODULE_PREFIX}module${CMAKE_SHARED_MODULE_SUFFIX}") diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-implib-only.cmake b/Tests/RunCMake/Autogen/CMP0111-imported-target-implib-only.cmake new file mode 100644 index 0000000..8640fdc --- /dev/null +++ b/Tests/RunCMake/Autogen/CMP0111-imported-target-implib-only.cmake @@ -0,0 +1,13 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0111-imported-target-prelude.cmake") + +set_location(executable LOCATION "${CMAKE_CURRENT_BINARY_DIR}/executable${CMAKE_EXECUTABLE_SUFFIX}") + +if (CMAKE_IMPORT_LIBRARY_SUFFIX) + set_location(shared IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}shared${CMAKE_IMPORT_LIBRARY_SUFFIX}") +else () + set_location(shared LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}shared${CMAKE_SHARED_LIBRARY_SUFFIX}") +endif () + +set_location(static LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}static${CMAKE_STATIC_LIBRARY_SUFFIX}") +set_location(unknown LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}unknown${CMAKE_STATIC_LIBRARY_SUFFIX}") +set_location(module LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_MODULE_PREFIX}module${CMAKE_SHARED_MODULE_SUFFIX}") diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-libname.cmake b/Tests/RunCMake/Autogen/CMP0111-imported-target-libname.cmake new file mode 100644 index 0000000..e1318c2 --- /dev/null +++ b/Tests/RunCMake/Autogen/CMP0111-imported-target-libname.cmake @@ -0,0 +1,14 @@ +include("${CMAKE_CURRENT_LIST_DIR}/CMP0111-imported-target-prelude.cmake") + +set_location(executable LOCATION "${CMAKE_CURRENT_BINARY_DIR}/executable${CMAKE_EXECUTABLE_SUFFIX}") + +set_location(shared LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}shared${CMAKE_SHARED_LIBRARY_SUFFIX}") +if (CMAKE_IMPORT_LIBRARY_SUFFIX) + set_location(shared IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}shared${CMAKE_IMPORT_LIBRARY_SUFFIX}") +endif () + +set_location(static LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}static${CMAKE_IMPORT_LIBRARY_SUFFIX}") +set_location(unknown LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}unknown${CMAKE_IMPORT_LIBRARY_SUFFIX}") +set_location(module LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_MODULE_PREFIX}module${CMAKE_SHARED_MODULE_SUFFIX}") + +set_location(interface LIBNAME "interface") diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake b/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake new file mode 100644 index 0000000..8fa6041 --- /dev/null +++ b/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake @@ -0,0 +1,32 @@ +enable_language(CXX) + +find_package(Qt5 REQUIRED COMPONENTS Core) + +# Detect `-NOTFOUND` libraries at generate time. +cmake_policy(SET CMP0111 NEW) + +add_executable(imported::executable IMPORTED) +add_library(imported::shared SHARED IMPORTED) +add_library(imported::static STATIC IMPORTED) +add_library(imported::unknown UNKNOWN IMPORTED) +add_library(imported::interface INTERFACE IMPORTED) +add_library(imported::module MODULE IMPORTED) + +function (set_location target name loc) + set_property(TARGET "imported::${target}" PROPERTY + "IMPORTED_${name}" "${loc}") +endfunction () + +set(CMAKE_AUTOMOC 1) + +add_library(automoc + empty.cpp) +target_link_libraries(automoc + PRIVATE + imported::shared + imported::static + imported::unknown + imported::interface) +add_dependencies(automoc + imported::executable + imported::module) diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake index a31b67c..bbcbd5e 100644 --- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake +++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake @@ -5,4 +5,8 @@ if (with_qt5) run_cmake(QtInFunction) run_cmake(QtInFunctionNested) run_cmake(QtInFunctionProperty) + + run_cmake(CMP0111-imported-target-full) + run_cmake(CMP0111-imported-target-libname) + run_cmake(CMP0111-imported-target-implib-only) endif () diff --git a/Utilities/Scripts/update-curl.bash b/Utilities/Scripts/update-curl.bash index abd54f6..dd8e7a8 100755 --- a/Utilities/Scripts/update-curl.bash +++ b/Utilities/Scripts/update-curl.bash @@ -8,7 +8,7 @@ readonly name="curl" readonly ownership="Curl Upstream <curl-library@cool.haxx.se>" readonly subtree="Utilities/cmcurl" readonly repo="https://github.com/curl/curl.git" -readonly tag="curl-7_79_0" +readonly tag="curl-7_79_1" readonly shortlog=false readonly paths=" CMake/* diff --git a/Utilities/cmcurl/include/curl/curlver.h b/Utilities/cmcurl/include/curl/curlver.h index 6c20917..9019868 100644 --- a/Utilities/cmcurl/include/curl/curlver.h +++ b/Utilities/cmcurl/include/curl/curlver.h @@ -30,13 +30,13 @@ /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "7.79.0" +#define LIBCURL_VERSION "7.79.1" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 7 #define LIBCURL_VERSION_MINOR 79 -#define LIBCURL_VERSION_PATCH 0 +#define LIBCURL_VERSION_PATCH 1 /* This is the numeric version of the libcurl version number, meant for easier parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will @@ -57,7 +57,7 @@ CURL_VERSION_BITS() macro since curl's own configure script greps for it and needs it to contain the full number. */ -#define LIBCURL_VERSION_NUM 0x074f00 +#define LIBCURL_VERSION_NUM 0x074f01 /* * This is the date and time when the full source package was created. The diff --git a/Utilities/cmcurl/lib/hsts.c b/Utilities/cmcurl/lib/hsts.c index 853c7df..052dc11 100644 --- a/Utilities/cmcurl/lib/hsts.c +++ b/Utilities/cmcurl/lib/hsts.c @@ -49,6 +49,7 @@ #define MAX_HSTS_HOSTLENSTR "256" #define MAX_HSTS_DATELEN 64 #define MAX_HSTS_DATELENSTR "64" +#define UNLIMITED "unlimited" #ifdef DEBUGBUILD /* to play well with debug builds, we can *set* a fixed time this will @@ -283,13 +284,17 @@ static CURLcode hsts_push(struct Curl_easy *data, e.namelen = strlen(sts->host); e.includeSubDomains = sts->includeSubDomains; - result = Curl_gmtime((time_t)sts->expires, &stamp); - if(result) - return result; + if(sts->expires != TIME_T_MAX) { + result = Curl_gmtime((time_t)sts->expires, &stamp); + if(result) + return result; - msnprintf(e.expire, sizeof(e.expire), "%d%02d%02d %02d:%02d:%02d", - stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday, - stamp.tm_hour, stamp.tm_min, stamp.tm_sec); + msnprintf(e.expire, sizeof(e.expire), "%d%02d%02d %02d:%02d:%02d", + stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday, + stamp.tm_hour, stamp.tm_min, stamp.tm_sec); + } + else + strcpy(e.expire, UNLIMITED); sc = data->set.hsts_write(data, &e, i, data->set.hsts_write_userp); @@ -303,14 +308,18 @@ static CURLcode hsts_push(struct Curl_easy *data, static CURLcode hsts_out(struct stsentry *sts, FILE *fp) { struct tm stamp; - CURLcode result = Curl_gmtime((time_t)sts->expires, &stamp); - if(result) - return result; - - fprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n", - sts->includeSubDomains ? ".": "", sts->host, - stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday, - stamp.tm_hour, stamp.tm_min, stamp.tm_sec); + if(sts->expires != TIME_T_MAX) { + CURLcode result = Curl_gmtime((time_t)sts->expires, &stamp); + if(result) + return result; + fprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n", + sts->includeSubDomains ? ".": "", sts->host, + stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday, + stamp.tm_hour, stamp.tm_min, stamp.tm_sec); + } + else + fprintf(fp, "%s%s \"%s\"\n", + sts->includeSubDomains ? ".": "", sts->host, UNLIMITED); return CURLE_OK; } @@ -403,7 +412,8 @@ static CURLcode hsts_add(struct hsts *h, char *line) "%" MAX_HSTS_HOSTLENSTR "s \"%" MAX_HSTS_DATELENSTR "[^\"]\"", host, date); if(2 == rc) { - time_t expires = Curl_getdate_capped(date); + time_t expires = strcmp(date, UNLIMITED) ? Curl_getdate_capped(date) : + TIME_T_MAX; CURLcode result; char *p = host; bool subdomain = FALSE; @@ -456,7 +466,7 @@ static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h) return result; } else if(sc == CURLSTS_FAIL) - return CURLE_BAD_FUNCTION_ARGUMENT; + return CURLE_ABORTED_BY_CALLBACK; } while(sc == CURLSTS_OK); } return CURLE_OK; diff --git a/Utilities/cmcurl/lib/hsts.h b/Utilities/cmcurl/lib/hsts.h index baa5828..653c053 100644 --- a/Utilities/cmcurl/lib/hsts.h +++ b/Utilities/cmcurl/lib/hsts.h @@ -59,7 +59,7 @@ CURLcode Curl_hsts_loadcb(struct Curl_easy *data, struct hsts *h); #else #define Curl_hsts_cleanup(x) -#define Curl_hsts_loadcb(x,y) +#define Curl_hsts_loadcb(x,y) CURLE_OK #define Curl_hsts_save(x,y,z) #endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */ #endif /* HEADER_CURL_HSTS_H */ diff --git a/Utilities/cmcurl/lib/http.c b/Utilities/cmcurl/lib/http.c index d5c36dd..648583c 100644 --- a/Utilities/cmcurl/lib/http.c +++ b/Utilities/cmcurl/lib/http.c @@ -4232,9 +4232,9 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, char separator; char twoorthree[2]; int httpversion = 0; - int digit4 = -1; /* should remain untouched to be good */ + char digit4 = 0; nc = sscanf(HEADER1, - " HTTP/%1d.%1d%c%3d%1d", + " HTTP/%1d.%1d%c%3d%c", &httpversion_major, &httpversion, &separator, @@ -4250,13 +4250,13 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, /* There can only be a 4th response code digit stored in 'digit4' if all the other fields were parsed and stored first, so nc is 5 when - digit4 is not -1 */ - else if(digit4 != -1) { + digit4 a digit */ + else if(ISDIGIT(digit4)) { failf(data, "Unsupported response code in HTTP response"); return CURLE_UNSUPPORTED_PROTOCOL; } - if((nc == 4) && (' ' == separator)) { + if((nc >= 4) && (' ' == separator)) { httpversion += 10 * httpversion_major; switch(httpversion) { case 10: diff --git a/Utilities/cmcurl/lib/http2.c b/Utilities/cmcurl/lib/http2.c index a3de607..6d63f43 100644 --- a/Utilities/cmcurl/lib/http2.c +++ b/Utilities/cmcurl/lib/http2.c @@ -2221,12 +2221,6 @@ CURLcode Curl_http2_setup(struct Curl_easy *data, stream->mem = data->state.buffer; stream->len = data->set.buffer_size; - httpc->inbuflen = 0; - httpc->nread_inbuf = 0; - - httpc->pause_stream_id = 0; - httpc->drain_total = 0; - multi_connchanged(data->multi); /* below this point only connection related inits are done, which only needs to be done once per connection */ @@ -2252,6 +2246,12 @@ CURLcode Curl_http2_setup(struct Curl_easy *data, conn->httpversion = 20; conn->bundle->multiuse = BUNDLE_MULTIPLEX; + httpc->inbuflen = 0; + httpc->nread_inbuf = 0; + + httpc->pause_stream_id = 0; + httpc->drain_total = 0; + infof(data, "Connection state changed (HTTP/2 confirmed)"); return CURLE_OK; diff --git a/Utilities/cmcurl/lib/multi.c b/Utilities/cmcurl/lib/multi.c index 8509781..518ceb5 100644 --- a/Utilities/cmcurl/lib/multi.c +++ b/Utilities/cmcurl/lib/multi.c @@ -1052,11 +1052,17 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi, for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) { curl_socket_t s = CURL_SOCKET_BAD; - if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK((sockbunch[i]))) { + if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK(sockbunch[i])) { + if(!FDSET_SOCK(sockbunch[i])) + /* pretend it doesn't exist */ + continue; FD_SET(sockbunch[i], read_fd_set); s = sockbunch[i]; } - if((bitmap & GETSOCK_WRITESOCK(i)) && VALID_SOCK((sockbunch[i]))) { + if((bitmap & GETSOCK_WRITESOCK(i)) && VALID_SOCK(sockbunch[i])) { + if(!FDSET_SOCK(sockbunch[i])) + /* pretend it doesn't exist */ + continue; FD_SET(sockbunch[i], write_fd_set); s = sockbunch[i]; } diff --git a/Utilities/cmcurl/lib/select.h b/Utilities/cmcurl/lib/select.h index 19da1e7..59a571d 100644 --- a/Utilities/cmcurl/lib/select.h +++ b/Utilities/cmcurl/lib/select.h @@ -97,8 +97,10 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes, #if defined(TPF) #define VALID_SOCK(x) 1 #define VERIFY_SOCK(x) Curl_nop_stmt +#define FDSET_SOCK(x) 1 #elif defined(USE_WINSOCK) #define VALID_SOCK(s) ((s) < INVALID_SOCKET) +#define FDSET_SOCK(x) 1 #define VERIFY_SOCK(x) do { \ if(!VALID_SOCK(x)) { \ SET_SOCKERRNO(WSAEINVAL); \ @@ -106,17 +108,17 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes, } \ } while(0) #else -#ifdef HAVE_POLL_FINE -#define VALID_SOCK(s) ((s) >= 0) /* FD_SETSIZE is irrelevant for poll */ -#else -#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE)) -#endif -#define VERIFY_SOCK(x) do { \ - if(!VALID_SOCK(x)) { \ - SET_SOCKERRNO(EINVAL); \ - return -1; \ - } \ -} while(0) +#define VALID_SOCK(s) ((s) >= 0) + +/* If the socket is small enough to get set or read from an fdset */ +#define FDSET_SOCK(s) ((s) < FD_SETSIZE) + +#define VERIFY_SOCK(x) do { \ + if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \ + SET_SOCKERRNO(EINVAL); \ + return -1; \ + } \ + } while(0) #endif #endif /* HEADER_CURL_SELECT_H */ diff --git a/Utilities/cmcurl/lib/strerror.c b/Utilities/cmcurl/lib/strerror.c index 431ff1c..8a27197 100644 --- a/Utilities/cmcurl/lib/strerror.c +++ b/Utilities/cmcurl/lib/strerror.c @@ -731,12 +731,11 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) max = buflen - 1; *buf = '\0'; - /* !checksrc! disable STRERROR 2 */ #if defined(WIN32) || defined(_WIN32_WCE) #if defined(WIN32) /* 'sys_nerr' is the maximum errno number, it is not widely portable */ if(err >= 0 && err < sys_nerr) - strncpy(buf, strerror(err), max); + strncpy(buf, sys_errlist[err], max); else #endif { @@ -787,6 +786,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) } #else { + /* !checksrc! disable STRERROR 1 */ const char *msg = strerror(err); if(msg) strncpy(buf, msg, max); diff --git a/Utilities/cmcurl/lib/transfer.c b/Utilities/cmcurl/lib/transfer.c index 3e650b5..05fec79 100644 --- a/Utilities/cmcurl/lib/transfer.c +++ b/Utilities/cmcurl/lib/transfer.c @@ -1503,7 +1503,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) } #endif Curl_http2_init_state(&data->state); - Curl_hsts_loadcb(data, data->hsts); + result = Curl_hsts_loadcb(data, data->hsts); } /* |