[CMake] newbie q - where do I put what in which CMakeLists file? out of source build

Pierre Abbat phma at phma.optus.nu
Tue Mar 8 12:24:45 EST 2011


I have a program called "tone12" which I was working on in KDevelop 3, then 
copied to my DragonFly box which has KDev 4. Finding out that KDev4 no longer 
has support for autotools, I created an empty project, copied the files, and 
got it to compile. Then I added a big-endian test (I just added a MIDI 
parsing routine, and some numbers are written in MIDI files with a specified 
endianness). CMake looks easy enough to manage without an IDE, and the KDev I 
have isn't developed enough. So I'd like to make a tree that looks like this:

~/tone12:
CMakeLists.txt
src/
build/
README
INSTALL
LICENSE

~/tone12/src:
CMakeLists.txt
config.h.in
midi.h
riffwave.h
tonegen.cpp
midi.cpp
riffwave.cpp
tone12.cpp
tonegen.h

~/tone12/build:
(object files and executable go here)
(also some midi files for the program to read)

I'd like it to make a tarball package consisting of the listed files in tone12 
and tone12/src, but not the config.h or the midi files. My CMakeLists files 
are currently as follows:

~/tone12/CMakeLists.txt:
project(tone12)

add_subdirectory(src)

INCLUDE(CPack)
INCLUDE(TestBigEndian)

TEST_BIG_ENDIAN(BIGENDIAN)
configure_file(src/config.h.in config.h)

~/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)

The result is that config.h goes in ~/tone12/build/src, where make can't find 
it. I don't want build/src, just build. How do I fix it?

Pierre
-- 
li ze te'a ci vu'u ci bi'e te'a mu du
li ci su'i ze te'a mu bi'e vu'u ci


More information about the CMake mailing list