aboutsummaryrefslogtreecommitdiff
path: root/cmake/Platforms
diff options
context:
space:
mode:
authorfelix.morgner@ost.ch <felix.morgner@gmail.com>2023-10-07 10:45:45 +0200
committerfelix.morgner@ost.ch <felix.morgner@gmail.com>2023-10-07 10:45:45 +0200
commit68db123a2f37a66aea218fa48a5bab8ea6b12951 (patch)
tree911c21ba6ab3694ab6339186001a14c04fe889ea /cmake/Platforms
parentfa1f8636d2e2368c9cb446284946570565563f4f (diff)
downloadteachos-68db123a2f37a66aea218fa48a5bab8ea6b12951.tar.xz
teachos-68db123a2f37a66aea218fa48a5bab8ea6b12951.zip
x86_64: implement first bootable kernel
Diffstat (limited to 'cmake/Platforms')
-rw-r--r--cmake/Platforms/x86_64.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/cmake/Platforms/x86_64.cmake b/cmake/Platforms/x86_64.cmake
new file mode 100644
index 0000000..9e727cf
--- /dev/null
+++ b/cmake/Platforms/x86_64.cmake
@@ -0,0 +1,23 @@
+execute_process(COMMAND "x86_64-none-elf-g++" "-print-file-name=crtbegin.o"
+ OUTPUT_VARIABLE CRT_BEGIN
+ ERROR_QUIET
+)
+string(STRIP "${CRT_BEGIN}" CRT_BEGIN)
+mark_as_advanced(CRT_BEGIN)
+
+string(REGEX REPLACE "/crtbegin.o" "" CMAKE_SYSROOT "${CRT_BEGIN}")
+mark_as_advanced(CMAKE_SYSROOT)
+
+set(CMAKE_CXX_FLAGS_INIT "-m64 -mno-red-zone -mcmodel=large")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-nostartfiles")
+set(CMAKE_CXX_LINK_EXECUTABLE
+ "<CMAKE_CXX_COMPILER> \
+ <FLAGS> \
+ <CMAKE_CXX_LINK_FLAGS> \
+ <LINK_FLAGS> \
+ ${CMAKE_SYSROOT}/crtbegin.o \
+ <OBJECTS> \
+ -o <TARGET> \
+ <LINK_LIBRARIES> \
+ ${CMAKE_SYSROOT}/crtend.o"
+)