-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
98 lines (74 loc) · 2.49 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
cmake_minimum_required(VERSION 2.8)
project(odbxuv C)
find_package(PkgConfig)
if(${PKG_CONFIG_FOUND})
message(STATUS "Using pkg-config to detect opendbx...")
pkg_check_modules(OPENDBX opendbx)
if(OPENDBX_FOUND)
message(STATUS "Found Opendbx.")
message(STATUS "include: ${OPENDBX_INCLUDE_DIRS}")
else()
message(WARNING "opendbx not found. No database support!")
endif()
else()
set(OPENDBX_LIBRARIES opendbx)
find_path(OPENDBX_INCLUDE_DIRS odbx.h)
find_library(OPENDBX_LIBRARY_DIRS ${OPENDBX_LIBRARIES})
endif()
include_directories(${OPENDBX_INCLUDE_DIRS})
link_directories(${OPENDBX_LIBRARY_DIRS})
option(HAVE_LOCAL_LIBUV 0)
if(${HAVE_LOCAL_LIBUV})
add_subdirectory(libraries/uv)
endif()
set(ODBXUV_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
${OPENDBX_INCLUDE_DIRS}
${UV_INCLUDE_DIRS}
CACHE INTERNAL "Odbxuv include directories")
set(ODBXUV_LIBRARY
"odbxuv"
CACHE INTERNAL "Odbxuv library name")
set(ODBXUV_LIBRARIES
${ODBXUV_LIBRARY}
${OPENDBX_LIBRARIES}
CACHE INTERNAL "Odbxuv libraries")
set(ODBXUV_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/db.c)
set(ODBXUV_MODE "STATIC")
include_directories(${ODBXUV_INCLUDE_DIRS})
add_library(${ODBXUV_LIBRARY} ${ODBXUV_MODE}
${ODBXUV_SOURCES})
target_link_libraries(${ODBXUV_LIBRARIES} ${OPENDBX_LIBRARIES})
set(ODBXUV_BUILD_TESTS 1)
if(${ODBXUV_BUILD_TESTS})
add_executable(${ODBXUV_LIBRARY}_tests
${CMAKE_CURRENT_SOURCE_DIR}/test/db_test.c)
target_link_libraries(
${ODBXUV_LIBRARY}_tests
${ODBXUV_LIBRARIES}
${UV_LIBRARIES})
if(NOT DEFINED INSTALL_RUNTIME_DIR)
set(INSTALL_RUNTIME_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
install(TARGETS
${ODBXUV_LIBRARY}_tests
RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR})
endif()
find_package(Doxygen)
if(DOXYGEN_FOUND)
message("-- Adding doc target using doxygen.")
if(NOT DEFINED INSTALL_DOC_DIR)
set(INSTALL_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
endif()
file(MAKE_DIRECTORY ${INSTALL_DOC_DIR})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
add_custom_target(doc_odbxuv
${DOXYGEN_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM)
set(ODBXUV_HAVE_DOCS 1 CACHE INTERNAL "Have odbxuv documentation")
endif(DOXYGEN_FOUND)