Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
73c46d53
Commit
73c46d53
authored
Dec 05, 2010
by
Peter Drahoš
Committed by
Vicent Marti
Dec 12, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic testing support and options to specify install paths
parent
7cbdaf7f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
14 deletions
+50
-14
CMakeLists.txt
+42
-9
README.md
+8
-5
No files found.
CMakeLists.txt
View file @
73c46d53
# CMake build script for the libgit2 project
# Theres nothing wrong with the original Waf build besides dependency on Python which I lack on some systems.
# Peter Drahos 2010
#
# Building:
# > mkdir build && cd build
# > cmake .. && make -j3
#
# Testing:
# > ctest -V
#
# Install:
# > make install
PROJECT
(
libgit2 C
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
# Find required dependencies
FIND_PACKAGE
(
zlib REQUIRED
)
INCLUDE_DIRECTORIES
(
${
ZLIB_INCLUDE_DIR
}
src
)
# Try finding openssl
FIND_PACKAGE
(
OpenSSL
)
...
...
@@ -16,15 +27,15 @@ ELSEIF ()
ENDIF
()
# Sane defaults and options
SET
(
INSTALL_BIN bin CACHE PATH
"Where to install binaries to."
)
SET
(
INSTALL_LIB lib CACHE PATH
"Where to install libraries to."
)
SET
(
INSTALL_INC include/git CACHE PATH
"Where to install headers to."
)
OPTION
(
BUILD_SHARED_LIBS
"Build Shared Library (OFF for Static)"
ON
)
OPTION
(
BUILD_TESTS
"Build Tests"
ON
)
IF
(
NOT CMAKE_BUILD_TYPE
)
SET
(
CMAKE_BUILD_TYPE
"Release"
CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
ENDIF
()
INCLUDE_DIRECTORIES
(
${
ZLIB_INCLUDE_DIR
}
src
)
# Collect sourcefiles
FILE
(
GLOB SRC src/*.c
)
FILE
(
GLOB SRC_SHA1 src/block-sha1/*.c
)
...
...
@@ -54,13 +65,35 @@ TARGET_LINK_LIBRARIES(git2 ${ZLIB_LIBRARY} ${LIB_SHA1})
# Install
INSTALL
(
TARGETS git2
RUNTIME DESTINATION
bin
LIBRARY DESTINATION
lib
ARCHIVE DESTINATION
lib
RUNTIME DESTINATION
${
INSTALL_BIN
}
LIBRARY DESTINATION
${
INSTALL_LIB
}
ARCHIVE DESTINATION
${
INSTALL_LIB
}
)
INSTALL
(
FILES
${
SRC_H
}
DESTINATION
include/git
)
INSTALL
(
FILES
${
SRC_H
}
DESTINATION
${
INSTALL_INC
}
)
# Tests
IF
(
BUILD_TESTS
)
# TODO. The Waf build generates *.toc files for each test which complicates things.
ENABLE_TESTING
()
# Find and build all tests
INCLUDE_DIRECTORIES
(
tests
)
FILE
(
GLOB TESTS tests/t????-*.c
)
FOREACH
(
TEST_SRC
${
TESTS
}
)
# Match the source to get test name
STRING
(
REGEX MATCH
"(t....-.*).c$"
TEST_NAME
${
TEST_SRC
}
)
SET
(
TEST_NAME
${
CMAKE_MATCH_1
}
)
# This is the actual matched variable, got to love CMake macro language
# Generate TOC by finding BEGIN_TEST entries in test source.
FILE
(
READ
${
TEST_SRC
}
TEST_CODE
)
STRING
(
REGEX MATCHALL
"BEGIN_TEST
\\
([^
\\
)]*
\\
)
\n
"
TEST_TOC
${
TEST_CODE
}
)
FILE
(
WRITE tests/
${
TEST_NAME
}
.toc
${
TEST_TOC
}
)
# If desired this might be moved to the build dir
# Compile
ADD_EXECUTABLE
(
${
TEST_NAME
}
tests/test_main.c tests/test_lib.c tests/test_helpers.c
${
TEST_SRC
}
)
TARGET_LINK_LIBRARIES
(
${
TEST_NAME
}
git2
)
SET_TARGET_PROPERTIES
(
${
TEST_NAME
}
PROPERTIES COMPILE_DEFINITIONS TEST_TOC=\
"
${
TEST_NAME
}
.toc
\"
)
# Add CTest
ADD_TEST(
${
TEST_NAME
}
${
TEST_NAME
}
)
ENDFOREACH ()
ENDIF ()
README.md
View file @
73c46d53
...
...
@@ -42,19 +42,22 @@ When building using CMake the following dependencies are required:
*
CMake 2.6+
<http://www.cmake.org>
Probably already installed in your system are
:
Required dependency
:
*
zlib 1.2+
<http://www.zlib.net/>
*
LibSSL
<http://www.openssl.org/>
Optional dependency:
Generate makefile or IDE workspace specific to your system using CMake by pointing the CMakeGui to the CMakeLists.txt file.
*
LibSSL
<http://www.openssl.org/>
O
ptionally, you can build from commandline on most UNIX systems using:
O
n most Unix systems you can build the library using the following commands
$ ccmake .
$ mkdir build && cd build
$ cmake ..
$ make install
Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
Building libgit2 - Unix systems
==================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment