Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 58d2da1

Browse files
committed
Merge pull request #362 from dawagner/export-cmake
CMake: generate and install a Package Configuration file Such a file makes it possible for other CMake build systems to import an link against the Parameter Framework. See https://cmake.org/cmake/help/v3.2/manual/cmake-packages.7.html#package-configuration-file.
2 parents 95d3066 + eaecc74 commit 58d2da1

File tree

17 files changed

+123
-55
lines changed

17 files changed

+123
-55
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN true)
9494

9595
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
9696
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
97+
# Automatically add the current source and build dirs to the private and
98+
# interface include directories.
99+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
100+
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
97101

98102
include(ctest/CMakeLists.txt)
99103

@@ -126,3 +130,4 @@ add_subdirectory(doc)
126130
add_subdirectory(schemas)
127131

128132
add_subdirectory(cpack)
133+
add_subdirectory(cmake)

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ build_script:
8888
# %INSTALL%\bin is where parameter.dll is installed
8989
# Also add the path where the release libxml2.dll has been extracted
9090
- set TEST_PATH=%RELEASE_LIBXML2_PATH%\bin;%INSTALL%\lib;%INSTALL%\bin
91-
- cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_PREFIX_PATH=%INSTALL% %APPVEYOR_BUILD_FOLDER%\skeleton-subsystem
91+
- cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALL% -DCMAKE_PREFIX_PATH="%INSTALL%;%RELEASE_LIBXML2_PATH%" %APPVEYOR_BUILD_FOLDER%\skeleton-subsystem
9292
# Unfortunately, the skeleton test currently doesn't work on
9393
# multi-configuration build systems (Visual Studio is one of those) without
9494
# installing the plugin

asio/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (NETWORKING)
4444

4545
# Ubuntu 14.04 packages asio 1.10.1 and clang 3.4.1.
4646
# In this environment, asio stand alone (set ASIO_STANDALONE)
47-
# does not correcly detect that the stl has CHRONO support (c++11).
47+
# does not correctly detect that the stl has CHRONO support (c++11).
4848
# Force the use of std::chrono by setting ASIO_HAS_STD_CHRONO
4949
target_include_directories(asio SYSTEM INTERFACE "${ASIO_DIR}")
5050
target_link_libraries(asio INTERFACE "${CMAKE_THREAD_LIBS_INIT}")

bindings/c/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ install(FILES ParameterFramework.h
3737

3838
target_link_libraries(cparameter PRIVATE parameter pfw_utility)
3939

40-
target_include_directories(cparameter
41-
# Fixme use an include folder
42-
PUBLIC .
43-
# Export symbol macro header
44-
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
45-
4640
install(TARGETS cparameter LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
4741

4842
if(BUILD_TESTING)

cmake/CMakeLists.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) 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+
configure_file(ParameterFrameworkConfig.cmake
30+
"${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfig.cmake"
31+
COPYONLY
32+
)
33+
34+
include(CMakePackageConfigHelpers)
35+
write_basic_package_version_file(
36+
"${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfigVersion.cmake"
37+
VERSION ${PF_VERSION_MAJOR}.${PF_VERSION_MINOR}.${PF_VERSION_PATCH}
38+
COMPATIBILITY SameMajorVersion)
39+
40+
export(EXPORT ParameterTargets
41+
FILE "${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkTargets.cmake"
42+
NAMESPACE ParameterFramework::)
43+
44+
install(EXPORT ParameterTargets DESTINATION lib/cmake/ParameterFramework
45+
FILE ParameterFrameworkTargets.cmake
46+
NAMESPACE ParameterFramework::)
47+
install(FILES
48+
"${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfig.cmake"
49+
"${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfigVersion.cmake"
50+
DESTINATION lib/cmake/ParameterFramework)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 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+
include("${CMAKE_CURRENT_LIST_DIR}/ParameterFrameworkTargets.cmake")

ctest/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function(set_test_env TestName)
7171
endif()
7272

7373

74-
# With nmake and nmake, executables are build in:
74+
# With nmake and nmake, executables are built in:
7575
# ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} => `bin/`
7676
#
7777
# Nevertheless Visual studio (and xcode) can build for debug and release

parameter/CMakeLists.txt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,32 @@ endif()
127127
configure_file(version.h.in "${CMAKE_CURRENT_BINARY_DIR}/version.h")
128128

129129
target_link_libraries(parameter
130-
# Unfortunatly xmlSink and xmlSource need to be exposed to the plugins
131-
PUBLIC xmlserializer
132-
PRIVATE pfw_utility remote-processor
130+
PRIVATE xmlserializer pfw_utility remote-processor
133131
PRIVATE ${CMAKE_DL_LIBS})
134132

135133
target_include_directories(parameter
136-
PUBLIC include log/include
137-
# Export symbol macro header
138-
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}"
139-
# FIXE: define . as an PUBLIC include directory only for plugins
140-
PUBLIC .)
134+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
135+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/log/include>)
136+
137+
install(TARGETS parameter EXPORT ParameterTargets
138+
LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib
139+
INCLUDES DESTINATION "include/parameter/client" "include/parameter/plugin")
140+
141+
# Export an interface library for plugins to use (after the ParameterFramework
142+
# project is built and installed). It makes them link against libparameter and
143+
# use xmlserializer's and pfw_utilify's include directories.
144+
add_library(plugin INTERFACE)
145+
target_link_libraries(plugin INTERFACE parameter)
146+
install(TARGETS plugin EXPORT ParameterTargets
147+
INCLUDES DESTINATION "include/parameter/xmlserializer" "include/parameter/utility")
148+
# Unfortunately, while the "plugin" interface library is suitable for external
149+
# plugins (built using the installed Parameter Framework) we want to build some
150+
# plugins before the whole project is installed. Therefore, they need to get
151+
# xmlserializer's and pfw_utility's headers from the build tree. This
152+
# "plugin-internal-hack" is for them.
153+
add_library(plugin-internal-hack INTERFACE)
154+
target_link_libraries(plugin-internal-hack INTERFACE parameter xmlserializer)
141155

142-
install(TARGETS parameter LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
143156
# Client headers
144157
install(FILES
145158
"${CMAKE_CURRENT_BINARY_DIR}/parameter_export.h"
@@ -161,7 +174,6 @@ install(FILES
161174
Element.h
162175
ElementBuilder.h
163176
ElementLibrary.h
164-
FileIncluderElementBuilder.h
165177
FormattedSubsystemObject.h
166178
InstanceConfigurableElement.h
167179
LoggingElementBuilderTemplate.h

remote-processor/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ generate_export_header(remote-processor
4040
set(CMAKE_THREAD_PREFER_PTHREAD 1)
4141
find_package(Threads REQUIRED)
4242

43-
target_include_directories(remote-processor
44-
# Symbol export macro header
45-
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}"
46-
# TODO: separate remote-processor's includes in half (public/private)
47-
PUBLIC .)
48-
4943
target_link_libraries(remote-processor PRIVATE pfw_utility asio ${CMAKE_THREAD_LIBS_INIT})
5044

51-
install(TARGETS remote-processor LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
45+
install(TARGETS remote-processor EXPORT ParameterTargets
46+
LIBRARY DESTINATION lib RUNTIME DESTINATION bin)

skeleton-subsystem/CMakeLists.txt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ cmake_minimum_required(VERSION 2.8.12)
3131

3232
project(parameter-framework-plugins-skeleton)
3333

34+
find_package(ParameterFramework REQUIRED)
35+
3436
if(WIN32)
3537
# Force include iso646.h to support alternative operator form (and, or, not...)
3638
# Such support is require by the standard and can be enabled with /Za
@@ -45,29 +47,16 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
4547
set(CMAKE_VISIBILITY_INLINES_HIDDEN true)
4648

4749
# Force libs and executable to all be at a known place - simplifies a lot of
48-
# things, expecially setting the test environment
50+
# things, especially setting the test environment
4951
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
5052
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
5153

52-
#
53-
# Find PFW libraries and include directories
54-
#
55-
find_path(PFW_INCLUDE_ROOT NAMES parameter/plugin/Plugin.h)
56-
57-
find_library(PFW_CORE_LIBRARY NAMES parameter)
58-
59-
set(PFW_INCLUDE_DIRS
60-
${PFW_INCLUDE_ROOT}/parameter/plugin
61-
${PFW_INCLUDE_ROOT}/xmlserializer
62-
${PFW_INCLUDE_ROOT}/utility)
63-
6454
add_library(skeleton-subsystem MODULE
6555
SkeletonSubsystemBuilder.cpp
6656
SkeletonSubsystem.cpp
6757
SkeletonSubsystemObject.cpp)
6858

69-
target_include_directories(skeleton-subsystem PRIVATE ${PFW_INCLUDE_DIRS})
70-
target_link_libraries(skeleton-subsystem ${PFW_CORE_LIBRARY})
59+
target_link_libraries(skeleton-subsystem PRIVATE ParameterFramework::plugin)
7160

7261
install(TARGETS skeleton-subsystem
7362
LIBRARY DESTINATION lib

0 commit comments

Comments
 (0)