File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ project(ArrayFire VERSION 3.7.1 LANGUAGES C CXX)
1111
1212set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR} /CMakeModules" )
1313
14+ include (config_ccache )
1415include (AFBuildConfigurations )
1516include (AFInstallDirs )
1617include (CMakeDependentOption )
Original file line number Diff line number Diff line change 1+ # picked up original content from https://crascit.com/2016/04/09/using-ccache-with-cmake/
2+
3+ if (UNIX )
4+ find_program (CCACHE_PROGRAM ccache )
5+
6+ set (CCACHE_FOUND OFF )
7+ if (CCACHE_PROGRAM)
8+ set (CCACHE_FOUND ON )
9+ endif ()
10+
11+ option (AF_USE_CCACHE "Use ccache when compiling" ${CCACHE_FOUND} )
12+
13+ if (${AF_USE_CCACHE} )
14+ # Set up wrapper scripts
15+ set (C_LAUNCHER "${CCACHE_PROGRAM} " )
16+ set (CXX_LAUNCHER "${CCACHE_PROGRAM} " )
17+ configure_file (${ArrayFire_SOURCE_DIR} /CMakeModules/launch-c.in launch-c )
18+ configure_file (${ArrayFire_SOURCE_DIR} /CMakeModules/launch-cxx.in launch-cxx )
19+ execute_process (COMMAND chmod a+rx
20+ "${ArrayFire_BINARY_DIR} /launch-c"
21+ "${ArrayFire_BINARY_DIR} /launch-cxx"
22+ )
23+ if (CMAKE_GENERATOR STREQUAL "Xcode" )
24+ # Set Xcode project attributes to route compilation and linking
25+ # through our scripts
26+ set (CMAKE_XCODE_ATTRIBUTE_CC "${ArrayFire_BINARY_DIR} /launch-c" )
27+ set (CMAKE_XCODE_ATTRIBUTE_CXX "${ArrayFire_BINARY_DIR} /launch-cxx" )
28+ set (CMAKE_XCODE_ATTRIBUTE_LD "${ArrayFire_BINARY_DIR} /launch-c" )
29+ set (CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${ArrayFire_BINARY_DIR} /launch-cxx" )
30+ else ()
31+ # Support Unix Makefiles and Ninja
32+ set (CMAKE_C_COMPILER_LAUNCHER "${ArrayFire_BINARY_DIR} /launch-c" )
33+ set (CMAKE_CXX_COMPILER_LAUNCHER "${ArrayFire_BINARY_DIR} /launch-cxx" )
34+ endif ()
35+ endif ()
36+ mark_as_advanced (CCACHE_PROGRAM )
37+ mark_as_advanced (AF_USE_CCACHE )
38+ endif ()
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Xcode generator doesn't include the compiler as the
4+ # first argument, Ninja and Makefiles do. Handle both cases.
5+ if [[ " $1 " = " ${CMAKE_C_COMPILER} " ]] ; then
6+ shift
7+ fi
8+
9+ export CCACHE_CPP2=true
10+ exec " ${C_LAUNCHER} " " ${CMAKE_C_COMPILER} " " $@ "
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Xcode generator doesn't include the compiler as the
4+ # first argument, Ninja and Makefiles do. Handle both cases.
5+ if [[ " $1 " = " ${CMAKE_CXX_COMPILER} " ]] ; then
6+ shift
7+ fi
8+
9+ export CCACHE_CPP2=true
10+ exec " ${CXX_LAUNCHER} " " ${CMAKE_CXX_COMPILER} " " $@ "
You can’t perform that action at this time.
0 commit comments