-
Notifications
You must be signed in to change notification settings - Fork 5
/
PNaCl.toolchain.txt
101 lines (81 loc) · 4.67 KB
/
PNaCl.toolchain.txt
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#-------------------------------------------------------------------------------
# pnacl.toolchain.cmake
# Fips cmake toolchain file for cross-compiling to PNaCl.
#-------------------------------------------------------------------------------
set( toolroot c:/general/tools )
set(NACL_SDK_BUNDLE "pepper_49")
set(NACL_SDK_DIRNAME "${toolroot}/nacl_sdk")
set(NACL_TOOLCHAIN_DIRNAME "win_pnacl")
set( PNACL_BUILD 1 )
ADD_DEFINITIONS( -D_PNACL )
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(COMPILING on)
set(CMAKE_CROSSCOMPILING TRUE)
if( WIN32 )
set( PNACL_EXTENSION .bat )
endif( WIN32 )
set(FIPS_NACL_EXCEPTION_FLAGS "-fno-exceptions")
macro(find_nacl_sdk_root)
get_filename_component(NACL_SDK_ROOT "${NACL_SDK_DIRNAME}/${NACL_SDK_BUNDLE}" ABSOLUTE)
if (NOT EXISTS "${NACL_SDK_ROOT}/README")
message(FATAL_ERROR "Could not find NaCl SDK at ${NACL_SDK_ROOT}! Please run 'fips setup nacl'!")
else()
set(NACL_SDK_ROOT ${NACL_SDK_ROOT} CACHE STRING "NaCl SDK location.")
endif()
endmacro()
# find the NaCl SDK
find_nacl_sdk_root()
set(NACL_TOOLCHAIN_ROOT "${NACL_SDK_ROOT}/toolchain/${NACL_TOOLCHAIN_DIRNAME}")
# set paths to toolchain components
set(NACL_BIN "${NACL_TOOLCHAIN_ROOT}/bin")
set(NACL_INCLUDE "${NACL_SDK_ROOT}/include")
set(NACL_LIB "${NACL_SDK_ROOT}/lib/pnacl/Release")
# standard header and lib search paths
include_directories(${NACL_INCLUDE} ${NACL_INCLUDE}/pnacl)
link_directories(${NACL_LIB})
# define configurations
set(CMAKE_CONFIGURATION_TYPES Debug Release)
# standard libraries
set(CMAKE_CXX_STANDARD_LIBRARIES "-lppapi_gles2 -lppapi_cpp -lppapi -lpthread")
set(CMAKE_C_STANDARD_LIBRARIES "lppapi_gles2 -lppapi -lpthread")
# specify cross-compilers
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_COMPILER "${NACL_BIN}/pnacl-clang${PNACL_EXTENSION}" CACHE PATH "gcc" FORCE)
set(CMAKE_CXX_COMPILER "${NACL_BIN}/pnacl-clang++" CACHE PATH "g++" FORCE)
set(CMAKE_AR "${NACL_BIN}/pnacl-ar${PNACL_EXTENSION}" CACHE PATH "archive" FORCE)
set(CMAKE_LINKER "${NACL_BIN}/pnacl-clang++" CACHE PATH "linker" FORCE)
set(CMAKE_RANLIB "${NACL_BIN}/pnacl-ranlib${PNACL_EXTENSION}" CACHE PATH "ranlib" FORCE)
# only search for libraries and includes in the toolchain
set(CMAKE_FIND_ROOT_PATH ${NACL_TOOLCHAIN_ROOT}/usr)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_SYSTEM_INCLUDE_PATH "${NACL_TOOLCHAIN_ROOT}/usr/include")
# compiler flags
set(CMAKE_CXX_FLAGS "${FIPS_NACL_EXCEPTION_FLAGS} ${FIPS_NACL_RTTI_FLAGS} -std=c++11 -pthread -D_XOPEN_SOURCE=600 -Wno-multichar -Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-unused-volatile-lvalue -Wno-deprecated-writable-strings -Wno-inconsistent-missing-override -Wno-unknown-warning-option")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -D_DEBUG_ -D_DEBUG -DNACL_SDK_DEBUG")
set(CMAKE_C_FLAGS "-pthread -D_XOPEN_SOURCE=600 -Wno-multichar -Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-unused-volatile-lvalue -Wno-deprecated-writable-strings -Wno-unknown-warning-option")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "-O0 -D_DEBUG_ -D_DEBUG -g -DNACL_SDK_DEBUG")
set(CMAKE_EXE_LINKER_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
# update cache variables for cmake gui
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Config Type" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Generic C++ Compiler Flags" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "C++ Debug Compiler Flags" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "C++ Release Compiler Flags" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Generic C Compiler Flags" FORCE)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "C Debug Compiler Flags" FORCE)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "C Release Compiler Flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Generic Linker Flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "Debug Linker Flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Release Linker Flags" FORCE)
# set the build type to use
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Compile Type" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release)