Windows support: portable local server launch + clean quit, %APPDATA% data dir, Win32 libs, MinGW/MSVC build docs
This commit is contained in:
@@ -41,12 +41,19 @@ target_include_directories(bs_shared PUBLIC shared)
|
||||
target_link_libraries(bs_shared PUBLIC glm::glm nlohmann_json::nlohmann_json enet)
|
||||
target_compile_definitions(bs_shared PUBLIC GLM_FORCE_RADIANS GLM_ENABLE_EXPERIMENTAL
|
||||
BS_ASSET_DIR="${CMAKE_SOURCE_DIR}/assets")
|
||||
if(WIN32)
|
||||
target_link_libraries(bs_shared PUBLIC ws2_32 winmm) # ENet sockets + timers
|
||||
endif()
|
||||
if(MSVC)
|
||||
target_compile_options(bs_shared PRIVATE /W4)
|
||||
target_link_libraries(bs_shared PUBLIC ws2_32 winmm)
|
||||
target_compile_options(bs_shared PRIVATE /W4 /utf-8)
|
||||
else()
|
||||
target_compile_options(bs_shared PRIVATE -Wall -Wextra -Wno-unused-parameter)
|
||||
endif()
|
||||
if(MINGW)
|
||||
# no libgcc / libstdc++ DLLs to ship next to the executables; C99 printf (%zu) on msvcrt
|
||||
add_link_options(-static-libgcc -static-libstdc++)
|
||||
target_compile_definitions(bs_shared PUBLIC __USE_MINGW_ANSI_STDIO=1)
|
||||
endif()
|
||||
|
||||
# --- Server -------------------------------------------------------------------
|
||||
if(BS_BUILD_SERVER)
|
||||
@@ -54,7 +61,12 @@ if(BS_BUILD_SERVER)
|
||||
find_package(Threads REQUIRED)
|
||||
file(GLOB BS_SERVER_SOURCES CONFIGURE_DEPENDS server/*.cpp)
|
||||
add_executable(safari_server ${BS_SERVER_SOURCES})
|
||||
target_link_libraries(safari_server PRIVATE bs_shared SQLite::SQLite3 Threads::Threads)
|
||||
if(TARGET SQLite3::SQLite3) # CMake >= 4.3 name; older releases only define SQLite::SQLite3
|
||||
set(BS_SQLITE SQLite3::SQLite3)
|
||||
else()
|
||||
set(BS_SQLITE SQLite::SQLite3)
|
||||
endif()
|
||||
target_link_libraries(safari_server PRIVATE bs_shared ${BS_SQLITE} Threads::Threads)
|
||||
if(NOT MSVC)
|
||||
target_compile_options(safari_server PRIVATE -Wall -Wextra -Wno-unused-parameter)
|
||||
endif()
|
||||
@@ -86,6 +98,13 @@ if(BS_BUILD_CLIENT)
|
||||
if(NOT MSVC)
|
||||
target_compile_options(safari_client PRIVATE -Wall -Wextra -Wno-unused-parameter)
|
||||
endif()
|
||||
if(WIN32)
|
||||
# A game, not a console tool: no console window opens next to it.
|
||||
set_target_properties(safari_client PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
if(MSVC)
|
||||
target_link_options(safari_client PRIVATE /ENTRY:mainCRTStartup) # keep int main()
|
||||
endif()
|
||||
endif()
|
||||
# The client launches the dedicated server for "Host game" from its own folder.
|
||||
if(BS_BUILD_SERVER)
|
||||
add_dependencies(safari_client safari_server)
|
||||
|
||||
Reference in New Issue
Block a user