From f30947336a95a357d4548e222731352a61e3d74d Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 5 Sep 2024 12:52:25 +0300 Subject: [PATCH] BuildSystem: Cleanup cmake files --- BAN/CMakeLists.txt | 3 +++ CMakeLists.txt | 3 +++ kernel/CMakeLists.txt | 11 ++++++----- userspace/libraries/LibC/CMakeLists.txt | 7 ++----- userspace/libraries/LibFont/CMakeLists.txt | 2 -- userspace/libraries/LibGUI/CMakeLists.txt | 2 -- userspace/libraries/LibImage/CMakeLists.txt | 2 -- userspace/libraries/LibInput/CMakeLists.txt | 4 +--- userspace/programs/Terminal/CMakeLists.txt | 2 +- userspace/programs/WindowServer/CMakeLists.txt | 2 +- 10 files changed, 17 insertions(+), 21 deletions(-) diff --git a/BAN/CMakeLists.txt b/BAN/CMakeLists.txt index feb9f8ec..a9b5d0f4 100644 --- a/BAN/CMakeLists.txt +++ b/BAN/CMakeLists.txt @@ -6,7 +6,10 @@ set(BAN_SOURCES ) add_library(ban ${BAN_SOURCES}) +target_link_options(ban PRIVATE -nolibc) banan_link_library(ban libc) +set_target_properties(ban PROPERTIES OUTPUT_NAME libban) + banan_install_headers(ban) install(TARGETS ban OPTIONAL) diff --git a/CMakeLists.txt b/CMakeLists.txt index 581595c2..e5c1201a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,9 @@ set(CMAKE_INSTALL_SYSCONF ${BANAN_ETC}) set(CMAKE_INSTALL_MESSAGE NEVER) set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY True) +set(CMAKE_STATIC_LIBRARY_PREFIX "") +set(CMAKE_SHARED_LIBRARY_PREFIX "") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 9f81ecf5..8d5d0938 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -191,12 +191,12 @@ target_compile_options(kernel PRIVATE -Wall -Wextra -Werror -Wstack-usage=1024 ) -# This might not work with other toolchains -target_compile_options(kernel PRIVATE $<$: +# C++ specific +target_compile_options(kernel PRIVATE -Wno-literal-suffix -Wno-invalid-offsetof -fno-rtti - -fno-exceptions> + -fno-exceptions ) if(ENABLE_KERNEL_UBSAN) @@ -213,8 +213,9 @@ endif() target_link_options(kernel PRIVATE -ffreestanding -nostdlib -orphan-handling=error) -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=crtbegin.o OUTPUT_VARIABLE CRTBEGIN OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=crtend.o OUTPUT_VARIABLE CRTEND OUTPUT_STRIP_TRAILING_WHITESPACE) +get_target_property(KERNEL_COMPILE_OPTIONS kernel COMPILE_OPTIONS) +execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${KERNEL_COMPILE_OPTIONS} -print-file-name=crtbegin.o OUTPUT_VARIABLE CRTBEGIN OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${KERNEL_COMPILE_OPTIONS} -print-file-name=crtend.o OUTPUT_VARIABLE CRTEND OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_command( TARGET kernel PRE_LINK diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index a6a5389e..0742483f 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -76,8 +76,8 @@ banan_install_headers(objlibc) add_library(libc-static STATIC $) add_library(libc-shared SHARED $) -target_link_options(libc-static PRIVATE -nolibc) -target_link_options(libc-shared PRIVATE -nolibc) +target_link_options(libc-static PRIVATE -nostdlib) +target_link_options(libc-shared PRIVATE -nostdlib) install(TARGETS libc-static OPTIONAL) install(TARGETS libc-shared OPTIONAL) @@ -86,6 +86,3 @@ set_target_properties(libc-static PROPERTIES OUTPUT_NAME libc) set_target_properties(libc-shared PROPERTIES OUTPUT_NAME libc) add_library(libc ALIAS libc-static) - -set(CMAKE_STATIC_LIBRARY_PREFIX "") -set(CMAKE_SHARED_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibFont/CMakeLists.txt b/userspace/libraries/LibFont/CMakeLists.txt index d33a8122..390eed3a 100644 --- a/userspace/libraries/LibFont/CMakeLists.txt +++ b/userspace/libraries/LibFont/CMakeLists.txt @@ -9,5 +9,3 @@ banan_link_library(libfont ban) banan_install_headers(libfont) install(TARGETS libfont OPTIONAL) - -set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibGUI/CMakeLists.txt b/userspace/libraries/LibGUI/CMakeLists.txt index 5cbfdf5e..1234dcca 100644 --- a/userspace/libraries/LibGUI/CMakeLists.txt +++ b/userspace/libraries/LibGUI/CMakeLists.txt @@ -10,5 +10,3 @@ banan_link_library(libgui libc) banan_install_headers(libgui) install(TARGETS libgui OPTIONAL) - -set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibImage/CMakeLists.txt b/userspace/libraries/LibImage/CMakeLists.txt index 019549ea..33597d34 100644 --- a/userspace/libraries/LibImage/CMakeLists.txt +++ b/userspace/libraries/LibImage/CMakeLists.txt @@ -11,5 +11,3 @@ banan_link_library(libimage ban) banan_install_headers(libimage) install(TARGETS libimage OPTIONAL) - -set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibInput/CMakeLists.txt b/userspace/libraries/LibInput/CMakeLists.txt index ed3d02a2..b1c24d5c 100644 --- a/userspace/libraries/LibInput/CMakeLists.txt +++ b/userspace/libraries/LibInput/CMakeLists.txt @@ -4,10 +4,8 @@ set(LIBINPUT_SOURCES ) add_library(libinput ${LIBINPUT_SOURCES}) -banan_include_headers(libinput ban) +banan_link_library(libinput ban) banan_link_library(libinput libc) banan_install_headers(libinput) install(TARGETS libinput OPTIONAL) - -set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/programs/Terminal/CMakeLists.txt b/userspace/programs/Terminal/CMakeLists.txt index 4ba92d82..4ddc6892 100644 --- a/userspace/programs/Terminal/CMakeLists.txt +++ b/userspace/programs/Terminal/CMakeLists.txt @@ -4,7 +4,7 @@ set(SOURCES ) add_executable(Terminal ${SOURCES}) -banan_include_headers(Terminal ban) +banan_link_library(Terminal ban) banan_link_library(Terminal libc) banan_link_library(Terminal libfont) banan_link_library(Terminal libgui) diff --git a/userspace/programs/WindowServer/CMakeLists.txt b/userspace/programs/WindowServer/CMakeLists.txt index 7bc7674e..8fdf79f9 100644 --- a/userspace/programs/WindowServer/CMakeLists.txt +++ b/userspace/programs/WindowServer/CMakeLists.txt @@ -6,8 +6,8 @@ set(SOURCES ) add_executable(WindowServer ${SOURCES}) -banan_include_headers(WindowServer ban) banan_include_headers(WindowServer libgui) +banan_link_library(WindowServer ban) banan_link_library(WindowServer libc) banan_link_library(WindowServer libfont) banan_link_library(WindowServer libimage)