4 # SIMGEAR_CORE_LIBRARIES, a list of the core static libraries
5 # SIMGEAR_LIBRARIES, a list of all the static libraries (core + scene)
6 # SIMGEAR_FOUND, if false, do not try to link to SimGear
7 # SIMGEAR_INCLUDE_DIR, where to find the headers
9 # $SIMGEAR_DIR is an environment variable that would
10 # correspond to the ./configure --prefix=$SIMGEAR_DIR
11 # used in building SimGear.
13 # Created by James Turner. This was influenced by the FindOpenAL.cmake module.
15 #=============================================================================
16 # Copyright 2005-2009 Kitware, Inc.
18 # Distributed under the OSI-approved BSD License (the "License");
19 # see accompanying file Copyright.txt for details.
21 # This software is distributed WITHOUT ANY WARRANTY; without even the
22 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 # See the License for more information.
24 #=============================================================================
25 # (To distributed this file outside of CMake, substitute the full
26 # License text for the above reference.)
28 include(SelectLibraryConfigurations)
30 macro(find_sg_component comp libs)
31 set(compLib "sg${comp}")
32 string(TOUPPER "SIMGEAR_${comp}" compLibBase)
33 set( compLibName ${compLibBase}_LIBRARY )
35 FIND_LIBRARY(${compLibName}_DEBUG
36 NAMES ${compLib}${CMAKE_DEBUG_POSTFIX}
37 HINTS $ENV{SIMGEAR_DIR}
38 PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
44 FIND_LIBRARY(${compLibName}_RELEASE
45 NAMES ${compLib}${CMAKE_RELEASE_POSTFIX}
46 HINTS $ENV{SIMGEAR_DIR}
47 PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
53 select_library_configurations( ${compLibBase} )
55 set(componentLibRelease ${${compLibName}_RELEASE})
56 #message(STATUS "Simgear ${compLibName}_RELEASE ${componentLibRelease}")
57 set(componentLibDebug ${${compLibName}_DEBUG})
58 #message(STATUS "Simgear ${compLibName}_DEBUG ${componentLibDebug}")
59 if (NOT ${compLibName}_DEBUG)
60 if (NOT ${compLibName}_RELEASE)
61 #message(STATUS "found ${componentLib}")
62 list(APPEND ${libs} ${componentLibRelease})
65 list(APPEND ${libs} optimized ${componentLibRelease} debug ${componentLibDebug})
69 FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
70 HINTS $ENV{SIMGEAR_DIR}
80 message(STATUS ${SIMGEAR_INCLUDE_DIR})
83 find_package(ZLIB REQUIRED)
84 find_package(Threads REQUIRED)
87 message(STATUS "looking for shared Simgear libraries")
89 # check for dynamic framework/library (experimental!)
90 FIND_LIBRARY(SIMGEAR_SHARED_CORE_LIBRARY
91 NAMES simgearCore SimGearCore
94 PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
103 FIND_LIBRARY(SIMGEAR_SHARED_SCENE_LIBRARY
104 NAMES simgearScene SimGearScene
107 PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
116 set(SIMGEAR_CORE_LIBRARIES ${SIMGEAR_SHARED_CORE_LIBRARY})
117 set(SIMGEAR_LIBRARIES ${SIMGEAR_SHARED_SCENE_LIBRARY} ${SIMGEAR_SHARED_CORE_LIBRARY})
118 set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES "")
122 set(SIMGEAR_LIBRARIES "") # clear value
123 set(SIMGEAR_CORE_LIBRARIES "") # clear value
124 message(STATUS "looking for static Simgear libraries")
126 # note the order here affects the order Simgear libraries are
127 # linked in, and hence ability to link when using a traditional
128 # linker such as GNU ld on Linux
159 foreach(component ${comps})
160 find_sg_component(${component} SIMGEAR_CORE_LIBRARIES)
163 foreach(component ${scene_comps})
164 find_sg_component(${component} SIMGEAR_LIBRARIES)
167 # again link order matters - scene libraires depend on core ones
168 list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
170 set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
171 ${CMAKE_THREAD_LIBS_INIT}
175 list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ws2_32.lib)
179 # basic timing routines on non windows systems, may be also cygwin?!
180 check_function_exists(clock_gettime clock_gettime_in_libc)
181 if(NOT clock_gettime_in_libc)
182 check_library_exists(rt clock_gettime "" have_rt)
184 list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES rt)
186 endif(NOT clock_gettime_in_libc)
188 endif(SIMGEAR_SHARED)
190 # now we've found SimGear, check its version
192 include(CheckCXXSourceRuns)
194 message(STATUS "looking for version: ${SimGear_FIND_VERSION}")
196 SET(CMAKE_REQUIRED_INCLUDES ${SIMGEAR_INCLUDE_DIR})
198 check_cxx_source_runs(
200 #include \"simgear/version.h\"
202 #define xstr(s) str(s)
205 #define MIN_MAJOR ${SimGear_FIND_VERSION_MAJOR}
206 #define MIN_MINOR ${SimGear_FIND_VERSION_MINOR}
207 #define MIN_MICRO ${SimGear_FIND_VERSION_PATCH}
210 int major, minor, micro;
212 /* printf(%d.%d.%d or greater, , MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
213 printf(\"found %s ... \", xstr(SIMGEAR_VERSION));
215 sscanf( xstr(SIMGEAR_VERSION), \"%d.%d.%d\", &major, &minor, µ );
217 if ( (major < MIN_MAJOR) ||
218 (major == MIN_MAJOR && minor < MIN_MINOR) ||
219 (major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO) ) {
228 include(FindPackageHandleStandardArgs)
229 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SimGear DEFAULT_MSG
230 SIMGEAR_LIBRARIES SIMGEAR_INCLUDE_DIR SIMGEAR_VERSION_OK)