-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
94 lines (80 loc) · 3.19 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
#
# Beatmup image and signal processing library
# Copyright (C) 2019, lnstadrum
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.2.1)
project (Apps)
option(USE_LIB "Build static library and use it for all apps instead compiling the Beatmup source code for every app" ON)
option(DEBUG "Enable debugging" OFF)
set(PROFILE_PLATFORM_SPECIFIC_BITMAP ON)
set(PROFILE_NNETS ON)
include("core/CMakeLists.in")
if (USE_LIB)
add_library(_beatmup STATIC ${BEATMUP_SOURCES})
if (USE_GLX OR USE_OPENGL)
add_dependencies(_beatmup libglewmx_static)
if (NOT MSVC)
target_compile_options(libglewmx_static PRIVATE "-fPIC")
endif()
endif()
endif (USE_LIB)
# compiler-specific flags (not for Visual Studio)
if (NOT MSVC)
# add stop-on-first-error flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors")
# enable position-independend code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
# set debugging-related flags
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DBEATMUP_DEBUG")
elseif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif (DEBUG)
######################################################
# APPS #
######################################################
function(add_app APP_NAME APP_SOURCES)
if (USE_LIB)
add_executable(${APP_NAME} ${APP_SOURCES})
target_link_libraries(${APP_NAME} _beatmup)
else()
add_executable(${APP_NAME} ${BEATMUP_SOURCES} ${APP_SOURCES})
endif (USE_LIB)
if (MSVC)
set_property(TARGET ${APP_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY ${BEATMUP_ROOT_DIR})
elseif((USE_GLX OR USE_OPENGL) AND NOT USE_LIB)
add_dependencies(${APP_NAME} libglewmx_static)
endif (MSVC)
endfunction()
add_app(BasicRendering apps/basic_rendering/app.cpp)
add_app(Benchmark apps/benchmark/app.cpp)
add_app(Classify apps/classify/app.cpp)
add_app(FloodFill apps/flood_fill/app.cpp)
add_app(Shaderer apps/shaderer/app.cpp)
add_app(Tests apps/tests/app.cpp)
add_app(Tools apps/tools/app.cpp)
add_app(X2 apps/x2/app.cpp)
######################################################
# PYTHON BINDING #
######################################################
add_subdirectory(pybind11)
pybind11_add_module(beatmup SHARED
python/src/bitmap.cpp
python/src/chunk_collection.cpp
python/src/bindings.cpp
python/src/binding_tools.cpp)
target_link_libraries(beatmup PUBLIC _beatmup)