Skip to content

Commit

Permalink
cmake: build hardened dll game with sub cmake to use different compil…
Browse files Browse the repository at this point in the history
…ation flags
  • Loading branch information
illwieckz committed Dec 30, 2024
1 parent bd81ee8 commit 55fdd45
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
12 changes: 9 additions & 3 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,15 @@ else()
try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector")

if (NOT NACL OR (NACL AND GAME_PIE))
try_c_cxx_flag(FPIE "-fPIE")
if (NOT APPLE)
try_linker_flag(LINKER_PIE "-pie")
if (FORK EQUAL 2 AND BUILD_GAME_NATIVE_DLL)
try_c_cxx_flag(FPIC "-fPIC")
try_linker_flag(LINKER_PIC "-pic")
else()
try_c_cxx_flag(FPIE "-fPIE")

if (NOT APPLE)
try_linker_flag(LINKER_PIE "-pie")
endif()
endif()
endif()

Expand Down
24 changes: 22 additions & 2 deletions cmake/DaemonGame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ function(GAMEMODULE)
endif()

if (BUILD_GAME_NATIVE_DLL)
buildGameModule("native-dll")
if (USE_HARDENING)
set(FORK 1 PARENT_SCOPE)
else()
buildGameModule("native-dll")
endif()
endif()

if (BUILD_GAME_NATIVE_EXE)
Expand All @@ -125,6 +129,17 @@ function(GAMEMODULE)
"-D${inherited_option}=${${inherited_option}}")
endforeach(inherited_option)

if (BUILD_GAME_NATIVE_DLL AND USE_HARDENING)
set(VMS_PROJECT dll-vms)
set(VMS_PROJECTS ${VMS_PROJECT})

gameSubProject(
-DBUILD_GAME_NACL=OFF
-DBUILD_GAME_NATIVE_DLL=ON
-DBUILD_GAME_NATIVE_EXE=OFF
)
endif()

if (BUILD_GAME_NACL)
if (USE_NACL_SAIGO)
add_custom_target(nacl-vms ALL)
Expand Down Expand Up @@ -174,7 +189,12 @@ function(GAMEMODULE)

set(VMS_PROJECTS ${VMS_PROJECTS} PARENT_SCOPE)
elseif (FORK EQUAL 2)
if (BUILD_GAME_NACL)
if (BUILD_GAME_NATIVE_DLL)
# Put the .dll and .so files in the same directory as the engine.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/..)

buildGameModule("native-dll")
elseif (BUILD_GAME_NACL)
if (USE_NACL_SAIGO)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
else()
Expand Down

0 comments on commit 55fdd45

Please sign in to comment.