refactor CMake configuration: update library installation paths and exclude Unity from default build

This commit is contained in:
2026-03-27 15:01:45 -03:00
parent 12ff389d49
commit 407224a796
3 changed files with 34 additions and 2 deletions

18
.idea/copilotDiffState.xml generated Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CopilotDiffPersistence">
<option name="pendingDiffs">
<map>
<entry key="/CMakeLists (snapshot).txt">
<value>
<PendingDiffInfo>
<option name="filePath" value="/CMakeLists (snapshot).txt" />
<option name="originalContent" value="cmake_minimum_required(VERSION 4.2)&#10;project(dynamic_array LANGUAGES C)&#10;&#10;set(CMAKE_C_STANDARD 11)&#10;&#10;&#10;# Configures Testing Framework&#10;include(CTest)&#10;add_subdirectory(submodules/external/unity)&#10;enable_testing()&#10;&#10;&#10;# Configures the project&#10;add_subdirectory(src)&#10;&#10;&#10;# Install the library to a specific directory (e.g., 'lib') relative to the install prefix&#10;install(TARGETS dynamic_array&#10; LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # Installs shared libs to &lt;prefix&gt;/lib&#10; ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # Installs static libs to &lt;prefix&gt;/lib&#10; RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Installs associated executables to &lt;prefix&gt;/bin&#10;)&#10;" />
<option name="updatedContent" value="cmake_minimum_required(VERSION 4.2)&#10;project(dynamic_array LANGUAGES C)&#10;&#10;set(CMAKE_C_STANDARD 11)&#10;&#10;&#10;# Configures Testing Framework&#10;include(CTest)&#10;# Exclude Unity from default build/install - only needed for tests&#10;add_subdirectory(submodules/external/unity EXCLUDE_FROM_ALL)&#10;enable_testing()&#10;&#10;&#10;# Configures the project&#10;add_subdirectory(src)&#10;&#10;&#10;# Install the library to a specific directory (e.g., 'lib') relative to the install prefix&#10;install(TARGETS dynamic_array&#10; LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # Installs shared libs to &lt;prefix&gt;/lib&#10; ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # Installs static libs to &lt;prefix&gt;/lib&#10; RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Installs associated executables to &lt;prefix&gt;/bin&#10;)&#10;" />
</PendingDiffInfo>
</value>
</entry>
</map>
</option>
</component>
</project>

View File

@@ -6,7 +6,8 @@ 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()

View File

@@ -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 <prefix>/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # Installs static libs to <prefix>/lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Installs associated executables to <prefix>/bin
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # Installs headers to <prefix>/include
)
# Testing
add_executable(test_dynamic_array test_dynamic_array.c)
target_link_libraries(test_dynamic_array PRIVATE dynamic_array unity::framework)