Skip to content

Commit e3664da

Browse files
committed
CMake: add option TBB_INSTALL
Signed-off-by: Vladislav Shchapov <[email protected]>
1 parent e2dca80 commit e3664da

File tree

4 files changed

+101
-94
lines changed

4 files changed

+101
-94
lines changed

CMakeLists.txt

+30-28
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ option(TBB_CPF "Enable preview features of the library" OFF)
106106
option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
107107
option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
108108
option(TBB_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" ON)
109+
option(TBB_INSTALL "Enable installation" ON)
109110

110111
if (NOT DEFINED BUILD_SHARED_LIBS)
111112
set(BUILD_SHARED_LIBS ON)
@@ -234,34 +235,35 @@ else()
234235
else()
235236
add_subdirectory(src/tbbbind)
236237
endif()
237-
238-
# -------------------------------------------------------------------
239-
# Installation instructions
240-
include(CMakePackageConfigHelpers)
241-
242-
install(DIRECTORY include/
243-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
244-
COMPONENT devel)
245-
246-
install(EXPORT ${PROJECT_NAME}Targets
247-
NAMESPACE TBB::
248-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
249-
COMPONENT devel)
250-
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
251-
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake)\n")
252-
253-
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
254-
COMPATIBILITY AnyNewerVersion)
255-
256-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
257-
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
258-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
259-
COMPONENT devel)
260-
261-
install(FILES "README.md"
262-
DESTINATION ${CMAKE_INSTALL_DOCDIR}
263-
COMPONENT devel)
264-
# -------------------------------------------------------------------
238+
if (TBB_INSTALL)
239+
# -------------------------------------------------------------------
240+
# Installation instructions
241+
include(CMakePackageConfigHelpers)
242+
243+
install(DIRECTORY include/
244+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
245+
COMPONENT devel)
246+
247+
install(EXPORT ${PROJECT_NAME}Targets
248+
NAMESPACE TBB::
249+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
250+
COMPONENT devel)
251+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
252+
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake)\n")
253+
254+
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
255+
COMPATIBILITY AnyNewerVersion)
256+
257+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
258+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
259+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
260+
COMPONENT devel)
261+
262+
install(FILES "README.md"
263+
DESTINATION ${CMAKE_INSTALL_DOCDIR}
264+
COMPONENT devel)
265+
# -------------------------------------------------------------------
266+
endif()
265267
endif()
266268

267269
if (TBB_TEST)

cmake/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ TBBMALLOC_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB)
1414
TBBMALLOC_PROXY_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB) memory allocator proxy build (requires TBBMALLOC_BUILD. ON by default)
1515
TBB4PY_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB) Python module build (OFF by default)
1616
TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
17+
TBB_INSTALL:BOOL - Enable installation (ON by default)
1718
TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
1819
TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
1920
TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)

cmake/utils.cmake

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2022 Intel Corporation
1+
# Copyright (c) 2020-2023 Intel Corporation
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -23,25 +23,27 @@ macro(tbb_remove_compile_flag flag)
2323
endmacro()
2424

2525
macro(tbb_install_target target)
26-
install(TARGETS ${target}
27-
EXPORT TBBTargets
28-
LIBRARY
29-
DESTINATION ${CMAKE_INSTALL_LIBDIR}
30-
NAMELINK_SKIP
31-
COMPONENT runtime
32-
RUNTIME
33-
DESTINATION ${CMAKE_INSTALL_BINDIR}
34-
COMPONENT runtime
35-
ARCHIVE
36-
DESTINATION ${CMAKE_INSTALL_LIBDIR}
37-
COMPONENT devel)
38-
39-
if (BUILD_SHARED_LIBS)
26+
if (TBB_INSTALL)
4027
install(TARGETS ${target}
28+
EXPORT TBBTargets
4129
LIBRARY
4230
DESTINATION ${CMAKE_INSTALL_LIBDIR}
43-
NAMELINK_ONLY
31+
NAMELINK_SKIP
32+
COMPONENT runtime
33+
RUNTIME
34+
DESTINATION ${CMAKE_INSTALL_BINDIR}
35+
COMPONENT runtime
36+
ARCHIVE
37+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
4438
COMPONENT devel)
39+
40+
if (BUILD_SHARED_LIBS)
41+
install(TARGETS ${target}
42+
LIBRARY
43+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
44+
NAMELINK_ONLY
45+
COMPONENT devel)
46+
endif()
4547
endif()
4648
endmacro()
4749

src/tbb/CMakeLists.txt

+52-50
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2022 Intel Corporation
1+
# Copyright (c) 2020-2023 Intel Corporation
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -123,57 +123,59 @@ target_link_libraries(tbb
123123

124124
tbb_install_target(tbb)
125125

126-
if (MSVC)
127-
# Create a copy of target linker file (tbb<ver>[_debug].lib) with legacy name (tbb[_debug].lib)
128-
# to support previous user experience for linkage.
129-
install(FILES
130-
$<TARGET_LINKER_FILE:tbb>
131-
DESTINATION lib
132-
CONFIGURATIONS RelWithDebInfo Release MinSizeRel
133-
RENAME tbb.lib
134-
COMPONENT devel
135-
)
136-
137-
install(FILES
138-
$<TARGET_LINKER_FILE:tbb>
139-
DESTINATION lib
140-
CONFIGURATIONS Debug
141-
RENAME tbb_debug.lib
142-
COMPONENT devel
143-
)
144-
endif()
145-
146-
set(_tbb_pc_lib_name tbb)
147-
148-
if (WIN32)
149-
set(_tbb_pc_lib_name ${_tbb_pc_lib_name}${TBB_BINARY_VERSION})
150-
endif()
151-
152-
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
153-
set(TBB_PC_NAME tbb)
154-
else()
155-
set(TBB_PC_NAME tbb32)
156-
endif()
157-
158-
set(_prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
159-
160-
if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
161-
set(_libdir_for_pc_file "${CMAKE_INSTALL_LIBDIR}")
162-
else()
163-
set(_libdir_for_pc_file "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
126+
if (TBB_INSTALL)
127+
if (MSVC)
128+
# Create a copy of target linker file (tbb<ver>[_debug].lib) with legacy name (tbb[_debug].lib)
129+
# to support previous user experience for linkage.
130+
install(FILES
131+
$<TARGET_LINKER_FILE:tbb>
132+
DESTINATION lib
133+
CONFIGURATIONS RelWithDebInfo Release MinSizeRel
134+
RENAME tbb.lib
135+
COMPONENT devel
136+
)
137+
138+
install(FILES
139+
$<TARGET_LINKER_FILE:tbb>
140+
DESTINATION lib
141+
CONFIGURATIONS Debug
142+
RENAME tbb_debug.lib
143+
COMPONENT devel
144+
)
145+
endif()
146+
147+
set(_tbb_pc_lib_name tbb)
148+
149+
if (WIN32)
150+
set(_tbb_pc_lib_name ${_tbb_pc_lib_name}${TBB_BINARY_VERSION})
151+
endif()
152+
153+
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
154+
set(TBB_PC_NAME tbb)
155+
else()
156+
set(TBB_PC_NAME tbb32)
157+
endif()
158+
159+
set(_prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
160+
161+
if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
162+
set(_libdir_for_pc_file "${CMAKE_INSTALL_LIBDIR}")
163+
else()
164+
set(_libdir_for_pc_file "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
165+
endif()
166+
167+
if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
168+
set(_includedir_for_pc_file "${CMAKE_INSTALL_INCLUDEDIR}")
169+
else()
170+
set(_includedir_for_pc_file "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
171+
endif()
172+
173+
configure_file(${PROJECT_SOURCE_DIR}/integration/pkg-config/tbb.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TBB_PC_NAME}.pc @ONLY)
174+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TBB_PC_NAME}.pc
175+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/
176+
COMPONENT devel)
164177
endif()
165178

166-
if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
167-
set(_includedir_for_pc_file "${CMAKE_INSTALL_INCLUDEDIR}")
168-
else()
169-
set(_includedir_for_pc_file "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
170-
endif()
171-
172-
configure_file(${PROJECT_SOURCE_DIR}/integration/pkg-config/tbb.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${TBB_PC_NAME}.pc @ONLY)
173-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TBB_PC_NAME}.pc
174-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/
175-
COMPONENT devel)
176-
177179
if (COMMAND tbb_gen_vars)
178180
tbb_gen_vars(tbb)
179181
endif()

0 commit comments

Comments
 (0)