I want to take advantage of Ninja's "job pools" in my custom commands; something finally directly supported in cmake 3.15.0. Many/most people won't have this version, so I would like to simply ADD this support without requiring that anyone update their cmake version.
A more general question is...
"What's the best way to specify a conditional clause of a custom command …?"
add_custom_command(
OUTPUT foo
COMMAND ${CMAKE_COMMAND} -E touch foo
if("${CMAKE_VERSION}" STRGREATER_EQUAL "3.15.0") # <-- syntax error
JOB_POOL my_job_pool # <-- syntax error
endif() # <-- syntax error
VERBATIM
)
Maybe...?
if("${CMAKE_VERSION}" STRGREATER_EQUAL "3.15.0")
set(USE_JOB_POOL JOB_POOL my_job_pool)
endif()
add_custom_command(
OUTPUT foo
COMMAND ${CMAKE_COMMAND} -E touch foo
${USE_JOB_POOL}
VERBATIM
)
Or...?
add_custom_command(
OUTPUT foo
COMMAND ${CMAKE_COMMAND} -E touch foo
$<IF:$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.15.0>:JOB_POOL my_job_pool>
VERBATIM
)