summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-06-21 20:23:54 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-06-21 20:23:54 (GMT)
commit1383368628411f3834e2e29e81be306db74c610f (patch)
tree5dc8ec712f63accdd7c2321695e4e5134bfa2215
parent7f1fbe4e4c3ab8debde333e80e697208407c0a64 (diff)
downloadCMake-1383368628411f3834e2e29e81be306db74c610f.zip
CMake-1383368628411f3834e2e29e81be306db74c610f.tar.gz
CMake-1383368628411f3834e2e29e81be306db74c610f.tar.bz2
ENH: print a warning if ADD_LIBRARY( SHARED/MODULE ) is used and the target
platform doesn't support shared libraries Alex
-rw-r--r--Modules/CMakeGenericSystem.cmake3
-rw-r--r--Modules/Platform/Generic.cmake4
-rw-r--r--Source/cmAddLibraryCommand.cxx16
3 files changed, 23 insertions, 0 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index 897969a..2af179d 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -19,6 +19,9 @@ SET(CMAKE_DL_LIBS "dl")
SET(CMAKE_FIND_LIBRARY_PREFIXES "lib")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
+# basically all general purpose OSs support shared libs
+SET(CMAKE_TARGET_SUPPORTS_ONLY_STATIC_LIBS FALSE)
+
SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL
"If set, runtime paths are not added when using shared libraries.")
diff --git a/Modules/Platform/Generic.cmake b/Modules/Platform/Generic.cmake
index fdced24..9c78745 100644
--- a/Modules/Platform/Generic.cmake
+++ b/Modules/Platform/Generic.cmake
@@ -6,3 +6,7 @@
# about the platform. So everything has to be specified
# in the system/compiler files ${CMAKE_SYSTEM_NAME}-<compiler_basename>.cmake
# and/or ${CMAKE_SYSTEM_NAME}-<compiler_basename>-${CMAKE_SYSTEM_PROCESSOR}.cmake
+
+# (embedded) targets without operating system usually don't support shared libraries
+SET(CMAKE_TARGET_SUPPORTS_ONLY_STATIC_LIBS TRUE)
+
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 09e3774..bdf59ad 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -77,6 +77,22 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
cmSystemTools::Message(msg.c_str() ,"Warning");
}
+ /* ideally we should check whether for the linker language of the target
+ CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
+ STATIC. But at this point we know only the name of the target, but not
+ yet its linker language. */
+ if ((shared != 0) &&
+ (this->Makefile->IsOn("CMAKE_TARGET_SUPPORTS_ONLY_STATIC_LIBS")))
+ {
+ std::string msg = "ADD_LIBRARY for library ";
+ msg += args[0];
+ msg += " is used with the SHARED or MODULE option, but the target "
+ "platform supports only STATIC libraries. Building it STATIC instead. "
+ "This may lead to problems.";
+ cmSystemTools::Message(msg.c_str() ,"Warning");
+ shared = 0;
+ }
+
std::vector<std::string> srclists;
while (s != args.end())
{