cmake/nc_platform.cmake
Danny Robson 54f0855312 Use CMAKE_CURRENT_LIST_DIR for local includes to simplify usage
This means that we no longer need to modify the module path for CMake
before including the root script.
2022-06-15 10:46:52 +10:00

42 lines
1.2 KiB
CMake

###############################################################################
if (__nc_platform)
return ()
endif ()
set (__nc_platform TRUE)
###############################################################################
include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/link_flag.cmake")
###############################################################################
# attempt to detect platforms that aren't super common
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX 1)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(FREEBSD 1)
elseif (WIN32)
else()
message (FATAL_ERROR "unknown platform")
endif()
###############################################################################
# apply useful, non-obvious, default settings for each platform
if (WINDOWS)
add_definitions("-DWIN32_LEAN_AND_MEAN")
endif(WINDOWS)
if (FREEBSD)
append_compile_flag("-I/usr/local/include")
append_link_flag("-L/usr/local/lib")
endif (FREEBSD)
###############################################################################
# general platform assistance settings
append_link_flag("-fno-common")
append_link_flag("-fno-nonansi-builtins")