[Cmake-commits] CMake branch, master, updated. v3.10.1-820-gb4dfe1d
Kitware Robot
kwrobot at kitware.com
Tue Jan 16 09:35:19 EST 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, master has been updated
via b4dfe1d8163055f9f40a4c18f5eccccb28f06559 (commit)
via 7accd7ebe2b6e9999e427c23a81c6e6811033a1d (commit)
via 47b8a421b000fa2a6428e160b2937488344b6b56 (commit)
via 506fda1cf026a88378589009b62ca8bf633c5197 (commit)
via c2f79c98677d43fb8686f9e4309acddfae8f3dfd (commit)
via e1f0518de09a54065459a728993563d84fb85a6a (commit)
via eae0a85d84fe12f058f8542aa4d05cfdf5c61cb1 (commit)
via 0795d25b78d5b7682aea091d260eaf1bca7afd0a (commit)
via 1ab4d186a7d5a3481d2f0978aaebd6bf0bc7f891 (commit)
via 07e1a74361b89c1080db1bca904dcd82e955777d (commit)
via f74c25802de11e4e4578b1c9473f99d106491da8 (commit)
from 27cbbf0ed047ef4adbe33b3a0bb21812577660b7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b4dfe1d8163055f9f40a4c18f5eccccb28f06559
commit b4dfe1d8163055f9f40a4c18f5eccccb28f06559
Merge: 7accd7e 506fda1
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 16 14:33:12 2018 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jan 16 09:33:23 2018 -0500
Merge topic 'extend-compile-language-genex'
506fda1c Genex: Enable COMPILE_LANGUAGE for INCLUDE_DIRECTORIES with VS and Xcode
c2f79c98 Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS with VS and Xcode
0795d25b cmVisualStudio10TargetGenerator: Factor out include dir computation
1ab4d186 cmLocalVisualStudio7Generator: Clarify variable name of compiled language
07e1a743 cmLocalVisualStudio7Generator: Clarify condition for target that compiles
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1657
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7accd7ebe2b6e9999e427c23a81c6e6811033a1d
commit 7accd7ebe2b6e9999e427c23a81c6e6811033a1d
Merge: 47b8a42 f74c258
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 16 14:26:54 2018 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jan 16 09:27:02 2018 -0500
Merge topic 'CheckIncludeFile-required-libs'
f74c2580 CheckIncludeFiles: Honor CMAKE_REQUIRED_LIBRARIES
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1620
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47b8a421b000fa2a6428e160b2937488344b6b56
commit 47b8a421b000fa2a6428e160b2937488344b6b56
Merge: 27cbbf0 e1f0518
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 16 14:24:27 2018 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jan 16 09:25:00 2018 -0500
Merge topic 'gnu-visibility-aix'
e1f0518d GNU: Use -fvisibility on AIX when supported
eae0a85d Tests: Remove redundant code from RunCMake.GenerateExportHeader case
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1659
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=506fda1cf026a88378589009b62ca8bf633c5197
commit 506fda1cf026a88378589009b62ca8bf633c5197
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jan 11 14:32:13 2018 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 12 14:27:37 2018 -0500
Genex: Enable COMPILE_LANGUAGE for INCLUDE_DIRECTORIES with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based
on the linker language. By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags. Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`INCLUDE_DIRECTORIES` to match the selected language.
This is not exactly the same as for other generators, but is the best VS
and Xcode can do. It is also sufficient for many use cases since the
set of include directories for C and C++ is frequently similar but may
be distinct from those for other languages like CUDA.
Fixes: #17435
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index 85130a0..0f6d4cf 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -97,27 +97,32 @@ Available logical expressions are:
compile features and a list of supported compilers.
``$<COMPILE_LANGUAGE:lang>``
``1`` when the language used for compilation unit matches ``lang``,
- otherwise ``0``. This expression may be used to specify compile options
- and compile definitions for source files of a
+ otherwise ``0``. This expression may be used to specify compile options,
+ compile definitions, and include directories for source files of a
particular language in a target. For example:
.. code-block:: cmake
- add_executable(myapp main.cpp foo.c bar.cpp)
+ add_executable(myapp main.cpp foo.c bar.cpp zot.cu)
target_compile_options(myapp
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
)
target_compile_definitions(myapp
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX>
+ $<$<COMPILE_LANGUAGE:CUDA>:COMPILING_CUDA>
+ )
+ target_include_directories(myapp
+ PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/opt/foo/cxx_headers>
)
- This specifies the use of the ``-fno-exceptions`` compile option
- and ``COMPILING_CXX`` compile definition for C++ only
- (compiler id checks elided).
+ This specifies the use of the ``-fno-exceptions`` compile option,
+ ``COMPILING_CXX`` compile definition, and ``cxx_headers`` include
+ directory for C++ only (compiler id checks elided). It also specifies
+ a ``COMPILING_CUDA`` compile definition for CUDA.
Note that with :ref:`Visual Studio Generators` and :generator:`Xcode` there
- is no way to represent target-wide compile definitions separately for
- ``C`` and ``CXX`` languages.
+ is no way to represent target-wide compile definitions or include directories
+ separately for ``C`` and ``CXX`` languages.
Also, with :ref:`Visual Studio Generators` there is no way to represent
target-wide flags separately for ``C`` and ``CXX`` languages. Under these
generators, expressions for both C and C++ sources will be evaluated
@@ -133,16 +138,6 @@ Available logical expressions are:
add_executable(myapp main.cpp)
target_link_libraries(myapp myapp_c myapp_cxx)
- The ``Makefile`` and ``Ninja`` based generators can also use this
- expression to specify compile-language specific include directories:
-
- .. code-block:: cmake
-
- add_executable(myapp main.cpp foo.c bar.cpp)
- target_include_directories(myapp
- PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/opt/foo/cxx_headers>
- )
-
Informational Expressions
=========================
diff --git a/Help/release/dev/extend-compile-language-genex.rst b/Help/release/dev/extend-compile-language-genex.rst
index c95c606..7c09376 100644
--- a/Help/release/dev/extend-compile-language-genex.rst
+++ b/Help/release/dev/extend-compile-language-genex.rst
@@ -4,10 +4,11 @@ extend-compile-language-genex
* :ref:`Visual Studio Generators` learned to support the ``COMPILE_LANGUAGE``
:manual:`generator expression <cmake-generator-expressions(7)>` in
target-wide :prop_tgt:`COMPILE_DEFINITIONS`,
- :prop_tgt:`COMPILE_OPTIONS`, and :command:`file(GENERATE)`.
+ :prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_OPTIONS`, and
+ :command:`file(GENERATE)`.
* The :generator:`Xcode` generator learned to support the ``COMPILE_LANGUAGE``
:manual:`generator expression <cmake-generator-expressions(7)>` in
- target-wide :prop_tgt:`COMPILE_DEFINITIONS`.
- It previously supported only :prop_tgt:`COMPILE_OPTIONS` and
- :command:`file(GENERATE)`.
+ target-wide :prop_tgt:`COMPILE_DEFINITIONS` and
+ :prop_tgt:`INCLUDE_DIRECTORIES`. It previously supported only
+ :prop_tgt:`COMPILE_OPTIONS` and :command:`file(GENERATE)`.
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 597112a..34ef45f 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -805,7 +805,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const override
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
if (context->Language.empty()) {
reportError(
@@ -827,33 +827,14 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
return std::string();
}
std::string genName = gg->GetName();
- if (genName.find("Visual Studio") != std::string::npos) {
- if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, "
- "COMPILE_DEFINITIONS, "
- "and file(GENERATE) with the Visual Studio generator.");
- return std::string();
- }
- } else if (genName.find("Xcode") != std::string::npos) {
- if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, "
- "COMPILE_DEFINITIONS, "
- "and file(GENERATE) with the Xcode generator.");
- return std::string();
- }
- } else {
- if (genName.find("Makefiles") == std::string::npos &&
- genName.find("Ninja") == std::string::npos &&
- genName.find("Watcom WMake") == std::string::npos) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> not supported for this generator.");
- return std::string();
- }
+ if (genName.find("Makefiles") == std::string::npos &&
+ genName.find("Ninja") == std::string::npos &&
+ genName.find("Visual Studio") == std::string::npos &&
+ genName.find("Xcode") == std::string::npos &&
+ genName.find("Watcom WMake") == std::string::npos) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<COMPILE_LANGUAGE:...> not supported for this generator.");
+ return std::string();
}
if (parameters.empty()) {
return context->Language;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d22356e..bd51f60 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2000,8 +2000,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
const bool emitSystemIncludes = this->XcodeVersion >= 83;
std::vector<std::string> includes;
- this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C",
- configName);
+ if (!langForPreprocessor.empty()) {
+ this->CurrentLocalGenerator->GetIncludeDirectories(
+ includes, gtgt, langForPreprocessor, configName);
+ }
std::set<std::string> emitted;
emitted.insert("/System/Library/Frameworks");
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 003163e..59c20a9 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -796,10 +796,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
<< "\\$(ConfigurationName)\"\n";
}
fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
- std::vector<std::string> includes;
- this->GetIncludeDirectories(includes, target, "C", configName);
- std::vector<std::string>::iterator i = includes.begin();
- for (; i != includes.end(); ++i) {
+ std::vector<std::string> includes_cl;
+ if (!langForClCompile.empty()) {
+ this->GetIncludeDirectories(includes_cl, target, langForClCompile,
+ configName);
+ }
+ std::vector<std::string>::iterator i = includes_cl.begin();
+ for (; i != includes_cl.end(); ++i) {
// output the include path
std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
fout << ipath << ";";
@@ -834,9 +837,12 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
"\t\t\t\tName=\"MASM\"\n"
"\t\t\t\tIncludePaths=\""
;
+ std::vector<std::string> includes_masm;
+ this->GetIncludeDirectories(includes_masm, target, "ASM_MASM",
+ configName);
/* clang-format on */
const char* sep = "";
- for (i = includes.begin(); i != includes.end(); ++i) {
+ for (i = includes_masm.begin(); i != includes_masm.end(); ++i) {
std::string inc = *i;
cmConvertToWindowsSlash(inc);
fout << sep << this->EscapeForXML(inc);
@@ -864,7 +870,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
}
fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"
<< "\t\t\t\tAdditionalIncludeDirectories=\"";
- for (i = includes.begin(); i != includes.end(); ++i) {
+ std::vector<std::string> includes_rc;
+ this->GetIncludeDirectories(includes_rc, target, "RC", configName);
+ for (i = includes_rc.begin(); i != includes_rc.end(); ++i) {
std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
fout << ipath << ";";
}
@@ -878,7 +886,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
}
fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
- for (i = includes.begin(); i != includes.end(); ++i) {
+ std::vector<std::string> includes_midl;
+ this->GetIncludeDirectories(includes_midl, target, "MIDL", configName);
+ for (i = includes_midl.begin(); i != includes_midl.end(); ++i) {
std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
fout << ipath << ";";
}
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 5533652..6d7dd41 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2502,7 +2502,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
void cmVisualStudio10TargetGenerator::WriteClOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ std::string const& configName)
{
Options& clOptions = *(this->ClOptions[configName]);
if (this->ProjectType == csproj) {
@@ -2510,7 +2510,11 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
}
this->WriteString("<ClCompile>\n", 2);
clOptions.PrependInheritedString("AdditionalOptions");
- clOptions.AppendFlag("AdditionalIncludeDirectories", includes);
+ if (!this->LangForClCompile.empty()) {
+ std::vector<std::string> const includes =
+ this->GetIncludes(configName, this->LangForClCompile);
+ clOptions.AppendFlag("AdditionalIncludeDirectories", includes);
+ }
clOptions.AppendFlag("AdditionalIncludeDirectories",
"%(AdditionalIncludeDirectories)");
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
@@ -2596,7 +2600,7 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
}
void cmVisualStudio10TargetGenerator::WriteRCOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ std::string const& configName)
{
if (!this->MSTools) {
return;
@@ -2606,6 +2610,8 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions(
Options& rcOptions = *(this->RcOptions[configName]);
rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "RC");
+ std::vector<std::string> const includes =
+ this->GetIncludes(configName, "RC");
rcOptions.AppendFlag("AdditionalIncludeDirectories", includes);
rcOptions.AppendFlag("AdditionalIncludeDirectories",
"%(AdditionalIncludeDirectories)");
@@ -2710,7 +2716,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
}
void cmVisualStudio10TargetGenerator::WriteCudaOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ std::string const& configName)
{
if (!this->MSTools || !this->GlobalGenerator->IsCudaEnabled()) {
return;
@@ -2718,6 +2724,8 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions(
this->WriteString("<CudaCompile>\n", 2);
Options& cudaOptions = *(this->CudaOptions[configName]);
+ std::vector<std::string> const includes =
+ this->GetIncludes(configName, "CUDA");
cudaOptions.AppendFlag("Include", includes);
cudaOptions.AppendFlag("Include", "%(Include)");
cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
@@ -2832,7 +2840,7 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
}
void cmVisualStudio10TargetGenerator::WriteMasmOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ std::string const& configName)
{
if (!this->MSTools || !this->GlobalGenerator->IsMasmEnabled()) {
return;
@@ -2845,6 +2853,8 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions(
"\n", "ASM_MASM");
Options& masmOptions = *(this->MasmOptions[configName]);
+ std::vector<std::string> const includes =
+ this->GetIncludes(configName, "ASM_MASM");
masmOptions.AppendFlag("IncludePaths", includes);
masmOptions.AppendFlag("IncludePaths", "%(IncludePaths)");
masmOptions.PrependInheritedString("AdditionalOptions");
@@ -2889,13 +2899,15 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
}
void cmVisualStudio10TargetGenerator::WriteNasmOptions(
- std::string const& configName, std::vector<std::string> includes)
+ std::string const& configName)
{
if (!this->GlobalGenerator->IsNasmEnabled()) {
return;
}
this->WriteString("<NASM>\n", 2);
+ std::vector<std::string> includes =
+ this->GetIncludes(configName, "ASM_NASM");
Options& nasmOptions = *(this->NasmOptions[configName]);
for (size_t i = 0; i < includes.size(); i++) {
includes[i] += "\\";
@@ -3443,7 +3455,7 @@ void cmVisualStudio10TargetGenerator::AddTargetsFileAndConfigPair(
}
void cmVisualStudio10TargetGenerator::WriteMidlOptions(
- std::string const& /*config*/, std::vector<std::string> const& includes)
+ std::string const& configName)
{
if (!this->MSTools) {
return;
@@ -3469,6 +3481,8 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions(
// on the CMake side?
this->WriteString("<Midl>\n", 2);
this->WriteString("<AdditionalIncludeDirectories>", 3);
+ std::vector<std::string> const includes =
+ this->GetIncludes(configName, "MIDL");
for (std::string const& i : includes) {
*this->BuildFileStream << cmVS10EscapeXML(i) << ";";
}
@@ -3493,20 +3507,19 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
return;
}
for (std::string const& i : this->Configurations) {
- std::vector<std::string> const includes = this->GetIncludes(i, "C");
this->WritePlatformConfigTag("ItemDefinitionGroup", i, 1);
*this->BuildFileStream << "\n";
// output cl compile flags <ClCompile></ClCompile>
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
- this->WriteClOptions(i, includes);
+ this->WriteClOptions(i);
// output rc compile flags <ResourceCompile></ResourceCompile>
- this->WriteRCOptions(i, includes);
- this->WriteCudaOptions(i, includes);
- this->WriteMasmOptions(i, includes);
- this->WriteNasmOptions(i, includes);
+ this->WriteRCOptions(i);
+ this->WriteCudaOptions(i);
+ this->WriteMasmOptions(i);
+ this->WriteNasmOptions(i);
}
// output midl flags <Midl></Midl>
- this->WriteMidlOptions(i, includes);
+ this->WriteMidlOptions(i);
// write events
if (this->ProjectType != csproj) {
this->WriteEvents(i);
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index b1a09eb..c346164 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -95,16 +95,13 @@ private:
bool ComputeClOptions();
bool ComputeClOptions(std::string const& configName);
- void WriteClOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteClOptions(std::string const& config);
bool ComputeRcOptions();
bool ComputeRcOptions(std::string const& config);
- void WriteRCOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteRCOptions(std::string const& config);
bool ComputeCudaOptions();
bool ComputeCudaOptions(std::string const& config);
- void WriteCudaOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteCudaOptions(std::string const& config);
bool ComputeCudaLinkOptions();
bool ComputeCudaLinkOptions(std::string const& config);
@@ -112,20 +109,17 @@ private:
bool ComputeMasmOptions();
bool ComputeMasmOptions(std::string const& config);
- void WriteMasmOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteMasmOptions(std::string const& config);
bool ComputeNasmOptions();
bool ComputeNasmOptions(std::string const& config);
- void WriteNasmOptions(std::string const& config,
- std::vector<std::string> includes);
+ void WriteNasmOptions(std::string const& config);
bool ComputeLinkOptions();
bool ComputeLinkOptions(std::string const& config);
bool ComputeLibOptions();
bool ComputeLibOptions(std::string const& config);
void WriteLinkOptions(std::string const& config);
- void WriteMidlOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteMidlOptions(std::string const& config);
void WriteAntBuildOptions(std::string const& config);
void OutputLinkIncremental(std::string const& configName);
void WriteCustomRule(cmSourceFile const* source,
diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
index d57556a..8713d99 100644
--- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
@@ -42,17 +42,17 @@ add_executable(consumer
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
)
-if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja")
- target_sources(consumer PRIVATE
- "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
- )
- target_include_directories(consumer
- PRIVATE
- $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only>
- $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only>
- )
+target_sources(consumer PRIVATE
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
+)
+target_include_directories(consumer
+ PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only>
+ $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only>
+)
+if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
target_compile_definitions(consumer
- PRIVATE -DTEST_LANG_DEFINES
+ PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
)
endif()
diff --git a/Tests/CMakeCommands/target_include_directories/consumer.c b/Tests/CMakeCommands/target_include_directories/consumer.c
index ae88f92..419c2d2 100644
--- a/Tests/CMakeCommands/target_include_directories/consumer.c
+++ b/Tests/CMakeCommands/target_include_directories/consumer.c
@@ -1,5 +1,13 @@
-#ifdef TEST_LANG_DEFINES
+// Visual Studio allows only one set of flags for C and C++.
+// In a target using C++ we pick the C++ flags even for C sources.
+#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
+#include "cxx_only.h"
+
+#ifndef CXX_ONLY_DEFINE
+#error Expected CXX_ONLY_DEFINE
+#endif
+#else
#include "c_only.h"
#ifndef C_ONLY_DEFINE
diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp
index 0f8153b..1e018ad 100644
--- a/Tests/CMakeCommands/target_include_directories/consumer.cpp
+++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp
@@ -1,12 +1,10 @@
#include "consumer.h"
#include "common.h"
+#include "cxx_only.h"
#include "interfaceinclude.h"
#include "publicinclude.h"
#include "relative_dir.h"
-#ifdef TEST_LANG_DEFINES
-#include "cxx_only.h"
-#endif
#ifdef PRIVATEINCLUDE_DEFINE
#error Unexpected PRIVATEINCLUDE_DEFINE
@@ -32,11 +30,9 @@
#error Expected CONSUMER_DEFINE
#endif
-#ifdef TEST_LANG_DEFINES
#ifndef CXX_ONLY_DEFINE
#error Expected CXX_ONLY_DEFINE
#endif
-#endif
int main()
{
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index 1a5599b..ffe4859 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -45,6 +45,11 @@ target_compile_definitions(CudaOnlyWithDefs
-DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
)
+target_include_directories(CudaOnlyWithDefs
+ PRIVATE
+ $<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CURRENT_SOURCE_DIR}/inc_cuda>
+)
+
if(APPLE)
# Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
diff --git a/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h
new file mode 100644
index 0000000..e228b58
--- /dev/null
+++ b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h
@@ -0,0 +1 @@
+#define INC_CUDA
diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu
index 426eb62..3793d74 100644
--- a/Tests/CudaOnly/WithDefs/main.notcu
+++ b/Tests/CudaOnly/WithDefs/main.notcu
@@ -2,6 +2,11 @@
#include <cuda_runtime.h>
#include <iostream>
+#include <inc_cuda.h>
+#ifndef INC_CUDA
+#error "INC_CUDA not defined!"
+#endif
+
#ifndef HOST_DEFINE
#error "HOST_DEFINE not defined!"
#endif
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 8eb8568..edd6c79 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -351,8 +351,6 @@ add_RunCMake_test(IfacePaths_INCLUDE_DIRECTORIES TEST_DIR IfacePaths)
set(IfacePaths_SOURCES_ARGS -DTEST_PROP=SOURCES)
add_RunCMake_test(IfacePaths_SOURCES TEST_DIR IfacePaths)
-add_RunCMake_test(COMPILE_LANGUAGE-genex)
-
# Matlab module related tests
if(CMake_TEST_FindMatlab)
add_RunCMake_test(FindMatlab)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt
deleted file mode 100644
index ef2163c..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-cmake_minimum_required(VERSION 3.1)
-project(${RunCMake_TEST} NONE)
-include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
deleted file mode 100644
index 0e13c48..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS,
- COMPILE_DEFINITIONS, and file\(GENERATE\) with the Visual Studio generator.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
deleted file mode 100644
index 3f86dd4..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS,
- COMPILE_DEFINITIONS, and file\(GENERATE\) with the Xcode generator.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake
deleted file mode 100644
index 31771f6..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-target_include_directories(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:anydir>)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
deleted file mode 100644
index 9ed1b67..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-include(RunCMake)
-
-if (RunCMake_GENERATOR STREQUAL "Xcode")
- set(RunCMake-stderr-file IncludeDirectories-stderr-Xcode.txt)
- run_cmake(IncludeDirectories)
-elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
- set(RunCMake-stderr-file IncludeDirectories-stderr-VS.txt)
- run_cmake(IncludeDirectories)
-endif()
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp b/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp
deleted file mode 100644
index 766b775..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int main()
-{
- return 0;
-}
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2f79c98677d43fb8686f9e4309acddfae8f3dfd
commit c2f79c98677d43fb8686f9e4309acddfae8f3dfd
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jan 11 11:23:06 2018 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 12 14:27:37 2018 -0500
Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based
on the linker language. By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags. Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`COMPILE_DEFINITIONS` to match the selected language.
This is not exactly the same as for other generators, but is the best VS
and Xcode can do. It is also sufficient for many use cases since the
set of definitions for C and C++ is frequently similar but may be
distinct from those for other languages like CUDA.
Issue: #17435
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index dc5621a..85130a0 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -97,10 +97,9 @@ Available logical expressions are:
compile features and a list of supported compilers.
``$<COMPILE_LANGUAGE:lang>``
``1`` when the language used for compilation unit matches ``lang``,
- otherwise ``0``. This expression may be used to specify compile options for
- source files of a particular language in a target. For example, to specify
- the use of the ``-fno-exceptions`` compile option (compiler id checks
- elided):
+ otherwise ``0``. This expression may be used to specify compile options
+ and compile definitions for source files of a
+ particular language in a target. For example:
.. code-block:: cmake
@@ -108,10 +107,20 @@ Available logical expressions are:
target_compile_options(myapp
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
)
+ target_compile_definitions(myapp
+ PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX>
+ )
+
+ This specifies the use of the ``-fno-exceptions`` compile option
+ and ``COMPILING_CXX`` compile definition for C++ only
+ (compiler id checks elided).
- Note that with :ref:`Visual Studio Generators` there is no way to represent
+ Note that with :ref:`Visual Studio Generators` and :generator:`Xcode` there
+ is no way to represent target-wide compile definitions separately for
+ ``C`` and ``CXX`` languages.
+ Also, with :ref:`Visual Studio Generators` there is no way to represent
target-wide flags separately for ``C`` and ``CXX`` languages. Under these
- generators, target-wide flags for both C and C++ sources will be evaluated
+ generators, expressions for both C and C++ sources will be evaluated
using ``CXX`` if there are any C++ sources and otherwise using ``C``.
A workaround is to create separate libraries for each source file language
instead:
@@ -125,15 +134,11 @@ Available logical expressions are:
target_link_libraries(myapp myapp_c myapp_cxx)
The ``Makefile`` and ``Ninja`` based generators can also use this
- expression to specify compile-language specific compile definitions
- and include directories:
+ expression to specify compile-language specific include directories:
.. code-block:: cmake
add_executable(myapp main.cpp foo.c bar.cpp)
- target_compile_definitions(myapp
- PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX>
- )
target_include_directories(myapp
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/opt/foo/cxx_headers>
)
diff --git a/Help/release/dev/extend-compile-language-genex.rst b/Help/release/dev/extend-compile-language-genex.rst
index 0a0a669..c95c606 100644
--- a/Help/release/dev/extend-compile-language-genex.rst
+++ b/Help/release/dev/extend-compile-language-genex.rst
@@ -1,7 +1,13 @@
extend-compile-language-genex
-----------------------------
-* The ``COMPILE_LANGUAGE`` :manual:`generator expression
- <cmake-generator-expressions(7)>` may now be used with
- :ref:`Visual Studio Generators` in :prop_tgt:`COMPILE_OPTIONS`
- and :command:`file(GENERATE)`.
+* :ref:`Visual Studio Generators` learned to support the ``COMPILE_LANGUAGE``
+ :manual:`generator expression <cmake-generator-expressions(7)>` in
+ target-wide :prop_tgt:`COMPILE_DEFINITIONS`,
+ :prop_tgt:`COMPILE_OPTIONS`, and :command:`file(GENERATE)`.
+
+* The :generator:`Xcode` generator learned to support the ``COMPILE_LANGUAGE``
+ :manual:`generator expression <cmake-generator-expressions(7)>` in
+ target-wide :prop_tgt:`COMPILE_DEFINITIONS`.
+ It previously supported only :prop_tgt:`COMPILE_OPTIONS` and
+ :command:`file(GENERATE)`.
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 3d311d6..597112a 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -828,20 +828,20 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
}
std::string genName = gg->GetName();
if (genName.find("Visual Studio") != std::string::npos) {
- if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
- dagChecker->EvaluatingIncludeDirectories())) {
+ if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
reportError(
context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS "
+ "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, "
+ "COMPILE_DEFINITIONS, "
"and file(GENERATE) with the Visual Studio generator.");
return std::string();
}
} else if (genName.find("Xcode") != std::string::npos) {
- if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
- dagChecker->EvaluatingIncludeDirectories())) {
+ if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
reportError(
context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS "
+ "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, "
+ "COMPILE_DEFINITIONS, "
"and file(GENERATE) with the Xcode generator.");
return std::string();
}
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 338c2b4..d22356e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1703,6 +1703,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
gtgt->GetName().c_str());
return;
}
+ std::string const& langForPreprocessor = llang;
if (gtgt->IsIPOEnabled(llang, configName)) {
const char* ltoValue =
@@ -1723,7 +1724,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->AppendDefines(ppDefs, exportMacro);
}
std::vector<std::string> targetDefines;
- gtgt->GetCompileDefinitions(targetDefines, configName, "C");
+ if (!langForPreprocessor.empty()) {
+ gtgt->GetCompileDefinitions(targetDefines, configName,
+ langForPreprocessor);
+ }
this->AppendDefines(ppDefs, targetDefines);
buildSettings->AddAttribute("GCC_PREPROCESSOR_DEFINITIONS",
ppDefs.CreateList());
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 4cc6e3c..003163e 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -705,7 +705,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
targetOptions.Parse(defineFlags.c_str());
targetOptions.ParseFinish();
std::vector<std::string> targetDefines;
- target->GetCompileDefinitions(targetDefines, configName, "CXX");
+ if (!langForClCompile.empty()) {
+ target->GetCompileDefinitions(targetDefines, configName, langForClCompile);
+ }
targetOptions.AddDefines(targetDefines);
targetOptions.SetVerboseMakefile(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
@@ -812,7 +814,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
}
fout << "\"\n";
targetOptions.OutputFlagMap(fout, "\t\t\t\t");
- targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
+ targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n",
+ langForClCompile);
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
// Specify the compiler program database file if configured.
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 7074624..5533652 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2391,6 +2391,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
}
}
+ this->LangForClCompile = langForClCompile;
if (!langForClCompile.empty()) {
std::string baseFlagVar = "CMAKE_";
baseFlagVar += langForClCompile;
@@ -2434,8 +2435,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
std::vector<std::string> targetDefines;
switch (this->ProjectType) {
case vcxproj:
- this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
- "CXX");
+ if (!langForClCompile.empty()) {
+ this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
+ langForClCompile);
+ }
break;
case csproj:
this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
@@ -2512,7 +2515,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
"%(AdditionalIncludeDirectories)");
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "CXX");
+ "\n", this->LangForClCompile);
if (this->NsightTegra) {
if (const char* processMax =
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 3f56959..b1a09eb 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -183,6 +183,7 @@ private:
OptionsMap MasmOptions;
OptionsMap NasmOptions;
OptionsMap LinkOptions;
+ std::string LangForClCompile;
std::string PathToProjectFile;
std::string ProjectFileExtension;
enum VsProjectType
diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
index f96283d..7dc7995 100644
--- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
@@ -26,18 +26,18 @@ target_compile_definitions(consumer
PRIVATE
)
-if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja")
- target_sources(consumer PRIVATE
- "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
- )
- target_compile_definitions(consumer
- PRIVATE
- CONSUMER_LANG_$<COMPILE_LANGUAGE>
- LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
- LANG_IS_C=$<COMPILE_LANGUAGE:C>
- )
+target_sources(consumer PRIVATE
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
+)
+target_compile_definitions(consumer
+ PRIVATE
+ CONSUMER_LANG_$<COMPILE_LANGUAGE>
+ LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
+ LANG_IS_C=$<COMPILE_LANGUAGE:C>
+)
+if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
target_compile_definitions(consumer
- PRIVATE -DTEST_LANG_DEFINES
+ PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
)
endif()
diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.c b/Tests/CMakeCommands/target_compile_definitions/consumer.c
index 7931a6f..e134a8b 100644
--- a/Tests/CMakeCommands/target_compile_definitions/consumer.c
+++ b/Tests/CMakeCommands/target_compile_definitions/consumer.c
@@ -1,5 +1,23 @@
-#ifdef TEST_LANG_DEFINES
+// Visual Studio allows only one set of flags for C and C++.
+// In a target using C++ we pick the C++ flags even for C sources.
+#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
+#ifndef CONSUMER_LANG_CXX
+#error Expected CONSUMER_LANG_CXX
+#endif
+
+#ifdef CONSUMER_LANG_C
+#error Unexpected CONSUMER_LANG_C
+#endif
+
+#if !LANG_IS_CXX
+#error Expected LANG_IS_CXX
+#endif
+
+#if LANG_IS_C
+#error Unexpected LANG_IS_C
+#endif
+#else
#ifdef CONSUMER_LANG_CXX
#error Unexpected CONSUMER_LANG_CXX
#endif
diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
index 0202c17..69ea151 100644
--- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
+++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
@@ -15,7 +15,6 @@
#error Expected DASH_D_DEFINE
#endif
-#ifdef TEST_LANG_DEFINES
#ifndef CONSUMER_LANG_CXX
#error Expected CONSUMER_LANG_CXX
#endif
@@ -31,7 +30,6 @@
#if LANG_IS_C
#error Unexpected LANG_IS_C
#endif
-#endif
int main()
{
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index 5bd93a4..1a5599b 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -32,8 +32,8 @@ add_executable(CudaOnlyWithDefs ${main})
target_compile_options(CudaOnlyWithDefs
PRIVATE
- -DCOMPILE_LANG_$<COMPILE_LANGUAGE>
- -DLANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
+ -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
+ -DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
-Xcompiler=-DHOST_DEFINE
$<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>>
)
@@ -41,6 +41,8 @@ target_compile_options(CudaOnlyWithDefs
target_compile_definitions(CudaOnlyWithDefs
PRIVATE
$<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>>
+ -DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE>
+ -DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
)
if(APPLE)
diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu
index bfb3577..426eb62 100644
--- a/Tests/CudaOnly/WithDefs/main.notcu
+++ b/Tests/CudaOnly/WithDefs/main.notcu
@@ -10,16 +10,28 @@
#error "PACKED_DEFINE not defined!"
#endif
-#ifndef COMPILE_LANG_CUDA
-#error "COMPILE_LANG_CUDA not defined!"
+#ifndef FLAG_COMPILE_LANG_CUDA
+#error "FLAG_COMPILE_LANG_CUDA not defined!"
#endif
-#ifndef LANG_IS_CUDA
-#error "LANG_IS_CUDA not defined!"
+#ifndef FLAG_LANG_IS_CUDA
+#error "FLAG_LANG_IS_CUDA not defined!"
#endif
-#if !LANG_IS_CUDA
-#error "Expected LANG_IS_CUDA"
+#if !FLAG_LANG_IS_CUDA
+#error "Expected FLAG_LANG_IS_CUDA"
+#endif
+
+#ifndef DEF_COMPILE_LANG_CUDA
+#error "DEF_COMPILE_LANG_CUDA not defined!"
+#endif
+
+#ifndef DEF_LANG_IS_CUDA
+#error "DEF_LANG_IS_CUDA not defined!"
+#endif
+
+#if !DEF_LANG_IS_CUDA
+#error "Expected DEF_LANG_IS_CUDA"
#endif
static __global__ void DetermineIfValidCudaDevice()
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 0585d0c..4586357 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -269,10 +269,8 @@ set_property(SOURCE srcgenex_flags_COMPILE_LANGUAGE.c PROPERTY COMPILE_FLAGS "$<
add_executable(srcgenex_defs srcgenex_defs.c)
set_property(SOURCE srcgenex_defs.c PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>)
-if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake")
- add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c)
- set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>)
-endif()
+add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c)
+set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>)
#-----------------------------------------------------------------------------
# Cover test properties with generator expressions.
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt
deleted file mode 100644
index 42c1485..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
- file\(GENERATE\) with the Visual Studio generator.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt
deleted file mode 100644
index 7879a79..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
- file\(GENERATE\) with the Xcode generator.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake
deleted file mode 100644
index 7935d88..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-target_compile_definitions(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-DANYTHING>)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
index 3806ed1..0e13c48 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
+++ b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
@@ -3,7 +3,7 @@ CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
\$<COMPILE_LANGUAGE:CXX>
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
- file\(GENERATE\) with the Visual Studio generator.
+ \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS,
+ COMPILE_DEFINITIONS, and file\(GENERATE\) with the Visual Studio generator.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
index a3fb9c5..3f86dd4 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
+++ b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
@@ -3,7 +3,7 @@ CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
\$<COMPILE_LANGUAGE:CXX>
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
- file\(GENERATE\) with the Xcode generator.
+ \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS,
+ COMPILE_DEFINITIONS, and file\(GENERATE\) with the Xcode generator.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt
deleted file mode 100644
index 5d19153..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
- file\(GENERATE\) with the Visual Studio generator.
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt
deleted file mode 100644
index 4a4564e..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
- file\(GENERATE\) with the Xcode generator.
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake
deleted file mode 100644
index 3a07d7d..0000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-set_property(SOURCE main.cpp PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:CXX>:ANYTHING>)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
index 1a93dcd..9ed1b67 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
+++ b/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
@@ -1,23 +1,9 @@
include(RunCMake)
if (RunCMake_GENERATOR STREQUAL "Xcode")
- set(RunCMake-stderr-file CompileDefinitions-stderr-Xcode.txt)
- run_cmake(CompileDefinitions)
-elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
- set(RunCMake-stderr-file CompileDefinitions-stderr-VS.txt)
- run_cmake(CompileDefinitions)
-endif()
-if (RunCMake_GENERATOR STREQUAL "Xcode")
set(RunCMake-stderr-file IncludeDirectories-stderr-Xcode.txt)
run_cmake(IncludeDirectories)
elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
set(RunCMake-stderr-file IncludeDirectories-stderr-VS.txt)
run_cmake(IncludeDirectories)
endif()
-if (RunCMake_GENERATOR STREQUAL "Xcode")
- set(RunCMake-stderr-file PerSourceCompileDefinitions-stderr-Xcode.txt)
- run_cmake(PerSourceCompileDefinitions)
-elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
- set(RunCMake-stderr-file PerSourceCompileDefinitions-stderr-VS.txt)
- run_cmake(PerSourceCompileDefinitions)
-endif()
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e1f0518de09a54065459a728993563d84fb85a6a
commit e1f0518de09a54065459a728993563d84fb85a6a
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Jan 12 11:25:19 2018 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 12 11:50:10 2018 -0500
GNU: Use -fvisibility on AIX when supported
Revise the logic from commit v3.7.0-rc1~173^2~2 (GNU: Do not use
-fvisibility on AIX or HP-UX, 2016-09-03) to add a version check.
The GCC 7 release notes [1] state that visibility support has been
added for AIX 7.1 and above.
[1] https://gcc.gnu.org/gcc-7/changes.html
diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake
index 7f08c4a..0abbb61 100644
--- a/Modules/Platform/AIX-GNU.cmake
+++ b/Modules/Platform/AIX-GNU.cmake
@@ -24,5 +24,7 @@ macro(__aix_compiler_gnu lang)
set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1)
set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
- unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY)
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 7 OR CMAKE_SYSTEM_VERSION VERSION_LESS 7.1)
+ unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY)
+ endif()
endmacro()
diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
index cfca8fe..cf81f36 100644
--- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake
+++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
@@ -53,7 +53,16 @@ endif()
add_subdirectory(lib_shared_and_static)
-add_compiler_export_flags()
+if(CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
+ AND CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY)
+ # With GNU 7 on AIX, passing -fvisibility=hidden when driving the
+ # linker for a shared library drops the so init/destruct symbols.
+ # Just use the modern approach instead of testing the macro.
+ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+else()
+ add_compiler_export_flags()
+endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR})
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eae0a85d84fe12f058f8542aa4d05cfdf5c61cb1
commit eae0a85d84fe12f058f8542aa4d05cfdf5c61cb1
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Jan 12 11:01:37 2018 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 12 11:01:37 2018 -0500
Tests: Remove redundant code from RunCMake.GenerateExportHeader case
Drop extra `add_compiler_export_flags` calls from subdirectories because
it is already called in the top-level directory before entering them.
diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt
index c4a761c..9516a5a 100644
--- a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt
+++ b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt
@@ -1,7 +1,5 @@
include(GenerateExportHeader)
-add_compiler_export_flags()
-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_library(libshared SHARED libshared.cpp)
diff --git a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt
index 0fd136c..56e8335 100644
--- a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt
+++ b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt
@@ -2,8 +2,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(GenerateExportHeader)
-add_compiler_export_flags()
-
# Show that the export header has no effect on a static library.
add_library(libstatic STATIC libstatic.cpp)
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0795d25b78d5b7682aea091d260eaf1bca7afd0a
commit 0795d25b78d5b7682aea091d260eaf1bca7afd0a
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jan 11 14:46:38 2018 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Jan 11 15:03:02 2018 -0500
cmVisualStudio10TargetGenerator: Factor out include dir computation
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index f997a11..7074624 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2319,6 +2319,18 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
}
}
+std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes(
+ std::string const& config, std::string const& lang) const
+{
+ std::vector<std::string> includes;
+ this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
+ lang, config);
+ for (std::string& i : includes) {
+ this->ConvertToWindowsSlash(i);
+ }
+ return includes;
+}
+
bool cmVisualStudio10TargetGenerator::ComputeClOptions()
{
for (std::string const& i : this->Configurations) {
@@ -3478,12 +3490,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
return;
}
for (std::string const& i : this->Configurations) {
- std::vector<std::string> includes;
- this->LocalGenerator->GetIncludeDirectories(includes,
- this->GeneratorTarget, "C", i);
- for (std::string& ii : includes) {
- this->ConvertToWindowsSlash(ii);
- }
+ std::vector<std::string> const includes = this->GetIncludes(i, "C");
this->WritePlatformConfigTag("ItemDefinitionGroup", i, 1);
*this->BuildFileStream << "\n";
// output cl compile flags <ClCompile></ClCompile>
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index fb24f1a..3f56959 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -90,6 +90,9 @@ private:
void WriteTargetSpecificReferences();
void WriteTargetsFileReferences();
+ std::vector<std::string> GetIncludes(std::string const& config,
+ std::string const& lang) const;
+
bool ComputeClOptions();
bool ComputeClOptions(std::string const& configName);
void WriteClOptions(std::string const& config,
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ab4d186a7d5a3481d2f0978aaebd6bf0bc7f891
commit 1ab4d186a7d5a3481d2f0978aaebd6bf0bc7f891
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jan 11 10:55:20 2018 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Jan 11 10:55:20 2018 -0500
cmLocalVisualStudio7Generator: Clarify variable name of compiled language
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 7aae250..4cc6e3c 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -637,6 +637,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
configType = projectType;
}
std::string flags;
+ std::string langForClCompile;
if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
const std::string& linkLanguage =
(this->FortranProject ? std::string("Fortran")
@@ -647,10 +648,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
target->GetName().c_str());
return;
}
- if (linkLanguage == "C" || linkLanguage == "CXX" ||
- linkLanguage == "Fortran") {
+ langForClCompile = linkLanguage;
+ if (langForClCompile == "C" || langForClCompile == "CXX" ||
+ langForClCompile == "Fortran") {
std::string baseFlagVar = "CMAKE_";
- baseFlagVar += linkLanguage;
+ baseFlagVar += langForClCompile;
baseFlagVar += "_FLAGS";
flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str());
std::string flagVar =
@@ -667,7 +669,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
}
// Add the target-specific flags.
- this->AddCompileOptions(flags, target, linkLanguage, configName);
+ this->AddCompileOptions(flags, target, langForClCompile, configName);
// Check IPO related warning/error.
target->IsIPOEnabled(linkLanguage, configName);
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=07e1a74361b89c1080db1bca904dcd82e955777d
commit 07e1a74361b89c1080db1bca904dcd82e955777d
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Jan 11 10:54:06 2018 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Thu Jan 11 10:54:06 2018 -0500
cmLocalVisualStudio7Generator: Clarify condition for target that compiles
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index eccd4d0..7aae250 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -637,7 +637,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
configType = projectType;
}
std::string flags;
- if (strcmp(configType, "10") != 0) {
+ if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
const std::string& linkLanguage =
(this->FortranProject ? std::string("Fortran")
: target->GetLinkerLanguage(configName));
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f74c25802de11e4e4578b1c9473f99d106491da8
commit f74c25802de11e4e4578b1c9473f99d106491da8
Author: Don Hinton <hintonda at gmail.com>
AuthorDate: Sun Dec 24 11:30:24 2017 -0800
Commit: Brad King <brad.king at kitware.com>
CommitDate: Wed Jan 10 14:13:32 2018 -0500
CheckIncludeFiles: Honor CMAKE_REQUIRED_LIBRARIES
This is needed when cross compiling and the compiler requires a specific
linker different from the default, e.g., when cross compiling from
Darwin to Linux and passing `-fuse-ld=lld` to clang.
Fixes: #9514
diff --git a/Help/release/dev/CheckIncludeFile-required-libs.rst b/Help/release/dev/CheckIncludeFile-required-libs.rst
new file mode 100644
index 0000000..14c43d1
--- /dev/null
+++ b/Help/release/dev/CheckIncludeFile-required-libs.rst
@@ -0,0 +1,11 @@
+CheckIncludeFile-required-libs
+------------------------------
+
+* The :module:`CheckIncludeFile` module ``check_include_file`` macro
+ learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
+
+* The :module:`CheckIncludeFileCXX` module ``check_include_file_cxx`` macro
+ learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
+
+* The :module:`CheckIncludeFiles` module ``check_include_files`` macro
+ learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake
index e5554c4..501fc9a 100644
--- a/Modules/CheckIncludeFile.cmake
+++ b/Modules/CheckIncludeFile.cmake
@@ -27,6 +27,8 @@
# list of macros to define (-DFOO=bar)
# ``CMAKE_REQUIRED_INCLUDES``
# list of include directories
+# ``CMAKE_REQUIRED_LIBRARIES``
+# list of libraries to link
# ``CMAKE_REQUIRED_QUIET``
# execute quietly without messages
#
@@ -59,6 +61,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
"${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}"
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index 7948bab..cdb25fb 100644
--- a/Modules/CheckIncludeFileCXX.cmake
+++ b/Modules/CheckIncludeFileCXX.cmake
@@ -27,6 +27,8 @@
# list of macros to define (-DFOO=bar)
# ``CMAKE_REQUIRED_INCLUDES``
# list of include directories
+# ``CMAKE_REQUIRED_LIBRARIES``
+# list of libraries to link
# ``CMAKE_REQUIRED_QUIET``
# execute quietly without messages
#
@@ -58,6 +60,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
"${CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS}"
diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake
index 59afdab..14db68c 100644
--- a/Modules/CheckIncludeFiles.cmake
+++ b/Modules/CheckIncludeFiles.cmake
@@ -33,6 +33,8 @@
# list of macros to define (-DFOO=bar)
# ``CMAKE_REQUIRED_INCLUDES``
# list of include directories
+# ``CMAKE_REQUIRED_LIBRARIES``
+# list of libraries to link
# ``CMAKE_REQUIRED_QUIET``
# execute quietly without messages
#
@@ -102,6 +104,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
${CMAKE_BINARY_DIR}
${src}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILES_FLAGS}
"${CHECK_INCLUDE_FILES_INCLUDE_DIRS}"
-----------------------------------------------------------------------
Summary of changes:
Help/manual/cmake-generator-expressions.7.rst | 42 ++++++------
.../release/dev/CheckIncludeFile-required-libs.rst | 11 ++++
Help/release/dev/extend-compile-language-genex.rst | 15 +++--
Modules/CheckIncludeFile.cmake | 3 +
Modules/CheckIncludeFileCXX.cmake | 3 +
Modules/CheckIncludeFiles.cmake | 3 +
Modules/Platform/AIX-GNU.cmake | 4 +-
Source/cmGeneratorExpressionNode.cxx | 37 +++--------
Source/cmGlobalXCodeGenerator.cxx | 12 +++-
Source/cmLocalVisualStudio7Generator.cxx | 43 +++++++++----
Source/cmVisualStudio10TargetGenerator.cxx | 67 +++++++++++++-------
Source/cmVisualStudio10TargetGenerator.h | 22 +++----
.../target_compile_definitions/CMakeLists.txt | 22 +++----
.../target_compile_definitions/consumer.c | 20 +++++-
.../target_compile_definitions/consumer.cpp | 2 -
.../target_include_directories/CMakeLists.txt | 20 +++---
.../target_include_directories/consumer.c | 10 ++-
.../target_include_directories/consumer.cpp | 6 +-
Tests/CudaOnly/WithDefs/CMakeLists.txt | 11 +++-
Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h | 1 +
Tests/CudaOnly/WithDefs/main.notcu | 29 +++++++--
Tests/GeneratorExpression/CMakeLists.txt | 6 +-
Tests/RunCMake/CMakeLists.txt | 2 -
.../RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt | 3 -
.../CompileDefinitions-result.txt | 1 -
.../CompileDefinitions-stderr-VS.txt | 9 ---
.../CompileDefinitions-stderr-Xcode.txt | 9 ---
.../CompileDefinitions.cmake | 5 --
.../IncludeDirectories-result.txt | 1 -
.../IncludeDirectories-stderr-VS.txt | 9 ---
.../IncludeDirectories-stderr-Xcode.txt | 9 ---
.../IncludeDirectories.cmake | 5 --
.../PerSourceCompileDefinitions-result.txt | 1 -
.../PerSourceCompileDefinitions-stderr-VS.txt | 7 --
.../PerSourceCompileDefinitions-stderr-Xcode.txt | 7 --
.../PerSourceCompileDefinitions.cmake | 5 --
.../COMPILE_LANGUAGE-genex/RunCMakeTest.cmake | 23 -------
Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp | 5 --
Tests/RunCMake/GenerateExportHeader/GEH.cmake | 11 +++-
.../GenerateExportHeader/libshared/CMakeLists.txt | 2 -
.../GenerateExportHeader/libstatic/CMakeLists.txt | 2 -
41 files changed, 252 insertions(+), 253 deletions(-)
create mode 100644 Help/release/dev/CheckIncludeFile-required-libs.rst
create mode 100644 Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
delete mode 100644 Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list