prep for 2025
This commit is contained in:
98
cmake/platform.cmake
Normal file
98
cmake/platform.cmake
Normal file
@@ -0,0 +1,98 @@
|
||||
# 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()
|
||||
Reference in New Issue
Block a user