[CMake] newbie q - where do I put what in which CMakeLists file? out of source build
Johannes Zarl
Johannes.Zarl at jku.at
Wed Mar 9 05:19:42 EST 2011
> configure_file(src/config.h.in config.h)
In CMake, use of relative filenames is (mostly) discouraged. A robust
way to do this would be to write:
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in
${CMAKE_CURRENT_BINARY_DIRECTORY}/include/config.h )
include_directories( ${CMAKE_CURRENT_BINARY_DIRECTORY}/include )
The "include_directories" tells cmake to add a "-I/path/to/tone12/build/include" directive,
so config.h can be found.
>
> ~/tone12/src/CMakeLists.txt:
> add_executable(tone12 tone12.cpp midi.cpp midi.h riffwave.cpp riffwave.cpp
> tonegen.cpp tonegen.h)
> configure_file(config.h.in config.h)
It's normally not a good idea to call configure_file twice. You have to decide
which of the two configure_file statements you really want (which fits your project style,
is more robust when changing directory names,...).
You have the same issue with relative paths here, as above. If you want to configure
your header here, you could write:
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIRECTORY}/config.h )
include_directories( ${CMAKE_CURRENT_BINARY_DIRECTORY} )
(Current binary directory in this case evaluates to /path/to/tone12/build/src.)
HTH,
Johannes
--
Johannes Zarl
Virtual Reality Services
Johannes Kepler University
Informationsmanagement
Altenbergerstrasze 69
4040 Linz, Austria
Phone: +43 732 2468-8321
johannes.zarl at jku.at
http://vrc.zid.jku.at
More information about the CMake
mailing list