99 lines
2.2 KiB
CMake
99 lines
2.2 KiB
CMake
# cmake/platform.cmake
|
|
# Platform detection + compiler options
|
|
|
|
if(DEFINED PLATFORM_CONFIG_INCLUDED)
|
|
return()
|
|
endif()
|
|
set(PLATFORM_CONFIG_INCLUDED TRUE)
|
|
|
|
# -------------------------------------------------------
|
|
# Platform detection
|
|
# -------------------------------------------------------
|
|
if(APPLE)
|
|
set(PLATFORM "macOS")
|
|
message(STATUS "Platform: ${PLATFORM}")
|
|
|
|
set(PLATFORM_LINK_LIBRARIES
|
|
"-framework Cocoa"
|
|
"-framework IOKit"
|
|
"-framework CoreVideo"
|
|
"-framework OpenGL"
|
|
)
|
|
|
|
elseif(UNIX AND NOT APPLE AND NOT EMSCRIPTEN) # Linux, BSD, etc.
|
|
set(PLATFORM "Linux")
|
|
message(STATUS "Platform: ${PLATFORM}")
|
|
|
|
set(PLATFORM_LINK_LIBRARIES
|
|
dl
|
|
m
|
|
GL
|
|
X11
|
|
)
|
|
|
|
elseif(WIN32)
|
|
set(PLATFORM "Windows")
|
|
message(STATUS "Platform: ${PLATFORM}")
|
|
|
|
set(PLATFORM_LINK_LIBRARIES
|
|
OpenGL32.lib
|
|
)
|
|
|
|
set(PLATFORM_DEFINITIONS
|
|
${PLATFORM_DEFINITIONS}
|
|
"_WIN32_WINNT=0x0A00"
|
|
)
|
|
|
|
elseif(EMSCRIPTEN)
|
|
set(PLATFORM "Emscripten")
|
|
message(STATUS "Platform: ${PLATFORM}")
|
|
|
|
# Emscripten specific flags (not the warnings; those are below)
|
|
add_compile_options(
|
|
-pthread
|
|
-fexceptions
|
|
-sUSE_PTHREADS=1
|
|
)
|
|
add_link_options(
|
|
-pthread
|
|
-fexceptions
|
|
-sUSE_PTHREADS=1
|
|
)
|
|
|
|
else()
|
|
message(FATAL_ERROR "Platform: Unknown!")
|
|
endif()
|
|
|
|
# -------------------------------------------------------
|
|
# Compiler specific options (BASE_OPTIONS)
|
|
# -------------------------------------------------------
|
|
if(NOT MSVC)
|
|
set(BASE_OPTIONS
|
|
-Wall
|
|
-Wextra
|
|
# -Werror
|
|
# fmt warnings
|
|
-Wno-deprecated-literal-operator
|
|
)
|
|
|
|
if(EMSCRIPTEN)
|
|
list(APPEND BASE_OPTIONS
|
|
# asio
|
|
-Wno-sign-conversion
|
|
-Wno-shadow
|
|
-Wno-shorten-64-to-32
|
|
-Wno-implicit-int-conversion
|
|
-Wno-unused-private-field
|
|
-Wno-deprecated-declarations
|
|
)
|
|
endif()
|
|
else()
|
|
set(BASE_OPTIONS
|
|
/W4
|
|
# /WX # warnings as errors (MSVC equivalent of -Werror)
|
|
/utf-8
|
|
/Zc:__cplusplus
|
|
#/fsanitize=address # Doesn't work without Visual Studio
|
|
)
|
|
endif()
|