summaryrefslogtreecommitdiff
path: root/examples/CMakeLists.txt
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-01-24 11:31:49 +0100
committerPatrick Steinhardt <ps@pks.im>2019-02-15 12:06:54 +0100
commitead10785dcd9e7599a52a0349a69c113c76e650d (patch)
tree14c30c430befd05eb160108fe49a14d72faeb3d7 /examples/CMakeLists.txt
parent7562422ab9310b81142986f69964194f491948cc (diff)
downloadlibgit2-ead10785dcd9e7599a52a0349a69c113c76e650d.tar.gz
examples: create common lg2 executable
Inside of our networking example code, we have a git2 executable that acts as an entry point to all the different network examples. As such, it is kind of the same like the normal git(1) executable in that it simply arbitrates to the respective subcommands. Let's extend this approach and merge all examples into a single standalone lg2 executable. Instead of building an executable for all the existing examples we have, we now bundle them all inside of the lg2 one and let them be callable via subcommands. In the process, we can get rid of duplicated library initialization, deinitialization and repository discovery code. Instead of having each subcommand handle these on its own, we simply do it inside of the single main function now.
Diffstat (limited to 'examples/CMakeLists.txt')
-rw-r--r--examples/CMakeLists.txt20
1 files changed, 5 insertions, 15 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index c02af0684..05e344df1 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,25 +1,15 @@
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
-FILE(GLOB_RECURSE SRC_EXAMPLE_GIT2 network/*.c common.?)
-ADD_EXECUTABLE(cgit2 ${SRC_EXAMPLE_GIT2})
-SET_TARGET_PROPERTIES(cgit2 PROPERTIES C_STANDARD 90)
+FILE(GLOB LG2_SOURCES *.c)
+ADD_EXECUTABLE(lg2 ${LG2_SOURCES})
+SET_TARGET_PROPERTIES(lg2 PROPERTIES C_STANDARD 90)
# Ensure that we do not use deprecated functions internally
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
IF(WIN32 OR ANDROID)
- TARGET_LINK_LIBRARIES(cgit2 git2)
+ TARGET_LINK_LIBRARIES(lg2 git2)
ELSE()
- TARGET_LINK_LIBRARIES(cgit2 git2 pthread)
+ TARGET_LINK_LIBRARIES(lg2 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})
- IF(NOT ${app_name} STREQUAL "common")
- ADD_EXECUTABLE(${app_name} ${src_app} "common.c")
- TARGET_LINK_LIBRARIES(${app_name} git2)
- SET_TARGET_PROPERTIES(${app_name} PROPERTIES C_STANDARD 90)
- ENDIF()
-ENDFOREACH()