* Bug 61 fixed. The plugins are built as module and SOVERSION is removed.
[profile/ivi/genivi/genivi-audio-manager.git] / PluginCommandInterfaceDbus / CMakeLists.txt
1 # Copyright (c) 2012 BMW
2 #
3 # author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
4 #
5 # copyright
6 # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
7 # including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
8 # subject to the following conditions:
9 # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
12 # THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13 #
14 # For further information see http://www.genivi.org/.
15 #
16
17 cmake_minimum_required(VERSION 2.6)
18
19 PROJECT(PluginCommandInterfaceDbus)
20
21 OPTION (WITH_COMMAND_INTERFACE_DBUS
22         "build with commandinterface dbus plugin" ON )
23
24 IF (WITH_COMMAND_INTERFACE_DBUS)
25
26 set(LIBRARY_OUTPUT_PATH ${PLUGINS_OUTPUT_PATH}/command)
27 set(DOC_OUTPUT_PATH ${DOC_OUTPUT_PATH}/CommandDBusPlugin)
28 set(INCLUDE_FOLDER "include")
29 message(STATUS "prefix ${CMAKE_INSTALL_PREFIX}")
30 SET(SHARED_FOLDER "${CMAKE_INSTALL_PREFIX}/share")
31
32 FILE(READ "${AUDIO_INCLUDE_FOLDER}/command/IAmCommandSend.h" VERSION_BUFFER LIMIT 6000)
33 STRING(REGEX MATCH "CommandSendVersion*.[^0-9]*[0-9].[0-9]*[0-9]" LIB_INTERFACE_VERSION_STRING ${VERSION_BUFFER})
34 STRING(REGEX REPLACE "CommandSendVersion*.." "" LIB_INTERFACE_VERSION ${LIB_INTERFACE_VERSION_STRING})
35 MESSAGE(STATUS "Building against command interface version ${LIB_INTERFACE_VERSION}")
36
37 IF(USE_BUILD_LIBS) 
38     SET(COMMAND_DBUS_INTROSPECTION_FOLDER ${EXECUTABLE_OUTPUT_PATH})
39     SET(COMMAND_DBUS_INTROSPECTION_FILE ${EXECUTABLE_OUTPUT_PATH}/CommandInterface.xml)
40 ELSE(USE_BUILD_LIBS) 
41     SET(COMMAND_DBUS_INTROSPECTION_FOLDER ${SHARED_FOLDER}/audiomanager)
42     SET(COMMAND_DBUS_INTROSPECTION_FILE ${SHARED_FOLDER}/audiomanager/CommandInterface.xml)
43 ENDIF(USE_BUILD_LIBS)
44
45 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake ${CMAKE_CURRENT_SOURCE_DIR}/include/configCommandDbus.h )
46
47 FIND_PACKAGE(DBUS REQUIRED)
48
49 INCLUDE_DIRECTORIES(
50         ${CMAKE_SOURCE_DIR} 
51         ${CMAKE_CURRENT_BINARY_DIR}
52         ${DBUS_INCLUDE_DIR}
53         ${DBUS_ARCH_INCLUDE_DIR}
54         ${AUDIO_INCLUDE_FOLDER}
55         ${PROJECT_INCLUDE_FOLDER}
56         ${DLT_INCLUDE_DIRS}
57         ${INCLUDE_FOLDER}
58 )
59
60 # all source files go here
61 file(GLOB PLUGINDBUS_SRCS_CXX "src/*.cpp")
62
63 add_library(PluginCommandInterfaceDbus MODULE ${PLUGINDBUS_SRCS_CXX})
64
65 TARGET_LINK_LIBRARIES(PluginCommandInterfaceDbus 
66     ${DLT_LIBRARIES}
67     ${DBUS_LIBRARY}
68 )
69
70 IF(WITH_TESTS)
71         add_subdirectory (test)
72 ENDIF(WITH_TESTS)
73
74 #IF(WITH_DOCUMENTATION)
75 #       file(MAKE_DIRECTORY ${DOC_OUTPUT_PATH})
76 #       configure_file(${DOXY_FILE}  ${DOC_OUTPUT_PATH}/Doxyfile  @ONLY IMMEDIATE)
77 #       add_custom_target (PluginInterfaceDBusDocs ALL 
78 #               COMMAND ${DOXYGEN_EXECUTABLE} ${DOC_OUTPUT_PATH}/Doxyfile WORKING_DIRECTORY ${DOC_OUTPUT_PATH}
79 #               SOURCES ${PROJECT_BINARY_DIR} ${DOC_OUTPUT_PATH}/Doxyfile
80 #       )
81 #ENDIF(WITH_DOCUMENTATION)
82
83 INSTALL(TARGETS PluginCommandInterfaceDbus 
84         DESTINATION "lib/${LIB_INSTALL_SUFFIX}/command"
85         PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
86         COMPONENT sampleplugins
87 )
88
89 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/CommandInterface.xml 
90         DESTINATION "${COMMAND_DBUS_INTROSPECTION_FOLDER}"
91         COMPONENT sampleplugins
92 )
93
94 IF(USE_BUILD_LIBS) 
95     execute_process(
96             COMMAND mkdir -p "${CMAKE_SOURCE_DIR}/bin"
97             COMMAND cp "${CMAKE_SOURCE_DIR}/PluginCommandInterfaceDbus/${INCLUDE_FOLDER}/CommandInterface.xml" ${EXECUTABLE_OUTPUT_PATH}/CommandInterface.xml)
98 ENDIF(USE_BUILD_LIBS) 
99
100 SET(ADD_DEPEND "audiomanager-bin" "dlt" "libdbus-1-3(>=1.2.16)")
101 set_property(GLOBAL APPEND PROPERTY sampleplugins_prop "${ADD_DEPEND}")
102
103 ENDIF (WITH_COMMAND_INTERFACE_DBUS)