4 # SIMGEAR_FOUND, if false, do not try to link to SimGear
5 # SIMGEAR_INCLUDE_DIR, where to find the headers
7 # $SIMGEAR_DIR is an environment variable that would
8 # correspond to the ./configure --prefix=$SIMGEAR_DIR
9 # used in building SimGear.
11 # Created by James Turner. This was influenced by the FindOpenAL.cmake module.
13 #=============================================================================
14 # Copyright 2005-2009 Kitware, Inc.
16 # Distributed under the OSI-approved BSD License (the "License");
17 # see accompanying file Copyright.txt for details.
19 # This software is distributed WITHOUT ANY WARRANTY; without even the
20 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 # See the License for more information.
22 #=============================================================================
23 # (To distributed this file outside of CMake, substitute the full
24 # License text for the above reference.)
26 # Per my request, CMake should search for frameworks first in
27 # the following order:
28 # ~/Library/Frameworks/SimGear.framework/Headers
29 # /Library/Frameworks/SimGear.framework/Headers
30 # /System/Library/Frameworks/SimGear.framework/Headers
32 # On OS X, this will prefer the Framework version (if found) over others.
33 # People will have to manually change the cache values of
34 # SimGear_LIBRARIES to override this selection or set the CMake environment
35 # CMAKE_INCLUDE_PATH to modify the search paths.
37 FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
38 HINTS $ENV{SIMGEAR_DIR}
48 message(STATUS ${SIMGEAR_INCLUDE_DIR})
50 # check for dynamic framework/library
51 FIND_LIBRARY(SIMGEAR_LIBRARIES
55 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
64 macro(find_sg_component comp libs)
65 set(compLib "sg${comp}")
66 string(TOUPPER "SIMGEAR_${comp}_LIBRARY" compLibName)
68 FIND_LIBRARY(${compLibName}
70 HINTS $ENV{SIMGEAR_DIR}
71 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
78 set(componentLib ${${compLibName}})
79 if (NOT ${componentLib} STREQUAL "componentLib-NOTFOUND")
80 #message(STATUS "found ${componentLib}")
81 list(APPEND ${libs} ${componentLib})
85 if(${SIMGEAR_LIBRARIES} STREQUAL "SIMGEAR_LIBRARIES-NOTFOUND")
86 set(SIMGEAR_LIBRARIES "") # clear value
88 # note the order here affects the order Simgear libraries are
89 # linked in, and hence ability to link when using a traditional
90 # linker such as GNU ld on Linux
115 foreach(component ${comps})
116 find_sg_component(${component} SIMGEAR_LIBRARIES)
120 # now we've found SimGear, check its version
122 include(CheckCXXSourceRuns)
124 message(STATUS "looking for version: ${SimGear_FIND_VERSION}")
126 SET(CMAKE_REQUIRED_INCLUDES ${SIMGEAR_INCLUDE_DIR})
128 check_cxx_source_runs(
130 #include <simgear/version.h>
132 #define xstr(s) str(s)
135 #define MIN_MAJOR ${SimGear_FIND_VERSION_MAJOR}
136 #define MIN_MINOR ${SimGear_FIND_VERSION_MINOR}
137 #define MIN_MICRO ${SimGear_FIND_VERSION_PATCH}
140 int major, minor, micro;
142 /* printf(%d.%d.%d or greater, , MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
143 printf(\"found %s ... \", xstr(SIMGEAR_VERSION));
145 sscanf( xstr(SIMGEAR_VERSION), \"%d.%d.%d\", &major, &minor, µ );
147 if ( (major < MIN_MAJOR) ||
148 (major == MIN_MAJOR && minor < MIN_MINOR) ||
149 (major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO) ) {
158 include(FindPackageHandleStandardArgs)
159 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SimGear DEFAULT_MSG
160 SIMGEAR_LIBRARIES SIMGEAR_INCLUDE_DIR SIMGEAR_VERSION_OK)