rok commented on code in PR #51139:
URL: https://github.com/apache/arrow/pull/51139#discussion_r3916996582


##########
python/CMakeLists.txt:
##########
@@ -130,11 +130,14 @@ if(CCACHE_FOUND
    AND NOT CMAKE_C_COMPILER_LAUNCHER
    AND NOT CMAKE_CXX_COMPILER_LAUNCHER)
   message(STATUS "Using ccache: ${CCACHE_FOUND}")
-  set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_FOUND})
-  set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_FOUND})
-  # ARROW-3985: let ccache preserve C++ comments, because some of them may be
-  # meaningful to the compiler
-  set(ENV{CCACHE_COMMENTS} "1")
+  # 1. Let ccache preserve C++ comments, because some of them may be
+  #    meaningful to the compiler (ARROW-3985)
+  # 2. Set ccache base_dir to the build output directory as it is typically
+  #    a temporary directory, and would otherwise fail caching because of
+  #    using different paths everytime.
+  set(ccache_command ${CCACHE_FOUND} keep_comments_cpp=true 
base_dir=${CMAKE_BINARY_DIR})

Review Comment:
   My :robot: suggest two options, preferring the first one. I would defer to 
@kou
   ```diff                                                                      
                                                                                
                                
   diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt                   
                                                                                
                              
   --- a/python/CMakeLists.txt                                                  
                                                                                
                              
   +++ b/python/CMakeLists.txt                                                  
                                                                                
                              
   @@ -136,7 +136,13 @@ if(CCACHE_FOUND                                         
                                                                                
                              
     # 2. Set ccache base_dir to the build output directory as it is typically  
                                                                                
                             
     #    a temporary directory, and would otherwise fail caching because of    
                                                                                
                             
     #    using different paths everytime.                                      
                                                                                
                             
   -  set(ccache_command ${CCACHE_FOUND} keep_comments_cpp=true 
base_dir=${CMAKE_BINARY_DIR})                                                   
                                              
   +  set(ccache_command                                                        
                                                                                
                              
   +      ${CMAKE_COMMAND}                                                      
                                                                                
                              
   +      -E                                                                    
                                                                                
                              
   +      env                                                                   
                                                                                
                              
   +      "CCACHE_COMMENTS=1"                                                   
                                                                                
                              
   +      "CCACHE_BASEDIR=${CMAKE_BINARY_DIR}"                                  
                                                                                
                              
   +      ${CCACHE_FOUND})                                                      
                                                                                
                              
     set(CMAKE_C_COMPILER_LAUNCHER ${ccache_command})                           
                                                                                
                             
     set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_command})                         
                                                                                
                             
   endif()                                                                      
                                                                                
                             
   ```
   
   or 
   
   ```diff                                                                      
                                                                                
                                
   diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt                   
                                                                                
                              
   --- a/python/CMakeLists.txt                                                  
                                                                                
                              
   +++ b/python/CMakeLists.txt                                                  
                                                                                
                              
   @@ -130,6 +130,17 @@ if(CCACHE_FOUND                                         
                                                                                
                              
    AND NOT CMAKE_CXX_COMPILER_LAUNCHER)                                        
                                                                                
                           
   message(STATUS "Using ccache: ${CCACHE_FOUND}")                              
                                                                                
                           
                                                                                
                                                                                
                           
   +  execute_process(                                                          
                                                                                
                              
   +    COMMAND ${CCACHE_FOUND} --version                                       
                                                                                
                              
   +    OUTPUT_VARIABLE ccache_version_output                                   
                                                                                
                              
   +    OUTPUT_STRIP_TRAILING_WHITESPACE)                                       
                                                                                
                              
   +  set(ccache_version "0")                                                   
                                                                                
                              
   +  if(ccache_version_output                                                  
                                                                                
                              
   +     MATCHES "ccache version ([0-9]+\\.[0-9]+(\\.[0-9]+)?)")                
                                                                                
                              
   +    set(ccache_version "${CMAKE_MATCH_1}")                                  
                                                                                
                              
   +  endif()                                                                   
                                                                                
                              
   +                                                                            
                                                                                
                              
   # 1. Let ccache preserve C++ comments, because some of them may be           
                                                                                
                           
   #    meaningful to the compiler (ARROW-3985)                                 
                                                                                
                           
   # 2. Set ccache base_dir to the build output directory as it is typically    
                                                                                
                           
   @@ -137,7 +148,12 @@ if(CCACHE_FOUND                                         
                                                                                
                              
   #    a temporary directory, and would otherwise fail caching because of      
                                                                                
                           
   #    using different paths everytime.                                        
                                                                                
                           
   -  set(ccache_command ${CCACHE_FOUND} keep_comments_cpp=true 
base_dir=${CMAKE_BINARY_DIR})                                                   
                                              
   +  if(ccache_version VERSION_GREATER_EQUAL 4.8)                              
                                                                                
                              
   +    set(ccache_command ${CCACHE_FOUND} keep_comments_cpp=true               
                                                                                
                              
   +                       base_dir=${CMAKE_BINARY_DIR})                        
                                                                                
                              
   +  else()                                                                    
                                                                                
                              
   +    message(STATUS "ccache ${ccache_version} does not support command-line 
configuration")                                                                 
                               
   +    set(ccache_command ${CCACHE_FOUND})                                     
                                                                                
                              
   +  endif()                                                                   
                                                                                
                              
   set(CMAKE_C_COMPILER_LAUNCHER ${ccache_command})                             
                                                                                
                           
   set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_command})                           
                                                                                
                           
   endif()                                                                      
                                                                                
                             
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to