[CMake] General questions
Yang Zhang
yanghatespam at gmail.com
Sun Feb 24 17:02:51 EST 2008
Yang Zhang wrote:
> Hi, thanks for your reply.
>
> Mike Jackson wrote:
> >
> > -- Mike Jackson Senior Research Engineer
> > Innovative Management & Technology Services
> >
> >
> > On Feb 23, 2008, at 4:34 AM, Yang Zhang wrote:
> >> - Can cmake auto-generate and cache transitive dependencies via
> >> #includes (best described in Peter Miller's paper "Recursive Make
> >> Considered Harmful")?
> >
> > I have no idea what a ransitive dependencies is, BUT cmake is more than
> > capable of generating custom header files based on input from the cmake
> > files. Look at the "CONFIGURE_FILE" command. run "cmake --help-command
> > CONFIGURE_FILE" in a terminal.
>
> That wasn't quite what I was asking, but I *think* the wiki has answered
> my question:
>
> "Auto depend information for C++, C, and Fortran"
Argh. I just did a little test where this feature seems to only work
partially. Here, we see it working:
$ mkdir test
$ cd test
$ mkdir inc
$ echo 'int main() { return 0; }' > inc/a.h
$ echo '#include "a.h"' > a.c
$ cat > CMakeLists.txt
project(a)
add_executable(a a.c)
include_directories(inc)
$ cmake .
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yz/test
$ make
Scanning dependencies of target a
[100%] Building C object CMakeFiles/a.dir/a.o
Linking C executable a
[100%] Built target a
$ make
[100%] Built target a
$ touch inc/a.h
$ make
Scanning dependencies of target a
[100%] Building C object CMakeFiles/a.dir/a.o
Linking C executable a
[100%] Built target a
$ make
[100%] Built target a
However, the following doesn't work (imagine now that a.h is a header
I'm working on, shared by multiple projects in /usr/local/include):
$ make clean
$ cat > CMakeLists.txt
project(a)
add_executable(a a.c)
$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yz/test
$ CPATH=inc make
Scanning dependencies of target a
[100%] Building C object CMakeFiles/a.dir/a.o
Linking C executable a
[100%] Built target a
$ CPATH=inc make
[100%] Built target a
$ touch inc/a.h
$ CPATH=inc make
[100%] Built target a
It appears that cmake doesn't know where the header files are actually
located, and hence is unable to add a proper dependency. I'm hoping to
avoid specifying the same include_directories(...) for all projects that
I'm working on. I've recently been surviving on an an ad-hoc build
system that uses gcc -M, which specifies full paths, but that's tied to
the compiler, of course.
--
Yang Zhang
http://www.mit.edu/~y_z/
More information about the CMake
mailing list