Skip to content

Commit 571790f

Browse files
committed
[cmake] Fix link pool and allow overriding from command line.
Fix the usage of JOB_POOL_LINK. JOB_POOL_LINK is not global property, only a target property. To set in all the targets, one has to set CMAKE_JOB_POOL_LINK. Also, allow overriding JOB_POOLS from the command line with CMAKE_JOB_POOLS. There's a workaround for old versions of CMake which do not have automatic support for that override.
1 parent 1ea700a commit 571790f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

CMakeLists.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ endif()
1111
list(APPEND CMAKE_MODULE_PATH
1212
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
1313

14-
# Make a job pool for things that can't yet be distributed
15-
cmake_host_system_information(
16-
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
17-
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
18-
# Put linking in that category
19-
set_property(GLOBAL PROPERTY JOB_POOL_LINK local_jobs)
14+
if(DEFINED CMAKE_JOB_POOLS)
15+
# CMake < 3.11 doesn't support CMAKE_JOB_POOLS. Manually set the property.
16+
set_property(GLOBAL PROPERTY JOB_POOLS "${CMAKE_JOB_POOLS}")
17+
else()
18+
# Make a job pool for things that can't yet be distributed
19+
cmake_host_system_information(
20+
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
21+
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
22+
# Put linking in that category
23+
set(CMAKE_JOB_POOL_LINK local_jobs)
24+
endif()
2025

2126
ENABLE_LANGUAGE(C)
2227

0 commit comments

Comments
 (0)