Skip to content

Commit cfa6cc2

Browse files
committed
cmake: make DaemonPlatform, Architecture, Compiler, etc. autonomous and reusable
1 parent 5ab62e7 commit cfa6cc2

File tree

15 files changed

+69
-40
lines changed

15 files changed

+69
-40
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ if (Daemon_OUT)
7575
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Daemon_OUT})
7676
endif()
7777

78-
include(DaemonSourceGenerator)
79-
include(DaemonPlatform)
78+
include(DaemonPlatform/Platform)
8079

8180
################################################################################
8281
# Configuration options
@@ -465,7 +464,7 @@ endif()
465464
include(DaemonNacl)
466465
if (NACL)
467466
add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE})
468-
set_target_properties(srclibs-nacl-module PROPERTIES POSITION_INDEPENDENT_CODE ${GAME_PIE} FOLDER "libs")
467+
set_target_properties(srclibs-nacl-module PROPERTIES POSITION_INDEPENDENT_CODE ${NACL_PIE} FOLDER "libs")
469468
set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module)
470469
else()
471470
add_library(srclibs-nacl-native EXCLUDE_FROM_ALL ${NACLLIST_NATIVE})

cmake/DaemonCompiler/DaemonCompiler.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

cmake/DaemonFlags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ else()
491491
try_c_cxx_flag(FNO_STRICT_OVERFLOW "-fno-strict-overflow")
492492
try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector")
493493

494-
if (NOT NACL OR (NACL AND GAME_PIE))
494+
if (NOT NACL OR (NACL AND NACL_PIE))
495495
# The -pie flag requires -fPIC:
496496
# > ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
497497
# This flag isn't used on macOS:

cmake/DaemonGame.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ option(BUILD_GAME_NATIVE_DLL "Build the shared library files, mostly useful for
3939
option(BUILD_GAME_NATIVE_EXE "Build native executable, which might be used for better performances by server owners" OFF)
4040

4141
include(ExternalProject)
42-
include(DaemonSourceGenerator)
43-
include(DaemonPlatform)
42+
include(DaemonPlatform/Platform)
43+
# TODO: Delete when Game uses NACL_PIE instead of GAME_PIE.
44+
set(GAME_PIE ${NACL_PIE})
4445

4546
# Do not report unused native compiler if native vms are not built.
4647
# If only NACL vms are built, this will be reported in chainloaded build.

cmake/DaemonArchitecture.cmake renamed to cmake/DaemonPlatform/Architecture.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626

2727
################################################################################
28-
# Determine architecture
28+
# Architecture detection.
2929
################################################################################
3030

3131
# When adding a new architecture, look at all the places ARCH is used
3232

3333
try_compile(BUILD_RESULT
3434
"${CMAKE_BINARY_DIR}"
35-
"${DAEMON_DIR}/cmake/DaemonArchitecture/DaemonArchitecture.cpp"
35+
"${CMAKE_CURRENT_LIST_DIR}/Architecture/Architecture.cpp"
3636
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
3737
OUTPUT_VARIABLE BUILD_LOG
3838
)
@@ -46,7 +46,7 @@ try_compile(BUILD_RESULT
4646
# Setting USE_WERROR to ON doesn't print this warning.
4747
if (NOT BUILD_RESULT)
4848
message(WARNING
49-
"Failed to build DaemonArchitecture.cpp\n"
49+
"Failed to build Architecture.cpp\n"
5050
"Setting -Werror in CXXFLAGS can produce false positive errors\n"
5151
"${BUILD_LOG}"
5252
)
@@ -57,7 +57,7 @@ string(REPLACE "DAEMON_ARCH_" "" ARCH "${ARCH_DEFINE}")
5757

5858
if (NOT ARCH)
5959
message(FATAL_ERROR
60-
"Missing DAEMON_ARCH, there is a mistake in DaemonArchitecture.cpp\n"
60+
"Missing DAEMON_ARCH, there is a mistake in Architecture.cpp\n"
6161
"${BUILD_LOG}"
6262
)
6363
elseif(ARCH STREQUAL "unsupported")

cmake/DaemonArchitecture/DaemonArchitecture.cpp renamed to cmake/DaemonPlatform/Architecture/Architecture.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
platforms including ppc64, but we know how to do it for them. */
3333

3434
#include <stdint.h>
35-
#include "../../src/common/Endian.h"
36-
37-
/* qprocessordetection.h will print an error if it fails to detect
38-
endianness and while it is not already set, so the else clause is
39-
outsourced to that qprocessordetection.h file instead. */
40-
41-
#if defined(Q3_BIG_ENDIAN)
42-
#define Q_BYTE_ORDER Q_BIG_ENDIAN
43-
#elif defined(Q3_LITTLE_ENDIAN)
44-
#define Q_BYTE_ORDER Q_LITTLE_ENDIAN
45-
#endif
4635

4736
/* This source file includes qprocessordetection.h from Qt:
4837

cmake/DaemonCompiler.cmake renamed to cmake/DaemonPlatform/Compiler.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626

2727
################################################################################
28-
# Determine compiler
28+
# Compiler detection.
2929
################################################################################
3030

3131
# FIXME: Force -W#pragma-messages and -Wno-error
@@ -39,15 +39,15 @@ function(detect_daemon_compiler lang)
3939

4040
try_compile(BUILD_RESULT
4141
"${CMAKE_BINARY_DIR}"
42-
"${DAEMON_DIR}/cmake/DaemonCompiler/DaemonCompiler${${lang}_EXT}"
42+
"${CMAKE_CURRENT_LIST_DIR}/Compiler/Compiler${${lang}_EXT}"
4343
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
4444
OUTPUT_VARIABLE BUILD_LOG
4545
)
4646

4747
get_filename_component(compiler_basename "${CMAKE_${lang}_COMPILER}" NAME)
4848

4949
if (NOT BUILD_RESULT)
50-
message(WARNING "Failed to build DaemonCompiler${${lang}_EXT}, relying on CMake builtin detection.")
50+
message(WARNING "Failed to build Compiler${${lang}_EXT}, relying on CMake builtin detection.")
5151
set(compiler_name "Unknown")
5252
else()
5353
set(BUILD_LOG "\n${BUILD_LOG}\n")
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "Compiler.c"

0 commit comments

Comments
 (0)