-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
150 lines (131 loc) · 5.77 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
cmake_minimum_required(VERSION 3.1.0)
project (ice_engine)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(ICEENGINE_COMPILER_FLAGS "")
set(ICEENGINE_DEFINITIONS -DAS_USE_STLNAMES)
set(ICEENGINE_LINKER_FLAGS "-no-pie")
if(MSVC)
list(APPEND ICEENGINE_COMPILER_FLAGS /EHsc /MP)
set(ICEENGINE_LINKER_FLAGS "")
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
list(APPEND ICEENGINE_COMPILER_FLAGS /EHsc /MP)
set(ICEENGINE_LINKER_FLAGS "")
endif()
elseif(APPLE)
set(ICEENGINE_LINKER_FLAGS "")
endif()
# Custom options
option(ICEENGINE_BUILD_AS_LIBRARY "ICEENGINE_BUILD_AS_LIBRARY" FALSE)
option(ICEENGINE_BUILD_TESTS "ICEENGINE_BUILD_TESTS" FALSE)
option(ICEENGINE_BUILD_BENCHMARKS "ICEENGINE_BUILD_BENCHMARKS" FALSE)
option(ICEENGINE_ENABLE_DEBUG_LOGGING "ICEENGINE_ENABLE_DEBUG_LOGGING" FALSE)
option(ICEENGINE_ENABLE_TRACE_LOGGING "ICEENGINE_ENABLE_TRACE_LOGGING" FALSE)
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo OR ICEENGINE_ENABLE_DEBUG_LOGGING)
list(APPEND ICEENGINE_DEFINITIONS -DICEENGINE_ENABLE_DEBUG_LOGGING)
endif()
if(ICEENGINE_ENABLE_TRACE_LOGGING)
list(APPEND ICEENGINE_DEFINITIONS -DICEENGINE_ENABLE_TRACE_LOGGING)
endif()
# Dependencies
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED)
find_package(assimp REQUIRED)
find_package(SDL2 REQUIRED)
find_package(glm REQUIRED)
find_package(angelscript REQUIRED)
find_package(freeimage REQUIRED)
find_package(entityx REQUIRED)
find_package(ctpl REQUIRED)
if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
find_package(Threads REQUIRED)
elseif(APPLE)
find_library(QUARTZCORE_LIBRARY QuartzCore REQUIRED)
find_library(METAL_LIBRARY Metal REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED)
find_library(APPSERV_LIBRARY ApplicationServices REQUIRED)
find_library(CARBON_LIBRARY Carbon REQUIRED)
find_library(COREAUDIO_LIBRARY CoreAudio REQUIRED)
find_library(FORCEFEEDBACK_LIBRARY ForceFeedback REQUIRED)
find_library(IOK_LIBRARY IOKit REQUIRED)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox REQUIRED)
find_library(ICONV_LIBRARY iconv REQUIRED)
endif()
if(WIN32)
configure_file(${freeimage_LIB_DIRS}/../bin/FreeImage.dll ./ COPYONLY)
endif()
set(ICEENGINE_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE STRING "Where the Ice Engine include directory can be found")
set(ICEENGINE_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING "")
# Set our runtime library locations
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
if(APPLE)
set(CMAKE_INSTALL_RPATH "./")
set(CMAKE_MACOSX_RPATH ON)
endif()
# Source
file(GLOB_RECURSE SOURCES "src/*.cpp")
# Generate library
if(ICEENGINE_BUILD_AS_LIBRARY)
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp")
add_library(ice_engine STATIC ${SOURCES})
else()
add_executable(ice_engine ${SOURCES})
endif()
# Headers
target_include_directories(ice_engine PUBLIC include)
target_include_directories(ice_engine PRIVATE include/scripting/angel_script/debugger)
target_include_directories(ice_engine PRIVATE include/scripting/angel_script/scriptarray)
target_include_directories(ice_engine PRIVATE include/scripting/angel_script/scriptbuilder)
target_include_directories(ice_engine PRIVATE include/scripting/angel_script/scriptdictionary)
target_include_directories(ice_engine PRIVATE include/scripting/angel_script/scripthandle)
target_include_directories(ice_engine PRIVATE include/scripting/angel_script/scripthelper)
target_include_directories(ice_engine PRIVATE include/scripting/angel_script/scriptstdstring)
target_compile_definitions(ice_engine PRIVATE ${ICEENGINE_DEFINITIONS})
target_compile_options(ice_engine PRIVATE ${ICEENGINE_COMPILER_FLAGS})
target_link_libraries(ice_engine PUBLIC glm::glm)
target_link_libraries(ice_engine PRIVATE freeimage::freeimage)
target_link_libraries(ice_engine PRIVATE Boost::system)
target_link_libraries(ice_engine PRIVATE Boost::chrono)
target_link_libraries(ice_engine PRIVATE Boost::atomic)
target_link_libraries(ice_engine PRIVATE Boost::thread)
target_link_libraries(ice_engine PRIVATE Boost::program_options)
target_link_libraries(ice_engine PRIVATE Boost::filesystem)
target_link_libraries(ice_engine PRIVATE Boost::log)
target_link_libraries(ice_engine PRIVATE Boost::log_setup)
target_link_libraries(ice_engine PRIVATE Boost::date_time)
target_link_libraries(ice_engine PRIVATE Boost::regex)
target_link_libraries(ice_engine PRIVATE Boost::serialization)
target_link_libraries(ice_engine PRIVATE Boost::wave)
target_link_libraries(ice_engine PRIVATE assimp::assimp)
target_link_libraries(ice_engine PRIVATE SDL2::SDL2)
target_link_libraries(ice_engine PRIVATE angelscript::angelscript)
target_link_libraries(ice_engine PRIVATE entityx::entityx)
target_link_libraries(ice_engine PRIVATE ctpl::ctpl)
if(APPLE)
target_link_libraries(ice_engine PUBLIC ${QUARTZCORE_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${METAL_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${APPKIT_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${APPSERV_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${CARBON_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${COREAUDIO_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${FORCEFEEDBACK_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${IOK_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${AUDIOTOOLBOX_LIBRARY})
target_link_libraries(ice_engine PUBLIC ${ICONV_LIBRARY})
endif()
if (ICEENGINE_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if (ICEENGINE_BUILD_BENCHMARKS)
enable_testing()
add_subdirectory(benchmarks)
endif()
# Disable Position Independent Executable - this is starting to be enabled by default,
# which is causing issues
target_link_libraries(ice_engine PUBLIC ${ICEENGINE_LINKER_FLAGS})
# Set install dir
install(TARGETS ice_engine DESTINATION /usr/lib)