diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bf794113..817421865 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,10 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN true) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +# Automatically add the current source and build dirs to the private and +# interface include directories. +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) include(ctest/CMakeLists.txt) @@ -126,3 +130,4 @@ add_subdirectory(doc) add_subdirectory(schemas) add_subdirectory(cpack) +add_subdirectory(cmake) diff --git a/appveyor.yml b/appveyor.yml index f1e38dc56..cd2f0dfac 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -88,7 +88,7 @@ build_script: # %INSTALL%\bin is where parameter.dll is installed # Also add the path where the release libxml2.dll has been extracted - set TEST_PATH=%RELEASE_LIBXML2_PATH%\bin;%INSTALL%\lib;%INSTALL%\bin - - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_PREFIX_PATH=%INSTALL% %APPVEYOR_BUILD_FOLDER%\skeleton-subsystem + - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_PREFIX_PATH="%INSTALL%;%RELEASE_LIBXML2_PATH%" %APPVEYOR_BUILD_FOLDER%\skeleton-subsystem # Unfortunately, the skeleton test currently doesn't work on # multi-configuration build systems (Visual Studio is one of those) without # installing the plugin diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 9c0ef115b..1270e0543 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -44,7 +44,7 @@ if (NETWORKING) # Ubuntu 14.04 packages asio 1.10.1 and clang 3.4.1. # In this environment, asio stand alone (set ASIO_STANDALONE) - # does not correcly detect that the stl has CHRONO support (c++11). + # does not correctly detect that the stl has CHRONO support (c++11). # Force the use of std::chrono by setting ASIO_HAS_STD_CHRONO target_include_directories(asio SYSTEM INTERFACE "${ASIO_DIR}") target_link_libraries(asio INTERFACE "${CMAKE_THREAD_LIBS_INIT}") diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index 0c884122e..c04ac3c9c 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -37,12 +37,6 @@ install(FILES ParameterFramework.h target_link_libraries(cparameter PRIVATE parameter pfw_utility) -target_include_directories(cparameter - # Fixme use an include folder - PUBLIC . - # Export symbol macro header - PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") - install(TARGETS cparameter LIBRARY DESTINATION lib RUNTIME DESTINATION bin) if(BUILD_TESTING) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt new file mode 100644 index 000000000..29ce10a3c --- /dev/null +++ b/cmake/CMakeLists.txt @@ -0,0 +1,50 @@ +# Copyright (c) 2016, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. Neither the name of the copyright holder 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. + +configure_file(ParameterFrameworkConfig.cmake + "${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfig.cmake" + COPYONLY +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfigVersion.cmake" + VERSION ${PF_VERSION_MAJOR}.${PF_VERSION_MINOR}.${PF_VERSION_PATCH} + COMPATIBILITY SameMajorVersion) + +export(EXPORT ParameterTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkTargets.cmake" + NAMESPACE ParameterFramework::) + +install(EXPORT ParameterTargets DESTINATION lib/cmake/ParameterFramework + FILE ParameterFrameworkTargets.cmake + NAMESPACE ParameterFramework::) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfigVersion.cmake" + DESTINATION lib/cmake/ParameterFramework) diff --git a/cmake/ParameterFrameworkConfig.cmake b/cmake/ParameterFrameworkConfig.cmake new file mode 100644 index 000000000..cc14d4684 --- /dev/null +++ b/cmake/ParameterFrameworkConfig.cmake @@ -0,0 +1,29 @@ +# Copyright (c) 2016, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. 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. +# +# 3. Neither the name of the copyright holder 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_CURRENT_LIST_DIR}/ParameterFrameworkTargets.cmake") diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt index d56c9a16d..e80bc3f54 100644 --- a/ctest/CMakeLists.txt +++ b/ctest/CMakeLists.txt @@ -71,7 +71,7 @@ function(set_test_env TestName) endif() - # With nmake and nmake, executables are build in: + # With nmake and nmake, executables are built in: # ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} => `bin/` # # Nevertheless Visual studio (and xcode) can build for debug and release diff --git a/parameter/CMakeLists.txt b/parameter/CMakeLists.txt index 230dd5ff4..05c90af13 100644 --- a/parameter/CMakeLists.txt +++ b/parameter/CMakeLists.txt @@ -127,19 +127,32 @@ endif() configure_file(version.h.in "${CMAKE_CURRENT_BINARY_DIR}/version.h") target_link_libraries(parameter - # Unfortunatly xmlSink and xmlSource need to be exposed to the plugins - PUBLIC xmlserializer - PRIVATE pfw_utility remote-processor + PRIVATE xmlserializer pfw_utility remote-processor PRIVATE ${CMAKE_DL_LIBS}) target_include_directories(parameter - PUBLIC include log/include - # Export symbol macro header - PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" - # FIXE: define . as an PUBLIC include directory only for plugins - PUBLIC .) + PUBLIC $ + PUBLIC $) + +install(TARGETS parameter EXPORT ParameterTargets + LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib + INCLUDES DESTINATION "include/parameter/client" "include/parameter/plugin") + +# Export an interface library for plugins to use (after the ParameterFramework +# project is built and installed). It makes them link against libparameter and +# use xmlserializer's and pfw_utilify's include directories. +add_library(plugin INTERFACE) +target_link_libraries(plugin INTERFACE parameter) +install(TARGETS plugin EXPORT ParameterTargets + INCLUDES DESTINATION "include/parameter/xmlserializer" "include/parameter/utility") +# Unfortunately, while the "plugin" interface library is suitable for external +# plugins (built using the installed Parameter Framework) we want to build some +# plugins before the whole project is installed. Therefore, they need to get +# xmlserializer's and pfw_utility's headers from the build tree. This +# "plugin-internal-hack" is for them. +add_library(plugin-internal-hack INTERFACE) +target_link_libraries(plugin-internal-hack INTERFACE parameter xmlserializer) -install(TARGETS parameter LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib) # Client headers install(FILES "${CMAKE_CURRENT_BINARY_DIR}/parameter_export.h" @@ -161,7 +174,6 @@ install(FILES Element.h ElementBuilder.h ElementLibrary.h - FileIncluderElementBuilder.h FormattedSubsystemObject.h InstanceConfigurableElement.h LoggingElementBuilderTemplate.h diff --git a/remote-processor/CMakeLists.txt b/remote-processor/CMakeLists.txt index ee21f55b6..5887bf5ea 100644 --- a/remote-processor/CMakeLists.txt +++ b/remote-processor/CMakeLists.txt @@ -40,12 +40,7 @@ generate_export_header(remote-processor set(CMAKE_THREAD_PREFER_PTHREAD 1) find_package(Threads REQUIRED) -target_include_directories(remote-processor - # Symbol export macro header - PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" - # TODO: separate remote-processor's includes in half (public/private) - PUBLIC .) - target_link_libraries(remote-processor PRIVATE pfw_utility asio ${CMAKE_THREAD_LIBS_INIT}) -install(TARGETS remote-processor LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +install(TARGETS remote-processor EXPORT ParameterTargets + LIBRARY DESTINATION lib RUNTIME DESTINATION bin) diff --git a/skeleton-subsystem/CMakeLists.txt b/skeleton-subsystem/CMakeLists.txt index 1ec822d05..1bc1d874c 100644 --- a/skeleton-subsystem/CMakeLists.txt +++ b/skeleton-subsystem/CMakeLists.txt @@ -31,6 +31,8 @@ cmake_minimum_required(VERSION 2.8.12) project(parameter-framework-plugins-skeleton) +find_package(ParameterFramework REQUIRED) + if(WIN32) # Force include iso646.h to support alternative operator form (and, or, not...) # Such support is require by the standard and can be enabled with /Za @@ -45,29 +47,16 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN true) # Force libs and executable to all be at a known place - simplifies a lot of -# things, expecially setting the test environment +# things, especially setting the test environment set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) -# -# Find PFW libraries and include directories -# -find_path(PFW_INCLUDE_ROOT NAMES parameter/plugin/Plugin.h) - -find_library(PFW_CORE_LIBRARY NAMES parameter) - -set(PFW_INCLUDE_DIRS - ${PFW_INCLUDE_ROOT}/parameter/plugin - ${PFW_INCLUDE_ROOT}/xmlserializer - ${PFW_INCLUDE_ROOT}/utility) - add_library(skeleton-subsystem MODULE SkeletonSubsystemBuilder.cpp SkeletonSubsystem.cpp SkeletonSubsystemObject.cpp) -target_include_directories(skeleton-subsystem PRIVATE ${PFW_INCLUDE_DIRS}) -target_link_libraries(skeleton-subsystem ${PFW_CORE_LIBRARY}) +target_link_libraries(skeleton-subsystem PRIVATE ParameterFramework::plugin) install(TARGETS skeleton-subsystem LIBRARY DESTINATION lib diff --git a/skeleton-subsystem/test/CMakeLists.txt b/skeleton-subsystem/test/CMakeLists.txt index 46cb66911..d36d456b1 100644 --- a/skeleton-subsystem/test/CMakeLists.txt +++ b/skeleton-subsystem/test/CMakeLists.txt @@ -30,8 +30,7 @@ configure_file(structure.xml "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) configure_file(toplevel.xml "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) add_executable(skeleton-test main.cpp) -target_include_directories(skeleton-test PRIVATE "${PFW_INCLUDE_ROOT}/parameter/client") -target_link_libraries(skeleton-test "${PFW_CORE_LIBRARY}") +target_link_libraries(skeleton-test PRIVATE ParameterFramework::parameter) add_test(NAME skeleton-test WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" diff --git a/test/functional-tests/CMakeLists.txt b/test/functional-tests/CMakeLists.txt index 1ab0449c8..fdc0f6906 100644 --- a/test/functional-tests/CMakeLists.txt +++ b/test/functional-tests/CMakeLists.txt @@ -42,7 +42,8 @@ if(BUILD_TESTING) find_package(LibXml2 REQUIRED) target_link_libraries(parameterFunctionalTest - PRIVATE parameter catch tmpfile LibXml2::libxml2 introspection-subsystem) + PRIVATE parameter + PRIVATE pfw_utility catch tmpfile LibXml2::libxml2 introspection-subsystem) add_test(NAME parameterFunctionalTest COMMAND parameterFunctionalTest) diff --git a/test/introspection-subsystem/CMakeLists.txt b/test/introspection-subsystem/CMakeLists.txt index faccab348..b59be40f5 100644 --- a/test/introspection-subsystem/CMakeLists.txt +++ b/test/introspection-subsystem/CMakeLists.txt @@ -52,7 +52,7 @@ if (BUILD_TESTING) # # Note : headers located in root project directory remain private. target_include_directories(introspection-subsystem - PUBLIC "include" "${CMAKE_CURRENT_BINARY_DIR}") + PUBLIC "include") - target_link_libraries(introspection-subsystem PRIVATE parameter) + target_link_libraries(introspection-subsystem PRIVATE plugin-internal-hack) endif() diff --git a/test/test-subsystem/CMakeLists.txt b/test/test-subsystem/CMakeLists.txt index eeaa7de45..e5e752bde 100644 --- a/test/test-subsystem/CMakeLists.txt +++ b/test/test-subsystem/CMakeLists.txt @@ -35,5 +35,5 @@ if (BUILD_TESTING) TESTSubsystemString.cpp TESTSubsystemBuilder.cpp) - target_link_libraries(test-subsystem PRIVATE parameter) + target_link_libraries(test-subsystem PRIVATE plugin-internal-hack) endif() diff --git a/test/tmpfile/CMakeLists.txt b/test/tmpfile/CMakeLists.txt index 84818e725..0dba1a16f 100644 --- a/test/tmpfile/CMakeLists.txt +++ b/test/tmpfile/CMakeLists.txt @@ -34,5 +34,4 @@ if(BUILD_TESTING) endif () add_library(tmpfile STATIC ${OS_SPECIFIC_TMPFILE}) - target_include_directories(tmpfile PUBLIC .) endif() diff --git a/utility/CMakeLists.txt b/utility/CMakeLists.txt index 49e01e29d..8173ecaa3 100644 --- a/utility/CMakeLists.txt +++ b/utility/CMakeLists.txt @@ -38,8 +38,6 @@ add_library(pfw_utility STATIC Utility.cpp DynamicLibrary.cpp) -target_include_directories(pfw_utility PUBLIC .) - # Needed for linking against shared libraries on Linux (no-op on Windows) set_target_properties(pfw_utility PROPERTIES POSITION_INDEPENDENT_CODE TRUE) @@ -48,7 +46,7 @@ install(FILES ErrorContext.hpp Utility.h convert.hpp - DESTINATION "include/utility") + DESTINATION "include/parameter/utility") if(BUILD_TESTING) # Add unit test diff --git a/xmlserializer/CMakeLists.txt b/xmlserializer/CMakeLists.txt index 067a00e60..91f51d2fe 100644 --- a/xmlserializer/CMakeLists.txt +++ b/xmlserializer/CMakeLists.txt @@ -60,16 +60,13 @@ if(NOT XML2_XINCLUDE_SUPPORT) "please install a version of libxml2 supporting it.") endif() -target_include_directories(xmlserializer PUBLIC .) - target_link_libraries(xmlserializer PUBLIC pfw_utility # For NonCopyable and ErrorContext PRIVATE LibXml2::libxml2) - install(FILES XmlSink.h XmlSource.h XmlElement.h XmlSerializingContext.h - DESTINATION "include/xmlserializer") + DESTINATION "include/parameter/xmlserializer")