Commit 60ee53dfce5ff0201e6f519c653cf0de195ff35b

Russell Belfer 2013-09-03T15:14:04

Split examples CMakeLists.txt Also, this converts the examples/CMakeLists.txt from explicitly listing to just globbing for all the individual C files.

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()