diff --git a/BAN/CMakeLists.txt b/BAN/CMakeLists.txt index 0f8f05f0f5..3f759c40ad 100644 --- a/BAN/CMakeLists.txt +++ b/BAN/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - -project(BAN CXX) - set(BAN_SOURCES BAN/Assert.cpp BAN/New.cpp @@ -9,16 +5,8 @@ set(BAN_SOURCES BAN/Time.cpp ) -add_custom_target(ban-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot -) - add_library(ban ${BAN_SOURCES}) -add_dependencies(ban headers libc-install) +banan_link_library(ban libc) -add_custom_target(ban-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libban.a ${BANAN_LIB}/ - DEPENDS ban - BYPRODUCTS ${BANAN_LIB}/libban.a -) +banan_install_headers(ban) +install(TARGETS ban) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8c0053add..7d5f22d741 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,41 @@ add_compile_definitions(__enable_sse=1) project(banan-os CXX C ASM) set(BANAN_BASE_SYSROOT ${CMAKE_SOURCE_DIR}/base-sysroot.tar.gz) + set(BANAN_INCLUDE ${BANAN_SYSROOT}/usr/include) -set(BANAN_LIB ${BANAN_SYSROOT}/usr/lib) -set(BANAN_BIN ${BANAN_SYSROOT}/usr/bin) -set(BANAN_SHARE ${BANAN_SYSROOT}/usr/share) -set(BANAN_BOOT ${BANAN_SYSROOT}/boot) +set(BANAN_LIB ${BANAN_SYSROOT}/usr/lib) +set(BANAN_BIN ${BANAN_SYSROOT}/usr/bin) +set(BANAN_ETC ${BANAN_SYSROOT}/usr/etc) +set(BANAN_SHARE ${BANAN_SYSROOT}/usr/share) +set(BANAN_BOOT ${BANAN_SYSROOT}/boot) + +set(CMAKE_INSTALL_BINDIR ${BANAN_BIN}) +set(CMAKE_INSTALL_SBINDIR ${BANAN_BIN}) +set(CMAKE_INSTALL_LIBDIR ${BANAN_LIB}) +set(CMAKE_INSTALL_INCLUDEDIR ${BANAN_INCLUDE}) +set(CMAKE_INSTALL_SYSCONF ${BANAN_ETC}) +set(CMAKE_INSTALL_MESSAGE NEVER) + +# include headers of ${library} to ${target} +function(banan_include_headers target library) + target_include_directories(${target} PRIVATE $/include) +endfunction() + +# include headers and link ${library} to ${target} +function(banan_link_library target library) + target_link_libraries(${target} PRIVATE ${library}) + banan_include_headers(${target} ${library}) +endfunction() + +# add install step for all header files of target +function(banan_install_headers target) + file(GLOB_RECURSE headers RELATIVE $/include "*.h") + foreach(header ${headers}) + get_filename_component(subdirectory ${header} DIRECTORY) + install(FILES include/${header} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${subdirectory} OPTIONAL) + endforeach() + target_include_directories(${target} PRIVATE $/include) +endfunction() add_subdirectory(kernel) add_subdirectory(bootloader) @@ -25,20 +55,3 @@ add_custom_target(sysroot COMMAND ${CMAKE_COMMAND} -E make_directory ${BANAN_SYSROOT} COMMAND cd ${BANAN_SYSROOT} && tar xf ${BANAN_BASE_SYSROOT} ) - -add_custom_target(headers - DEPENDS kernel-headers - DEPENDS ban-headers - DEPENDS userspace-headers -) - -add_custom_target(install-sysroot - DEPENDS kernel-install - DEPENDS ban-install - DEPENDS userspace-install -) - -add_custom_target(package-sysroot - COMMAND cd ${BANAN_SYSROOT} && tar cf ${BANAN_SYSROOT_TAR} * - DEPENDS install-sysroot -) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 931b3016b1..8fa5f09bb5 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -1,13 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - -project(kernel CXX C ASM) - -if("${BANAN_ARCH}" STREQUAL "x86_64") - set(ELF_FORMAT elf64-x86-64) -elseif("${BANAN_ARCH}" STREQUAL "i686") - set(ELF_FORMAT elf32-i386) -endif() - set(KERNEL_SOURCES font/prefs.psf.o kernel/ACPI/ACPI.cpp @@ -106,7 +96,7 @@ set(KERNEL_SOURCES icxxabi.cpp ) -#set(ENABLE_KERNEL_UBSAN True) +set(ENABLE_KERNEL_UBSAN False) if(ENABLE_KERNEL_UBSAN) set(KERNEL_SOURCES ${KERNEL_SOURCES} ubsan.cpp) @@ -172,7 +162,6 @@ set(KERNEL_SOURCES ) add_executable(kernel ${KERNEL_SOURCES}) -add_dependencies(kernel headers) target_compile_definitions(kernel PUBLIC __is_kernel) target_compile_definitions(kernel PUBLIC __arch=${BANAN_ARCH}) @@ -199,16 +188,6 @@ endif() target_link_options(kernel PUBLIC -ffreestanding -nostdlib) -add_custom_target(kernel-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot -) - -add_custom_target(kernel-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/kernel ${BANAN_BOOT}/banan-os.kernel - DEPENDS kernel -) - 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) @@ -225,6 +204,22 @@ add_custom_command( # COMMAND x86_64-banan_os-strip ${CMAKE_CURRENT_BINARY_DIR}/kernel #) +banan_include_headers(kernel ban) +banan_include_headers(kernel libc) +banan_include_headers(kernel libfont) +banan_include_headers(kernel libelf) +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}) + +if("${BANAN_ARCH}" STREQUAL "x86_64") + set(ELF_FORMAT elf64-x86-64) +elseif("${BANAN_ARCH}" STREQUAL "i686") + set(ELF_FORMAT elf32-i386) +endif() + add_custom_command( OUTPUT font/prefs.psf.o COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && objcopy -O ${ELF_FORMAT} -B i386 -I binary font/prefs.psf ${CMAKE_CURRENT_BINARY_DIR}/font/prefs.psf.o diff --git a/script/build.sh b/script/build.sh index 23144d2810..22c7e2e245 100755 --- a/script/build.sh +++ b/script/build.sh @@ -7,6 +7,9 @@ source $BANAN_SCRIPT_DIR/config.sh FAKEROOT_FILE="$BANAN_BUILD_DIR/fakeroot-context" run_fakeroot() { + if [ ! -f $FAKEROOT_FILE ]; then + touch $FAKEROOT_FILE + fi fakeroot -i $FAKEROOT_FILE -s $FAKEROOT_FILE -- /bin/bash -c '$@' bash $@ } @@ -44,9 +47,14 @@ build_toolchain () { create_image () { build_target bootloader - build_target install-sysroot + build_target install + $BANAN_ROOT_DIR/ports/build.sh - build_target package-sysroot + + pushd $BANAN_SYSROOT >/dev/null + run_fakeroot tar cf ${BANAN_SYSROOT_TAR} * + popd >/dev/null + $BANAN_SCRIPT_DIR/image.sh "$1" } @@ -106,8 +114,12 @@ case $1 in build_target clean rm -f $FAKEROOT_FILE rm -rf $BANAN_SYSROOT + rm -f $BANAN_SYSROOT.tar rm -f $BANAN_DISK_IMAGE_PATH ;; + distclean) + rm -rf $BANAN_BUILD_DIR + ;; *) build_target $1 ;; diff --git a/userspace/CMakeLists.txt b/userspace/CMakeLists.txt index 6c194e0fbb..8d26d9583d 100644 --- a/userspace/CMakeLists.txt +++ b/userspace/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - -project(userspace CXX) - set(USERSPACE_PROJECTS cat cat-mmap @@ -18,7 +14,6 @@ set(USERSPACE_PROJECTS ls meminfo mkdir - mmap-shared-test nslookup poweroff resolver @@ -34,6 +29,7 @@ set(USERSPACE_PROJECTS test test-framebuffer test-globals + test-mmap-shared test-mouse test-popen test-sort @@ -50,20 +46,16 @@ set(USERSPACE_PROJECTS add_subdirectory(libraries) -foreach(USERSPACE_PROJECT ${USERSPACE_PROJECTS}) - add_subdirectory(${USERSPACE_PROJECT}) -endforeach() - -add_custom_target(userspace DEPENDS libraries) -add_custom_target(userspace-headers DEPENDS libraries-headers) -add_custom_target(userspace-install DEPENDS userspace libraries-install) - -add_subdirectory(aoc2023) - -foreach(USERSPACE_PROJECT ${USERSPACE_PROJECTS}) - target_compile_options(${USERSPACE_PROJECT} PRIVATE -g) - add_dependencies(userspace ${USERSPACE_PROJECT}) - add_dependencies(userspace-install ${USERSPACE_PROJECT}-install) - - target_link_options(${USERSPACE_PROJECT} PRIVATE -nolibc) +add_custom_target(userspace) + +#add_subdirectory(aoc2023) + +foreach(project ${USERSPACE_PROJECTS}) + add_subdirectory(${project}) + add_dependencies(${project} crtx-install) + add_dependencies(userspace ${project}) + # This is to allow cmake to link when libc updates + target_link_options(${project} PRIVATE -nolibc) + # Default compile options + target_compile_options(${project} PRIVATE -g -O2) endforeach() diff --git a/userspace/Shell/CMakeLists.txt b/userspace/Shell/CMakeLists.txt index ac2e606aa7..206d043b97 100644 --- a/userspace/Shell/CMakeLists.txt +++ b/userspace/Shell/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(Shell CXX) - set(SOURCES main.cpp ) add_executable(Shell ${SOURCES}) -target_compile_options(Shell PUBLIC -O2 -g) -target_link_libraries(Shell PUBLIC libc ban) +banan_link_library(Shell ban) +banan_link_library(Shell libc) -add_custom_target(Shell-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/Shell ${BANAN_BIN}/ - DEPENDS Shell -) +install(TARGETS Shell) diff --git a/userspace/Terminal/CMakeLists.txt b/userspace/Terminal/CMakeLists.txt index e8a084935d..9c39342af1 100644 --- a/userspace/Terminal/CMakeLists.txt +++ b/userspace/Terminal/CMakeLists.txt @@ -1,17 +1,13 @@ -cmake_minimum_required(VERSION 3.26) - -project(Terminal CXX) - set(SOURCES main.cpp Terminal.cpp ) add_executable(Terminal ${SOURCES}) -target_compile_options(Terminal PUBLIC -O2 -g) -target_link_libraries(Terminal PUBLIC libc ban libfont libgui libinput) +banan_include_headers(Terminal ban) +banan_link_library(Terminal libc) +banan_link_library(Terminal libfont) +banan_link_library(Terminal libgui) +banan_link_library(Terminal libinput) -add_custom_target(Terminal-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/Terminal ${BANAN_BIN}/ - DEPENDS Terminal -) +install(TARGETS Terminal) diff --git a/userspace/WindowServer/CMakeLists.txt b/userspace/WindowServer/CMakeLists.txt index bb70ad6de0..d7df2bde06 100644 --- a/userspace/WindowServer/CMakeLists.txt +++ b/userspace/WindowServer/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - -project(WindowServer CXX) - set(SOURCES main.cpp Framebuffer.cpp @@ -10,10 +6,11 @@ set(SOURCES ) add_executable(WindowServer ${SOURCES}) -target_compile_options(WindowServer PUBLIC -O2 -g) -target_link_libraries(WindowServer PUBLIC libc ban libfont libgui libimage libinput) +banan_include_headers(WindowServer ban) +banan_include_headers(WindowServer libgui) +banan_link_library(WindowServer libc) +banan_link_library(WindowServer libfont) +banan_link_library(WindowServer libimage) +banan_link_library(WindowServer libinput) -add_custom_target(WindowServer-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/WindowServer ${BANAN_BIN}/ - DEPENDS WindowServer -) +install(TARGETS WindowServer) diff --git a/userspace/aoc2023/CMakeLists.txt b/userspace/aoc2023/CMakeLists.txt index 6aee4858ce..7f6c4b0691 100644 --- a/userspace/aoc2023/CMakeLists.txt +++ b/userspace/aoc2023/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023 CXX) - set(AOC2023_PROJECTS day1 day2 @@ -30,20 +26,21 @@ set(AOC2023_PROJECTS full ) -set(BANAN_AOC2023_BIN ${BANAN_BIN}/aoc2023) +set(BANAN_AOC2023_BIN ${CMAKE_INSTALL_BINDIR}/aoc2023) set(BANAN_AOC2023_INPUT ${BANAN_SHARE}/aoc2023) +set(CMAKE_INSTALL_BINDIR ${BANAN_AOC2023_BIN}) + add_custom_target(aoc2023) -add_custom_target(aoc2023_always - COMMAND ${CMAKE_COMMAND} -E make_directory ${BANAN_AOC2023_BIN} - COMMAND ${CMAKE_COMMAND} -E make_directory ${BANAN_AOC2023_INPUT} - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/input/* ${BANAN_AOC2023_INPUT}/ -) -add_custom_target(aoc2023-install DEPENDS aoc2023 aoc2023_always) + +file(GLOB_RECURSE input_files "input/*") +foreach(file ${input_files}) + install(FILES ${file} DESTINATION ${BANAN_AOC2023_INPUT}) +endforeach() foreach(AOC2023_PROJECT ${AOC2023_PROJECTS}) add_subdirectory(${AOC2023_PROJECT}) + add_dependencies(aoc2023 aoc2023_${AOC2023_PROJECT}) endforeach() add_dependencies(userspace aoc2023) -add_dependencies(userspace-install aoc2023-install) diff --git a/userspace/aoc2023/day-template/CMakeLists.txt b/userspace/aoc2023/day-template/CMakeLists.txt index de3e502eed..fa588c3237 100644 --- a/userspace/aoc2023/day-template/CMakeLists.txt +++ b/userspace/aoc2023/day-template/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day-template CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day-template ${SOURCES}) -target_compile_options(aoc2023_day-template PUBLIC -O2 -g) -target_link_libraries(aoc2023_day-template PUBLIC libc ban) +banan_include_headers(aoc2023_day-template ban) +banan_link_library(aoc2023_day-template libc) -add_dependencies(aoc2023_day-template libc-install ban-install) - -add_custom_target(aoc2023_day-template-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day-template ${BANAN_AOC2023_BIN}/day-template - DEPENDS aoc2023_day-template - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day-template) -add_dependencies(aoc2023-install aoc2023_day-template-install) +install(TARGETS aoc2023_day-template) diff --git a/userspace/aoc2023/day1/CMakeLists.txt b/userspace/aoc2023/day1/CMakeLists.txt index 6b8138c826..d91a19e30d 100644 --- a/userspace/aoc2023/day1/CMakeLists.txt +++ b/userspace/aoc2023/day1/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day1 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day1 ${SOURCES}) -target_compile_options(aoc2023_day1 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day1 PUBLIC libc) +banan_include_headers(aoc2023_day1 ban) +banan_link_library(aoc2023_day1 libc) -add_dependencies(aoc2023_day1 libc-install ban-install) - -add_custom_target(aoc2023_day1-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day1 ${BANAN_AOC2023_BIN}/day1 - DEPENDS aoc2023_day1 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day1) -add_dependencies(aoc2023-install aoc2023_day1-install) +install(TARGETS aoc2023_day1) diff --git a/userspace/aoc2023/day10/CMakeLists.txt b/userspace/aoc2023/day10/CMakeLists.txt index 5b1560954a..f9bfd51b13 100644 --- a/userspace/aoc2023/day10/CMakeLists.txt +++ b/userspace/aoc2023/day10/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day10 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day10 ${SOURCES}) -target_compile_options(aoc2023_day10 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day10 PUBLIC libc ban) +banan_include_headers(aoc2023_day10 ban) +banan_link_library(aoc2023_day10 libc) -add_dependencies(aoc2023_day10 libc-install ban-install) - -add_custom_target(aoc2023_day10-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day10 ${BANAN_AOC2023_BIN}/day10 - DEPENDS aoc2023_day10 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day10) -add_dependencies(aoc2023-install aoc2023_day10-install) +install(TARGETS aoc2023_day10) diff --git a/userspace/aoc2023/day11/CMakeLists.txt b/userspace/aoc2023/day11/CMakeLists.txt index 9bf7e8c6c9..2b0191e398 100644 --- a/userspace/aoc2023/day11/CMakeLists.txt +++ b/userspace/aoc2023/day11/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day11 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day11 ${SOURCES}) -target_compile_options(aoc2023_day11 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day11 PUBLIC libc ban) +banan_include_headers(aoc2023_day11 ban) +banan_link_library(aoc2023_day11 libc) -add_dependencies(aoc2023_day11 libc-install ban-install) - -add_custom_target(aoc2023_day11-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day11 ${BANAN_AOC2023_BIN}/day11 - DEPENDS aoc2023_day11 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day11) -add_dependencies(aoc2023-install aoc2023_day11-install) +install(TARGETS aoc2023_day11) diff --git a/userspace/aoc2023/day12/CMakeLists.txt b/userspace/aoc2023/day12/CMakeLists.txt index 2b3b1705ae..03ae6b997a 100644 --- a/userspace/aoc2023/day12/CMakeLists.txt +++ b/userspace/aoc2023/day12/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day12 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day12 ${SOURCES}) -target_compile_options(aoc2023_day12 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day12 PUBLIC libc ban) +banan_link_library(aoc2023_day12 ban) +banan_link_library(aoc2023_day12 libc) -add_dependencies(aoc2023_day12 libc-install ban-install) - -add_custom_target(aoc2023_day12-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day12 ${BANAN_AOC2023_BIN}/day12 - DEPENDS aoc2023_day12 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day12) -add_dependencies(aoc2023-install aoc2023_day12-install) +install(TARGETS aoc2023_day12) diff --git a/userspace/aoc2023/day13/CMakeLists.txt b/userspace/aoc2023/day13/CMakeLists.txt index 7b39e8485f..4aafcac77e 100644 --- a/userspace/aoc2023/day13/CMakeLists.txt +++ b/userspace/aoc2023/day13/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day13 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day13 ${SOURCES}) -target_compile_options(aoc2023_day13 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day13 PUBLIC libc ban) +banan_include_headers(aoc2023_day13 ban) +banan_link_library(aoc2023_day13 libc) -add_dependencies(aoc2023_day13 libc-install ban-install) - -add_custom_target(aoc2023_day13-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day13 ${BANAN_AOC2023_BIN}/day13 - DEPENDS aoc2023_day13 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day13) -add_dependencies(aoc2023-install aoc2023_day13-install) +install(TARGETS aoc2023_day13) diff --git a/userspace/aoc2023/day14/CMakeLists.txt b/userspace/aoc2023/day14/CMakeLists.txt index 781002a4b8..0d6d273e0f 100644 --- a/userspace/aoc2023/day14/CMakeLists.txt +++ b/userspace/aoc2023/day14/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day14 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day14 ${SOURCES}) -target_compile_options(aoc2023_day14 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day14 PUBLIC libc ban) +banan_include_headers(aoc2023_day14 ban) +banan_link_library(aoc2023_day14 libc) -add_dependencies(aoc2023_day14 libc-install ban-install) - -add_custom_target(aoc2023_day14-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day14 ${BANAN_AOC2023_BIN}/day14 - DEPENDS aoc2023_day14 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day14) -add_dependencies(aoc2023-install aoc2023_day14-install) +install(TARGETS aoc2023_day14) diff --git a/userspace/aoc2023/day15/CMakeLists.txt b/userspace/aoc2023/day15/CMakeLists.txt index bc0b387c5b..4d845a7621 100644 --- a/userspace/aoc2023/day15/CMakeLists.txt +++ b/userspace/aoc2023/day15/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day15 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day15 ${SOURCES}) -target_compile_options(aoc2023_day15 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day15 PUBLIC libc ban) +banan_include_headers(aoc2023_day15 ban) +banan_link_library(aoc2023_day15 libc) -add_dependencies(aoc2023_day15 libc-install ban-install) - -add_custom_target(aoc2023_day15-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day15 ${BANAN_AOC2023_BIN}/day15 - DEPENDS aoc2023_day15 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day15) -add_dependencies(aoc2023-install aoc2023_day15-install) +install(TARGETS aoc2023_day15) diff --git a/userspace/aoc2023/day16/CMakeLists.txt b/userspace/aoc2023/day16/CMakeLists.txt index d19f078ae0..dafa191334 100644 --- a/userspace/aoc2023/day16/CMakeLists.txt +++ b/userspace/aoc2023/day16/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day16 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day16 ${SOURCES}) -target_compile_options(aoc2023_day16 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day16 PUBLIC libc ban) +banan_include_headers(aoc2023_day16 ban) +banan_link_library(aoc2023_day16 libc) -add_dependencies(aoc2023_day16 libc-install ban-install) - -add_custom_target(aoc2023_day16-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day16 ${BANAN_AOC2023_BIN}/day16 - DEPENDS aoc2023_day16 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day16) -add_dependencies(aoc2023-install aoc2023_day16-install) +install(TARGETS aoc2023_day16) diff --git a/userspace/aoc2023/day17/CMakeLists.txt b/userspace/aoc2023/day17/CMakeLists.txt index f43e30471a..e3e8204d56 100644 --- a/userspace/aoc2023/day17/CMakeLists.txt +++ b/userspace/aoc2023/day17/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day17 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day17 ${SOURCES}) -target_compile_options(aoc2023_day17 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day17 PUBLIC libc ban) +banan_include_headers(aoc2023_day17 ban) +banan_link_library(aoc2023_day17 libc) -add_dependencies(aoc2023_day17 libc-install ban-install) - -add_custom_target(aoc2023_day17-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day17 ${BANAN_AOC2023_BIN}/day17 - DEPENDS aoc2023_day17 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day17) -add_dependencies(aoc2023-install aoc2023_day17-install) +install(TARGETS aoc2023_day17) diff --git a/userspace/aoc2023/day18/CMakeLists.txt b/userspace/aoc2023/day18/CMakeLists.txt index c732ea33ef..850c47bf8a 100644 --- a/userspace/aoc2023/day18/CMakeLists.txt +++ b/userspace/aoc2023/day18/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day18 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day18 ${SOURCES}) -target_compile_options(aoc2023_day18 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day18 PUBLIC libc ban) +banan_include_headers(aoc2023_day18 ban) +banan_link_library(aoc2023_day18 libc) -add_dependencies(aoc2023_day18 libc-install ban-install) - -add_custom_target(aoc2023_day18-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day18 ${BANAN_AOC2023_BIN}/day18 - DEPENDS aoc2023_day18 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day18) -add_dependencies(aoc2023-install aoc2023_day18-install) +install(TARGETS aoc2023_day18) diff --git a/userspace/aoc2023/day19/CMakeLists.txt b/userspace/aoc2023/day19/CMakeLists.txt index 17741eadef..6310da7146 100644 --- a/userspace/aoc2023/day19/CMakeLists.txt +++ b/userspace/aoc2023/day19/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day19 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day19 ${SOURCES}) -target_compile_options(aoc2023_day19 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day19 PUBLIC libc ban) +banan_include_headers(aoc2023_day19 ban) +banan_link_library(aoc2023_day19 libc) -add_dependencies(aoc2023_day19 libc-install ban-install) - -add_custom_target(aoc2023_day19-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day19 ${BANAN_AOC2023_BIN}/day19 - DEPENDS aoc2023_day19 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day19) -add_dependencies(aoc2023-install aoc2023_day19-install) +install(TARGETS aoc2023_day19) diff --git a/userspace/aoc2023/day2/CMakeLists.txt b/userspace/aoc2023/day2/CMakeLists.txt index 91a76458d1..2ac2f804b5 100644 --- a/userspace/aoc2023/day2/CMakeLists.txt +++ b/userspace/aoc2023/day2/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day2 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day2 ${SOURCES}) -target_compile_options(aoc2023_day2 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day2 PUBLIC libc) +banan_include_headers(aoc2023_day2 ban) +banan_link_library(aoc2023_day2 libc) -add_dependencies(aoc2023_day2 libc-install ban-install) - -add_custom_target(aoc2023_day2-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day2 ${BANAN_AOC2023_BIN}/day2 - DEPENDS aoc2023_day2 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day2) -add_dependencies(aoc2023-install aoc2023_day2-install) +install(TARGETS aoc2023_day2) diff --git a/userspace/aoc2023/day20/CMakeLists.txt b/userspace/aoc2023/day20/CMakeLists.txt index ee0430fc15..e95d111a47 100644 --- a/userspace/aoc2023/day20/CMakeLists.txt +++ b/userspace/aoc2023/day20/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day20 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day20 ${SOURCES}) -target_compile_options(aoc2023_day20 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day20 PUBLIC libc ban) +banan_link_library(aoc2023_day20 ban) +banan_link_library(aoc2023_day20 libc) -add_dependencies(aoc2023_day20 libc-install ban-install) - -add_custom_target(aoc2023_day20-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day20 ${BANAN_AOC2023_BIN}/day20 - DEPENDS aoc2023_day20 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day20) -add_dependencies(aoc2023-install aoc2023_day20-install) +install(TARGETS aoc2023_day20) diff --git a/userspace/aoc2023/day20/main.cpp b/userspace/aoc2023/day20/main.cpp index 8638830411..394b493424 100644 --- a/userspace/aoc2023/day20/main.cpp +++ b/userspace/aoc2023/day20/main.cpp @@ -30,6 +30,8 @@ struct Module BAN::String name; BAN::Vector targets; + virtual ~Module() {} + virtual void handle_signal(const Signal& signal, BAN::Queue& signal_queue) = 0; }; diff --git a/userspace/aoc2023/day21/CMakeLists.txt b/userspace/aoc2023/day21/CMakeLists.txt index aaa6ec5ed3..d519a99918 100644 --- a/userspace/aoc2023/day21/CMakeLists.txt +++ b/userspace/aoc2023/day21/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day21 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day21 ${SOURCES}) -target_compile_options(aoc2023_day21 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day21 PUBLIC libc ban) +banan_include_headers(aoc2023_day21 ban) +banan_link_library(aoc2023_day21 libc) -add_dependencies(aoc2023_day21 libc-install ban-install) - -add_custom_target(aoc2023_day21-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day21 ${BANAN_AOC2023_BIN}/day21 - DEPENDS aoc2023_day21 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day21) -add_dependencies(aoc2023-install aoc2023_day21-install) +install(TARGETS aoc2023_day21) diff --git a/userspace/aoc2023/day22/CMakeLists.txt b/userspace/aoc2023/day22/CMakeLists.txt new file mode 100644 index 0000000000..fb7efd8764 --- /dev/null +++ b/userspace/aoc2023/day22/CMakeLists.txt @@ -0,0 +1,9 @@ +set(SOURCES + main.cpp +) + +add_executable(aoc2023_day22 ${SOURCES}) +banan_include_headers(aoc2023_day22 ban) +banan_link_library(aoc2023_day22 libc) + +install(TARGETS aoc2023_day22) diff --git a/userspace/aoc2023/day22/main.cpp b/userspace/aoc2023/day22/main.cpp new file mode 100644 index 0000000000..5d75a5f8e4 --- /dev/null +++ b/userspace/aoc2023/day22/main.cpp @@ -0,0 +1,191 @@ +#include +#include +#include + +#include +#include +#include + +using i8 = int8_t; +using i16 = int16_t; +using i32 = int32_t; +using i64 = int64_t; + +using u8 = uint8_t; +using u16 = uint16_t; +using u32 = uint32_t; +using u64 = uint64_t; + +struct Position +{ + i64 x, y, z; + + bool operator==(const Position& other) const + { + return x == other.x && y == other.y && z == other.z; + } +}; + +static constexpr bool rectangle_contains(const Position& c1, const Position& c2, const Position& p) +{ + ASSERT(c1.x <= c2.x); + ASSERT(c1.y <= c2.y); + return (c1.x <= p.x && p.x <= c2.x) && (c1.y <= p.y && p.y <= c2.y); +} + +struct Brick +{ + Position corners[2]; + BAN::HashSet supporting; + BAN::HashSet supported_by; + + bool supports(const Brick& other) const + { + if (corners[1].z + 1 != other.corners[0].z) + return false; + + for (i32 i = 0; i < 4; i++) + if (rectangle_contains(corners[0], corners[1], { other.corners[i / 2].x, other.corners[i % 2].y, 0 })) + return true; + + for (i32 i = 0; i < 4; i++) + if (rectangle_contains(other.corners[0], other.corners[1], { corners[i / 2].x, corners[i % 2].y, 0 })) + return true; + + return false; + } +}; + +i64 parse_i64(BAN::StringView str) +{ + i64 result = 0; + for (char c : str) + { + ASSERT(isdigit(c)); + result = (result * 10) + (c - '0'); + } + return result; +} + +BAN::Vector parse_bricks(FILE* fp) +{ + BAN::Vector bricks; + + char buffer[64]; + while (fgets(buffer, sizeof(buffer), fp)) + { + BAN::StringView line(buffer); + ASSERT(line.back() == '\n'); + line = line.substring(0, line.size() - 1); + if (line.empty()) + break; + + auto corner_strs = MUST(line.split('~')); + ASSERT(corner_strs.size() == 2); + + Brick brick; + for (i32 i = 0; i < 2; i++) + { + auto coords = MUST(corner_strs[i].split(',')); + ASSERT(coords.size() == 3); + brick.corners[i].x = parse_i64(coords[0]); + brick.corners[i].y = parse_i64(coords[1]); + brick.corners[i].z = parse_i64(coords[2]); + } + ASSERT(brick.corners[0].x <= brick.corners[1].x); + ASSERT(brick.corners[0].y <= brick.corners[1].y); + ASSERT(brick.corners[0].z <= brick.corners[1].z); + MUST(bricks.push_back(brick)); + } + + return bricks; +} + +i64 puzzle1(FILE* fp) +{ + auto brick_comp = [](const Brick& b1, const Brick& b2) { return b1.corners[0].z < b2.corners[0].z; }; + + auto bricks = parse_bricks(fp); + BAN::sort::sort(bricks.begin(), bricks.end(), brick_comp); + + // Simulate brick falling + for (size_t i = 0; i < bricks.size();) + { + bool can_fall = bricks[i].corners[0].z > 1; + for (size_t j = 0; j < i && can_fall; j++) + if (bricks[j].supports(bricks[i])) + can_fall = false; + + if (!can_fall) + i++; + else + { + bricks[i].corners[0].z--; + bricks[i].corners[1].z--; + for (; i > 0; i--) + { + if (brick_comp(bricks[i - 1], bricks[i])) + break; + BAN::swap(bricks[i - 1], bricks[i]); + } + } + } + + // Store brick supporting structures + for (size_t i = 0; i < bricks.size(); i++) + { + for (size_t j = 0; j < bricks.size(); j++) + { + if (i == j) + continue; + if (bricks[i].supports(bricks[j])) + { + MUST(bricks[i].supporting.insert(&bricks[j])); + MUST(bricks[j].supported_by.insert(&bricks[i])); + } + } + } + + i64 result = 0; + for (const auto& brick : bricks) + { + bool disintegratable = true; + for (const auto* support : brick.supporting) + if (support->supported_by.size() <= 1) + disintegratable = false; + result += disintegratable; + } + + // OFF BY 7 + + return result; +} + +i64 puzzle2(FILE* fp) +{ + (void)fp; + return -1; +} + +int main(int argc, char** argv) +{ + const char* file_path = "/usr/share/aoc2023/day22_input.txt"; + + if (argc >= 2) + file_path = argv[1]; + + FILE* fp = fopen(file_path, "r"); + if (fp == nullptr) + { + perror("fopen"); + return 1; + } + + printf("puzzle1: %" PRId64 "\n", puzzle1(fp)); + + fseek(fp, 0, SEEK_SET); + + printf("puzzle2: %" PRId64 "\n", puzzle2(fp)); + + fclose(fp); +} diff --git a/userspace/aoc2023/day23/CMakeLists.txt b/userspace/aoc2023/day23/CMakeLists.txt index d27f82bf2a..83675ac214 100644 --- a/userspace/aoc2023/day23/CMakeLists.txt +++ b/userspace/aoc2023/day23/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day23 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day23 ${SOURCES}) -target_compile_options(aoc2023_day23 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day23 PUBLIC libc ban) +banan_include_headers(aoc2023_day23 ban) +banan_link_library(aoc2023_day23 libc) -add_dependencies(aoc2023_day23 libc-install ban-install) - -add_custom_target(aoc2023_day23-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day23 ${BANAN_AOC2023_BIN}/day23 - DEPENDS aoc2023_day23 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day23) -add_dependencies(aoc2023-install aoc2023_day23-install) +install(TARGETS aoc2023_day23) diff --git a/userspace/aoc2023/day24/CMakeLists.txt b/userspace/aoc2023/day24/CMakeLists.txt index 90e2b855c3..166383847e 100644 --- a/userspace/aoc2023/day24/CMakeLists.txt +++ b/userspace/aoc2023/day24/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day24 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day24 ${SOURCES}) -target_compile_options(aoc2023_day24 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day24 PUBLIC libc ban) +banan_include_headers(aoc2023_day24 ban) +banan_link_library(aoc2023_day24 libc) -add_dependencies(aoc2023_day24 libc-install ban-install) - -add_custom_target(aoc2023_day24-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day24 ${BANAN_AOC2023_BIN}/day24 - DEPENDS aoc2023_day24 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day24) -add_dependencies(aoc2023-install aoc2023_day24-install) +install(TARGETS aoc2023_day24) diff --git a/userspace/aoc2023/day25/CMakeLists.txt b/userspace/aoc2023/day25/CMakeLists.txt index dea869bcf0..f40143d051 100644 --- a/userspace/aoc2023/day25/CMakeLists.txt +++ b/userspace/aoc2023/day25/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day25 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day25 ${SOURCES}) -target_compile_options(aoc2023_day25 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day25 PUBLIC libc ban) +banan_link_library(aoc2023_day25 ban) +banan_link_library(aoc2023_day25 libc) -add_dependencies(aoc2023_day25 libc-install ban-install) - -add_custom_target(aoc2023_day25-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day25 ${BANAN_AOC2023_BIN}/day25 - DEPENDS aoc2023_day25 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day25) -add_dependencies(aoc2023-install aoc2023_day25-install) +install(TARGETS aoc2023_day25) diff --git a/userspace/aoc2023/day25/main.cpp b/userspace/aoc2023/day25/main.cpp index e4f313e112..a5a6f2c199 100644 --- a/userspace/aoc2023/day25/main.cpp +++ b/userspace/aoc2023/day25/main.cpp @@ -21,6 +21,9 @@ using u64 = uint64_t; struct Component { + Component(BAN::String name) + : name(BAN::move(name)) + {} BAN::String name; BAN::Vector connections; }; diff --git a/userspace/aoc2023/day3/CMakeLists.txt b/userspace/aoc2023/day3/CMakeLists.txt index 9ca68813f0..1b0d615a4d 100644 --- a/userspace/aoc2023/day3/CMakeLists.txt +++ b/userspace/aoc2023/day3/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day3 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day3 ${SOURCES}) -target_compile_options(aoc2023_day3 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day3 PUBLIC libc ban) +banan_include_headers(aoc2023_day3 ban) +banan_link_library(aoc2023_day3 libc) -add_dependencies(aoc2023_day3 libc-install ban-install) - -add_custom_target(aoc2023_day3-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day3 ${BANAN_AOC2023_BIN}/day3 - DEPENDS aoc2023_day3 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day3) -add_dependencies(aoc2023-install aoc2023_day3-install) +install(TARGETS aoc2023_day3) diff --git a/userspace/aoc2023/day4/CMakeLists.txt b/userspace/aoc2023/day4/CMakeLists.txt index f934e8a131..d2802650e9 100644 --- a/userspace/aoc2023/day4/CMakeLists.txt +++ b/userspace/aoc2023/day4/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day4 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day4 ${SOURCES}) -target_compile_options(aoc2023_day4 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day4 PUBLIC libc ban) +banan_link_library(aoc2023_day4 ban) +banan_link_library(aoc2023_day4 libc) -add_dependencies(aoc2023_day4 libc-install ban-install) - -add_custom_target(aoc2023_day4-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day4 ${BANAN_AOC2023_BIN}/day4 - DEPENDS aoc2023_day4 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day4) -add_dependencies(aoc2023-install aoc2023_day4-install) +install(TARGETS aoc2023_day4) diff --git a/userspace/aoc2023/day5/CMakeLists.txt b/userspace/aoc2023/day5/CMakeLists.txt index e9897bf7c3..fb2da9aec9 100644 --- a/userspace/aoc2023/day5/CMakeLists.txt +++ b/userspace/aoc2023/day5/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day5 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day5 ${SOURCES}) -target_compile_options(aoc2023_day5 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day5 PUBLIC libc ban) +banan_include_headers(aoc2023_day5 ban) +banan_link_library(aoc2023_day5 libc) -add_dependencies(aoc2023_day5 libc-install ban-install) - -add_custom_target(aoc2023_day5-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day5 ${BANAN_AOC2023_BIN}/day5 - DEPENDS aoc2023_day5 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day5) -add_dependencies(aoc2023-install aoc2023_day5-install) +install(TARGETS aoc2023_day5) diff --git a/userspace/aoc2023/day6/CMakeLists.txt b/userspace/aoc2023/day6/CMakeLists.txt index c1e5eb5e4c..b584e78eae 100644 --- a/userspace/aoc2023/day6/CMakeLists.txt +++ b/userspace/aoc2023/day6/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day6 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day6 ${SOURCES}) -target_compile_options(aoc2023_day6 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day6 PUBLIC libc ban) +banan_include_headers(aoc2023_day6 ban) +banan_link_library(aoc2023_day6 libc) -add_dependencies(aoc2023_day6 libc-install ban-install) - -add_custom_target(aoc2023_day6-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day6 ${BANAN_AOC2023_BIN}/day6 - DEPENDS aoc2023_day6 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day6) -add_dependencies(aoc2023-install aoc2023_day6-install) +install(TARGETS aoc2023_day6) diff --git a/userspace/aoc2023/day7/CMakeLists.txt b/userspace/aoc2023/day7/CMakeLists.txt index 74e2b82558..f88ce3e8c3 100644 --- a/userspace/aoc2023/day7/CMakeLists.txt +++ b/userspace/aoc2023/day7/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day7 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day7 ${SOURCES}) -target_compile_options(aoc2023_day7 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day7 PUBLIC libc ban) +banan_include_headers(aoc2023_day7 ban) +banan_link_library(aoc2023_day7 libc) -add_dependencies(aoc2023_day7 libc-install ban-install) - -add_custom_target(aoc2023_day7-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day7 ${BANAN_AOC2023_BIN}/day7 - DEPENDS aoc2023_day7 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day7) -add_dependencies(aoc2023-install aoc2023_day7-install) +install(TARGETS aoc2023_day7) diff --git a/userspace/aoc2023/day8/CMakeLists.txt b/userspace/aoc2023/day8/CMakeLists.txt index 581feb9e79..a738ad8c3b 100644 --- a/userspace/aoc2023/day8/CMakeLists.txt +++ b/userspace/aoc2023/day8/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day8 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day8 ${SOURCES}) -target_compile_options(aoc2023_day8 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day8 PUBLIC libc ban) +banan_include_headers(aoc2023_day8 ban) +banan_link_library(aoc2023_day8 libc) -add_dependencies(aoc2023_day8 libc-install ban-install) - -add_custom_target(aoc2023_day8-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day8 ${BANAN_AOC2023_BIN}/day8 - DEPENDS aoc2023_day8 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day8) -add_dependencies(aoc2023-install aoc2023_day8-install) +install(TARGETS aoc2023_day8) diff --git a/userspace/aoc2023/day9/CMakeLists.txt b/userspace/aoc2023/day9/CMakeLists.txt index 4f630f8cc2..02836e411e 100644 --- a/userspace/aoc2023/day9/CMakeLists.txt +++ b/userspace/aoc2023/day9/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023_day9 CXX) - set(SOURCES main.cpp ) add_executable(aoc2023_day9 ${SOURCES}) -target_compile_options(aoc2023_day9 PUBLIC -O2 -g) -target_link_libraries(aoc2023_day9 PUBLIC libc ban) +banan_include_headers(aoc2023_day9 ban) +banan_link_library(aoc2023_day9 libc) -add_dependencies(aoc2023_day9 libc-install ban-install) - -add_custom_target(aoc2023_day9-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day9 ${BANAN_AOC2023_BIN}/day9 - DEPENDS aoc2023_day9 - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023_day9) -add_dependencies(aoc2023-install aoc2023_day9-install) +install(TARGETS aoc2023_day9) diff --git a/userspace/aoc2023/full/CMakeLists.txt b/userspace/aoc2023/full/CMakeLists.txt index b202e73977..0cc52df6c0 100644 --- a/userspace/aoc2023/full/CMakeLists.txt +++ b/userspace/aoc2023/full/CMakeLists.txt @@ -1,20 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(aoc2023-full CXX) - set(SOURCES main.cpp ) -add_executable(aoc2023-full ${SOURCES}) -target_compile_options(aoc2023-full PUBLIC -O2 -g) -target_link_libraries(aoc2023-full PUBLIC libc) +add_executable(aoc2023_full ${SOURCES}) +banan_include_headers(aoc2023_full ban) +banan_link_library(aoc2023_full libc) -add_custom_target(aoc2023-full-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023-full ${BANAN_AOC2023_BIN}/full - DEPENDS aoc2023-full - DEPENDS aoc2023_always -) - -add_dependencies(aoc2023 aoc2023-full) -add_dependencies(aoc2023-install aoc2023-full-install) +install(TARGETS aoc2023_full) diff --git a/userspace/cat-mmap/CMakeLists.txt b/userspace/cat-mmap/CMakeLists.txt index b5d06b7c06..8f0298af40 100644 --- a/userspace/cat-mmap/CMakeLists.txt +++ b/userspace/cat-mmap/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(cat-mmap CXX) - set(SOURCES main.cpp ) add_executable(cat-mmap ${SOURCES}) -target_compile_options(cat-mmap PUBLIC -O2 -g) -target_link_libraries(cat-mmap PUBLIC libc) +banan_link_library(cat-mmap libc) -add_custom_target(cat-mmap-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cat-mmap ${BANAN_BIN}/ - DEPENDS cat-mmap -) +install(TARGETS cat-mmap) diff --git a/userspace/cat/CMakeLists.txt b/userspace/cat/CMakeLists.txt index 999d539c5f..a0e8ee9791 100644 --- a/userspace/cat/CMakeLists.txt +++ b/userspace/cat/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(cat CXX) - set(SOURCES main.cpp ) add_executable(cat ${SOURCES}) -target_compile_options(cat PUBLIC -O2 -g) -target_link_libraries(cat PUBLIC libc) +banan_link_library(cat libc) -add_custom_target(cat-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cat ${BANAN_BIN}/ - DEPENDS cat -) +install(TARGETS cat) diff --git a/userspace/chmod/CMakeLists.txt b/userspace/chmod/CMakeLists.txt index 076db1d121..53b91dc858 100644 --- a/userspace/chmod/CMakeLists.txt +++ b/userspace/chmod/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(chmod CXX) - set(SOURCES main.cpp ) add_executable(chmod ${SOURCES}) -target_compile_options(chmod PUBLIC -O2 -g) -target_link_libraries(chmod PUBLIC libc) +banan_link_library(chmod libc) -add_custom_target(chmod-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/chmod ${BANAN_BIN}/ - DEPENDS chmod -) +install(TARGETS chmod) diff --git a/userspace/cp/CMakeLists.txt b/userspace/cp/CMakeLists.txt index cd68633c9d..a4b4e03afe 100644 --- a/userspace/cp/CMakeLists.txt +++ b/userspace/cp/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(cp CXX) - set(SOURCES main.cpp ) add_executable(cp ${SOURCES}) -target_compile_options(cp PUBLIC -O2 -g) -target_link_libraries(cp PUBLIC libc ban) +banan_include_headers(cp ban) +banan_link_library(cp libc) -add_custom_target(cp-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cp ${BANAN_BIN}/ - DEPENDS cp -) +install(TARGETS cp) diff --git a/userspace/create_program.sh b/userspace/create_program.sh index 0f770cfb31..1b1881bcd6 100755 --- a/userspace/create_program.sh +++ b/userspace/create_program.sh @@ -7,27 +7,22 @@ PROGRAM_NAME=$1 mkdir $PROGRAM_NAME cat > $PROGRAM_NAME/CMakeLists.txt << EOF -cmake_minimum_required(VERSION 3.26) - -project($PROGRAM_NAME CXX) - set(SOURCES main.cpp ) add_executable($PROGRAM_NAME \${SOURCES}) -target_compile_options($PROGRAM_NAME PUBLIC -O2 -g) -target_link_libraries($PROGRAM_NAME PUBLIC libc) +banan_link_library($PROGRAM_NAME ban) +banan_link_library($PROGRAM_NAME libc) -add_custom_target($PROGRAM_NAME-install - COMMAND \${CMAKE_COMMAND} -E copy \${CMAKE_CURRENT_BINARY_DIR}/$PROGRAM_NAME \${BANAN_BIN}/ - DEPENDS $PROGRAM_NAME -) +install(TARGETS $PROGRAM_NAME) EOF cat > $PROGRAM_NAME/main.cpp << EOF +#include + int main() { - + printf("Hello World\n"); } EOF diff --git a/userspace/dd/CMakeLists.txt b/userspace/dd/CMakeLists.txt index b86d31ff79..7c3da0c544 100644 --- a/userspace/dd/CMakeLists.txt +++ b/userspace/dd/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(dd CXX) - set(SOURCES main.cpp ) add_executable(dd ${SOURCES}) -target_compile_options(dd PUBLIC -O2 -g) -target_link_libraries(dd PUBLIC libc) +banan_link_library(dd libc) -add_custom_target(dd-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/dd ${BANAN_BIN}/ - DEPENDS dd -) +install(TARGETS dd) diff --git a/userspace/dhcp-client/CMakeLists.txt b/userspace/dhcp-client/CMakeLists.txt index 1344687347..b02731a049 100644 --- a/userspace/dhcp-client/CMakeLists.txt +++ b/userspace/dhcp-client/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(dhcp-client CXX) - set(SOURCES main.cpp ) add_executable(dhcp-client ${SOURCES}) -target_compile_options(dhcp-client PUBLIC -O2 -g) -target_link_libraries(dhcp-client PUBLIC libc) +banan_include_headers(dhcp-client ban) +banan_link_library(dhcp-client libc) -add_custom_target(dhcp-client-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/dhcp-client ${BANAN_BIN}/ - DEPENDS dhcp-client -) +install(TARGETS dhcp-client) diff --git a/userspace/echo/CMakeLists.txt b/userspace/echo/CMakeLists.txt index bb2f607d68..638a3caad6 100644 --- a/userspace/echo/CMakeLists.txt +++ b/userspace/echo/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(echo CXX) - set(SOURCES main.cpp ) add_executable(echo ${SOURCES}) -target_compile_options(echo PUBLIC -O2 -g) -target_link_libraries(echo PUBLIC libc) +banan_link_library(echo libc) -add_custom_target(echo-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/echo ${BANAN_BIN}/ - DEPENDS echo -) +install(TARGETS echo) diff --git a/userspace/getopt/CMakeLists.txt b/userspace/getopt/CMakeLists.txt index 83509b7748..08ad357e09 100644 --- a/userspace/getopt/CMakeLists.txt +++ b/userspace/getopt/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(getopt CXX) - set(SOURCES main.cpp ) add_executable(getopt ${SOURCES}) -target_compile_options(getopt PUBLIC -O2 -g) -target_link_libraries(getopt PUBLIC libc ban) +banan_include_headers(getopt ban) +banan_link_library(getopt libc) -add_custom_target(getopt-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/getopt ${BANAN_BIN}/ - DEPENDS getopt -) +install(TARGETS getopt) diff --git a/userspace/id/CMakeLists.txt b/userspace/id/CMakeLists.txt index 3d4e37b857..d301ca59b2 100644 --- a/userspace/id/CMakeLists.txt +++ b/userspace/id/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(id CXX) - set(SOURCES main.cpp ) add_executable(id ${SOURCES}) -target_compile_options(id PUBLIC -O2 -g) -target_link_libraries(id PUBLIC libc ban) +banan_include_headers(id ban) +banan_link_library(id libc) -add_custom_target(id-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/id ${BANAN_BIN}/ - DEPENDS id -) +install(TARGETS id) diff --git a/userspace/image/CMakeLists.txt b/userspace/image/CMakeLists.txt index 4118864215..84eafe0f2d 100644 --- a/userspace/image/CMakeLists.txt +++ b/userspace/image/CMakeLists.txt @@ -1,16 +1,10 @@ -cmake_minimum_required(VERSION 3.26) - -project(image CXX) - set(SOURCES main.cpp ) add_executable(image ${SOURCES}) -target_compile_options(image PUBLIC -O2 -g) -target_link_libraries(image PUBLIC libc ban libimage) +banan_include_headers(image ban) +banan_link_library(image libc) +banan_link_library(image libimage) -add_custom_target(image-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/image ${BANAN_BIN}/ - DEPENDS image -) +install(TARGETS image) diff --git a/userspace/init/CMakeLists.txt b/userspace/init/CMakeLists.txt index 71227f56b0..09f0f913df 100644 --- a/userspace/init/CMakeLists.txt +++ b/userspace/init/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(init CXX) - set(SOURCES main.cpp ) add_executable(init ${SOURCES}) -target_compile_options(init PUBLIC -O2 -g) -target_link_libraries(init PUBLIC libc ban) +banan_include_headers(init ban) +banan_link_library(init libc) -add_custom_target(init-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/init ${BANAN_BIN}/ - DEPENDS init -) +install(TARGETS init) diff --git a/userspace/libraries/CMakeLists.txt b/userspace/libraries/CMakeLists.txt index a53cabb2ce..fa2169f68c 100644 --- a/userspace/libraries/CMakeLists.txt +++ b/userspace/libraries/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - -project(libraries CXX) - set(USERSPACE_LIBRARIES LibC LibELF @@ -11,23 +7,17 @@ set(USERSPACE_LIBRARIES LibInput ) -foreach(LIBRARY ${USERSPACE_LIBRARIES}) - add_subdirectory(${LIBRARY}) +foreach(library ${USERSPACE_LIBRARIES}) + add_subdirectory(${library}) endforeach() add_custom_target(libraries) -add_custom_target(libraries-headers) -add_custom_target(libraries-install) -foreach(LIBRARY ${USERSPACE_LIBRARIES}) - string(TOLOWER ${LIBRARY} LIBRARY_LOWER) - - if (TARGET ${LIBRARY_LOWER}) - add_dependencies(libraries ${LIBRARY_LOWER}) +foreach(library ${USERSPACE_LIBRARIES}) + string(TOLOWER ${library} library_lower) + if (TARGET ${library_lower}) + add_dependencies(libraries ${library_lower}) # This is to allow cmake to link when libc updates - target_link_options(${LIBRARY_LOWER} PRIVATE -nolibc) + target_link_options(${library_lower} PRIVATE -nolibc) endif() - - add_dependencies(libraries-headers ${LIBRARY_LOWER}-headers) - add_dependencies(libraries-install ${LIBRARY_LOWER}-install) endforeach() diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index 4a8275b972..99edf15993 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -1,7 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - -project(libc CXX ASM) - set(LIBC_SOURCES arpa/inet.cpp assert.cpp @@ -35,34 +31,24 @@ set(LIBC_SOURCES ../../../BAN/BAN/Assert.cpp ) -add_custom_target(libc-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot -) - -add_custom_target(crtx - COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crt0.S -o crt0.o - COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crti.S -o crti.o - COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crtn.S -o crtn.o -) - -add_custom_target(crtx-install - COMMAND ${CMAKE_COMMAND} -E copy crt0.o ${BANAN_LIB}/ - COMMAND ${CMAKE_COMMAND} -E copy crti.o ${BANAN_LIB}/ - COMMAND ${CMAKE_COMMAND} -E copy crtn.o ${BANAN_LIB}/ - DEPENDS crtx -) - add_library(libc ${LIBC_SOURCES}) -add_dependencies(libc headers crtx-install) - target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns) target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=) -add_custom_target(libc-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libc.a ${BANAN_LIB}/ - DEPENDS libc - BYPRODUCTS ${BANAN_LIB}/libc.a +add_library(crt0 OBJECT arch/${BANAN_ARCH}/crt0.S) +add_library(crti OBJECT arch/${BANAN_ARCH}/crti.S) +add_library(crtn OBJECT arch/${BANAN_ARCH}/crtn.S) +add_custom_target(crtx-install + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crt0.o + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crti.o + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crtn.o + DEPENDS crt0 crti crtn sysroot ) +banan_include_headers(libc ban) +banan_include_headers(libc kernel) + +banan_install_headers(libc) +install(TARGETS libc) + set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibELF/CMakeLists.txt b/userspace/libraries/LibELF/CMakeLists.txt index b9ce4fd135..ffe8b45b7b 100644 --- a/userspace/libraries/LibELF/CMakeLists.txt +++ b/userspace/libraries/LibELF/CMakeLists.txt @@ -1,12 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(LibELF CXX) - -add_custom_target(libelf-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot +set(SOURCES + dummy.cpp ) -add_custom_target(libelf-install - DEPENDS libelf-headers -) +add_library(libelf ${SOURCES}) + +banan_install_headers(libelf) +install(TARGETS libelf) diff --git a/userspace/libraries/LibELF/dummy.cpp b/userspace/libraries/LibELF/dummy.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/userspace/libraries/LibFont/CMakeLists.txt b/userspace/libraries/LibFont/CMakeLists.txt index cb1b8fa5f4..d433b36af6 100644 --- a/userspace/libraries/LibFont/CMakeLists.txt +++ b/userspace/libraries/LibFont/CMakeLists.txt @@ -1,25 +1,13 @@ -cmake_minimum_required(VERSION 3.26) - -project(libfont CXX) - set(LIBGUI_SOURCES Font.cpp PSF.cpp ) -add_custom_target(libfont-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot -) - add_library(libfont ${LIBGUI_SOURCES}) -add_dependencies(libfont headers libc-install) -target_link_libraries(libfont PUBLIC libc) +banan_link_library(libfont libc) +banan_link_library(libfont ban) -add_custom_target(libfont-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libfont.a ${BANAN_LIB}/ - DEPENDS libfont - BYPRODUCTS ${BANAN_LIB}/libfont.a -) +banan_install_headers(libfont) +install(TARGETS libfont) set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibGUI/CMakeLists.txt b/userspace/libraries/LibGUI/CMakeLists.txt index 5cd0f6494e..9a96c0f961 100644 --- a/userspace/libraries/LibGUI/CMakeLists.txt +++ b/userspace/libraries/LibGUI/CMakeLists.txt @@ -1,24 +1,14 @@ -cmake_minimum_required(VERSION 3.26) - -project(libgui CXX) - set(LIBGUI_SOURCES Window.cpp ) -add_custom_target(libgui-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot -) - add_library(libgui ${LIBGUI_SOURCES}) -add_dependencies(libgui headers libc-install) -target_link_libraries(libgui PUBLIC libc libfont) +banan_include_headers(libgui ban) +banan_include_headers(libgui libfont) +banan_include_headers(libgui libinput) +banan_link_library(libgui libc) -add_custom_target(libgui-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libgui.a ${BANAN_LIB}/ - DEPENDS libgui - BYPRODUCTS ${BANAN_LIB}/libgui.a -) +banan_install_headers(libgui) +install(TARGETS libgui) set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibImage/CMakeLists.txt b/userspace/libraries/LibImage/CMakeLists.txt index 2798423ae8..418581c18f 100644 --- a/userspace/libraries/LibImage/CMakeLists.txt +++ b/userspace/libraries/LibImage/CMakeLists.txt @@ -1,27 +1,15 @@ -cmake_minimum_required(VERSION 3.26) - -project(libimage CXX) - set(LIBIMAGE_SOURCES Image.cpp Netbpm.cpp PNG.cpp ) -add_custom_target(libimage-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot -) - add_library(libimage ${LIBIMAGE_SOURCES}) -add_dependencies(libimage headers libc-install) -target_link_libraries(libimage PUBLIC libc) target_compile_options(libimage PRIVATE -O3) +banan_link_library(libimage libc) +banan_link_library(libimage ban) -add_custom_target(libimage-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libimage.a ${BANAN_LIB}/ - DEPENDS libimage - BYPRODUCTS ${BANAN_LIB}/libimage.a -) +banan_install_headers(libimage) +install(TARGETS libimage) set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/libraries/LibInput/CMakeLists.txt b/userspace/libraries/LibInput/CMakeLists.txt index e357bcfd81..dd075eb07e 100644 --- a/userspace/libraries/LibInput/CMakeLists.txt +++ b/userspace/libraries/LibInput/CMakeLists.txt @@ -1,24 +1,13 @@ -cmake_minimum_required(VERSION 3.26) - -project(libinput CXX) - set(LIBINPUT_SOURCES KeyEvent.cpp KeyboardLayout.cpp ) -add_custom_target(libinput-headers - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/ - DEPENDS sysroot -) - add_library(libinput ${LIBINPUT_SOURCES}) -target_link_libraries(libinput PUBLIC libc ban) +banan_include_headers(libinput ban) +banan_link_library(libinput libc) -add_custom_target(libinput-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libinput.a ${BANAN_LIB}/ - DEPENDS libinput - BYPRODUCTS ${BANAN_LIB}/libinput.a -) +banan_install_headers(libinput) +install(TARGETS libinput) set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/loadkeys/CMakeLists.txt b/userspace/loadkeys/CMakeLists.txt index dc34136694..dd6d7a3472 100644 --- a/userspace/loadkeys/CMakeLists.txt +++ b/userspace/loadkeys/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(loadkeys CXX) - set(SOURCES main.cpp ) add_executable(loadkeys ${SOURCES}) -target_compile_options(loadkeys PUBLIC -O2 -g) -target_link_libraries(loadkeys PUBLIC libc) +banan_link_library(loadkeys libc) -add_custom_target(loadkeys-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/loadkeys ${BANAN_BIN}/ - DEPENDS loadkeys -) +install(TARGETS loadkeys) diff --git a/userspace/ls/CMakeLists.txt b/userspace/ls/CMakeLists.txt index 0bb3e55757..d1fa310aa6 100644 --- a/userspace/ls/CMakeLists.txt +++ b/userspace/ls/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(ls CXX) - set(SOURCES main.cpp ) add_executable(ls ${SOURCES}) -target_compile_options(ls PUBLIC -O2 -g) -target_link_libraries(ls PUBLIC libc ban) +banan_link_library(ls ban) +banan_link_library(ls libc) -add_custom_target(ls-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/ls ${BANAN_BIN}/ - DEPENDS ls -) +install(TARGETS ls) diff --git a/userspace/meminfo/CMakeLists.txt b/userspace/meminfo/CMakeLists.txt index 1fa350b9f3..fd5339cf9b 100644 --- a/userspace/meminfo/CMakeLists.txt +++ b/userspace/meminfo/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(meminfo CXX) - set(SOURCES main.cpp ) add_executable(meminfo ${SOURCES}) -target_compile_options(meminfo PUBLIC -O2 -g) -target_link_libraries(meminfo PUBLIC libc) +banan_link_library(meminfo libc) -add_custom_target(meminfo-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/meminfo ${BANAN_BIN}/ - DEPENDS meminfo -) +install(TARGETS meminfo) diff --git a/userspace/mkdir/CMakeLists.txt b/userspace/mkdir/CMakeLists.txt index 8111b6492d..38fbda31e3 100644 --- a/userspace/mkdir/CMakeLists.txt +++ b/userspace/mkdir/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(mkdir CXX) - set(SOURCES main.cpp ) add_executable(mkdir ${SOURCES}) -target_compile_options(mkdir PUBLIC -O2 -g) -target_link_libraries(mkdir PUBLIC libc) +banan_link_library(mkdir libc) -add_custom_target(mkdir-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/mkdir ${BANAN_BIN}/ - DEPENDS mkdir -) +install(TARGETS mkdir) diff --git a/userspace/mmap-shared-test/CMakeLists.txt b/userspace/mmap-shared-test/CMakeLists.txt deleted file mode 100644 index 59981ab681..0000000000 --- a/userspace/mmap-shared-test/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.26) - -project(mmap-shared-test CXX) - -set(SOURCES - main.cpp -) - -add_executable(mmap-shared-test ${SOURCES}) -target_compile_options(mmap-shared-test PUBLIC -O2 -g) -target_link_libraries(mmap-shared-test PUBLIC libc) - -add_custom_target(mmap-shared-test-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/mmap-shared-test ${BANAN_BIN}/ - DEPENDS mmap-shared-test -) diff --git a/userspace/nslookup/CMakeLists.txt b/userspace/nslookup/CMakeLists.txt index 1b706be837..c251bb2f78 100644 --- a/userspace/nslookup/CMakeLists.txt +++ b/userspace/nslookup/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(nslookup CXX) - set(SOURCES main.cpp ) add_executable(nslookup ${SOURCES}) -target_compile_options(nslookup PUBLIC -O2 -g) -target_link_libraries(nslookup PUBLIC libc) +banan_link_library(nslookup libc) -add_custom_target(nslookup-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/nslookup ${BANAN_BIN}/ - DEPENDS nslookup -) +install(TARGETS nslookup) diff --git a/userspace/poweroff/CMakeLists.txt b/userspace/poweroff/CMakeLists.txt index d2ada9229c..81c3f74c0c 100644 --- a/userspace/poweroff/CMakeLists.txt +++ b/userspace/poweroff/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(poweroff CXX) - set(SOURCES main.cpp ) add_executable(poweroff ${SOURCES}) -target_compile_options(poweroff PUBLIC -O2 -g) -target_link_libraries(poweroff PUBLIC libc) +banan_link_library(poweroff libc) -add_custom_target(poweroff-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/poweroff ${BANAN_BIN}/ - DEPENDS poweroff -) +install(TARGETS poweroff) diff --git a/userspace/resolver/CMakeLists.txt b/userspace/resolver/CMakeLists.txt index 40b6b02049..23a8cc1c7e 100644 --- a/userspace/resolver/CMakeLists.txt +++ b/userspace/resolver/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(resolver CXX) - set(SOURCES main.cpp ) add_executable(resolver ${SOURCES}) -target_compile_options(resolver PUBLIC -O2 -g) -target_link_libraries(resolver PUBLIC libc ban) +banan_link_library(resolver ban) +banan_link_library(resolver libc) -add_custom_target(resolver-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/resolver ${BANAN_BIN}/ - DEPENDS resolver -) +install(TARGETS resolver) diff --git a/userspace/rm/CMakeLists.txt b/userspace/rm/CMakeLists.txt index c7ed5335fe..9213a5510f 100644 --- a/userspace/rm/CMakeLists.txt +++ b/userspace/rm/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(rm CXX) - set(SOURCES main.cpp ) add_executable(rm ${SOURCES}) -target_compile_options(rm PUBLIC -O2 -g) -target_link_libraries(rm PUBLIC libc ban) +banan_include_headers(rm ban) +banan_link_library(rm libc) -add_custom_target(rm-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/rm ${BANAN_BIN}/ - DEPENDS rm -) +install(TARGETS rm) diff --git a/userspace/sleep/CMakeLists.txt b/userspace/sleep/CMakeLists.txt index 38299e583f..3efe450fb6 100644 --- a/userspace/sleep/CMakeLists.txt +++ b/userspace/sleep/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(sleep CXX) - set(SOURCES main.cpp ) add_executable(sleep ${SOURCES}) -target_compile_options(sleep PUBLIC -O2 -g) -target_link_libraries(sleep PUBLIC libc) +banan_link_library(sleep libc) -add_custom_target(sleep-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/sleep ${BANAN_BIN}/ - DEPENDS sleep -) +install(TARGETS sleep) diff --git a/userspace/snake/CMakeLists.txt b/userspace/snake/CMakeLists.txt index 59dc04a882..66e4059eae 100644 --- a/userspace/snake/CMakeLists.txt +++ b/userspace/snake/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(snake CXX) - set(SOURCES main.cpp ) add_executable(snake ${SOURCES}) -target_compile_options(snake PUBLIC -O2 -g) -target_link_libraries(snake PUBLIC libc) +banan_include_headers(snake ban) +banan_link_library(snake libc) -add_custom_target(snake-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/snake ${BANAN_BIN}/ - DEPENDS snake -) +install(TARGETS snake) diff --git a/userspace/stat/CMakeLists.txt b/userspace/stat/CMakeLists.txt index fb690ecaa1..2b539b2121 100644 --- a/userspace/stat/CMakeLists.txt +++ b/userspace/stat/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(stat CXX) - set(SOURCES main.cpp ) add_executable(stat ${SOURCES}) -target_compile_options(stat PUBLIC -O2 -g) -target_link_libraries(stat PUBLIC libc ban) +banan_link_library(stat ban) +banan_link_library(stat libc) -add_custom_target(stat-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/stat ${BANAN_BIN}/ - DEPENDS stat -) +install(TARGETS stat) diff --git a/userspace/sudo/CMakeLists.txt b/userspace/sudo/CMakeLists.txt index f1cf6b2962..f116692382 100644 --- a/userspace/sudo/CMakeLists.txt +++ b/userspace/sudo/CMakeLists.txt @@ -1,17 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(sudo CXX) - set(SOURCES main.cpp ) add_executable(sudo ${SOURCES}) -target_compile_options(sudo PUBLIC -O2 -g) -target_link_libraries(sudo PUBLIC libc) +banan_link_library(sudo libc) -add_custom_target(sudo-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/sudo ${BANAN_BIN}/ - COMMAND /bin/chmod u+s ${BANAN_BIN}/sudo - DEPENDS sudo -) +install(TARGETS sudo) diff --git a/userspace/sync/CMakeLists.txt b/userspace/sync/CMakeLists.txt index 611e7f557b..307481f56e 100644 --- a/userspace/sync/CMakeLists.txt +++ b/userspace/sync/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(sync CXX) - set(SOURCES main.cpp ) add_executable(sync ${SOURCES}) -target_compile_options(sync PUBLIC -O2 -g) -target_link_libraries(sync PUBLIC libc) +banan_link_library(sync libc) -add_custom_target(sync-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/sync ${BANAN_BIN}/ - DEPENDS sync -) +install(TARGETS sync) diff --git a/userspace/tee/CMakeLists.txt b/userspace/tee/CMakeLists.txt index 4697ff5262..7962c169b1 100644 --- a/userspace/tee/CMakeLists.txt +++ b/userspace/tee/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(tee CXX) - set(SOURCES main.cpp ) add_executable(tee ${SOURCES}) -target_compile_options(tee PUBLIC -O2 -g) -target_link_libraries(tee PUBLIC libc) +banan_link_library(tee libc) -add_custom_target(tee-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/tee ${BANAN_BIN}/ - DEPENDS tee -) +install(TARGETS tee) diff --git a/userspace/test-framebuffer/CMakeLists.txt b/userspace/test-framebuffer/CMakeLists.txt index cd2b58e0e5..fa8c2f130f 100644 --- a/userspace/test-framebuffer/CMakeLists.txt +++ b/userspace/test-framebuffer/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-framebuffer CXX) - set(SOURCES main.cpp ) add_executable(test-framebuffer ${SOURCES}) -target_compile_options(test-framebuffer PUBLIC -O2 -g) -target_link_libraries(test-framebuffer PUBLIC libc) +banan_link_library(test-framebuffer libc) -add_custom_target(test-framebuffer-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-framebuffer ${BANAN_BIN}/ - DEPENDS test-framebuffer -) +install(TARGETS test-framebuffer) diff --git a/userspace/test-globals/CMakeLists.txt b/userspace/test-globals/CMakeLists.txt index 6c7aa366b3..ad9ab9460c 100644 --- a/userspace/test-globals/CMakeLists.txt +++ b/userspace/test-globals/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-globals CXX) - set(SOURCES main.cpp ) add_executable(test-globals ${SOURCES}) -target_compile_options(test-globals PUBLIC -O2 -g) -target_link_libraries(test-globals PUBLIC libc) +banan_link_library(test-globals libc) -add_custom_target(test-globals-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-globals ${BANAN_BIN}/ - DEPENDS test-globals -) +install(TARGETS test-globals) diff --git a/userspace/test-mmap-shared/CMakeLists.txt b/userspace/test-mmap-shared/CMakeLists.txt new file mode 100644 index 0000000000..29d9e930e3 --- /dev/null +++ b/userspace/test-mmap-shared/CMakeLists.txt @@ -0,0 +1,8 @@ +set(SOURCES + main.cpp +) + +add_executable(test-mmap-shared ${SOURCES}) +banan_link_library(test-mmap-shared libc) + +install(TARGETS test-mmap-shared) diff --git a/userspace/mmap-shared-test/main.cpp b/userspace/test-mmap-shared/main.cpp similarity index 100% rename from userspace/mmap-shared-test/main.cpp rename to userspace/test-mmap-shared/main.cpp diff --git a/userspace/test-mouse/CMakeLists.txt b/userspace/test-mouse/CMakeLists.txt index 50f7504747..2060258e98 100644 --- a/userspace/test-mouse/CMakeLists.txt +++ b/userspace/test-mouse/CMakeLists.txt @@ -1,16 +1,10 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-mouse CXX) - set(SOURCES main.cpp ) add_executable(test-mouse ${SOURCES}) -target_compile_options(test-mouse PUBLIC -O2 -g) -target_link_libraries(test-mouse PUBLIC libc) +banan_include_headers(test-mouse ban) +banan_include_headers(test-mouse libinput) +banan_link_library(test-mouse libc) -add_custom_target(test-mouse-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-mouse ${BANAN_BIN}/ - DEPENDS test-mouse -) +install(TARGETS test-mouse) diff --git a/userspace/test-popen/CMakeLists.txt b/userspace/test-popen/CMakeLists.txt index 02c38f23c4..c475c12ad4 100644 --- a/userspace/test-popen/CMakeLists.txt +++ b/userspace/test-popen/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-popen CXX) - set(SOURCES main.cpp ) add_executable(test-popen ${SOURCES}) -target_compile_options(test-popen PUBLIC -O2 -g) -target_link_libraries(test-popen PUBLIC libc) +banan_link_library(test-popen libc) -add_custom_target(test-popen-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-popen ${BANAN_BIN}/ - DEPENDS test-popen -) +install(TARGETS test-popen) diff --git a/userspace/test-sort/CMakeLists.txt b/userspace/test-sort/CMakeLists.txt index 1a88a60c13..96c48bcbe6 100644 --- a/userspace/test-sort/CMakeLists.txt +++ b/userspace/test-sort/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-sort CXX) - set(SOURCES main.cpp ) add_executable(test-sort ${SOURCES}) -target_compile_options(test-sort PUBLIC -O2 -g) -target_link_libraries(test-sort PUBLIC libc) +banan_include_headers(test-sort ban) +banan_link_library(test-sort libc) -add_custom_target(test-sort-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-sort ${BANAN_BIN}/ - DEPENDS test-sort -) +install(TARGETS test-sort) diff --git a/userspace/test-tcp/CMakeLists.txt b/userspace/test-tcp/CMakeLists.txt index b96ed9d09b..519fb2d0d0 100644 --- a/userspace/test-tcp/CMakeLists.txt +++ b/userspace/test-tcp/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-tcp CXX) - set(SOURCES main.cpp ) add_executable(test-tcp ${SOURCES}) -target_compile_options(test-tcp PUBLIC -O2 -g) -target_link_libraries(test-tcp PUBLIC libc) +banan_link_library(test-tcp libc) -add_custom_target(test-tcp-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-tcp ${BANAN_BIN}/ - DEPENDS test-tcp -) +install(TARGETS test-tcp) diff --git a/userspace/test-udp/CMakeLists.txt b/userspace/test-udp/CMakeLists.txt index 3294e6cc47..60d3f0246e 100644 --- a/userspace/test-udp/CMakeLists.txt +++ b/userspace/test-udp/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-udp CXX) - set(SOURCES main.cpp ) add_executable(test-udp ${SOURCES}) -target_compile_options(test-udp PUBLIC -O2 -g) -target_link_libraries(test-udp PUBLIC libc) +banan_link_library(test-udp libc) -add_custom_target(test-udp-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-udp ${BANAN_BIN}/ - DEPENDS test-udp -) +install(TARGETS test-udp) diff --git a/userspace/test-unix-socket/CMakeLists.txt b/userspace/test-unix-socket/CMakeLists.txt index 814407c288..82cbc0382c 100644 --- a/userspace/test-unix-socket/CMakeLists.txt +++ b/userspace/test-unix-socket/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-unix-socket CXX) - set(SOURCES main.cpp ) add_executable(test-unix-socket ${SOURCES}) -target_compile_options(test-unix-socket PUBLIC -O2 -g) -target_link_libraries(test-unix-socket PUBLIC libc) +banan_link_library(test-unix-socket libc) -add_custom_target(test-unix-socket-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-unix-socket ${BANAN_BIN}/ - DEPENDS test-unix-socket -) +install(TARGETS test-unix-socket) diff --git a/userspace/test-window/CMakeLists.txt b/userspace/test-window/CMakeLists.txt index 766b9ea30c..b0c0857fd0 100644 --- a/userspace/test-window/CMakeLists.txt +++ b/userspace/test-window/CMakeLists.txt @@ -1,16 +1,11 @@ -cmake_minimum_required(VERSION 3.26) - -project(test-window CXX) - set(SOURCES main.cpp ) add_executable(test-window ${SOURCES}) -target_compile_options(test-window PUBLIC -O2 -g) -target_link_libraries(test-window PUBLIC libc ban libgui) +banan_include_headers(test-window ban) +banan_include_headers(test-window libinput) +banan_link_library(test-window libc) +banan_link_library(test-window libgui) -add_custom_target(test-window-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test-window ${BANAN_BIN}/ - DEPENDS test-window -) +install(TARGETS test-window) diff --git a/userspace/test/CMakeLists.txt b/userspace/test/CMakeLists.txt index 0de2c685c1..093742dbcb 100644 --- a/userspace/test/CMakeLists.txt +++ b/userspace/test/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(test CXX) - set(TEST_SOURCES test.cpp ) add_executable(test ${TEST_SOURCES}) -target_compile_options(test PUBLIC -O2 -g) -target_link_libraries(test PUBLIC libc) +banan_link_library(test libc) -add_custom_target(test-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/test ${BANAN_BIN}/ - DEPENDS test -) +install(TARGETS test) diff --git a/userspace/touch/CMakeLists.txt b/userspace/touch/CMakeLists.txt index c4542c6468..2e93a18220 100644 --- a/userspace/touch/CMakeLists.txt +++ b/userspace/touch/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(touch CXX) - set(SOURCES main.cpp ) add_executable(touch ${SOURCES}) -target_compile_options(touch PUBLIC -O2 -g) -target_link_libraries(touch PUBLIC libc) +banan_link_library(touch libc) -add_custom_target(touch-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/touch ${BANAN_BIN}/ - DEPENDS touch -) +install(TARGETS touch) diff --git a/userspace/u8sum/CMakeLists.txt b/userspace/u8sum/CMakeLists.txt index 249d160d7c..3233e3effb 100644 --- a/userspace/u8sum/CMakeLists.txt +++ b/userspace/u8sum/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(u8sum CXX) - set(SOURCES main.cpp ) add_executable(u8sum ${SOURCES}) -target_compile_options(u8sum PUBLIC -O2 -g) -target_link_libraries(u8sum PUBLIC libc) +banan_link_library(u8sum libc) -add_custom_target(u8sum-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/u8sum ${BANAN_BIN}/ - DEPENDS u8sum -) +install(TARGETS u8sum) diff --git a/userspace/whoami/CMakeLists.txt b/userspace/whoami/CMakeLists.txt index 1a9a3aacaa..106f9616de 100644 --- a/userspace/whoami/CMakeLists.txt +++ b/userspace/whoami/CMakeLists.txt @@ -1,16 +1,9 @@ -cmake_minimum_required(VERSION 3.26) - -project(whoami CXX) - set(SOURCES main.cpp ) add_executable(whoami ${SOURCES}) -target_compile_options(whoami PUBLIC -O2 -g) -target_link_libraries(whoami PUBLIC libc ban) +banan_include_headers(whoami ban) +banan_link_library(whoami libc) -add_custom_target(whoami-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/whoami ${BANAN_BIN}/ - DEPENDS whoami -) +install(TARGETS whoami) diff --git a/userspace/yes/CMakeLists.txt b/userspace/yes/CMakeLists.txt index 6ef982bd39..b6ef202cfc 100644 --- a/userspace/yes/CMakeLists.txt +++ b/userspace/yes/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.26) - -project(yes CXX) - set(SOURCES main.cpp ) add_executable(yes ${SOURCES}) -target_compile_options(yes PUBLIC -O2 -g) -target_link_libraries(yes PUBLIC libc) +banan_link_library(yes libc) -add_custom_target(yes-install - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/yes ${BANAN_BIN}/ - DEPENDS yes -) +install(TARGETS yes)