cmake_tutorial/libs/lib1/CMakeLists.txt
2025-07-03 17:29:32 +02:00

17 lines
904 B
CMake

# Defines a static library target named 'lib1' from its source file.
add_library(lib1 STATIC src/lib1.c)
# Specifies include directories that are part of lib1's public interface.
# - PUBLIC: Means that targets linking to lib1 (like cmake_tutorialApp) will
# inherit this include path. This allows them to find lib1.h.
# ${CMAKE_CURRENT_SOURCE_DIR} refers to the current directory where this CMakeLists.txt resides.
target_include_directories(lib1 PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc
)
# Links lib1 to lib2 and lib3.
# - PRIVATE: Indicates that lib1's implementation depends on lib2 and lib3,
# but targets linking to lib1 do NOT need to know about lib2 or lib3.
# CMake automatically propagates the PUBLIC/INTERFACE include directories from lib2 and lib3
# to lib1, so explicit include directories for them are not needed here.
target_link_libraries(lib1 PRIVATE lib2 lib3)