Files
ViewDesignEngine/cmake/CompilerSettings.cmake
T

42 lines
1.7 KiB
CMake
Raw Normal View History

# Compiler settings for ViewDesignEngine
# Include with: include(cmake/CompilerSettings.cmake)
# ── GCC / Clang ───────────────────────────────────
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
target_compile_options(vde_compile_options INTERFACE
-Wall -Wextra -Wpedantic
-Wshadow -Wnon-virtual-dtor
-Woverloaded-virtual -Wconversion
-Wsign-conversion -Wnull-dereference
-Wdouble-promotion -Wformat=2
)
if(ENABLE_SANITIZERS)
target_compile_options(vde_compile_options INTERFACE
-fsanitize=address,undefined -fno-omit-frame-pointer
)
target_link_options(vde_compile_options INTERFACE
-fsanitize=address,undefined
)
endif()
if(ENABLE_LTO AND CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(vde_compile_options INTERFACE -flto)
target_link_options(vde_compile_options INTERFACE -flto)
endif()
endif()
# ── MSVC ───────────────────────────────────────────
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(vde_compile_options INTERFACE
/W4 /permissive- /Zc:__cplusplus /utf-8
)
target_compile_definitions(vde_compile_options INTERFACE
_CRT_SECURE_NO_WARNINGS NOMINMAX
)
endif()
# ── 公共编译定义 ───────────────────────────────────
target_compile_definitions(vde_compile_options INTERFACE
VDE_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
VDE_VERSION_MINOR=${PROJECT_VERSION_MINOR}
)