diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h index 45047957a..e9bbf2816 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 841061cd4..46cd77eae 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" \ - " $ = The link language of the target " \ - "being generated.\n" \ - " $ = '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 381ef7c32..c1f53b4a2 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 ¶meters, - cmGeneratorExpressionContext *context, - const GeneratorExpressionContent *content, - cmGeneratorExpressionDAGChecker *dagChecker) const - { - if (dagChecker && dagChecker->EvaluatingLinkLibraries()) - { - reportError(context, content->GetOriginalExpression(), - "$ expression can not be used while evaluating " - "link libraries"); - return std::string(); - } - if (parameters.size() != 0 && parameters.size() != 1) - { - reportError(context, content->GetOriginalExpression(), - "$ expression requires one or two parameters"); - return std::string(); - } - cmTarget* target = context->HeadTarget; - if (!target) - { - reportError(context, content->GetOriginalExpression(), - "$ 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 818a580a2..2cd19cf2e 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 70500cdaf..f8cecd11d 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 $ 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__LINKER_PREFERENCE variables."); + "See documentation of CMAKE__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 $ 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 $ 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 bc58b3174..585485d2a 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 29686183c..fcc37f06a 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 698c989a8..a270b2b12 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 c6868547d..ae6befc5f 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 6bf9c5c23..a0d3f4e96 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=\"$\" LETTER_LIST4=\"$\" LETTER_LIST5=\"$\" - "$<$:LINK_CXX_DEFINE>" - "$<$:LINK_C_DEFINE>" - "LINK_LANGUAGE_IS_$" + "$<$,CXX>:LINK_CXX_DEFINE>" + "$<$,C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$" ) 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_CXX_DEFINE>" - "$<$:LINK_C_DEFINE>" - "LINK_LANGUAGE_IS_$" + "$<$,CXX>:LINK_CXX_DEFINE>" + "$<$,C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$" ) # 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_CXX_DEFINE>" - "$<$:LINK_C_DEFINE>" - "LINK_LANGUAGE_IS_$" + "$<$,CXX>:LINK_CXX_DEFINE>" + "$<$,C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$" + "C_EXECUTABLE_LINK_LANGUAGE_IS_$" ) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 691926104..8e2bd0a0d 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 - "$<$:${CMAKE_CURRENT_BINARY_DIR}/bad>" - "$<$:${CMAKE_CURRENT_BINARY_DIR}/good>" - "$<$,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" + "$<$,C>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$,CXX>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" ) add_executable(TargetIncludeDirectories_C main.c) set_property(TARGET TargetIncludeDirectories_C APPEND PROPERTY INCLUDE_DIRECTORIES - "$<$:${CMAKE_CURRENT_BINARY_DIR}/bad>" - "$<$:${CMAKE_CURRENT_BINARY_DIR}/good>" - "$<$,C>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" + "$<$,CXX>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$,C>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$,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 8e0591d34..a5d5d5088 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: - \$ + \$ - \$ 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 e0f8c5724..d4e31cde3 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 $<$,anything>:bar>) +target_link_libraries(foo $<$,anything>:bar>)