+# Change the default build type to something fast
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release CACHE STRING
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+ FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+
+# Determine name of library installation directory, i.e. "lib" vs "lib64", which
+# differs between all Debian-based vs all other Linux distros.
+# See cmake bug #11964, http://cmake.org/gitweb?p=cmake.git;a=commit;h=126c993d
+# GNUInstallDirs requires CMake >= 2.8.5, use own file for older cmake
+if(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
+ include(GNUInstallDirs)
+else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
+ include(OldGNUInstallDirs)
+endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
+message(STATUS "Library installation directory: ${CMAKE_INSTALL_LIBDIR}")
+
+#####################################################################################
+# Configure library search paths
+#####################################################################################
+
+if(NOT "${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
+ # Workaround for Ubuntu/Debian which introduced the "multiarch" library
+ # directory structure, which is unsupported by CMake < 2.8.10, so we need to
+ # add paths manually
+ # see http://www.cmake.org/Bug/view.php?id=12049 and
+ # http://www.cmake.org/Bug/view.php?id=12037
+ list(APPEND ADDITIONAL_LIBRARY_PATHS
+ /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
+ /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
+ /lib/${CMAKE_LIBRARY_ARCHITECTURE})
+ message(STATUS "additional library directories: ${ADDITIONAL_LIBRARY_PATHS}")
+endif()
+
+if(NOT MSVC)
+ # TBD: are these really necessary? Aren't they considered by cmake automatically?
+ list(APPEND ADDITIONAL_LIBRARY_PATHS
+ /opt/local
+ /usr/local
+ /usr)
+endif()
+#####################################################################################
+
+if (NOT MSVC)
+option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
+option(SYSTEM_EXPAT "Set to ON to build SimGear using the system libExpat" OFF)
+else()
+# Building SimGear DLLs is currently not supported for MSVC.
+set(SIMGEAR_SHARED OFF)
+# Using a system expat is currently not supported for MSVC - it would require shared simgear (DLL).
+set(SYSTEM_EXPAT OFF)
+endif()
+
+option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support" OFF)
+option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
+option(ENABLE_LIBSVN "Set to ON to build SimGear with libsvnclient support" ON)
+option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
+option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON)
+option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support" ON)
+
+if (MSVC)
+ GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_BINARY_DIR} PATH)
+ if (CMAKE_CL_64)
+ SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty.x64")
+ else (CMAKE_CL_64)
+ SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty")
+ endif (CMAKE_CL_64)
+ if (EXISTS ${TEST_3RDPARTY_DIR})
+ set(MSVC_3RDPARTY_ROOT ${PARENT_DIR} CACHE PATH "Location where the third-party dependencies are extracted")
+ else (EXISTS ${TEST_3RDPARTY_DIR})
+ set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
+ endif (EXISTS ${TEST_3RDPARTY_DIR})
+else (MSVC)
+ set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
+endif (MSVC)