+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)