From f2e8fd06c2c2db4ff69bfd7449425bd088c6b920 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 27 Nov 2006 16:13:41 -0500 Subject: ENH: make sure things do not depend on optimized libraries if they are debug, and the other way around as well --- Source/cmMakefileTargetGenerator.cxx | 16 +++++++++++++++- Tests/Simple/CMakeLists.txt | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 381df2e..1adff5c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1136,7 +1136,13 @@ void cmMakefileTargetGenerator { return; } - + // Compute which library configuration to link. + cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED; + if(cmSystemTools::UpperCase( + this->LocalGenerator->ConfigurationName.c_str()) == "DEBUG") + { + linkType = cmTarget::DEBUG; + } // Keep track of dependencies already listed. std::set emitted; @@ -1149,6 +1155,14 @@ void cmMakefileTargetGenerator for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin(); lib != tlibs.end(); ++lib) { + // skip the library if it is not general and the link type + // does not match the current target + if(lib->second != cmTarget::GENERAL && + lib->second != linkType) + { + continue; + } + // Don't emit the same library twice for this target. if(emitted.insert(lib->first).second) { diff --git a/Tests/Simple/CMakeLists.txt b/Tests/Simple/CMakeLists.txt index 13abefe..c098224 100644 --- a/Tests/Simple/CMakeLists.txt +++ b/Tests/Simple/CMakeLists.txt @@ -10,3 +10,8 @@ add_library (simpleLib STATIC ) target_link_libraries (simple simpleLib) + +# make sure optimized libs are not used by debug builds +if(CMAKE_BUILD_TYPE MATCHES Debug) + target_link_libraries(simple optimized c:/not/here.lib ) +endif(CMAKE_BUILD_TYPE MATCHES Debug) -- cgit v0.12