From 60f8108324dcc3859640799168fb33ea865cf815 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 7 Oct 2023 12:24:15 +0200 Subject: cmake: move modules to source --- cmake/Platforms/x86_64.cmake | 23 ----------------------- conanfile.py | 9 +++++---- source/cmake/Platforms/x86_64.cmake | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 27 deletions(-) delete mode 100644 cmake/Platforms/x86_64.cmake create mode 100644 source/cmake/Platforms/x86_64.cmake diff --git a/cmake/Platforms/x86_64.cmake b/cmake/Platforms/x86_64.cmake deleted file mode 100644 index 9e727cf..0000000 --- a/cmake/Platforms/x86_64.cmake +++ /dev/null @@ -1,23 +0,0 @@ -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_SYSROOT}/crtbegin.o \ - \ - -o \ - \ - ${CMAKE_SYSROOT}/crtend.o" -) diff --git a/conanfile.py b/conanfile.py index cc79bae..83040b7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -38,6 +38,8 @@ class KernelConan(ConanFile): toolchain.variables["TEACHOS_DESCRIPTION"] = self.description toolchain.variables["TEACHOS_HOMEPAGE_URL"] = self.homepage toolchain.variables["TEACHOS_VERSION"] = self.version + toolchain.blocks["teachos_cmake_modules"] = CMakeModulesPathBlock + toolchain.blocks["teachos_cmake_modules"].values["root"] = self.source_folder toolchain.blocks["teachos_platform"] = PlatformIncludeBlock toolchain.blocks["teachos_platform"].values["platform"] = self.settings.arch toolchain.blocks.remove("cmake_flags_init") @@ -49,8 +51,7 @@ class KernelConan(ConanFile): class PlatformIncludeBlock: - template = 'include("../cmake/Platforms/{{platform}}.cmake")' + template = 'include("{{platform}}")' - -def context(self): - return {"platform": None} +class CMakeModulesPathBlock: + template = 'list(APPEND CMAKE_MODULE_PATH "{{root}}/cmake/Modules" "{{root}}/cmake/Platforms")' diff --git a/source/cmake/Platforms/x86_64.cmake b/source/cmake/Platforms/x86_64.cmake new file mode 100644 index 0000000..9e727cf --- /dev/null +++ b/source/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_SYSROOT}/crtbegin.o \ + \ + -o \ + \ + ${CMAKE_SYSROOT}/crtend.o" +) -- cgit v1.2.3