diff --git a/CMakeLists.txt b/CMakeLists.txt
index 121d598a23b2c5932cf703bf4bc642f5bc0a4f4f..15ae9cd2dc97357eae381aa491898f21ea70a92f 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 ee1d7de6aaf2389dd716ba005ef075946f57b087..2ade8eb5fd35ede297f8ea1a7dde4d880f5abfa0 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 90dde771374ed5cc271c01abfd03a29c4d0fda91..6b291f2e6e2f165065b6d6a9d9d948c7072beb79 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 790a92b64c0e246505734a21d22993a684aea966..ee981dd2eedb32a2de0201ec2bd84b4d9ac2dc30 100644
--- a/src/stun.cpp
+++ b/src/stun.cpp
@@ -14,7 +14,7 @@
 
 #include <vector>
 
-#if defined (__linux__)
+#if defined (__linux__) || defined (__FreeBSD__)
 #include <sys/random.h>
 #elif defined (_WIN32)
 #define _CRT_RAND_S