pull in new policy updates
[profile/ivi/smartdevicelink.git] / src / components / policy / src / policy / CMakeLists.txt
1 # Copyright (c) 2013, Ford Motor Company
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 #
7 # Redistributions of source code must retain the above copyright notice, this
8 # list of conditions and the following disclaimer.
9 #
10 # Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following
12 # disclaimer in the documentation and/or other materials provided with the
13 # distribution.
14 #
15 # Neither the name of the Ford Motor Company nor the names of its contributors
16 # may be used to endorse or promote products derived from this software
17 # without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30
31 set(target Policy)
32 set(install_destination bin)
33 set(copy_destination ${CMAKE_BINARY_DIR}/src/appMain)
34 set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX})
35
36 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
37
38 if (EXTENDED_POLICY_FLAG)
39   add_definitions(-DEXTENDED_POLICY)
40 endif()
41
42 #Generation of policy table interface...
43 #include(${CMAKE_SOURCE_DIR}/tools/intergen/GenerateInterfaceLibrary.cmake)
44
45 include_directories (
46   ./include
47   ./usage_statistics/include
48   ${CMAKE_SOURCE_DIR}/src/components/rpc_base/include
49   ${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/jsoncpp/include
50   #${CMAKE_CURRENT_BINARY_DIR}
51   ${CMAKE_SOURCE_DIR}/src/components/utils/include/
52   ${CMAKE_SOURCE_DIR}/src/components/config_profile/include
53 )
54
55 set(SOURCES
56   ./src/policy_manager_impl.cc
57   ./src/policy_helper.cc
58   ./src/policy_table.cc
59   ./src/sql_pt_queries.cc
60   ./src/sql_pt_representation.cc
61 )
62
63 if (EXTENDED_POLICY_FLAG)
64   list(APPEND SOURCES
65     ./src/sql_pt_ext_queries.cc
66     ./src/sql_pt_ext_representation.cc
67   )
68 endif ()
69
70 add_subdirectory(usage_statistics)
71
72 if (EXTENDED_POLICY_FLAG)
73 add_subdirectory(policy_table/table_struct_ext)
74 include_directories(./policy_table/table_struct_ext)
75 else ()
76 include_directories(./policy_table/table_struct)
77 add_subdirectory(policy_table/table_struct)
78 endif()
79
80 set(LIBRARIES ConfigProfile policy_struct dbms jsoncpp Utils)
81 if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
82   # --- QDB Wrapper
83   include_directories (qdb_wrapper/include)
84   add_subdirectory(qdb_wrapper)
85 else ()
86   # --- SQLite Wrapper
87   include_directories (sqlite_wrapper/include)
88   add_subdirectory(sqlite_wrapper)
89   list(APPEND LIBRARIES sqlite3)
90 endif ()
91
92 add_library(${target} SHARED ${SOURCES})
93 target_link_libraries(${target} ${LIBRARIES} )
94
95 if(ENABLE_LOG)
96   add_dependencies(${target} liblog4cxx)
97   target_link_libraries(${target} log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
98 endif()
99
100 add_custom_target(copy_library_${target} ALL
101   COMMAND ${CMAKE_COMMAND} -E copy_if_different
102     ${CMAKE_CURRENT_BINARY_DIR}/${library_name}
103     ${copy_destination}
104     DEPENDS ${target}
105     COMMENT "Copying library ${library_name}")
106
107 if (BUILD_TESTS_WITH_HMI)
108   add_custom_target(test_copy_library_${target} ALL
109     COMMAND ${CMAKE_COMMAND} -E copy_if_different
110       ${CMAKE_CURRENT_BINARY_DIR}/${library_name}
111       ${CMAKE_BINARY_DIR}/test/
112       DEPENDS ${target}
113       COMMENT "Copying library ${library_name}")
114 endif(BUILD_TESTS_WITH_HMI)
115
116 install(TARGETS ${target}
117   DESTINATION ${install_destination}
118   PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
119     GROUP_READ GROUP_EXECUTE
120     WORLD_READ WORLD_EXECUTE
121 )