]> git.mxchange.org Git - simgear.git/commitdiff
fix static build with recent GNU binutils
authorStanislaw Halik <sthalik@misaki.pl>
Wed, 2 Oct 2013 15:18:21 +0000 (17:18 +0200)
committerJames Turner <zakalawe@mac.com>
Thu, 3 Oct 2013 20:49:38 +0000 (21:49 +0100)
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
CMakeLists.txt
simgear/CMakeLists.txt

index 2617f6e4fc4887217ec1fe3cfcce14eb26d9a1a9..3bbee824566ec92a6d44383be3d6400864ad733d 100644 (file)
@@ -267,6 +267,20 @@ if(HAVE_CLOCK_GETTIME)
     endif(HAVE_RT)
 endif(HAVE_CLOCK_GETTIME)
 
+set(DL_LIBRARY "")
+check_cxx_source_compiles(
+    "#include <dlfcn.h>
+    int main(void) {
+        return 0;
+    }
+    "
+    HAVE_DLFCN_H)
+
+if(HAVE_DLFCN_H)
+    check_library_exists(dl dlerror "" HAVE_DL)
+    set(DL_LIBRARY "dl")
+endif()
+
 SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually 'd' on windows")
 SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
 SET(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
@@ -360,25 +374,17 @@ else()
 endif(ENABLE_TESTS)
 
 # always set TEST_LIBS as it is also used by other tools/applications
-# TODO maybe better rename?
-if(SIMGEAR_SHARED)
-    set( TEST_LIBS
-        SimGearCore)
-else()
-    set( TEST_LIBS
-        SimGearCore
-        ${CMAKE_THREAD_LIBS_INIT}
-        ${ZLIB_LIBRARY}
-        ${WINSOCK_LIBRARY}
-        ${RT_LIBRARY}
-        ${CORE_SERVICES_LIBRARY})
-endif()
+set(TEST_LIBS_INTERNAL_CORE
+    ${CMAKE_THREAD_LIBS_INIT}
+    ${ZLIB_LIBRARY}
+    ${WINSOCK_LIBRARY}
+    ${RT_LIBRARY}
+    ${DL_LIBRARY}
+    ${CORE_SERVICES_LIBRARY})
+set(TEST_LIBS SimGearCore ${TEST_LIBS_INTERNAL_CORE})
 
 if(NOT SIMGEAR_HEADLESS)
-    set( TEST_LIBS
-        SimGearScene
-        ${TEST_LIBS}
-        ${OPENGL_LIBRARIES})
+    set(TEST_LIBS SimGearScene ${OPENGL_LIBRARIES} ${TEST_LIBS})
 endif()
 
 install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h  DESTINATION include/simgear/)
index 1d1e4bcc6b35707773bdc66a3c01618c3ce68e4a..27f8cb3efeba09cba254cadef9ef7ab802748764 100644 (file)
@@ -59,12 +59,6 @@ if(SIMGEAR_SHARED)
     set_property(TARGET SimGearCore PROPERTY VERSION   ${SIMGEAR_VERSION})
     set_property(TARGET SimGearCore PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
 
-    target_link_libraries(SimGearCore ${ZLIB_LIBRARY} ${RT_LIBRARY} 
-        ${LibArchive_LIBRARIES}
-        ${EXPAT_LIBRARIES}
-        ${CMAKE_THREAD_LIBS_INIT}
-        ${CORE_SERVICES_LIBRARY})
-
     if(NOT SIMGEAR_HEADLESS)
         add_library(SimGearScene SHARED ${sceneSources})
       # set_property(TARGET SimGearScene PROPERTY FRAMEWORK 1)
@@ -73,14 +67,6 @@ if(SIMGEAR_SHARED)
         set_property(TARGET SimGearScene PROPERTY VERSION   ${SIMGEAR_VERSION})
         set_property(TARGET SimGearScene PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
 
-        target_link_libraries(SimGearScene
-            SimGearCore
-            ${ZLIB_LIBRARY}
-            ${OPENSCENEGRAPH_LIBRARIES}
-            ${OPENAL_LIBRARY}
-            ${OPENGL_LIBRARY}
-            ${JPEG_LIBRARY})
-    
         install(TARGETS SimGearScene LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif()
     
@@ -133,6 +119,25 @@ else()
     endif(NOT SIMGEAR_HEADLESS)
 endif(SIMGEAR_SHARED)
 
+target_link_libraries(SimGearCore
+    ${ZLIB_LIBRARY}
+    ${RT_LIBRARY}
+    ${DL_LIBRARY}
+    ${LibArchive_LIBRARIES}
+    ${EXPAT_LIBRARIES}
+    ${CMAKE_THREAD_LIBS_INIT}
+    ${CORE_SERVICES_LIBRARY})
+
+if(NOT SIMGEAR_HEADLESS)
+    target_link_libraries(SimGearScene
+        SimGearCore
+        ${ZLIB_LIBRARY}
+        ${OPENSCENEGRAPH_LIBRARIES}
+        ${OPENAL_LIBRARY}
+        ${OPENGL_LIBRARY}
+        ${JPEG_LIBRARY})
+endif()
+
 if(ENABLE_RTI)
     # Ugly first aid to make hla compile agian
     set_property(SOURCE hla/RTI13InteractionClass.cxx hla/RTI13ObjectClass.cxx