mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
Merge pull request #6501
3843a6ab
Made ccache optional (opt out) and tidied up the FindCcache.cmake (mj-xmr)
This commit is contained in:
commit
7cd0d7f324
2 changed files with 15 additions and 7 deletions
|
@ -48,7 +48,12 @@ message(STATUS "CMake version ${CMAKE_VERSION}")
|
||||||
|
|
||||||
project(monero)
|
project(monero)
|
||||||
|
|
||||||
include(FindCcache) # Has to be included after the project() macro, to be able to read the CXX variable.
|
option (USE_CCACHE "Use ccache if a usable instance is found" ON)
|
||||||
|
if (USE_CCACHE)
|
||||||
|
include(FindCcache) # Has to be included after the project() macro, to be able to read the CXX variable.
|
||||||
|
else()
|
||||||
|
message(STATUS "ccache deselected")
|
||||||
|
endif()
|
||||||
|
|
||||||
enable_language(C ASM)
|
enable_language(C ASM)
|
||||||
|
|
||||||
|
|
|
@ -41,17 +41,20 @@
|
||||||
|
|
||||||
find_program(CCACHE_FOUND ccache)
|
find_program(CCACHE_FOUND ccache)
|
||||||
if (CCACHE_FOUND)
|
if (CCACHE_FOUND)
|
||||||
set(TEMP_CPP_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test-program.cpp")
|
# Try to compile a test program with ccache, in order to verify if it really works. (needed on exotic setups)
|
||||||
|
# Create a temporary file with a simple program.
|
||||||
|
set(TEMP_CPP_FILE "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/test-program.cpp")
|
||||||
file(WRITE "${TEMP_CPP_FILE}" "int main() { return 0; }")
|
file(WRITE "${TEMP_CPP_FILE}" "int main() { return 0; }")
|
||||||
|
# And run the found ccache on it.
|
||||||
execute_process(COMMAND "${CCACHE_FOUND}" "${CMAKE_CXX_COMPILER}" "${TEMP_CPP_FILE}" RESULT_VARIABLE RET)
|
execute_process(COMMAND "${CCACHE_FOUND}" "${CMAKE_CXX_COMPILER}" "${TEMP_CPP_FILE}" RESULT_VARIABLE RET)
|
||||||
if (${RET} EQUAL 0)
|
if (${RET} EQUAL 0)
|
||||||
message("found usable ccache: ${CCACHE_FOUND}")
|
# Success
|
||||||
|
message(STATUS "Found usable ccache: ${CCACHE_FOUND}")
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_FOUND}")
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_FOUND}")
|
||||||
else()
|
else()
|
||||||
message("found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}")
|
message(STATUS "Found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message("ccache NOT found!")
|
message(STATUS "ccache NOT found! Please install it for faster rebuilds.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue