From 1fb05aff6ab3b8f683bc6244510b88fb345a6657 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Wed, 15 Apr 2026 20:02:59 -0300 Subject: [PATCH] refactor: simplify CI configuration and enhance CMake installation rules --- .github/workflows/ci.yml | 7 +------ src/CMakeLists.txt | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8536fd1..757f694 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,9 +16,7 @@ jobs: submodules: recursive - name: Cache and install APT packages - uses: awalsh128/cache-apt-pkgs-action@v1 - with: - packages: cmake build-essential + run: sudo apt update && sudo apt install cmake build-essential - name: Configure project run: make configure @@ -36,6 +34,3 @@ jobs: run: | ls -la ${{ runner.temp }}/install/lib/ ls -la ${{ runner.temp }}/install/include/ - - - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71afb50..2d53494 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,22 +1,24 @@ -# Library Configuration include(GNUInstallDirs) + +# Library Configuration add_library(dynamic_array INTERFACE) -target_include_directories(dynamic_array INTERFACE - $ - $ +target_include_directories(dynamic_array INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +set_target_properties(dynamic_array PROPERTIES PUBLIC_HEADER dynamic_array.h) + + +# Install the library to a specific directory (e.g., 'lib') relative to the install prefix +install(TARGETS dynamic_array + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # Installs shared libs to /lib + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # Installs static libs to /lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Installs associated executables to /bin + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # Installs headers to /include ) -# Install the exported target and public header -install(TARGETS dynamic_array) -install(FILES dynamic_array.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - - # Testing add_executable(test_dynamic_array test_dynamic_array.c) target_link_libraries(test_dynamic_array PRIVATE dynamic_array unity::framework) - add_test(NAME test_dynamic_array COMMAND test_dynamic_array) \ No newline at end of file