More cleanup of cmake build files
[oonf.git] / CMakeLists.txt
1 project (OONF C)
2 cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
3
4 ###########################
5 #### API configuration ####
6 ###########################
7
8 # set cached variables
9 include (./cmake/lib_config.cmake)
10
11 # include compiler flags
12 include (./cmake/cc_flags.cmake)
13
14 ########################
15 #### Doxygen target ####
16 ########################
17
18 find_package(Doxygen)
19 if(DOXYGEN_FOUND)
20     configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/files/framework.doxyfile.in
21         ${CMAKE_CURRENT_BINARY_DIR}/framework.doxyfile @ONLY)
22     add_custom_target(doc
23         ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/framework.doxyfile
24         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
25         COMMENT "Generating API documentation with Doxygen" VERBATIM
26     )
27 endif(DOXYGEN_FOUND)
28
29 ########################################
30 #### get repository tag and version ####
31 ########################################
32
33 include (cmake/get_version.cmake)
34 IF(EXISTS "${PROJECT_BINARY_DIR}/version.cmake")
35   include (${PROJECT_BINARY_DIR}/version.cmake)
36 ENDIF()
37
38 #############################
39 #### add tarball targets ####
40 #############################
41
42 ADD_CUSTOM_TARGET(targz  COMMAND ${CMAKE_COMMAND}
43                                  -D SOURCE:STRING=${CMAKE_SOURCE_DIR}
44                                  -D BINARY:STRING=${PROJECT_BINARY_DIR}
45                                  -D VERSION:STRING=${VERSION}
46                                  -D FORMAT:STRING=tar.gz
47                                  -P ${CMAKE_SOURCE_DIR}/cmake/generate_archive.cmake)
48                                 
49 ADD_CUSTOM_TARGET(tarbz2 COMMAND ${CMAKE_COMMAND}
50                                  -D SOURCE:STRING=${CMAKE_SOURCE_DIR}
51                                  -D BINARY:STRING=${PROJECT_BINARY_DIR}
52                                  -D VERSION:STRING=${VERSION}
53                                  -D FORMAT:STRING=tar.bz2
54                                  -P ${CMAKE_SOURCE_DIR}/cmake/generate_archive.cmake)
55 ADD_CUSTOM_TARGET(zip    COMMAND ${CMAKE_COMMAND}
56                                  -D SOURCE:STRING=${CMAKE_SOURCE_DIR}
57                                  -D BINARY:STRING=${PROJECT_BINARY_DIR}
58                                  -D VERSION:STRING=${VERSION}
59                                  -D FORMAT:STRING=zip
60                                  -P ${CMAKE_SOURCE_DIR}/cmake/generate_archive.cmake)
61
62 #########################
63 #### Compile targets ####
64 #########################
65
66 # add define for length of base path
67 string(LENGTH "${CMAKE_SOURCE_DIR}/" BASELENGTH)
68 add_definitions(-DBASEPATH_LENGTH=${BASELENGTH})
69
70 # include build helper
71 include (cmake/declare_library.cmake)
72
73 # include files
74 include_directories(${PROJECT_BINARY_DIR})
75 include_directories(src-api)
76
77 if (NOT OONF_NO_TESTING)
78     ENABLE_TESTING()
79 endif (NOT OONF_NO_TESTING)
80
81 # define static and dynamic target
82 add_custom_target(static)
83 add_custom_target(dynamic)
84
85 # start compiling core and plugins
86 add_subdirectory(src-api)
87 add_subdirectory(src-plugins)
88 # add_subdirectory(examples)
89 add_subdirectory(src)
90
91 if (NOT OONF_NO_TESTING)
92     add_subdirectory(tests)
93 endif (NOT OONF_NO_TESTING)