Add sound manager initial source code
[staging/soundmanager.git] / libsoundmanager / CMakeLists.txt
1 #
2 # Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17
18 cmake_minimum_required(VERSION 3.0)
19
20 set(TARGET_LIBSM soundmanager)
21 add_definitions("-std=c++11")
22
23 pkg_check_modules(libsm_depends  json-c libafbwsc libsystemd audiomanager)
24 set(libsm_sources libsoundmanager.cpp)
25
26 include_directories(${LIBSM_INCLUDE_DIR})
27 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
28
29 add_library(${TARGET_LIBSM} SHARED ${libsm_sources})
30 target_compile_options(${TARGET_LIBSM} PUBLIC ${libsm_depends_CFLAGS})
31
32 if(DEFINED DEBUGMODE)
33  target_compile_options(${TARGET_LIBSM} PRIVATE -g -O0)
34 else(DEFINED DEBUGMODE)
35  target_compile_options(${TARGET_LIBSM} PRIVATE -g -O2)
36 endif(DEFINED DEBUGMODE)
37
38 include_directories(${TARGET_LIBSM} ${libsm_depends_INCLUDE_DIRS})
39 target_link_libraries(${TARGET_LIBSM} afbwsc -lpthread ${link_libraries} ${libsm_depends_LIBRARIES})
40
41 INSTALL(TARGETS ${TARGET_LIBSM}
42     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
43
44 #####################
45 pkg_check_modules(test_depends glib-2.0 gio-2.0 gio-unix-2.0)
46 add_executable(libsoundmanager-demo test.cpp)
47 include_directories(libsoundmanager-demo ${test_depends_INCLUDE_DIRS})
48 TARGET_LINK_LIBRARIES(libsoundmanager-demo
49     soundmanager
50     ${link_libraries}
51     -lpthread
52     ${test_depends_LIBRARIES}
53     ${libsm_depends_LIBRARIES}
54 )
55 #####################
56 add_subdirectory(test)
57