blob: 92c2112d58ac678d7efd89d6f7df01f4b841bcd3 (
plain)
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
|
# Add the directory to the list of states.
# The directories contents will be compiled into a shared object file and linked
# to the main daw library, unless you compile statically, or link during runtime.
#
# Say you want to add a new state, called ${STATENAME} to your project, localted
# at ${PROJECT_ROOT}, Then your directory structure for your main project should
# be as follows:
# ${PROJECT_ROOT}/
# ├ state_${STATENAME}/
# │ ├ includes/states/${STATENAME}.h
# │ └ src/ ..
# ├ state_foo/ ..
# └ state_bar/ ..
#
# Then call `daw_add_state(${STATENAME}) for each of your states.
macro(daw_add_state STATENAME)
# Add state include directory to the engines target
set_property(TARGET daw
APPEND PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/state_${STATENAME}/include)
# Append state to list of states
file(APPEND ${CMAKE_BINARY_DIR}/include/states/list_of_states.h
"State(${STATENAME})\n")
# Append header inclusion of state to common state header
file(APPEND ${CMAKE_BINARY_DIR}/include/states/all_states.h
"#include <states/${STATENAME}.h>\n")
# Glob the states sources, not my proudest moment
file(GLOB STATE_SOURCES
LIST_DIRECTORIES false
state_${STATENAME}/src/*.c
)
# TODO: When state reloading is implemented properly, add MODULE library
# option In general, this should only be available when debugging.
if(BUILD_SHARED_LIBS)
if(DAW_BUILD_DEBUG AND DAW_BUILD_HOTRELOAD)
add_library(${STATENAME} MODULE ${STATE_SOURCES})
else()
add_library(${STATENAME} SHARED ${STATE_SOURCES})
endif()
else()
add_library(${STATENAME} OBJECT ${STATE_SOURCES})
endif()
target_include_directories(${STATENAME} PUBLIC
state_${STATENAME}/include
${daw_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include
include
)
if(NOT DAW_BUILD_HOTRELOAD)
set_property(TARGET daw
APPEND PROPERTY LINK_LIBRARIES
${STATENAME})
endif()
list(APPEND STATE_LIST ${STATENAME})
endmacro()
|