# 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_DIR, where to find the headers
+# SIMGEAR_INCLUDE_DIRS, where to find the headers
#
# $SIMGEAR_DIR is an environment variable that would
# correspond to the ./configure --prefix=$SIMGEAR_DIR
HINTS $ENV{SIMGEAR_DIR}
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
PATHS
- /usr/local
- /usr
- /opt
+ ${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
- /usr/local
- /usr
- /opt
+ ${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 "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}")
endif()
endmacro()
-macro(find_sg_component comp libs)
- set(compLib "sg${comp}")
- string(TOUPPER "SIMGEAR_${comp}" libVar)
-
- find_sg_library(${compLib} ${libVar} ${libs})
-endmacro()
-
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
+ ${ADDITIONAL_LIBRARY_PATHS}
)
# make sure the simgear include directory exists
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 EXISTS ${SIMGEAR_INCLUDE_DIR}/simgear/version.h)
+if (NOT SG_VERSION_FILE)
message(FATAL_ERROR "Found SimGear, but it does not contain a simgear/version.h include! "
- "SimGear installation is incomplete.")
+ "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()
-# 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})
+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' "
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")
-
- # 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
- set(comps
- environment
- nasal
- tsync
- bucket
- io
- serial
- math
- props
- structure
- timing
- xml
- misc
- threads
- debug
- magvar
- )
- set(scene_comps
- ephem
- sky
- material
- tgdb
- model
- screen
- bvh
- util
- sound)
-
- foreach(component ${comps})
- find_sg_component(${component} SIMGEAR_CORE_LIBRARIES)
- endforeach()
-
- foreach(component ${scene_comps})
- find_sg_component(${component} SIMGEAR_LIBRARIES)
- endforeach()
+ 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})
- #message(STATUS "all libs ${SIMGEAR_LIBRARIES}")
-
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARY}
- ${LIBSVN_LIBRARIES}
${WINMM_LIBRARY})
- set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES
- ${ALUT_LIBRARY}
+ set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES
${OPENAL_LIBRARY})
+ 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)
endif(NOT MSVC)
endif(SIMGEAR_SHARED)
-if((NOT SIMGEAR_CORE_LIBRARIES)OR(NOT SIMGEAR_LIBRARIES))
+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.")
# now we've found SimGear, try test-compiling using its includes
include(CheckCXXSourceRuns)
+include(CheckCXXSourceCompiles)
-SET(CMAKE_REQUIRED_INCLUDES ${SIMGEAR_INCLUDE_DIR})
+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)
endif()
unset(CMAKE_REQUIRED_DEFINITIONS)
+unset(SIMGEAR_CURL_TEST CACHE)
+check_cxx_source_compiles("
+ #include \"simgear/simgear_config.h\"
+ #if !defined(ENABLE_CURL)
+ #error Curl not enabled
+ #endif
+ int main() {}
+"
+SIMGEAR_CURL_TEST)
+
+if (SIMGEAR_CURL_TEST)
+ message(STATUS "SimGear uses Curl")
+ find_package(CURL REQUIRED)
+ list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ${CURL_LIBRARIES})
+endif()
+
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SimGear DEFAULT_MSG
- SIMGEAR_LIBRARIES SIMGEAR_CORE_LIBRARIES SIMGEAR_INCLUDE_DIR SIMGEAR_COMPILE_TEST)
-
+ SIMGEAR_LIBRARIES SIMGEAR_CORE_LIBRARIES SIMGEAR_INCLUDE_DIRS SIMGEAR_COMPILE_TEST)