diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2023-07-28 11:25:09 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2023-07-28 12:27:27 +0000 |
| commit | a4884f7b42659638eb1bfb59d131454878c1a71f (patch) | |
| tree | 67087cddc98b0ae057f0232dd0fe6c99260f4d3e /tools/cmake/DawAddState.cmake | |
| parent | 22db1a2e1b41bed7d5083ce68888a583881d58bf (diff) | |
test
Diffstat (limited to 'tools/cmake/DawAddState.cmake')
| -rw-r--r-- | tools/cmake/DawAddState.cmake | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/tools/cmake/DawAddState.cmake b/tools/cmake/DawAddState.cmake index a20aac7..4739b3c 100644 --- a/tools/cmake/DawAddState.cmake +++ b/tools/cmake/DawAddState.cmake @@ -1,36 +1,52 @@ # 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 -macro(daw_add_state STATEDIR) +# 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_${STATEDIR}/include) + ${CMAKE_SOURCE_DIR}/state_${STATENAME}/include) - file(APPEND ${CMAKE_BINARY_DIR}/include/state_type_list.h - "State(${STATEDIR})\n") + # Append state to list of states + file(APPEND ${CMAKE_BINARY_DIR}/include/states/list_of_states.h + "State(${STATENAME})\n") - file(APPEND ${CMAKE_BINARY_DIR}/include/include_states.h - "#include <states/${STATEDIR}.h>\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_${STATEDIR}/src/*.c + 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(${STATEDIR} MODULE ${STATE_SOURCES}) + add_library(${STATENAME} MODULE ${STATE_SOURCES}) else() - add_library(${STATEDIR} SHARED ${STATE_SOURCES}) + add_library(${STATENAME} SHARED ${STATE_SOURCES}) endif() else() - add_library(${STATEDIR} OBJECT ${STATE_SOURCES}) + add_library(${STATENAME} OBJECT ${STATE_SOURCES}) endif() - target_include_directories(${STATEDIR} PUBLIC - state_${STATEDIR}/include + target_include_directories(${STATENAME} PUBLIC + state_${STATENAME}/include ${daw_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include include @@ -38,7 +54,7 @@ macro(daw_add_state STATEDIR) set_property(TARGET daw APPEND PROPERTY LINK_LIBRARIES - ${STATEDIR}) + ${STATENAME}) - list(APPEND STATE_LIST ${STATEDIR}) + list(APPEND STATE_LIST ${STATENAME}) endmacro() |
