[CMake] Setting variables in CMakeLists.txt

barcaroller barcaroller at sympatico.ca
Sat May 2 00:41:18 EDT 2009


"Philip Lowman" <philip at yhbt.com> wrote in message 
news:f168bb790904301926p217e9bafn6f58a1a2a9b12704 at mail.gmail.com...
>
> Which version of CMake are you using?
>

I was using cmake 2.6.3.  I have installed cmake 2.6.4 but the problem is 
still there.  Looking at the makefiles in the generated build/CMakeFiles 
confirms that only absolute pathnames are being generated.

However, when I use in-source builds (i.e. when I build inside the 'src' 
directory instead of the 'build' directory), all of this work perfectly as 
long as I use CACHE BOOL ""

    SET(CMAKE_VERBOSE_MAKEFILE    ON CACHE BOOL "")
    SET(CMAKE_USE_RELATIVE_PATHS  ON CACHE BOOL "")

In other words, relative and absolute paths are generated properly based on 
the CMAKE_USE_RELATIVE_PATHS variable (with CACHE BOOL "")

    > cd src     (instead of 'cd build')
    > cmake .    (instead of 'cmake ../src')
    > make       (generated relative pathnames; see below)

    /usr/bin/c++    -I. -I.. -I../.. -I/usr2/include/boost   -g -Wall -ansi  
-o CMakeFiles/myprogram.dir/myprogram.cpp.o  -c myprogram.cpp


So, to recap:

   If I use in-source builds, with CACHE BOOL "", it works
   If I use out-of-source builds, it does not work (with or without CACHE 
BOOL "")


I'm at a loss to explain this.  Given that cmake is being successfully used 
by KDE and Boost, I'm assuming that I'm doing something wrong.






More information about the CMake mailing list