forked from Andersbakken/rct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.cmake
35 lines (33 loc) · 1.37 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
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpointer-arith -Wnon-virtual-dtor -Wshadow -Wformat")
if (NOT RCT_RTTI_ENABLED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpointer-arith -Wshadow -Wformat") # -pthread")
if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-D_DARWIN_UNLIMITED_SELECT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
if (NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
# Use pic instead of PIC, which produces faster and smaller code,
# but could eventully lead to linker problems.
if(NOT WIN32)
set(CMAKE_CXX_COMPILE_OPTIONS_PIC "-fpic")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fpic")
endif()
endif ()
if (RCT_USE_LIBCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
string(STRIP "${CMAKE_EXE_LINKER_FLAGS}" CMAKE_EXE_LINKER_FLAGS)
endif ()
endif ()