Skip to content

Commit

Permalink
cmake: build dll game with sub cmake to use different compilation flags
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Dec 30, 2024
1 parent af2ba5a commit 9a1de43
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 175 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ option(USE_STATIC_LIBS "Tries to use static libs where possible. Only works for

# Game VM modules are built with a recursive invocation of CMake, by which all the configuration
# options are lost, except ones we explicitly choose to pass.
set(DEFAULT_NACL_VM_INHERITED_OPTIONS
set(DEFAULT_VM_INHERITED_OPTIONS
BE_VERBOSE
BUILD_CGAME
BUILD_SGAME
Expand All @@ -202,15 +202,16 @@ set(DEFAULT_NACL_VM_INHERITED_OPTIONS
USE_COMPILER_INTRINSICS
USE_DEBUG_OPTIMIZE
USE_HARDENING
USE_LTO
USE_PEDANTIC
USE_PRECOMPILED_HEADER
USE_RECOMMENDED_C_STANDARD
USE_RECOMMENDED_CXX_STANDARD
USE_WERROR
)
set(NACL_VM_INHERITED_OPTIONS "${DEFAULT_NACL_VM_INHERITED_OPTIONS}" CACHE STRING
"Semicolon-separated list of options for which NaCl game VMs should use the same value as the other binaries")
mark_as_advanced(NACL_VM_INHERITED_OPTIONS)
set(VM_INHERITED_OPTIONS "${DEFAULT_VM_INHERITED_OPTIONS}" CACHE STRING
"Semicolon-separated list of options for which game VMs should use the same value as the other binaries")
mark_as_advanced(VM_INHERITED_OPTIONS)

################################################################################
# Directories
Expand Down
14 changes: 10 additions & 4 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,19 @@ 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 AND (BUILD_CGAME OR BUILD_SGAME))
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()

if ("${FLAG_LINKER_PIE}" AND MINGW)
if ("${FLAG_shared_LINKER_PIE}" AND MINGW)
# https://github.com/msys2/MINGW-packages/issues/4100
if (ARCH STREQUAL "i686")
set_linker_flag("-Wl,-e,_mainCRTStartup")
Expand Down
Loading

0 comments on commit 9a1de43

Please sign in to comment.