Set the preferred address entry (gd:structuredPostalAddress).
[libgcal.git] / CMakeLists.txt
blobbb4235e5deaccb2558121418bab0acdc63318973
1 # Copyright (c) 2009 Mike Arthur <mike@mikearthur.co.uk>
3 project("LibGCal" C)
4 cmake_minimum_required(VERSION 2.6)
5 set(CMAKE_MODULE_PATH
6         "${CMAKE_SOURCE_DIR}/cmake/modules"
7         "${CMAKE_SOURCE_DIR}/cmake/3rd-party-modules/opensync"
10 include(SetBuildType)
12 set(GCAL_VERSION_MAJOR 0)
13 set(GCAL_VERSION_MINOR 9)
14 set(GCAL_VERSION_PATCH 4)
15 set(GCAL_VERSION
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)
28 if(CURL_DEBUG)
29   ADD_DEFINITIONS(-DGCAL_DEBUG_CURL)
30 endif()
32 find_package(CURL REQUIRED)
33 find_package(LibXml2 REQUIRED)
35 find_program(CTAGS etags)
36 find_program(DOXYGEN doxygen)
38 if(CMAKE_DEBUG_BUILD)
39         # Try and find GCOV for test coverage.
40         find_program(GCOV gcov)
41         set(CMAKE_C_FLAGS
42                 "${CMAKE_C_FLAGS} -Wall -W -Wno-pointer-sign -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wbad-function-cast -Wcast-qual -Wno-pointer-sign"
43         )
44 endif()
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
61 if(DOXYGEN)
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)
66 endif()
68 # Generate pkg-config files
69 configure_file(${CMAKE_SOURCE_DIR}/libgcal.pc.in ${CMAKE_BINARY_DIR}/libgcal.pc @ONLY)
70 install(
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
80 install(
81         FILES "${CMAKE_BINARY_DIR}/cmake/LibGCalConfig.cmake"
82         DESTINATION "${GCAL_LIBRARY_INSTALL_DIR}/LibGCal/cmake"
85 if(CTAGS)
86         add_custom_target(tags
87                 COMMAND ${CTAGS} ${GCAL_SOURCE_DIR}/*.c ${GCAL_HEADER_DIR}/*.h ${GCAL_TEST_DIR}/*.?
88         )
89 endif()
91 include_directories(
92         ${GCAL_HEADER_DIR}
93         ${CURL_INCLUDE_DIRS}
94         ${LIBXML2_INCLUDE_DIR}
97 # If we've found GCov then add the necessary profiling flags.
98 if(GCOV)
99         set(CMAKE_C_FLAGS
100                 "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage"
101         )
102 endif()
104 add_subdirectory(${GCAL_SOURCE_DIR})
106 if(ENABLE_TESTS)
107         add_subdirectory(${GCAL_TEST_DIR})
108 endif()
110 # Install header files
111 install(
112         DIRECTORY "${GCAL_HEADER_DIR}/"
113         DESTINATION "${GCAL_INCLUDE_INSTALL_DIR}"
114         FILES_MATCHING PATTERN "*.h"
117 # Add uninstall
118 configure_file(
119         "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
120         "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
121         IMMEDIATE @ONLY
123 add_custom_target(uninstall
124         "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
128 # Make dist
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})