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