From 08fd5970a11311ed9bccbc8ef20e4077c9839af8 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Tue, 20 Aug 2024 17:50:50 +0300 Subject: [PATCH] slight restructure of CMakeLists --- CMakeLists.txt | 8 ++++++-- apps/template/CMakeLists.txt | 3 +-- apps/testgame/CMakeLists.txt | 3 +-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d12a67..3eb5749 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,7 +187,9 @@ function(link_and_include_deps target) endfunction() -function(use_townengine target) +function(use_townengine target sources) + add_executable(${target} ${sources}) + # system libraries find_library(MATH_LIBRARY m) if(MATH_LIBRARY) @@ -219,7 +221,9 @@ endfunction() give_options(${TOWNENGINE_TARGET}) link_and_include_deps(${TOWNENGINE_TARGET}) -add_subdirectory(apps/testgame) +if (${CMAKE_PROJECT_NAME} MATCHES townengine) + add_subdirectory(apps/testgame) +endif () # zip up assets # currently, you must run cmake from the project root dir for this to work correctly diff --git a/apps/template/CMakeLists.txt b/apps/template/CMakeLists.txt index 68d6f74..49dfcc3 100644 --- a/apps/template/CMakeLists.txt +++ b/apps/template/CMakeLists.txt @@ -15,8 +15,7 @@ set(SOURCE_FILES game.c ) -add_executable(${PROJECT_NAME} ${SOURCE_FILES}) -use_townengine(${PROJECT_NAME}) +use_townengine(${PROJECT_NAME} "${SOURCE_FILES}") set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/apps/testgame/CMakeLists.txt b/apps/testgame/CMakeLists.txt index 61bdb8c..4b310c2 100644 --- a/apps/testgame/CMakeLists.txt +++ b/apps/testgame/CMakeLists.txt @@ -23,8 +23,7 @@ set(SOURCE_FILES scenes/ingame.c scenes/ingame.h ) -add_executable(${PROJECT_NAME} ${SOURCE_FILES}) -use_townengine(${PROJECT_NAME}) +use_townengine(${PROJECT_NAME} "${SOURCE_FILES}") set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}