add bootstrapping shell script for purposes of setting --data-dir and cwd for LD_PATH=./
This commit is contained in:
parent
9a3d7a9db3
commit
ca3cda25df
@ -196,50 +196,67 @@ function(link_deps target)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(use_townengine target sources output_directory)
|
||||
function(use_townengine target sources output_directory data_dir)
|
||||
if (TOWNENGINE_HOT_RELOAD)
|
||||
add_library(${target}_shared SHARED ${sources})
|
||||
set_target_properties(${target}_shared PROPERTIES
|
||||
# game shared library, for reloading
|
||||
add_library(${target}_game SHARED ${sources})
|
||||
set_target_properties(${target}_game PROPERTIES
|
||||
OUTPUT_NAME game
|
||||
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
||||
give_options(${target}_shared)
|
||||
include_deps(${target}_shared)
|
||||
target_link_libraries(${target}_shared PUBLIC SDL2::SDL2)
|
||||
add_executable(${target} ${TOWNENGINE_DIR}/townengine/null.c)
|
||||
set_target_properties(${target}_shared PROPERTIES
|
||||
OUTPUT_NAME game
|
||||
give_options(${target}_game)
|
||||
include_deps(${target}_game)
|
||||
target_link_libraries(${target}_game PUBLIC SDL2::SDL2)
|
||||
|
||||
# launcher binary, loads game and engine shared library
|
||||
add_executable(${target}_app ${TOWNENGINE_DIR}/townengine/null.c)
|
||||
set_target_properties(${target}_app PROPERTIES
|
||||
OUTPUT_NAME launcher
|
||||
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
||||
|
||||
# put libtownengine.so alongside the binary
|
||||
set_target_properties(${TOWNENGINE_TARGET} PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
||||
else ()
|
||||
add_executable(${target} ${sources})
|
||||
add_executable(${target}_app ${sources})
|
||||
endif ()
|
||||
|
||||
# system libraries
|
||||
find_library(MATH_LIBRARY m)
|
||||
if (MATH_LIBRARY)
|
||||
target_link_libraries(${target} PUBLIC ${MATH_LIBRARY})
|
||||
target_link_libraries(${target}_app PUBLIC ${MATH_LIBRARY})
|
||||
endif ()
|
||||
|
||||
give_options(${target})
|
||||
include_deps(${target})
|
||||
link_deps(${target})
|
||||
target_link_libraries(${target} PUBLIC ${TOWNENGINE_TARGET})
|
||||
|
||||
set_target_properties(${target} PROPERTIES
|
||||
give_options(${target}_app)
|
||||
include_deps(${target}_app)
|
||||
link_deps(${target}_app)
|
||||
target_link_libraries(${target}_app PUBLIC ${TOWNENGINE_TARGET})
|
||||
set_target_properties(${target}_app PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${output_directory})
|
||||
|
||||
# copy dlls for baby windows
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:${target}>
|
||||
$<TARGET_RUNTIME_DLLS:${target}>
|
||||
add_custom_command(TARGET ${target}_app POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:${target}_app>
|
||||
$<TARGET_RUNTIME_DLLS:${target}_app>
|
||||
COMMAND_EXPAND_LISTS)
|
||||
|
||||
if (UNIX)
|
||||
# create a bootstrapping script
|
||||
string(JOIN "\n" TOWNENGINE_BOOTSTRAP
|
||||
"#!/bin/env sh"
|
||||
"cd \"$(dirname \"$0\")\""
|
||||
"./launcher --data-dir ${data_dir}")
|
||||
|
||||
FILE(GENERATE OUTPUT ${output_directory}/${target}
|
||||
CONTENT "${TOWNENGINE_BOOTSTRAP}"
|
||||
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
give_options(${TOWNENGINE_TARGET})
|
||||
include_deps(${TOWNENGINE_TARGET})
|
||||
link_deps(${TOWNENGINE_TARGET})
|
||||
|
||||
# build the testgame if this cmake list is built directly
|
||||
if (${CMAKE_PROJECT_NAME} MATCHES townengine)
|
||||
add_subdirectory(apps/testgame)
|
||||
endif ()
|
||||
|
@ -16,4 +16,4 @@ set(SOURCE_FILES
|
||||
state.h
|
||||
)
|
||||
|
||||
use_townengine(${PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
use_townengine(${PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_CURRENT_SOURCE_DIR} ../../data)
|
||||
|
@ -23,4 +23,4 @@ set(SOURCE_FILES
|
||||
scenes/ingame.c scenes/ingame.h
|
||||
)
|
||||
|
||||
use_townengine(${PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
use_townengine(${PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_CURRENT_SOURCE_DIR} ../../data)
|
||||
|
Loading…
Reference in New Issue
Block a user