summaryrefslogtreecommitdiff
path: root/Toolchain/CMake/GNUToolchain.txt.in
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2021-09-07 02:21:36 -0600
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-09-15 19:04:52 +0430
commitb5c98ede084e5d29b8586f3bb2bf134184d372be (patch)
tree7f4ece17df372bbe5dd27c5063b67195e1f578ea /Toolchain/CMake/GNUToolchain.txt.in
parent904a268872416dc9b9f26c83fd0b1bd8b715c511 (diff)
downloadserenity-b5c98ede084e5d29b8586f3bb2bf134184d372be.zip
Meta: Switch to a SuperBuild that splits host and target builds
Replace the old logic where we would start with a host build, and swap all the CMake compiler and target variables underneath it to trick CMake into building for Serenity after we configured and built the Lagom code generators. The SuperBuild creates two ExternalProjects, one for Lagom and one for Serenity. The Serenity project depends on the install stage for the Lagom build. The SuperBuild also generates a CMakeToolchain file for the Serenity build to use that replaces the old toolchain file that was only used for Ports. To ensure that code generators are rebuilt when core libraries such as AK and LibCore are modified, developers will need to direct their manual `ninja` invocations to the SuperBuild's binary directory instead of the Serenity binary directory. This commit includes warning coalescing and option style cleanup for the affected CMakeLists in the Kernel, top level, and runtime support libraries. A large part of the cleanup is replacing USE_CLANG_TOOLCHAIN with the proper CMAKE_CXX_COMPILER_ID variable, which will no longer be confused by a host clang compiler.
Diffstat (limited to 'Toolchain/CMake/GNUToolchain.txt.in')
-rw-r--r--Toolchain/CMake/GNUToolchain.txt.in37
1 files changed, 37 insertions, 0 deletions
diff --git a/Toolchain/CMake/GNUToolchain.txt.in b/Toolchain/CMake/GNUToolchain.txt.in
new file mode 100644
index 0000000000..9a0a2efdc8
--- /dev/null
+++ b/Toolchain/CMake/GNUToolchain.txt.in
@@ -0,0 +1,37 @@
+list(APPEND CMAKE_MODULE_PATH "@SERENITY_SOURCE_DIR@/Toolchain/CMake")
+
+set(CMAKE_SYSTEM_NAME SerenityOS)
+set(CMAKE_SYSTEM_PROCESSOR "@SERENITY_ARCH@")
+
+set(SERENITYOS 1)
+set(triple @SERENITY_ARCH@-pc-serenity)
+set(TOOLCHAIN_PATH @SERENITY_SOURCE_DIR@/Toolchain/Local/@SERENITY_ARCH@/bin)
+set(TOOLCHAIN_PREFIX ${TOOLCHAIN_PATH}/${triple}-)
+
+# where to read from/write to
+set(CMAKE_SYSROOT @SERENITY_BUILD_DIR@/Root)
+set(CMAKE_STAGING_PREFIX @SERENITY_BUILD_DIR@/Root/usr/local)
+set(CMAKE_INSTALL_PREFIX @SERENITY_BUILD_DIR@/Root/usr/local)
+set(CMAKE_INSTALL_DATAROOTDIR @SERENITY_BUILD_DIR@/Root/usr/local/share)
+
+set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
+set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
+set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}gcc)
+set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}ld)
+set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib)
+set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}strip)
+set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar)
+set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
+set(CMAKE_CXXFILT ${TOOLCHAIN_PREFIX}c++filt)
+
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,max-page-size=0x1000,-z,separate-code")
+
+# FIXME: We could eliminate this setting by building LibC and support asm files (crti.o, crtn.o)
+# in a separate build stage before the main build to ensure that LibC is available
+# for the try_compile check for the main build.
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)