[cmake-developers] Adding an option for relative compiler invocations

Michael Enßlin michael at ensslin.cc
Fri Jan 23 17:44:07 EST 2015


Hi,

thanks for your reply.

I am using an out-of-source build, and my build system even contains
rules to explicitly prohibit in-source builds.

To make __FILE__ behave correctly, you'd have to invoke the compiler
with a different cwd.

A generated line in build.make, which currently looks like this:

cd /home/mic/git/openage/.bin/gcc-release-O2/cpp && /usr/bin/g++
$(CXX_DEFINES) $(CXX_FLAGS) -o CMakeFiles/openage.dir/engine.cpp.o -c
/home/mic/git/openage/cpp/engine.cpp

would need to be changed to

cd /home/mic/git/openage && /usr/bin/g++ $(CXX_DEFINES) $(CXX_FLAGS) -o
/home/mic/git/openage/.bin/gcc-release-O2/cpp/CMakeFiles/openage.dir/engine.cpp.o
-c cpp/engine.cpp

The solution I'm currently using is similar to the one you're
suggesting; note that your suggestion can lead to misleading debug
messages or even undefined behavior in the event that __FILE__ does not
start with CMAKE_SOURCE_DIR for whatever reason.

I'm not using any non-library include paths, so the include issue
doesn't apply to my.

~ Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150123/736e1e97/attachment.sig>


More information about the cmake-developers mailing list