-
Notifications
You must be signed in to change notification settings - Fork 8
/
CreativeEngine.cmake
152 lines (120 loc) · 4.94 KB
/
CreativeEngine.cmake
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
### CREATIVE ENGINE CMAKE ####
# Exports:
# ${CREATIVE_ENGINE_INCLUDE_DIRS} - used in INCLUDE_DIRECTORIES(...)
# ${CREATIVE_ENGINE_SOURCE_FILES} - used in ADD_EXECUTABLE(...)
# ${CREATIVE_ENGINE_LINK_LIBRARIES} - used in TARGET_LINK_LIBRARIES(...)
# creative-engine path
if (EXISTS $ENV{CREATIVE_ENGINE_PATH})
# SET ENV variable in CLion project SETtings
SET(CREATIVE_ENGINE_PATH $ENV{CREATIVE_ENGINE_PATH})
# message(STATUS "********************************* Using user-defined creative-engine path: ${CREATIVE_ENGINE_PATH}")
else ()
# SET(CREATIVE_ENGINE_PATH "${CMAKE_SOURCE_DIR}/../creative-engine") # This broke debugging in clion!
SET(CREATIVE_ENGINE_PATH "${CMAKE_SOURCE_DIR}/creative-engine")
# message(STATUS "<<<<<<<<<<<<<<<<<<<<<<<<<< Falling back to default creative-engine path: ${CREATIVE_ENGINE_PATH}")
endif ()
INCLUDE(FindPkgConfig)
# CMake Module path (additional cmake files via find_package)
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/creative-engine/cmake.files)
include(CMakePrintHelpers)
FIND_PACKAGE(SDL2 REQUIRED)
FIND_PACKAGE(SDL2_image REQUIRED)
ProcessorCount(N)
if(NOT N EQUAL 0)
set(N, N*2) # use hyperthreads - processor count is 4 on an i7 that has 8 cores including hyperthreads
set(${PROJECT_NAME}_FLAGS -j${N})
set(${PROJECT_NAME}_args ${${PROJECT_NAME}_args} PARALLEL_LEVEL ${N})
endif()
INCLUDE_DIRECTORIES(
${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_MIXER_INCLUDE_DIR}
)
#Debug purposes
#ADD_COMPILE_DEFINITIONS(__XTENSA__=true)
# Exports:
# ${CREATIVE_ENGINE_INCLUDE_DIRS} - used in INCLUDE_DIRECTORIES(...)
# ${CREATIVE_ENGINE_SOURCE_FILES} - used in ADD_EXECUTABLE(...)
# ${CREATIVE_ENGINE_LINK_LIBRARIES} - used in TARGET_LINK_LIBRARIES(...)
########## RCOMP #########
function(compile_rcomp_and_resources)
# resource compiler
SET(RCOMP "${CREATIVE_ENGINE_PATH}/tools/rcomp")
# build rcomp-src
ADD_CUSTOM_COMMAND(
OUTPUT rcomp
COMMAND cd ${CREATIVE_ENGINE_PATH}/tools/rcomp-src && $(MAKE) # $(MAKE) passes -j to make
COMMENT "Building rcomp ${CREATIVE_ENGINE_PATH}"
)
# build Resources.bin
ADD_CUSTOM_COMMAND(
OUTPUT Resources.bin
COMMAND find ${CMAKE_CURRENT_SOURCE_DIR} -name "Resources.bin" -exec rm -f {} +
COMMAND find ${CMAKE_CURRENT_BINARY_DIR} -name "BResourceManager.cpp.o" -exec rm -f {} +
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/src && ${RCOMP} Resources.r
DEPENDS rcomp
COMMENT "Compiling Resources ${CMAKE_CURRENT_SOURCE_DIR}"
)
endfunction()
# Used in INCLUDE_DIRECTORIES(...)
SET(CREATIVE_ENGINE_INCLUDE_DIRS
${CREATIVE_ENGINE_PATH}/src
${CREATIVE_ENGINE_PATH}/src/BStore
${CREATIVE_ENGINE_PATH}/src/BStore/DesktopStore
${CREATIVE_ENGINE_PATH}/src/Audio
${CREATIVE_ENGINE_PATH}/src/Audio/mixer
${CREATIVE_ENGINE_PATH}/src/Audio/SDL2Audio
${CREATIVE_ENGINE_PATH}/src/Audio/LDKAudio
${CREATIVE_ENGINE_PATH}/src/Display
${CREATIVE_ENGINE_PATH}/src/Display/DesktopDisplay
${CREATIVE_ENGINE_PATH}/src/Display/LDKDisplay
${CREATIVE_ENGINE_PATH}/src/Controls
${CREATIVE_ENGINE_PATH}/src/Controls/DesktopControls
${CREATIVE_ENGINE_PATH}/src/Controls/LDKControls
${CREATIVE_ENGINE_PATH}/src/Widgets
${CREATIVE_ENGINE_PATH}/src/libxmp
${CREATIVE_ENGINE_PATH}/src/libxmp/loaders
)
#This is for LibXMP minimal build
ADD_COMPILE_DEFINITIONS(LIBXMP_CORE_PLAYER=true)
# gather creative-engine sources
# Used in ADD_EXECUTABLE(...)
file(GLOB_RECURSE CREATIVE_ENGINE_SOURCE_FILES
${CREATIVE_ENGINE_PATH}/src/*.cpp
${CREATIVE_ENGINE_PATH}/src/*.c
)
SET(_CE_SDL2_LIBRARIES ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY})
#message("_CE_SDL2_LIBRARIES = ${_CE_SDL2_LIBRARIES}")
# could change to "CE_DIRECT_LINUX_CONTROS_ENABLED=true make"
# Direct linux controls (non-SDL2!)
if (DEFINED ENV{CE_DIRECT_LINUX_CONTROS_ENABLED})
ADD_COMPILE_DEFINITIONS(__MODUS_TARGET_DIRECT_LINUX_CONTROLS__=true)
else()
ADD_COMPILE_DEFINITIONS(__MODUS_TARGET_DESKTOP_CONTROLS__=true)
endif()
# Network matrix display
if (DEFINED ENV{CE_NETWORK_DISPLAY_ENABLED})
ADD_COMPILE_DEFINITIONS(__MODUS_TARGET_NETWORK_DISPLAY__=true)
INCLUDE_DIRECTORIES(
${CREATIVE_ENGINE_PATH}/src/Display/NetworkDisplay
${CREATIVE_ENGINE_PATH}/src/Controls/DirectLinuxControls
)
FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(Boost REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
SET(_BOOST_AND_THREADS
${CMAKE_THREAD_LIBS_INIT}
${Boost_System}
)
elseif (DEFINED ENV{CE_DESKTOP_DISPLAY_ENABLED})
ADD_COMPILE_DEFINITIONS(__MODUS_TARGET_DESKTOP_DISPLAY__=true)
#Append image for video
SET(_CE_SDL2_LIBRARIES "${_CE_SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES}")
SET(_BOOST_AND_THREADS "")
endif()
# Used in TARGET_LINK_LIBRARIES(...)
SET(CREATIVE_ENGINE_LINK_LIBRARIES
${_CE_SDL2_LIBRARIES}
${_BOOST_AND_THREADS}
)
MESSAGE(CREATIVE_ENGINE_LINK_LIBRARIES " " ${CREATIVE_ENGINE_LINK_LIBRARIES})