@@ -8,16 +8,47 @@ project(service_runtime C CXX)
88
99set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /../../../cmake)
1010
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+
1141include (DaemonPlatform/Platform)
1242
1343#FIXME: What to do with this?
1444set (CPPPATH "${CMAKE_BINARY_DIR} /gen" )
1545
1646# normally comment out -- uncomment out to test the pedantic removal
1747# 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()
2152
2253set (GENERATED "${CMAKE_BINARY_DIR} /gen/native_client/src/trusted/service_runtime" )
2354
@@ -266,8 +297,9 @@ if (LINUX)
266297 # on i386.
267298 # See https://code.google.com/p/nativeclient/issues/detail?id=3581.
268299#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" )
270301#TODO: NACL_SIGNAL_OBJ = nacl_signal_env.ComponentObject('linux/nacl_signal.c')])
302+
271303 set (LDR_INPUTS ${LDR_INPUTS} ${NACL_SIGNAL_OBJ} )
272304 endif ()
273305endif ()
@@ -399,16 +431,19 @@ if (LINUX AND NOT BUILD_ELSEWHERE)
399431#TODO: bootstrap_env = env.Clone()
400432#TODO: bootstrap_env.Replace(CLANG_OPTS='')
401433#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" )
405440
406441 # TODO(bbudge) Remove -Qunused-arguments when Clang supports -fno-pic.
407442 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)
412447 endif ()
413448
414449 set (COMPILER_OVERRIDE '')
@@ -441,7 +476,7 @@ if (LINUX AND NOT BUILD_ELSEWHERE)
441476 # truncated, which produces an error. With mcmodel set to large,
442477 # there is no restriction on the code and data, so we can
443478 # safely set reserve_top to 0x100000000.
444- #TODO: bootstrap_env.Append(CCFLAGS=[' -mcmodel=large'] )
479+ set_c_cxx_flag( " -mcmodel=large" )
445480 else ()
446481 set (reserve_top '0x0')
447482 endif ()
0 commit comments