Hello Willy,

On 1/4/13 4:58 PM, Willy Lambert wrote:
> I am trying to convert an existing project from Manual Makefiles to
> Cmake for building it.
> We have a logger that rely on the __FILE__ define to say which file is
> "writing" into the log but this is broken by the CMake default
> behavior using absolute paths.
> So I wonder if there is any way to have the file name in the code to
> be able to log "Error : line XXX in file.cpp".

This is somewhat hackish and should be surrounded by a check for the
Makefile generator:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst
${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")

Thanks,
Gregor

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to