From 5a6a6654696d33a5c94a7bb2e5e83a0a7ef34fa7 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Tue, 4 Jun 2024 08:43:55 +0200 Subject: [PATCH] Examples: Create CMakeLists.txt, enable building --- CMakeLists.txt | 5 +++++ examples/c/CMakeLists.txt | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 examples/c/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index d0396f11..166ac03f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ PROJECT (librepo C) OPTION (ENABLE_TESTS "Build test?" ON) OPTION (ENABLE_DOCS "Build docs?" ON) +OPTION (ENABLE_EXAMPLES "Build examples?" ON) OPTION (WITH_ZCHUNK "Build with zchunk support" ON) OPTION (ENABLE_PYTHON "Build Python bindings" ON) OPTION (USE_GPGME "Use GpgMe (instead of rpm library) for OpenPGP key support" ON) @@ -132,3 +133,7 @@ ENDIF (ENABLE_TESTS) IF (ENABLE_DOCS) ADD_SUBDIRECTORY (doc) ENDIF (ENABLE_DOCS) + +IF (ENABLE_EXAMPLES) + ADD_SUBDIRECTORY (examples/c) +ENDIF (ENABLE_EXAMPLES) diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt new file mode 100644 index 00000000..0a4442e7 --- /dev/null +++ b/examples/c/CMakeLists.txt @@ -0,0 +1,7 @@ +FILE(GLOB one_file_sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") + +FOREACH(file_path ${one_file_sources}) + GET_FILENAME_COMPONENT(filename "${file_path}" NAME_WLE) + ADD_EXECUTABLE("${filename}" "${file_path}") + TARGET_LINK_LIBRARIES("${filename}" librepo) +ENDFOREACH()