소스 검색

cmake: add ccache support

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 2 년 전
부모
커밋
93f5348c47
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  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")
 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)
 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
 # Compose CFLAGS
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------