tests: Add generating resolv.conf to torture
[obnox/cwrap/resolv_wrapper.git] / CMakeLists.txt
1 project(resolv_wrapper C)
2
3 # Required cmake version
4 cmake_minimum_required(VERSION 2.8.0)
5
6 # global needed variables
7 set(APPLICATION_NAME ${PROJECT_NAME})
8
9 set(APPLICATION_VERSION_MAJOR "1")
10 set(APPLICATION_VERSION_MINOR "0")
11 set(APPLICATION_VERSION_PATCH "0")
12
13 set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
14
15 # SOVERSION scheme: CURRENT.AGE.REVISION
16 #   If there was an incompatible interface change:
17 #     Increment CURRENT. Set AGE and REVISION to 0
18 #   If there was a compatible interface change:
19 #     Increment AGE. Set REVISION to 0
20 #   If the source code was changed, but there were no interface changes:
21 #     Increment REVISION.
22 set(LIBRARY_VERSION "0.0.0")
23 set(LIBRARY_SOVERSION "0")
24
25 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
26 set(CMAKE_MODULE_PATH
27   ${CMAKE_SOURCE_DIR}/cmake/Modules
28 )
29
30 # add definitions
31 include(DefineCMakeDefaults)
32 include(DefinePlatformDefaults)
33 include(DefineCompilerFlags)
34 include(DefineInstallationPaths)
35 include(DefineOptions.cmake)
36 include(CPackConfig.cmake)
37
38 # disallow in-source build
39 include(MacroEnsureOutOfSourceBuild)
40 macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
41
42 # Find out if we have threading available
43 set(CMAKE_THREAD_PREFER_PTHREADS ON)
44 find_package(Threads)
45
46 # config.h checks
47 include(ConfigureChecks.cmake)
48 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
49
50 # check subdirectories
51 add_subdirectory(src)
52
53 # pkg-config file
54 get_filename_component(RESOLV_WRAPPER_LIB ${RESOLV_WRAPPER_LOCATION} NAME)
55
56 configure_file(resolv_wrapper.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/resolv_wrapper.pc @ONLY)
57 install(
58   FILES
59     ${CMAKE_CURRENT_BINARY_DIR}/resolv_wrapper.pc
60   DESTINATION
61     ${LIB_INSTALL_DIR}/pkgconfig
62   COMPONENT
63     pkgconfig
64 )
65
66 # cmake config files
67 configure_file(resolv_wrapper-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/resolv_wrapper-config-version.cmake @ONLY)
68 configure_file(resolv_wrapper-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/resolv_wrapper-config.cmake @ONLY)
69 install(
70     FILES
71         ${CMAKE_CURRENT_BINARY_DIR}/resolv_wrapper-config-version.cmake
72         ${CMAKE_CURRENT_BINARY_DIR}/resolv_wrapper-config.cmake
73     DESTINATION
74         ${CMAKE_INSTALL_DIR}/resolv_wrapper
75     COMPONENT
76         devel
77 )
78
79 add_subdirectory(doc)
80 if (UNIT_TESTING)
81     find_package(CMocka REQUIRED)
82     include(AddCMockaTest)
83     add_subdirectory(tests)
84 endif (UNIT_TESTING)