[CMake] Several subprojects in subdirectories
Igor Polyakov
igorpol_gbt at mail.ru
Wed Nov 9 03:06:45 EST 2005
Hello, cmake.
I have a directory, where my project is located.
I have three subprojects within subdirectories: "lib", "src" and
"tests" and coresponding source files within each of these subdirectories.
Subprojects have the following dependencies: src -> lib, tests -> lib.
I want to have ability to build all of these subprojects at one time
or build one of them or (more, if there are out-of-date dependencies
between subprojects).
How could I do this with CMake ?
What I've done:
I've written CMakeLists.txt within each of subdirectories, each of
these files specifying, how to make one of subprojects. And I have
written CMakeLists.txt in the top directory with only one line:
SUBDIRS(lib src tests)
What problems do I have:
I don't know, how to specify, that subproject src is dependent from
subproject lib, so it should be built only after library is created.
I tried in src directory:
1.
TARGET_LINK_LIBRARIES(${MyExe} ../lib/MyLib.lib)
Doesn't work, because CMake requires absolute paths.
2.
FIND_LIBRARY(MyLibPath NAMES MyLib PATHS ${MyExe_SOURCE_DIR}/../lib)
TARGET_LINK_LIBRARIES(${MyExe} ${MyLibPath})
Doesn't work when I build "src", when "lib" is not built - CMake could
not find library with such name.
What am I missing ? Please, help !
--
Best regards,
Igor Polyakov mailto:igorpol_gbt at mail.ru
More information about the CMake
mailing list