summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2022-01-03 06:19:40 (GMT)
committerBrad King <brad.king@kitware.com>2022-06-14 19:31:17 (GMT)
commit45ca894164ce53ada93144131e17ce665267f1ce (patch)
tree935c9372a7850c66d7fbb124f622237d16e87af2 /Modules/Platform
parentca8a5b05de811d6a95cfa7a33a2985f2b193967f (diff)
downloadCMake-45ca894164ce53ada93144131e17ce665267f1ce.zip
CMake-45ca894164ce53ada93144131e17ce665267f1ce.tar.gz
CMake-45ca894164ce53ada93144131e17ce665267f1ce.tar.bz2
SerenityOS: Add Platform module
Add an initial Platform module for SerenityOS [1]. This module is a mix of the platform module currently used to build the Serenity Kernel and Userspace applications and libraries, and the platform module included in the CMake Port [2] which still has some work to do on the system before its other patches could be considered for upstream. As such, the platform module is currently only useful when used with a suitably patched GCC or LLVM cross-compiler toolchain. [1] https://github.com/SerenityOS/serenity [2] https://github.com/SerenityOS/serenity/tree/master/Ports/cmake/patches Issue: #23589
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/SerenityOS-Clang-ASM.cmake2
-rw-r--r--Modules/Platform/SerenityOS-Clang-C.cmake2
-rw-r--r--Modules/Platform/SerenityOS-Clang-CXX.cmake2
-rw-r--r--Modules/Platform/SerenityOS-GNU-ASM.cmake2
-rw-r--r--Modules/Platform/SerenityOS-GNU-C.cmake2
-rw-r--r--Modules/Platform/SerenityOS-GNU-CXX.cmake2
-rw-r--r--Modules/Platform/SerenityOS-GNU.cmake24
-rw-r--r--Modules/Platform/SerenityOS.cmake12
8 files changed, 48 insertions, 0 deletions
diff --git a/Modules/Platform/SerenityOS-Clang-ASM.cmake b/Modules/Platform/SerenityOS-Clang-ASM.cmake
new file mode 100644
index 0000000..ba1e18c
--- /dev/null
+++ b/Modules/Platform/SerenityOS-Clang-ASM.cmake
@@ -0,0 +1,2 @@
+include(Platform/SerenityOS-GNU)
+__serenity_compiler_gnu(ASM)
diff --git a/Modules/Platform/SerenityOS-Clang-C.cmake b/Modules/Platform/SerenityOS-Clang-C.cmake
new file mode 100644
index 0000000..791a197
--- /dev/null
+++ b/Modules/Platform/SerenityOS-Clang-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/SerenityOS-GNU)
+__serenity_compiler_gnu(C)
diff --git a/Modules/Platform/SerenityOS-Clang-CXX.cmake b/Modules/Platform/SerenityOS-Clang-CXX.cmake
new file mode 100644
index 0000000..084e319
--- /dev/null
+++ b/Modules/Platform/SerenityOS-Clang-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/SerenityOS-GNU)
+__serenity_compiler_gnu(CXX)
diff --git a/Modules/Platform/SerenityOS-GNU-ASM.cmake b/Modules/Platform/SerenityOS-GNU-ASM.cmake
new file mode 100644
index 0000000..ba1e18c
--- /dev/null
+++ b/Modules/Platform/SerenityOS-GNU-ASM.cmake
@@ -0,0 +1,2 @@
+include(Platform/SerenityOS-GNU)
+__serenity_compiler_gnu(ASM)
diff --git a/Modules/Platform/SerenityOS-GNU-C.cmake b/Modules/Platform/SerenityOS-GNU-C.cmake
new file mode 100644
index 0000000..791a197
--- /dev/null
+++ b/Modules/Platform/SerenityOS-GNU-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/SerenityOS-GNU)
+__serenity_compiler_gnu(C)
diff --git a/Modules/Platform/SerenityOS-GNU-CXX.cmake b/Modules/Platform/SerenityOS-GNU-CXX.cmake
new file mode 100644
index 0000000..084e319
--- /dev/null
+++ b/Modules/Platform/SerenityOS-GNU-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/SerenityOS-GNU)
+__serenity_compiler_gnu(CXX)
diff --git a/Modules/Platform/SerenityOS-GNU.cmake b/Modules/Platform/SerenityOS-GNU.cmake
new file mode 100644
index 0000000..ed39477
--- /dev/null
+++ b/Modules/Platform/SerenityOS-GNU.cmake
@@ -0,0 +1,24 @@
+# This module is shared by multiple languages; use include blocker.
+include_guard()
+
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,separate-code,-z,max-page-size=0x1000")
+
+macro(__serenity_compiler_gnu lang)
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,")
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
+ set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,")
+ set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,")
+ set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic")
+
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared -Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,separate-code")
+
+ # Initialize link type selection flags. These flags are used when
+ # building a shared library, shared module, or executable that links
+ # to other libraries to select whether to use the static or shared
+ # versions of the libraries.
+ foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
+ set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic")
+ set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic")
+ endforeach()
+
+endmacro()
diff --git a/Modules/Platform/SerenityOS.cmake b/Modules/Platform/SerenityOS.cmake
new file mode 100644
index 0000000..541620c
--- /dev/null
+++ b/Modules/Platform/SerenityOS.cmake
@@ -0,0 +1,12 @@
+
+set(SERENITYOS 1)
+
+set(CMAKE_DL_LIBS "-ldl")
+set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
+set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
+
+# Shared libraries with no builtin soname may not be linked safely by
+# specifying the file path.
+set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1)
+
+include(Platform/UnixPaths)