call are ``PRIVATE`` to the interface library and do not appear in its
:prop_tgt:`INTERFACE_SOURCES` target property.
+.. _`add_library imported libraries`:
+
Imported Libraries
^^^^^^^^^^^^^^^^^^
:prop_tgt:`IMPORTED_IMPLIB_<CONFIG>`) specifies the location of the
DLL import library file (``.lib`` or ``.dll.a``) on disk, and the
``IMPORTED_LOCATION`` is the location of the ``.dll`` runtime
- library (and is optional).
+ library (and is optional, but needed by the :genex:`TARGET_RUNTIME_DLLS`
+ generator expression).
Additional usage requirements may be specified in ``INTERFACE_*`` properties.
Try building a project. The success or failure of the ``try_compile``,
i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``.
-.. versionadded:: 3.14
- The name of the ``<resultVar>`` is defined by the user. Previously, it had
- a fixed name ``RESULT_VAR``.
-
In this form, ``<srcdir>`` should contain a complete CMake project with a
``CMakeLists.txt`` file and all sources. The ``<bindir>`` and ``<srcdir>``
will not be deleted after this command is run. Specify ``<targetName>`` to
variable). The success or failure of the ``try_compile``, i.e. ``TRUE`` or
``FALSE`` respectively, is returned in ``<resultVar>``.
-.. versionadded:: 3.14
- The name of the ``<resultVar>`` is defined by the user. Previously, it had
- a fixed name ``RESULT_VAR``.
-
In this form, one or more source files must be provided. If
:variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is unset or is set to ``EXECUTABLE``,
the sources must include a definition for ``main`` and CMake will create a
set to ``FAILED_TO_RUN``. See the :command:`try_compile` command for
information on how the test project is constructed to build the source file.
-.. versionadded:: 3.14
- The names of the result variables ``<runResultVar>`` and
- ``<compileResultVar>`` are defined by the user. Previously, they had
- fixed names ``RUN_RESULT_VAR`` and ``COMPILE_RESULT_VAR``.
-
The options are:
``CMAKE_FLAGS <flags>...``
.. code-block:: cmake
- find_package(foo REQUIRED)
+ find_package(foo CONFIG REQUIRED) # package generated by install(EXPORT)
add_executable(exe main.c)
target_link_libraries(exe PRIVATE foo::foo foo::bar)
COMMAND_EXPAND_LISTS
)
+ .. note::
+
+ :ref:`Imported Targets` are supported only if they know the location
+ of their ``.dll`` files. An imported ``SHARED`` or ``MODULE`` library
+ must have :prop_tgt:`IMPORTED_LOCATION` set to its ``.dll`` file. See
+ the :ref:`add_library imported libraries <add_library imported libraries>`
+ section for details. Many :ref:`Find Modules` produce imported targets
+ with the ``UNKNOWN`` type and therefore will be ignored.
+
.. genex:: $<INSTALL_PREFIX>
Content of the install prefix when the target is exported via
* The :generator:`Visual Studio 17 2022` generator is now based on the
"Visual Studio 2022" release candidates. Previously it was based on
preview versions.
+
+3.21.5
+------
+
+This version made no changes to documented features or interfaces.
+Some implementation updates were made to support ecosystem changes
+and/or fix regressions.
set(id_cl "$(CLToolExe)")
elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
set(id_cl clang.exe)
- # Executable names have been chosen according documentation
- # URL: (https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-dpcpp-compiler/top.html#top_GUID-A9B4C91D-97AC-450D-9742-9D895BC8AEE1)
elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel")
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "DPC\\+\\+ Compiler")
set(id_cl dpcpp.exe)
- elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler 2021")
- set(id_cl icx.exe)
- elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler")
+ elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler ([8-9]\\.|1[0-9]\\.|XE)")
set(id_cl icl.exe)
+ elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler")
+ set(id_cl icx.exe)
endif()
else()
set(id_cl cl.exe)
list(PREPEND _CMAKE_MT_NAMES "llvm-mt")
list(PREPEND _CMAKE_LINKER_NAMES "lld-link")
list(APPEND _CMAKE_TOOL_VARS NM)
- elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIntel")
+ elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xIntel")
list(PREPEND _CMAKE_AR_NAMES "xilib")
list(PREPEND _CMAKE_LINKER_NAMES "xilink")
endif()
set(CMAKE_Fortran_COMPILER_WRAPPER "@CMAKE_Fortran_COMPILER_WRAPPER@")
set(CMAKE_Fortran_PLATFORM_ID "@CMAKE_Fortran_PLATFORM_ID@")
set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@")
+set(CMAKE_Fortran_COMPILER_FRONTEND_VARIANT "@CMAKE_Fortran_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@")
@_SET_CMAKE_Fortran_XL_CPP@
@_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID@
elseif(CMAKE_CXX_COMPILER_LOADED)
CHECK_CXX_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD)
endif()
- if(CMAKE_HAVE_LIBC_PTHREAD)
+
+ # Check for -pthread first if enabled. This is the recommended
+ # way, but not backwards compatible as one must also pass -pthread
+ # as compiler flag then.
+ if(THREADS_PREFER_PTHREAD_FLAG)
+ _check_pthreads_flag()
+ endif()
+
+ if(Threads_FOUND)
+ # do nothing, we are done
+ elseif(CMAKE_HAVE_LIBC_PTHREAD)
set(CMAKE_THREAD_LIBS_INIT "")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
else()
- # Check for -pthread first if enabled. This is the recommended
- # way, but not backwards compatible as one must also pass -pthread
- # as compiler flag then.
- if (THREADS_PREFER_PTHREAD_FLAG)
- _check_pthreads_flag()
- endif ()
-
if(CMAKE_SYSTEM MATCHES "GHS-MULTI")
_check_threads_lib(posix pthread_create CMAKE_HAVE_PTHREADS_CREATE)
endif()
# Query the VS Installer tool for locations of VS 2017 and above.
set(_vs_installer_paths "")
- foreach(vs RANGE 16 15 -1) # change the first number to the largest supported version
+ foreach(vs RANGE 17 15 -1) # change the first number to the largest supported version
cmake_host_system_information(RESULT _vs_dir QUERY VS_${vs}_DIR)
if(_vs_dir)
list(APPEND _vs_installer_paths "${_vs_dir}/VC/Auxiliary/Build")
${swig_custom_products}
${swig_cleanup_command}
# Let's create the ${outdir} at execution time, in case dir contains $(OutDir)
- COMMAND "${CMAKE_COMMAND}" -E make_directory ${outdir} ${outfiledir}
+ COMMAND "${CMAKE_COMMAND}" -E make_directory "${workingdir}" "${outdir}" "${outfiledir}"
${swig_timestamp_command}
COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}"
"-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 21)
-set(CMake_VERSION_PATCH 4)
+set(CMake_VERSION_PATCH 5)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
if(NOT CMake_VERSION_NO_GIT)
# If this source was exported by 'git archive', use its commit info.
- set(git_info [==[f65cebf51a CMake 3.21.4]==])
+ set(git_info [==[6fe5df13c2 CMake 3.21.5]==])
# Otherwise, try to identify the current development source version.
if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* "
return true;
}
}
- } else if (compilerId == "Intel") {
+ } else if (compilerId == "Intel" || compilerId == "IntelLLVM") {
const char seq[2] = { '\n', '\0' };
const int seqlen = 2;
#include <cmext/algorithm>
#include <cmext/string_view>
+#include "cm_codecvt.hxx"
+
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
const char* name, std::string const& options,
std::vector<std::string>& makefile_depends)
{
+ // FIXME: Find a better way to determine the response file encoding,
+ // perhaps using tool-specific platform information variables.
+ // For now, use the makefile encoding as a heuristic.
+ codecvt::Encoding responseEncoding =
+ this->GlobalGenerator->GetMakefileEncoding();
+ // Non-MSVC tooling may not understand a BOM.
+ if (responseEncoding == codecvt::UTF8_WITH_BOM &&
+ !this->Makefile->IsOn("MSVC")) {
+ responseEncoding = codecvt::UTF8;
+ }
+
// Create the response file.
std::string responseFileNameFull =
cmStrCat(this->TargetBuildDirectoryFull, '/', name);
- cmGeneratedFileStream responseStream(
- responseFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
+ cmGeneratedFileStream responseStream(responseFileNameFull, false,
+ responseEncoding);
responseStream.SetCopyIfDifferent(true);
responseStream << options << "\n";
}
Json::Value const& version = ppi["version"];
- if (version.asUInt() != 0) {
+ if (version.asUInt() > 1) {
cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ",
arg_pp, ": version ", version.asString()));
return false;
// cannot use it to print messages. Another implementation will
// be needed to print colored messages on Windows.
static_cast<void>(md);
- std::cerr << m << cmakemainGetStack(cm) << "\n";
+ std::cerr << m << cmakemainGetStack(cm) << '\n' << std::flush;
#else
cmsysTerminal_cfprintf(md.desiredColor, stderr, "%s", m.c_str());
fflush(stderr); // stderr is buffered in some cases.
- std::cerr << cmakemainGetStack(cm) << "\n";
+ std::cerr << cmakemainGetStack(cm) << '\n' << std::flush;
#endif
}
"flags": []
},
{
- "name": "LinkControlFlowGuard",
- "switch": "guard:cf",
- "comment": "Control Flow Guard",
- "value": "true",
- "flags": []
- },
- {
"name": "LinkGuardEHContMetadata",
"switch": "guard:ehcont",
"comment": "Enable EH Continuation Metadata",
run_cmake(VsSettings)
run_cmake(VsSourceSettingsTool)
run_cmake(VsPlatformToolset)
+run_cmake(VsControlFlowGuardLinkSetting)
run_cmake(VsWinRTByDefault)
--- /dev/null
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/ControlFlowGuardProject.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ControlFlowGuardProject.vcxproj does not exist.")
+ return()
+endif()
+
+set(Is_in_link_section 0)
+set(HAS_ControlFlowGuardSetting 0)
+
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<LinkControlFlowGuard>([^<>]+)</LinkControlFlowGuard>")
+ set(RunCMake_TEST_FAILED "Project file ControlFlowGuardProject.vcxproj contains the invalid <LinkControlFlowGuard> link property.")
+ return()
+ break()
+ endif()
+ if(line MATCHES "^ *<Link>")
+ # The start of the link section of the vcxproj file
+ set(Is_in_link_section 1)
+ continue()
+ endif()
+ if(line MATCHES "^ *</Link>")
+ # The end of the link section of the vcxproj file
+ set(Is_in_link_section 0)
+ continue()
+ endif()
+ if(Is_in_link_section)
+ if(line MATCHES "^ *<AdditionalOptions>([^<>]+)</AdditionalOptions>")
+ if("${CMAKE_MATCH_1}" MATCHES ".*/guard:cf.*")
+ set(HAS_ControlFlowGuardSetting 1)
+ break()
+ endif()
+ endif()
+ endif()
+endforeach()
+
+if(NOT HAS_ControlFlowGuardSetting)
+ set(RunCMake_TEST_FAILED "Project file ControlFlowGuardProject.vcxproj does not have '/guard:cf' specified in the <AdditionalOptions> property.")
+ return()
+endif()
--- /dev/null
+enable_language(CXX)
+
+# Add the Control Flow Guard compiler and linker option
+add_compile_options("/guard:cf")
+string(APPEND CMAKE_SHARED_LINKER_FLAGS " /guard:cf")
+
+add_library(ControlFlowGuardProject SHARED foo.cpp)
${build_generator_args}
--build-project TestBasicPython
--build-options ${build_options} -DSWIG_USE_SWIG_DEPENDENCIES=ON
+ "-DSWIG_OUTFILE_DIR=${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPython.Depfile"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
add_test(NAME UseSWIG.Depfile.BasicPerl COMMAND