summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/Platform/Darwin.cmake2
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx22
-rw-r--r--Source/cmMakefileTargetGenerator.cxx22
-rw-r--r--Source/cmMakefileTargetGenerator.h3
4 files changed, 44 insertions, 5 deletions
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 71b5f3c..1c49198 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -24,6 +24,8 @@ IF(NOT XCODE)
SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-install_name")
ENDIF(NOT XCODE)
+SET(CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w)
+SET(CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w)
SET(CMAKE_C_CREATE_SHARED_LIBRARY
"<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> -install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 60303ea..4ae00db 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -246,16 +246,23 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Add the link message.
std::string buildEcho = "Linking ";
buildEcho += linkLanguage;
+ const char* forbiddenFlagVar = 0;
switch(this->Target->GetType())
{
case cmTarget::STATIC_LIBRARY:
- buildEcho += " static library "; break;
+ buildEcho += " static library ";
+ break;
case cmTarget::SHARED_LIBRARY:
- buildEcho += " shared library "; break;
+ forbiddenFlagVar = "_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS";
+ buildEcho += " shared library ";
+ break;
case cmTarget::MODULE_LIBRARY:
- buildEcho += " shared module "; break;
+ forbiddenFlagVar = "_CREATE_SHARED_MODULE_FORBIDDEN_FLAGS";
+ buildEcho += " shared module ";
+ break;
default:
- buildEcho += " library "; break;
+ buildEcho += " library ";
+ break;
}
buildEcho += targetOutPath.c_str();
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str());
@@ -436,6 +443,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
this->LocalGenerator
->AddLanguageFlags(langFlags, linkLanguage,
this->LocalGenerator->m_ConfigurationName.c_str());
+ // remove any language flags that might not work with the
+ // particular os
+ if(forbiddenFlagVar)
+ {
+ this->RemoveForbiddenFlags(forbiddenFlagVar,
+ linkLanguage, langFlags);
+ }
vars.LanguageCompileFlags = langFlags.c_str();
// Expand placeholders in the commands.
this->LocalGenerator->m_TargetImplib = targetOutPathImport;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 3ec828b..842c6eb 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -799,3 +799,25 @@ void cmMakefileTargetGenerator
delete this->InfoFileStream;
delete this->FlagFileStream;
}
+
+void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
+ const char* linkLang,
+ std::string& linkFlags)
+{
+ // check for language flags that are not allowed at link time, and
+ // remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool
+ // which fails, there may be more]
+
+ std::string removeFlags = "CMAKE_";
+ removeFlags += linkLang;
+ removeFlags += flagVar;
+ std::string removeflags =
+ this->Makefile->GetSafeDefinition(removeFlags.c_str());
+ std::vector<std::string> removeList;
+ cmSystemTools::ExpandListArgument(removeflags, removeList);
+ for(std::vector<std::string>::iterator i = removeList.begin();
+ i != removeList.end(); ++i)
+ {
+ cmSystemTools::ReplaceString(linkFlags, i->c_str(), "");
+ }
+}
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index cbc67ca..9bc2345 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -99,7 +99,8 @@ protected:
void AppendTargetDepends(std::vector<std::string>& depends);
virtual void CloseFileStreams();
-
+ void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
+ std::string& linkFlags);
cmStdString TargetName;
cmTarget *Target;
cmLocalUnixMakefileGenerator3 *LocalGenerator;