]> git.proxmox.com Git - libgit2.git/blame - CMakeLists.txt
Update README.md
[libgit2.git] / CMakeLists.txt
CommitLineData
583cf169
PD
1# CMake build script for the libgit2 project
2# Theres nothing wrong with the original Waf build besides dependency on Python which I lack on some systems.
3# Peter Drahos 2010
4PROJECT(libgit2 C)
5CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
6
7# Sane defaults
8OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
9OPTION (BUILD_TESTS "Build Tests" ON)
10IF (NOT CMAKE_BUILD_TYPE)
11 SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
12ENDIF ()
13
14# Find dependencies
15FIND_PACKAGE(zlib REQUIRED)
16FIND_PACKAGE(OpenSSL REQUIRED)
17
18INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} src)
19
20# Collect sourcefiles
21FILE(GLOB SRC src/*.c)
22FILE(GLOB SRC_GIT src/git/*.c)
23FILE(GLOB SRC_SHA src/block-sha1/*.c)
24FILE(GLOB SRC_PLAT src/unix/*.c)
25FILE(GLOB SRC_H src/git/*.h)
26
27# On Windows use specific platform sources
28IF (WIN32)
29 ADD_DEFINITIONS(WIN32 _DEBUG _LIB ZLIB_WINAPI)
30 FILE(GLOB SRC_PLAT src/win32/*.c)
31ENDIF ()
32
33# TODO. PPC Detection for optimized sha1.
34
35# Compile and link libgit2
36ADD_LIBRARY(git2 ${SRC} ${SRC_GIT} ${SRC_SHA} ${SRC_PLAT})
37TARGET_LINK_LIBRARIES(git2 ${ZLIB_LIBRARY} ${OPENSSL_CRYPTO_LIBRARIES})
38
39# Install
40INSTALL(TARGETS git2
41 RUNTIME DESTINATION bin
42 LIBRARY DESTINATION lib
43 ARCHIVE DESTINATION lib
44)
45INSTALL(FILES ${SRC_H} DESTINATION include/git)
46
47# Tests
48IF (BUILD_TESTS)
49 # TODO. The Waf build generates *.toc files for each test which complicates things.
50ENDIF ()