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()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
function(use_townengine target sources output_directory)
|
function(use_townengine target sources output_directory data_dir)
|
||||||
if (TOWNENGINE_HOT_RELOAD)
|
if (TOWNENGINE_HOT_RELOAD)
|
||||||
add_library(${target}_shared SHARED ${sources})
|
# game shared library, for reloading
|
||||||
set_target_properties(${target}_shared PROPERTIES
|
add_library(${target}_game SHARED ${sources})
|
||||||
|
set_target_properties(${target}_game PROPERTIES
|
||||||
OUTPUT_NAME game
|
OUTPUT_NAME game
|
||||||
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
||||||
give_options(${target}_shared)
|
give_options(${target}_game)
|
||||||
include_deps(${target}_shared)
|
include_deps(${target}_game)
|
||||||
target_link_libraries(${target}_shared PUBLIC SDL2::SDL2)
|
target_link_libraries(${target}_game PUBLIC SDL2::SDL2)
|
||||||
add_executable(${target} ${TOWNENGINE_DIR}/townengine/null.c)
|
|
||||||
set_target_properties(${target}_shared PROPERTIES
|
# launcher binary, loads game and engine shared library
|
||||||
OUTPUT_NAME game
|
add_executable(${target}_app ${TOWNENGINE_DIR}/townengine/null.c)
|
||||||
|
set_target_properties(${target}_app PROPERTIES
|
||||||
|
OUTPUT_NAME launcher
|
||||||
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
||||||
|
|
||||||
|
# put libtownengine.so alongside the binary
|
||||||
set_target_properties(${TOWNENGINE_TARGET} PROPERTIES
|
set_target_properties(${TOWNENGINE_TARGET} PROPERTIES
|
||||||
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
LIBRARY_OUTPUT_DIRECTORY ${output_directory})
|
||||||
else ()
|
else ()
|
||||||
add_executable(${target} ${sources})
|
add_executable(${target}_app ${sources})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# system libraries
|
# system libraries
|
||||||
find_library(MATH_LIBRARY m)
|
find_library(MATH_LIBRARY m)
|
||||||
if (MATH_LIBRARY)
|
if (MATH_LIBRARY)
|
||||||
target_link_libraries(${target} PUBLIC ${MATH_LIBRARY})
|
target_link_libraries(${target}_app PUBLIC ${MATH_LIBRARY})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
give_options(${target})
|
give_options(${target}_app)
|
||||||
include_deps(${target})
|
include_deps(${target}_app)
|
||||||
link_deps(${target})
|
link_deps(${target}_app)
|
||||||
target_link_libraries(${target} PUBLIC ${TOWNENGINE_TARGET})
|
target_link_libraries(${target}_app PUBLIC ${TOWNENGINE_TARGET})
|
||||||
|
set_target_properties(${target}_app PROPERTIES
|
||||||
set_target_properties(${target} PROPERTIES
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${output_directory})
|
RUNTIME_OUTPUT_DIRECTORY ${output_directory})
|
||||||
|
|
||||||
# copy dlls for baby windows
|
# copy dlls for baby windows
|
||||||
add_custom_command(TARGET ${target} POST_BUILD
|
add_custom_command(TARGET ${target}_app POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:${target}>
|
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:${target}_app>
|
||||||
$<TARGET_RUNTIME_DLLS:${target}>
|
$<TARGET_RUNTIME_DLLS:${target}_app>
|
||||||
COMMAND_EXPAND_LISTS)
|
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()
|
endfunction()
|
||||||
|
|
||||||
give_options(${TOWNENGINE_TARGET})
|
give_options(${TOWNENGINE_TARGET})
|
||||||
include_deps(${TOWNENGINE_TARGET})
|
include_deps(${TOWNENGINE_TARGET})
|
||||||
link_deps(${TOWNENGINE_TARGET})
|
link_deps(${TOWNENGINE_TARGET})
|
||||||
|
|
||||||
|
# build the testgame if this cmake list is built directly
|
||||||
if (${CMAKE_PROJECT_NAME} MATCHES townengine)
|
if (${CMAKE_PROJECT_NAME} MATCHES townengine)
|
||||||
add_subdirectory(apps/testgame)
|
add_subdirectory(apps/testgame)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -16,4 +16,4 @@ set(SOURCE_FILES
|
|||||||
state.h
|
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
|
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