forked from wheybags/freeablo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
108 lines (84 loc) · 3.99 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
cmake_minimum_required (VERSION 3.11)
## Windows Config ##
if (WIN32)
set (CMAKE_SYSTEM_VERSION 8.1 CACHE STRING INTERNAL FORCE)
set(desired_generators "Visual Studio 16 2019")
if (NOT "${CMAKE_GENERATOR}" IN_LIST desired_generators)
message(FATAL_ERROR "Incorrect generator, please run cmake with: -G GENERATOR, where GENERATOR is one of: ${desired_generators}")
endif()
set(HUNTER_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
endif()
project (Freeablo)
set(OpenGL_GL_PREFERENCE LEGACY)
Find_Package(OpenGL REQUIRED)
set(FA_COMPILER_FLAGS "")
set (CMAKE_CXX_STANDARD 17)
if(WIN32)
add_definitions(-DNOMINMAX) # http://stackoverflow.com/questions/5004858/stdmin-gives-error
endif()
option (FA_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors")
if(UNIX)
set(FA_COMPILER_FLAGS "${FA_COMPILER_FLAGS} -Wall -pedantic -Wextra -Wno-unknown-pragmas -Wno-missing-braces")
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
if (FA_TREAT_WARNINGS_AS_ERRORS)
set(FA_COMPILER_FLAGS "${FA_COMPILER_FLAGS} -Werror")
endif()
endif()
if(MSVC)
set(FA_COMPILER_FLAGS "${FA_COMPILER_FLAGS} /MP /W4 /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4100 /wd4611 /wd4458 /wd4459 /wd4127 /wd4800 /wd4267 /wd4172")
# 4244 - e.g. 'argument': conversion from 'const long double' to 'double' -- boost headers
# 4100 - unreferenced formal parameter -- boost headers
# 4172 - boost headers
# 4611 - interaction between '_setjmp' and C++ object destruction is non-portable -- savepng.cpp
# 4458 - shadow for class member -- librocket headers
# 4459 - declaration of 'self' hides global declaration
# 4127 - conditional expression is constant, could be useful to check that both branches compilable.
# 4267 - conversion from 'size_t' to 'int', possible loss of data -- too many such warnings in 64-bit build currently
# 4800 - forcing value to bool, stupid warning
set(FA_COMPILER_FLAGS "${FA_COMPILER_FLAGS} /w44062")
# 4061 - not all enumerator values are handled by the switch statement
add_definitions (-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS )
# SCL - because current boost is too old and emits this warning
# CRT - something in nuklear.h
if (FA_TREAT_WARNINGS_AS_ERRORS)
set(FA_COMPILER_FLAGS "${FA_COMPILER_FLAGS} /WX")
endif()
endif()
#TODO: get rid of this?
include_directories("${PROJECT_SOURCE_DIR}/components/")
# allow the user to specify extra include dirs and defines on the command line
if(CLI_INCLUDE_DIRS)
include_directories(${CLI_INCLUDE_DIRS})
endif()
if(CLI_DEFINES)
add_definitions(${CLI_DEFINES})
endif()
add_subdirectory (extern)
add_subdirectory (components)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(apps/freeablo)
add_subdirectory(apps/celview)
add_subdirectory(apps/mpqtool)
add_subdirectory(apps/exedump)
add_subdirectory(apps/launcher)
add_subdirectory(apps/fontgenerator)
add_subdirectory(test)
if(MSVC)
set_property(TARGET freeablo PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
set_property(TARGET celview PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
set_property(TARGET exedump PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
set_property(TARGET launcher PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
set_property(TARGET unit_tests PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()
# TODO: use the new FILE(CREATE_LINK) comand in newer cmake (+upgrade cmake on ci workers)
if (WIN32)
string(REPLACE "/" "\\" SYM_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}\\resources")
string(REPLACE "/" "\\" SYM_DEST "${CMAKE_CURRENT_BINARY_DIR}\\resources")
if (NOT EXISTS "${SYM_DEST}")
exec_program("cmd" ARGS "/wait" "/c" "mklink" "/j" "${SYM_DEST}" "${SYM_SOURCE}")
endif()
else()
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/resources")
execute_process(COMMAND "ln" "-s" "${CMAKE_CURRENT_SOURCE_DIR}/resources" "${CMAKE_CURRENT_BINARY_DIR}/resources")
endif()
endif()