1 # Copyright (c) 2009 Mike Arthur <mike@mikearthur.co.uk>
4 cmake_minimum_required(VERSION 2.6)
6 "${CMAKE_SOURCE_DIR}/cmake/modules"
7 "${CMAKE_SOURCE_DIR}/cmake/3rd-party-modules/opensync"
12 set(GCAL_VERSION_MAJOR 0)
13 set(GCAL_VERSION_MINOR 9)
14 set(GCAL_VERSION_PATCH 4)
16 ${GCAL_VERSION_MAJOR}.${GCAL_VERSION_MINOR}.${GCAL_VERSION_PATCH}
18 set(GCAL_VERSION_COUNT 3)
20 message(STATUS "Building ${PROJECT_NAME} ${GCAL_VERSION}")
22 set(LIB_SUFFIX "" CACHE STRING
23 "Define suffix of library directory name (e.g. 32/64 for lib32/lib64)"
26 option(ENABLE_TESTS "Build unit tests" ON)
27 option(CURL_DEBUG "Enable cURL debugging" OFF)
29 ADD_DEFINITIONS(-DGCAL_DEBUG_CURL)
32 find_package(CURL REQUIRED)
33 find_package(LibXml2 REQUIRED)
35 find_program(CTAGS etags)
36 find_program(DOXYGEN doxygen)
39 # Try and find GCOV for test coverage.
40 find_program(GCOV gcov)
42 "${CMAKE_C_FLAGS} -Wall -W -Wno-pointer-sign -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wbad-function-cast -Wcast-qual -Wno-pointer-sign"
46 set(GCAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
47 set(GCAL_HEADER_DIR "${CMAKE_SOURCE_DIR}/inc")
48 set(GCAL_TEST_DIR "${CMAKE_SOURCE_DIR}/utests")
50 set(GCAL_LIBRARY_INSTALL_DIR "lib${LIB_SUFFIX}")
51 set(GCAL_INCLUDE_INSTALL_DIR "include")
52 set(GCAL_CMAKE_MODULE_INSTALL_DIR "${CMAKE_ROOT}/Modules")
54 include(SetAutotoolsVariables)
56 add_custom_target(doc)
57 add_custom_target(docs)
58 add_dependencies(docs doc)
60 # Generate Doxygen Documentation
62 configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in Doxyfile @ONLY)
63 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/docs")
64 add_custom_target(doxygen ${DOXYGEN})
65 add_dependencies(doc doxygen)
68 # Generate pkg-config files
69 configure_file(${CMAKE_SOURCE_DIR}/libgcal.pc.in ${CMAKE_BINARY_DIR}/libgcal.pc @ONLY)
71 FILES "${CMAKE_BINARY_DIR}/libgcal.pc"
72 DESTINATION "${GCAL_LIBRARY_INSTALL_DIR}/pkgconfig"
76 # Generate CMake package configuration file
77 configure_file(${CMAKE_SOURCE_DIR}/cmake/LibGCalConfig.cmake.in ${CMAKE_BINARY_DIR}/cmake/LibGCalConfig.cmake @ONLY)
78 # TODO: Install this to ${GCAL_LIBRARY_INSTALL_DIR}/cmake/LibGCal when we
79 # depend on CMake >= 2.6.3
81 FILES "${CMAKE_BINARY_DIR}/cmake/LibGCalConfig.cmake"
82 DESTINATION "${GCAL_LIBRARY_INSTALL_DIR}/LibGCal/cmake"
86 add_custom_target(tags
87 COMMAND ${CTAGS} ${GCAL_SOURCE_DIR}/*.c ${GCAL_HEADER_DIR}/*.h ${GCAL_TEST_DIR}/*.?
94 ${LIBXML2_INCLUDE_DIR}
97 # If we've found GCov then add the necessary profiling flags.
100 "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage"
104 add_subdirectory(${GCAL_SOURCE_DIR})
107 add_subdirectory(${GCAL_TEST_DIR})
110 # Install header files
112 DIRECTORY "${GCAL_HEADER_DIR}/"
113 DESTINATION "${GCAL_INCLUDE_INSTALL_DIR}"
114 FILES_MATCHING PATTERN "*.h"
119 "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
120 "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
123 add_custom_target(uninstall
124 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
129 set(PROJECT_VERSION ${GCAL_VERSION})
130 set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
131 add_custom_target(dist
132 COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
133 | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
134 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})