summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeCPack.cmake3
-rw-r--r--CMakeCPackOptions.cmake.in10
-rw-r--r--Help/command/file.rst46
-rw-r--r--Help/generator/Xcode.rst4
-rw-r--r--Help/release/dev/require-xcode-5.rst4
-rw-r--r--Help/variable/CMAKE_MAKE_PROGRAM.rst8
-rw-r--r--Modules/CMakeDetermineASMCompiler.cmake2
-rw-r--r--Modules/CMakeDetermineCompilerABI.cmake6
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake2
-rw-r--r--Modules/CMakeDetermineVSServicePack.cmake2
-rw-r--r--Modules/FindBoost.cmake8
-rw-r--r--Modules/Platform/UnixPaths.cmake14
-rw-r--r--README.rst19
-rw-r--r--Source/CMakeLists.txt3
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmGlobalGenerator.cxx23
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx13
-rw-r--r--Source/cmGlobalVisualStudio14Generator.h3
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx6
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx72
-rw-r--r--Source/cmLocalGenerator.cxx110
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx22
-rw-r--r--Source/cmNinjaTargetGenerator.cxx14
-rw-r--r--Source/cmQtAutoGen.cxx20
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx64
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.h6
-rw-r--r--Source/cmQtAutoGenInitializer.cxx53
-rw-r--r--Source/cmQtAutoGenInitializer.h4
-rw-r--r--Source/cmRulePlaceholderExpander.cxx10
-rw-r--r--Source/cmRulePlaceholderExpander.h2
-rw-r--r--Source/cmTarget.cxx11
-rw-r--r--Source/cmUuid.cxx18
-rw-r--r--Source/cmUuid.h4
-rw-r--r--Source/cmake.cxx23
-rw-r--r--Source/cmakexbuild.cxx80
-rw-r--r--Source/cmcmd.cxx30
36 files changed, 343 insertions, 378 deletions
diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake
index dc9f0ba..78e22cc 100644
--- a/CMakeCPack.cmake
+++ b/CMakeCPack.cmake
@@ -102,9 +102,6 @@ if(CMake_INSTALL_COMPONENTS)
if(WIN32 AND NOT CYGWIN)
list(APPEND _CPACK_IFW_COMPONENTS_ALL cmcldeps)
endif()
- if(APPLE)
- list(APPEND _CPACK_IFW_COMPONENTS_ALL cmakexbuild)
- endif()
if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME
${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in
index a08c97d..2a4bcc5 100644
--- a/CMakeCPackOptions.cmake.in
+++ b/CMakeCPackOptions.cmake.in
@@ -109,16 +109,6 @@ if(CPACK_GENERATOR MATCHES "IFW")
set(CPACK_IFW_COMPONENT_CMCLDEPS_VERSION
"@CMake_IFW_ROOT_COMPONENT_VERSION@")
- set(CPACK_COMPONENT_CMAKEXBUILD_DISPLAY_NAME "cmakexbuild")
- set(CPACK_COMPONENT_CMAKEXBUILD_DESCRIPTION
- "The \"cmakexbuild\" executable is a wrapper program for \"xcodebuild\"")
- set(CPACK_COMPONENT_CMAKEXBUILD_REQUIRED TRUE)
- set(CPACK_COMPONENT_CMAKEXBUILD_GROUP Tools)
- set(CPACK_IFW_COMPONENT_CMAKEXBUILD_NAME "CMakeXBuild")
- set(CPACK_IFW_COMPONENT_CMAKEXBUILD_PRIORITY 85)
- set(CPACK_IFW_COMPONENT_CMAKEXBUILD_VERSION
- "@CMake_IFW_ROOT_COMPONENT_VERSION@")
-
# Dialogs
set(CPACK_COMPONENT_GROUP_DIALOGS_DISPLAY_NAME "Interactive Dialogs")
set(CPACK_COMPONENT_GROUP_DIALOGS_DESCRIPTION
diff --git a/Help/command/file.rst b/Help/command/file.rst
index db4d6fc..465e567 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -26,8 +26,8 @@ Synopsis
file(`MAKE_DIRECTORY`_ [<dir>...])
file({`COPY`_ | `INSTALL`_} <file>... DESTINATION <dir> [...])
file(`SIZE`_ <filename> <out-var>)
- file(`READ_SYMLINK`_ <filename> <out-var>)
- file(`CREATE_LINK`_ <file> <new-file> [...])
+ file(`READ_SYMLINK`_ <linkname> <out-var>)
+ file(`CREATE_LINK`_ <original> <linkname> [...])
`Path Conversion`_
file(`RELATIVE_PATH`_ <out-var> <directory> <file>)
@@ -350,22 +350,22 @@ pointing to a file and is readable.
.. code-block:: cmake
- file(READ_SYMLINK <filename> <variable>)
+ file(READ_SYMLINK <linkname> <variable>)
-Read the symlink at ``<filename>`` and put the result in ``<variable>``.
-Requires that ``<filename>`` is a valid path pointing to a symlink. If
-``<filename>`` does not exist, or is not a symlink, an error is thrown.
+This subcommand queries the symlink ``<linkname>`` and stores the path it
+points to in the result ``<variable>``. If ``<linkname>`` does not exist or
+is not a symlink, CMake issues a fatal error.
Note that this command returns the raw symlink path and does not resolve
-relative symlinks. If you want to resolve the relative symlink yourself, you
-could do something like this:
+a relative path. The following is an example of how to ensure that an
+absolute path is obtained:
.. code-block:: cmake
- set(filename "/path/to/foo.sym")
- file(READ_SYMLINK "${filename}" result)
+ set(linkname "/path/to/foo.sym")
+ file(READ_SYMLINK "${linkname}" result)
if(NOT IS_ABSOLUTE "${result}")
- get_filename_component(dir "${filename}" DIRECTORY)
+ get_filename_component(dir "${linkname}" DIRECTORY)
set(result "${dir}/${result}")
endif()
@@ -373,23 +373,23 @@ could do something like this:
.. code-block:: cmake
- file(CREATE_LINK <file> <new-file>
+ file(CREATE_LINK <original> <linkname>
[RESULT <result>] [COPY_ON_ERROR] [SYMBOLIC])
-Create a link to ``<file>`` at ``<new-file>``.
+Create a link ``<linkname>`` that points to ``<original>``.
+It will be a hard link by default, but providing the ``SYMBOLIC`` option
+results in a symbolic link instead. Hard links require that ``original``
+exists and is a file, not a directory. If ``<linkname>`` already exists,
+it will be overwritten.
-It is a hard link by default. This can be changed to symbolic links by
-using ``SYMBOLIC``. The original file needs to exist for hard links.
-
-The ``<result>`` variable, if specified, gets the status of the operation.
-It is set to ``0`` in case of success. Otherwise, it contains the error
-generated. In case of failures, if ``RESULT`` is not specified, a fatal error
-is emitted.
+The ``<result>`` variable, if specified, receives the status of the operation.
+It is set to ``0`` upon success or an error message otherwise. If ``RESULT``
+is not specified and the operation fails, a fatal error is emitted.
Specifying ``COPY_ON_ERROR`` enables copying the file as a fallback if
-creating the link fails.
-
-Overwrites the ``<new-file>`` if it exists.
+creating the link fails. It can be useful for handling situations such as
+``<original>`` and ``<linkname>`` being on different drives or mount points,
+which would make them unable to support a hard link.
Path Conversion
^^^^^^^^^^^^^^^
diff --git a/Help/generator/Xcode.rst b/Help/generator/Xcode.rst
index 71430c7..d893ac5 100644
--- a/Help/generator/Xcode.rst
+++ b/Help/generator/Xcode.rst
@@ -3,9 +3,7 @@ Xcode
Generate Xcode project files.
-This supports Xcode 3.0 and above. Support for Xcode versions prior
-to Xcode 5 is deprecated and will be dropped in a future version of
-CMake.
+This supports Xcode 5.0 and above.
Toolset Selection
^^^^^^^^^^^^^^^^^
diff --git a/Help/release/dev/require-xcode-5.rst b/Help/release/dev/require-xcode-5.rst
new file mode 100644
index 0000000..6cfe96a
--- /dev/null
+++ b/Help/release/dev/require-xcode-5.rst
@@ -0,0 +1,4 @@
+require-xcode-5
+---------------
+
+* The :generator:`Xcode` generator now requires at least Xcode 5.
diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst
index 4f5a50f..56df2df 100644
--- a/Help/variable/CMAKE_MAKE_PROGRAM.rst
+++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst
@@ -19,15 +19,11 @@ to configure the project:
This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache
so that it may be edited by the user.
-* The :generator:`Xcode` generator sets this to ``xcodebuild`` (or possibly an
- otherwise undocumented ``cmakexbuild`` wrapper implementing some
- workarounds).
+* The :generator:`Xcode` generator sets this to ``xcodebuild``.
This generator prefers to lookup the build tool at build time
rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache
- ahead of time. This is because ``xcodebuild`` is easy to find,
- the ``cmakexbuild`` wrapper is needed only for older Xcode versions,
- and the path to ``cmakexbuild`` may be outdated if CMake itself moves.
+ ahead of time. This is because ``xcodebuild`` is easy to find.
For compatibility with versions of CMake prior to 3.2, if
a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index dbc41c8..ac27f87 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -83,7 +83,7 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_XL "XL C")
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS MSVC )
- set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "/?")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "-?")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_MSVC "Microsoft")
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI )
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index fd1d5fb..e0d2449 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -96,6 +96,12 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Parsed ${lang} implicit include dir info from above output: rv=${rv}\n${log}\n\n")
if("${rv}" STREQUAL "done")
+ # Entries that we have been told to explicitly pass as standard include
+ # directories will not be implicitly added by the compiler.
+ if(CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES)
+ list(REMOVE_ITEM implicit_incdirs ${CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES})
+ endif()
+
# We parsed implicit include directories, so override the default initializer.
set(_CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT "${implicit_incdirs}")
endif()
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 83ce392..8ba4246 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -824,7 +824,7 @@ function(CMAKE_DIAGNOSE_UNSUPPORTED_CLANG lang envvar)
endif()
# Test whether an MSVC-like command-line option works.
- execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" /?
+ execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -?
RESULT_VARIABLE _clang_result
OUTPUT_VARIABLE _clang_stdout
ERROR_VARIABLE _clang_stderr)
diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake
index 9edc309..a3c4d9c 100644
--- a/Modules/CMakeDetermineVSServicePack.cmake
+++ b/Modules/CMakeDetermineVSServicePack.cmake
@@ -79,7 +79,7 @@ endfunction()
function(_DetermineVSServicePack_FastCheckVersionWithCompiler _SUCCESS_VAR _VERSION_VAR)
if(EXISTS ${CMAKE_CXX_COMPILER})
execute_process(
- COMMAND ${CMAKE_CXX_COMPILER} /?
+ COMMAND ${CMAKE_CXX_COMPILER} -?
ERROR_VARIABLE _output
OUTPUT_QUIET
)
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 8c112d4..7882c4b 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -1807,10 +1807,12 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
foreach(compiler IN LISTS _boost_COMPILER)
list(APPEND _boost_RELEASE_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} )
endforeach()
list(APPEND _boost_RELEASE_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} )
@@ -1819,10 +1821,12 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
foreach(compiler IN LISTS _boost_COMPILER)
list(APPEND _boost_RELEASE_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
endforeach()
list(APPEND _boost_RELEASE_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
endif()
endforeach()
@@ -1860,10 +1864,12 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
foreach(compiler IN LISTS _boost_COMPILER)
list(APPEND _boost_DEBUG_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} )
endforeach()
list(APPEND _boost_DEBUG_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} )
@@ -1872,10 +1878,12 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
foreach(compiler IN LISTS _boost_COMPILER)
list(APPEND _boost_DEBUG_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
endforeach()
list(APPEND _boost_DEBUG_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
endif()
endforeach()
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
index 46c24bb..97f744d 100644
--- a/Modules/Platform/UnixPaths.cmake
+++ b/Modules/Platform/UnixPaths.cmake
@@ -63,21 +63,29 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
/lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
)
+if(CMAKE_SYSROOT_COMPILE)
+ set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
+else()
+ set(_cmake_sysroot_compile "${CMAKE_SYSROOT}")
+endif()
+
# Default per-language values. These may be later replaced after
# parsing the implicit directory information from compiler output.
set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}
- /usr/include
+ "${_cmake_sysroot_compile}/usr/include"
)
set(_CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}
- /usr/include
+ "${_cmake_sysroot_compile}/usr/include"
)
set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES}
- /usr/include
+ "${_cmake_sysroot_compile}/usr/include"
)
+unset(_cmake_sysroot_compile)
+
# Enable use of lib32 and lib64 search path variants by default.
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
diff --git a/README.rst b/README.rst
index 775463e..11bafca 100644
--- a/README.rst
+++ b/README.rst
@@ -67,11 +67,24 @@ choice. Once this has finished successfully, run ``make`` and
Windows
^^^^^^^
-You need to download and install a binary release of CMake in order to build
-CMake. You can get these releases from the `CMake Download Page`_. Then
-proceed with the instructions below.
+There are two ways for building CMake under Windows:
+
+1. Compile with MSVC from VS 2015 or later.
+ You need to download and install a binary release of CMake. You can get
+ these releases from the `CMake Download Page`_. Then proceed with the
+ instructions below for `Building CMake with CMake`_.
+
+2. Bootstrap with MinGW under MSYS2.
+ Download and install `MSYS2`_. Then install the required build tools::
+
+ $ pacman -S --needed git base-devel mingw-w64-x86_64-gcc
+
+ and bootstrap as above::
+
+ $ ./bootstrap && make
.. _`CMake Download Page`: https://cmake.org/cmake/resources/software.html
+.. _`MSYS2`: https://www.msys2.org/
Building CMake with CMake
-------------------------
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 1c06052..663d42e 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -1060,9 +1060,6 @@ if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARI
endif()
if(APPLE)
- add_executable(cmakexbuild cmakexbuild.cxx)
- list(APPEND _tools cmakexbuild)
- target_link_libraries(cmakexbuild CMakeLib)
add_executable(OSXScriptLauncher
CPack/OSXScriptLauncher.cxx)
target_link_libraries(OSXScriptLauncher cmsys)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 6af2c8e..b324571 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 14)
-set(CMake_VERSION_PATCH 20190218)
+set(CMake_VERSION_PATCH 20190220)
#set(CMake_VERSION_RC 1)
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 11c382f..fa0ffcc 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -7,6 +7,7 @@
#include <algorithm>
#include <assert.h>
#include <cstring>
+#include <initializer_list>
#include <iterator>
#include <sstream>
#include <stdio.h>
@@ -2280,10 +2281,9 @@ void cmGlobalGenerator::AddGlobalTarget_Package(
return;
}
- const char* reservedTargets[] = { "package", "PACKAGE" };
- for (const char* const* tn = cm::cbegin(reservedTargets);
- tn != cm::cend(reservedTargets); ++tn) {
- if (!this->CheckCMP0037(*tn, "when CPack packaging is enabled")) {
+ static const auto reservedTargets = { "package", "PACKAGE" };
+ for (auto const& target : reservedTargets) {
+ if (!this->CheckCMP0037(target, "when CPack packaging is enabled")) {
return;
}
}
@@ -2330,10 +2330,10 @@ void cmGlobalGenerator::AddGlobalTarget_PackageSource(
return;
}
- const char* reservedTargets[] = { "package_source" };
- for (const char* const* tn = cm::cbegin(reservedTargets);
- tn != cm::cend(reservedTargets); ++tn) {
- if (!this->CheckCMP0037(*tn, "when CPack source packaging is enabled")) {
+ static const auto reservedTargets = { "package_source" };
+ for (auto const& target : reservedTargets) {
+ if (!this->CheckCMP0037(target,
+ "when CPack source packaging is enabled")) {
return;
}
}
@@ -2360,10 +2360,9 @@ void cmGlobalGenerator::AddGlobalTarget_Test(
return;
}
- const char* reservedTargets[] = { "test", "RUN_TESTS" };
- for (const char* const* tn = cm::cbegin(reservedTargets);
- tn != cm::cend(reservedTargets); ++tn) {
- if (!this->CheckCMP0037(*tn, "when CTest testing is enabled")) {
+ static const auto reservedTargets = { "test", "RUN_TESTS" };
+ for (auto const& target : reservedTargets) {
+ if (!this->CheckCMP0037(target, "when CTest testing is enabled")) {
return;
}
}
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 2d54c33..6509b56 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -158,14 +158,22 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf,
bool required)
{
// Find the default version of the Windows 10 SDK.
- this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion();
- if (required && this->WindowsTargetPlatformVersion.empty()) {
+ std::string const version = this->GetWindows10SDKVersion();
+ if (required && version.empty()) {
std::ostringstream e;
e << "Could not find an appropriate version of the Windows 10 SDK"
<< " installed on this machine";
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
+ this->SetWindowsTargetPlatformVersion(version, mf);
+ return true;
+}
+
+void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion(
+ std::string const& version, cmMakefile* mf)
+{
+ this->WindowsTargetPlatformVersion = version;
if (!cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion,
this->SystemVersion)) {
std::ostringstream e;
@@ -175,7 +183,6 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf,
}
mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION",
this->WindowsTargetPlatformVersion.c_str());
- return true;
}
bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index 32008b0..6e12d3e 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -40,6 +40,9 @@ protected:
virtual bool SelectWindows10SDK(cmMakefile* mf, bool required);
+ void SetWindowsTargetPlatformVersion(std::string const& version,
+ cmMakefile* mf);
+
// Used to verify that the Desktop toolset for the current generator is
// installed on the machine.
bool IsWindowsDesktopToolsetInstalled() const override;
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 913fc4a..2f9eb3f 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -401,6 +401,12 @@ bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf)
// If the Win 8.1 SDK is installed then we can select a SDK matching
// the target Windows version.
if (this->IsWin81SDKInstalled()) {
+ // VS 2019 does not default to 8.1 so specify it explicitly when needed.
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS16 &&
+ !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) {
+ this->SetWindowsTargetPlatformVersion("8.1", mf);
+ return true;
+ }
return cmGlobalVisualStudio14Generator::InitializeWindows(mf);
}
// Otherwise we must choose a Win 10 SDK even if we are not targeting
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 68de8ae..11cc98e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -217,7 +217,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
sscanf(version_string.c_str(), "%u.%u", &v[0], &v[1]);
unsigned int version_number = 10 * v[0] + v[1];
- if (version_number < 30) {
+ if (version_number < 50) {
cm->IssueMessage(MessageType::FATAL_ERROR,
"Xcode " + version_string + " not supported.");
return nullptr;
@@ -256,15 +256,11 @@ std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand()
{
- if (this->XcodeVersion >= 40) {
- std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
- if (makeProgram.empty()) {
- makeProgram = "xcodebuild";
- }
- return makeProgram;
+ std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
+ if (makeProgram.empty()) {
+ makeProgram = "xcodebuild";
}
- // Use cmakexbuild wrapper to suppress environment dump from output.
- return cmSystemTools::GetCMakeCommand() + "xbuild";
+ return makeProgram;
}
bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
@@ -550,12 +546,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// run the depend check makefile as a post build rule
// this will make sure that when the next target is built
// things are up-to-date
- if (target->GetType() == cmStateEnums::OBJECT_LIBRARY ||
- (this->XcodeVersion < 50 &&
- (target->GetType() == cmStateEnums::EXECUTABLE ||
- target->GetType() == cmStateEnums::STATIC_LIBRARY ||
- target->GetType() == cmStateEnums::SHARED_LIBRARY ||
- target->GetType() == cmStateEnums::MODULE_LIBRARY))) {
+ if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
makeHelper.back() = // fill placeholder
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
cmCustomCommandLines commandLines;
@@ -1183,23 +1174,6 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
}
}
- if (this->XcodeVersion < 50) {
- // Add object library contents as external objects. (Equivalent to
- // the externalObjFiles above, except each one is not a cmSourceFile
- // within the target.)
- std::vector<cmSourceFile const*> objs;
- gtgt->GetExternalObjects(objs, "");
- for (auto sourceFile : objs) {
- if (sourceFile->GetObjectLibrary().empty()) {
- continue;
- }
- std::string const& obj = sourceFile->GetFullPath();
- cmXCodeObject* xsf =
- this->CreateXCodeSourceFileFromPath(obj, gtgt, "", nullptr);
- externalObjFiles.push_back(xsf);
- }
- }
-
// some build phases only apply to bundles and/or frameworks
bool isFrameworkTarget = gtgt->IsFrameworkOnApple();
bool isBundleTarget = gtgt->GetPropertyAsBool("MACOSX_BUNDLE");
@@ -2123,9 +2097,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
default:
break;
}
- if (this->XcodeVersion < 40) {
- buildSettings->AddAttribute("PREBINDING", this->CreateString("NO"));
- }
BuildObjectListOrString dirs(this, true);
BuildObjectListOrString fdirs(this, true);
@@ -2775,8 +2746,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
// Loop over configuration types and set per-configuration info.
for (auto const& configName : this->CurrentConfigurationTypes) {
- // Get the current configuration name.
- if (this->XcodeVersion >= 50) {
+ {
// Add object library contents as link flags.
std::string linkObjs;
const char* sep = "";
@@ -2886,7 +2856,7 @@ bool cmGlobalXCodeGenerator::CreateGroups(
// Put cmSourceFile instances in proper groups:
for (auto const& si : gtgt->GetAllConfigSources()) {
cmSourceFile const* sf = si.Source;
- if (this->XcodeVersion >= 50 && !sf->GetObjectLibrary().empty()) {
+ if (!sf->GetObjectLibrary().empty()) {
// Object library files go on the link line instead.
continue;
}
@@ -3076,16 +3046,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
v << std::setfill('0') << std::setw(4) << XcodeVersion * 10;
group->AddAttribute("LastUpgradeCheck", this->CreateString(v.str()));
this->RootObject->AddAttribute("attributes", group);
- if (this->XcodeVersion >= 32) {
- this->RootObject->AddAttribute("compatibilityVersion",
- this->CreateString("Xcode 3.2"));
- } else if (this->XcodeVersion >= 31) {
- this->RootObject->AddAttribute("compatibilityVersion",
- this->CreateString("Xcode 3.1"));
- } else {
- this->RootObject->AddAttribute("compatibilityVersion",
- this->CreateString("Xcode 3.0"));
- }
+ this->RootObject->AddAttribute("compatibilityVersion",
+ this->CreateString("Xcode 3.2"));
// Point Xcode at the top of the source tree.
{
std::string pdir =
@@ -3540,13 +3502,7 @@ void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
cmXCodeObject::Indent(1, fout);
fout << "};\n";
cmXCodeObject::Indent(1, fout);
- if (this->XcodeVersion >= 32) {
- fout << "objectVersion = 46;\n";
- } else if (this->XcodeVersion >= 31) {
- fout << "objectVersion = 45;\n";
- } else {
- fout << "objectVersion = 44;\n";
- }
+ fout << "objectVersion = 46;\n";
cmXCode21Object::PrintList(this->XCodeObjects, fout);
cmXCodeObject::Indent(1, fout);
fout << "rootObject = " << this->RootObject->GetId()
@@ -3714,11 +3670,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
// Flag value with escaped quotes and backslashes.
for (auto c : flag) {
if (c == '\'') {
- if (this->XcodeVersion >= 40) {
- flags += "'\\''";
- } else {
- flags += "\\'";
- }
+ flags += "'\\''";
} else if (c == '\\') {
flags += "\\\\";
} else {
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index fad1741..8393165 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -34,6 +34,7 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
#include <assert.h>
+#include <initializer_list>
#include <iterator>
#include <sstream>
#include <stdio.h>
@@ -51,25 +52,23 @@
// replaced in the form <var> with GetSafeDefinition(var).
// ${LANG} is replaced in the variable first with all enabled
// languages.
-static const char* ruleReplaceVars[] = {
- "CMAKE_${LANG}_COMPILER",
- "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
- "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
- "CMAKE_SHARED_MODULE_${LANG}_FLAGS",
- "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS",
- "CMAKE_${LANG}_LINK_FLAGS",
- "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG",
- "CMAKE_${LANG}_ARCHIVE",
- "CMAKE_AR",
- "CMAKE_CURRENT_SOURCE_DIR",
- "CMAKE_CURRENT_BINARY_DIR",
- "CMAKE_RANLIB",
- "CMAKE_LINKER",
- "CMAKE_MT",
- "CMAKE_CUDA_HOST_COMPILER",
- "CMAKE_CUDA_HOST_LINK_LAUNCHER",
- "CMAKE_CL_SHOWINCLUDES_PREFIX"
-};
+static auto ruleReplaceVars = { "CMAKE_${LANG}_COMPILER",
+ "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
+ "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
+ "CMAKE_SHARED_MODULE_${LANG}_FLAGS",
+ "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS",
+ "CMAKE_${LANG}_LINK_FLAGS",
+ "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG",
+ "CMAKE_${LANG}_ARCHIVE",
+ "CMAKE_AR",
+ "CMAKE_CURRENT_SOURCE_DIR",
+ "CMAKE_CURRENT_BINARY_DIR",
+ "CMAKE_RANLIB",
+ "CMAKE_LINKER",
+ "CMAKE_MT",
+ "CMAKE_CUDA_HOST_COMPILER",
+ "CMAKE_CUDA_HOST_LINK_LAUNCHER",
+ "CMAKE_CL_SHOWINCLUDES_PREFIX" };
cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
: cmOutputConverter(makefile->GetStateSnapshot())
@@ -138,15 +137,13 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->VariableMappings[compilerOptionSysroot] =
this->Makefile->GetSafeDefinition(compilerOptionSysroot);
- for (const char* const* replaceIter = cm::cbegin(ruleReplaceVars);
- replaceIter != cm::cend(ruleReplaceVars); ++replaceIter) {
- std::string actualReplace = *replaceIter;
- if (actualReplace.find("${LANG}") != std::string::npos) {
- cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
+ for (std::string replaceVar : ruleReplaceVars) {
+ if (replaceVar.find("${LANG}") != std::string::npos) {
+ cmSystemTools::ReplaceString(replaceVar, "${LANG}", lang);
}
- this->VariableMappings[actualReplace] =
- this->Makefile->GetSafeDefinition(actualReplace);
+ this->VariableMappings[replaceVar] =
+ this->Makefile->GetSafeDefinition(replaceVar);
}
}
}
@@ -920,6 +917,20 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
return result;
}
+ // Standard include directories to be added unconditionally at the end.
+ // These are intended to simulate additional implicit include directories.
+ std::vector<std::string> userStandardDirs;
+ {
+ std::string key = "CMAKE_";
+ key += lang;
+ key += "_STANDARD_INCLUDE_DIRECTORIES";
+ std::string const value = this->Makefile->GetSafeDefinition(key);
+ cmSystemTools::ExpandListArgument(value, userStandardDirs);
+ for (std::string& usd : userStandardDirs) {
+ cmSystemTools::ConvertToUnixSlashes(usd);
+ }
+ }
+
// Implicit include directories
std::vector<std::string> implicitDirs;
std::set<std::string> implicitSet;
@@ -928,24 +939,21 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
return (implicitSet.find(dir) == implicitSet.end());
};
{
- std::string rootPath;
- if (const char* sysrootCompile =
- this->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE")) {
- rootPath = sysrootCompile;
- } else {
- rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
- }
- cmSystemTools::ConvertToUnixSlashes(rootPath);
-
// Raw list of implicit include directories
- std::vector<std::string> impDirVec;
+ // Start with "standard" directories that we unconditionally add below.
+ std::vector<std::string> impDirVec = userStandardDirs;
// Load implicit include directories for this language.
std::string key = "CMAKE_";
key += lang;
key += "_IMPLICIT_INCLUDE_DIRECTORIES";
if (const char* value = this->Makefile->GetDefinition(key)) {
+ size_t const impDirVecOldSize = impDirVec.size();
cmSystemTools::ExpandListArgument(value, impDirVec);
+ // FIXME: Use cmRange with 'advance()' when it supports non-const.
+ for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) {
+ cmSystemTools::ConvertToUnixSlashes(impDirVec[i]);
+ }
}
// The Platform/UnixPaths module used to hard-code /usr/include for C, CXX,
@@ -965,13 +973,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
}
for (std::string const& i : impDirVec) {
- std::string imd = i;
- cmSystemTools::ConvertToUnixSlashes(imd);
- if (!rootPath.empty() && !cmHasPrefix(imd, rootPath)) {
- imd = rootPath + imd;
- }
- if (implicitSet.insert(imd).second) {
- implicitDirs.emplace_back(std::move(imd));
+ if (implicitSet.insert(i).second) {
+ implicitDirs.emplace_back(i);
}
}
}
@@ -1010,23 +1013,10 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
MoveSystemIncludesToEnd(result, config, lang, target);
// Append standard include directories for this language.
- {
- std::vector<std::string> userStandardDirs;
- {
- std::string key = "CMAKE_";
- key += lang;
- key += "_STANDARD_INCLUDE_DIRECTORIES";
- std::string const value = this->Makefile->GetSafeDefinition(key);
- cmSystemTools::ExpandListArgument(value, userStandardDirs);
- }
- userDirs.reserve(userDirs.size() + userStandardDirs.size());
- for (std::string& usd : userStandardDirs) {
- cmSystemTools::ConvertToUnixSlashes(usd);
- if (notImplicit(usd)) {
- emitDir(usd);
- }
- userDirs.emplace_back(std::move(usd));
- }
+ userDirs.reserve(userDirs.size() + userStandardDirs.size());
+ for (std::string& usd : userStandardDirs) {
+ emitDir(usd);
+ userDirs.emplace_back(std::move(usd));
}
// Append compiler implicit include directories
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 3874f48..3784313 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -799,10 +799,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string frameworkPath;
std::string linkPath;
- cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
- std::string createRule = genTarget.GetCreateRuleVariable(
- this->TargetLinkLanguage, this->GetConfigName());
+ std::string createRule =
+ gt.GetCreateRuleVariable(this->TargetLinkLanguage, this->GetConfigName());
bool useWatcomQuote = mf->IsOn(createRule + "_USE_WATCOM_QUOTE");
cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
@@ -815,9 +814,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory()));
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
- localGen.GetTargetFlags(
- linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"],
- vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget);
+ localGen.GetTargetFlags(linkLineComputer.get(), this->GetConfigName(),
+ vars["LINK_LIBRARIES"], vars["FLAGS"],
+ vars["LINK_FLAGS"], frameworkPath, linkPath, &gt);
// Add OS X version flags, if any.
if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
@@ -838,7 +837,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
vars["LINK_PATH"] = frameworkPath + linkPath;
std::string lwyuFlags;
- if (genTarget.GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
+ if (gt.GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
lwyuFlags = " -Wl,--no-as-needed";
}
@@ -847,17 +846,16 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// code between the Makefile executable and library generators.
if (targetType == cmStateEnums::EXECUTABLE) {
std::string t = vars["FLAGS"];
- localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ localGen.AddArchitectureFlags(t, &gt, TargetLinkLanguage, cfgName);
t += lwyuFlags;
vars["FLAGS"] = t;
} else {
std::string t = vars["ARCH_FLAGS"];
- localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ localGen.AddArchitectureFlags(t, &gt, TargetLinkLanguage, cfgName);
vars["ARCH_FLAGS"] = t;
t.clear();
t += lwyuFlags;
- localGen.AddLanguageFlagsForLinking(t, &genTarget, TargetLinkLanguage,
- cfgName);
+ localGen.AddLanguageFlagsForLinking(t, &gt, TargetLinkLanguage, cfgName);
vars["LANGUAGE_COMPILE_FLAGS"] = t;
}
if (this->GetGeneratorTarget()->HasSOName(cfgName)) {
@@ -880,7 +878,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
targetOutputImplib, cmOutputConverter::SHELL);
vars["TARGET_IMPLIB"] = impLibPath;
EnsureParentDirectoryExists(impLibPath);
- if (genTarget.HasImportLibrary(cfgName)) {
+ if (gt.HasImportLibrary(cfgName)) {
byproducts.push_back(targetOutputImplib);
}
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 8d2586d..6013cd0 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -455,6 +455,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.SwiftAuxiliarySources = "$SWIFT_AUXILIARY_SOURCES";
vars.SwiftModuleName = "$SWIFT_MODULE_NAME";
vars.SwiftLibraryName = "$SWIFT_LIBRARY_NAME";
+ vars.SwiftPartialModule = "$SWIFT_PARTIAL_MODULE";
+ vars.SwiftPartialDoc = "$SWIFT_PARTIAL_DOC";
}
// For some cases we do an explicit preprocessor invocation.
@@ -945,6 +947,18 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
cmGeneratorTarget::Names targetNames =
this->GeneratorTarget->GetLibraryNames(this->GetConfigName());
vars["SWIFT_LIBRARY_NAME"] = targetNames.Base;
+
+ if (const char* partial = source->GetProperty("SWIFT_PARTIAL_MODULE")) {
+ vars["SWIFT_PARTIAL_MODULE"] = partial;
+ } else {
+ vars["SWIFT_PARTIAL_MODULE"] = objectFileName + ".swiftmodule";
+ }
+
+ if (const char* partial = source->GetProperty("SWIFT_PARTIAL_DOC")) {
+ vars["SWIFT_PARTIAL_DOC"] = partial;
+ } else {
+ vars["SWIFT_PARTIAL_DOC"] = objectFileName + ".swiftdoc";
+ }
}
if (!this->NeedDepTypeMSVC(language)) {
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index 653caf7..f437138 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -7,7 +7,7 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <iterator>
+#include <array>
#include <sstream>
#include <utility>
@@ -137,13 +137,21 @@ std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc)
std::string cmQtAutoGen::Quoted(std::string const& text)
{
- static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",
- "\b", "\\b", "\f", "\\f", "\n", "\\n",
- "\r", "\\r", "\t", "\\t", "\v", "\\v" };
+ const std::array<std::pair<const char*, const char*>, 9> replaces = {
+ { { "\\", "\\\\" },
+ { "\"", "\\\"" },
+ { "\a", "\\a" },
+ { "\b", "\\b" },
+ { "\f", "\\f" },
+ { "\n", "\\n" },
+ { "\r", "\\r" },
+ { "\t", "\\t" },
+ { "\v", "\\v" } }
+ };
std::string res = text;
- for (const char* const* it = cm::cbegin(rep); it != cm::cend(rep); it += 2) {
- cmSystemTools::ReplaceString(res, *it, *(it + 1));
+ for (auto const& pair : replaces) {
+ cmSystemTools::ReplaceString(res, pair.first, pair.second);
}
res = '"' + res;
res += '"';
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
index 95a297c..3ad91ee 100644
--- a/Source/cmQtAutoGenGlobalInitializer.cxx
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -6,10 +6,12 @@
#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
+#include "cmDuration.h"
#include "cmGeneratorTarget.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
+#include "cmProcessOutput.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
@@ -183,6 +185,68 @@ void cmQtAutoGenGlobalInitializer::AddToGlobalAutoRcc(
}
}
+bool cmQtAutoGenGlobalInitializer::GetExecutableTestOutput(
+ std::string const& generator, std::string const& executable,
+ std::string& error, std::string* output)
+{
+ // Check if we have cached output
+ {
+ auto it = this->ExecutableTestOutputs_.find(executable);
+ if (it != this->ExecutableTestOutputs_.end()) {
+ // Return output on demand
+ if (output != nullptr) {
+ *output = it->second;
+ }
+ return true;
+ }
+ }
+
+ // Check if the executable exists
+ if (!cmSystemTools::FileExists(executable, true)) {
+ error = "The \"";
+ error += generator;
+ error += "\" executable ";
+ error += cmQtAutoGen::Quoted(executable);
+ error += " does not exist.";
+ return false;
+ }
+
+ // Test the executable
+ std::string stdOut;
+ {
+ std::string stdErr;
+ std::vector<std::string> command;
+ command.push_back(executable);
+ command.emplace_back("-h");
+ int retVal = 0;
+ const bool runResult = cmSystemTools::RunSingleCommand(
+ command, &stdOut, &stdErr, &retVal, nullptr, cmSystemTools::OUTPUT_NONE,
+ cmDuration::zero(), cmProcessOutput::Auto);
+ if (!runResult) {
+ error = "Test run of \"";
+ error += generator;
+ error += "\" executable ";
+ error += cmQtAutoGen::Quoted(executable) + " failed.\n";
+ error += cmQtAutoGen::QuotedCommand(command);
+ error += "\n";
+ error += stdOut;
+ error += "\n";
+ error += stdErr;
+ return false;
+ }
+ }
+
+ // Return executable output on demand
+ if (output != nullptr) {
+ *output = stdOut;
+ }
+
+ // Register executable and output
+ this->ExecutableTestOutputs_.emplace(executable, std::move(stdOut));
+
+ return true;
+}
+
bool cmQtAutoGenGlobalInitializer::generate()
{
return (InitializeCustomTargets() && SetupCustomTargets());
diff --git a/Source/cmQtAutoGenGlobalInitializer.h b/Source/cmQtAutoGenGlobalInitializer.h
index 9e6bac0..74184a0 100644
--- a/Source/cmQtAutoGenGlobalInitializer.h
+++ b/Source/cmQtAutoGenGlobalInitializer.h
@@ -8,6 +8,7 @@
#include <map>
#include <memory> // IWYU pragma: keep
#include <string>
+#include <unordered_map>
#include <vector>
class cmLocalGenerator;
@@ -38,10 +39,15 @@ private:
void AddToGlobalAutoRcc(cmLocalGenerator* localGen,
std::string const& targetName);
+ bool GetExecutableTestOutput(std::string const& generator,
+ std::string const& executable,
+ std::string& error, std::string* output);
+
private:
std::vector<std::unique_ptr<cmQtAutoGenInitializer>> Initializers_;
std::map<cmLocalGenerator*, std::string> GlobalAutoGenTargets_;
std::map<cmLocalGenerator*, std::string> GlobalAutoRccTargets_;
+ std::unordered_map<std::string, std::string> ExecutableTestOutputs_;
};
#endif
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index a96d574..614a88b 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1439,18 +1439,18 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
return res;
}
-std::pair<bool, std::string> GetQtExecutable(
- const cmQtAutoGen::IntegerVersion& qtVersion, cmGeneratorTarget* target,
+std::pair<bool, std::string> cmQtAutoGenInitializer::GetQtExecutable(
const std::string& executable, bool ignoreMissingTarget, std::string* output)
{
const std::string upperExecutable = cmSystemTools::UpperCase(executable);
- std::string result =
- target->Target->GetSafeProperty("AUTO" + upperExecutable + "_EXECUTABLE");
+ std::string result = this->Target->Target->GetSafeProperty(
+ "AUTO" + upperExecutable + "_EXECUTABLE");
if (!result.empty()) {
- cmListFileBacktrace lfbt = target->Target->GetMakefile()->GetBacktrace();
+ cmListFileBacktrace lfbt =
+ this->Target->Target->GetMakefile()->GetBacktrace();
cmGeneratorExpression ge(lfbt);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(result);
- result = cge->Evaluate(target->GetLocalGenerator(), "");
+ result = cge->Evaluate(this->Target->GetLocalGenerator(), "");
return std::make_pair(true, result);
}
@@ -1460,12 +1460,12 @@ std::pair<bool, std::string> GetQtExecutable(
// Find executable
{
const std::string targetName =
- GetQtExecutableTargetName(qtVersion, executable);
+ GetQtExecutableTargetName(this->QtVersion, executable);
if (targetName.empty()) {
err = "The AUTO" + upperExecutable + " feature ";
err += "supports only Qt 4, Qt 5 and Qt 6.";
} else {
- cmLocalGenerator* localGen = target->GetLocalGenerator();
+ cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
if (tgt != nullptr) {
if (tgt->IsImported()) {
@@ -1485,36 +1485,14 @@ std::pair<bool, std::string> GetQtExecutable(
// Test executable
if (err.empty()) {
- if (cmSystemTools::FileExists(result, true)) {
- std::vector<std::string> command;
- command.push_back(result);
- command.emplace_back("-h");
- std::string stdOut;
- std::string stdErr;
- int retVal = 0;
- const bool runResult = cmSystemTools::RunSingleCommand(
- command, &stdOut, &stdErr, &retVal, nullptr,
- cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
- if (!runResult) {
- err = "Test of \"" + executable + "\" binary ";
- err += cmQtAutoGen::Quoted(result) + " failed: ";
- err += cmQtAutoGen::QuotedCommand(command);
- } else {
- if (output != nullptr) {
- *output = stdOut;
- }
- }
- } else {
- err = "The \"" + executable + "\" binary ";
- err += cmQtAutoGen::Quoted(result);
- err += " does not exist";
- }
+ this->GlobalInitializer->GetExecutableTestOutput(executable, result, err,
+ output);
}
// Print error
if (!err.empty()) {
std::string msg = "AutoGen (";
- msg += target->GetName();
+ msg += this->Target->GetName();
msg += "): ";
msg += err;
cmSystemTools::Error(msg);
@@ -1526,16 +1504,14 @@ std::pair<bool, std::string> GetQtExecutable(
bool cmQtAutoGenInitializer::GetMocExecutable()
{
- const auto result =
- GetQtExecutable(this->QtVersion, this->Target, "moc", false, nullptr);
+ const auto result = this->GetQtExecutable("moc", false, nullptr);
this->Moc.Executable = result.second;
return result.first;
}
bool cmQtAutoGenInitializer::GetUicExecutable()
{
- const auto result =
- GetQtExecutable(this->QtVersion, this->Target, "uic", true, nullptr);
+ const auto result = this->GetQtExecutable("uic", true, nullptr);
this->Uic.Executable = result.second;
return result.first;
}
@@ -1543,8 +1519,7 @@ bool cmQtAutoGenInitializer::GetUicExecutable()
bool cmQtAutoGenInitializer::GetRccExecutable()
{
std::string stdOut;
- const auto result =
- GetQtExecutable(this->QtVersion, this->Target, "rcc", false, &stdOut);
+ const auto result = this->GetQtExecutable("rcc", false, &stdOut);
this->Rcc.Executable = result.second;
if (!result.first) {
return false;
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index 10f0bf3..781dd15 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -110,6 +110,10 @@ private:
std::vector<std::string>& files,
std::string& errorMessage);
+ std::pair<bool, std::string> GetQtExecutable(const std::string& executable,
+ bool ignoreMissingTarget,
+ std::string* output);
+
private:
cmQtAutoGenGlobalInitializer* GlobalInitializer;
cmGeneratorTarget* Target;
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index 5ebdd1b..18d00b1 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -177,6 +177,16 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
return replaceValues.SwiftLibraryName;
}
}
+ if (replaceValues.SwiftPartialDoc) {
+ if (variable == "SWIFT_PARTIAL_DOC") {
+ return replaceValues.SwiftPartialDoc;
+ }
+ }
+ if (replaceValues.SwiftPartialModule) {
+ if (variable == "SWIFT_PARTIAL_MODULE") {
+ return replaceValues.SwiftPartialModule;
+ }
+ }
if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
variable == "TARGET_INSTALLNAME_DIR") {
// All these variables depend on TargetSOName
diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h
index 930eafd..93d0577 100644
--- a/Source/cmRulePlaceholderExpander.h
+++ b/Source/cmRulePlaceholderExpander.h
@@ -61,6 +61,8 @@ public:
const char* SwiftAuxiliarySources;
const char* SwiftModuleName;
const char* SwiftLibraryName;
+ const char* SwiftPartialModule;
+ const char* SwiftPartialDoc;
};
// Expand rule variables in CMake of the type found in language rules
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index e871634..d1e4f06 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -5,6 +5,7 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
#include <assert.h>
+#include <initializer_list>
#include <iterator>
#include <set>
#include <sstream>
@@ -312,23 +313,23 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// Setup per-configuration property default values.
if (this->GetType() != cmStateEnums::UTILITY) {
- const char* configProps[] = {
+ static const auto configProps = {
/* clang-format needs this comment to break after the opening brace */
"ARCHIVE_OUTPUT_DIRECTORY_", "LIBRARY_OUTPUT_DIRECTORY_",
"RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_",
"COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_",
- "INTERPROCEDURAL_OPTIMIZATION_", nullptr
+ "INTERPROCEDURAL_OPTIMIZATION_"
};
for (std::string const& configName : configNames) {
std::string configUpper = cmSystemTools::UpperCase(configName);
- for (const char** p = configProps; *p; ++p) {
+ for (auto const& prop : configProps) {
// Interface libraries have no output locations, so honor only
// the configuration map.
if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY &&
- strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) {
+ strcmp(prop, "MAP_IMPORTED_CONFIG_") != 0) {
continue;
}
- std::string property = *p;
+ std::string property = prop;
property += configUpper;
this->SetPropertyDefault(property, nullptr);
}
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx
index 201e1cc..51ecbd1 100644
--- a/Source/cmUuid.cxx
+++ b/Source/cmUuid.cxx
@@ -4,16 +4,10 @@
#include "cmCryptoHash.h"
+#include <array>
#include <string.h>
-cmUuid::cmUuid()
-{
- Groups.push_back(4);
- Groups.push_back(2);
- Groups.push_back(2);
- Groups.push_back(2);
- Groups.push_back(6);
-}
+static const std::array<int, 5> kUuidGroups = { { 4, 2, 2, 2, 6 } };
std::string cmUuid::FromMd5(std::vector<unsigned char> const& uuidNamespace,
std::string const& name) const
@@ -83,11 +77,11 @@ bool cmUuid::StringToBinary(std::string const& input,
return false;
}
size_t index = 0;
- for (size_t i = 0; i < this->Groups.size(); ++i) {
+ for (size_t i = 0; i < kUuidGroups.size(); ++i) {
if (i != 0 && input[index++] != '-') {
return false;
}
- size_t digits = this->Groups[i] * 2;
+ size_t digits = kUuidGroups[i] * 2;
if (!StringToBinaryImpl(input.substr(index, digits), output)) {
return false;
}
@@ -103,12 +97,12 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const
std::string output;
size_t inputIndex = 0;
- for (size_t i = 0; i < this->Groups.size(); ++i) {
+ for (size_t i = 0; i < kUuidGroups.size(); ++i) {
if (i != 0) {
output += '-';
}
- size_t bytes = this->Groups[i];
+ size_t bytes = kUuidGroups[i];
for (size_t j = 0; j < bytes; ++j) {
unsigned char byte = input[inputIndex++];
output += this->ByteToHex(byte);
diff --git a/Source/cmUuid.h b/Source/cmUuid.h
index 158ce6e..7de20dd 100644
--- a/Source/cmUuid.h
+++ b/Source/cmUuid.h
@@ -15,8 +15,6 @@
class cmUuid
{
public:
- cmUuid();
-
std::string FromMd5(std::vector<unsigned char> const& uuidNamespace,
std::string const& name) const;
@@ -42,8 +40,6 @@ private:
std::string BinaryToString(const unsigned char* input) const;
bool IntFromHexDigit(char input, char& output) const;
-
- std::vector<int> Groups;
};
#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index dd29c0c..ab783c7 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -99,6 +99,7 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
#include <cstring>
+#include <initializer_list>
#include <iostream>
#include <iterator>
#include <memory> // IWYU pragma: keep
@@ -1892,11 +1893,10 @@ bool cmake::LoadCache(const std::string& path, bool internal,
std::set<std::string>& includes)
{
bool result = this->State->LoadCache(path, internal, excludes, includes);
- static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
- "CMAKE_CACHE_MINOR_VERSION" };
- for (const char* const* nameIt = cm::cbegin(entries);
- nameIt != cm::cend(entries); ++nameIt) {
- this->UnwatchUnusedCli(*nameIt);
+ static const auto entries = { "CMAKE_CACHE_MAJOR_VERSION",
+ "CMAKE_CACHE_MINOR_VERSION" };
+ for (auto const& entry : entries) {
+ this->UnwatchUnusedCli(entry);
}
return result;
}
@@ -1904,13 +1904,12 @@ bool cmake::LoadCache(const std::string& path, bool internal,
bool cmake::SaveCache(const std::string& path)
{
bool result = this->State->SaveCache(path, this->GetMessenger());
- static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
- "CMAKE_CACHE_MINOR_VERSION",
- "CMAKE_CACHE_PATCH_VERSION",
- "CMAKE_CACHEFILE_DIR" };
- for (const char* const* nameIt = cm::cbegin(entries);
- nameIt != cm::cend(entries); ++nameIt) {
- this->UnwatchUnusedCli(*nameIt);
+ static const auto entries = { "CMAKE_CACHE_MAJOR_VERSION",
+ "CMAKE_CACHE_MINOR_VERSION",
+ "CMAKE_CACHE_PATCH_VERSION",
+ "CMAKE_CACHEFILE_DIR" };
+ for (auto const& entry : entries) {
+ this->UnwatchUnusedCli(entry);
}
return result;
}
diff --git a/Source/cmakexbuild.cxx b/Source/cmakexbuild.cxx
deleted file mode 100644
index f5c8f07..0000000
--- a/Source/cmakexbuild.cxx
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-#include "cmsys/Process.h"
-#include <iostream>
-#include <string>
-#include <vector>
-
-#include "cmDuration.h"
-#include "cmSystemTools.h"
-
-// This is a wrapper program for xcodebuild
-// it calls xcodebuild, and does two things
-// it removes much of the output, all the setenv
-// stuff. Also, it checks for the text file busy
-// error, and re-runs xcodebuild until that error does
-// not show up.
-
-int RunXCode(std::vector<const char*>& argv, bool& hitbug)
-{
- hitbug = false;
- cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, argv.data());
- cmsysProcess_SetTimeout(cp, 0);
- cmsysProcess_Execute(cp);
- std::vector<char> out;
- std::vector<char> err;
- std::string line;
- int pipe =
- cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out, err);
- while (pipe != cmsysProcess_Pipe_None) {
- if (line.find("/bin/sh: bad interpreter: Text file busy") !=
- std::string::npos) {
- hitbug = true;
- std::cerr << "Hit xcodebuild bug : " << line << "\n";
- }
- // if the bug is hit, no more output should be generated
- // because it may contain bogus errors
- // also remove all output with setenv in it to tone down
- // the verbosity of xcodebuild
- if (!hitbug && (line.find("setenv") == std::string::npos)) {
- if (pipe == cmsysProcess_Pipe_STDERR) {
- std::cerr << line << "\n";
- } else if (pipe == cmsysProcess_Pipe_STDOUT) {
- std::cout << line << "\n";
- }
- }
- pipe = cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out,
- err);
- }
- cmsysProcess_WaitForExit(cp, nullptr);
- if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
- return cmsysProcess_GetExitValue(cp);
- }
- if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
- return -1;
- }
- return -1;
-}
-
-int main(int ac, char* av[])
-{
- std::vector<const char*> argv;
- argv.push_back("xcodebuild");
- for (int i = 1; i < ac; i++) {
- argv.push_back(av[i]);
- }
- argv.push_back(nullptr);
- bool hitbug = true;
- int ret = 0;
- while (hitbug) {
- ret = RunXCode(argv, hitbug);
- }
- if (ret < 0) {
- return 255;
- }
- return ret;
-}
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 21802ad..adfce37 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -37,6 +37,7 @@
#include "cmsys/Process.h"
#include "cmsys/Terminal.h"
#include <algorithm>
+#include <array>
#include <iostream>
#include <iterator>
#include <memory> // IWYU pragma: keep
@@ -350,12 +351,13 @@ struct CoCompiler
bool NoOriginalCommand;
};
-static CoCompiler CoCompilers[] = { // Table of options and handlers.
- { "--cppcheck=", HandleCppCheck, false },
- { "--cpplint=", HandleCppLint, false },
- { "--iwyu=", HandleIWYU, false },
- { "--lwyu=", HandleLWYU, true },
- { "--tidy=", HandleTidy, false }
+static const std::array<CoCompiler, 5> CoCompilers = {
+ { // Table of options and handlers.
+ { "--cppcheck=", HandleCppCheck, false },
+ { "--cpplint=", HandleCppLint, false },
+ { "--iwyu=", HandleIWYU, false },
+ { "--lwyu=", HandleLWYU, true },
+ { "--tidy=", HandleTidy, false } }
};
struct CoCompileJob
@@ -386,16 +388,15 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args)
doing_options = false;
} else if (doing_options) {
bool optionFound = false;
- for (CoCompiler const* cc = cm::cbegin(CoCompilers);
- cc != cm::cend(CoCompilers); ++cc) {
- size_t optionLen = strlen(cc->Option);
- if (arg.compare(0, optionLen, cc->Option) == 0) {
+ for (CoCompiler const& cc : CoCompilers) {
+ size_t optionLen = strlen(cc.Option);
+ if (arg.compare(0, optionLen, cc.Option) == 0) {
optionFound = true;
CoCompileJob job;
job.Command = arg.substr(optionLen);
- job.Handler = cc->Handler;
+ job.Handler = cc.Handler;
jobs.push_back(std::move(job));
- if (cc->NoOriginalCommand) {
+ if (cc.NoOriginalCommand) {
runOriginalCmd = false;
}
}
@@ -419,9 +420,8 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args)
if (jobs.empty()) {
std::cerr << "__run_co_compile missing command to run. "
"Looking for one or more of the following:\n";
- for (CoCompiler const* cc = cm::cbegin(CoCompilers);
- cc != cm::cend(CoCompilers); ++cc) {
- std::cerr << cc->Option << "\n";
+ for (CoCompiler const& cc : CoCompilers) {
+ std::cerr << cc.Option << "\n";
}
return 1;
}