[CMake] bug in GET_FILENAME_COMPONENT()

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jan 30 17:00:15 EST 2006


Hi, 
 
GET_FILENAME_COMPONENT(... ABSOLUTE) works only correct when used from 
the toplevel directory, i.e. CMAKE_SOURCE_DIR. If used from subdirs it 
interprets relative paths not as relative to the 
CMAKE_CURRENT_SOURCE_DIR, but also as relative to CMAKE_SOURCE_DIR. 
I filed a bug report, it's #2797 
 
 
cmGetFilenameComponentCommand::InitialPass() contains: 
... 
  else if (args[2] == "ABSOLUTE") 
  { 
    result = cmSystemTools::CollapseFullPath(filename.c_str()); 
  } 
 
which leads in SystemTools::CollapseFullPath() to the following code 
path: 
 
  if(in_base) 
... 
  else 
  { 
    // Use the current working directory as a base path. 
    char buf[2048]; 
    if(const char* cwd = Getcwd(buf, 2048)) 
... 
 
So either cmGetFilenameComponentCommand::InitialPass() should call 
CollapseFullPath() with ${CMAKE_CURRENT_SOURCE_DIR} as second argument, 
or SystemTools::CollapseFullPath() should use not the current working 
directory, but also ${CMAKE_CURRENT_SOURCE_DIR} as base path. 
 
(due to this bug I have to use this macro for building KDE:  
 
MACRO(QT4_GET_ABS_PATH _abs_filename _filename) 
  IF(${_filename} MATCHES "^([a-zA-Z]:)?/.+") 
    SET(${_abs_filename} ${_filename}) 
  ELSE(${_filename} MATCHES "^([a-zA-Z]:)?/.+") 
    SET(${_abs_filename} ${CMAKE_CURRENT_SOURCE_DIR}/${_filename}) 
  ENDIF(${_filename} MATCHES "^([a-zA-Z]:)?/.+") 
ENDMACRO(QT4_GET_ABS_PATH ) 
 
Bye 
Alex 
 
 

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner


More information about the CMake mailing list