From 407224a796e94746e2a848b00647618842f71c95 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Fri, 27 Mar 2026 15:01:45 -0300 Subject: [PATCH] refactor CMake configuration: update library installation paths and exclude Unity from default build --- .idea/copilotDiffState.xml | 18 ++++++++++++++++++ CMakeLists.txt | 5 +++-- src/CMakeLists.txt | 13 +++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .idea/copilotDiffState.xml diff --git a/.idea/copilotDiffState.xml b/.idea/copilotDiffState.xml new file mode 100644 index 0000000..1f7876f --- /dev/null +++ b/.idea/copilotDiffState.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4983ec7..de5f000 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,10 @@ set(CMAKE_C_STANDARD 11) # Configures Testing Framework include(CTest) -add_subdirectory(submodules/external/unity) +# Exclude Unity from default build/install - only needed for tests +add_subdirectory(submodules/external/unity EXCLUDE_FROM_ALL) enable_testing() # Configures the project -add_subdirectory(src) +add_subdirectory(src) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c36066..0c26c8f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,22 @@ +# Library Configuration add_library(dynamic_array dynamic_array.c dynamic_array.h) 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 +) + + +# Testing + add_executable(test_dynamic_array test_dynamic_array.c) target_link_libraries(test_dynamic_array PRIVATE dynamic_array unity::framework)