summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmAddCompileOptionsCommand.h1
-rw-r--r--Source/cmDocumentGeneratorExpressions.h8
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx78
-rw-r--r--Source/cmMakefile.cxx3
-rw-r--r--Source/cmTarget.cxx25
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.h1
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.h1
-rw-r--r--Tests/CompileDefinitions/compiletest_mixed_c.c4
-rw-r--r--Tests/CompileDefinitions/compiletest_mixed_cxx.cpp4
-rw-r--r--Tests/CompileDefinitions/target_prop/CMakeLists.txt19
-rw-r--r--Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt12
-rw-r--r--Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt5
-rw-r--r--Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake2
13 files changed, 53 insertions, 110 deletions
diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h
index 4504795..e9bbf28 100644
--- a/Source/cmAddCompileOptionsCommand.h
+++ b/Source/cmAddCompileOptionsCommand.h
@@ -62,7 +62,6 @@ public:
"Arguments to add_compile_options may use \"generator "
"expressions\" with the syntax \"$<...>\". "
CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS
;
}
diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h
index 841061c..46cd77e 100644
--- a/Source/cmDocumentGeneratorExpressions.h
+++ b/Source/cmDocumentGeneratorExpressions.h
@@ -95,12 +95,4 @@
"the target on which the generator expression is evaluated.\n" \
""
-#define CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS \
- "Language related expressions:\n" \
- " $<LINK_LANGUAGE> = The link language of the target " \
- "being generated.\n" \
- " $<LINK_LANGUAGE:lang> = '1' if the link language of the " \
- "target being generated matches lang, else '0'.\n" \
- ""
-
#endif
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 381ef7c..c1f53b4 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -573,69 +573,6 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
}
} configurationTestNode;
-//----------------------------------------------------------------------------
-static const struct LinkLanguageNode : public cmGeneratorExpressionNode
-{
- LinkLanguageNode() {}
-
- virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
-
- std::string Evaluate(const std::vector<std::string> &parameters,
- cmGeneratorExpressionContext *context,
- const GeneratorExpressionContent *content,
- cmGeneratorExpressionDAGChecker *dagChecker) const
- {
- if (dagChecker && dagChecker->EvaluatingLinkLibraries())
- {
- reportError(context, content->GetOriginalExpression(),
- "$<LINK_LANGUAGE> expression can not be used while evaluating "
- "link libraries");
- return std::string();
- }
- if (parameters.size() != 0 && parameters.size() != 1)
- {
- reportError(context, content->GetOriginalExpression(),
- "$<LINK_LANGUAGE> expression requires one or two parameters");
- return std::string();
- }
- cmTarget* target = context->HeadTarget;
- if (!target)
- {
- reportError(context, content->GetOriginalExpression(),
- "$<LINK_LANGUAGE> may only be used with targets. It may not "
- "be used with add_custom_command.");
- return std::string();
- }
-
- const char *lang = target->GetLinkerLanguage(context->Config);
- if (parameters.size() == 0)
- {
- return lang ? lang : "";
- }
- else
- {
- cmsys::RegularExpression langValidator;
- langValidator.compile("^[A-Za-z0-9_]*$");
- if (!langValidator.find(parameters.begin()->c_str()))
- {
- reportError(context, content->GetOriginalExpression(),
- "Expression syntax not recognized.");
- return std::string();
- }
- if (!lang)
- {
- return parameters.front().empty() ? "1" : "0";
- }
-
- if (strcmp(parameters.begin()->c_str(), lang) == 0)
- {
- return "1";
- }
- return "0";
- }
- }
-} linkLanguageNode;
-
static const struct JoinNode : public cmGeneratorExpressionNode
{
JoinNode() {}
@@ -835,6 +772,19 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
assert(target);
+ if (propertyName == "LINKER_LANGUAGE")
+ {
+ if (dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries())
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "LINKER_LANGUAGE target property can not be used while evaluating "
+ "link libraries");
+ return std::string();
+ }
+ const char *lang = target->GetLinkerLanguage(context->Config);
+ return lang ? lang : "";
+ }
+
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
target->GetName(),
propertyName,
@@ -1380,8 +1330,6 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &configurationNode;
else if (identifier == "CONFIG")
return &configurationTestNode;
- else if (identifier == "LINK_LANGUAGE")
- return &linkLanguageNode;
else if (identifier == "TARGET_FILE")
return &targetFileNode;
else if (identifier == "TARGET_LINKER_FILE")
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 818a580..2cd19cf 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4087,8 +4087,7 @@ void cmMakefile::DefineProperties(cmake *cm)
"the options for the compiler.\n"
"Contents of COMPILE_OPTIONS may use \"generator expressions\" with "
"the syntax \"$<...>\". "
- CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
cm->DefineProperty
("LINK_DIRECTORIES", cmProperty::DIRECTORY,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 70500cd..f8cecd1 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -292,7 +292,6 @@ void cmTarget::DefineProperties(cmake *cm)
"Contents of COMPILE_DEFINITIONS may use \"generator expressions\" with "
"the syntax \"$<...>\". "
CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS
CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER);
cm->DefineProperty
@@ -311,8 +310,7 @@ void cmTarget::DefineProperties(cmake *cm)
"the options for the compiler.\n"
"Contents of COMPILE_OPTIONS may use \"generator expressions\" with "
"the syntax \"$<...>\". "
- CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
cm->DefineProperty
("INTERFACE_COMPILE_OPTIONS", cmProperty::TARGET,
@@ -323,8 +321,7 @@ void cmTarget::DefineProperties(cmake *cm)
"as $<TARGET_PROPERTY:foo,INTERFACE_COMPILE_OPTIONS> to use the "
"compile options specified in the interface of 'foo'."
"\n"
- CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
cm->DefineProperty
("DEFINE_SYMBOL", cmProperty::TARGET,
@@ -653,8 +650,7 @@ void cmTarget::DefineProperties(cmake *cm)
"See also the include_directories command.\n"
"Contents of INCLUDE_DIRECTORIES may use \"generator expressions\" with "
"the syntax \"$<...>\". "
- CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
cm->DefineProperty
("INSTALL_NAME_DIR", cmProperty::TARGET,
@@ -749,7 +745,11 @@ void cmTarget::DefineProperties(cmake *cm)
"file providing the program entry point (main). "
"If not set, the language with the highest linker preference "
"value is the default. "
- "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables.");
+ "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables."
+ "\n"
+ "If this property is not set by the user, it will be calculated at "
+ "generate-time by CMake."
+ );
cm->DefineProperty
("LOCATION", cmProperty::TARGET,
@@ -870,8 +870,7 @@ void cmTarget::DefineProperties(cmake *cm)
"as $<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES> to use the "
"include directories specified in the interface of 'foo'."
"\n"
- CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
cm->DefineProperty
("SYSTEM_INTERFACE_INCLUDE_DIRECTORIES", cmProperty::TARGET,
@@ -881,8 +880,7 @@ void cmTarget::DefineProperties(cmake *cm)
"compiler warnings. Consuming targets will then mark the same include "
"directories as system headers."
"\n"
- CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
cm->DefineProperty
("INTERFACE_COMPILE_DEFINITIONS", cmProperty::TARGET,
@@ -893,8 +891,7 @@ void cmTarget::DefineProperties(cmake *cm)
"as $<TARGET_PROPERTY:foo,INTERFACE_COMPILE_DEFINITIONS> to use the "
"compile definitions specified in the interface of 'foo'."
"\n"
- CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
cm->DefineProperty
("LINK_INTERFACE_MULTIPLICITY", cmProperty::TARGET,
diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h
index bc58b31..585485d 100644
--- a/Source/cmTargetCompileDefinitionsCommand.h
+++ b/Source/cmTargetCompileDefinitionsCommand.h
@@ -70,7 +70,6 @@ public:
"Arguments to target_compile_definitions may use \"generator "
"expressions\" with the syntax \"$<...>\". "
CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS
;
}
diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h
index 2968618..fcc37f0 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.h
+++ b/Source/cmTargetIncludeDirectoriesCommand.h
@@ -83,7 +83,6 @@ public:
"Arguments to target_include_directories may use \"generator "
"expressions\" with the syntax \"$<...>\". "
CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
- CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS
;
}
diff --git a/Tests/CompileDefinitions/compiletest_mixed_c.c b/Tests/CompileDefinitions/compiletest_mixed_c.c
index 698c989..a270b2b 100644
--- a/Tests/CompileDefinitions/compiletest_mixed_c.c
+++ b/Tests/CompileDefinitions/compiletest_mixed_c.c
@@ -13,6 +13,10 @@
#error Unexpected LINK_LANGUAGE_IS_C
#endif
+#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C
+#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
+#endif
+
void someFunc(void)
{
diff --git a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
index c686854..ae6befc 100644
--- a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
+++ b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
@@ -13,6 +13,10 @@
#error Unexpected LINK_LANGUAGE_IS_C
#endif
+#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C
+#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
+#endif
+
int main(int argc, char **argv)
{
return 0;
diff --git a/Tests/CompileDefinitions/target_prop/CMakeLists.txt b/Tests/CompileDefinitions/target_prop/CMakeLists.txt
index 6bf9c5c..a0d3f4e 100644
--- a/Tests/CompileDefinitions/target_prop/CMakeLists.txt
+++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt
@@ -23,9 +23,9 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS
LETTER_LIST3=\"$<JOIN:A;B;C;D,,->\"
LETTER_LIST4=\"$<JOIN:A;B;C;D,-,->\"
LETTER_LIST5=\"$<JOIN:A;B;C;D,-,>\"
- "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>"
- "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>"
- "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>"
+ "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_LANGUAGE>"
)
set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS
@@ -36,16 +36,17 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS
add_executable(target_prop_c_executable ../compiletest.c)
set_property(TARGET target_prop_c_executable APPEND PROPERTY COMPILE_DEFINITIONS
- "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>"
- "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>"
- "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>"
+ "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_LANGUAGE>"
)
# Resulting link language will be CXX
add_executable(target_prop_mixed_executable ../compiletest_mixed_c.c ../compiletest_mixed_cxx.cpp)
set_property(TARGET target_prop_mixed_executable APPEND PROPERTY COMPILE_DEFINITIONS
- "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>"
- "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>"
- "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>"
+ "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_LANGUAGE>"
+ "C_EXECUTABLE_LINK_LANGUAGE_IS_$<TARGET_PROPERTY:target_prop_c_executable,LINKER_LANGUAGE>"
)
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
index 6919261..8e2bd0a 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
@@ -156,15 +156,15 @@ target_include_directories(TargetIncludeDirectories PRIVATE "${CMAKE_CURRENT_BIN
# Test that the language generator expressions work
set_property(TARGET TargetIncludeDirectories
APPEND PROPERTY INCLUDE_DIRECTORIES
- "$<$<LINK_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/bad>"
- "$<$<LINK_LANGUAGE:CXX>:${CMAKE_CURRENT_BINARY_DIR}/good>"
- "$<$<STREQUAL:$<LINK_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/bad>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/good>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>"
)
add_executable(TargetIncludeDirectories_C main.c)
set_property(TARGET TargetIncludeDirectories_C
APPEND PROPERTY INCLUDE_DIRECTORIES
- "$<$<LINK_LANGUAGE:CXX>:${CMAKE_CURRENT_BINARY_DIR}/bad>"
- "$<$<LINK_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/good>"
- "$<$<STREQUAL:$<LINK_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/bad>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/good>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>"
)
diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt
index 8e0591d..a5d5d50 100644
--- a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt
+++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt
@@ -1,6 +1,7 @@
CMake Error:
Error evaluating generator expression:
- \$<LINK_LANGUAGE>
+ \$<TARGET_PROPERTY:LINKER_LANGUAGE>
- \$<LINK_LANGUAGE> expression can not be used while evaluating link libraries
+ LINKER_LANGUAGE target property can not be used while evaluating link
+ libraries
diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake
index e0f8c57..d4e31cd 100644
--- a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake
+++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake
@@ -1,4 +1,4 @@
add_library(foo SHARED empty.cpp)
add_library(bar SHARED empty.cpp)
-target_link_libraries(foo $<$<STREQUAL:$<LINK_LANGUAGE>,anything>:bar>)
+target_link_libraries(foo $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,anything>:bar>)