From cb359a05dc49e563e2339ff94a7afe6252ddf5b2 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 31 May 2023 22:40:15 +0300 Subject: [PATCH] BuildSystem: link libraries when they change This also fixed the need for manual linkin on firt build --- BAN/CMakeLists.txt | 1 + libc/CMakeLists.txt | 1 + userspace/CMakeLists.txt | 1 + userspace/Shell/CMakeLists.txt | 5 +---- userspace/cat/CMakeLists.txt | 3 +-- userspace/test/CMakeLists.txt | 4 +--- userspace/yes/CMakeLists.txt | 3 +-- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/BAN/CMakeLists.txt b/BAN/CMakeLists.txt index f88ded84..b909e43d 100644 --- a/BAN/CMakeLists.txt +++ b/BAN/CMakeLists.txt @@ -20,4 +20,5 @@ add_dependencies(ban headers libc-install) add_custom_target(ban-install COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libban.a ${BANAN_LIB}/ DEPENDS ban + BYPRODUCTS ${BANAN_LIB}/libban.a ) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 0483ae4a..0873bf0f 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -26,6 +26,7 @@ add_dependencies(libc headers crt0) add_custom_target(libc-install COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/libc.a ${BANAN_LIB}/ DEPENDS libc + BYPRODUCTS ${BANAN_LIB}/libc.a ) set(CMAKE_STATIC_LIBRARY_PREFIX "") diff --git a/userspace/CMakeLists.txt b/userspace/CMakeLists.txt index 0138f20e..e4a65c69 100644 --- a/userspace/CMakeLists.txt +++ b/userspace/CMakeLists.txt @@ -17,6 +17,7 @@ add_custom_target(userspace) add_custom_target(userspace-install DEPENDS userspace) foreach(USERSPACE_PROJECT ${USERSPACE_PROJECTS}) + target_link_options(${USERSPACE_PROJECT} PUBLIC -nodefaultlibs) add_dependencies(userspace ${USERSPACE_PROJECT}) add_dependencies(userspace-install ${USERSPACE_PROJECT}-install) endforeach() diff --git a/userspace/Shell/CMakeLists.txt b/userspace/Shell/CMakeLists.txt index fde110c9..f62bc158 100644 --- a/userspace/Shell/CMakeLists.txt +++ b/userspace/Shell/CMakeLists.txt @@ -8,10 +8,7 @@ set(SOURCES add_executable(Shell ${SOURCES}) target_compile_options(Shell PUBLIC -O2 -g) -add_dependencies(Shell libc-install ban-install) -target_link_options(Shell PUBLIC -nodefaultlibs) -target_link_libraries(Shell PUBLIC ${BANAN_LIB}/libc.a) -target_link_libraries(Shell PUBLIC ${BANAN_LIB}/libban.a) +target_link_libraries(Shell PUBLIC libc ban) add_custom_target(Shell-install COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/Shell ${BANAN_BIN}/ diff --git a/userspace/cat/CMakeLists.txt b/userspace/cat/CMakeLists.txt index 27cb999c..c5e6524e 100644 --- a/userspace/cat/CMakeLists.txt +++ b/userspace/cat/CMakeLists.txt @@ -8,8 +8,7 @@ set(SOURCES add_executable(cat ${SOURCES}) target_compile_options(cat PUBLIC -O2 -g) -add_dependencies(cat libc-install) -target_link_options(cat PUBLIC -nodefaultlibs -lc) +target_link_libraries(cat PUBLIC libc) add_custom_target(cat-install COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cat ${BANAN_BIN}/ diff --git a/userspace/test/CMakeLists.txt b/userspace/test/CMakeLists.txt index 6a2ce163..08bc0640 100644 --- a/userspace/test/CMakeLists.txt +++ b/userspace/test/CMakeLists.txt @@ -8,9 +8,7 @@ set(TEST_SOURCES add_executable(test ${TEST_SOURCES}) target_compile_options(test PUBLIC -O2 -g) -add_dependencies(test libc-install) -target_link_options(test PUBLIC -nodefaultlibs) -target_link_libraries(test PUBLIC ${BANAN_LIB}/libc.a) +target_link_libraries(test PUBLIC libc) add_custom_target(test-install COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/test ${BANAN_BIN}/ diff --git a/userspace/yes/CMakeLists.txt b/userspace/yes/CMakeLists.txt index fd25963d..aa1eb58d 100644 --- a/userspace/yes/CMakeLists.txt +++ b/userspace/yes/CMakeLists.txt @@ -8,8 +8,7 @@ set(SOURCES add_executable(yes ${SOURCES}) target_compile_options(yes PUBLIC -O2 -g) -add_dependencies(yes libc-install) -target_link_options(yes PUBLIC -nodefaultlibs -lc) +target_link_libraries(yes PUBLIC libc) add_custom_target(yes-install COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/yes ${BANAN_BIN}/