2011-09-11 19:44:43 +00:00
cmake_minimum_required (VERSION 2.6.4)
2010-11-30 10:08:30 +00:00
include (CheckFunctionExists)
include (CheckCSourceCompiles)
2010-12-25 23:44:02 +00:00
include (CheckCXXSourceCompiles)
include (CheckIncludeFile)
2011-10-22 15:07:09 +00:00
2010-11-30 10:08:30 +00:00
project(FlightGear)
2011-11-30 22:33:03 +00:00
# We have some custom .cmake scripts not in the official distribution.
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
2011-11-30 18:56:44 +00:00
if(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
# use official include provided by latest CMake
include(GNUInstallDirs)
else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
# backward compatibility: use our own module for older cmake versions
include(OldGNUInstallDirs)
endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
2011-01-05 16:19:42 +00:00
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
2011-09-26 12:33:06 +00:00
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
2011-01-05 16:19:42 +00:00
2011-01-01 21:46:16 +00:00
# read 'version' file into a variable (stripping any newlines or spaces)
file(READ version versionFile)
string(STRIP ${versionFile} FLIGHTGEAR_VERSION)
2010-11-30 10:08:30 +00:00
#packaging
2011-11-30 18:56:44 +00:00
if(EXISTS ${PROJECT_SOURCE_DIR}/.gitignore)
file(READ .gitignore CPACK_SOURCE_IGNORE_FILES)
else()
# clean tar-balls do not contain SCM (.git/.gitignore/...) files.
set(CPACK_SOURCE_IGNORE_FILES
"^${PROJECT_SOURCE_DIR}/.git;\\\\.gitignore;Makefile.am;~$;${CPACK_SOURCE_IGNORE_FILES}")
endif()
2011-09-08 12:59:40 +00:00
# split version string into components, note CMAKE_MATCH_0 is the entire regexp match
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" CPACK_PACKAGE_VERSION ${FLIGHTGEAR_VERSION} )
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
2010-11-30 10:08:30 +00:00
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
2011-10-22 15:07:09 +00:00
set(CPACK_SOURCE_GENERATOR TBZ2 ZIP)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "flightgear-${FLIGHTGEAR_VERSION}" CACHE INTERNAL "tarball basename")
include (CPack)
2011-11-01 17:05:54 +00:00
if (FG_DATA_DIR)
message(STATUS "Using explicit data-dir: ${FG_DATA_DIR}")
else()
2011-11-05 13:17:08 +00:00
set(FG_DATA_DIR "${CMAKE_INSTALL_PREFIX}/lib/FlightGear" CACHE PATH "Default location where data files are located")
2011-11-01 17:05:54 +00:00
message(STATUS "Using default data-dir: ${FG_DATA_DIR}")
endif()
2010-11-30 10:08:30 +00:00
2011-09-12 06:10:48 +00:00
# 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)
2011-01-01 18:24:53 +00:00
if($ENV{BUILD_ID})
set(HUDSON_BUILD_ID $ENV{BUILD_ID})
set(HUDSON_BUILD_NUMBER $ENV{BUILD_NUMBER})
message(STATUS "running under Hudson, build-number is ${HUDSON_BUILD_NUMBER}")
else()
set(HUDSON_BUILD_NUMBER 0)
set(HUDSON_BUILD_ID "none")
endif()
2011-09-21 16:13:13 +00:00
IF(APPLE)
set(EVENT_INPUT_DEFAULT 1)
2011-10-16 18:55:04 +00:00
find_library(CORESERVICES_LIBRARY CoreServices)
2011-11-20 13:23:52 +00:00
find_library(COCOA_LIBRARY Cocoa)
list(APPEND PLATFORM_LIBS ${COCOA_LIBRARY} ${CORESERVICES_LIBRARY})
2011-10-16 18:55:04 +00:00
2011-09-21 16:13:13 +00:00
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
2011-12-04 13:37:25 +00:00
find_package(UDev)
if(UDEV_FOUND)
set(EVENT_INPUT_DEFAULT 1)
endif(UDEV_FOUND)
2011-09-21 16:13:13 +00:00
endif()
2011-01-01 18:24:53 +00:00
find_package(Git)
if (GIT_FOUND)
execute_process(COMMAND git --git-dir ${PROJECT_SOURCE_DIR}/.git rev-parse HEAD
OUTPUT_VARIABLE REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Git revision is ${REVISION}")
else()
set(REVISION "none")
endif()
2010-11-30 10:08:30 +00:00
option(LOGGING "Set to OFF to build FlightGear without logging" ON)
option(SP_FDMS "Set to ON to build FlightGear with special-purpose FDMs" OFF)
2011-11-01 16:21:59 +00:00
option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" OFF)
option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" OFF)
2010-11-30 10:08:30 +00:00
option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
2011-01-06 16:56:07 +00:00
option(ENABLE_FGADMIN "Set to ON to build FlightGear with FGADMIN" ON)
2011-09-21 16:13:13 +00:00
option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" ${EVENT_INPUT_DEFAULT})
2011-08-04 16:59:46 +00:00
option(ENABLE_LIBSVN "Set to ON to build FlightGear/terrasync with libsvnclient support" ON)
2011-09-05 18:25:30 +00:00
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
2011-07-21 13:46:29 +00:00
option(WITH_FGPANEL "Set to ON to build the fgpanel application" ON)
2011-11-05 13:17:08 +00:00
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
2011-09-26 12:33:06 +00:00
2011-09-12 09:07:31 +00:00
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})
2011-10-21 12:36:04 +00:00
list(APPEND PLATFORM_LIBS "winmm.lib")
2011-09-12 09:07:31 +00:00
else (MSVC)
set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
endif (MSVC)
2010-11-30 10:08:30 +00:00
if(LOGGING)
# nothing
else()
set(FG_NDEBUG 1)
endif()
2011-06-12 13:17:03 +00:00
if(SP_FDMS)
2010-11-30 10:08:30 +00:00
set(ENABLE_SP_FDM 1)
endif()
2011-01-28 13:57:32 +00:00
if (MSVC AND MSVC_3RDPARTY_ROOT)
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
set( OSG_MSVC "msvc" )
if (${MSVC_VERSION} EQUAL 1600)
set( OSG_MSVC ${OSG_MSVC}100 )
else (${MSVC_VERSION} EQUAL 1600)
set( OSG_MSVC ${OSG_MSVC}90 )
endif (${MSVC_VERSION} EQUAL 1600)
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 ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/lib )
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/include)
set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
set (ALUT_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)
2011-01-01 21:22:37 +00:00
2011-09-21 16:13:13 +00:00
if(EVENT_INPUT)
message(STATUS "checking event-based Input")
2011-12-04 13:37:25 +00:00
2011-09-21 16:13:13 +00:00
IF(APPLE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
2011-12-04 13:37:25 +00:00
if(NOT UDEV_FOUND)
message(WARNING "UDev not found, event input is disabled!")
set(EVENT_INPUT 0)
else()
set(EVENT_INPUT_LIBRARIES ${UDEV_LIBRARIES})
endif()
2011-09-21 16:13:13 +00:00
else()
message(WARNING "event input is not supported on this platform yet")
endif()
2011-12-04 13:37:25 +00:00
# Keep PLIB INPUT enabled as long as EventInput does not replace current joystick configurations.
set(ENABLE_PLIB_JOYSTICK 1)
2011-09-21 16:13:13 +00:00
else(EVENT_INPUT)
set(ENABLE_PLIB_JOYSTICK 1)
endif(EVENT_INPUT)
2011-01-01 21:22:37 +00:00
2010-11-30 10:08:30 +00:00
# check required dependencies
2011-01-03 09:50:05 +00:00
find_package(Boost REQUIRED)
2010-11-30 10:08:30 +00:00
find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(ALUT REQUIRED)
2011-11-26 15:41:35 +00:00
find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgFX osgUtil osgViewer osgGA)
2011-01-06 16:56:07 +00:00
if(ENABLE_FGADMIN)
find_package(FLTK)
endif(ENABLE_FGADMIN)
2011-01-01 21:22:37 +00:00
2011-01-09 00:15:29 +00:00
if(ENABLE_LIBSVN)
find_package(SvnClient)
if(LIBSVN_FOUND)
message(STATUS "libsvn found, enabling in terrasync")
set(HAVE_SVN_CLIENT_H 1)
set(HAVE_LIBSVN_CLIENT_1 1)
endif(LIBSVN_FOUND)
endif(ENABLE_LIBSVN)
2011-01-14 21:37:39 +00:00
find_package(PLIB REQUIRED puaux pu js fnt)
2011-07-17 09:07:07 +00:00
find_package(SimGear 2.5.0 REQUIRED)
2010-11-30 10:08:30 +00:00
2011-11-05 13:17:08 +00:00
if (JPEG_FACTORY)
# check simgear was built with JPEG-factory support
find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
2011-11-06 10:51:02 +00:00
set(CMAKE_REQUIRED_INCLUDES
${SIMGEAR_INCLUDE_DIR}
2011-11-06 14:55:06 +00:00
${JPEG_INCLUDE_DIR}
2011-11-06 10:51:02 +00:00
${OPENSCENEGRAPH_INCLUDE_DIRS})
2011-11-05 13:17:08 +00:00
check_cxx_source_compiles(
"#include <simgear/screen/jpgfactory.hxx>
int main() { return 0; } "
FG_JPEG_SERVER)
if (NOT FG_JPEG_SERVER)
message(STATUS "JPEG server support requested, but SimGear was built without JPEG support")
endif()
endif()
2010-12-25 23:44:02 +00:00
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
2011-01-03 21:47:11 +00:00
check_include_file(windows.h HAVE_WINDOWS_H)
2010-12-25 23:44:02 +00:00
# definition depends on OSG version
set(CMAKE_REQUIRED_INCLUDES ${OPENSCENEGRAPH_INCLUDE_DIRS})
check_cxx_source_compiles(
"#include <osg/CullSettings>
int main()
{
osg::CullSettings::VariablesMask mask = osg::CullSettings::CLEAR_MASK;
return 0;
}
"
HAVE_CULLSETTINGS_CLEAR_MASK)
2011-09-05 18:25:30 +00:00
if(ENABLE_RTI)
find_package(RTI)
if(RTI_FOUND)
set(FG_HAVE_HLA 1)
endif(RTI_FOUND)
endif(ENABLE_RTI)
2010-12-26 12:55:52 +00:00
2010-11-30 10:08:30 +00:00
if(CMAKE_COMPILER_IS_GNUCXX)
set(WARNING_FLAGS -Wall)
endif(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32)
if(MSVC)
# turn off various warnings
# foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
# SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
# endforeach(warning)
2011-01-03 21:47:11 +00:00
set(MSVC_FLAGS "-DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
2011-01-28 14:15:20 +00:00
if (${MSVC_VERSION} EQUAL 1600)
set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
endif (${MSVC_VERSION} EQUAL 1600)
2010-11-30 10:08:30 +00:00
endif(MSVC)
set(NOMINMAX 1)
endif(WIN32)
2010-12-27 12:44:17 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
2011-01-28 14:15:20 +00:00
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
2010-11-30 10:08:30 +00:00
2010-12-26 12:55:52 +00:00
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
2011-09-11 09:22:10 +00:00
${Boost_INCLUDE_DIRS}
2010-12-26 12:55:52 +00:00
${ZLIB_INCLUDE_DIR}
2011-09-11 09:22:10 +00:00
${ALUT_INCLUDE_DIR}
2010-11-30 10:08:30 +00:00
${OPENAL_INCLUDE_DIR}
${SIMGEAR_INCLUDE_DIR}
${PLIB_INCLUDE_DIR} )
include_directories(${PROJECT_SOURCE_DIR}/src)
2011-01-01 21:46:16 +00:00
# following is needed, because config.h is include 'bare', whereas
# version.h is included as <Include/version.h> - this should be cleaned up
include_directories(${PROJECT_BINARY_DIR}/src)
2010-11-30 10:08:30 +00:00
include_directories(${PROJECT_BINARY_DIR}/src/Include)
add_definitions(-DHAVE_CONFIG_H)
2011-06-02 22:01:17 +00:00
check_function_exists(mkfifo HAVE_MKFIFO)
2010-11-30 10:08:30 +00:00
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/src/Include/config_cmake.h.in"
"${PROJECT_BINARY_DIR}/src/Include/config.h"
)
2011-01-01 18:24:53 +00:00
#and the same for the version header
configure_file (
"${PROJECT_SOURCE_DIR}/src/Include/version.h.cmake-in"
"${PROJECT_BINARY_DIR}/src/Include/version.h"
)
2010-11-30 10:08:30 +00:00
add_subdirectory(src)
add_subdirectory(utils)
2011-11-04 09:38:07 +00:00
add_subdirectory(man)
2010-12-28 13:43:14 +00:00
2011-10-18 11:14:20 +00:00
set (INSTALL_DOCS
2011-11-26 15:41:35 +00:00
README
2011-10-18 11:14:20 +00:00
README.OpenAL
README.plib
README.OSG
README.SimGear)
2011-11-30 18:56:44 +00:00
INSTALL(FILES ${INSTALL_DOCS} DESTINATION ${CMAKE_INSTALL_DOCDIR} OPTIONAL)
2011-10-18 11:14:20 +00:00
2010-12-28 13:43:14 +00:00
#-----------------------------------------------------------------------------
### uninstall target
#-----------------------------------------------------------------------------
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")