-option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
-option(SIMGEAR_HEADLESS "Set to ON to build SimGear with GUI/graphics support" OFF)
-option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
-set(MSVC_3RDPARTY_DIR NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
-
-if (MSVC_3RDPARTY_DIR)
- message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_DIR}")
- set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/lib ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/lib )
- set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/include ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/include)
- set (BOOST_ROOT ${MSVC_3RDPARTY_DIR}/boost_1_44_0)
- set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
- set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
- set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/lib)
-endif (MSVC_3RDPARTY_DIR)
+# 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}")
+
+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_SOURCE_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)
+
+if (MSVC AND MSVC_3RDPARTY_ROOT)
+ message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
+ set( OSG_MSVC "msvc" )
+ if (${MSVC_VERSION} EQUAL 1700)
+ set( OSG_MSVC ${OSG_MSVC}110 )
+ elseif (${MSVC_VERSION} EQUAL 1600)
+ set( OSG_MSVC ${OSG_MSVC}100 )
+ else (${MSVC_VERSION} EQUAL 1700)
+ set( OSG_MSVC ${OSG_MSVC}90 )
+ endif (${MSVC_VERSION} EQUAL 1700)
+ if (CMAKE_CL_64)
+ set( OSG_MSVC ${OSG_MSVC}-64 )
+ set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
+ else (CMAKE_CL_64)
+ set( MSVC_3RDPARTY_DIR 3rdParty )
+ endif (CMAKE_CL_64)
+
+ set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib )
+ set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include)
+ find_path(BOOST_ROOT boost/version.hpp
+ ${MSVC_3RDPARTY_ROOT}/boost
+ ${MSVC_3RDPARTY_ROOT}/boost_1_51_0
+ ${MSVC_3RDPARTY_ROOT}/boost_1_50_0
+ ${MSVC_3RDPARTY_ROOT}/boost_1_49_0
+ ${MSVC_3RDPARTY_ROOT}/boost_1_48_0
+ ${MSVC_3RDPARTY_ROOT}/boost_1_47_0
+ ${MSVC_3RDPARTY_ROOT}/boost_1_46_1
+ ${MSVC_3RDPARTY_ROOT}/boost_1_46_0
+ ${MSVC_3RDPARTY_ROOT}/boost_1_45_0
+ ${MSVC_3RDPARTY_ROOT}/boost_1_44_0
+ )
+ # set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
+ message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
+ set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
+ set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
+endif (MSVC AND MSVC_3RDPARTY_ROOT)