APPLINK-6593:
[profile/ivi/smartdevicelink.git] / src / appMain / CMakeLists.txt
1 IF (${WEB_HMI})
2 set (BROKER_LIBRARIES
3   MessageBrokerClient
4   MessageBrokerServer
5 )
6 ENDIF (${WEB_HMI})
7
8
9 if (EXTENDED_MEDIA_MODE)
10 set(default_media_inc
11 ${GSTREAMER_gst_INCLUDE_DIR}
12 )
13 else(EXTENDED_MEDIA_MODE)
14 set(default_media_inc
15 )
16 endif()
17
18 set(LIBRARIES
19   ApplicationManager
20   HMI_API
21   MOBILE_API
22   v4_protocol_v1_2_no_extra
23   SmartObjects
24   formatters
25   ProtocolHandler
26   connectionHandler
27   TransportManager
28   HMIMessageHandler
29   MessageBroker  
30   ${BROKER_LIBRARIES}
31   Utils
32   encryption
33   jsoncpp
34   ConfigProfile
35   RequestWatchdog
36   MediaManager
37   Resumption
38   apr-1
39   aprutil-1
40 )
41
42 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
43   list(APPEND LIBRARIES pthread)
44   list(APPEND LIBRARIES dl)
45 endif()
46
47 if (BUILD_BT_SUPPORT)
48         list(APPEND LIBRARIES bluetooth)
49 endif()
50 if (BUILD_AVAHI_SUPPORT)
51         list(APPEND LIBRARIES avahi-client avahi-common)
52 endif()
53 if (BUILD_USB_SUPPORT)
54   cmake_policy(PUSH)
55   # make link_directories() treat paths relative to the source dir
56   # info: cmake --help-policy CMP0015
57   cmake_policy(SET CMP0015 NEW)
58   link_directories(../thirdPartyLibs/libusbx)
59   cmake_policy(POP)
60 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
61   list(APPEND LIBRARIES Libusb-1.0.16)
62 endif()
63 endif()
64
65 include_directories (
66   ./
67   ../components/protocol_handler/include/
68   ../thirdPartyLibs/jsoncpp/include/
69   ../components/application_manager/include
70   ../components/formatters/include
71   ../components/transport_manager/include
72   ../components/config_profile/include
73   ../components/utils/include/
74   ../components/connection_handler/include/
75   ../components/hmi_message_handler/include
76   ../components/request_watchdog/include
77   ../components/smart_objects/include/
78   ../components/media_manager/include/
79   ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/include/
80   ../components/resumption/include/
81   ../thirdPartyLibs/MessageBroker/include
82   ../thirdPartyLibs/encryption/include
83   ${CMAKE_SOURCE_DIR}/src/components/
84   ${CMAKE_BINARY_DIR}/src/components/
85   ${CMAKE_SOURCE_DIR}/src/components/dbus/include/
86   ${CMAKE_SOURCE_DIR}
87   ${default_media_inc}
88 )
89
90 set (SOURCES
91   main.cc
92   life_cycle.cc
93 )
94
95 if( NOT CMAKE_BUILD_TYPE )
96   set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build. Options are: None, Debug, Release, RelWithDebInfo, MinSizeRel." FORCE)
97 endif()
98
99 add_executable(${PROJECT} ${SOURCES})
100 target_link_libraries(${PROJECT} ${LIBRARIES})
101
102 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
103 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/audio.8bit.wav DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
104 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
105 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/smartDeviceLink.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
106 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/policy_table.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
107 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/hmi_capabilities.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
108 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/sdl_preloaded_pt.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
109
110 if (BUILD_TESTS)
111   file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx.properties DESTINATION ${CMAKE_BINARY_DIR}/test/)
112   file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/smartDeviceLink.ini DESTINATION ${CMAKE_BINARY_DIR}/test/)
113 endif()
114
115 if (${QT_HMI})
116   set(main_qml "hmi/MainWindow.qml")
117   set(plugins_dir "hmi/plugins")
118
119   if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
120     set(start_command "./start-qml.sh")
121     set(command_arguments "${main_qml} ${plugins_dir}")
122   else ()
123     execute_process(
124       COMMAND ${CMAKE_SOURCE_DIR}/FindQt.sh -v ${qt_version} -b qmlscene
125       OUTPUT_VARIABLE start_command
126     )
127     set(command_arguments "${main_qml} -I ${plugins_dir}")
128   endif ()
129
130   file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/start_hmi.sh
131     "#!/bin/sh\n${start_command} ${command_arguments}\n")
132 elseif (${WEB_HMI})
133   file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/hmi_link
134     "${CMAKE_HOME_DIRECTORY}/src/components/HMI/index.html")
135 endif ()
136
137 # Install rules
138 install(TARGETS ${PROJECT} DESTINATION bin)
139 install(
140   FILES log4cxx.properties audio.8bit.wav test.txt smartDeviceLink.ini policy_table.json
141     hmi_capabilities.json sdl_preloaded_pt.json
142   DESTINATION bin
143 )
144 if (${WEB_HMI})
145   if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
146     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hmi_link DESTINATION bin)
147   endif ()
148 elseif (${QT_HMI})
149   if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
150     install(FILES start-qml.sh DESTINATION bin
151       PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
152         GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
153   endif ()
154   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/start_hmi.sh DESTINATION bin
155     PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
156       GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
157 endif ()