1
0
Fork 0

cmake: Factor out common simgear dependency libs.

Factor out and use this core simgear depenency
library cmake variable.
This commit is contained in:
Mathias Froehlich 2011-09-11 11:22:10 +02:00
parent 099bfd988b
commit 549c5eccb9
10 changed files with 43 additions and 62 deletions

View file

@ -158,33 +158,6 @@ check_cxx_source_compiles(
"
HAVE_CULLSETTINGS_CLEAR_MASK)
# library required by simgear
# XXX This should go in a module and only run if simgear is not shared.
if(HAVE_UNISTD_H)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
check_cxx_source_compiles(
"#include <unistd.h>
#if !defined(_POSIX_TIMERS) || (0 >= _POSIX_TIMERS)
#error clock_gettime is not supported
#endif
int main() { return 0; }
"
HAVE_CLOCK_GETTIME)
endif(HAVE_UNISTD_H)
set(RT_LIBRARY "")
if(HAVE_CLOCK_GETTIME)
check_function_exists(clock_gettime CLOCK_GETTIME_IN_LIBC)
if(NOT CLOCK_GETTIME_IN_LIBC)
check_library_exists(rt clock_gettime "" HAVE_RT)
if(HAVE_RT)
set(RT_LIBRARY rt)
endif(HAVE_RT)
endif(NOT CLOCK_GETTIME_IN_LIBC)
endif(HAVE_CLOCK_GETTIME)
if(ENABLE_RTI)
find_package(RTI)
if(RTI_FOUND)
@ -211,7 +184,6 @@ if(WIN32)
endif(MSVC)
set(NOMINMAX 1)
set( WINSOCK_LIBRARY "ws2_32.lib" )
endif(WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
@ -219,9 +191,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTR
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${ALUT_INCLUDE_DIR}
${ALUT_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
${SIMGEAR_INCLUDE_DIR}
${PLIB_INCLUDE_DIR} )

View file

@ -63,6 +63,10 @@ FIND_LIBRARY(SIMGEAR_LIBRARIES
/opt
)
# dependent packages
find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
macro(find_sg_component comp libs)
set(compLib "sg${comp}")
string(TOUPPER "SIMGEAR_${comp}" compLibBase)
@ -146,9 +150,29 @@ if(${SIMGEAR_LIBRARIES} STREQUAL "SIMGEAR_LIBRARIES-NOTFOUND")
foreach(component ${scene_comps})
find_sg_component(${component} SIMGEAR_LIBRARIES)
endforeach()
# again link order matters - scene libraires depend on core ones
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARY})
if(WIN32)
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ${WINSOCK_LIBRARY})
endif(WIN32)
if(NOT MSVC)
# basic timing routines on non windows systems, may be also cygwin?!
check_function_exists(clock_gettime clock_gettime_in_libc)
if(NOT clock_gettime_in_libc)
check_library_exists(rt clock_gettime "" have_rt)
if(have_rt)
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES rt)
endif(have_rt)
endif(NOT clock_gettime_in_libc)
endif(NOT MSVC)
endif()
# now we've found SimGear, check its version

View file

@ -38,7 +38,7 @@ add_executable(yasim yasim-test.cpp)
target_link_libraries(yasim
fgYASim
${SIMGEAR_CORE_LIBRARIES}
${ZLIB_LIBRARIES})
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
install(TARGETS yasim RUNTIME DESTINATION bin)

View file

@ -31,22 +31,17 @@ set(FGJS_SOURCES
add_executable(fgjs ${FGJS_SOURCES})
if(WIN32)
set(SOCKETS_LIBRARY wsock32.lib)
endif(WIN32)
target_link_libraries(fgjs
${SIMGEAR_CORE_LIBRARIES}
${SOCKETS_LIBRARY}
${PLIB_LIBRARIES}
${ZLIB_LIBRARY})
${PLIB_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
add_executable(js_demo js_demo.cxx)
target_link_libraries(js_demo
${SIMGEAR_CORE_LIBRARIES}
${PLIB_LIBRARIES}
${ZLIB_LIBRARY})
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
flightgear_component(Input "${SOURCES}")

View file

@ -71,16 +71,15 @@ endif()
target_link_libraries(fgfs
${FG_LIBS}
${HLA_LIBRARIES}
${SIMGEAR_LIBRARIES}
${OPENSCENEGRAPH_LIBRARIES}
${OPENAL_LIBRARY}
${OPENGL_LIBRARIES}
${ALUT_LIBRARY}
${ZLIB_LIBRARIES}
${PLIB_LIBRARIES}
${LIBSVN_LIBRARIES}
${WINSOCK_LIBRARY}
${RT_LIBRARY})
${HLA_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS fgfs RUNTIME DESTINATION bin)

View file

@ -7,11 +7,8 @@ target_link_libraries(GPSsmooth
${SIMGEAR_CORE_LIBRARIES}
${PLIB_SG_LIBRARY}
${PLIB_UL_LIBRARY}
${ZLIB_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
${WINMM_LIBRARY}
${WINSOCK_LIBRARY}
${ZLIB_LIBRARIES}
${RT_LIBRARY}
)
target_link_libraries(MIDGsmooth
@ -19,8 +16,7 @@ target_link_libraries(MIDGsmooth
${PLIB_SG_LIBRARY}
${PLIB_UL_LIBRARY}
${WINMM_LIBRARY}
${WINSOCK_LIBRARY}
${RT_LIBRARY}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
target_link_libraries(UGsmooth
@ -28,9 +24,7 @@ target_link_libraries(UGsmooth
${PLIB_SG_LIBRARY}
${PLIB_UL_LIBRARY}
${WINMM_LIBRARY}
${WINSOCK_LIBRARY}
${ZLIB_LIBRARIES}
${RT_LIBRARY}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS GPSsmooth MIDGsmooth UGsmooth RUNTIME DESTINATION bin)

View file

@ -4,9 +4,8 @@ add_executable(terrasync terrasync.cxx)
target_link_libraries(terrasync
${SIMGEAR_CORE_LIBRARIES}
${ZLIB_LIBRARIES}
${WINSOCK_LIBRARY}
${RT_LIBRARY})
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
if(LIBSVN_FOUND)
target_link_libraries(terrasync ${LIBSVN_LIBRARIES})

View file

@ -7,9 +7,9 @@ add_dependencies(fgadmin FGAdminUI)
target_link_libraries(fgadmin FGAdminUI
${SIMGEAR_LIBRARIES}
${ZLIB_LIBRARIES}
${PLIB_LIBRARIES}
${FLTK_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS fgadmin RUNTIME DESTINATION bin)

View file

@ -20,10 +20,8 @@ if(GLUT_FOUND)
${GLUT_LIBRARIES}
${SIMGEAR_CORE_LIBRARIES}
${OPENGL_LIBRARIES}
${ZLIB_LIBRARIES}
${PLIB_LIBRARIES}
${WINSOCK_LIBRARY}
${RT_LIBRARY}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS fgpanel RUNTIME DESTINATION bin)

View file

@ -5,8 +5,8 @@ target_link_libraries(fgviewer
${SIMGEAR_LIBRARIES}
${OPENSCENEGRAPH_LIBRARIES}
${OPENGL_LIBRARIES}
${ZLIB_LIBRARIES}
${PLIB_LIBRARIES}
${RT_LIBRARY})
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS fgviewer RUNTIME DESTINATION bin)