From 4d228e40c7b8e9452586fd5830b6fcf3faface56 Mon Sep 17 00:00:00 2001 From: Daniel Evans Date: Wed, 18 Jun 2014 17:07:51 +0100 Subject: [PATCH] Improve CMake scripts Look for bullet using the FindBullet package --- CMakeLists.txt | 22 ++++++++++++++++++---- rwgame/CMakeLists.txt | 4 ++-- rwviewer/CMakeLists.txt | 4 ++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca072de9..ae00de9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,16 +2,30 @@ cmake_minimum_required(VERSION 2.8) project(OpenRW) -set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11 -Wall" ) +# TODO: +# - Visual Studio support +# - Find libraries correctly, e.g. FindBullet + +SET(BUILD_OLD_TOOLS FALSE CACHE BOOL "Build old datadump and analyzer tools") + +IF(CMAKE_BUILD_TYPE MATCHES DEBUG) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11 -Wall -Wextra" ) +ELSE() + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -Wall" ) +ENDIF() # Make GLM use radians add_definitions(-DGLM_FORCE_RADIANS) -add_subdirectory(datadump) +find_package(Bullet REQUIRED) + +IF(BUILD_OLD_TOOLS) + add_subdirectory(analyzer) + add_subdirectory(datadump) +ENDIF() + add_subdirectory(rwgame) add_subdirectory(rwviewer) add_subdirectory(rwengine) -add_subdirectory(analyzer) - add_subdirectory(tests) diff --git a/rwgame/CMakeLists.txt b/rwgame/CMakeLists.txt index c5e0430b..a1163394 100644 --- a/rwgame/CMakeLists.txt +++ b/rwgame/CMakeLists.txt @@ -7,8 +7,8 @@ add_executable(rwgame debugstate.cpp ) -include_directories("${CMAKE_SOURCE_DIR}/rwengine/include" /usr/include/bullet) +include_directories("${CMAKE_SOURCE_DIR}/rwengine/include" ${BULLET_INCLUDE_DIRS}) -target_link_libraries( rwgame rwengine sfml-graphics sfml-window sfml-system GL GLEW BulletDynamics BulletCollision LinearMath ) +target_link_libraries( rwgame rwengine sfml-graphics sfml-window sfml-system GL GLEW ${BULLET_LIBRARIES} ) install(TARGETS rwgame RUNTIME DESTINATION bin) diff --git a/rwviewer/CMakeLists.txt b/rwviewer/CMakeLists.txt index b3c3a83a..b5758d69 100644 --- a/rwviewer/CMakeLists.txt +++ b/rwviewer/CMakeLists.txt @@ -15,9 +15,9 @@ add_executable(rwviewer AnimationListModel.cpp AnimationListWidget.cpp) -include_directories("${CMAKE_SOURCE_DIR}/rwengine/include" /usr/include/bullet) +include_directories("${CMAKE_SOURCE_DIR}/rwengine/include" ${BULLET_INCLUDE_DIRS}) -target_link_libraries(rwviewer rwengine sfml-graphics sfml-system GL GLEW BulletDynamics BulletCollision LinearMath) +target_link_libraries(rwviewer rwengine sfml-graphics sfml-system GL GLEW ${BULLET_LIBRARIES}) qt5_use_modules(rwviewer Widgets OpenGL) install(TARGETS rwviewer RUNTIME DESTINATION bin)