-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
92 lines (65 loc) · 2.36 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
cmake_minimum_required(VERSION 3.2)
set(NLAUDIO_VERSION_MAJOR 1)
set(NLAUDIO_VERSION_MINOR 0)
set(NLAUDIO_VERSION_PATCH 0)
set(NLAUDIO_VERSION_STRING ${NLAUDIO_VERSION_MAJOR}.${NLAUDIO_VERSION_MINOR}.${NLAUDIO_VERSION_PATCH})
project(nlaudio VERSION ${NLAUDIO_VERSION_STRING})
option(BUILD_EXAMPLES "Build Examples" ON)
include(FindPkgConfig)
set(LIBS alsa jack)
find_package(Threads) # pthread
####################
function(addLib name)
pkg_check_modules(${name} REQUIRED ${name})
include_directories(${${name}_INCLUDE_DIRS})
link_directories(${${name}_LIBRARY_DIRS})
endfunction(addLib)
function(linkLib name target)
pkg_check_modules(${name} REQUIRED ${name})
target_link_libraries(${target} ${${name}_LIBRARIES})
endfunction(linkLib)
################## libnlaudio
set(LIBRARY_INCLUDE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/nlaudio)
include_directories(${LIBRARY_INCLUDE_DIRECTORY})
## target headers is for qt creator, so we get headers in project
#FILE(GLOB_RECURSE NLAUDIO_HEADERS "${LIBRARY_INCLUDE_DIRECTORY}/*")
#add_custom_target(headers SOURCES ${NLAUDIO_HEADERS})
file(GLOB_RECURSE LIBRARY_SOURCES src/*)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
add_library(nlaudio SHARED ${LIBRARY_SOURCES})
set_target_properties(nlaudio PROPERTIES VERSION ${NLAUDIO_VERSION_STRING} SOVERSION ${NLAUDIO_VERSION_MAJOR})
foreach(lib ${LIBS})
addLib(${lib})
endforeach(lib)
foreach(lib ${LIBS})
linkLib(${lib} nlaudio)
endforeach(lib)
add_compile_options(-Wall)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>)
######################
if (${BUILD_EXAMPLES})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples)
endif()
###################
# Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/doxyconfig ${CMAKE_CURRENT_BINARY_DIR}/doxyconfig @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxyconfig
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
#############
# Install
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if ("${LIB64}" STREQUAL "TRUE")
set(LIBSUFFIX 64)
else()
set(LIBSUFFIX "")
endif()
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/nlaudio DESTINATION include)
INSTALL(TARGETS nlaudio
LIBRARY DESTINATION lib COMPONENT libraries
)