Skip to content

Commit 55760ca

Browse files
committed
cmake: build hardened dll game with sub cmake to use different compilation flags
1 parent 01f143a commit 55760ca

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
@@ -157,7 +157,11 @@ function(GAMEMODULE)
157157
endif()
158158

159159
if (BUILD_GAME_NATIVE_DLL)
160-
buildGameModule("native-dll")
160+
if (USE_HARDENING)
161+
set(FORK 1 PARENT_SCOPE)
162+
else()
163+
buildGameModule("native-dll")
164+
endif()
161165
endif()
162166

163167
if (BUILD_GAME_NATIVE_EXE)
@@ -180,6 +184,17 @@ function(GAMEMODULE)
180184
"-D${inherited_option}=${${inherited_option}}")
181185
endforeach(inherited_option)
182186

187+
if (BUILD_GAME_NATIVE_DLL AND USE_HARDENING)
188+
set(VMS_PROJECT dll-vms)
189+
set(VMS_PROJECTS ${VMS_PROJECT})
190+
191+
gameSubProject(
192+
-DBUILD_GAME_NACL=OFF
193+
-DBUILD_GAME_NATIVE_DLL=ON
194+
-DBUILD_GAME_NATIVE_EXE=OFF
195+
)
196+
endif()
197+
183198
if (BUILD_GAME_NACL)
184199
if (USE_NACL_SAIGO)
185200
add_custom_target(nacl-vms ALL)
@@ -229,7 +244,12 @@ function(GAMEMODULE)
229244

230245
set(VMS_PROJECTS ${VMS_PROJECTS} PARENT_SCOPE)
231246
elseif (FORK EQUAL 2)
232-
if (BUILD_GAME_NACL)
247+
if (BUILD_GAME_NATIVE_DLL)
248+
# Put the .dll and .so files in the same directory as the engine.
249+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/..)
250+
251+
buildGameModule("native-dll")
252+
elseif (BUILD_GAME_NACL)
233253
if (USE_NACL_SAIGO)
234254
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
235255
else()

0 commit comments

Comments
 (0)