-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
170 lines (138 loc) · 4.44 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#
# Face Smash
#
cmake_minimum_required(VERSION 3.9)
#
# Building in-tree is not allowed (we take care of your craziness).
#
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.")
endif()
#
# Project configuration
#
project(facesmash VERSION 0.0.1)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(SETTINGS_ORGANIZATION "Michele Caini")
set(SETTINGS_APPLICATION ${PROJECT_NAME})
set(PROJECT_AUTHOR "Michele Caini")
set(PROJECT_AUTHOR_EMAIL "michele.caini@gmail.com")
message("*")
message("* ${PROJECT_NAME} v${PROJECT_VERSION} (${CMAKE_BUILD_TYPE})")
message("* Copyright (c) 2018 ${PROJECT_AUTHOR} <${PROJECT_AUTHOR_EMAIL}>")
message("*")
#
# Compiler stuff
#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DRELEASE")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -DDEBUG")
if(ASAN)
message("-- Address sanitizer enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif(ASAN)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CLANG_CXX_FLAGS "-Wno-missing-braces -Wno-mismatched-tags")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CLANG_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CLANG_CXX_FLAGS}")
endif()
#
# Dependencies
#
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${facesmash_SOURCE_DIR}/cmake/module)
if(WIN32)
set(ENV{SDL2DIR} ${facesmash_SOURCE_DIR}/deps/SDL2)
set(ENV{SDL2IMAGEDIR} ${facesmash_SOURCE_DIR}/deps/SDL2_image)
set(ENV{SDL2MIXERDIR} ${facesmash_SOURCE_DIR}/deps/SDL2_mixer)
set(ENV{SDL2TTFDIR} ${facesmash_SOURCE_DIR}/deps/SDL2_ttf)
set(ZLIB_ROOT ${facesmash_SOURCE_DIR}/deps/zlib)
set(VISAGE_LIB_SUFFIX "64${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(OpenCV_DIR ${facesmash_SOURCE_DIR}/deps/opencv/build)
else()
set(VISAGE_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenCV REQUIRED)
if(NOT WIN32)
find_package(BLAS REQUIRED)
find_package(OpenMP)
# used for video stream acquisition
endif()
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
set(
VISAGE_SDK_LIBRARIES
${facesmash_SOURCE_DIR}/deps/visageSDK/lib/libVisageVision${VISAGE_LIB_SUFFIX}
${facesmash_SOURCE_DIR}/deps/visageSDK/lib/libVisageAnalyser${VISAGE_LIB_SUFFIX}
)
# this is necessary on archlinux to disable the default Position Independent Executable
link_libraries("-no-pie")
link_libraries("${BLAS_LINKER_FLAGS}")
option(BUILD_TESTING "Disable testing with ctest for EnTT." ON)
configure_file(${facesmash_SOURCE_DIR}/cmake/in/EnTT.in ${facesmash_SOURCE_DIR}/deps/EnTT/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${facesmash_SOURCE_DIR}/deps/EnTT)
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${facesmash_SOURCE_DIR}/deps/EnTT)
include_directories(
${facesmash_SOURCE_DIR}/deps/EnTT/src/src
${facesmash_SOURCE_DIR}/deps/visageSDK/include
)
#
# The Game
#
add_subdirectory(src)
add_executable(facesmash ${FACE_SMASH_SOURCES})
target_include_directories(
facesmash
PRIVATE ${SDL2_INCLUDE_DIR}
PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS}
PRIVATE ${SDL2_MIXER_INCLUDE_DIRS}
PRIVATE ${SDL2_TTF_INCLUDE_DIRS}
PRIVATE ${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(
facesmash
PRIVATE ${SDL2_LIBRARY}
PRIVATE ${SDL2_IMAGE_LIBRARIES}
PRIVATE ${SDL2_MIXER_LIBRARIES}
PRIVATE ${SDL2_TTF_LIBRARIES}
PRIVATE ${ZLIB_LIBRARIES}
PRIVATE ${BLAS_LIBRARIES}
PRIVATE ${VISAGE_SDK_LIBRARIES}
PRIVATE ${OpenCV_LIBS}
)
add_definitions(-DVISAGE_STATIC)
#
# Package
#
install(
DIRECTORY
${facesmash_SOURCE_DIR}/assets/png
${facesmash_SOURCE_DIR}/assets/font
DESTINATION ${facesmash_BINARY_DIR}/game
)
install(
TARGETS facesmash
DESTINATION ${facesmash_BINARY_DIR}/game
)
#
# AOB
#
add_custom_target(
facesmash_aob
SOURCES
AUTHORS
LICENSE
README.md
TODO
)