Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
libgit2/CMakeLists.txt at development · lht/libgit2 · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
lht
libgit2
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
development
Breadcrumbs
libgit2
/
CMakeLists.txt
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
161 lines (132 loc) · 5.12 KB
development
Breadcrumbs
libgit2
/
CMakeLists.txt
Copy path
Top
File metadata and controls
Code
Blame
161 lines (132 loc) · 5.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#
CMake build script for the libgit2 project
#
#
Building (out of source build):
#
> mkdir build && cd build
#
> cmake .. [-DSETTINGS=VALUE]
#
> cmake --build .
#
#
Testing:
#
> ctest -V
#
#
Install:
#
> cmake --build . --target install
PROJECT
(libgit2
C
)
CMAKE_MINIMUM_REQUIRED
(
VERSION
2.6
)
FILE
(
STRINGS
"include/git2/version.h"
GIT2_HEADER
REGEX
"^#define LIBGIT2_VERSION
\"
[^
\"
]*
\"
$"
)
STRING
(
REGEX
REPLACE
"^.*LIBGIT2_VERSION
\"
([0-9]+).*$"
"
\\
1"
LIBGIT2_VERSION_MAJOR
"
${GIT2_HEADER}
"
)
STRING
(
REGEX
REPLACE
"^.*LIBGIT2_VERSION
\"
[0-9]+
\\
.([0-9]+).*$"
"
\\
1"
LIBGIT2_VERSION_MINOR
"
${GIT2_HEADER}
"
)
STRING
(
REGEX
REPLACE
"^.*LIBGIT2_VERSION
\"
[0-9]+
\\
.[0-9]+
\\
.([0-9]+).*$"
"
\\
1"
LIBGIT2_VERSION_REV
"
${GIT2_HEADER}
"
)
SET
(LIBGIT2_VERSION_STRING
"
${LIBGIT2_VERSION_MAJOR}
.
${LIBGIT2_VERSION_MINOR}
.
${LIBGIT2_VERSION_REV}
"
)
#
Find required dependencies
INCLUDE_DIRECTORIES
(
src
include
deps/http-parser
)
FILE
(
GLOB
SRC_HTTP
deps/http-parser/*.c
)
IF
(
NOT
WIN32
)
FIND_PACKAGE
(
ZLIB
)
ENDIF
()
IF
(ZLIB_FOUND)
INCLUDE_DIRECTORIES
(
${ZLIB_INCLUDE_DIRS}
)
LINK_LIBRARIES
(
${ZLIB_LIBRARIES}
)
ELSE
(
ZLIB_FOUND
)
INCLUDE_DIRECTORIES
(
deps/zlib
)
ADD_DEFINITIONS
(
-DNO_VIZ
-DSTDC
-DNO_GZIP
)
FILE
(
GLOB
SRC_ZLIB
deps/zlib/*.c
)
ENDIF
()
#
Installation paths
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
CACHE
PATH
"Where to install headers to."
)
#
Build options
OPTION
(
BUILD_SHARED_LIBS
"Build Shared Library (OFF for Static)"
ON
)
OPTION
(
THREADSAFE
"Build libgit2 as threadsafe"
OFF
)
OPTION
(
BUILD_TESTS
"Build Tests"
ON
)
OPTION
(
BUILD_CLAY
"Build Tests using the Clay suite"
OFF
)
#
Platform specific compilation flags
IF
(
MSVC
)
#
Not using __stdcall with the CRT causes problems
OPTION
(
STDCALL
"Buildl libgit2 with the __stdcall convention"
ON
)
SET
(
CMAKE_C_FLAGS
"/W4 /nologo /Zi
${
CMAKE_C_FLAGS
}
"
)
IF
(STDCALL)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
/Gz"
)
ENDIF
()
#
TODO: bring back /RTC1 /RTCc
SET
(
CMAKE_C_FLAGS_DEBUG
"/Od /DEBUG /MTd"
)
SET
(
CMAKE_C_FLAGS_RELEASE
"/MT /O2"
)
SET
(WIN_RC
"src/win32/git2.rc"
)
ELSE
()
SET
(
CMAKE_C_FLAGS
"-O2 -g -Wall -Wextra -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes
${
CMAKE_C_FLAGS
}
"
)
SET
(
CMAKE_C_FLAGS_DEBUG
"-O0 -g"
)
IF
(
NOT
MINGW)
#
MinGW always does PIC and complains if we tell it to
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fPIC"
)
ENDIF
()
ENDIF
()
#
Build Debug by default
IF
(
NOT
CMAKE_BUILD_TYPE
)
SET
(
CMAKE_BUILD_TYPE
"Debug"
CACHE
STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
ENDIF
()
IF
(THREADSAFE)
IF
(
NOT
WIN32
)
find_package
(
Threads
REQUIRED
)
ENDIF
()
ADD_DEFINITIONS
(
-DGIT_THREADS
)
ENDIF
()
ADD_DEFINITIONS
(
-D_FILE_OFFSET_BITS=64
)
#
Collect sourcefiles
FILE
(
GLOB
SRC_H
include
/git2/*.h
)
#
On Windows use specific platform sources
IF
(
WIN32
AND
NOT
CYGWIN
)
ADD_DEFINITIONS
(
-DWIN32
-D_DEBUG
)
FILE
(
GLOB
SRC
src/*.c
src/transports/*.c
src/win32/*.c
)
ELSE
()
FILE
(
GLOB
SRC
src/*.c
src/transports/*.c
src/unix/*.c
)
ENDIF
()
#
Compile and link libgit2
ADD_LIBRARY
(
git2
${SRC}
${SRC_ZLIB}
${SRC_HTTP}
${WIN_RC}
)
IF
(
WIN32
)
TARGET_LINK_LIBRARIES
(
git2
ws2_32
)
ELSEIF
(
CMAKE_SYSTEM_NAME
MATCHES
"(Solaris|SunOS)"
)
TARGET_LINK_LIBRARIES
(
git2
socket
nsl
)
ENDIF
()
TARGET_LINK_LIBRARIES
(
git2
${CMAKE_THREAD_LIBS_INIT}
)
SET_TARGET_PROPERTIES
(git2 PROPERTIES
VERSION
${LIBGIT2_VERSION_STRING}
)
SET_TARGET_PROPERTIES
(git2 PROPERTIES
SOVERSION
${LIBGIT2_VERSION_MAJOR}
)
CONFIGURE_FILE
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/libgit2.pc.in
${
CMAKE_CURRENT_BINARY_DIR
}
/libgit2.pc
@ONLY
)
#
Install
INSTALL
(
TARGETS
git2
RUNTIME
DESTINATION
${INSTALL_BIN}
LIBRARY
DESTINATION
${INSTALL_LIB}
ARCHIVE
DESTINATION
${INSTALL_LIB}
)
INSTALL
(
FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/libgit2.pc
DESTINATION
${INSTALL_LIB}
/pkgconfig )
INSTALL
(
DIRECTORY
include/git2
DESTINATION
${INSTALL_INC}
)
INSTALL
(
FILES
include/git2.h
DESTINATION
${INSTALL_INC}
)
#
Tests
IF
(BUILD_TESTS)
SET
(TEST_RESOURCES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/tests/resources"
CACHE
PATH
"Path to test resources."
)
ADD_DEFINITIONS
(
-DTEST_RESOURCES=
\
"
${TEST_RESOURCES}
\"
)
INCLUDE_DIRECTORIES(tests)
FILE(GLOB SRC_TEST tests/t??-*.c)
ADD_EXECUTABLE(libgit2_test tests/test_main.c tests/test_lib.c tests/test_helpers.c
${SRC}
${SRC_TEST}
${SRC_ZLIB}
${SRC_HTTP}
)
TARGET_LINK_LIBRARIES(libgit2_test
${CMAKE_THREAD_LIBS_INIT}
)
IF (WIN32)
TARGET_LINK_LIBRARIES(libgit2_test ws2_32)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "
(
Solaris|SunOS
)
")
TARGET_LINK_LIBRARIES(libgit2_test socket nsl)
ENDIF ()
ENABLE_TESTING()
ADD_TEST(libgit2_test libgit2_test)
ENDIF ()
IF (BUILD_CLAY)
SET(CLAY_FIXTURES "
${
CMAKE_CURRENT_SOURCE_DIR
}
/tests/resources/
")
ADD_DEFINITIONS(-DCLAY_FIXTURE_PATH=
\"
${CLAY_FIXTURES}
\"
)
INCLUDE_DIRECTORIES(tests-clay)
FILE(GLOB_RECURSE SRC_TEST tests-clay/*.c)
ADD_EXECUTABLE(libgit2_clay
${SRC}
${SRC_TEST}
${SRC_ZLIB}
${SRC_HTTP}
)
TARGET_LINK_LIBRARIES(libgit2_clay
${CMAKE_THREAD_LIBS_INIT}
)
IF (WIN32)
TARGET_LINK_LIBRARIES(libgit2_clay ws2_32)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "
(
Solaris|SunOS
)
")
TARGET_LINK_LIBRARIES(libgit2_clay socket nsl)
ENDIF ()
ENABLE_TESTING()
ADD_TEST(libgit2_clay libgit2_clay)
ENDIF ()
You can’t perform that action at this time.