From 1a34f6416bcc6d3019e2ed5a4ee40d9f6f230d3b Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Wed, 21 Aug 2024 17:29:06 +0300 Subject: [PATCH] fix .so placement and loading paths --- CMakeLists.txt | 10 ++++++++-- apps/template/CMakeLists.txt | 7 ++----- apps/template/game.c | 2 +- townengine/main.c | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4521263..3958e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,7 +122,8 @@ function(give_options target) -ffp-contract=fast -fno-signed-zeros -fno-trapping-math - -freciprocal-math) + -freciprocal-math + -Wl,$<$:-rpath ./>) set(BUILD_FLAGS_RELEASE -O3 @@ -204,7 +205,12 @@ function(use_townengine target sources output_directory) give_options(${target}_shared) include_deps(${target}_shared) target_link_libraries(${target}_shared PUBLIC SDL2::SDL2) - add_executable(${target} ${CMAKE_SOURCE_DIR}/townengine/null.c) + add_executable(${target} ${TOWNENGINE_DIR}/townengine/null.c) + set_target_properties(${target}_shared PROPERTIES + OUTPUT_NAME game + LIBRARY_OUTPUT_DIRECTORY ${output_directory}) + set_target_properties(${TOWNENGINE_TARGET} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${output_directory}) else () add_executable(${target} ${sources}) endif () diff --git a/apps/template/CMakeLists.txt b/apps/template/CMakeLists.txt index 49dfcc3..eb299c9 100644 --- a/apps/template/CMakeLists.txt +++ b/apps/template/CMakeLists.txt @@ -13,10 +13,7 @@ endif() set(SOURCE_FILES game.c + state.h ) -use_townengine(${PROJECT_NAME} "${SOURCE_FILES}") - -set_target_properties(${PROJECT_NAME} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) +use_townengine(${PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/apps/template/game.c b/apps/template/game.c index 6477369..84869f3 100644 --- a/apps/template/game.c +++ b/apps/template/game.c @@ -4,7 +4,7 @@ #include -void game_tick(t_ctx *ctx) { +void game_tick(void) { /* do state initialization when engine asks for it */ /* it could happen multiple times per application run, as game code is reloadable */ if (ctx.initialization_needed) { diff --git a/townengine/main.c b/townengine/main.c index e8bfd89..476c207 100644 --- a/townengine/main.c +++ b/townengine/main.c @@ -25,7 +25,7 @@ #include #ifdef __linux__ - #define GAME_OBJECT_PATH "../apps/testgame/libgame.so" + #define GAME_OBJECT_PATH "./libgame.so" #else #define GAME_OBJECT_PATH "game.dll" #endif