...
 
Commits (59)
......@@ -31,11 +31,11 @@ syn region cmakeGeneratorExpression start="$<" end=">" contained oneline contain
syn region cmakeString start='"' end='"' contained contains=cmakeTodo,cmakeVariableValue,cmakeEscaped
syn region cmakeVariableValue start="${" end="}" contained oneline contains=cmakeVariable,cmakeTodo
syn region cmakeVariableValue start="${" end="}" contained oneline contains=cmakeVariable,cmakeTodo,cmakeVariableValue
syn region cmakeEnvironment start="$ENV{" end="}" contained oneline contains=cmakeTodo
syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo
syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeGeneratorExpressions,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo
syn case match
......
......@@ -13,6 +13,9 @@ my @properties;
my @modules;
my %keywords; # command => keyword-list
# find cmake/Modules/ | sed -rn 's/.*CMakeDetermine(.+)Compiler.cmake/\1/p' | sort
my @languages = qw(ASM ASM_MASM ASM_NASM C CSharp CUDA CXX Fortran Java RC Swift);
# unwanted upper-cases
my %unwanted = map { $_ => 1 } qw(VS CXX IDE NOTFOUND NO_ DFOO DBAR NEW);
# cannot remove ALL - exists for add_custom_command
......@@ -30,8 +33,21 @@ push @modules, "ExternalProject";
# variables
open(CMAKE, "$cmake --help-variable-list|") or die "could not run cmake";
while (<CMAKE>) {
next if /\</; # skip if containing < or >
chomp;
if (/<(.*?)>/) {
if ($1 eq 'LANG') {
foreach my $lang (@languages) {
(my $V = $_) =~ s/<.*>/$lang/;
push @variables, $V;
}
next
} else {
next; # skip if containing < or >
}
}
push @variables, $_;
}
close(CMAKE);
......
This diff is collapsed.
......@@ -8,11 +8,16 @@ if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
set(_INTEL_WINDOWS 1)
endif()
if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Clang"
AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
set(_CLANG_MSVC_WINDOWS 1)
endif()
# Disable deprecation warnings for standard C functions.
# really only needed for newer versions of VS, but should
# not hurt other versions, and this will work into the
# future
if(MSVC OR _INTEL_WINDOWS)
if(MSVC OR _INTEL_WINDOWS OR _CLANG_MSVC_WINDOWS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
else()
endif()
......@@ -21,6 +26,10 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stack:10000000")
endif()
if(_CLANG_MSVC_WINDOWS AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -stack:20000000")
endif()
#silence duplicate symbol warnings on AIX
if(CMAKE_SYSTEM_NAME MATCHES "AIX")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
......
......@@ -377,7 +377,15 @@ command is needed to stage it again.
Resolve
=======
A MR may be resolved in one of the following ways.
The workflow used by the CMake project supports a number of different
ways in which a MR can be moved to a resolved state. In addition to
the conventional practices of merging or closing a MR without merging it,
a MR can also be moved to a quasi-resolved state pending some action.
This may involve moving discussion to an issue or it may be the result of
an extended period of inactivity. These quasi-resolved states are used
to help manage the relatively large number of MRs the project receives
and are not an indication of the changes being rejected. The following
sections explain the different resolutions a MR may be given.
Merge
-----
......@@ -433,15 +441,68 @@ Close
-----
If review has concluded that the MR should not be integrated then it
may be closed through GitLab.
may be closed through GitLab. This would normally be a final state
with no expectation that the MR would be re-opened in the future.
It is also used when a MR is being superseded by another separate one,
in which case a reference to the new MR should be added to the MR being
closed.
Expire
------
If progress on a MR has stalled for a while, it may be closed with a
``workflow:expired`` label and a comment indicating that the MR has
been closed due to inactivity.
Contributors are welcome to re-open an expired MR when they are ready
to continue work. Please re-open *before* pushing an update to the
MR topic branch to ensure GitLab will still act on the association.
been closed due to inactivity (it may also be done where the MR is blocked
for an extended period by work in a different MR). This is not an
indication that there is a problem with the MR's content, it is only a
practical measure to allow the reviewers to focus attention on MRs that
are actively being worked on. As a guide, the average period of inactivity
before transitioning a MR to the expired state would be around 2 weeks,
but this may decrease to 1 week or less when there is a high number of
open merge requests.
Reviewers would usually provide a message similar to the following when
resolving a MR as expired::
Closing for now. @<MR-author> please re-open when ready to continue work.
This is to make it clear to contributors that they are welcome to re-open
the expired MR when they are ready to return to working on it and moving
it forward. In the meantime, the MR will appear as ``Closed`` in GitLab,
but it can be differentiated from permanently closed MRs by the presence
of the ``workflow:expired`` label.
**NOTE:** Please re-open *before* pushing an update to the MR topic branch
to ensure GitLab will still act on the association. If changes are pushed
before re-opening the MR, the reviewer should initiate a ``Do: check`` to
force GitLab to act on the updates.
External Discussion
-------------------
In some situations, a series of comments on a MR may develop into a more
involved discussion, or it may become apparent that there are broader
discussions that need to take place before the MR can move forward in an
agreed direction. Such discussions are better suited to GitLab issues
rather than in a MR because MRs may be superseded by a different MR, or
the set of changes may evolve to look quite different to the context in
which the discussions began. When this occurs, reviewers may ask the
MR author to open an issue to discuss things there and they will transition
the MR to a resolved state with the label ``workflow:external-discussion``.
The MR will appear in GitLab as closed, but it can be differentiated from
permanently closed MRs by the presence of the ``workflow:external-discussion``
label. Reviewers should leave a message clearly explaining the action
so that the MR author understands that the MR closure is temporary and
it is clear what actions need to happen next. The following is an example
of such a message, but it will usually be necessary to tailor the message
to the individual situation::
The desired behavior here looks to be more involved than first thought.
Please open an issue so we can discuss the relevant details there.
Once the path forward is clear, we can re-open this MR and continue work.
When the discussion in the associated issue runs its course and the way
forward is clear, the MR can be re-opened again and the
``workflow:external-discussion`` label removed. Reviewers should ensure
that the issue created contains a reference to the MR so that GitLab
provides a cross-reference to link the two.
......@@ -342,6 +342,7 @@ Properties on Targets
/prop_tgt/VS_KEYWORD
/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION
/prop_tgt/VS_NO_SOLUTION_DEPLOY
/prop_tgt/VS_PACKAGE_REFERENCES
/prop_tgt/VS_PROJECT_IMPORT
/prop_tgt/VS_SCC_AUXPATH
/prop_tgt/VS_SCC_LOCALPATH
......
......@@ -552,20 +552,23 @@ Available commands are:
Compress the resulting archive with bzip2.
``J``
Compress the resulting archive with XZ.
``--``
Stop interpreting options and treat all remaining arguments
as file names even if they start in ``-``.
``--zstd``
Compress the resulting archive with Zstandard.
``--files-from=<file>``
Read file names from the given file, one per line.
Blank lines are ignored. Lines may not start in ``-``
except for ``--add-file=<name>`` to add files whose
names start in ``-``.
``--mtime=<date>``
Specify modification time recorded in tarball entries.
``--format=<format>``
Specify the format of the archive to be created.
Supported formats are: ``7zip``, ``gnutar``, ``pax``,
``paxr`` (restricted pax, default), and ``zip``.
``--mtime=<date>``
Specify modification time recorded in tarball entries.
``--``
Stop interpreting options and treat all remaining arguments
as file names, even if they start with ``-``.
``time <command> [<args>...]``
Run command and display elapsed time.
......
VS_PACKAGE_REFERENCES
---------------------
Visual Studio package references for nuget.
Adds one or more semicolon-delimited package references to a generated
Visual Studio project. The version of the package will be
underscore delimited. For example, ``boost_1.7.0;nunit_3.12.*``.
.. code-block:: cmake
set_property(TARGET ${TARGET_NAME} PROPERTY
VS_PACKAGE_REFERENCES "boost_1.7.0")
......@@ -412,3 +412,11 @@ Changes made since CMake 3.14.0 include the following.
incorrectly propagate usage requirements of those dependencies to
dependents that link the static library. This has been fixed.
The bug also existed in 3.13.0 through 3.13.4 and is fixed in 3.13.5.
3.14.5
------
* Entries of the ``CPATH`` environment variable are no longer excluded
from explicit use via :command:`include_directories` and
:command:`target_include_directories` as they were in CMake 3.14.0
through 3.14.4.
clang-gnulike-support
---------------------
* The ``Clang`` compiler variant on Windows that targets the MSVC ABI
but has a GNU-like command line is now supported.
Help/release/dev/cmake-e-tar-zstd-support
-----------------------------------------
* The :manual:`cmake(1)` ``-E tar`` tool now support Zstandard compression
algorithm with ``--zstd`` option. Zstandard was designed to give
a compression ratio comparable to that of the DEFLATE (zip) algorithm,
but faster, especially for decompression.
vs-add-package-references
-------------------------
* A :prop_tgt:`VS_PACKAGE_REFERENCES` target property was added to
tell :ref:`Visual Studio Generators` to add references to nuget
packages.
......@@ -12,6 +12,7 @@ set(CMAKE_C11_COMPILE_FEATURES "@CMAKE_C11_COMPILE_FEATURES@")
set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@")
set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@")
set(CMAKE_C_COMPILER_FRONTEND_VARIANT "@CMAKE_C_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@")
@_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_C_ARCHITECTURE_ID@
......
......@@ -14,6 +14,7 @@ set(CMAKE_CXX20_COMPILE_FEATURES "@CMAKE_CXX20_COMPILE_FEATURES@")
set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "@CMAKE_CXX_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
@_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_CXX_ARCHITECTURE_ID@
......
......@@ -114,7 +114,6 @@ if(NOT CMAKE_C_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c)
CMAKE_DIAGNOSE_UNSUPPORTED_CLANG(C CC)
# Set old compiler and platform id variables.
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
......
......@@ -109,7 +109,6 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp)
CMAKE_DIAGNOSE_UNSUPPORTED_CLANG(CXX CXX)
# Set old compiler and platform id variables.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
......
......@@ -136,6 +136,31 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "")
endif()
set(_variant "")
if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xClang")
if(CMAKE_HOST_WIN32 AND "x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC")
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC")
else()
# Test whether an MSVC-like command-line option works.
execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -?
RESULT_VARIABLE _clang_result
OUTPUT_VARIABLE _clang_stdout
ERROR_VARIABLE _clang_stderr)
if(_clang_result EQUAL 0)
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC")
else()
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
endif()
endif()
set(_variant " with ${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}-like command-line")
else()
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
endif()
else()
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "")
endif()
# Display the final identification result.
if(CMAKE_${lang}_COMPILER_ID)
if(CMAKE_${lang}_COMPILER_VERSION)
......@@ -149,9 +174,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
set(_archid "")
endif()
message(STATUS "The ${lang} compiler identification is "
"${CMAKE_${lang}_COMPILER_ID}${_archid}${_version}")
"${CMAKE_${lang}_COMPILER_ID}${_archid}${_version}${_variant}")
unset(_archid)
unset(_version)
unset(_variant)
else()
message(STATUS "The ${lang} compiler identification is unknown")
endif()
......@@ -163,6 +189,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
PARENT_SCOPE)
set(CMAKE_${lang}_XCODE_ARCHS "${CMAKE_${lang}_XCODE_ARCHS}" PARENT_SCOPE)
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_VERSION_INTERNAL "${CMAKE_${lang}_COMPILER_VERSION_INTERNAL}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_WRAPPER "${CMAKE_${lang}_COMPILER_WRAPPER}" PARENT_SCOPE)
......@@ -864,38 +891,3 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags)
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" PARENT_SCOPE)
endif()
endfunction()
function(CMAKE_DIAGNOSE_UNSUPPORTED_CLANG lang envvar)
if(NOT CMAKE_HOST_WIN32 OR CMAKE_GENERATOR MATCHES "Visual Studio" OR
NOT "${CMAKE_${lang}_COMPILER_ID};${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "Clang;MSVC")
return()
endif()
# Test whether an MSVC-like command-line option works.
execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -?
RESULT_VARIABLE _clang_result
OUTPUT_VARIABLE _clang_stdout
ERROR_VARIABLE _clang_stderr)
if(_clang_result EQUAL 0)
return()
endif()
# Help the user configure the environment to use the MSVC-like Clang.
string(CONCAT _msg
"The Clang compiler tool\n"
" \"${CMAKE_${lang}_COMPILER}\"\n"
"targets the MSVC ABI but has a GNU-like command-line interface. "
"This is not supported. "
"Use 'clang-cl' instead, e.g. by setting '${envvar}=clang-cl' in the environment."
)
execute_process(COMMAND rc -help
RESULT_VARIABLE _rc_result
OUTPUT_VARIABLE _rc_stdout
ERROR_VARIABLE _rc_stderr)
if(NOT _rc_result EQUAL 0)
string(APPEND _msg " "
"Furthermore, use the MSVC command-line environment."
)
endif()
message(FATAL_ERROR "${_msg}")
endfunction()
......@@ -60,7 +60,9 @@ __resolve_tool_path(CMAKE_MT "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Manifes
set(_CMAKE_TOOL_VARS "")
# if it's the MS C/CXX compiler, search for link
if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC"
if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND
("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC"
OR NOT "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang"))
OR "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC"
OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xPGI")
OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xNVIDIA")
......@@ -80,17 +82,26 @@ else()
if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}/bin)
endif()
find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang)
set(LLVM_OBJDUMP "llvm-objdump")
set(LLVM_LLD "ld.lld")
set(LLVM_RANLIB "llvm-ranlib")
set(LLVM_AR "llvm-ar")
endif()
find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${LLVM_AR} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${LLVM_RANLIB} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if(NOT CMAKE_RANLIB)
set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
endif()
find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${LLVM_LLD} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${LLVM_OBJDUMP} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
list(APPEND _CMAKE_TOOL_VARS CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
......
......@@ -3,6 +3,6 @@
find_program(CMAKE_MAKE_PROGRAM
NAMES ninja-build ninja
NAMES ninja-build ninja samu
DOC "Program used to build from build.ninja files.")
mark_as_advanced(CMAKE_MAKE_PROGRAM)
......@@ -19,12 +19,16 @@ endif()
set(CMAKE_INCLUDE_FLAG_Swift "-I ")
set(CMAKE_Swift_DEFINE_FLAG -D)
set(CMAKE_Swift_COMPILE_OPTIONS_TARGET "-target ")
set(CMAKE_Swift_COMPILER_ARG1 -frontend)
set(CMAKE_Swift_DEFINE_FLAG -D)
set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ")
set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ")
set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @)
set(CMAKE_Swift_LINKER_PREFERENCE 50)
set(CMAKE_Swift_LINKER_PREFERENCE_PROPAGATES 1)
# NOTE(compnerd) use the short form for convenience and ease of search. They
# are treated equivalent to their long form names as well as custom Swift
# specific names.
......
include(Compiler/Clang)
__compiler_clang(CXX)
if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
endif()
......@@ -10,7 +10,8 @@ if(APPLE AND NOT appleClangPolicy STREQUAL NEW)
return()
endif()
if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
......@@ -56,6 +57,14 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
unset(_clang_version_std17)
if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
# This clang++ is missing some features because of MSVC compatibility.
unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT)
unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT)
endif()
__compiler_check_default_language_standard(CXX 2.1 98)
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9
AND CMAKE_CXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0)
......
This diff is collapsed.
......@@ -347,6 +347,7 @@ macro(_OPENMP_SET_VERSION_BY_SPEC_DATE LANG)
# Preview versions
"201611=5.0" # OpenMP 5.0 preview 1
# Combined versions, 2.5 onwards
"201811=5.0"
"201511=4.5"
"201307=4.0"
"201107=3.1"
......@@ -363,6 +364,9 @@ macro(_OPENMP_SET_VERSION_BY_SPEC_DATE LANG)
# Fortran version 1.0
"199710=1.0"
)
if(MSVC)
list(APPEND OpenMP_SPEC_DATE_MAP "2019=2.0")
endif()
if(OpenMP_${LANG}_SPEC_DATE)
string(REGEX MATCHALL "${OpenMP_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" _version_match "${OpenMP_SPEC_DATE_MAP}")
......
......@@ -1315,8 +1315,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
HINTS ${_${_PYTHON_PREFIX}_HINTS}
PATHS ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
PATH_SUFFIXES lib libs)
endif()
if (${_PYTHON_PREFIX}_LIBRARY_RELEASE)
# extract version from library name
if (${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "python([23])([0-9]+)")
......
......@@ -67,8 +67,8 @@ set(_ZLIB_SEARCH_NORMAL
unset(_ZLIB_x86)
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
set(ZLIB_NAMES z zlib zdll zlib1)
set(ZLIB_NAMES_DEBUG zlibd zlibd1)
set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic)
set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd)
# Try each search configuration.
foreach(search ${_ZLIB_SEARCHES})
......
......@@ -8,13 +8,120 @@ if(__WINDOWS_CLANG)
endif()
set(__WINDOWS_CLANG 1)
macro(__windows_compiler_clang_gnu lang)
set(CMAKE_LIBRARY_PATH_FLAG "-L")
set(CMAKE_LINK_LIBRARY_FLAG "-l")
set(CMAKE_IMPORT_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_MODULE_PREFIX "")
set(CMAKE_STATIC_LIBRARY_PREFIX "")
set(CMAKE_EXECUTABLE_SUFFIX ".exe")
set(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
set(CMAKE_SHARED_MODULE_SUFFIX ".dll")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>")
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib")
set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1)
set (CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:")
if("${CMAKE_${lang}_SIMULATE_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)")
math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}")
endif()
# No -fPIC on Windows
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
# Create archiving rules to support large object file lists for static libraries.
set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
"<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY})
set(CMAKE_${lang}_LINK_EXECUTABLE
"<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd)
set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd)
if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
set(__ADDED_FLAGS "")
set(__ADDED_FLAGS_DEBUG "")
else()
set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd")
set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt")
endif()
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}")
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}")
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
unset(__ADDED_FLAGS)
unset(__ADDED_FLAGS_DEBUG)
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames")
enable_language(RC)
endmacro()
if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
include(Platform/Windows-MSVC)
macro(__windows_compiler_clang lang)
set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}")
__windows_compiler_msvc(${lang})
endmacro()
if ( DEFINED CMAKE_C_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_ID
AND NOT "x${CMAKE_C_COMPILER_ID}" STREQUAL "x${CMAKE_CXX_COMPILER_ID}")
message(FATAL_ERROR "The current configuration mixes Clang and MSVC or "
"some other CL compatible compiler tool. This is not supported. "
"Use either clang or MSVC as both C and C++ compilers.")
endif()
if ( DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT AND DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT
AND NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}")
message(FATAL_ERROR "The current configuration uses the Clang compiler "
"tool with mixed frontend variants, both the GNU and in MSVC CL "
"like variants. This is not supported. Use either clang/clang++ "
"or clang-cl as both C and C++ compilers.")
endif()
if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" )
include(Platform/Windows-MSVC)
macro(__windows_compiler_clang lang)
set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}")
__windows_compiler_msvc(${lang})
endmacro()
else()
cmake_policy(GET CMP0091 __WINDOWS_CLANG_CMP0091)
if(__WINDOWS_CLANG_CMP0091 STREQUAL "NEW")
set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "")
endif()
unset(__WINDOWS_CLANG_CMP0091)
set(CMAKE_BUILD_TYPE_INIT Debug)
macro(__windows_compiler_clang lang)
__windows_compiler_clang_gnu(${lang})
endmacro()
endif()
else()
include(Platform/Windows-GNU)
macro(__windows_compiler_clang lang)
......
......@@ -421,5 +421,7 @@ macro(__windows_compiler_msvc_enable_rc flags)
endif()
enable_language(RC)
set(CMAKE_NINJA_CMCLDEPS_RC 1)
if(NOT DEFINED CMAKE_NINJA_CMCLDEPS_RC)
set(CMAKE_NINJA_CMCLDEPS_RC 1)
endif()
endmacro()
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 14)
set(CMake_VERSION_PATCH 20190529)
set(CMake_VERSION_PATCH 20190531)
#set(CMake_VERSION_RC 1)
......@@ -137,6 +137,13 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c,
return;
}
break;
case CompressZstd:
if (archive_write_add_filter_zstd(this->Archive) != ARCHIVE_OK) {
this->Error = "archive_write_add_filter_zstd: ";
this->Error += cm_archive_error_string(this->Archive);
return;
}
break;
}
#if !defined(_WIN32) || defined(__CYGWIN__)
if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) {
......
......@@ -49,7 +49,8 @@ public:
CompressGZip,
CompressBZip2,
CompressLZMA,
CompressXZ
CompressXZ,
CompressZstd
};
/** Construct with output stream to which to write archive. */
......
......@@ -1611,8 +1611,8 @@ std::string cmCTest::Base64GzipEncodeFile(std::string const& file)
std::vector<std::string> files;
files.push_back(file);
if (!cmSystemTools::CreateTar(tarFile.c_str(), files,
cmSystemTools::TarCompressGZip, false)) {
if (!cmSystemTools::CreateTar(tarFile, files, cmSystemTools::TarCompressGZip,
false)) {
cmCTestLog(this, ERROR_MESSAGE,
"Error creating tar while "
"encoding file: "
......
......@@ -61,7 +61,8 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
if (0 != vsIDE) {
DISPID dispid = (DISPID)-1;
OLECHAR* name = L"ExecuteCommand";
wchar_t execute_command[] = L"ExecuteCommand";
OLECHAR* name = execute_command;
hr =
vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
......@@ -119,7 +120,8 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
}
oss << " dwHelpContext: " << excep.dwHelpContext << std::endl;
oss << " pvReserved: " << excep.pvReserved << std::endl;
oss << " pfnDeferredFillIn: " << excep.pfnDeferredFillIn << std::endl;
oss << " pfnDeferredFillIn: "
<< reinterpret_cast<void*>(excep.pfnDeferredFillIn) << std::endl;
oss << " scode: " << excep.scode << std::endl;
}
......@@ -140,7 +142,8 @@ HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution)
if (0 != vsIDE) {
DISPID dispid = (DISPID)-1;
OLECHAR* name = L"Solution";
wchar_t solution[] = L"Solution";
OLECHAR* name = solution;
hr =
vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
......@@ -183,7 +186,8 @@ HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName)
if (0 != vsSolution) {
DISPID dispid = (DISPID)-1;
OLECHAR* name = L"FullName";
wchar_t full_name[] = L"FullName";
OLECHAR* name = full_name;
hr = vsSolution->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT,
&dispid);
......
......@@ -535,11 +535,22 @@ void cmGlobalGenerator::EnableLanguage(
# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning(push)
# pragma warning(disable : 4996)
# ifdef __INTEL_COMPILER
# pragma warning(disable : 1478)
# elif defined __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# else
# pragma warning(disable : 4996)
# endif
# endif
GetVersionExW((OSVERSIONINFOW*)&osviex);
# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning(pop)
# ifdef __clang__
# pragma clang diagnostic pop
# else
# pragma warning(pop)
# endif
# endif
std::ostringstream windowsVersionString;
windowsVersionString << osviex.dwMajorVersion << "."
......
This diff is collapsed.
......@@ -138,18 +138,10 @@ public:
const std::string& output);
/**
* Write a rule statement named @a name to @a os with the @a comment,
* the mandatory @a command, the @a depfile and the @a description.
* It also writes the variables bound to this rule statement.
* Write a rule statement to @a os.
* @warning no escaping of any kind is done here.
*/
static void WriteRule(std::ostream& os, const std::string& name,
const std::string& command,
const std::string& description,
const std::string& comment, const std::string& depfile,
const std::string& deptype, const std::string& rspfile,
const std::string& rspcontent,
const std::string& restat, bool generator);
static void WriteRule(std::ostream& os, cmNinjaRule const& rule);
/**
* Write a variable named @a name to @a os with value @a value and an
......@@ -273,11 +265,7 @@ public:
* Call WriteRule() behind the scene but perform some check before like:
* - Do not add twice the same rule.
*/
void AddRule(const std::string& name, const std::string& command,
const std::string& description, const std::string& comment,
const std::string& depfile, const std::string& deptype,
const std::string& rspfile, const std::string& rspcontent,
const std::string& restat, bool generator);
void AddRule(cmNinjaRule const& rule);
bool HasRule(const std::string& name);
......
......@@ -252,7 +252,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
std::ostringstream error;
cmListFileContext lfc;
lfc.FilePath = this->FileName;
lfc.Line = lastLine;
lfc.Line = line;
cmListFileBacktrace lfbt = this->Backtrace;
lfbt = lfbt.Push(lfc);
error << "Parse error. Function missing ending \")\". "
......
......@@ -88,6 +88,19 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->ComputeObjectMaxPath();
// Canonicalize entries of the CPATH environment variable the same
// way detection of CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES does.
{
std::vector<std::string> cpath;
cmSystemTools::GetPath(cpath, "CPATH");
for (std::string& cp : cpath) {
if (cmSystemTools::FileIsFullPath(cp)) {
cp = cmSystemTools::CollapseFullPath(cp);
this->EnvCPATH.emplace(std::move(cp));
}
}
}
std::vector<std::string> enabledLanguages =
this->GetState()->GetEnabledLanguages();
......@@ -1011,9 +1024,18 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
}
// Checks if this is not an excluded (implicit) include directory.
auto notExcluded = [&implicitSet, &implicitExclude](std::string const& dir) {
return ((implicitSet.find(dir) == implicitSet.end()) &&
(implicitExclude.find(dir) == implicitExclude.end()));
auto notExcluded = [this, &implicitSet, &implicitExclude,
&lang](std::string const& dir) {
return (
// Do not exclude directories that are not in an excluded set.
((implicitSet.find(dir) == implicitSet.end()) &&
(implicitExclude.find(dir) == implicitExclude.end()))
// Do not exclude entries of the CPATH environment variable even though
// they are implicitly searched by the compiler. They are meant to be
// user-specified directories that can be re-ordered or converted to
// -isystem without breaking real compiler builtin headers.
|| ((lang == "C" || lang == "CXX") &&
(this->EnvCPATH.find(dir) != this->EnvCPATH.end())));
};
// Get the target-specific include directories.
......
......@@ -429,6 +429,8 @@ protected:
std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations;
std::set<std::string> EnvCPATH;
typedef std::unordered_map<std::string, cmGeneratorTarget*>
GeneratorTargetMap;
GeneratorTargetMap GeneratorTargetSearchIndex;
......
......@@ -162,13 +162,8 @@ struct cmNinjaRemoveNoOpCommands
void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
{
cmStateEnums::TargetType targetType = this->GetGeneratorTarget()->GetType();
std::string ruleName = this->LanguageLinkerDeviceRule();
// Select whether to use a response file for objects.
std::string rspfile;
std::string rspcontent;
if (!this->GetGlobalGenerator()->HasRule(ruleName)) {
cmNinjaRule rule(this->LanguageLinkerDeviceRule());
if (!this->GetGlobalGenerator()->HasRule(rule.Name)) {
cmRulePlaceholderExpander::RuleVariables vars;
vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str();
vars.CMTargetType =
......@@ -192,16 +187,16 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
} else {
responseFlag = "@";
}
rspfile = "$RSP_FILE";
responseFlag += rspfile;
rule.RspFile = "$RSP_FILE";
responseFlag += rule.RspFile;
// build response file content
if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
rspcontent = "$in";
rule.RspContent = "$in";
} else {
rspcontent = "$in_newline";
rule.RspContent = "$in_newline";
}
rspcontent += " $LINK_LIBRARIES";
rule.RspContent += " $LINK_LIBRARIES";
vars.Objects = responseFlag.c_str();
vars.LinkLibraries = "";
}
......@@ -220,7 +215,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
vars.Manifests = "$MANIFESTS";
std::string langFlags;
if (targetType != cmStateEnums::EXECUTABLE) {
if (this->GetGeneratorTarget()->GetType() != cmStateEnums::EXECUTABLE) {
langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS";
vars.LanguageCompileFlags = langFlags.c_str();
}
......@@ -247,39 +242,35 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
// If there is no ranlib the command will be ":". Skip it.
cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands());
std::string linkCmd =
this->GetLocalGenerator()->BuildCommandLine(linkCmds);
rule.Command = this->GetLocalGenerator()->BuildCommandLine(linkCmds);
// Write the linker rule with response file if needed.
std::ostringstream comment;
comment << "Rule for linking " << this->TargetLinkLanguage << " "
<< this->GetVisibleTypeName() << ".";
std::ostringstream description;
description << "Linking " << this->TargetLinkLanguage << " "
<< this->GetVisibleTypeName() << " $TARGET_FILE";
this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(),
comment.str(),
/*depfile*/ "",
/*deptype*/ "", rspfile, rspcontent,
/*restat*/ "$RESTAT",
/*generator*/ false);
rule.Comment = "Rule for linking ";
rule.Comment += this->TargetLinkLanguage;
rule.Comment += " ";
rule.Comment += this->GetVisibleTypeName();
rule.Comment += ".";
rule.Description = "Linking ";
rule.Description += this->TargetLinkLanguage;
rule.Description += " ";
rule.Description += this->GetVisibleTypeName();
rule.Description += " $TARGET_FILE";
rule.Restat = "$RESTAT";
this->GetGlobalGenerator()->AddRule(rule);
}
}
void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
{
cmStateEnums::TargetType targetType = this->GetGeneratorTarget()->GetType();
std::string ruleName = this->LanguageLinkerRule();
// Select whether to use a response file for objects.
std::string rspfile;
std::string rspcontent;
if (!this->GetGlobalGenerator()->HasRule(ruleName)) {
std::string linkRuleName = this->LanguageLinkerRule();
if (!this->GetGlobalGenerator()->HasRule(linkRuleName)) {
cmNinjaRule rule(std::move(linkRuleName));
cmRulePlaceholderExpander::RuleVariables vars;
vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str();
vars.CMTargetType =
cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType());
vars.CMTargetType = cmState::GetTargetTypeName(targetType);
vars.Language = this->TargetLinkLanguage.c_str();
......@@ -311,16 +302,16 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
} else {
responseFlag = "@";
}
rspfile = "$RSP_FILE";
responseFlag += rspfile;
rule.RspFile = "$RSP_FILE";
responseFlag += rule.RspFile;
// build response file content
if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
rspcontent = "$in";
rule.RspContent = "$in";
} else {
rspcontent = "$in_newline";
rule.RspContent = "$in_newline";
}
rspcontent += " $LINK_PATH $LINK_LIBRARIES";
rule.RspContent += " $LINK_PATH $LINK_LIBRARIES";
if (this->TargetLinkLanguage == "Swift") {
vars.SwiftSources = responseFlag.c_str();
} else {
......@@ -389,22 +380,21 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
linkCmds.emplace_back("$POST_BUILD");
std::string linkCmd =
this->GetLocalGenerator()->BuildCommandLine(linkCmds);
rule.Command = this->GetLocalGenerator()->BuildCommandLine(linkCmds);
// Write the linker rule with response file if needed.
std::ostringstream comment;
comment << "Rule for linking " << this->TargetLinkLanguage << " "
<< this->GetVisibleTypeName() << ".";
std::ostringstream description;
description << "Linking " << this->TargetLinkLanguage << " "
<< this->GetVisibleTypeName() << " $TARGET_FILE";
this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(),
comment.str(),
/*depfile*/ "",
/*deptype*/ "", rspfile, rspcontent,
/*restat*/ "$RESTAT",
/*generator*/ false);
rule.Comment = "Rule for linking ";
rule.Comment += this->TargetLinkLanguage;
rule.Comment += " ";
rule.Comment += this->GetVisibleTypeName();
rule.Comment += ".";
rule.Description = "Linking ";
rule.Description += this->TargetLinkLanguage;
rule.Description += " ";
rule.Description += this->GetVisibleTypeName();
rule.Description += " $TARGET_FILE";
rule.Restat = "$RESTAT";
this->GetGlobalGenerator()->AddRule(rule);
}
if (this->TargetNames.Output != this->TargetNames.Real &&
......@@ -413,41 +403,28 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
if (targetType == cmStateEnums::EXECUTABLE) {
std::vector<std::string> commandLines;
commandLines.push_back(cmakeCommand +
" -E cmake_symlink_executable $in $out");
commandLines.emplace_back("$POST_BUILD");
this->GetGlobalGenerator()->AddRule(
"CMAKE_SYMLINK_EXECUTABLE",
this->GetLocalGenerator()->BuildCommandLine(commandLines),
"Creating executable symlink $out",
"Rule for creating "
"executable symlink.",
/*depfile*/ "",
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
/*restat*/ "",
/*generator*/ false);
cmNinjaRule rule("CMAKE_SYMLINK_EXECUTABLE");
{
std::vector<std::string> cmd;
cmd.push_back(cmakeCommand + " -E cmake_symlink_executable $in $out");
cmd.emplace_back("$POST_BUILD");
rule.Command = this->GetLocalGenerator()->BuildCommandLine(cmd);
}
rule.Description = "Creating executable symlink $out";
rule.Comment = "Rule for creating executable symlink.";
this->GetGlobalGenerator()->AddRule(rule);
} else {
std::vector<std::string> commandLines;
commandLines.push_back(cmakeCommand +
" -E cmake_symlink_library $in $SONAME $out");
commandLines.emplace_back("$POST_BUILD");
this->GetGlobalGenerator()->AddRule(
"CMAKE_SYMLINK_LIBRARY",
this->GetLocalGenerator()->BuildCommandLine(commandLines),
"Creating library symlink $out",
"Rule for creating "
"library symlink.",
/*depfile*/ "",
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
/*restat*/ "",
/*generator*/ false);
cmNinjaRule rule("CMAKE_SYMLINK_LIBRARY");
{
std::vector<std::string> cmd;
cmd.push_back(cmakeCommand +
" -E cmake_symlink_library $in $SONAME $out");
cmd.emplace_back("$POST_BUILD");
rule.Command = this->GetLocalGenerator()->BuildCommandLine(cmd);
}
rule.Description = "Creating library symlink $out";
rule.Comment = "Rule for creating library symlink.";
this->GetGlobalGenerator()->AddRule(rule);
}
}
}
......
......@@ -495,9 +495,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
if (explicitPP) {
cmNinjaRule rule(this->LanguagePreprocessRule(lang));
// Explicit preprocessing always uses a depfile.
std::string const ppDeptype; // no deps= for multiple outputs
std::string const ppDepfile = "$DEP_FILE";
rule.DepType = ""; // no deps= for multiple outputs
rule.DepFile = "$DEP_FILE";
cmRulePlaceholderExpander::RuleVariables ppVars;
ppVars.CMTargetName = vars.CMTargetName;
......@@ -505,7 +506,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
ppVars.Language = vars.Language;
ppVars.Object = "$out"; // for RULE_LAUNCH_COMPILE
ppVars.PreprocessedSource = "$out";
ppVars.DependencyFile = ppDepfile.c_str();
ppVars.DependencyFile = rule.DepFile.c_str();
// Preprocessing uses the original source,
// compilation uses preprocessed output.
......@@ -524,17 +525,15 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
ppVars.Includes = vars.Includes;
// If using a response file, move defines, includes, and flags into it.
std::string ppRspFile;
std::string ppRspContent;
if (!responseFlag.empty()) {
ppRspFile = "$RSP_FILE";
ppRspContent = " ";
ppRspContent += ppVars.Defines;
ppRspContent += " ";
ppRspContent += ppVars.Includes;
ppRspContent += " ";
ppRspContent += ppFlags;
ppFlags = responseFlag + ppRspFile;
rule.RspFile = "$RSP_FILE";
rule.RspContent = " ";
rule.RspContent += ppVars.Defines;
rule.RspContent += " ";
rule.RspContent += ppVars.Includes;
rule.RspContent += " ";
rule.RspContent += ppFlags;
ppFlags = responseFlag + rule.RspFile;
ppVars.Defines = "";
ppVars.Includes = "";
}
......@@ -570,31 +569,25 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
}
ppCmds.emplace_back(std::move(ccmd));
}
std::string const ppCmdLine =
this->GetLocalGenerator()->BuildCommandLine(ppCmds);
rule.Command = this->GetLocalGenerator()->BuildCommandLine(ppCmds);
// Write the rule for preprocessing file of the given language.
std::string ppComment = "Rule for preprocessing ";
ppComment += lang;
ppComment += " files.";
std::string ppDesc = "Building ";
ppDesc += lang;
ppDesc += " preprocessed $out";
this->GetGlobalGenerator()->AddRule(
this->LanguagePreprocessRule(lang), ppCmdLine, ppDesc, ppComment,
ppDepfile, ppDeptype, ppRspFile, ppRspContent,
/*restat*/ "",
/*generator*/ false);
rule.Comment = "Rule for preprocessing ";
rule.Comment += lang;
rule.Comment += " files.";
rule.Description = "Building ";
rule.Description += lang;
rule.Description += " preprocessed $out";
this->GetGlobalGenerator()->AddRule(rule);
}
if (needDyndep) {
// Write the rule for ninja dyndep file generation.
cmNinjaRule rule(this->LanguageDyndepRule(lang));
// Command line length is almost always limited -> use response file for
// dyndep rules
std::string ddRspFile = "$out.rsp";
std::string ddRspContent = "$in";
std::string ddCmdLine;
rule.RspFile = "$out.rsp";
rule.RspContent = "$in";
// Run CMake dependency scanner on the source file (using the preprocessed
// source if that was performed).
......@@ -608,53 +601,49 @@ void cmNinjaTarge