Genex: Enable COMPILE_LANGUAGE for file(GENERATE) with Visual Studio

Issue: #17435
This commit is contained in:
Brad King
2017-11-17 14:31:07 -05:00
parent 0f6f7c8ab1
commit 2b7d59f310
5 changed files with 23 additions and 18 deletions

View File

@@ -828,12 +828,16 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
}
std::string genName = gg->GetName();
if (genName.find("Visual Studio") != std::string::npos) {
reportError(context, content->GetOriginalExpression(),
"$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
"generators.");
return std::string();
}
if (genName.find("Xcode") != std::string::npos) {
if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
dagChecker->EvaluatingCompileOptions() ||
dagChecker->EvaluatingIncludeDirectories())) {
reportError(
context, content->GetOriginalExpression(),
"$<COMPILE_LANGUAGE:...> may only be used for file(GENERATE) "
"with the Visual Studio generator.");
return std::string();
}
} else if (genName.find("Xcode") != std::string::npos) {
if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
dagChecker->EvaluatingIncludeDirectories())) {
reportError(

View File

@@ -3,6 +3,7 @@ CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\):
\$<COMPILE_LANGUAGE:CXX>
\$<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
\$<COMPILE_LANGUAGE:...> may only be used for file\(GENERATE\) with the Visual
Studio generator.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@@ -3,6 +3,7 @@ CMake Error at CompileOptions.cmake:5 \(target_compile_options\):
\$<COMPILE_LANGUAGE:CXX>
\$<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
\$<COMPILE_LANGUAGE:...> may only be used for file\(GENERATE\) with the Visual
Studio generator.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@@ -3,6 +3,7 @@ CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
\$<COMPILE_LANGUAGE:CXX>
\$<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
\$<COMPILE_LANGUAGE:...> may only be used for file\(GENERATE\) with the Visual
Studio generator.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@@ -21,15 +21,13 @@ if (NOT file_contents MATCHES "generated.cpp.rule")
message(SEND_ERROR "Rule file not in target sources! ${file_contents}")
endif()
if (NOT RunCMake_GENERATOR MATCHES "Visual Studio")
run_cmake(COMPILE_LANGUAGE-genex)
foreach(l CXX C)
file(READ "${RunCMake_BINARY_DIR}/COMPILE_LANGUAGE-genex-build/opts-${l}.txt" l_defs)
if (NOT l_defs STREQUAL "LANG_IS_${l}\n")
message(FATAL_ERROR "File content does not match: ${l_defs}")
endif()
endforeach()
endif()
run_cmake(COMPILE_LANGUAGE-genex)
foreach(l CXX C)
file(READ "${RunCMake_BINARY_DIR}/COMPILE_LANGUAGE-genex-build/opts-${l}.txt" l_defs)
if (NOT l_defs STREQUAL "LANG_IS_${l}\n")
message(FATAL_ERROR "File content does not match: ${l_defs}")
endif()
endforeach()
set(timeformat "%Y%j%H%M%S")