[CMake] Linker Include Path
Matthias Schweinoch
matthias.schweinoch at gmx.de
Fri Oct 28 14:44:39 EDT 2011
Hi all,
I'm using cmake (2.8.5) to build a set of C++ libraries. I have a
project directory structure which is basically organized like this:
package/component/CMakeLists.txt
package/component/inc/foo.hpp
package/component/src/foo.cpp
Boiled down, my CMakeLists.txt for this component looks like this:
SET(HEADERS inc/foo.hpp)
SET(SOURCES src/foo.cpp)
SET(LIBS whatever)
INCLUDE_DIRECTORIES(inc)
ADD_LIBRARY(MyLib ${HEADERS} ${SOURCES})
TARGET_LINK_LIBRARIES(MyLib ${LIBRARIES})
This has worked fine for me. Now, however, I would like to add another
subdirectory to the src tree (this has organizational reasons),
resulting in something like this:
package/component/CMakeLists.txt
package/component/inc/foo.hpp
package/component/src/foo.cpp
package/component/src/xyz/xyz.cpp
I modified the SOURCES assignment in my CMakeLists.txt like so:
SET(SOURCES src/foo.cpp src/xyz/xyz.cpp)
While this does compile, it does not link. I assume that this is because
the xyz.o is put in
CURRENT_BINARY_OUTPUT/xyz/xyz.o
and the linker does not include that subdirectory. If I move the source
file up by one level (i.e. into the src directory), everything compiles
and links just fine, but that's not really an acceptable solution. Is
there some (portable) way to tell CMake to include the xyz output path
so that xyz.o is found at link time?
Thanks in advance for your help!
Matthias
More information about the CMake
mailing list