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.
This commit is contained in:
Yamagi Burmeister 2016-04-12 19:21:10 +02:00
parent df6199de70
commit 08dae0c605

View File

@ -28,6 +28,9 @@ endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES "GNU|kFreeBSD") if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES "GNU|kFreeBSD")
SET(LINUX TRUE) SET(LINUX TRUE)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
SET(FREEBSD TRUE)
endif()
if(APPLE) if(APPLE)
SET(MACOSX TRUE) SET(MACOSX TRUE)
endif() endif()
@ -71,6 +74,16 @@ if(LINUX)
add_definitions(-DPRAGMA_ONCE=1) add_definitions(-DPRAGMA_ONCE=1)
endif() 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) if(MACOSX)
add_definitions(-DPLATFORM_UNIX=1) add_definitions(-DPLATFORM_UNIX=1)
add_definitions(-DPLATFORM_MACOSX=1) add_definitions(-DPLATFORM_MACOSX=1)
@ -826,6 +839,19 @@ if(LINUX)
endif() endif()
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) if(TFE)
set_target_properties(ssam PROPERTIES OUTPUT_NAME "ssam-tfe") set_target_properties(ssam PROPERTIES OUTPUT_NAME "ssam-tfe")
endif() endif()