summaryrefslogtreecommitdiff
path: root/src/components/utils/CMakeLists.txt
blob: e48f1e48d71592b5c16a3a719d16578174a83d9e (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# Copyright (c) 2016, Ford Motor Company
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the
# distribution.
#
# Neither the name of the Ford Motor Company nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake)
include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)

include_directories (
  ${COMPONENTS_DIR}/utils/include
  ${COMPONENTS_DIR}/config_profile/include
  ${COMPONENTS_DIR}/media_manager/include
  ${COMPONENTS_DIR}/protocol_handler/include
  ${JSONCPP_INCLUDE_DIRECTORY}
  ${LOG4CXX_INCLUDE_DIRECTORY}
  ${BOOST_INCLUDE_DIR}
  ${CMAKE_SOURCE_DIR}/src
)
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
    include_directories(${SQLITE_INCLUDE_DIRECTORY})
endif ()

# dbms
set(DBMS_PATHS
  ${CMAKE_CURRENT_SOURCE_DIR}/include/utils/sqlite_wrapper
  ${CMAKE_CURRENT_SOURCE_DIR}/src/sqlite_wrapper
  ${CMAKE_CURRENT_SOURCE_DIR}/include/utils/qdb_wrapper
  ${CMAKE_CURRENT_SOURCE_DIR}/src/qdb_wrapper
)

set(EXCLUDE_PATHS
  thread_manager.cc
  pulse_thread_delegate.cc
  ${DBMS_PATHS}
)

set(LIBRARIES
  encryption
  jsoncpp
)

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
    list(APPEND LIBRARIES sqlite_static)
else()
    find_package(Sqlite3 REQUIRED)
endif ()

if(NOT BUILD_BACKTRACE_SUPPORT)
  list(APPEND EXCLUDE_PATHS
    back_trace.cc
  )
endif()

if (ENABLE_LOG)
  if(ANDROID)
    list(APPEND EXCLUDE_PATHS
    logger/log4cxxlogger.cc
    )
  elseif(${LOGGER_NAME} STREQUAL "LOG4CXX")
    list(APPEND EXCLUDE_PATHS
      logger/boostlogger.cc
    )
    list(APPEND LIBRARIES
    log4cxx -L${LOG4CXX_LIBS_DIRECTORY}
      apr-1 -L${APR_LIBS_DIRECTORY}
      aprutil-1 -L${APR_UTIL_LIBS_DIRECTORY}
    ConfigProfile
    )
  else()
    list(APPEND EXCLUDE_PATHS
      logger/log4cxxlogger.cc
    )
  endif()
else()
  list(APPEND EXCLUDE_PATHS
    auto_trace.cc
    logger/log4cxxlogger.cc
    logger/boostlogger.cc
  )
endif() #(ENABLE_LOG)

if(NOT BUILD_BT_SUPPORT)
  list(APPEND EXCLUDE_PATHS
    ${CMAKE_CURRENT_SOURCE_DIR}/include/utils/bluetooth
    ${CMAKE_CURRENT_SOURCE_DIR}/src/bluetooth
  )
endif()

if (NOT CMAKE_SYSTEM_NAME STREQUAL "QNX")
    list(APPEND EXCLUDE_PATHS
      pulse_thread_delegate.cc
    )
endif()

set(PATHS
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${CMAKE_CURRENT_SOURCE_DIR}/src
)

collect_sources(SOURCES "${PATHS}" "${EXCLUDE_PATHS}")

if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
    # --- QDB Wrapper
    add_subdirectory(./src/qdb_wrapper)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
    # --- SQLite Wrapper
    add_subdirectory(./src/sqlite_wrapper)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Android")
    # --- SQLite Wrapper
    add_subdirectory(./src/sqlite_wrapper)
endif ()

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 list(APPEND LIBRARIES dl pthread ${RTLIB})
endif()

add_library("Utils" ${SOURCES})
GET_PROPERTY(BOOST_LIBS_DIRECTORY GLOBAL PROPERTY GLOBAL_BOOST_LIBS)
list(APPEND LIBRARIES boost_system -L${BOOST_LIBS_DIRECTORY})
list(APPEND LIBRARIES boost_thread -L${BOOST_LIBS_DIRECTORY})
list(APPEND LIBRARIES boost_date_time -L${BOOST_LIBS_DIRECTORY})
list(APPEND LIBRARIES boost_filesystem -L${BOOST_LIBS_DIRECTORY})
if (ENABLE_LOG AND ${LOGGER_NAME} STREQUAL "BOOST")
  list(APPEND LIBRARIES boost_log_setup -L${BOOST_LIBS_DIRECTORY})
  list(APPEND LIBRARIES boost_log -L${BOOST_LIBS_DIRECTORY})
endif ()
list(APPEND LIBRARIES boost_regex -L${BOOST_LIBS_DIRECTORY})
target_link_libraries("Utils" ${LIBRARIES})
add_dependencies("Utils" Boost)

if(ANDROID)
target_link_libraries("Utils"
                      android 
                      log)
endif()

if(ENABLE_LOG AND NOT ANDROID)
  if (${LOGGER_NAME} STREQUAL "LOG4CXX")
    add_dependencies("Utils" install-3rd_party_logger Boost)
  else()
    add_dependencies("Utils" Boost)
  endif()
endif()

if(BUILD_TESTS)
  add_subdirectory(test)
endif()

install(TARGETS "Utils"
  DESTINATION bin
  PERMISSIONS
    OWNER_READ OWNER_WRITE
    GROUP_READ
    WORLD_READ
)