Skip to content

Commit 43e01d4

Browse files
committed
cmake: build hardened dll game with sub cmake to use different compilation flags
1 parent 21e0663 commit 43e01d4

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

cmake/DaemonFlags.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,15 @@ else()
337337
try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector")
338338

339339
if (NOT NACL OR (NACL AND GAME_PIE))
340-
try_c_cxx_flag(FPIE "-fPIE")
341-
if (NOT APPLE)
342-
try_linker_flag(LINKER_PIE "-pie")
340+
if (FORK EQUAL 2 AND BUILD_GAME_NATIVE_DLL)
341+
try_c_cxx_flag(FPIC "-fPIC")
342+
try_linker_flag(LINKER_PIC "-pic")
343+
else()
344+
try_c_cxx_flag(FPIE "-fPIE")
345+
346+
if (NOT APPLE)
347+
try_linker_flag(LINKER_PIE "-pie")
348+
endif()
343349
endif()
344350
endif()
345351

cmake/DaemonGame.cmake

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ function(GAMEMODULE)
102102
endif()
103103

104104
if (BUILD_GAME_NATIVE_DLL)
105-
buildGameModule("native-dll")
105+
if (USE_HARDENING)
106+
set(FORK 1 PARENT_SCOPE)
107+
else()
108+
buildGameModule("native-dll")
109+
endif()
106110
endif()
107111

108112
if (BUILD_GAME_NATIVE_EXE)
@@ -125,6 +129,17 @@ function(GAMEMODULE)
125129
"-D${inherited_option}=${${inherited_option}}")
126130
endforeach(inherited_option)
127131

132+
if (BUILD_GAME_NATIVE_DLL AND USE_HARDENING)
133+
set(VMS_PROJECT dll-vms)
134+
set(VMS_PROJECTS ${VMS_PROJECT})
135+
136+
gameSubProject(
137+
-DBUILD_GAME_NACL=OFF
138+
-DBUILD_GAME_NATIVE_DLL=ON
139+
-DBUILD_GAME_NATIVE_EXE=OFF
140+
)
141+
endif()
142+
128143
if (BUILD_GAME_NACL)
129144
if (USE_NACL_SAIGO)
130145
add_custom_target(nacl-vms ALL)
@@ -174,7 +189,12 @@ function(GAMEMODULE)
174189

175190
set(VMS_PROJECTS ${VMS_PROJECTS} PARENT_SCOPE)
176191
elseif (FORK EQUAL 2)
177-
if (BUILD_GAME_NACL)
192+
if (BUILD_GAME_NATIVE_DLL)
193+
# Put the .dll and .so files in the same directory as the engine.
194+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/..)
195+
196+
buildGameModule("native-dll")
197+
elseif (BUILD_GAME_NACL)
178198
if (USE_NACL_SAIGO)
179199
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
180200
else()

0 commit comments

Comments
 (0)