]>
Commit | Line | Data |
---|---|---|
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 | |
4 | PROJECT(libgit2 C) | |
5 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) | |
6 | ||
7 | # Sane defaults | |
8 | OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON) | |
9 | OPTION (BUILD_TESTS "Build Tests" ON) | |
10 | IF (NOT CMAKE_BUILD_TYPE) | |
11 | SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) | |
12 | ENDIF () | |
13 | ||
14 | # Find dependencies | |
15 | FIND_PACKAGE(zlib REQUIRED) | |
16 | FIND_PACKAGE(OpenSSL REQUIRED) | |
17 | ||
18 | INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} src) | |
19 | ||
20 | # Collect sourcefiles | |
21 | FILE(GLOB SRC src/*.c) | |
22 | FILE(GLOB SRC_GIT src/git/*.c) | |
23 | FILE(GLOB SRC_SHA src/block-sha1/*.c) | |
24 | FILE(GLOB SRC_PLAT src/unix/*.c) | |
25 | FILE(GLOB SRC_H src/git/*.h) | |
26 | ||
27 | # On Windows use specific platform sources | |
28 | IF (WIN32) | |
29 | ADD_DEFINITIONS(WIN32 _DEBUG _LIB ZLIB_WINAPI) | |
30 | FILE(GLOB SRC_PLAT src/win32/*.c) | |
31 | ENDIF () | |
32 | ||
33 | # TODO. PPC Detection for optimized sha1. | |
34 | ||
35 | # Compile and link libgit2 | |
36 | ADD_LIBRARY(git2 ${SRC} ${SRC_GIT} ${SRC_SHA} ${SRC_PLAT}) | |
37 | TARGET_LINK_LIBRARIES(git2 ${ZLIB_LIBRARY} ${OPENSSL_CRYPTO_LIBRARIES}) | |
38 | ||
39 | # Install | |
40 | INSTALL(TARGETS git2 | |
41 | RUNTIME DESTINATION bin | |
42 | LIBRARY DESTINATION lib | |
43 | ARCHIVE DESTINATION lib | |
44 | ) | |
45 | INSTALL(FILES ${SRC_H} DESTINATION include/git) | |
46 | ||
47 | # Tests | |
48 | IF (BUILD_TESTS) | |
49 | # TODO. The Waf build generates *.toc files for each test which complicates things. | |
50 | ENDIF () |