blob: e1aab371e998fcd7213077c63be0ea0478c4d318 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# CRDOP compiler detection and warning flags (GCC, Clang, MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CRDOP_COMPILER "gcc")
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang")
set(CRDOP_COMPILER "clang")
elseif(MSVC)
set(CRDOP_COMPILER "msvc")
else()
set(CRDOP_COMPILER "${CMAKE_C_COMPILER_ID}")
endif()
message(STATUS "CRDOP compiler=${CRDOP_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})")
function(crdop_set_compile_options target)
if(MSVC)
target_compile_options(${target} PRIVATE /W3 /utf-8)
else()
target_compile_options(${target} PRIVATE -Wall -Wextra -Wno-unused-parameter)
if(CRDOP_COMPILER STREQUAL "clang")
target_compile_options(${target} PRIVATE
-Wno-gnu-zero-variadic-macro-arguments
-Wno-deprecated-non-prototype
)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(${target} PRIVATE -O2)
endif()
endif()
endfunction()
include(CheckLinkerFlag)
if(NOT WIN32 AND NOT APPLE)
check_linker_flag(C "-Wl,--wrap=malloc" CRDOP_LINKER_SUPPORTS_WRAP)
else()
set(CRDOP_LINKER_SUPPORTS_WRAP FALSE)
endif()
|