Skip to content

Commit 9a1de43

Browse files
committed
cmake: build dll game with sub cmake to use different compilation flags
1 parent af2ba5a commit 9a1de43

File tree

3 files changed

+225
-175
lines changed

3 files changed

+225
-175
lines changed

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ option(USE_STATIC_LIBS "Tries to use static libs where possible. Only works for
191191

192192
# Game VM modules are built with a recursive invocation of CMake, by which all the configuration
193193
# options are lost, except ones we explicitly choose to pass.
194-
set(DEFAULT_NACL_VM_INHERITED_OPTIONS
194+
set(DEFAULT_VM_INHERITED_OPTIONS
195195
BE_VERBOSE
196196
BUILD_CGAME
197197
BUILD_SGAME
@@ -202,15 +202,16 @@ set(DEFAULT_NACL_VM_INHERITED_OPTIONS
202202
USE_COMPILER_INTRINSICS
203203
USE_DEBUG_OPTIMIZE
204204
USE_HARDENING
205+
USE_LTO
205206
USE_PEDANTIC
206207
USE_PRECOMPILED_HEADER
207208
USE_RECOMMENDED_C_STANDARD
208209
USE_RECOMMENDED_CXX_STANDARD
209210
USE_WERROR
210211
)
211-
set(NACL_VM_INHERITED_OPTIONS "${DEFAULT_NACL_VM_INHERITED_OPTIONS}" CACHE STRING
212-
"Semicolon-separated list of options for which NaCl game VMs should use the same value as the other binaries")
213-
mark_as_advanced(NACL_VM_INHERITED_OPTIONS)
212+
set(VM_INHERITED_OPTIONS "${DEFAULT_VM_INHERITED_OPTIONS}" CACHE STRING
213+
"Semicolon-separated list of options for which game VMs should use the same value as the other binaries")
214+
mark_as_advanced(VM_INHERITED_OPTIONS)
214215

215216
################################################################################
216217
# Directories

cmake/DaemonFlags.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,19 @@ else()
335335
try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector")
336336

337337
if (NOT NACL OR (NACL AND GAME_PIE))
338-
try_c_cxx_flag(FPIE "-fPIE")
339-
if (NOT APPLE)
340-
try_linker_flag(LINKER_PIE "-pie")
338+
if (FORK EQUAL 2 AND BUILD_GAME_NATIVE_DLL AND (BUILD_CGAME OR BUILD_SGAME))
339+
try_c_cxx_flag(FPIC "-fPIC")
340+
try_linker_flag(LINKER_PIC "-pic")
341+
else()
342+
try_c_cxx_flag(FPIE "-fPIE")
343+
344+
if (NOT APPLE)
345+
try_linker_flag(LINKER_PIE "-pie")
346+
endif()
341347
endif()
342348
endif()
343349

344-
if ("${FLAG_LINKER_PIE}" AND MINGW)
350+
if ("${FLAG_shared_LINKER_PIE}" AND MINGW)
345351
# https://github.com/msys2/MINGW-packages/issues/4100
346352
if (ARCH STREQUAL "i686")
347353
set_linker_flag("-Wl,-e,_mainCRTStartup")

0 commit comments

Comments
 (0)