xref: /aosp_15_r20/external/parameter-framework/upstream/CMakeLists.txt (revision c33452fb792a5495ec310a9626f2638b053af5dd)
1*c33452fbSAndroid Build Coastguard Worker# Copyright (c) 2014-2016, Intel Corporation
2*c33452fbSAndroid Build Coastguard Worker# All rights reserved.
3*c33452fbSAndroid Build Coastguard Worker#
4*c33452fbSAndroid Build Coastguard Worker# Redistribution and use in source and binary forms, with or without modification,
5*c33452fbSAndroid Build Coastguard Worker# are permitted provided that the following conditions are met:
6*c33452fbSAndroid Build Coastguard Worker#
7*c33452fbSAndroid Build Coastguard Worker# 1. Redistributions of source code must retain the above copyright notice, this
8*c33452fbSAndroid Build Coastguard Worker# list of conditions and the following disclaimer.
9*c33452fbSAndroid Build Coastguard Worker#
10*c33452fbSAndroid Build Coastguard Worker# 2. Redistributions in binary form must reproduce the above copyright notice,
11*c33452fbSAndroid Build Coastguard Worker# this list of conditions and the following disclaimer in the documentation and/or
12*c33452fbSAndroid Build Coastguard Worker# other materials provided with the distribution.
13*c33452fbSAndroid Build Coastguard Worker#
14*c33452fbSAndroid Build Coastguard Worker# 3. Neither the name of the copyright holder nor the names of its contributors
15*c33452fbSAndroid Build Coastguard Worker# may be used to endorse or promote products derived from this software without
16*c33452fbSAndroid Build Coastguard Worker# specific prior written permission.
17*c33452fbSAndroid Build Coastguard Worker#
18*c33452fbSAndroid Build Coastguard Worker# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19*c33452fbSAndroid Build Coastguard Worker# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20*c33452fbSAndroid Build Coastguard Worker# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21*c33452fbSAndroid Build Coastguard Worker# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22*c33452fbSAndroid Build Coastguard Worker# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23*c33452fbSAndroid Build Coastguard Worker# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24*c33452fbSAndroid Build Coastguard Worker# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25*c33452fbSAndroid Build Coastguard Worker# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*c33452fbSAndroid Build Coastguard Worker# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27*c33452fbSAndroid Build Coastguard Worker# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*c33452fbSAndroid Build Coastguard Worker
29*c33452fbSAndroid Build Coastguard Worker# Known to work with CMake 3.2.2, might work with older 3.x versions, will not
30*c33452fbSAndroid Build Coastguard Worker# work with versions prior to 3.0.0.
31*c33452fbSAndroid Build Coastguard Worker# Visual Studio 14 needs 3.3.0; see https://cmake.org/Bug/print_bug_page.php?bug_id=15552
32*c33452fbSAndroid Build Coastguard Workercmake_minimum_required(VERSION 3.2.2)
33*c33452fbSAndroid Build Coastguard Workerif((CMAKE_GENERATOR MATCHES "Visual Studio .*")
34*c33452fbSAndroid Build Coastguard Worker    AND (CMAKE_GENERATOR STRGREATER "Visual Studio 14 2015"))
35*c33452fbSAndroid Build Coastguard Worker    cmake_minimum_required(VERSION 3.3.0)
36*c33452fbSAndroid Build Coastguard Workerendif()
37*c33452fbSAndroid Build Coastguard Worker
38*c33452fbSAndroid Build Coastguard Workerproject(parameter-framework)
39*c33452fbSAndroid Build Coastguard Worker
40*c33452fbSAndroid Build Coastguard Workerinclude(CMakeDependentOption)
41*c33452fbSAndroid Build Coastguard Worker
42*c33452fbSAndroid Build Coastguard Workeroption(COVERAGE "Build with coverage support" OFF)
43*c33452fbSAndroid Build Coastguard Workercmake_dependent_option(BASH_COMPLETION "Install bash completion configuration"
44*c33452fbSAndroid Build Coastguard Worker    ON
45*c33452fbSAndroid Build Coastguard Worker    UNIX # Only allow installing bash completion on Unix environments
46*c33452fbSAndroid Build Coastguard Worker    OFF)
47*c33452fbSAndroid Build Coastguard Workeroption(DOXYGEN "Enable doxygen generation (you still have to run 'make doc')" OFF)
48*c33452fbSAndroid Build Coastguard Workeroption(REQUIREMENTS "Generate the html version of the 'requirements' documentation" OFF)
49*c33452fbSAndroid Build Coastguard Workeroption(PYTHON_BINDINGS "Python library to use the Parameter Framework from python" ON)
50*c33452fbSAndroid Build Coastguard Workeroption(C_BINDINGS "Library to use the Parameter Framework using a C API" ON)
51*c33452fbSAndroid Build Coastguard Workeroption(FATAL_WARNINGS "Turn warnings into errors (-Werror flag)" ON)
52*c33452fbSAndroid Build Coastguard Workeroption(NETWORKING "Set to OFF in order to stub networking code" ON)
53*c33452fbSAndroid Build Coastguard Workeroption(CLIENT_SIMULATOR "Set to OFF to disable client simulator" ON)
54*c33452fbSAndroid Build Coastguard Worker
55*c33452fbSAndroid Build Coastguard Workerinclude(SetVersion.cmake)
56*c33452fbSAndroid Build Coastguard Worker
57*c33452fbSAndroid Build Coastguard Worker# Add FindLibXml2.cmake in cmake path so that `find_package(LibXml2)` will
58*c33452fbSAndroid Build Coastguard Worker# call the wrapper
59*c33452fbSAndroid Build Coastguard Workerlist(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake")
60*c33452fbSAndroid Build Coastguard Worker
61*c33452fbSAndroid Build Coastguard Workerset(CMAKE_CXX_STANDARD 11)
62*c33452fbSAndroid Build Coastguard Workerset(CMAKE_CXX_EXTENSIONS NO)
63*c33452fbSAndroid Build Coastguard Workerset(CMAKE_CXX_STANDARD_REQUIRED YES)
64*c33452fbSAndroid Build Coastguard Worker
65*c33452fbSAndroid Build Coastguard Workerif(WIN32)
66*c33452fbSAndroid Build Coastguard Worker    # By default cmake adds a warning level.
67*c33452fbSAndroid Build Coastguard Worker    # Nevertheless a different level is wanted for this project.
68*c33452fbSAndroid Build Coastguard Worker    # If a two different warning levels are present on the command line, cl raises a warning.
69*c33452fbSAndroid Build Coastguard Worker    # Thus delete the default level to set a different one.
70*c33452fbSAndroid Build Coastguard Worker    string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
71*c33452fbSAndroid Build Coastguard Worker
72*c33452fbSAndroid Build Coastguard Worker    # Force include iso646.h to support alternative operator form (and, or, not...)
73*c33452fbSAndroid Build Coastguard Worker    # Such support is require by the standard and can be enabled with /Za
74*c33452fbSAndroid Build Coastguard Worker    # but doing so breaks compilation of windows headers...
75*c33452fbSAndroid Build Coastguard Worker    #
76*c33452fbSAndroid Build Coastguard Worker    # Suppress warning 4127 (Conditional expression is constant) as it break
77*c33452fbSAndroid Build Coastguard Worker    # compilation when testing template value arguments or writing `while(true)`.
78*c33452fbSAndroid Build Coastguard Worker    #
79*c33452fbSAndroid Build Coastguard Worker    # Suppress warning 4251 (related to exported symbol without dll interface)
80*c33452fbSAndroid Build Coastguard Worker    # as it refers to private members (coding style forbids exposing attribute)
81*c33452fbSAndroid Build Coastguard Worker    # and thus are not to be used by the client. A better fix would be to export
82*c33452fbSAndroid Build Coastguard Worker    # only public methods instead of the whole class, but they are too many to
83*c33452fbSAndroid Build Coastguard Worker    # do that. A separated plugin interface would fix that.
84*c33452fbSAndroid Build Coastguard Worker    add_compile_options(/W4 /FIiso646.h -wd4127 -wd4251)
85*c33452fbSAndroid Build Coastguard Worker
86*c33452fbSAndroid Build Coastguard Worker    # FIXME: Once we have removed all warnings on windows, add the /WX flags if
87*c33452fbSAndroid Build Coastguard Worker    # FATAL_WARNINGS is enabled
88*c33452fbSAndroid Build Coastguard Workerelse()
89*c33452fbSAndroid Build Coastguard Worker    add_compile_options(-Wall -Wextra -Wconversion -Wno-sign-conversion
90*c33452fbSAndroid Build Coastguard Worker                 $<$<BOOL:FATAL_WARNINGS>:-Werror>)
91*c33452fbSAndroid Build Coastguard Workerendif()
92*c33452fbSAndroid Build Coastguard Worker
93*c33452fbSAndroid Build Coastguard Worker# Hide symbols by default, then exposed symbols are the same in linux and windows
94*c33452fbSAndroid Build Coastguard Workerset(CMAKE_CXX_VISIBILITY_PRESET hidden)
95*c33452fbSAndroid Build Coastguard Workerset(CMAKE_VISIBILITY_INLINES_HIDDEN true)
96*c33452fbSAndroid Build Coastguard Worker
97*c33452fbSAndroid Build Coastguard Worker
98*c33452fbSAndroid Build Coastguard Workerset(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
99*c33452fbSAndroid Build Coastguard Workerset(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
100*c33452fbSAndroid Build Coastguard Worker# Automatically add the current source and build dirs to the private and
101*c33452fbSAndroid Build Coastguard Worker# interface include directories.
102*c33452fbSAndroid Build Coastguard Workerset(CMAKE_INCLUDE_CURRENT_DIR ON)
103*c33452fbSAndroid Build Coastguard Workerset(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
104*c33452fbSAndroid Build Coastguard Worker
105*c33452fbSAndroid Build Coastguard Workerinclude(ctest/CMakeLists.txt)
106*c33452fbSAndroid Build Coastguard Worker
107*c33452fbSAndroid Build Coastguard Worker# Since there is no directory-wide property for linker flags, we can't use
108*c33452fbSAndroid Build Coastguard Worker# set_property for the link-time coverage flags.
109*c33452fbSAndroid Build Coastguard Workerif(COVERAGE)
110*c33452fbSAndroid Build Coastguard Worker    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
111*c33452fbSAndroid Build Coastguard Worker    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
112*c33452fbSAndroid Build Coastguard Workerendif()
113*c33452fbSAndroid Build Coastguard Worker
114*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(xmlserializer)
115*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(parameter)
116*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(utility)
117*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(asio)
118*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(remote-processor)
119*c33452fbSAndroid Build Coastguard Worker
120*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(remote-process)
121*c33452fbSAndroid Build Coastguard Worker
122*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(test)
123*c33452fbSAndroid Build Coastguard Worker
124*c33452fbSAndroid Build Coastguard Workerif(BASH_COMPLETION)
125*c33452fbSAndroid Build Coastguard Worker    add_subdirectory(tools/bash_completion)
126*c33452fbSAndroid Build Coastguard Workerendif()
127*c33452fbSAndroid Build Coastguard Worker
128*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(tools/xmlGenerator)
129*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(tools/xmlValidator)
130*c33452fbSAndroid Build Coastguard Workerif (CLIENT_SIMULATOR)
131*c33452fbSAndroid Build Coastguard Worker    add_subdirectory(tools/clientSimulator)
132*c33452fbSAndroid Build Coastguard Workerendif()
133*c33452fbSAndroid Build Coastguard Worker
134*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(bindings)
135*c33452fbSAndroid Build Coastguard Worker
136*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(doc)
137*c33452fbSAndroid Build Coastguard Worker
138*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(schemas)
139*c33452fbSAndroid Build Coastguard Worker
140*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(cpack)
141*c33452fbSAndroid Build Coastguard Workeradd_subdirectory(cmake)
142