2013-07-02 00:33:21 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
2014-01-26 04:45:55 +01:00
|
|
|
project(OpenRW)
|
2013-06-30 01:05:04 +02:00
|
|
|
|
2016-05-19 23:28:12 +02:00
|
|
|
#
|
|
|
|
# Options
|
|
|
|
#
|
|
|
|
|
2016-04-15 00:50:52 +02:00
|
|
|
# Global Build Configuration
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DRW_DEBUG=1")
|
2016-05-01 23:30:15 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pthread -Wextra -Wpedantic")
|
2016-05-19 23:28:12 +02:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
|
2016-04-12 00:56:18 +02:00
|
|
|
|
2016-05-24 17:31:54 +02:00
|
|
|
set(RW_VERBOSE_DEBUG_MESSAGES 1 CACHE BOOL "Print verbose debugging messages")
|
|
|
|
|
2015-03-30 01:59:22 +02:00
|
|
|
# Optional components
|
2016-05-19 23:28:12 +02:00
|
|
|
option(BUILD_TESTS "Build test suite")
|
|
|
|
option(BUILD_VIEWER "Build GUI data viewer")
|
2015-03-30 01:59:22 +02:00
|
|
|
|
2016-05-19 23:28:12 +02:00
|
|
|
# Compile-time Options & Features
|
|
|
|
option(ENABLE_SCRIPT_DEBUG "Enable verbose script execution")
|
|
|
|
option(ENABLE_PROFILING "Enable detailed profiling metrics")
|
2016-06-16 22:11:55 +02:00
|
|
|
option(TESTS_NODATA "Build tests for no-data testing")
|
2014-06-18 18:07:51 +02:00
|
|
|
|
2016-05-19 23:28:12 +02:00
|
|
|
#
|
|
|
|
# Build configuration
|
|
|
|
#
|
2016-06-01 20:01:22 +02:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
|
|
|
|
endif()
|
2014-08-17 00:02:34 +02:00
|
|
|
|
2016-05-20 03:09:22 +02:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2016-05-25 17:32:17 +02:00
|
|
|
add_definitions(-DRW_LINUX)
|
2016-05-20 16:24:51 +02:00
|
|
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
2016-05-25 17:32:17 +02:00
|
|
|
add_definitions(-DRW_OSX)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
|
|
|
add_definitions(-DRW_FREEBSD)
|
2016-08-13 21:33:04 +02:00
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
|
|
|
add_definitions(-DRW_NETBSD)
|
2016-08-11 23:42:42 +02:00
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
|
|
add_definitions(-DRW_OPENBSD)
|
2016-07-27 19:28:49 +02:00
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
add_definitions(-DRW_WINDOWS)
|
2016-05-20 03:09:22 +02:00
|
|
|
else ()
|
|
|
|
message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.")
|
|
|
|
endif ()
|
|
|
|
|
2016-05-20 16:28:47 +02:00
|
|
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-array-member-paren-init")
|
|
|
|
endif()
|
|
|
|
|
2016-07-27 19:28:49 +02:00
|
|
|
if(MINGW)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
|
|
|
|
endif()
|
|
|
|
|
2014-05-25 23:30:50 +02:00
|
|
|
# Make GLM use radians
|
|
|
|
add_definitions(-DGLM_FORCE_RADIANS)
|
|
|
|
|
2016-05-19 23:28:12 +02:00
|
|
|
IF(${ENABLE_PROFILING})
|
2016-04-27 00:35:04 +02:00
|
|
|
add_definitions(-DRENDER_PROFILER=0 -DRW_PROFILER=1)
|
2015-04-12 20:47:47 +02:00
|
|
|
else()
|
2016-04-27 00:35:04 +02:00
|
|
|
add_definitions(-DRENDER_PROFILER=0 -DRW_PROFILER=0)
|
2015-04-12 20:47:47 +02:00
|
|
|
ENDIF()
|
|
|
|
|
2014-12-15 21:44:36 +01:00
|
|
|
IF(${ENABLE_SCRIPT_DEBUG})
|
2016-05-22 21:05:04 +02:00
|
|
|
add_definitions(-DRW_SCRIPT_DEBUG)
|
2014-12-15 21:44:36 +01:00
|
|
|
ENDIF()
|
2016-05-21 19:09:41 +02:00
|
|
|
|
2016-05-24 17:31:54 +02:00
|
|
|
if(${RW_VERBOSE_DEBUG_MESSAGES})
|
|
|
|
add_definitions(-DRW_VERBOSE_DEBUG_MESSAGES=1)
|
|
|
|
else()
|
|
|
|
add_definitions(-DRW_VERBOSE_DEBUG_MESSAGES=0)
|
|
|
|
endif()
|
|
|
|
|
2016-06-29 23:19:03 +02:00
|
|
|
if(NOT DEFINED BIN_DIR)
|
|
|
|
set(BIN_DIR "bin" CACHE PATH "BIN_DIR")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED DOC_DIR)
|
|
|
|
set(DOC_DIR "share/doc/openrw" CACHE PATH "DOC_DIR")
|
|
|
|
endif()
|
|
|
|
|
2016-05-21 19:09:41 +02:00
|
|
|
# Find dependancies
|
2016-05-21 10:30:51 +02:00
|
|
|
find_package(OpenGL REQUIRED)
|
2016-05-24 19:49:19 +02:00
|
|
|
find_package(OpenAL REQUIRED)
|
2016-05-21 10:30:51 +02:00
|
|
|
find_package(Bullet REQUIRED)
|
|
|
|
find_package(MAD REQUIRED)
|
2016-05-29 01:44:31 +02:00
|
|
|
find_package(GLM REQUIRED)
|
2016-05-24 19:49:19 +02:00
|
|
|
find_package(LibSndFile REQUIRED)
|
2016-06-22 12:29:39 +02:00
|
|
|
find_package(SDL2 REQUIRED)
|
2016-05-21 10:30:51 +02:00
|
|
|
|
2016-06-22 12:29:39 +02:00
|
|
|
include_directories(
|
|
|
|
${SDL2_INCLUDE_DIR}
|
|
|
|
${GLM_INCLUDE_DIRS}
|
2016-08-11 23:42:42 +02:00
|
|
|
${OPENGL_INCLUDE_DIR}
|
2016-08-08 17:30:00 +02:00
|
|
|
${BULLET_INCLUDE_DIRS}
|
2016-06-22 12:29:39 +02:00
|
|
|
)
|
2014-06-18 18:07:51 +02:00
|
|
|
|
2016-05-20 03:09:22 +02:00
|
|
|
# External-internal dependencies
|
|
|
|
add_subdirectory(cmake/external)
|
|
|
|
|
2016-07-03 00:00:11 +02:00
|
|
|
# Include git hash in source
|
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
|
|
|
|
2016-05-19 23:28:12 +02:00
|
|
|
#
|
|
|
|
# Components
|
|
|
|
#
|
2014-06-18 18:07:51 +02:00
|
|
|
|
2016-04-07 02:13:46 +02:00
|
|
|
add_subdirectory(rwlib)
|
2015-03-30 01:59:22 +02:00
|
|
|
add_subdirectory(rwengine)
|
|
|
|
add_subdirectory(rwgame)
|
|
|
|
|
2016-05-19 23:28:12 +02:00
|
|
|
IF(${BUILD_VIEWER})
|
2015-03-30 01:59:22 +02:00
|
|
|
add_subdirectory(rwviewer)
|
|
|
|
ENDIF()
|
|
|
|
IF(${BUILD_TESTS})
|
2016-05-19 23:28:12 +02:00
|
|
|
add_subdirectory(tests)
|
2016-04-07 02:13:46 +02:00
|
|
|
ENDIF()
|
2016-06-21 22:26:09 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Finally
|
|
|
|
#
|
|
|
|
|
|
|
|
# Copy License file to install directory
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD")
|
|
|
|
install(FILES COPYING
|
2016-06-29 23:19:03 +02:00
|
|
|
DESTINATION "${DOC_DIR}"
|
2016-06-21 22:26:09 +02:00
|
|
|
)
|
|
|
|
endif()
|
2016-06-22 00:28:43 +02:00
|
|
|
# And copy to build directory for CI
|
|
|
|
file(COPY COPYING
|
|
|
|
DESTINATION .
|
|
|
|
)
|