From 99550f97bdf079dc4af4281d35689ec4004058d1 Mon Sep 17 00:00:00 2001 From: Hanicef Date: Sat, 27 Apr 2024 16:40:11 +0200 Subject: [PATCH] Fix FreeBSD build --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 4 ++++ src/io/streams.cpp | 4 ++-- src/stun.cpp | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 121d598a2..15ae9cd2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,8 @@ if("${SRB2_CPACK_GENERATOR}" STREQUAL "") set(SRB2_CPACK_GENERATOR "TGZ") elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") set(SRB2_CPACK_GENERATOR "TGZ") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") + set(SRB2_CPACK_GENERATOR "TGZ") endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee1d7de6a..2ade8eb5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -256,6 +256,10 @@ endif() target_link_libraries(SRB2SDL2 PRIVATE ZLIB::ZLIB) target_link_libraries(SRB2SDL2 PRIVATE PNG::PNG) target_link_libraries(SRB2SDL2 PRIVATE CURL::libcurl) +if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") + target_link_libraries(SRB2SDL2 PRIVATE -lexecinfo) + target_link_libraries(SRB2SDL2 PRIVATE -lpthread) +endif() target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB -DHAVE_PNG -DHAVE_CURL -D_LARGEFILE64_SOURCE) target_sources(SRB2SDL2 PRIVATE apng.c) diff --git a/src/io/streams.cpp b/src/io/streams.cpp index 90dde7713..6b291f2e6 100644 --- a/src/io/streams.cpp +++ b/src/io/streams.cpp @@ -172,7 +172,7 @@ static int portable_fseek64(FILE* file, int64_t offset, int origin) { #ifdef _MSC_VER return _fseeki64(file, offset, origin); -#elif __APPLE__ +#elif __APPLE__ || defined(__FreeBSD__) return fseeko(file, offset, origin); #else return fseeko64(file, offset, origin); @@ -183,7 +183,7 @@ static int64_t portable_ftell64(FILE* file) { #ifdef _MSC_VER return _ftelli64(file); -#elif __APPLE__ +#elif __APPLE__ || defined(__FreeBSD__) return ftello(file); #else return ftello64(file); diff --git a/src/stun.cpp b/src/stun.cpp index 790a92b64..ee981dd2e 100644 --- a/src/stun.cpp +++ b/src/stun.cpp @@ -14,7 +14,7 @@ #include -#if defined (__linux__) +#if defined (__linux__) || defined (__FreeBSD__) #include #elif defined (_WIN32) #define _CRT_RAND_S