X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=CMakeLists.txt;h=4ed9e8522e064c80d8174fff2e9763fec41a1ac9;hb=c0424aba7e483f2011b61f02307b659b71e2f56e;hp=62c39ad23a15a68d2d7fabf9edaa799677991cf3;hpb=e37232aeb4f521f34bd6ca5790f33ad48dcd8d42;p=simgear.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 62c39ad2..4ed9e852 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,31 +21,33 @@ if(InSourceBuild) message(WARNING " mkdir ../sgbuild && cd ../sgbuild && cmake ${CMAKE_SOURCE_DIR}") endif(InSourceBuild) -#packaging -SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") -SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README") -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simulation support libraries for FlightGear and related projects") -SET(CPACK_PACKAGE_VENDOR "The FlightGear project") -SET(CPACK_GENERATOR "TBZ2") -SET(CPACK_INSTALL_CMAKE_PROJECTS ${CMAKE_CURRENT_BINARY_DIR};SimGear;ALL;/) - - -# 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 ${SIMGEAR_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}) - -message(STATUS "version is ${CPACK_PACKAGE_VERSION_MAJOR} dot ${CPACK_PACKAGE_VERSION_MINOR} dot ${CPACK_PACKAGE_VERSION_PATCH}") - -set(CPACK_SOURCE_GENERATOR TBZ2) -set(CPACK_SOURCE_PACKAGE_FILE_NAME "simgear-${SIMGEAR_VERSION}" CACHE INTERNAL "tarball basename") -set(CPACK_SOURCE_IGNORE_FILES - "^${PROJECT_SOURCE_DIR}/.git;\\\\.gitignore;Makefile.am;~$;${CPACK_SOURCE_IGNORE_FILES}") - -message(STATUS "ignoring: ${CPACK_SOURCE_IGNORE_FILES}") - -include (CPack) +if (NOT EMBEDDED_SIMGEAR) + #packaging + SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") + SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README") + SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simulation support libraries for FlightGear and related projects") + SET(CPACK_PACKAGE_VENDOR "The FlightGear project") + SET(CPACK_GENERATOR "TBZ2") + SET(CPACK_INSTALL_CMAKE_PROJECTS ${CMAKE_CURRENT_BINARY_DIR};SimGear;ALL;/) + + + # 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 ${SIMGEAR_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}) + + message(STATUS "version is ${CPACK_PACKAGE_VERSION_MAJOR} dot ${CPACK_PACKAGE_VERSION_MINOR} dot ${CPACK_PACKAGE_VERSION_PATCH}") + + set(CPACK_SOURCE_GENERATOR TBZ2) + set(CPACK_SOURCE_PACKAGE_FILE_NAME "simgear-${SIMGEAR_VERSION}" CACHE INTERNAL "tarball basename") + set(CPACK_SOURCE_IGNORE_FILES + "^${PROJECT_SOURCE_DIR}/.git;\\\\.gitignore;Makefile.am;~$;${CPACK_SOURCE_IGNORE_FILES}") + + message(STATUS "ignoring: ${CPACK_SOURCE_IGNORE_FILES}") + + include (CPack) +endif() # We have some custom .cmake scripts not in the official distribution. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") @@ -68,6 +70,32 @@ else(${CMAKE_VERSION} VERSION_GREATER 2.8.4) 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) @@ -80,13 +108,15 @@ endif() option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support" OFF) option(JPEG_FACTORY "Enable JPEG-factory support" OFF) +option(SG_SVN_CLIENT "Set to ON to build SimGear with built-in SVN 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) +option(ENABLE_PKGUTIL "Set to ON to build the sg_pkgutil application (default)" ON) if (MSVC) - GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH) + 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) @@ -118,10 +148,11 @@ if (MSVC AND MSVC_3RDPARTY_ROOT) 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) + 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}/OpenRTI/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}/OpenRTI/include) find_path(BOOST_ROOT boost/version.hpp ${MSVC_3RDPARTY_ROOT}/boost + ${MSVC_3RDPARTY_ROOT}/boost_1_52_0 ${MSVC_3RDPARTY_ROOT}/boost_1_51_0 ${MSVC_3RDPARTY_ROOT}/boost_1_50_0 ${MSVC_3RDPARTY_ROOT}/boost_1_49_0 @@ -138,6 +169,10 @@ if (MSVC AND MSVC_3RDPARTY_ROOT) set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib) endif (MSVC AND MSVC_3RDPARTY_ROOT) +if(APPLE) + find_library(CORE_SERVICES_LIBRARY CoreServices) +endif() + find_package(Boost REQUIRED) set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION") @@ -150,6 +185,7 @@ else() if (ENABLE_SOUND) find_package(OpenAL REQUIRED) + message(STATUS "Sound support: ENABLED") endif(ENABLE_SOUND) find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgGA osgUtil) @@ -163,7 +199,9 @@ else() message(STATUS "JPEG-factory: DISABLED") endif(JPEG_FACTORY) -if(ENABLE_LIBSVN) +if (SG_SVN_CLIENT) + message(STATUS "Using built-in subversion client code") +elseif(ENABLE_LIBSVN) find_package(SvnClient) if(LIBSVN_FOUND) @@ -178,7 +216,7 @@ if(ENABLE_LIBSVN) endif(LIBSVN_FOUND) else() message(STATUS "Subversion client support: DISABLED") -endif(ENABLE_LIBSVN) +endif(SG_SVN_CLIENT) find_package(ZLIB REQUIRED) find_package(Threads REQUIRED) @@ -286,7 +324,10 @@ if(WIN32) # SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}") # endforeach(warning) - set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /wd4996 /wd4250") + set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /wd4996 /wd4250 -Dstrdup=_strdup") + if (${MSVC_VERSION} GREATER 1599) + set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" ) + endif (${MSVC_VERSION} GREATER 1599) endif(MSVC) # assumed on Windows @@ -298,6 +339,7 @@ endif(WIN32) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS_C} ${MSVC_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_CXX} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}") include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include) @@ -305,8 +347,11 @@ include_directories(${PROJECT_BINARY_DIR}/simgear) include_directories(${PROJECT_BINARY_DIR}/simgear/xml) include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} - ${OPENAL_INCLUDE_DIR} ) + ${Boost_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIR} + ${OPENAL_INCLUDE_DIR} + ${LibArchive_INCLUDE_DIRS} +) add_definitions(-DHAVE_CONFIG_H) @@ -327,14 +372,37 @@ if(ENABLE_TESTS) message(STATUS "Tests: ENABLED") include (Dart) - enable_testing() + enable_testing() else() message(STATUS "Tests: DISABLED") endif(ENABLE_TESTS) +# always set TEST_LIBS as it is also used by other tools/applications +# TODO maybe better rename? +if(SIMGEAR_SHARED) + set( TEST_LIBS + SimGearCore) +else() + set( TEST_LIBS + SimGearCore + ${CMAKE_THREAD_LIBS_INIT} + ${ZLIB_LIBRARY} + ${WINSOCK_LIBRARY} + ${RT_LIBRARY} + ${CORE_SERVICES_LIBRARY}) +endif() + +if(NOT SIMGEAR_HEADLESS) + set( TEST_LIBS + SimGearScene + ${TEST_LIBS} + ${OPENGL_LIBRARIES}) +endif() + install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/) add_subdirectory(simgear) +if (NOT EMBEDDED_SIMGEAR) #----------------------------------------------------------------------------- ### uninstall target #----------------------------------------------------------------------------- @@ -344,3 +412,6 @@ CONFIGURE_FILE( IMMEDIATE @ONLY) ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + +endif() +