summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-06-07 18:36:28 (GMT)
committerBrad King <brad.king@kitware.com>2010-06-07 18:36:28 (GMT)
commit6cf1ccd63270ab1a8ee790ff8faad17154870b5c (patch)
tree5456e64a7c6b366480a45f02fa009ec2cef5d454
parent608406bf55ad6aa33acff382c15038e95314a587 (diff)
parentc8b13ecc380e38eda475974bc7ab515a65fe90cc (diff)
downloadCMake-6cf1ccd63270ab1a8ee790ff8faad17154870b5c.zip
CMake-6cf1ccd63270ab1a8ee790ff8faad17154870b5c.tar.gz
CMake-6cf1ccd63270ab1a8ee790ff8faad17154870b5c.tar.bz2
Merge branch 'per-config-link-flags'
-rw-r--r--Modules/Platform/Windows-wcl386.cmake6
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx12
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx114
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx15
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx4
-rw-r--r--Source/cmTarget.cxx5
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx29
-rw-r--r--Templates/staticLibHeader.dsptemplate8
-rw-r--r--Tests/CMakeLists.txt28
-rw-r--r--Tests/LinkFlags/CMakeLists.txt28
-rw-r--r--Tests/LinkFlags/LinkFlags.c1
-rw-r--r--Tests/LinkFlags/LinkFlagsExe.c6
-rw-r--r--Tests/LinkFlags/LinkFlagsLib.c6
13 files changed, 217 insertions, 45 deletions
diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake
index b260489..7fc345f 100644
--- a/Modules/Platform/Windows-wcl386.cmake
+++ b/Modules/Platform/Windows-wcl386.cmake
@@ -31,7 +31,7 @@ SET(CMAKE_C_CREATE_IMPORT_LIBRARY
SET(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
SET(CMAKE_C_LINK_EXECUTABLE
- "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+ "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE})
@@ -52,7 +52,7 @@ SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_SHARED_MODULE
- "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+ "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
${CMAKE_CXX_CREATE_SHARED_MODULE}
${CMAKE_CXX_CREATE_IMPORT_LIBRARY})
@@ -64,7 +64,7 @@ SET(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE})
# create a C++ static library
-SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b '<TARGET_UNQUOTED>' <OBJECTS> ")
+SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b '<TARGET_UNQUOTED>' <LINK_FLAGS> <OBJECTS> ")
# create a C static library
SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY})
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 0d6e389..537a88f 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1514,8 +1514,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
extraLinkOptions = this->CurrentMakefile->
GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
}
-
- const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
+
+ const char* linkFlagsProp = "LINK_FLAGS";
+ if(target.GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ linkFlagsProp = "STATIC_LIBRARY_FLAGS";
+ }
+ const char* targetLinkFlags = target.GetProperty(linkFlagsProp);
if(targetLinkFlags)
{
extraLinkOptions += " ";
@@ -1523,7 +1528,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
}
if(configName && *configName)
{
- std::string linkFlagsVar = "LINK_FLAGS_";
+ std::string linkFlagsVar = linkFlagsProp;
+ linkFlagsVar += "_";
linkFlagsVar += cmSystemTools::UpperCase(configName);
if(const char* linkFlags = target.GetProperty(linkFlagsVar.c_str()))
{
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 89bfd05..539816d 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1142,6 +1142,10 @@ void cmLocalVisualStudio6Generator
// Get extra linker options for this target type.
std::string extraLinkOptions;
+ std::string extraLinkOptionsDebug;
+ std::string extraLinkOptionsRelease;
+ std::string extraLinkOptionsMinSizeRel;
+ std::string extraLinkOptionsRelWithDebInfo;
if(target.GetType() == cmTarget::EXECUTABLE)
{
extraLinkOptions =
@@ -1165,6 +1169,33 @@ void cmLocalVisualStudio6Generator
extraLinkOptions += targetLinkFlags;
}
+ if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_DEBUG"))
+ {
+ extraLinkOptionsDebug += " ";
+ extraLinkOptionsDebug += targetLinkFlags;
+ }
+
+ if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELEASE"))
+ {
+ extraLinkOptionsRelease += " ";
+ extraLinkOptionsRelease += targetLinkFlags;
+ }
+
+ if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_MINSIZEREL"))
+ {
+ extraLinkOptionsMinSizeRel += " ";
+ extraLinkOptionsMinSizeRel += targetLinkFlags;
+ }
+
+ if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELWITHDEBINFO"))
+ {
+ extraLinkOptionsRelWithDebInfo += " ";
+ extraLinkOptionsRelWithDebInfo += targetLinkFlags;
+ }
+
+
+
+
// Get standard libraries for this language.
if(targetBuilds)
{
@@ -1259,13 +1290,21 @@ void cmLocalVisualStudio6Generator
target.GetType() == cmTarget::SHARED_LIBRARY ||
target.GetType() == cmTarget::MODULE_LIBRARY)
{
- this->ComputeLinkOptions(target, "Debug", extraLinkOptions,
+ extraLinkOptionsDebug =
+ extraLinkOptions + " " + extraLinkOptionsDebug;
+ extraLinkOptionsRelease =
+ extraLinkOptions + " " + extraLinkOptionsRelease;
+ extraLinkOptionsMinSizeRel =
+ extraLinkOptions + " " + extraLinkOptionsMinSizeRel;
+ extraLinkOptionsRelWithDebInfo =
+ extraLinkOptions + " " + extraLinkOptionsRelWithDebInfo;
+ this->ComputeLinkOptions(target, "Debug", extraLinkOptionsDebug,
optionsDebug);
- this->ComputeLinkOptions(target, "Release", extraLinkOptions,
+ this->ComputeLinkOptions(target, "Release", extraLinkOptionsRelease,
optionsRelease);
- this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptions,
+ this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptionsMinSizeRel,
optionsMinSizeRel);
- this->ComputeLinkOptions(target, "RelWithDebInfo", extraLinkOptions,
+ this->ComputeLinkOptions(target, "RelWithDebInfo", extraLinkOptionsRelWithDebInfo,
optionsRelWithDebInfo);
}
@@ -1342,11 +1381,43 @@ void cmLocalVisualStudio6Generator
cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
}
std::string staticLibOptions;
+ std::string staticLibOptionsDebug;
+ std::string staticLibOptionsRelease;
+ std::string staticLibOptionsMinSizeRel;
+ std::string staticLibOptionsRelWithDebInfo;
if(target.GetType() == cmTarget::STATIC_LIBRARY )
{
if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
{
staticLibOptions = libflags;
+ staticLibOptionsDebug = libflags;
+ staticLibOptionsRelease = libflags;
+ staticLibOptionsMinSizeRel = libflags;
+ staticLibOptionsRelWithDebInfo = libflags;
+ }
+ if(const char* libflagsDebug =
+ target.GetProperty("STATIC_LIBRARY_FLAGS_DEBUG"))
+ {
+ staticLibOptionsDebug += " ";
+ staticLibOptionsDebug = libflagsDebug;
+ }
+ if(const char* libflagsRelease =
+ target.GetProperty("STATIC_LIBRARY_FLAGS_RELEASE"))
+ {
+ staticLibOptionsRelease += " ";
+ staticLibOptionsRelease = libflagsRelease;
+ }
+ if(const char* libflagsMinSizeRel =
+ target.GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL"))
+ {
+ staticLibOptionsMinSizeRel += " ";
+ staticLibOptionsMinSizeRel = libflagsMinSizeRel;
+ }
+ if(const char* libflagsRelWithDebInfo =
+ target.GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"))
+ {
+ staticLibOptionsRelWithDebInfo += " ";
+ staticLibOptionsRelWithDebInfo = libflagsRelWithDebInfo;
}
}
@@ -1378,6 +1449,14 @@ void cmLocalVisualStudio6Generator
mfcFlag);
if(target.GetType() == cmTarget::STATIC_LIBRARY )
{
+ cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_DEBUG",
+ staticLibOptionsDebug.c_str());
+ cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELEASE",
+ staticLibOptionsRelease.c_str());
+ cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_MINSIZEREL",
+ staticLibOptionsMinSizeRel.c_str());
+ cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELWITHDEBINFO",
+ staticLibOptionsRelWithDebInfo.c_str());
cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
staticLibOptions.c_str());
}
@@ -1519,41 +1598,18 @@ void cmLocalVisualStudio6Generator
std::string flagVar = baseFlagVar + "_RELEASE";
flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
- if(const char* targetLinkFlags =
- target.GetProperty("LINK_FLAGS_RELEASE"))
- {
- flagsRelease += targetLinkFlags;
- flagsRelease += " ";
- }
+
flagVar = baseFlagVar + "_MINSIZEREL";
flagsMinSize = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
- if(const char* targetLinkFlags =
- target.GetProperty("LINK_FLAGS_MINSIZEREL"))
- {
- flagsMinSize += targetLinkFlags;
- flagsMinSize += " ";
- }
-
+
flagVar = baseFlagVar + "_DEBUG";
flagsDebug = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
- if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_DEBUG"))
- {
- flagsDebug += targetLinkFlags;
- flagsDebug += " ";
- }
flagVar = baseFlagVar + "_RELWITHDEBINFO";
flagsDebugRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
- if(const char* targetLinkFlags =
- target.GetProperty("LINK_FLAGS_RELWITHDEBINFO"))
- {
- flagsDebugRel += targetLinkFlags;
- flagsDebugRel += " ";
- }
-
}
// if unicode is not found, then add -D_MBCS
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 2d8197c..136c177 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -915,7 +915,20 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n";
- if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
+
+ std::string libflags;
+ if(const char* flags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
+ {
+ libflags += flags;
+ }
+ std::string libFlagsConfig = "STATIC_LIBRARY_FLAGS_";
+ libFlagsConfig += configTypeUpper;
+ if(const char* flagsConfig = target.GetProperty(libFlagsConfig.c_str()))
+ {
+ libflags += " ";
+ libflags += flagsConfig;
+ }
+ if(!libflags.empty())
{
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
}
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index d3e6e11..dff91fe 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -122,6 +122,10 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
std::string extraFlags;
this->LocalGenerator->AppendFlags
(extraFlags,this->Target->GetProperty("STATIC_LIBRARY_FLAGS"));
+ std::string staticLibraryFlagsConfig = "STATIC_LIBRARY_FLAGS_";
+ staticLibraryFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
+ this->LocalGenerator->AppendFlags
+ (extraFlags, this->Target->GetProperty(staticLibraryFlagsConfig.c_str()));
this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false);
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 54b1815..45ba358 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -708,6 +708,11 @@ void cmTarget::DefineProperties(cmake *cm)
"Extra flags to use when linking a static library.");
cm->DefineProperty
+ ("STATIC_LIBRARY_FLAGS_<CONFIG>", cmProperty::TARGET,
+ "Per-configuration flags for creating a static library.",
+ "This is the configuration-specific version of STATIC_LIBRARY_FLAGS.");
+
+ cm->DefineProperty
("SUFFIX", cmProperty::TARGET,
"What comes after the library name.",
"A target property that can be set to override the suffix "
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9f64473..53d6594 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -860,6 +860,13 @@ OutputLinkIncremental(std::string const& configName)
flags += " ";
flags += targetLinkFlags;
}
+ std::string flagsProp = "LINK_FLAGS_";
+ flagsProp += CONFIG;
+ if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
+ {
+ flags += " ";
+ flags += flagsConfig;
+ }
if(flags.find("INCREMENTAL:NO") != flags.npos)
{
incremental = "false";
@@ -1016,22 +1023,27 @@ WriteRCOptions(std::string const& ,
}
-void cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const&
- )
+void
+cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
{
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
{
return;
}
- if(const char* libflags = this->Target
- ->GetProperty("STATIC_LIBRARY_FLAGS"))
+ const char* libflags = this->Target->GetProperty("STATIC_LIBRARY_FLAGS");
+ std::string flagsConfigVar = "STATIC_LIBRARY_FLAGS_";
+ flagsConfigVar += cmSystemTools::UpperCase(config);
+ const char* libflagsConfig =
+ this->Target->GetProperty(flagsConfigVar.c_str());
+ if(libflags || libflagsConfig)
{
this->WriteString("<Lib>\n", 2);
cmVisualStudioGeneratorOptions
libOptions(this->LocalGenerator, 10,
cmVisualStudioGeneratorOptions::Linker,
cmVS10LibFlagTable, 0, this);
- libOptions.Parse(libflags);
+ libOptions.Parse(libflags?libflags:"");
+ libOptions.Parse(libflagsConfig?libflagsConfig:"");
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
this->WriteString("</Lib>\n", 2);
@@ -1099,6 +1111,13 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
flags += " ";
flags += targetLinkFlags;
}
+ std::string flagsProp = "LINK_FLAGS_";
+ flagsProp += CONFIG;
+ if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
+ {
+ flags += " ";
+ flags += flagsConfig;
+ }
cmVisualStudioGeneratorOptions
linkOptions(this->LocalGenerator, 10,
cmVisualStudioGeneratorOptions::Linker,
diff --git a/Templates/staticLibHeader.dsptemplate b/Templates/staticLibHeader.dsptemplate
index 1b5c8bc..16b784e 100644
--- a/Templates/staticLibHeader.dsptemplate
+++ b/Templates/staticLibHeader.dsptemplate
@@ -67,7 +67,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" CM_STATIC_LIB_ARGS_RELEASE
CMAKE_CUSTOM_RULE_CODE_RELEASE
@@ -97,7 +97,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" CM_STATIC_LIB_ARGS_DEBUG
CMAKE_CUSTOM_RULE_CODE_DEBUG
@@ -128,7 +128,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" CM_STATIC_LIB_ARGS_MINSIZEREL
CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
@@ -158,7 +158,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" CM_STATIC_LIB_ARGS
+# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" CM_STATIC_LIB_ARGS_RELWITHDEBINFO
CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index b99b183..1b8f4f3 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -174,6 +174,34 @@ IF(BUILD_TESTING)
ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)
+ ADD_TEST(LinkFlags-prepare
+ ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/LinkFlags"
+ "${CMake_BINARY_DIR}/Tests/LinkFlags"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-project LinkFlags
+ --build-target LinkFlags
+ --build-options -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
+ )
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
+
+ MACRO(ADD_LINK_FLAGS_TEST name depends)
+ ADD_TEST(LinkFlags-${name}
+ ${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags"
+ --target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE}
+ )
+ SET_TESTS_PROPERTIES(LinkFlags-${name} PROPERTIES
+ PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends})
+ ENDMACRO()
+ ADD_LINK_FLAGS_TEST(lib prepare)
+ ADD_LINK_FLAGS_TEST(dll lib)
+ ADD_LINK_FLAGS_TEST(exe dll)
+ ADD_LINK_FLAGS_TEST(lib_config exe)
+ ADD_LINK_FLAGS_TEST(dll_config lib_config)
+ ADD_LINK_FLAGS_TEST(exe_config dll_config)
+
# If we are running right now with a UnixMakefiles based generator,
# build the "Simple" test with the ExtraGenerators, if available
# This doesn't test whether the generated project files work (unfortunately),
diff --git a/Tests/LinkFlags/CMakeLists.txt b/Tests/LinkFlags/CMakeLists.txt
new file mode 100644
index 0000000..e06020c
--- /dev/null
+++ b/Tests/LinkFlags/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 2.8)
+project(LinkFlags C)
+
+string(TOUPPER "${TEST_CONFIG}" TEST_CONFIG_UPPER)
+set(obj "${CMAKE_C_OUTPUT_EXTENSION}")
+if(BORLAND)
+ set(pre -)
+endif()
+
+add_library(LinkFlags_lib STATIC LinkFlagsLib.c)
+set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS ${pre}BADFLAG${obj})
+
+add_library(LinkFlags_dll SHARED LinkFlagsLib.c)
+set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS ${pre}BADFLAG${obj})
+
+add_executable(LinkFlags_exe LinkFlagsExe.c)
+set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS ${pre}BADFLAG${obj})
+
+add_library(LinkFlags_lib_config STATIC LinkFlagsLib.c)
+set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
+
+add_library(LinkFlags_dll_config SHARED LinkFlagsLib.c)
+set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
+
+add_executable(LinkFlags_exe_config LinkFlagsExe.c)
+set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
+
+add_executable(LinkFlags LinkFlags.c)
diff --git a/Tests/LinkFlags/LinkFlags.c b/Tests/LinkFlags/LinkFlags.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/Tests/LinkFlags/LinkFlags.c
@@ -0,0 +1 @@
+int main(void) { return 0; }
diff --git a/Tests/LinkFlags/LinkFlagsExe.c b/Tests/LinkFlags/LinkFlagsExe.c
new file mode 100644
index 0000000..123587a
--- /dev/null
+++ b/Tests/LinkFlags/LinkFlagsExe.c
@@ -0,0 +1,6 @@
+int main(void) { return 0; }
+
+/* Intel compiler does not reject bad flags or objects! */
+#if defined(__INTEL_COMPILER)
+# error BADFLAG
+#endif
diff --git a/Tests/LinkFlags/LinkFlagsLib.c b/Tests/LinkFlags/LinkFlagsLib.c
new file mode 100644
index 0000000..9d8d088
--- /dev/null
+++ b/Tests/LinkFlags/LinkFlagsLib.c
@@ -0,0 +1,6 @@
+int flags_lib(void) { return 0; }
+
+/* Intel compiler does not reject bad flags or objects! */
+#if defined(__INTEL_COMPILER)
+# error BADFLAG
+#endif