mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-06 06:30:33 -04:00
prepare linux build target Ubuntu 22, x64
This commit is contained in:
parent
8ef23fe366
commit
0a39f2d3d5
4 changed files with 29 additions and 19 deletions
|
@ -1,5 +1,3 @@
|
||||||
SET(files error.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(skeldal_platform STATIC)
|
add_library(skeldal_platform STATIC)
|
||||||
|
|
||||||
|
@ -15,6 +13,15 @@ target_sources(skeldal_platform PRIVATE
|
||||||
getopt.c
|
getopt.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(all_libs
|
||||||
|
skeldal_main
|
||||||
|
skeldal_libs
|
||||||
|
skeldal_platform
|
||||||
|
skeldal_sdl
|
||||||
|
skeldal_libs
|
||||||
|
${SDL2_LIBRARIES}
|
||||||
|
${STANDARD_LIBRARIES})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_sources(skeldal_platform PRIVATE
|
target_sources(skeldal_platform PRIVATE
|
||||||
windows/save_folder.cpp
|
windows/save_folder.cpp
|
||||||
|
@ -27,6 +34,7 @@ if(WIN32)
|
||||||
windows/skeldal.rc
|
windows/skeldal.rc
|
||||||
)
|
)
|
||||||
target_compile_definitions(skeldal_platform PRIVATE PLATFORM_WINDOWS)
|
target_compile_definitions(skeldal_platform PRIVATE PLATFORM_WINDOWS)
|
||||||
|
target_link_libraries(skeldal ${all_libs})
|
||||||
message(STATUS "Building for Windows")
|
message(STATUS "Building for Windows")
|
||||||
|
|
||||||
elseif(UNIX AND NOT APPLE)
|
elseif(UNIX AND NOT APPLE)
|
||||||
|
@ -34,16 +42,17 @@ elseif(UNIX AND NOT APPLE)
|
||||||
linux/save_folder.cpp
|
linux/save_folder.cpp
|
||||||
linux/map_file.cpp
|
linux/map_file.cpp
|
||||||
)
|
)
|
||||||
add_executable(skeldal)
|
add_executable(skeldal_bin)
|
||||||
target_sources(skeldal PRIVATE
|
target_sources(skeldal_bin PRIVATE
|
||||||
linux/app_start.cpp
|
linux/app_start.cpp
|
||||||
)
|
)
|
||||||
target_compile_definitions(skeldal_platform PRIVATE PLATFORM_LINUX)
|
target_compile_definitions(skeldal_platform PRIVATE PLATFORM_LINUX)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET skeldal POST_BUILD
|
TARGET skeldal_bin POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
${CMAKE_CURRENT_LIST_DIR}/linux/skeldal.sh
|
${CMAKE_CURRENT_LIST_DIR}/linux/skeldal.sh
|
||||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/skeldal.sh)
|
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/skeldal.sh)
|
||||||
|
target_link_libraries(skeldal_bin ${all_libs})
|
||||||
message(STATUS "Building for Linux")
|
message(STATUS "Building for Linux")
|
||||||
|
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
@ -56,18 +65,11 @@ elseif(APPLE)
|
||||||
)
|
)
|
||||||
target_compile_definitions(mylib PRIVATE PLATFORM_MACOS)
|
target_compile_definitions(mylib PRIVATE PLATFORM_MACOS)
|
||||||
message(STATUS "Building for macOS")
|
message(STATUS "Building for macOS")
|
||||||
|
target_link_libraries(skeldal ${all_libs})
|
||||||
else()
|
else()
|
||||||
error("Platform not detected, please add new platform here")
|
error("Platform not detected, please add new platform here")
|
||||||
endif()
|
endif()
|
||||||
set_property(TARGET skeldal_platform PROPERTY CXX_STANDARD 20)
|
set_property(TARGET skeldal_platform PROPERTY CXX_STANDARD 20)
|
||||||
|
|
||||||
add_subdirectory(sdl)
|
add_subdirectory(sdl)
|
||||||
|
|
||||||
target_link_libraries(skeldal
|
|
||||||
skeldal_main
|
|
||||||
skeldal_libs
|
|
||||||
skeldal_platform
|
|
||||||
skeldal_sdl
|
|
||||||
skeldal_libs
|
|
||||||
${SDL2_LIBRARIES}
|
|
||||||
${STANDARD_LIBRARIES})
|
|
||||||
|
|
|
@ -114,6 +114,14 @@ char change_current_directory(const char *path) {
|
||||||
return ec == std::error_code{}?1:0;
|
return ec == std::error_code{}?1:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::chrono::system_clock::time_point from_file_time(std::filesystem::file_time_type::clock::time_point tp) {
|
||||||
|
return std::chrono::time_point_cast<std::chrono::system_clock::duration>(
|
||||||
|
tp - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ctx) {
|
int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ctx) {
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
std::filesystem::directory_iterator iter(std::string(directory), ec);
|
std::filesystem::directory_iterator iter(std::string(directory), ec);
|
||||||
|
@ -130,7 +138,7 @@ int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ct
|
||||||
tmp = entry.path().string();
|
tmp = entry.path().string();
|
||||||
}
|
}
|
||||||
if (type & file_type_need_timestamp) {
|
if (type & file_type_need_timestamp) {
|
||||||
auto tm = std::chrono::clock_cast<std::chrono::system_clock>(entry.last_write_time(ec));
|
auto tm = from_file_time(entry.last_write_time(ec));
|
||||||
szortm = std::chrono::system_clock::to_time_t(tm);
|
szortm = std::chrono::system_clock::to_time_t(tm);
|
||||||
} else {
|
} else {
|
||||||
szortm = entry.file_size(ec);
|
szortm = entry.file_size(ec);
|
||||||
|
|
|
@ -20,7 +20,7 @@ void show_help(const char *arg0) {
|
||||||
"-l <lang> set language (cz|en)\n"
|
"-l <lang> set language (cz|en)\n"
|
||||||
"-s <directory> generate string-tables (for localization) and exit\n"
|
"-s <directory> generate string-tables (for localization) and exit\n"
|
||||||
"-h this help\n");
|
"-h this help\n");
|
||||||
exit(0);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_help_short() {
|
void show_help_short() {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
temp_file=$(mktemp /tmp/skeldal.XXXXXX.log)
|
temp_file=$(mktemp /tmp/skeldal.XXXXXX.log)
|
||||||
|
|
||||||
./skeldal > "$temp_file" 2>&1
|
`dirname $0`/skeldal_bin $* > "$temp_file" 2>&1
|
||||||
|
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ if [ $exit_code -ne 0 ]; then
|
||||||
error_message=$(cat "$temp_file")
|
error_message=$(cat "$temp_file")
|
||||||
|
|
||||||
if command -v zenity > /dev/null; then
|
if command -v zenity > /dev/null; then
|
||||||
zenity --warning --title="Skeldal ERROR" --text="$error_message"
|
zenity --warning --no-markup --title="Skeldal ERROR" --text="$error_message"
|
||||||
elif command -v kdialog > /dev/null; then
|
elif command -v kdialog > /dev/null; then
|
||||||
kdialog --title "Skeldal ERROR" --error "$error_message"
|
kdialog --title "Skeldal ERROR" --error "$error_message"
|
||||||
elif command -v xmessage > /dev/null; then
|
elif command -v xmessage > /dev/null; then
|
||||||
|
@ -22,5 +22,5 @@ if [ $exit_code -ne 0 ]; then
|
||||||
cat "$temp_file"
|
cat "$temp_file"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#rm $temp_file
|
rm $temp_file
|
||||||
exit $exit_code
|
exit $exit_code
|
Loading…
Add table
Add a link
Reference in a new issue