Kaynağa Gözat

cmake: add ccache support

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 2 yıl önce
ebeveyn
işleme
93f5348c47
1 değiştirilmiş dosya ile 14 ekleme ve 0 silme
  1. 14 0
      CMakeLists.txt

+ 14 - 0
CMakeLists.txt

@@ -38,6 +38,20 @@ option(WITH_GMP "Build with support for GNU Multi Precision Arithmetic Library"
 set(MPI_PROVIDER "LTM" CACHE STRING "Build tests and demos against 'LTM', 'TFM' or 'GMP', default is LTM")
 option(BUILD_SHARED_LIBS "Build shared library and only the shared library if \"ON\", default is static" OFF)
 
+#-----------------------------------------------------------------------------
+# Add support for ccache if desired
+#-----------------------------------------------------------------------------
+find_program(CCACHE ccache)
+
+if(CCACHE)
+    option(ENABLE_CCACHE "Enable ccache." ON)
+endif()
+
+# use ccache if installed
+if(CCACHE AND ENABLE_CCACHE)
+    set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
+endif()
+
 #-----------------------------------------------------------------------------
 # Compose CFLAGS
 #-----------------------------------------------------------------------------