mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
cmake: use rwengine::interface + no more add_definitions & include_directories
This commit is contained in:
parent
e5a8395d5c
commit
1926795d63
@ -6,11 +6,6 @@ project(OpenRW)
|
|||||||
# Options
|
# Options
|
||||||
#
|
#
|
||||||
|
|
||||||
# Global Build Configuration
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DRW_DEBUG=1")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pthread -Wextra -Wpedantic -Wdouble-promotion")
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
|
|
||||||
|
|
||||||
option(RW_VERBOSE_DEBUG_MESSAGES "Print verbose debugging messages" ON)
|
option(RW_VERBOSE_DEBUG_MESSAGES "Print verbose debugging messages" ON)
|
||||||
|
|
||||||
# Optional components
|
# Optional components
|
||||||
@ -32,59 +27,77 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_library(rw_interface INTERFACE)
|
||||||
|
add_library(openrw::interface ALIAS rw_interface)
|
||||||
|
|
||||||
|
# target_compile_features(rw_interface INTERFACE cxx_std_14) is not supported by CMake 3.2
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
target_compile_options(rw_interface
|
||||||
|
INTERFACE
|
||||||
|
"-Wall"
|
||||||
|
"-Wextra"
|
||||||
|
"-Wdouble-promotion"
|
||||||
|
"-Wpedantic"
|
||||||
|
"-pthread"
|
||||||
|
)
|
||||||
|
target_compile_definitions(rw_interface
|
||||||
|
INTERFACE
|
||||||
|
"$<$<CONFIG:Debug>:RW_DEBUG=1>"
|
||||||
|
"GLM_FORCE_RADIANS"
|
||||||
|
"RW_VERBOSE_DEBUG_MESSAGES=$<BOOL:${RW_VERBOSE_DEBUG_MESSAGES}>"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
add_definitions(-DRW_LINUX)
|
target_compile_definitions(rw_interface INTERFACE "RW_LINUX")
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
add_definitions(-DRW_OSX)
|
target_compile_definitions(rw_interface INTERFACE "RW_OSX")
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||||
add_definitions(-DRW_FREEBSD)
|
target_compile_definitions(rw_interface INTERFACE "RW_FREEBSD")
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
||||||
add_definitions(-DRW_NETBSD)
|
target_compile_definitions(rw_interface INTERFACE "RW_NETBSD")
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||||
add_definitions(-DRW_OPENBSD)
|
target_compile_definitions(rw_interface INTERFACE "RW_OPENBSD")
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
add_definitions(-DRW_WINDOWS)
|
target_compile_definitions(rw_interface INTERFACE "RW_WINDOWS")
|
||||||
else ()
|
else ()
|
||||||
message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.")
|
message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-array-member-paren-init")
|
target_compile_options(rw_interface INTERFACE "-Wno-gnu-array-member-paren-init")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
|
target_compile_options(rw_interface INTERFACE "-fpermissive")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Make GLM use radians
|
target_compile_definitions(rw_interface
|
||||||
add_definitions(-DGLM_FORCE_RADIANS)
|
INTERFACE
|
||||||
|
"RENDER_PROFILER=0"
|
||||||
|
"RW_PROFILER=$<BOOL:${ENABLE_PROFILING}>"
|
||||||
|
)
|
||||||
|
|
||||||
IF(${ENABLE_PROFILING})
|
IF(ENABLE_SCRIPT_DEBUG)
|
||||||
add_definitions(-DRENDER_PROFILER=0 -DRW_PROFILER=1)
|
target_compile_definitions(rw_interface
|
||||||
else()
|
INTERFACE
|
||||||
add_definitions(-DRENDER_PROFILER=0 -DRW_PROFILER=0)
|
"RW_SCRIPT_DEBUG"
|
||||||
ENDIF()
|
)
|
||||||
|
|
||||||
IF(${ENABLE_SCRIPT_DEBUG})
|
|
||||||
add_definitions(-DRW_SCRIPT_DEBUG)
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
if(FAILED_CHECK_ACTION STREQUAL "IGNORE")
|
if(FAILED_CHECK_ACTION STREQUAL "IGNORE")
|
||||||
add_definitions(-DRW_FAILED_CHECK_ACTION=0)
|
target_compile_definitions(rw_interface INTERFACE "RW_FAILED_CHECK_ACTION=0")
|
||||||
elseif(FAILED_CHECK_ACTION STREQUAL "ABORT")
|
elseif(FAILED_CHECK_ACTION STREQUAL "ABORT")
|
||||||
add_definitions(-DRW_FAILED_CHECK_ACTION=1)
|
target_compile_definitions(rw_interface INTERFACE "RW_FAILED_CHECK_ACTION=1")
|
||||||
elseif(FAILED_CHECK_ACTION STREQUAL "BREAKPOINT")
|
elseif(FAILED_CHECK_ACTION STREQUAL "BREAKPOINT")
|
||||||
add_definitions(-DRW_FAILED_CHECK_ACTION=2)
|
target_compile_definitions(rw_interface INTERFACE "RW_FAILED_CHECK_ACTION=2")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Illegal FAILED_CHECK_ACTION option.")
|
message(FATAL_ERROR "Illegal FAILED_CHECK_ACTION option.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${RW_VERBOSE_DEBUG_MESSAGES})
|
|
||||||
add_definitions(-DRW_VERBOSE_DEBUG_MESSAGES=1)
|
|
||||||
else()
|
|
||||||
add_definitions(-DRW_VERBOSE_DEBUG_MESSAGES=0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT DEFINED BIN_DIR)
|
if(NOT DEFINED BIN_DIR)
|
||||||
set(BIN_DIR "bin" CACHE PATH "BIN_DIR")
|
set(BIN_DIR "bin" CACHE PATH "BIN_DIR")
|
||||||
endif()
|
endif()
|
||||||
@ -101,14 +114,6 @@ find_package(GLM REQUIRED)
|
|||||||
find_package(FFmpeg REQUIRED)
|
find_package(FFmpeg REQUIRED)
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
|
|
||||||
include_directories(
|
|
||||||
${SDL2_INCLUDE_DIR}
|
|
||||||
${GLM_INCLUDE_DIRS}
|
|
||||||
${OPENGL_INCLUDE_DIR}
|
|
||||||
${BULLET_INCLUDE_DIRS}
|
|
||||||
${OPENAL_INCLUDE_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# External-internal dependencies
|
# External-internal dependencies
|
||||||
add_subdirectory(cmake/external)
|
add_subdirectory(cmake/external)
|
||||||
|
|
||||||
|
@ -134,24 +134,23 @@ add_library(rwengine
|
|||||||
${RWENGINE_SOURCES}
|
${RWENGINE_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MINGW)
|
|
||||||
target_link_libraries(rwengine)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(rwengine
|
target_link_libraries(rwengine
|
||||||
|
PUBLIC
|
||||||
rwlib
|
rwlib
|
||||||
|
PRIVATE
|
||||||
${FFMPEG_LIBRARIES}
|
${FFMPEG_LIBRARIES}
|
||||||
${OPENAL_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${OPENRW_PLATFORM_LIBS}
|
)
|
||||||
${SDL2_LIBRARY})
|
|
||||||
|
|
||||||
include_directories(SYSTEM
|
target_include_directories(rwengine
|
||||||
|
SYSTEM
|
||||||
|
PUBLIC
|
||||||
${BULLET_INCLUDE_DIR}
|
${BULLET_INCLUDE_DIR}
|
||||||
${FFMPEG_INCLUDE_DIR}
|
${FFMPEG_INCLUDE_DIR}
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(rwengine
|
||||||
rwengine
|
PUBLIC
|
||||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
|
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||||
)
|
)
|
||||||
|
@ -44,23 +44,26 @@ set(RWGAME_SOURCES
|
|||||||
add_executable(rwgame
|
add_executable(rwgame
|
||||||
${RWGAME_SOURCES})
|
${RWGAME_SOURCES})
|
||||||
|
|
||||||
include_directories(SYSTEM
|
target_include_directories(rwgame
|
||||||
|
SYSTEM
|
||||||
|
PRIVATE
|
||||||
${BULLET_INCLUDE_DIR}
|
${BULLET_INCLUDE_DIR}
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
|
${SDL2_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
include_directories(
|
|
||||||
|
target_include_directories(rwgame
|
||||||
|
PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/rwgame"
|
"${CMAKE_SOURCE_DIR}/rwgame"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(rwgame
|
target_link_libraries(rwgame
|
||||||
|
PRIVATE
|
||||||
rwengine
|
rwengine
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${BULLET_LIBRARIES}
|
${BULLET_LIBRARIES}
|
||||||
${SDL2_LIBRARY}
|
${SDL2_LIBRARY}
|
||||||
)
|
)
|
||||||
if(MINGW)
|
|
||||||
target_link_libraries(rwgame)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS rwgame RUNTIME DESTINATION "${BIN_DIR}")
|
install(TARGETS rwgame RUNTIME DESTINATION "${BIN_DIR}")
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <glm/vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "SDL.h"
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <render/GameRenderer.hpp>
|
#include <render/GameRenderer.hpp>
|
||||||
|
|
||||||
|
@ -44,14 +44,21 @@ add_library(rwlib
|
|||||||
${RWLIB_SOURCES}
|
${RWLIB_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
target_include_directories(rwlib
|
||||||
|
PUBLIC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/source"
|
"${CMAKE_CURRENT_SOURCE_DIR}/source"
|
||||||
"${Boost_INCLUDE_DIRS}")
|
)
|
||||||
|
|
||||||
target_include_directories(rwlib
|
target_include_directories(rwlib
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/source")
|
SYSTEM
|
||||||
|
PUBLIC
|
||||||
|
"${Boost_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(rwlib
|
target_link_libraries(rwlib
|
||||||
|
PUBLIC
|
||||||
|
openrw::interface
|
||||||
|
PRIVATE
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${OPENRW_PLATFORM_LIBS}
|
${Boost_LIBRARIES}
|
||||||
${Boost_LIBRARIES})
|
)
|
||||||
|
@ -23,7 +23,9 @@ add_executable(rwviewer
|
|||||||
AnimationListModel.cpp
|
AnimationListModel.cpp
|
||||||
AnimationListWidget.cpp)
|
AnimationListWidget.cpp)
|
||||||
|
|
||||||
include_directories(SYSTEM
|
target_include_directories(rwviewer
|
||||||
|
SYSTEM
|
||||||
|
PRIVATE
|
||||||
${BULLET_INCLUDE_DIR})
|
${BULLET_INCLUDE_DIR})
|
||||||
|
|
||||||
target_link_libraries(rwviewer
|
target_link_libraries(rwviewer
|
||||||
|
@ -2,12 +2,6 @@
|
|||||||
# Unit Tests
|
# Unit Tests
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
if(${TESTS_NODATA})
|
|
||||||
add_definitions(-DRW_TEST_WITH_DATA=0)
|
|
||||||
else()
|
|
||||||
add_definitions(-DRW_TEST_WITH_DATA=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(Boost COMPONENTS filesystem unit_test_framework REQUIRED)
|
find_package(Boost COMPONENTS filesystem unit_test_framework REQUIRED)
|
||||||
|
|
||||||
set(TEST_SOURCES
|
set(TEST_SOURCES
|
||||||
@ -54,17 +48,26 @@ set(TEST_SOURCES
|
|||||||
"${CMAKE_SOURCE_DIR}/rwgame/GameInput.cpp"
|
"${CMAKE_SOURCE_DIR}/rwgame/GameInput.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
|
|
||||||
|
|
||||||
add_executable(run_tests ${TEST_SOURCES})
|
add_executable(run_tests ${TEST_SOURCES})
|
||||||
|
|
||||||
include_directories(
|
target_compile_definitions(run_tests
|
||||||
include
|
PRIVATE
|
||||||
"${CMAKE_SOURCE_DIR}/tests"
|
"RW_TEST_WITH_DATA=$<NOT:$<BOOL:${TESTS_NODATA}>>"
|
||||||
"${CMAKE_SOURCE_DIR}/rwgame")
|
"BOOST_TEST_DYN_LINK"
|
||||||
|
)
|
||||||
|
|
||||||
include_directories(SYSTEM
|
target_include_directories(run_tests
|
||||||
${BULLET_INCLUDE_DIR})
|
SYSTEM
|
||||||
|
PRIVATE
|
||||||
|
${BULLET_INCLUDE_DIR}
|
||||||
|
${SDL2_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(run_tests
|
||||||
|
PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/tests"
|
||||||
|
"${CMAKE_SOURCE_DIR}/rwgame"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(run_tests
|
target_link_libraries(run_tests
|
||||||
rwengine
|
rwengine
|
||||||
|
Loading…
Reference in New Issue
Block a user