@@ -8,16 +8,47 @@ project(service_runtime C CXX)
8
8
9
9
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /../../../cmake)
10
10
11
+ macro (set_c_flag FLAG)
12
+ if (${ARGC} GREATER 1)
13
+ set (CMAKE_C_FLAGS_${ARGV1} "${CMAKE_${lang} _FLAGS_${ARGV1} } ${FLAG} " )
14
+ else ()
15
+ set (CMAKE_C_FLAGS "${CMAKE_${lang} _FLAGS} ${FLAG} " )
16
+ endif ()
17
+ endmacro ()
18
+
19
+ macro (set_c_cxx_flag FLAG)
20
+ foreach (lang C CXX)
21
+ if (${ARGC} GREATER 1)
22
+ set (CMAKE_${lang} _FLAGS_${ARGV1} "${CMAKE_${lang} _FLAGS_${ARGV1} } ${FLAG} " )
23
+ else ()
24
+ set (CMAKE_${lang} _FLAGS "${CMAKE_${lang} _FLAGS} ${FLAG} " )
25
+ endif ()
26
+ endforeach ()
27
+ endmacro ()
28
+
29
+ macro (set_linker_flag FLAG)
30
+ if (${ARGC} GREATER 1)
31
+ set (CMAKE_EXE_LINKER_FLAGS_${ARGV1} "${CMAKE_EXE_LINKER_FLAGS_${ARGV1} } ${FLAG} " )
32
+ set (CMAKE_SHARED_LINKER_FLAGS_${ARGV1} "${CMAKE_SHARED_LINKER_FLAGS_${ARGV1} } ${FLAG} " )
33
+ set (CMAKE_MODULE_LINKER_FLAGS_${ARGV1} "${CMAKE_MODULE_LINKER_FLAGS_${ARGV1} } ${FLAG} " )
34
+ else ()
35
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG} " )
36
+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLAG} " )
37
+ set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${FLAG} " )
38
+ endif ()
39
+ endmacro ()
40
+
11
41
include (DaemonPlatform/Platform)
12
42
13
43
#FIXME: What to do with this?
14
44
set (CPPPATH "${CMAKE_BINARY_DIR} /gen" )
15
45
16
46
# normally comment out -- uncomment out to test the pedantic removal
17
47
# check below.
18
- #if env.Bit('linux') or env.Bit('mac'):
19
- # env.FilterOut(CCFLAGS=['-pedantic'])
20
- # env.FilterOut(CCFLAGS=['-Wall'])
48
+ #if (LINUX OR APPLE)
49
+ # set_c_cxx_flag("-pedantic")
50
+ # set_c_cxx_flag("-Wall")
51
+ #endif()
21
52
22
53
set (GENERATED "${CMAKE_BINARY_DIR} /gen/native_client/src/trusted/service_runtime" )
23
54
@@ -122,9 +153,9 @@ elseif (ARCH STREQUAL "amd64")
122
153
123
154
#TODO: AMD64_ZERO_BASED_SANDBOX = env.Bit('x86_64_zero_based_sandbox')
124
155
if (AMD64_ZERO_BASED_SANDBOX)
125
- #TODO: env.Append(CPPDEFINES=[' -DNACL_X86_64_ZERO_BASED_SANDBOX=1'] )
156
+ add_definitions ( -DNACL_X86_64_ZERO_BASED_SANDBOX=1)
126
157
else ()
127
- #TODO: env.Append(CPPDEFINES=[' -DNACL_X86_64_ZERO_BASED_SANDBOX=0'] )
158
+ add_definitions ( -DNACL_X86_64_ZERO_BASED_SANDBOX=0)
128
159
endif ()
129
160
endif ()
130
161
elseif (ARCH STREQUAL "armhf" )
@@ -266,8 +297,9 @@ if (LINUX)
266
297
# on i386.
267
298
# See https://code.google.com/p/nativeclient/issues/detail?id=3581.
268
299
#TODO: nacl_signal_env.FilterOut(CCFLAGS=['-fstack-protector', '-fstack-protector-all'])
269
- #TODO: nacl_signal_env.Append(CCFLAGS=[' -fno-stack-protector'] )
300
+ set_c_cxx_flag( " -fno-stack-protector" )
270
301
#TODO: NACL_SIGNAL_OBJ = nacl_signal_env.ComponentObject('linux/nacl_signal.c')])
302
+
271
303
set (LDR_INPUTS ${LDR_INPUTS} ${NACL_SIGNAL_OBJ} )
272
304
endif ()
273
305
endif ()
@@ -399,16 +431,19 @@ if (LINUX AND NOT BUILD_ELSEWHERE)
399
431
#TODO: bootstrap_env = env.Clone()
400
432
#TODO: bootstrap_env.Replace(CLANG_OPTS='')
401
433
#TODO: bootstrap_env.FilterOut(CCFLAGS=['-fstack-protector', '-fPIC', '-fPIE', '-pedantic', '$COVERAGE_CCFLAGS'],
402
- #TODO: CFLAGS=['-Wdeclaration-after-statement'])
403
- #TODO: bootstrap_env.Append(CCFLAGS=['-fno-pic', '-fno-PIC', '-fno-pie', '-fno-pie',
404
- #TODO: '-fno-stack-protector'])
434
+ set_c_cxx_flag("-fno-pic" )
435
+ set_c_cxx_flag("-fno-PIC" )
436
+ set_c_cxx_flag("-fno-pie" )
437
+ set_c_cxx_flag("-fno-pie" )
438
+ set_c_cxx_flag("-fno-stack-protector" )
439
+ set_c_flag("-Wdeclaration-after-statement" )
405
440
406
441
# TODO(bbudge) Remove -Qunused-arguments when Clang supports -fno-pic.
407
442
if (DAEMON_CXX_COMPILER_Clang_COMPATIBILITY)
408
- #TODO: bootstrap_env.Append(CCFLAGS=[' -ffreestanding',
409
- #TODO: ' -U__STDC_HOSTED__',
410
- #TODO: ' -D__STDC_HOSTED__=1',
411
- #TODO: ' -Qunused-arguments'] )
443
+ set_c_cxx_flag( " -ffreestanding" )
444
+ add_definitions ( -U__STDC_HOSTED__)
445
+ add_definitions ( -D__STDC_HOSTED__=1)
446
+ add_definitions ( -Qunused-arguments)
412
447
endif ()
413
448
414
449
set (COMPILER_OVERRIDE '')
@@ -441,7 +476,7 @@ if (LINUX AND NOT BUILD_ELSEWHERE)
441
476
# truncated, which produces an error. With mcmodel set to large,
442
477
# there is no restriction on the code and data, so we can
443
478
# safely set reserve_top to 0x100000000.
444
- #TODO: bootstrap_env.Append(CCFLAGS=[' -mcmodel=large'] )
479
+ set_c_cxx_flag( " -mcmodel=large" )
445
480
else ()
446
481
set (reserve_top '0x0')
447
482
endif ()
0 commit comments