1
0
Fork 0

Use a Cmake imported target for SimGear

This commit is contained in:
James Turner 2016-01-30 01:59:16 +00:00
parent 06b6c4f513
commit e2f7585d9c
13 changed files with 30 additions and 304 deletions

View file

@ -148,7 +148,6 @@ else()
endif()
# FlightGear build options
option(SIMGEAR_SHARED "Set to ON when SimGear was built as a shared library" OFF)
option(LOGGING "Set to ON to build FlightGear with logging support (default)" ON)
option(JSBSIM_TERRAIN "Set to ON to build FlightGear with JSBSim terrain handling code" ON)
option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" ON)
@ -234,9 +233,7 @@ endif(EVENT_INPUT)
# check required dependencies
find_package(Boost REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(OpenSceneGraph 3.2.0 REQUIRED
osgText
osgSim
@ -262,7 +259,6 @@ endif()
if (SYSTEM_SQLITE)
find_package(SQLite3 REQUIRED)
message(STATUS "Using system SQLite3 library")
else()
set(SQLITE3_INCLUDED_DIR "${CMAKE_SOURCE_DIR}/3rdparty/sqlite3")
@ -308,7 +304,7 @@ endif (ENABLE_QT)
find_package(PLIB REQUIRED puaux pu js fnt)
# FlightGear and SimGear versions need to match
find_package(SimGear ${FLIGHTGEAR_VERSION} REQUIRED)
find_package(SimGear ${FLIGHTGEAR_VERSION} CONFIG REQUIRED)
##############################################################################
@ -383,7 +379,6 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${SIMGEAR_INCLUDE_DIRS}
${PLIB_INCLUDE_DIR}

View file

@ -1,242 +0,0 @@
# Locate SimGear
# This module defines
# SIMGEAR_CORE_LIBRARIES, a list of the core static libraries
# SIMGEAR_LIBRARIES, a list of all the static libraries (core + scene)
# SIMGEAR_FOUND, if false, do not try to link to SimGear
# SIMGEAR_INCLUDE_DIRS, where to find the headers
#
# $SIMGEAR_DIR is an environment variable that would
# correspond to the ./configure --prefix=$SIMGEAR_DIR
# used in building SimGear.
#
# Created by James Turner. This was influenced by the FindOpenAL.cmake module.
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
include(SelectLibraryConfigurations)
macro(find_sg_library libName varName libs)
set(libVarName "${varName}_LIBRARY")
# do not cache the library check
unset(${libVarName}_DEBUG CACHE)
unset(${libVarName}_RELEASE CACHE)
FIND_LIBRARY(${libVarName}_DEBUG
NAMES ${libName}${CMAKE_DEBUG_POSTFIX}
HINTS $ENV{SIMGEAR_DIR}
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
PATHS
${ADDITIONAL_LIBRARY_PATHS}
)
FIND_LIBRARY(${libVarName}_RELEASE
NAMES ${libName}${CMAKE_RELEASE_POSTFIX}
HINTS $ENV{SIMGEAR_DIR}
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
PATHS
${ADDITIONAL_LIBRARY_PATHS}
)
# message(STATUS "before: Simgear ${${libVarName}_RELEASE} ")
# message(STATUS "before: Simgear ${${libVarName}_DEBUG} ")
select_library_configurations( ${varName} )
# message(STATUS "after:Simgear ${${libVarName}_RELEASE} ")
# message(STATUS "after:Simgear ${${libVarName}_DEBUG} ")
set(componentLibRelease ${${libVarName}_RELEASE})
# message(STATUS "Simgear ${libVarName}_RELEASE ${componentLibRelease}")
set(componentLibDebug ${${libVarName}_DEBUG})
# message(STATUS "Simgear ${libVarName}_DEBUG ${componentLibDebug}")
if (NOT ${libVarName}_DEBUG)
if (NOT ${libVarName}_RELEASE)
#message(STATUS "found ${componentLib}")
list(APPEND ${libs} ${componentLibRelease})
endif()
else()
list(APPEND ${libs} optimized ${componentLibRelease} debug ${componentLibDebug})
endif()
endmacro()
FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
HINTS $ENV{SIMGEAR_DIR}
PATH_SUFFIXES include
PATHS
${ADDITIONAL_LIBRARY_PATHS}
)
# make sure the simgear include directory exists
if (NOT SIMGEAR_INCLUDE_DIR)
message(FATAL_ERROR "Cannot find SimGear includes! (Forgot 'make install' for SimGear?) "
"Compile & INSTALL SimGear before configuring FlightGear. "
"When using non-standard locations, use 'SIMGEAR_DIR' to configure the SimGear location.")
endif()
message(STATUS "SimGear include directory: ${SIMGEAR_INCLUDE_DIR}")
# read the simgear version header file, get the version
file(READ ${SIMGEAR_INCLUDE_DIR}/simgear/version.h SG_VERSION_FILE)
# make sure the simgear/version.h header exists
if (NOT SG_VERSION_FILE)
message(FATAL_ERROR "Found SimGear, but it does not contain a simgear/version.h include! "
"SimGear installation is incomplete or mismatching.")
endif()
string(STRIP "${SG_VERSION_FILE}" SIMGEAR_DEFINE)
string(REPLACE "#define SIMGEAR_VERSION " "" SIMGEAR_VERSION "${SIMGEAR_DEFINE}")
if(NOT SIMGEAR_VERSION)
message(FATAL_ERROR "Unable to find SimGear or simgear/version.h does not exist/is invalid. "
"Make sure you have installed the SimGear ${SimGear_FIND_VERSION} includes. "
"When using non-standard locations, please use 'SIMGEAR_DIR' "
"to select the SimGear library location to be used.")
endif()
message(STATUS "found SimGear version: ${SIMGEAR_VERSION} (needed ${SimGear_FIND_VERSION})")
if(NOT "${SIMGEAR_VERSION}" EQUAL "${SimGear_FIND_VERSION}")
message(FATAL_ERROR "You have installed a mismatching SimGear version ${SIMGEAR_VERSION} "
"instead of ${SimGear_FIND_VERSION} as required by FlightGear. "
"When using multiple SimGear installations, please use 'SIMGEAR_DIR' "
"to select the SimGear library location to be used.")
endif()
# dependent packages
find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
if(SIMGEAR_SHARED)
message(STATUS "looking for shared Simgear libraries")
find_sg_library(SimGearCore SIMGEAR_CORE SIMGEAR_CORE_LIBRARIES)
find_sg_library(SimGearScene SIMGEAR_SCENE SIMGEAR_LIBRARIES)
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES "")
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES "")
# message(STATUS "core lib ${SIMGEAR_CORE_LIBRARIES}")
# message(STATUS "all libs ${SIMGEAR_LIBRARIES}")
else(SIMGEAR_SHARED)
set(SIMGEAR_LIBRARIES "") # clear value
set(SIMGEAR_CORE_LIBRARIES "") # clear value
message(STATUS "looking for static SimGear libraries")
find_sg_library(SimGearCore SIMGEAR_CORE SIMGEAR_CORE_LIBRARIES)
find_sg_library(SimGearScene SIMGEAR_SCENE SIMGEAR_LIBRARIES)
# again link order matters - scene libraries depend on core ones
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARY}
${WINMM_LIBRARY})
if (USE_AEONWAVE)
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES
${AAX_LIBRARY})
else()
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES
${OPENAL_LIBRARY})
endif()
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ${COCOA_LIBRARY})
endif()
if(WIN32)
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ws2_32.lib)
endif(WIN32)
if(NOT MSVC)
# basic timing routines on non windows systems, may be also cygwin?!
check_library_exists(rt clock_gettime "" have_rt)
if(have_rt)
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES rt)
endif(have_rt)
endif(NOT MSVC)
endif(SIMGEAR_SHARED)
if((NOT SIMGEAR_CORE_LIBRARIES) OR (NOT SIMGEAR_LIBRARIES))
message(FATAL_ERROR "Cannot find SimGear libraries! (Forgot 'make install' for SimGear?) "
"Compile & INSTALL SimGear before configuring FlightGear. "
"When using non-standard locations, use 'SIMGEAR_DIR' to configure the SimGear location.")
else()
message(STATUS "found SimGear libraries")
endif()
# now we've found SimGear, try test-compiling using its includes
include(CheckCXXSourceRuns)
include(CheckCXXSourceCompiles)
set(SIMGEAR_INCLUDE_DIRS
${SIMGEAR_INCLUDE_DIR}
${SIMGEAR_INCLUDE_DIR}/simgear/3rdparty/utf8
)
SET(CMAKE_REQUIRED_INCLUDES ${SIMGEAR_INCLUDE_DIRS})
# clear cache, run a fresh compile test every time
unset(SIMGEAR_COMPILE_TEST CACHE)
# disable OSG dependencies for test-compiling
set(CMAKE_REQUIRED_DEFINITIONS "-DNO_OPENSCENEGRAPH_INTERFACE")
check_cxx_source_runs(
"#include <cstdio>
#include \"simgear/version.h\"
#include \"simgear/math/SGMath.hxx\"
#define xstr(s) str(s)
#define str(s) #s
#define MIN_MAJOR ${SimGear_FIND_VERSION_MAJOR}
#define MIN_MINOR ${SimGear_FIND_VERSION_MINOR}
#define MIN_MICRO ${SimGear_FIND_VERSION_PATCH}
int main() {
int major, minor, micro;
/* printf(%d.%d.%d or greater, , MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
printf(\"found %s ... \", xstr(SIMGEAR_VERSION));
sscanf( xstr(SIMGEAR_VERSION), \"%d.%d.%d\", &major, &minor, &micro );
if ( (major != MIN_MAJOR) ||
(minor != MIN_MINOR) ||
(micro != MIN_MICRO) ) {
return -1;
}
return 0;
}
"
SIMGEAR_COMPILE_TEST)
if(NOT SIMGEAR_COMPILE_TEST)
message(FATAL_ERROR "Oops, you have installed SimGear includes, however test compiling failed. "
"Try removing 'CMakeCache.txt' and reconfigure with 'cmake'.")
endif()
unset(CMAKE_REQUIRED_DEFINITIONS)
find_package(CURL REQUIRED)
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ${CURL_LIBRARIES})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SimGear DEFAULT_MSG
SIMGEAR_LIBRARIES SIMGEAR_CORE_LIBRARIES SIMGEAR_INCLUDE_DIRS SIMGEAR_COMPILE_TEST)

View file

@ -41,15 +41,9 @@ if(ENABLE_TESTS)
add_executable(yasim yasim-test.cpp ${COMMON})
add_executable(yasim-proptest proptest.cpp ${COMMON})
target_link_libraries(yasim
${SIMGEAR_CORE_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
target_link_libraries(yasim-proptest
${SIMGEAR_CORE_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
target_link_libraries(yasim SimGearCore)
target_link_libraries(yasim-proptest SimGearCore)
install(TARGETS yasim yasim-proptest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif(ENABLE_TESTS)

View file

@ -48,9 +48,8 @@ if(ENABLE_FGJS)
add_executable(fgjs ${FGJS_SOURCES})
target_link_libraries(fgjs
${SIMGEAR_CORE_LIBRARIES}
SimGearCore
${PLIB_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS fgjs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
@ -59,9 +58,8 @@ endif()
if(ENABLE_JS_DEMO)
add_executable(js_demo js_demo.cxx)
target_link_libraries(js_demo
${SIMGEAR_CORE_LIBRARIES}
SimGearCore
${PLIB_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS js_demo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -134,16 +134,14 @@ if(X11_FOUND)
target_link_libraries(fgfs ${X11_LIBRARIES})
endif()
target_link_libraries(fgfs
SimGearCore SimGearScene
${SQLITE3_LIBRARY}
${SIMGEAR_LIBRARIES}
${OPENSCENEGRAPH_LIBRARIES}
${OPENGL_LIBRARIES}
${PLIB_LIBRARIES}
${ZLIB_LIBRARY}
${HLA_LIBRARIES}
${EVENT_INPUT_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
${PLATFORM_LIBS}
)
@ -168,9 +166,7 @@ endif()
if(ENABLE_METAR)
add_executable(metar metar_main.cxx)
target_link_libraries(metar
${SIMGEAR_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
SimGearScene SimGearCore
${PLATFORM_LIBS}
)

View file

@ -17,22 +17,19 @@ add_executable(UGsmooth
)
target_link_libraries(GPSsmooth
${SIMGEAR_CORE_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
SimGearCore
${PLIB_SG_LIBRARY}
${PLIB_UL_LIBRARY}
)
target_link_libraries(MIDGsmooth
${SIMGEAR_CORE_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
SimGearCore
${PLIB_SG_LIBRARY}
${PLIB_UL_LIBRARY}
)
target_link_libraries(UGsmooth
${SIMGEAR_CORE_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
SimGearCore
${PLIB_SG_LIBRARY}
${PLIB_UL_LIBRARY}
${ZLIB_LIBRARY}

View file

@ -1,9 +1,6 @@
#add_executable(terrasync terrasync.cxx)
#target_link_libraries(terrasync
# ${SIMGEAR_CORE_LIBRARIES}
# ${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
#)
#target_link_libraries(terrasync SimGearCore)
#install(TARGETS terrasync RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -18,11 +18,10 @@ add_executable(fgai
)
target_link_libraries(fgai
${SIMGEAR_LIBRARIES}
SimGearCore SimGearScene
${OPENSCENEGRAPH_LIBRARIES}
${OPENGL_LIBRARIES}
${RTI_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS fgai RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -1,5 +1,7 @@
set(name fgcom)
find_package(OpenAL REQUIRED)
# Copy positions.txt content in const char* _positionsData[];
file(READ utils/positions.txt POSITIONS_DATA)
string(REGEX REPLACE "\n" "\"%
@ -27,8 +29,7 @@ add_executable(${name}
target_link_Libraries(${name}
iaxclient_lib
${OPENAL_LIBRARY}
${SIMGEAR_CORE_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
SimGearCore
)
install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -1,11 +1,7 @@
add_executable(fgelev fgelev.cxx)
target_link_libraries(fgelev
${SIMGEAR_LIBRARIES}
${OPENSCENEGRAPH_LIBRARIES}
${OPENGL_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
${ZLIB_LIBRARY}
SimGearScene SimGearCore
)
install(TARGETS fgelev RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -27,10 +27,9 @@ if(GLUT_FOUND)
target_link_libraries(fgpanel
${PNG_LIBRARIES}
${GLUT_LIBRARIES}
${SIMGEAR_CORE_LIBRARIES}
SimGearCore
${OPENGL_LIBRARIES}
${PLIB_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
include_directories(${PNG_INCLUDE_DIR})

View file

@ -47,10 +47,7 @@ if(X11_FOUND)
endif()
target_link_libraries(fgviewer
${SIMGEAR_LIBRARIES}
${OPENSCENEGRAPH_LIBRARIES}
${OPENGL_LIBRARIES}
SimGearScene SimGearCore
${FGVIEWER_RTI_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS fgviewer RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -1,10 +1,9 @@
add_executable(stgmerge stgmerge.cxx)
target_link_libraries(stgmerge
${SIMGEAR_LIBRARIES}
SimGearScene
${OPENSCENEGRAPH_LIBRARIES}
${OPENGL_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
)
install(TARGETS stgmerge RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})