22# SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik
33# SPDX-License-Identifier: BSD-3-Clause
44
5- cmake_minimum_required (VERSION 3.20 ...3.31 )
5+ cmake_minimum_required (VERSION 3.21 ...3.31 )
66
77include (FindPackageMessage )
88
@@ -12,36 +12,29 @@ include (FindPackageMessage)
1212# * https://ccache.dev/
1313# * https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html
1414macro (hibf_require_ccache )
15- set (HIBF_USE_CCACHE
16- ON
17- CACHE BOOL "Use ccache if available." )
18- set (HIBF_FPROFILE_ABS_PATH "-fprofile-abs-path" )
19- if (HIBF_USE_CCACHE)
15+ option (USE_CCACHE "Use ccache if available." ON )
16+
17+ if (USE_CCACHE)
2018 find_program (CCACHE_PROGRAM ccache )
2119
2220 if (NOT CCACHE_PROGRAM)
23- find_package_message (CCACHE_PROGRAM " Ccache program: not available" "[${CCACHE_PROGRAM} ]" )
21+ find_package_message (CCACHE_PROGRAM " Ccache program: not available" "[${CCACHE_PROGRAM} ]" )
2422 else ()
25- find_package_message (CCACHE_PROGRAM " Ccache program: available" "[${CCACHE_PROGRAM} ]" )
26- set (HIBF_FPROFILE_ABS_PATH "--ccache-skip -fprofile-abs-path" )
27- # New option since cmake >= 3.4:
28- # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html
29- if (NOT CMAKE_VERSION VERSION_LESS 3.15) # cmake >= 3.15
30- list (PREPEND CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
31- list (PREPEND CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
32- else ()
33- # prepend ccache to CMAKE_CXX_COMPILER_LAUNCHER
34- list (INSERT CMAKE_CXX_COMPILER_LAUNCHER 0 "${CCACHE_PROGRAM} " )
35- list (INSERT CMAKE_C_COMPILER_LAUNCHER 0 "${CCACHE_PROGRAM} " )
36- endif ()
23+ find_package_message (CCACHE_PROGRAM " Ccache program: available" "[${CCACHE_PROGRAM} ]" )
24+
25+ set (CMAKE_CXX_COMPILER_LAUNCHER
26+ "${CCACHE_PROGRAM} "
27+ CACHE INTERNAL "" )
28+ set (CMAKE_C_COMPILER_LAUNCHER
29+ "${CCACHE_PROGRAM} "
30+ CACHE INTERNAL "" )
3731
38- if ( NOT CMAKE_VERSION VERSION_LESS 3.21) # cmake >= 3.21
39- list ( PREPEND CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_PROGRAM} " )
40- list ( PREPEND CMAKE_C_LINKER_LAUNCHER " ${CCACHE_PROGRAM} " )
41- else ()
42- set_property ( GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM} " )
43- endif ( )
32+ set (CMAKE_CXX_LINKER_LAUNCHER
33+ "${CCACHE_PROGRAM} "
34+ CACHE INTERNAL " " )
35+ set (CMAKE_C_LINKER_LAUNCHER
36+ "${CCACHE_PROGRAM} "
37+ CACHE INTERNAL "" )
4438 endif ()
45- unset (CCACHE_PROGRAM)
4639 endif ()
4740endmacro ()
0 commit comments