Skip to content

Commit fff11e5

Browse files
committed
cmake: build hardened dll game with sub cmake to use different compilation flags
1 parent d642564 commit fff11e5

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

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
@@ -98,7 +98,11 @@ function(GAMEMODULE)
9898
endif()
9999

100100
if (BUILD_GAME_NATIVE_DLL)
101-
buildGameModule("native-dll")
101+
if (USE_HARDENING)
102+
set(FORK 1 PARENT_SCOPE)
103+
else()
104+
buildGameModule("native-dll")
105+
endif()
102106
endif()
103107

104108
if (BUILD_GAME_NATIVE_EXE)
@@ -121,6 +125,17 @@ function(GAMEMODULE)
121125
"-D${inherited_option}=${${inherited_option}}")
122126
endforeach(inherited_option)
123127

128+
if (BUILD_GAME_NATIVE_DLL AND USE_HARDENING)
129+
set(VMS_PROJECT dll-vms)
130+
set(VMS_PROJECTS ${VMS_PROJECT})
131+
132+
gameSubProject(
133+
-DBUILD_GAME_NACL=OFF
134+
-DBUILD_GAME_NATIVE_DLL=ON
135+
-DBUILD_GAME_NATIVE_EXE=OFF
136+
)
137+
endif()
138+
124139
if (BUILD_GAME_NACL)
125140
if (USE_NACL_SAIGO)
126141
add_custom_target(nacl-vms ALL)
@@ -170,7 +185,12 @@ function(GAMEMODULE)
170185

171186
set(VMS_PROJECTS ${VMS_PROJECTS} PARENT_SCOPE)
172187
elseif (FORK EQUAL 2)
173-
if (BUILD_GAME_NACL)
188+
if (BUILD_GAME_NATIVE_DLL)
189+
# Put the .dll and .so files in the same directory as the engine.
190+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/..)
191+
192+
buildGameModule("native-dll")
193+
elseif (BUILD_GAME_NACL)
174194
if (USE_NACL_SAIGO)
175195
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
176196
else()

0 commit comments

Comments
 (0)