From 08dae0c605188c1d9eb33497b959a4baade2a3b3 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 12 Apr 2016 19:21:10 +0200 Subject: [PATCH] Add FreeBSD defined to CMakeLists.txt - Detect FreeBSD. - Set both PLATFORM_UNIX and PLATFORM_FREEBSD. The latter is required to distinguish FreeBSD from other unixoid platforms like Linux. - On FreeBSD 3rd party libs are installed to /usr/local, we need to add /usr/local/include as include directory. - Add linker options for FreeBSD. FreeBSD has no -ldl. --- Sources/CMakeLists.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 30e7290..c5cc838 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -28,6 +28,9 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES "GNU|kFreeBSD") SET(LINUX TRUE) endif() +if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + SET(FREEBSD TRUE) +endif() if(APPLE) SET(MACOSX TRUE) endif() @@ -71,6 +74,16 @@ if(LINUX) add_definitions(-DPRAGMA_ONCE=1) endif() +if(FREEBSD) + set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) + add_definitions(-DPLATFORM_UNIX=1) + add_definitions(-DPLATFORM_FREEBSD=1) + add_definitions(-D_FILE_OFFSET_BITS=64) + add_definitions(-D_LARGEFILE_SOURCE=1) + add_definitions(-DPRAGMA_ONCE=1) + include_directories("/usr/local/include") +endif() + if(MACOSX) add_definitions(-DPLATFORM_UNIX=1) add_definitions(-DPLATFORM_MACOSX=1) @@ -826,6 +839,19 @@ if(LINUX) endif() endif() +if(FREEBSD) + set_target_properties(ssam PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN") + target_link_libraries(ssam "m") + target_link_libraries(ssam "pthread") + target_link_libraries(ssam ${SDL2_LIBRARY}) + if(BUILD_DEDICATED_SERVER) + set_target_properties(SeriousSamDedicated PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN") + target_link_libraries(SeriousSamDedicated "m") + target_link_libraries(SeriousSamDedicated "pthread") + target_link_libraries(SeriousSamDedicated ${SDL2_LIBRARY}) + endif() +endif() + if(TFE) set_target_properties(ssam PROPERTIES OUTPUT_NAME "ssam-tfe") endif()