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) 53 54include(SetVersion.cmake) 55 56# Add FindLibXml2.cmake in cmake path so that `find_package(LibXml2)` will 57# call the wrapper 58list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake") 59 60if(WIN32) 61 # By default cmake adds a warning level. 62 # Nevertheless a different level is wanted for this project. 63 # If a two different warning levels are present on the command line, cl raises a warning. 64 # Thus delete the default level to set a different one. 65 string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 66 67 # Force include iso646.h to support alternative operator form (and, or, not...) 68 # Such support is require by the standard and can be enabled with /Za 69 # but doing so breaks compilation of windows headers... 70 # 71 # Suppress warning 4127 (Conditional expression is constant) as it break 72 # compilation when testing template value arguments or writing `while(true)`. 73 # 74 # Suppress warning 4251 (related to exported symbol without dll interface) 75 # as it refers to private members (coding style forbids exposing attribute) 76 # and thus are not to be used by the client. A better fix would be to export 77 # only public methods instead of the whole class, but they are too many to 78 # do that. A separated plugin interface would fix that. 79 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /FIiso646.h -wd4127 -wd4251") 80 81 # FIXME: Once we have removed all warnings on windows, add the /WX flags if 82 # FATAL_WARNINGS is enabled 83else() 84 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wconversion -Wno-sign-conversion") 85 if(FATAL_WARNINGS) 86 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") 87 endif() 88endif() 89 90# Hide symbols by default, then exposed symbols are the same in linux and windows 91set(CMAKE_CXX_VISIBILITY_PRESET hidden) 92set(CMAKE_VISIBILITY_INLINES_HIDDEN true) 93 94 95set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) 96set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) 97 98include(ctest/CMakeLists.txt) 99 100if(COVERAGE) 101 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") 102 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") 103endif() 104 105add_subdirectory(xmlserializer) 106add_subdirectory(parameter) 107add_subdirectory(utility) 108add_subdirectory(asio) 109add_subdirectory(remote-processor) 110 111add_subdirectory(remote-process) 112 113add_subdirectory(test) 114 115if(BASH_COMPLETION) 116 add_subdirectory(tools/bash_completion) 117endif() 118 119add_subdirectory(tools/xmlGenerator) 120add_subdirectory(tools/xmlValidator) 121 122add_subdirectory(bindings) 123 124add_subdirectory(doc) 125 126add_subdirectory(schemas) 127 128add_subdirectory(cpack) 129