From 7458d465dde88a5e85b51d32b7b37f9dcfb9d216 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 May 2010 10:20:10 -0400 Subject: Fix LINK_FLAGS_ in VS 6 generator Add the flags to the link step, not the compile step! --- Source/cmLocalVisualStudio6Generator.cxx | 74 +++++++++++++++++++------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 89bfd05..d7ffcf7 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); } @@ -1519,41 +1558,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 -- cgit v0.12 From 159606c3667e006bba59490c2cae82871f25d773 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 May 2010 11:00:31 -0400 Subject: Implement LINK_FLAGS_ in VS 10 generator Add support for the per-config LINK_FLAGS property in VS 10. This was simply missing. --- Source/cmVisualStudio10TargetGenerator.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9f64473..13bbc74 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"; @@ -1099,6 +1106,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, -- cgit v0.12 From d3303dbc8130988be63b9dda913eb9af9770edeb Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 May 2010 09:47:12 -0400 Subject: Test LINK_FLAGS and STATIC_LIBRARY_FLAGS (#10768) Add a LinkFlags test series to check that these properties work. Since no link flag is accepted everywhere we test for presence of flags by adding a bad flag and looking for the complaint in the test output. --- Tests/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ Tests/LinkFlags/CMakeLists.txt | 24 ++++++++++++++++++++++++ Tests/LinkFlags/LinkFlags.c | 1 + Tests/LinkFlags/LinkFlagsLib.c | 1 + 4 files changed, 57 insertions(+) create mode 100644 Tests/LinkFlags/CMakeLists.txt create mode 100644 Tests/LinkFlags/LinkFlags.c create mode 100644 Tests/LinkFlags/LinkFlagsLib.c diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 330cf9f..0761486 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -174,6 +174,37 @@ 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) + + # STATIC_LIBRARY_FLAGS_ not yet implemented + SET_TESTS_PROPERTIES(LinkFlags-lib_config PROPERTIES WILL_FAIL 1) + # 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..48161f1 --- /dev/null +++ b/Tests/LinkFlags/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkFlags C) + +string(TOUPPER "${TEST_CONFIG}" TEST_CONFIG_UPPER) + +add_library(LinkFlags_lib STATIC LinkFlagsLib.c) +set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS _BADFLAG_) + +add_library(LinkFlags_dll SHARED LinkFlagsLib.c) +set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS _BADFLAG_) + +add_executable(LinkFlags_exe LinkFlags.c) +set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS _BADFLAG_) + +add_library(LinkFlags_lib_config STATIC LinkFlagsLib.c) +set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_) + +add_library(LinkFlags_dll_config SHARED LinkFlagsLib.c) +set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_) + +add_executable(LinkFlags_exe_config LinkFlags.c) +set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_) + +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/LinkFlagsLib.c b/Tests/LinkFlags/LinkFlagsLib.c new file mode 100644 index 0000000..f002eef --- /dev/null +++ b/Tests/LinkFlags/LinkFlagsLib.c @@ -0,0 +1 @@ +int flags_lib(void) { return 0; } -- cgit v0.12 From fe971d97cae4df94d3643c5203b79336cfd31e05 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 May 2010 10:45:54 -0400 Subject: Add STATIC_LIBRARY_FLAGS_ property (#10768) This is a per-configuration version of STATIC_LIBRARY_FLAGS. --- Source/cmLocalVisualStudio6Generator.cxx | 40 +++++++++++++++++++++++++++++ Source/cmLocalVisualStudio7Generator.cxx | 15 ++++++++++- Source/cmMakefileLibraryTargetGenerator.cxx | 4 +++ Source/cmTarget.cxx | 5 ++++ Source/cmVisualStudio10TargetGenerator.cxx | 15 +++++++---- Templates/staticLibHeader.dsptemplate | 8 +++--- Tests/CMakeLists.txt | 3 --- 7 files changed, 77 insertions(+), 13 deletions(-) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index d7ffcf7..539816d 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1381,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; } } @@ -1417,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()); } 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\tLocalGenerator->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_", 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 13bbc74..53d6594 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1023,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("\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("\n", 2); 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 0761486..0eec0c8 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -202,9 +202,6 @@ IF(BUILD_TESTING) ADD_LINK_FLAGS_TEST(dll_config lib_config) ADD_LINK_FLAGS_TEST(exe_config dll_config) - # STATIC_LIBRARY_FLAGS_ not yet implemented - SET_TESTS_PROPERTIES(LinkFlags-lib_config PROPERTIES WILL_FAIL 1) - # 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), -- cgit v0.12 From 5c49aa0c8622b5253b6041e85ba32a5b5ce26d74 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 May 2010 13:23:31 -0400 Subject: Xcode: Archives use STATIC_LIBRARY_FLAGS, not LINK_FLAGS The LINK_FLAGS property is defined only for targets that really link. These include executables and shared libraries. For static libraries we define the STATIC_LIBRARY_FLAGS property. Teach the Xcode generator to make this distinction. --- Source/cmGlobalXCodeGenerator.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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())) { -- cgit v0.12 From 9622fe5e9a2d9315426121643c17fd569b7f6907 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Jun 2010 14:40:28 -0400 Subject: Watcom: Use LINK_FLAGS and STATIC_LIBRARY_FLAGS Add the rule variable in Watcom command lines. --- Modules/Platform/Windows-wcl386.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 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 '' option caseexact file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' option caseexact file {} ${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) @@ -52,7 +52,7 @@ SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -d+ -fo -pl -cc++ ${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_CREATE_SHARED_MODULE - "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '' option caseexact file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '' option caseexact file {} ${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 '' ") +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b '' ") # create a C static library SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) -- cgit v0.12 From 6a009280fd38380f5d00dc073d63e51737ceb293 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Jun 2010 17:46:58 -0400 Subject: Better "bad" flag in LinkFlags test The Intel C Compiler for Linux ignores _BADFLAG_ when linking! Use a flag that looks like a missing object file to ensure its rejection. --- Tests/LinkFlags/CMakeLists.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Tests/LinkFlags/CMakeLists.txt b/Tests/LinkFlags/CMakeLists.txt index 48161f1..b510442 100644 --- a/Tests/LinkFlags/CMakeLists.txt +++ b/Tests/LinkFlags/CMakeLists.txt @@ -2,23 +2,24 @@ cmake_minimum_required(VERSION 2.8) project(LinkFlags C) string(TOUPPER "${TEST_CONFIG}" TEST_CONFIG_UPPER) +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") add_library(LinkFlags_lib STATIC LinkFlagsLib.c) -set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS _BADFLAG_) +set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS BADFLAG${obj}) add_library(LinkFlags_dll SHARED LinkFlagsLib.c) -set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS _BADFLAG_) +set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS BADFLAG${obj}) add_executable(LinkFlags_exe LinkFlags.c) -set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS _BADFLAG_) +set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS BADFLAG${obj}) add_library(LinkFlags_lib_config STATIC LinkFlagsLib.c) -set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_) +set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CONFIG_UPPER} BADFLAG_${TEST_CONFIG}${obj}) add_library(LinkFlags_dll_config SHARED LinkFlagsLib.c) -set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_) +set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} BADFLAG_${TEST_CONFIG}${obj}) add_executable(LinkFlags_exe_config LinkFlags.c) -set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} _BADFLAG_${TEST_CONFIG}_) +set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} BADFLAG_${TEST_CONFIG}${obj}) add_executable(LinkFlags LinkFlags.c) -- cgit v0.12 From a9b24af25c8206c5041e2d3e44a9dd3d52fbfe92 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Jun 2010 08:16:06 -0400 Subject: Borland-specific bad flag for LinkFlags tests The Borland librarian actually creates a BADFLAG.obj when the object is missing the first time! This causes later tests to not reject it. Instead use a Borland-specific variation on the flag. --- Tests/LinkFlags/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Tests/LinkFlags/CMakeLists.txt b/Tests/LinkFlags/CMakeLists.txt index b510442..ee547e4 100644 --- a/Tests/LinkFlags/CMakeLists.txt +++ b/Tests/LinkFlags/CMakeLists.txt @@ -3,23 +3,26 @@ 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 BADFLAG${obj}) +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 BADFLAG${obj}) +set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS ${pre}BADFLAG${obj}) add_executable(LinkFlags_exe LinkFlags.c) -set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS BADFLAG${obj}) +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} BADFLAG_${TEST_CONFIG}${obj}) +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} BADFLAG_${TEST_CONFIG}${obj}) +set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj}) add_executable(LinkFlags_exe_config LinkFlags.c) -set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} BADFLAG_${TEST_CONFIG}${obj}) +set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj}) add_executable(LinkFlags LinkFlags.c) -- cgit v0.12 From c8b13ecc380e38eda475974bc7ab515a65fe90cc Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Jun 2010 09:37:17 -0400 Subject: Intel-specific workaround for LinkFlags tests The Intel C compiler for Linux does not seem to reject any bad flags or object files on its link lines. Work around the problem by using a preprocessor #error directive to ensure that BADFLAG appears in the build output. This does not really achieve the purpose of the tests but it allows them to pass. --- Tests/LinkFlags/CMakeLists.txt | 4 ++-- Tests/LinkFlags/LinkFlagsExe.c | 6 ++++++ Tests/LinkFlags/LinkFlagsLib.c | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 Tests/LinkFlags/LinkFlagsExe.c diff --git a/Tests/LinkFlags/CMakeLists.txt b/Tests/LinkFlags/CMakeLists.txt index ee547e4..e06020c 100644 --- a/Tests/LinkFlags/CMakeLists.txt +++ b/Tests/LinkFlags/CMakeLists.txt @@ -13,7 +13,7 @@ set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS ${pre}BADFLAG${o add_library(LinkFlags_dll SHARED LinkFlagsLib.c) set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS ${pre}BADFLAG${obj}) -add_executable(LinkFlags_exe LinkFlags.c) +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) @@ -22,7 +22,7 @@ set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CO 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 LinkFlags.c) +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/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 index f002eef..9d8d088 100644 --- a/Tests/LinkFlags/LinkFlagsLib.c +++ b/Tests/LinkFlags/LinkFlagsLib.c @@ -1 +1,6 @@ int flags_lib(void) { return 0; } + +/* Intel compiler does not reject bad flags or objects! */ +#if defined(__INTEL_COMPILER) +# error BADFLAG +#endif -- cgit v0.12