2010-11-30 10:08:30 +00:00
|
|
|
# Locate SimGear
|
|
|
|
# This module defines
|
2011-11-28 18:23:34 +00:00
|
|
|
|
|
|
|
# SIMGEAR_CORE_LIBRARIES, a list of the core static libraries
|
|
|
|
# SIMGEAR_LIBRARIES, a list of all the static libraries (core + scene)
|
2011-09-01 19:05:50 +00:00
|
|
|
# SIMGEAR_FOUND, if false, do not try to link to SimGear
|
2010-11-30 10:08:30 +00:00
|
|
|
# SIMGEAR_INCLUDE_DIR, 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.)
|
|
|
|
|
2011-01-08 14:02:30 +00:00
|
|
|
include(SelectLibraryConfigurations)
|
2010-11-30 10:08:30 +00:00
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
macro(find_sg_library libName varName libs)
|
|
|
|
set(libVarName "${varName}_LIBRARY")
|
2012-02-19 19:20:12 +00:00
|
|
|
# do not cache the library check
|
|
|
|
unset(${libVarName}_DEBUG CACHE)
|
|
|
|
unset(${libVarName}_RELEASE CACHE)
|
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
FIND_LIBRARY(${libVarName}_DEBUG
|
|
|
|
NAMES ${libName}${CMAKE_DEBUG_POSTFIX}
|
2010-12-27 12:44:17 +00:00
|
|
|
HINTS $ENV{SIMGEAR_DIR}
|
2011-11-25 14:31:22 +00:00
|
|
|
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
2010-12-27 12:44:17 +00:00
|
|
|
PATHS
|
|
|
|
/usr/local
|
|
|
|
/usr
|
|
|
|
/opt
|
|
|
|
)
|
2011-11-30 19:19:49 +00:00
|
|
|
FIND_LIBRARY(${libVarName}_RELEASE
|
|
|
|
NAMES ${libName}${CMAKE_RELEASE_POSTFIX}
|
2011-01-08 14:02:30 +00:00
|
|
|
HINTS $ENV{SIMGEAR_DIR}
|
2011-11-25 14:31:22 +00:00
|
|
|
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
2011-01-08 14:02:30 +00:00
|
|
|
PATHS
|
|
|
|
/usr/local
|
|
|
|
/usr
|
|
|
|
/opt
|
|
|
|
)
|
2011-11-30 19:19:49 +00:00
|
|
|
|
|
|
|
# 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)
|
2011-01-08 14:02:30 +00:00
|
|
|
#message(STATUS "found ${componentLib}")
|
|
|
|
list(APPEND ${libs} ${componentLibRelease})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
list(APPEND ${libs} optimized ${componentLibRelease} debug ${componentLibDebug})
|
2010-12-27 12:44:17 +00:00
|
|
|
endif()
|
2010-11-30 10:08:30 +00:00
|
|
|
endmacro()
|
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
macro(find_sg_component comp libs)
|
|
|
|
set(compLib "sg${comp}")
|
|
|
|
string(TOUPPER "SIMGEAR_${comp}" libVar)
|
|
|
|
|
|
|
|
find_sg_library(${compLib} ${libVar} ${libs})
|
|
|
|
endmacro()
|
|
|
|
|
2011-11-28 18:23:34 +00:00
|
|
|
FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
|
|
|
|
HINTS $ENV{SIMGEAR_DIR}
|
|
|
|
PATH_SUFFIXES include
|
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/usr/local
|
|
|
|
/usr
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
2012-02-19 19:20:12 +00:00
|
|
|
# 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}")
|
|
|
|
|
|
|
|
# make sure the simgear/version.h header exists
|
|
|
|
if (NOT EXISTS ${SIMGEAR_INCLUDE_DIR}/simgear/version.h)
|
|
|
|
message(FATAL_ERROR "Found SimGear, but it does not contain a simgear/version.h include! "
|
|
|
|
"SimGear installation is incomplete.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# read the simgear version header file, get the version
|
|
|
|
file(READ ${SIMGEAR_INCLUDE_DIR}/simgear/version.h sgVersionFile)
|
|
|
|
string(STRIP ${sgVersionFile} SIMGEAR_DEFINE)
|
|
|
|
string(REPLACE "#define SIMGEAR_VERSION " "" SIMGEAR_VERSION ${SIMGEAR_DEFINE})
|
|
|
|
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()
|
2011-11-28 18:23:34 +00:00
|
|
|
|
|
|
|
# dependent packages
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
if(SIMGEAR_SHARED)
|
|
|
|
message(STATUS "looking for shared Simgear libraries")
|
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
find_sg_library(SimGearCore SIMGEAR_CORE SIMGEAR_CORE_LIBRARIES)
|
|
|
|
find_sg_library(SimGearScene SIMGEAR_SCENE SIMGEAR_LIBRARIES)
|
2011-11-28 18:23:34 +00:00
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
|
|
|
|
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
|
2011-11-28 18:23:34 +00:00
|
|
|
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES "")
|
2011-11-29 10:24:33 +00:00
|
|
|
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES "")
|
2011-11-28 18:23:34 +00:00
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
# message(STATUS "core lib ${SIMGEAR_CORE_LIBRARIES}")
|
|
|
|
# message(STATUS "all libs ${SIMGEAR_LIBRARIES}")
|
2011-11-28 18:23:34 +00:00
|
|
|
else(SIMGEAR_SHARED)
|
2010-12-27 12:44:17 +00:00
|
|
|
|
|
|
|
set(SIMGEAR_LIBRARIES "") # clear value
|
2011-09-08 12:59:40 +00:00
|
|
|
set(SIMGEAR_CORE_LIBRARIES "") # clear value
|
2012-02-19 19:20:12 +00:00
|
|
|
message(STATUS "looking for static SimGear libraries")
|
2011-09-08 12:59:40 +00:00
|
|
|
|
2010-11-30 10:08:30 +00:00
|
|
|
# note the order here affects the order Simgear libraries are
|
|
|
|
# linked in, and hence ability to link when using a traditional
|
|
|
|
# linker such as GNU ld on Linux
|
2011-09-01 19:05:50 +00:00
|
|
|
set(comps
|
2010-12-27 12:44:17 +00:00
|
|
|
environment
|
|
|
|
nasal
|
2012-02-19 13:33:41 +00:00
|
|
|
tsync
|
2010-12-27 12:44:17 +00:00
|
|
|
bucket
|
2011-09-08 12:59:40 +00:00
|
|
|
route
|
2010-12-27 12:44:17 +00:00
|
|
|
io
|
|
|
|
serial
|
2011-11-26 15:41:35 +00:00
|
|
|
math
|
2010-12-27 12:44:17 +00:00
|
|
|
props
|
2011-11-26 15:41:35 +00:00
|
|
|
structure
|
2012-02-19 13:33:41 +00:00
|
|
|
timing
|
2010-12-27 12:44:17 +00:00
|
|
|
xml
|
|
|
|
misc
|
2011-09-08 12:59:40 +00:00
|
|
|
threads
|
2011-09-01 19:05:50 +00:00
|
|
|
debug
|
2010-12-27 12:44:17 +00:00
|
|
|
magvar
|
2011-11-26 15:41:35 +00:00
|
|
|
)
|
2011-09-01 19:05:50 +00:00
|
|
|
|
2011-09-08 12:59:40 +00:00
|
|
|
set(scene_comps
|
|
|
|
ephem
|
|
|
|
sky
|
|
|
|
material
|
|
|
|
tgdb
|
|
|
|
model
|
2011-11-29 10:24:33 +00:00
|
|
|
screen
|
|
|
|
bvh
|
|
|
|
util
|
|
|
|
sound)
|
2011-09-08 12:59:40 +00:00
|
|
|
|
2010-12-27 12:44:17 +00:00
|
|
|
foreach(component ${comps})
|
2011-09-08 12:59:40 +00:00
|
|
|
find_sg_component(${component} SIMGEAR_CORE_LIBRARIES)
|
|
|
|
endforeach()
|
2011-11-26 15:41:35 +00:00
|
|
|
|
2011-09-08 12:59:40 +00:00
|
|
|
foreach(component ${scene_comps})
|
2010-12-27 12:44:17 +00:00
|
|
|
find_sg_component(${component} SIMGEAR_LIBRARIES)
|
|
|
|
endforeach()
|
2011-09-11 09:22:10 +00:00
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
# again link order matters - scene libraries depend on core ones
|
2011-09-08 12:59:40 +00:00
|
|
|
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
|
2011-09-11 09:22:10 +00:00
|
|
|
|
2011-11-30 19:19:49 +00:00
|
|
|
#message(STATUS "all libs ${SIMGEAR_LIBRARIES}")
|
|
|
|
|
2011-09-11 09:22:10 +00:00
|
|
|
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
2012-02-24 21:23:15 +00:00
|
|
|
${ZLIB_LIBRARY}
|
2012-02-25 00:05:39 +00:00
|
|
|
${LIBSVN_LIBRARIES}
|
|
|
|
${WINMM_LIBRARY})
|
2011-09-11 09:22:10 +00:00
|
|
|
|
2011-11-29 10:24:33 +00:00
|
|
|
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES
|
|
|
|
${ALUT_LIBRARY}
|
2012-02-24 21:23:15 +00:00
|
|
|
${OPENAL_LIBRARY})
|
2011-11-29 10:24:33 +00:00
|
|
|
|
2011-09-11 09:22:10 +00:00
|
|
|
if(WIN32)
|
2011-09-11 10:13:55 +00:00
|
|
|
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ws2_32.lib)
|
2011-09-11 09:22:10 +00:00
|
|
|
endif(WIN32)
|
|
|
|
|
|
|
|
if(NOT MSVC)
|
|
|
|
# basic timing routines on non windows systems, may be also cygwin?!
|
2012-02-24 21:22:14 +00:00
|
|
|
check_library_exists(rt clock_gettime "" have_rt)
|
|
|
|
if(have_rt)
|
|
|
|
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES rt)
|
|
|
|
endif(have_rt)
|
2011-09-11 09:22:10 +00:00
|
|
|
endif(NOT MSVC)
|
2011-11-28 18:23:34 +00:00
|
|
|
endif(SIMGEAR_SHARED)
|
2010-11-30 10:08:30 +00:00
|
|
|
|
2012-02-19 19:20:12 +00:00
|
|
|
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()
|
2010-11-30 10:08:30 +00:00
|
|
|
|
2012-02-19 19:20:12 +00:00
|
|
|
# now we've found SimGear, try test-compiling using its includes
|
2010-11-30 10:08:30 +00:00
|
|
|
include(CheckCXXSourceRuns)
|
|
|
|
|
|
|
|
SET(CMAKE_REQUIRED_INCLUDES ${SIMGEAR_INCLUDE_DIR})
|
|
|
|
|
2012-02-19 19:20:12 +00:00
|
|
|
# clear cache, run a fresh compile test every time
|
|
|
|
unset(SIMGEAR_COMPILE_TEST CACHE)
|
|
|
|
|
2012-02-19 21:12:52 +00:00
|
|
|
# disable OSG dependencies for test-compiling
|
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS "-DNO_OPENSCENEGRAPH_INTERFACE")
|
2010-11-30 10:08:30 +00:00
|
|
|
check_cxx_source_runs(
|
|
|
|
"#include <cstdio>
|
2011-01-03 17:58:15 +00:00
|
|
|
#include \"simgear/version.h\"
|
2012-02-19 19:20:12 +00:00
|
|
|
#include \"simgear/math/SGMath.hxx\"
|
2011-09-01 19:05:50 +00:00
|
|
|
|
2010-11-30 10:08:30 +00:00
|
|
|
#define xstr(s) str(s)
|
|
|
|
#define str(s) #s
|
2011-09-01 19:05:50 +00:00
|
|
|
|
2010-12-27 12:44:17 +00:00
|
|
|
#define MIN_MAJOR ${SimGear_FIND_VERSION_MAJOR}
|
|
|
|
#define MIN_MINOR ${SimGear_FIND_VERSION_MINOR}
|
|
|
|
#define MIN_MICRO ${SimGear_FIND_VERSION_PATCH}
|
2011-09-01 19:05:50 +00:00
|
|
|
|
2010-12-27 12:44:17 +00:00
|
|
|
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, µ );
|
|
|
|
|
2012-02-19 19:20:12 +00:00
|
|
|
if ( (major != MIN_MAJOR) ||
|
|
|
|
(minor != MIN_MINOR) ||
|
|
|
|
(micro != MIN_MICRO) ) {
|
2010-12-27 12:44:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2010-11-30 10:08:30 +00:00
|
|
|
"
|
2012-02-19 19:20:12 +00:00
|
|
|
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()
|
2012-02-19 21:12:52 +00:00
|
|
|
unset(CMAKE_REQUIRED_DEFINITIONS)
|
2010-11-30 10:08:30 +00:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
2011-09-01 19:05:50 +00:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SimGear DEFAULT_MSG
|
2012-02-19 19:20:12 +00:00
|
|
|
SIMGEAR_LIBRARIES SIMGEAR_CORE_LIBRARIES SIMGEAR_INCLUDE_DIR SIMGEAR_COMPILE_TEST)
|
2010-11-30 10:08:30 +00:00
|
|
|
|