This commit is contained in:
Attila Body 2025-05-26 10:22:03 +02:00
parent 0c66ff89b3
commit 9b8308eb4a
Signed by: abody
GPG key ID: BD0C6214E68FB5CF
11 changed files with 121 additions and 0 deletions

27
CMakeLists.txt Normal file
View file

@ -0,0 +1,27 @@
# Specifies the minimum version of CMake required to configure the project.
cmake_minimum_required(VERSION 3.10)
# Defines the name of the project. This name is used for various CMake targets and variables.
project(cmake_tutorial C)
# Configures CMake to generate a 'compile_commands.json' file in the build directory.
# This file is used by many IDEs and language servers (e.g., VS Code, CLion)
# to provide intelligent code features like autocompletion, go-to-definition, and static analysis.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export compile commands for IDEs." FORCE)
# Includes the CMakeLists.txt files from the specified subdirectories.
# This makes the targets (libraries) defined in those subdirectories available in the current scope.
# The order is important: libraries must be defined before they are linked.
add_subdirectory(libs/lib1)
add_subdirectory(libs/lib2)
add_subdirectory(libs/lib3)
# Defines an executable target named 'cmake_tutorialApp' from the source file 'src/app.c'.
add_executable(cmake_tutorial src/app.c)
# Links the executable target 'cmake_tutorialApp' to the specified libraries.
# - PRIVATE: Indicates that 'cmake_tutorialApp' needs these libraries for its own compilation/linking,
# but targets that link to 'cmake_tutorialApp' do NOT need them.
# CMake automatically propagates the PUBLIC/INTERFACE include directories from lib1, lib2, and lib3
# to cmake_tutorialApp, so explicit target_include_directories is not needed here.
target_link_libraries(cmake_tutorial PRIVATE lib1 lib2 lib3)