From b7b35d2c5aab37c83a77e016de5e01bfaef4eff7 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 14 Jul 2005 12:21:49 -0400 Subject: [PATCH] FIX: fix bug 2043 borland compiler and dll problem and add a test for it --- Source/cmLocalUnixMakefileGenerator3.cxx | 23 ++++++++++--------- .../OutOfSourceSubdir/CMakeLists.txt | 3 +++ .../OutOfSource/OutOfSourceSubdir/simple.cxx | 6 +++++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index c78317c68..3adca7ffb 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1370,11 +1370,7 @@ cmLocalUnixMakefileGenerator3 // Build a list of compiler flags and linker flags. std::string flags; std::string linkFlags; - - // Add flags to create an executable. - this->AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS"); - - +#if 0 // Loop over all libraries and see if all are shared const cmTarget::LinkLibraries& tlibs = target.GetLinkLibraries(); int AllShared = 2; // 0 = false, 1 = true, 2 = unknown @@ -1395,7 +1391,6 @@ cmLocalUnixMakefileGenerator3 } } } - // if all libs were shared then add the special borland flag for linking an // executable to only shared libs if(AllShared == 1) @@ -1403,6 +1398,17 @@ cmLocalUnixMakefileGenerator3 this->AppendFlags (linkFlags,m_Makefile->GetDefinition("CMAKE_SHARED_BUILD_CXX_FLAGS")); } +#endif + // Add flags to deal with shared libraries. Any library being + // linked in might be shared, so always use shared flags for an + // executable. + this->AddSharedFlags(linkFlags, linkLanguage, true); + + // Add flags to create an executable. + this->AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS"); + + + if(target.GetPropertyAsBool("WIN32_EXECUTABLE")) { this->AppendFlags(linkFlags, @@ -1417,11 +1423,6 @@ cmLocalUnixMakefileGenerator3 // Add language-specific flags. this->AddLanguageFlags(flags, linkLanguage); - // Add flags to deal with shared libraries. Any library being - // linked in might be shared, so always use shared flags for an - // executable. - this->AddSharedFlags(flags, linkLanguage, true); - // Add target-specific linker flags. this->AppendFlags(linkFlags, target.GetProperty("LINK_FLAGS")); diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt index f3d378531..412a1ca02 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt +++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt @@ -1,4 +1,7 @@ IF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") + SET(BUILD_SHARED_LIBS 1) + ADD_LIBRARY(testlib testlib.cxx) ADD_EXECUTABLE (simple simple.cxx) + TARGET_LINK_LIBRARIES(simple testlib) ENDIF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx index 1482f27e5..cfb1f1ab6 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx +++ b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx @@ -1,4 +1,10 @@ +#include "testlib.h" + int main () { + if(TestLib() != 1.0) + { + return -1; + } return 0; }