-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
130 lines (99 loc) · 3.4 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
cmake_minimum_required(VERSION 3.0)
project(Engine)
#===================Global vars========================
SET_PROPERTY(GLOBAL PROPERTY ENGINE_LIBS "")
SET_PROPERTY(GLOBAL PROPERTY ENGINE_INCLUDES "")
#======================================================
#===================Build options======================
option(BUILD_STATIC_LIB OFF)
option(BUILD_DYNAMIC_LIB OFF)
#Third-party libraries
option(USE_LUA ON)
option(USE_PHYSFS ON)
option(USE_SIMPLE_JSON ON)
#======================================================
#=====================Includes=========================
#Get Engine's sources
aux_source_directory(src SRC)
aux_source_directory(src/Core SRC_CORE)
aux_source_directory(src/GUI SRC_GUI)
aux_source_directory(src/GUI/Widgets SRC_WIDGETS)
aux_source_directory(src/Render SRC_RENDER)
aux_source_directory(src/IO SRC_IO)
aux_source_directory(src/LuaBindings SRC_LUA_BINDINGS)
aux_source_directory(src/Common SRC_COMMON)
set(SOURCES
${SRC}
${SRC_CORE}
${SRC_GUI}
${SRC_WIDGETS}
${SRC_RENDER}
${SRC_IO}
${SRC_COMMON}
src/Common/sys.h
src/Common/constants.h
)
#Append Lua includes
if(USE_LUA)
set(SOURCES ${SOURCES} ${SRC_LUA_BINDINGS})
add_definitions("-DUSE_LUA")
endif()
if(USE_PHYSFS)
add_definitions("-DUSE_PHYSFS")
endif()
if(USE_SIMPLE_JSON)
add_definitions("-DUSE_SIMPLE_JSON")
endif()
#include sources root
include_directories(src)
#======================================================
#================Compiler determining==================
set(GNU_CLANG ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if(UNIX AND NOT APPLE)
set(LINUX ON)
endif()
if(APPLE)
message(SEND_ERROR "MacOSX is not configured yet.\n[WARNING] Trying to use Linux build configuration.")
endif()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
message(SEND_ERROR "MSVC isn't configured yet, but it's able to compile with it ;)")
endif()
if(WIN32)
#Fix for sol2 building under MinGW
add_definitions("-D_GLIBCXX_USE_C99_CTYPE_TR1")
endif()
#======================================================
#================Compiler configuring==================
if(COVERAGE_ENABLED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif(COVERAGE_ENABLED)
if(BUILD_STATIC_LIB)
add_definitions("-DBUILD_STATIC_LIB")
add_library(${PROJECT_NAME} STATIC ${SOURCES})
elseif(BUILD_DYNAMIC_LIB)
add_library(${PROJECT_NAME} SHARED ${SOURCES})
elseif(NOT(BUILD_STATIC_LIB AND BUILD_DYNAMIC_LIB))
#Set binary folder
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
add_executable(${PROJECT_NAME} ${SOURCES})
endif()
#======================================================
#==================Libraries linking===================
#Add third-party libs
add_subdirectory(Third-party)
#extract globals
GET_PROPERTY(LOCAL_INCLUDES GLOBAL PROPERTY ENGINE_INCLUDES)
GET_PROPERTY(LOCAL_LIBS GLOBAL PROPERTY ENGINE_LIBS)
include_directories(${LOCAL_INCLUDES})
target_link_libraries(${PROJECT_NAME} ${LOCAL_LIBS})
#======================================================
#=================C++ standard setup===================
set(CXX_STANDARD_REQUIRED ON)
if(USE_LUA)
#Require c++14 standard
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
else()
#Require c++11 standard
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
endif()
#======================================================