forked from blockchainsllc/in3
-
Notifications
You must be signed in to change notification settings - Fork 2
/
compiler.cmake
54 lines (48 loc) · 2.04 KB
/
compiler.cmake
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
if(MSVC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -funsigned-char -std=c99")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -funsigned-char -std=c99 -D__FILENAME__=none")
else(MSVC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -funsigned-char -Wextra -std=c99")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -funsigned-char -Wextra -std=c99 -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
endif(MSVC)
if (WASM)
set (CMAKE_C_FLAGS "-Wall -funsigned-char -Wextra -std=c99")
set (CMAKE_CXX_FLAGS "-Wall -funsigned-char -Wextra -std=c99 -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
else (WASM)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif(WASM)
if(MSVC)
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX")
elseif(WASM)
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
else()
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Werror=vla")
endif()
set_property(GLOBAL PROPERTY C_STANDARD 99)
# Set DEAD_STRIP_LINKER_OPT
if(NOT CYGWIN AND NOT MINGW)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
endif()
endif()
if(NOT LLVM_NO_DEAD_STRIP)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_property(GLOBAL PROPERTY DEAD_STRIP_LINKER_OPT "-Wl,-dead_strip")
elseif(WASM)
set_property(GLOBAL PROPERTY DEAD_STRIP_LINKER_OPT "")
elseif(NOT WIN32)
set_property(GLOBAL PROPERTY DEAD_STRIP_LINKER_OPT "-Wl,--gc-sections")
endif()
endif()
# Only CMake >=3.13 has add_link_options(). For previous versions,
# DEAD_STRIP_LINKER_OPT can be used with target_link_libraries()
if(${CMAKE_VERSION} VERSION_GREATER "3.12.4")
get_property(DEAD_STRIP_LINKER_OPT GLOBAL PROPERTY DEAD_STRIP_LINKER_OPT)
add_link_options(${DEAD_STRIP_LINKER_OPT})
set_property(GLOBAL PROPERTY DEAD_STRIP_LINKER_OPT "")
endif()
if (CODE_COVERAGE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
endif()