BuildSystem: Cleanup CMake code to allow libc only installation

There was no way to just install libc which is required for stdlibc++
This commit is contained in:
Bananymous 2024-06-20 14:32:05 +03:00
parent 1488ec5a03
commit 9e1b5cbaab
82 changed files with 88 additions and 86 deletions

View File

@ -9,4 +9,4 @@ add_library(ban ${BAN_SOURCES})
banan_link_library(ban libc)
banan_install_headers(ban)
install(TARGETS ban)
install(TARGETS ban OPTIONAL)

View File

@ -24,6 +24,7 @@ set(CMAKE_INSTALL_LIBDIR ${BANAN_LIB})
set(CMAKE_INSTALL_INCLUDEDIR ${BANAN_INCLUDE})
set(CMAKE_INSTALL_SYSCONF ${BANAN_ETC})
set(CMAKE_INSTALL_MESSAGE NEVER)
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY True)
# include headers of ${library} to ${target}
function(banan_include_headers target library)
@ -38,12 +39,12 @@ endfunction()
# add install step for all header files of target
function(banan_install_headers target)
file(GLOB_RECURSE headers RELATIVE $<TARGET_PROPERTY:${target},SOURCE_DIR>/include "*.h")
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/include *.h)
foreach(header ${headers})
get_filename_component(subdirectory ${header} DIRECTORY)
install(FILES include/${header} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${subdirectory} OPTIONAL)
install(FILES include/${header} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${subdirectory})
endforeach()
target_include_directories(${target} PRIVATE $<TARGET_PROPERTY:${target},SOURCE_DIR>/include)
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
endfunction()
add_subdirectory(kernel)

View File

@ -212,7 +212,7 @@ banan_include_headers(kernel libinput)
banan_install_headers(kernel)
set_target_properties(kernel PROPERTIES OUTPUT_NAME banan-os.kernel)
install(TARGETS kernel DESTINATION ${BANAN_BOOT})
install(TARGETS kernel DESTINATION ${BANAN_BOOT} OPTIONAL)
if("${BANAN_ARCH}" STREQUAL "x86_64")
set(ELF_FORMAT elf64-x86-64)

View File

@ -46,7 +46,7 @@ build_toolchain () {
}
create_image () {
build_target bootloader
build_target all
build_target install
$BANAN_ROOT_DIR/ports/build.sh

View File

@ -239,7 +239,7 @@ find $BANAN_BUILD_DIR -mindepth 1 -maxdepth 1 ! -name toolchain -exec rm -r {} +
# NOTE: we have to manually create initial sysroot with libc headers
# since cmake cannot be invoked yet
mkdir -p $BANAN_SYSROOT/usr
cp -r $BANAN_ROOT_DIR/libc/include $BANAN_SYSROOT/usr/include
cp -r $BANAN_ROOT_DIR/userspace/libraries/LibC/include $BANAN_SYSROOT/usr/include
mkdir -p $BANAN_BUILD_DIR/toolchain
@ -262,7 +262,8 @@ fi
if (($BUILD_LIBSTDCPP)); then
# delete sysroot and install libc
rm -r $BANAN_SYSROOT
$BANAN_SCRIPT_DIR/build.sh libc-install
$BANAN_SCRIPT_DIR/build.sh libc
$BANAN_SCRIPT_DIR/build.sh install
build_libstdcpp
fi

View File

@ -6,4 +6,4 @@ add_executable(Shell ${SOURCES})
banan_link_library(Shell ban)
banan_link_library(Shell libc)
install(TARGETS Shell)
install(TARGETS Shell OPTIONAL)

View File

@ -10,4 +10,4 @@ banan_link_library(Terminal libfont)
banan_link_library(Terminal libgui)
banan_link_library(Terminal libinput)
install(TARGETS Terminal)
install(TARGETS Terminal OPTIONAL)

View File

@ -13,4 +13,4 @@ banan_link_library(WindowServer libfont)
banan_link_library(WindowServer libimage)
banan_link_library(WindowServer libinput)
install(TARGETS WindowServer)
install(TARGETS WindowServer OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day-template ${SOURCES})
banan_include_headers(aoc2023_day-template ban)
banan_link_library(aoc2023_day-template libc)
install(TARGETS aoc2023_day-template)
install(TARGETS aoc2023_day-template OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day1 ${SOURCES})
banan_include_headers(aoc2023_day1 ban)
banan_link_library(aoc2023_day1 libc)
install(TARGETS aoc2023_day1)
install(TARGETS aoc2023_day1 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day10 ${SOURCES})
banan_include_headers(aoc2023_day10 ban)
banan_link_library(aoc2023_day10 libc)
install(TARGETS aoc2023_day10)
install(TARGETS aoc2023_day10 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day11 ${SOURCES})
banan_include_headers(aoc2023_day11 ban)
banan_link_library(aoc2023_day11 libc)
install(TARGETS aoc2023_day11)
install(TARGETS aoc2023_day11 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day12 ${SOURCES})
banan_link_library(aoc2023_day12 ban)
banan_link_library(aoc2023_day12 libc)
install(TARGETS aoc2023_day12)
install(TARGETS aoc2023_day12 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day13 ${SOURCES})
banan_include_headers(aoc2023_day13 ban)
banan_link_library(aoc2023_day13 libc)
install(TARGETS aoc2023_day13)
install(TARGETS aoc2023_day13 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day14 ${SOURCES})
banan_include_headers(aoc2023_day14 ban)
banan_link_library(aoc2023_day14 libc)
install(TARGETS aoc2023_day14)
install(TARGETS aoc2023_day14 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day15 ${SOURCES})
banan_include_headers(aoc2023_day15 ban)
banan_link_library(aoc2023_day15 libc)
install(TARGETS aoc2023_day15)
install(TARGETS aoc2023_day15 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day16 ${SOURCES})
banan_include_headers(aoc2023_day16 ban)
banan_link_library(aoc2023_day16 libc)
install(TARGETS aoc2023_day16)
install(TARGETS aoc2023_day16 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day17 ${SOURCES})
banan_include_headers(aoc2023_day17 ban)
banan_link_library(aoc2023_day17 libc)
install(TARGETS aoc2023_day17)
install(TARGETS aoc2023_day17 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day18 ${SOURCES})
banan_include_headers(aoc2023_day18 ban)
banan_link_library(aoc2023_day18 libc)
install(TARGETS aoc2023_day18)
install(TARGETS aoc2023_day18 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day19 ${SOURCES})
banan_include_headers(aoc2023_day19 ban)
banan_link_library(aoc2023_day19 libc)
install(TARGETS aoc2023_day19)
install(TARGETS aoc2023_day19 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day2 ${SOURCES})
banan_include_headers(aoc2023_day2 ban)
banan_link_library(aoc2023_day2 libc)
install(TARGETS aoc2023_day2)
install(TARGETS aoc2023_day2 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day20 ${SOURCES})
banan_link_library(aoc2023_day20 ban)
banan_link_library(aoc2023_day20 libc)
install(TARGETS aoc2023_day20)
install(TARGETS aoc2023_day20 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day21 ${SOURCES})
banan_include_headers(aoc2023_day21 ban)
banan_link_library(aoc2023_day21 libc)
install(TARGETS aoc2023_day21)
install(TARGETS aoc2023_day21 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day22 ${SOURCES})
banan_include_headers(aoc2023_day22 ban)
banan_link_library(aoc2023_day22 libc)
install(TARGETS aoc2023_day22)
install(TARGETS aoc2023_day22 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day23 ${SOURCES})
banan_include_headers(aoc2023_day23 ban)
banan_link_library(aoc2023_day23 libc)
install(TARGETS aoc2023_day23)
install(TARGETS aoc2023_day23 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day24 ${SOURCES})
banan_include_headers(aoc2023_day24 ban)
banan_link_library(aoc2023_day24 libc)
install(TARGETS aoc2023_day24)
install(TARGETS aoc2023_day24 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day25 ${SOURCES})
banan_link_library(aoc2023_day25 ban)
banan_link_library(aoc2023_day25 libc)
install(TARGETS aoc2023_day25)
install(TARGETS aoc2023_day25 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day3 ${SOURCES})
banan_include_headers(aoc2023_day3 ban)
banan_link_library(aoc2023_day3 libc)
install(TARGETS aoc2023_day3)
install(TARGETS aoc2023_day3 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day4 ${SOURCES})
banan_link_library(aoc2023_day4 ban)
banan_link_library(aoc2023_day4 libc)
install(TARGETS aoc2023_day4)
install(TARGETS aoc2023_day4 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day5 ${SOURCES})
banan_include_headers(aoc2023_day5 ban)
banan_link_library(aoc2023_day5 libc)
install(TARGETS aoc2023_day5)
install(TARGETS aoc2023_day5 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day6 ${SOURCES})
banan_include_headers(aoc2023_day6 ban)
banan_link_library(aoc2023_day6 libc)
install(TARGETS aoc2023_day6)
install(TARGETS aoc2023_day6 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day7 ${SOURCES})
banan_include_headers(aoc2023_day7 ban)
banan_link_library(aoc2023_day7 libc)
install(TARGETS aoc2023_day7)
install(TARGETS aoc2023_day7 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day8 ${SOURCES})
banan_include_headers(aoc2023_day8 ban)
banan_link_library(aoc2023_day8 libc)
install(TARGETS aoc2023_day8)
install(TARGETS aoc2023_day8 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_day9 ${SOURCES})
banan_include_headers(aoc2023_day9 ban)
banan_link_library(aoc2023_day9 libc)
install(TARGETS aoc2023_day9)
install(TARGETS aoc2023_day9 OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(aoc2023_full ${SOURCES})
banan_include_headers(aoc2023_full ban)
banan_link_library(aoc2023_full libc)
install(TARGETS aoc2023_full)
install(TARGETS aoc2023_full OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(cat-mmap ${SOURCES})
banan_link_library(cat-mmap libc)
install(TARGETS cat-mmap)
install(TARGETS cat-mmap OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(cat ${SOURCES})
banan_link_library(cat libc)
install(TARGETS cat)
install(TARGETS cat OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(chmod ${SOURCES})
banan_link_library(chmod libc)
install(TARGETS chmod)
install(TARGETS chmod OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(cp ${SOURCES})
banan_include_headers(cp ban)
banan_link_library(cp libc)
install(TARGETS cp)
install(TARGETS cp OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(dd ${SOURCES})
banan_link_library(dd libc)
install(TARGETS dd)
install(TARGETS dd OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(dhcp-client ${SOURCES})
banan_include_headers(dhcp-client ban)
banan_link_library(dhcp-client libc)
install(TARGETS dhcp-client)
install(TARGETS dhcp-client OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(echo ${SOURCES})
banan_link_library(echo libc)
install(TARGETS echo)
install(TARGETS echo OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(getopt ${SOURCES})
banan_include_headers(getopt ban)
banan_link_library(getopt libc)
install(TARGETS getopt)
install(TARGETS getopt OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(http-server ${SOURCES})
banan_link_library(http-server ban)
banan_link_library(http-server libc)
install(TARGETS http-server)
install(TARGETS http-server OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(id ${SOURCES})
banan_include_headers(id ban)
banan_link_library(id libc)
install(TARGETS id)
install(TARGETS id OPTIONAL)

View File

@ -7,4 +7,4 @@ banan_include_headers(image ban)
banan_link_library(image libc)
banan_link_library(image libimage)
install(TARGETS image)
install(TARGETS image OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(init ${SOURCES})
banan_include_headers(init ban)
banan_link_library(init libc)
install(TARGETS init)
install(TARGETS init OPTIONAL)

View File

@ -32,7 +32,7 @@ set(LIBC_SOURCES
)
add_library(libc ${LIBC_SOURCES})
target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns)
target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns -nostdlib)
target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=)
add_library(crt0 OBJECT arch/${BANAN_ARCH}/crt0.S)
@ -49,6 +49,6 @@ banan_include_headers(libc ban)
banan_include_headers(libc kernel)
banan_install_headers(libc)
install(TARGETS libc)
install(TARGETS libc OPTIONAL)
set(CMAKE_STATIC_LIBRARY_PREFIX "")

View File

@ -5,4 +5,4 @@ set(SOURCES
add_library(libelf ${SOURCES})
banan_install_headers(libelf)
install(TARGETS libelf)
install(TARGETS libelf OPTIONAL)

View File

@ -8,6 +8,6 @@ banan_link_library(libfont libc)
banan_link_library(libfont ban)
banan_install_headers(libfont)
install(TARGETS libfont)
install(TARGETS libfont OPTIONAL)
set(CMAKE_STATIC_LIBRARY_PREFIX "")

View File

@ -9,6 +9,6 @@ banan_include_headers(libgui libinput)
banan_link_library(libgui libc)
banan_install_headers(libgui)
install(TARGETS libgui)
install(TARGETS libgui OPTIONAL)
set(CMAKE_STATIC_LIBRARY_PREFIX "")

View File

@ -10,6 +10,6 @@ banan_link_library(libimage libc)
banan_link_library(libimage ban)
banan_install_headers(libimage)
install(TARGETS libimage)
install(TARGETS libimage OPTIONAL)
set(CMAKE_STATIC_LIBRARY_PREFIX "")

View File

@ -8,6 +8,6 @@ banan_include_headers(libinput ban)
banan_link_library(libinput libc)
banan_install_headers(libinput)
install(TARGETS libinput)
install(TARGETS libinput OPTIONAL)
set(CMAKE_STATIC_LIBRARY_PREFIX "")

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(loadkeys ${SOURCES})
banan_link_library(loadkeys libc)
install(TARGETS loadkeys)
install(TARGETS loadkeys OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(ls ${SOURCES})
banan_link_library(ls ban)
banan_link_library(ls libc)
install(TARGETS ls)
install(TARGETS ls OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(meminfo ${SOURCES})
banan_link_library(meminfo libc)
install(TARGETS meminfo)
install(TARGETS meminfo OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(mkdir ${SOURCES})
banan_link_library(mkdir libc)
install(TARGETS mkdir)
install(TARGETS mkdir OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(nslookup ${SOURCES})
banan_link_library(nslookup libc)
install(TARGETS nslookup)
install(TARGETS nslookup OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(poweroff ${SOURCES})
banan_link_library(poweroff libc)
install(TARGETS poweroff)
install(TARGETS poweroff OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(resolver ${SOURCES})
banan_link_library(resolver ban)
banan_link_library(resolver libc)
install(TARGETS resolver)
install(TARGETS resolver OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(rm ${SOURCES})
banan_include_headers(rm ban)
banan_link_library(rm libc)
install(TARGETS rm)
install(TARGETS rm OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(sleep ${SOURCES})
banan_link_library(sleep libc)
install(TARGETS sleep)
install(TARGETS sleep OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(snake ${SOURCES})
banan_include_headers(snake ban)
banan_link_library(snake libc)
install(TARGETS snake)
install(TARGETS snake OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(stat ${SOURCES})
banan_link_library(stat ban)
banan_link_library(stat libc)
install(TARGETS stat)
install(TARGETS stat OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(sudo ${SOURCES})
banan_link_library(sudo libc)
install(TARGETS sudo)
install(TARGETS sudo OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(sync ${SOURCES})
banan_link_library(sync libc)
install(TARGETS sync)
install(TARGETS sync OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(tee ${SOURCES})
banan_link_library(tee libc)
install(TARGETS tee)
install(TARGETS tee OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(test-framebuffer ${SOURCES})
banan_link_library(test-framebuffer libc)
install(TARGETS test-framebuffer)
install(TARGETS test-framebuffer OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(test-globals ${SOURCES})
banan_link_library(test-globals libc)
install(TARGETS test-globals)
install(TARGETS test-globals OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(test-mmap-shared ${SOURCES})
banan_link_library(test-mmap-shared libc)
install(TARGETS test-mmap-shared)
install(TARGETS test-mmap-shared OPTIONAL)

View File

@ -7,4 +7,4 @@ banan_include_headers(test-mouse ban)
banan_include_headers(test-mouse libinput)
banan_link_library(test-mouse libc)
install(TARGETS test-mouse)
install(TARGETS test-mouse OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(test-popen ${SOURCES})
banan_link_library(test-popen libc)
install(TARGETS test-popen)
install(TARGETS test-popen OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(test-sort ${SOURCES})
banan_include_headers(test-sort ban)
banan_link_library(test-sort libc)
install(TARGETS test-sort)
install(TARGETS test-sort OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(test-tcp ${SOURCES})
banan_link_library(test-tcp libc)
install(TARGETS test-tcp)
install(TARGETS test-tcp OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(test-udp ${SOURCES})
banan_link_library(test-udp libc)
install(TARGETS test-udp)
install(TARGETS test-udp OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(test-unix-socket ${SOURCES})
banan_link_library(test-unix-socket libc)
install(TARGETS test-unix-socket)
install(TARGETS test-unix-socket OPTIONAL)

View File

@ -8,4 +8,4 @@ banan_include_headers(test-window libinput)
banan_link_library(test-window libc)
banan_link_library(test-window libgui)
install(TARGETS test-window)
install(TARGETS test-window OPTIONAL)

View File

@ -5,4 +5,4 @@ set(TEST_SOURCES
add_executable(test ${TEST_SOURCES})
banan_link_library(test libc)
install(TARGETS test)
install(TARGETS test OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(touch ${SOURCES})
banan_link_library(touch libc)
install(TARGETS touch)
install(TARGETS touch OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(u8sum ${SOURCES})
banan_link_library(u8sum libc)
install(TARGETS u8sum)
install(TARGETS u8sum OPTIONAL)

View File

@ -6,4 +6,4 @@ add_executable(whoami ${SOURCES})
banan_include_headers(whoami ban)
banan_link_library(whoami libc)
install(TARGETS whoami)
install(TARGETS whoami OPTIONAL)

View File

@ -5,4 +5,4 @@ set(SOURCES
add_executable(yes ${SOURCES})
banan_link_library(yes libc)
install(TARGETS yes)
install(TARGETS yes OPTIONAL)