1818function (pcl_ccache_compat_file_gen FILE_NAME CCACHE_PROGRAM COMPILER )
1919 message (STATUS "${FILE_NAME} for ${CCACHE_PROGRAM} with ${COMPILER} " )
2020 file (WRITE "${CMAKE_BINARY_DIR} /${FILE_NAME} " ""
21- "#!/ bin/sh\n "
21+ "#! /usr/ bin/env sh\n "
2222 "\n "
2323 "# Xcode generator doesn't include the compiler as the\n "
2424 "# first argument, Ninja and Makefiles do. Handle both cases.\n "
@@ -90,9 +90,10 @@ function(UseCompilerCache)
9090 # Indirect wrapper is needed for CCache < 3.3 or XCode
9191 if (NOT (${xcode_compat} OR ${ccache_compat} ))
9292 # Support Unix Makefiles and Ninja
93- set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
94- set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
95- set (CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " )
93+ message (STATUS "Compiler cache via cmake launcher prefix" )
94+ set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " PARENT_SCOPE )
95+ set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " PARENT_SCOPE )
96+ set (CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM} " PARENT_SCOPE )
9697 return ()
9798 endif ()
9899
@@ -105,22 +106,29 @@ function(UseCompilerCache)
105106 "${CMAKE_BINARY_DIR} /launch-cxx" )
106107
107108 # Cuda support only added in CMake 3.10
109+ set (cuda_supported FALSE )
108110 if (NOT (CMAKE_VERSION VERSION_LESS 3.10) AND CMAKE_CUDA_COMPILER)
111+ set (cuda_supported TRUE )
112+ endif ()
113+ if (${cuda_supported} )
109114 pcl_ccache_compat_file_gen ("launch-cuda" ${CCACHE_PROGRAM} ${CMAKE_CUDA_COMPILER} )
110115 execute_process (COMMAND chmod a+rx
111116 "${CMAKE_BINARY_DIR} /launch-cuda" )
112117 endif ()
113118
114119 if (${xcode_compat} )
115120 # Set Xcode project attributes to route compilation and linking properly
116- set (CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR} /launch-c" )
117- set (CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR} /launch-cxx" )
118- set (CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR} /launch-c" )
119- set (CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR} /launch-cxx" )
121+ message (STATUS "Compiler cache via launch files to support XCode" )
122+ set (CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR} /launch-c" PARENT_SCOPE )
123+ set (CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR} /launch-cxx" PARENT_SCOPE )
124+ set (CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR} /launch-c" PARENT_SCOPE )
125+ set (CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR} /launch-cxx" PARENT_SCOPE )
120126 else ()
121- # Support Unix Makefiles and Ninja
122- set (CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR} /launch-c" )
123- set (CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR} /launch-cxx" )
124- set (CMAKE_CUDA_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR} /launch-cuda" )
127+ message (STATUS "Compiler cache via launch files to support Unix Makefiles and Ninja" )
128+ set (CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR} /launch-c" PARENT_SCOPE )
129+ set (CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR} /launch-cxx" PARENT_SCOPE )
130+ if (${cuda_supported} )
131+ set (CMAKE_CUDA_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR} /launch-cuda" PARENT_SCOPE )
132+ endif ()
125133 endif ()
126134endfunction ()
0 commit comments