Skip to content

Commit 993144e

Browse files
committed
fixup
1 parent 2756160 commit 993144e

File tree

1 file changed

+49
-14
lines changed

1 file changed

+49
-14
lines changed

src/trusted/service_runtime/CMakeLists.txt

+49-14
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,47 @@ project(service_runtime C CXX)
88

99
set(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+
1141
include(DaemonPlatform/Platform)
1242

1343
#FIXME: What to do with this?
1444
set(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

2253
set(GENERATED "${CMAKE_BINARY_DIR}/gen/native_client/src/trusted/service_runtime")
2354

@@ -122,9 +153,9 @@ elseif (ARCH STREQUAL "amd64")
122153

123154
#TODO: AMD64_ZERO_BASED_SANDBOX = env.Bit('x86_64_zero_based_sandbox')
124155
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)
126157
else()
127-
#TODO: env.Append(CPPDEFINES=['-DNACL_X86_64_ZERO_BASED_SANDBOX=0'])
158+
add_definitions(-DNACL_X86_64_ZERO_BASED_SANDBOX=0)
128159
endif()
129160
endif()
130161
elseif(ARCH STREQUAL "armhf")
@@ -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()
273305
endif()
@@ -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

Comments
 (0)