Skip to content

cmake: make DaemonPlatform/Architecture/Compiler/BuildInfo autonomous and reusable #1641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ if (Daemon_OUT)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Daemon_OUT})
endif()

include(DaemonBuildInfo)
include(DaemonPlatform)
include(DaemonPlatform/Platform)

################################################################################
# Configuration options
Expand Down
1 change: 0 additions & 1 deletion cmake/DaemonCompiler/DaemonCompiler.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ else()
try_c_cxx_flag(FNO_STRICT_OVERFLOW "-fno-strict-overflow")
try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector")

if (NOT NACL OR (NACL AND GAME_PIE))
if (NOT NACL OR (NACL AND NACL_PIE))
# The -pie flag requires -fPIC:
# > ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
# This flag isn't used on macOS:
Expand Down
5 changes: 3 additions & 2 deletions cmake/DaemonGame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ option(BUILD_GAME_NATIVE_DLL "Build the shared library files, mostly useful for
option(BUILD_GAME_NATIVE_EXE "Build native executable, which might be used for better performances by server owners" OFF)

include(ExternalProject)
include(DaemonBuildInfo)
include(DaemonPlatform)
include(DaemonPlatform/Platform)
# TODO: Delete when Game uses NACL_PIE instead of GAME_PIE.
set(GAME_PIE ${NACL_PIE})

# Do not report unused native compiler if native vms are not built.
# If only NACL vms are built, this will be reported in chainloaded build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

try_compile(BUILD_RESULT
"${CMAKE_BINARY_DIR}"
"${DAEMON_DIR}/cmake/DaemonArchitecture/DaemonArchitecture.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Architecture/Architecture.cpp"
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
OUTPUT_VARIABLE BUILD_LOG
)
Expand All @@ -46,7 +46,7 @@ try_compile(BUILD_RESULT
# Setting USE_WERROR to ON doesn't print this warning.
if (NOT BUILD_RESULT)
message(WARNING
"Failed to build DaemonArchitecture.cpp\n"
"Failed to build Architecture.cpp\n"
"Setting -Werror in CXXFLAGS can produce false positive errors\n"
"${BUILD_LOG}"
)
Expand All @@ -57,7 +57,7 @@ string(REPLACE "DAEMON_ARCH_" "" ARCH "${ARCH_DEFINE}")

if (NOT ARCH)
message(FATAL_ERROR
"Missing DAEMON_ARCH, there is a mistake in DaemonArchitecture.cpp\n"
"Missing DAEMON_ARCH, there is a mistake in Architecture.cpp\n"
"${BUILD_LOG}"
)
elseif(ARCH STREQUAL "unsupported")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
platforms including ppc64, but we know how to do it for them. */

#include <stdint.h>
#include "../../src/common/Endian.h"

/* qprocessordetection.h will print an error if it fails to detect
endianness and while it is not already set, so the else clause is
outsourced to that qprocessordetection.h file instead. */

#if defined(Q3_BIG_ENDIAN)
#define Q_BYTE_ORDER Q_BIG_ENDIAN
#elif defined(Q3_LITTLE_ENDIAN)
#define Q_BYTE_ORDER Q_LITTLE_ENDIAN
#endif

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

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function(detect_daemon_compiler lang)

try_compile(BUILD_RESULT
"${CMAKE_BINARY_DIR}"
"${DAEMON_DIR}/cmake/DaemonCompiler/DaemonCompiler${${lang}_EXT}"
"${CMAKE_CURRENT_LIST_DIR}/Compiler/Compiler${${lang}_EXT}"
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
OUTPUT_VARIABLE BUILD_LOG
)
Expand Down
1 change: 1 addition & 0 deletions cmake/DaemonPlatform/Compiler/Compiler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "Compiler.c"
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
set -ueo pipefail

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
file_path="${script_dir}/DaemonCompiler.c"
file_path="${script_dir}/Compiler.c"

# PNaCl doesn't work with “-o /dev/null” as it uses the output path as a
# pattern for temporary files and then the parent folder should be writable.
Expand Down
12 changes: 12 additions & 0 deletions cmake/DaemonPlatform/Platform.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include(${CMAKE_CURRENT_LIST_DIR}/BuildInfo.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/System.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Architecture.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)

if (NACL AND DAEMON_CXX_COMPILER_Saigo)
# Saigo clang reports weird errors when building some Unvanquished cgame and sgame arm nexe with PIE.
# Saigo clang crashes when building Unvanquished amd64 cgame with PIE, sgame builds properly though.
set(NACL_PIE 0)
else()
set(NACL_PIE 1)
endif()
12 changes: 0 additions & 12 deletions cmake/DaemonPlatform.cmake → cmake/DaemonPlatform/System.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,3 @@ elseif( NACL )
else()
message( FATAL_ERROR "Platform not supported" )
endif()

if (NACL AND USE_NACL_SAIGO)
# Saigo clang reports weird errors when building some cgame and sgame arm nexe with PIE.
# Saigo clang crashes when building amd64 cgame with PIE, sgame builds properly though.
set(GAME_PIE 0)
else()
set(GAME_PIE 1)
endif()


include(DaemonArchitecture)
include(DaemonCompiler)