Split examples CMakeLists.txt Also, this converts the examples/CMakeLists.txt from explicitly listing to just globbing for all the individual C files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 78c25b1..5c09b41 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -409,38 +409,5 @@ IF (TAGS)
ENDIF ()
IF (BUILD_EXAMPLES)
- FILE(GLOB_RECURSE EXAMPLE_SRC examples/network/*.c examples/network/*.h)
- ADD_EXECUTABLE(cgit2 ${EXAMPLE_SRC})
- IF(WIN32 OR ANDROID)
- TARGET_LINK_LIBRARIES(cgit2 git2)
- ELSE()
- TARGET_LINK_LIBRARIES(cgit2 git2 pthread)
- ENDIF()
-
- ADD_EXECUTABLE(git-diff examples/diff.c)
- TARGET_LINK_LIBRARIES(git-diff git2)
-
- ADD_EXECUTABLE(git-general examples/general.c)
- TARGET_LINK_LIBRARIES(git-general git2)
-
- ADD_EXECUTABLE(git-showindex examples/showindex.c)
- TARGET_LINK_LIBRARIES(git-showindex git2)
-
- ADD_EXECUTABLE(git-rev-list examples/rev-list.c)
- TARGET_LINK_LIBRARIES(git-rev-list git2)
-
- ADD_EXECUTABLE(git-rev-parse examples/rev-parse.c)
- TARGET_LINK_LIBRARIES(git-rev-parse git2)
-
- ADD_EXECUTABLE(git-log examples/log.c)
- TARGET_LINK_LIBRARIES(git-log git2)
-
- ADD_EXECUTABLE(git-status examples/status.c)
- TARGET_LINK_LIBRARIES(git-status git2)
-
- ADD_EXECUTABLE(git-init examples/init.c)
- TARGET_LINK_LIBRARIES(git-init git2)
-
- ADD_EXECUTABLE(git-cat-file examples/cat-file.c)
- TARGET_LINK_LIBRARIES(git-cat-file git2)
+ ADD_SUBDIRECTORY(examples)
ENDIF ()
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..c20a6df
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,14 @@
+FILE(GLOB_RECURSE SRC_EXAMPLE_GIT2 network/*.c network/*.h)
+ADD_EXECUTABLE(cgit2 ${SRC_EXAMPLE_GIT2})
+IF(WIN32 OR ANDROID)
+ TARGET_LINK_LIBRARIES(cgit2 git2)
+ELSE()
+ TARGET_LINK_LIBRARIES(cgit2 git2 pthread)
+ENDIF()
+
+FILE(GLOB SRC_EXAMPLE_APPS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c)
+FOREACH(src_app ${SRC_EXAMPLE_APPS})
+ STRING(REPLACE ".c" "" app_name ${src_app})
+ ADD_EXECUTABLE(${app_name} ${src_app})
+ TARGET_LINK_LIBRARIES(${app_name} git2)
+ENDFOREACH()