Skip to content

Commit

Permalink
Disable RDI CCCAHE if cmake version great that 3.20.0 (#8262)
Browse files Browse the repository at this point in the history
> For the Makefile Generators, source dependencies are now, for a
> selection of compilers, generated by the compiler itself.

This doesn't work in RDI CCACHE which generates its own compiler
induced dependencies.

There is a variable CMAKE_DEPENDS_USE_COMPILER to revert to old
behavior but that does not work.

This PR disables RDI CCACHE if CMake is not compatible.

Signed-off-by: Soren Soe <[email protected]>
  • Loading branch information
stsoe authored Jul 1, 2024
1 parent d977685 commit 4825962
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions src/CMake/ccache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,41 @@
#
if (RDI_CCACHE)

find_program(gccwrap /tools/batonroot/rodin/devkits/lnx64/ccwrap/gccwrap)
find_program(gccarwrap /tools/batonroot/rodin/devkits/lnx64/ccwrap/gccarwrap)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0")
message ("-- CCACHE doesn't work with CMake version >= 3.20.0")
else()

if (gccwrap)
message ("-- Using compile cache wrapper ${gccwrap} with cache in $ENV{RDI_CCACHEROOT}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${gccwrap} --with-cache-rw")
endif ()
find_program(gccwrap /tools/batonroot/rodin/devkits/lnx64/ccwrap/gccwrap)
find_program(gccarwrap /tools/batonroot/rodin/devkits/lnx64/ccwrap/gccarwrap)

if (gccwrap)
message ("-- Using compile cache wrapper ${gccwrap} with cache in $ENV{RDI_CCACHEROOT}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${gccwrap} --with-cache-rw")
endif ()

if (gccarwrap)
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -qc -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -qc -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH)
set(CMAKE_C_ARCHIVE_FINISH)
message ("-- Using link cache wrapper ${gccarwrap} with cache in $ENV{RDI_CCACHEROOT}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${gccarwrap} --with-cache-rw")
endif ()
if (gccarwrap)
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -qc -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -qc -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH)
set(CMAKE_C_ARCHIVE_FINISH)
message ("-- Using link cache wrapper ${gccarwrap} with cache in $ENV{RDI_CCACHEROOT}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${gccarwrap} --with-cache-rw")
endif ()

# Disable abi compile time checks which renders ccache close to useless
message ("***** CCACHE: DISABLING ABI VERSION CHECK ******")
add_compile_options("-DDISABLE_ABI_CHECK")
# Disable abi compile time checks which renders ccache close to useless
message ("***** CCACHE: DISABLING ABI VERSION CHECK ******")
add_compile_options("-DDISABLE_ABI_CHECK")

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0")
# New in version 3.20.
# For the Makefile Generators, source dependencies are now, for a
# selection of compilers, generated by the compiler itself. By
# defining this variable with value FALSE, you can restore the
# legacy behavior (i.e. using CMake for dependencies discovery).
# Apparently doesn't work.
set(CMAKE_DEPENDS_USE_COMPILER FALSE)
endif()

endif()

endif()

0 comments on commit 4825962

Please sign in to comment.