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

Commit 22ccc36

Browse files
committed
CMake: define installation components
'install' commands can receive 'COMPONENT' arguments (one per target file kind). Upon request, CMake can install only the files associated to a given component. This will be used to generate separate archives/pacakges/installers with CPack. The following components are declared: - runtime (libparameter and libremote-processor); - dev (everything necessary to develop a plugin or a client: headers, cmake package files, ...); - c (the C bindings, i.e. libcparameter); - cdev (everything necessary to develop a client using the C bindings); - python (the Python bindings); - eng (the various tools, XML schemas, ...); - runtime-deps (on windows only: the msvc redistributable files). Unfortunately, per-component debian package generation and automatic dependency discovery (using shlibdeps) do not work together before CMake 3.4. Also, per-component debian package dependency declaration has been added in CMake 3.4, so it is not possible yet to declare, for instance, that the 'dev' package depends on the 'runtime' package. However, the following works and generates one archive for each component: cpack -G TGZ -D CPACK_ARCHIVE_COMPONENT_INSTALL=ON Signed-off-by: David Wagner <[email protected]>
1 parent 529a730 commit 22ccc36

File tree

15 files changed

+47
-21
lines changed

15 files changed

+47
-21
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ script:
118118
cmake $MY_CMAKE_OPTIONS . &&
119119
make &&
120120
make install ); fi
121+
# Check that all installed files are in a component (no "unspecified
122+
# component" archive created)
123+
- (cd build && cpack -G TGZ -D CPACK_ARCHIVE_COMPONENT_INSTALL=ON &&
124+
[ ! -x '*-Unspecified.tar.gz' ])
121125
# Keep this last
122126
- ( mkdir build_less_features && cd build_less_features &&
123127
rm -rf $PREFIX/asio-1.10.6 &&

bindings/c/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ generate_export_header(cparameter)
3333

3434
install(FILES ParameterFramework.h
3535
"${CMAKE_CURRENT_BINARY_DIR}/cparameter_export.h"
36-
DESTINATION "include/parameter/c")
36+
DESTINATION "include/parameter/c"
37+
COMPONENT c_dev)
3738

3839
target_link_libraries(cparameter PRIVATE parameter pfw_utility)
3940

40-
install(TARGETS cparameter LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
41+
install(TARGETS cparameter
42+
LIBRARY DESTINATION lib COMPONENT c
43+
RUNTIME DESTINATION bin COMPONENT c
44+
ARCHIVE DESTINATION lib COMPONENT c_dev)
4145

4246
if(BUILD_TESTING)
4347
# Add unit test

bindings/python/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ execute_process(COMMAND
8989
print(sysconfig.get_python_lib(plat_specific=True, prefix=''))"
9090
OUTPUT_VARIABLE PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
9191

92-
install(TARGETS _PyPfw LIBRARY DESTINATION ${PYTHON_MODULE_PATH})
92+
install(TARGETS _PyPfw LIBRARY DESTINATION ${PYTHON_MODULE_PATH} COMPONENT python)
9393

9494
# install the generated Python file as well
95-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PyPfw.py DESTINATION ${PYTHON_MODULE_PATH})
95+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PyPfw.py DESTINATION ${PYTHON_MODULE_PATH}
96+
COMPONENT python)

cmake/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ export(EXPORT ParameterTargets
4343

4444
install(EXPORT ParameterTargets DESTINATION lib/cmake/ParameterFramework
4545
FILE ParameterFrameworkTargets.cmake
46-
NAMESPACE ParameterFramework::)
46+
NAMESPACE ParameterFramework::
47+
COMPONENT dev)
4748
install(FILES
4849
"${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfig.cmake"
4950
"${CMAKE_CURRENT_BINARY_DIR}/ParameterFrameworkConfigVersion.cmake"
50-
DESTINATION lib/cmake/ParameterFramework)
51+
DESTINATION lib/cmake/ParameterFramework
52+
COMPONENT dev)

cpack/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ set(CPACK_WIX_UPGRADE_GUID "47E60D10-B344-445D-A2F6-5684CC8B1D47")
4747

4848
if (WIN32)
4949
# On windows, pack compiler provided libraries (MSVC redistributable) with the project
50+
# Have cpack make a specific archive for them
51+
set(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT runtime_deps)
5052
include(InstallRequiredSystemLibraries)
5153
# TODO: pack libxml2.dll with the project
5254
endif()

parameter/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ target_include_directories(parameter
137137
INTERFACE $<INSTALL_INTERFACE:include/parameter/plugin>)
138138

139139
install(TARGETS parameter EXPORT ParameterTargets
140-
LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
140+
LIBRARY DESTINATION lib COMPONENT runtime
141+
RUNTIME DESTINATION bin COMPONENT runtime
142+
ARCHIVE DESTINATION lib COMPONENT dev)
141143

142144
# Export an interface library for plugins to use (after the ParameterFramework
143145
# project is built and installed). It makes them link against libparameter and
@@ -147,7 +149,7 @@ target_link_libraries(plugin INTERFACE parameter)
147149
target_include_directories(plugin
148150
INTERFACE $<INSTALL_INTERFACE:include/parameter/xmlserializer>
149151
INTERFACE $<INSTALL_INTERFACE:include/parameter/utility>)
150-
install(TARGETS plugin EXPORT ParameterTargets)
152+
install(TARGETS plugin EXPORT ParameterTargets COMPONENT dev)
151153
# Unfortunately, while the "plugin" interface library is suitable for external
152154
# plugins (built using the installed Parameter Framework) we want to build some
153155
# plugins before the whole project is installed. Therefore, they need to get
@@ -167,7 +169,8 @@ install(FILES
167169
include/ParameterMgrPlatformConnector.h
168170
include/SelectionCriterionInterface.h
169171
include/SelectionCriterionTypeInterface.h
170-
DESTINATION "include/parameter/client")
172+
DESTINATION "include/parameter/client"
173+
COMPONENT dev)
171174
# Core (plugin) headers
172175
install(FILES
173176
"${CMAKE_CURRENT_BINARY_DIR}/parameter_export.h"
@@ -194,6 +197,8 @@ install(FILES
194197
Syncer.h
195198
TypeElement.h
196199
VirtualSubsystem.h
197-
DESTINATION "include/parameter/plugin")
200+
DESTINATION "include/parameter/plugin"
201+
COMPONENT dev)
198202
install(DIRECTORY log/include/log/
199-
DESTINATION "include/parameter/plugin/log")
203+
DESTINATION "include/parameter/plugin/log"
204+
COMPONENT dev)

remote-process/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ if(NETWORKING)
3535
target_link_libraries(remote-process
3636
PRIVATE remote-processor pfw_utility asio ${CMAKE_THREAD_LIBS_INIT})
3737

38-
install(TARGETS remote-process RUNTIME DESTINATION bin)
38+
install(TARGETS remote-process RUNTIME DESTINATION bin
39+
COMPONENT eng)
3940
endif()

remote-processor/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ find_package(Threads REQUIRED)
4343
target_link_libraries(remote-processor PRIVATE pfw_utility asio ${CMAKE_THREAD_LIBS_INIT})
4444

4545
install(TARGETS remote-processor EXPORT ParameterTargets
46-
LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
46+
LIBRARY DESTINATION lib COMPONENT runtime
47+
RUNTIME DESTINATION bin COMPONENT runtime
48+
ARCHIVE DESTINATION lib COMPONENT dev)

schemas/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ install(FILES ComponentLibrary.xsd
3737
Subsystem.xsd
3838
SystemClass.xsd
3939
W3cXmlAttributes.xsd
40-
DESTINATION share/${PROJECT_NAME}/schemas)
40+
DESTINATION share/${PROJECT_NAME}/schemas
41+
COMPONENT eng)

test/test-platform/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ if(NETWORKING)
3636
# Workaround because asio is still leaking to test-platform
3737
target_link_libraries(test-platform PRIVATE asio)
3838

39-
install(TARGETS test-platform RUNTIME DESTINATION bin)
39+
install(TARGETS test-platform RUNTIME DESTINATION bin COMPONENT eng)
4040
endif()

0 commit comments

Comments
 (0)