Hello Tyler, Please find my comments below.
2009/5/28 Tyler Roscoe <[email protected]> > On Thu, May 28, 2009 at 08:56:04PM +0300, Dmytro Ovdiienko wrote: > > 1. We have two projects A and B. > > 2. Project A is stored to <root>/A > > 3. Project B is stored to <root>/B > > 4. Project A depends on B. > > 5. Project B depends on A. (please don't ask me why:) ) > > 6. There is CMakeLists.txt in the <root> > > If A and B really depend on each other, I don't know how you would ever > expect to build them, nor how you would expect CMake to handle this > case. > That was just a sample. CMake can build it correctly, if you specify full path to the include directlry. If you root CMakeLists.txt declares ROOT_PRJ you can write following in the A project. INCLUDE_DIRECTORIES( ${ROOT_PRJ_SOURCE_DIR}/B ) And following in the B project INCLUDE_DIRECTORIES( ${ROOT_PRJ_SOURCE_DIR}/A ) > > But from your Lists below it appears that they don't really depend on > one another, in a "target A must be built before target B" sense, but > simply that they use headers from each other's source directories? > A and B are static libraries. The order static libraries building has no mater. > > ##################################### > > # Project A > > ##################################### > > SET (PROJECT_NAME A ) > > PROJECT (${PROJECT_NAME}) > > > > INCLUDE_DIRECTORIES( > > ${B_SOURCE_DIR} > > ) > > > > FILE (GLOB ${PROJECT_NAME}_SOURCE_LIST > > *.cpp > > ) > > > > ADD_LIBRARY (${PROJECT_NAME} ${${PROJECT_NAME}_SOURCE_LIST}) > > > > ##################################### > > # Project B > > ##################################### > > SET (PROJECT_NAME B ) > > PROJECT (${PROJECT_NAME}) > > > > INCLUDE_DIRECTORIES( > > ${A_SOURCE_DIR} > > ) > > > > FILE (GLOB ${PROJECT_NAME}_SOURCE_LIST > > *.cpp > > ) > > > > ADD_LIBRARY (${PROJECT_NAME} ${${PROJECT_NAME}_SOURCE_LIST}) > > > > > > And now we generate the project files and check Additional Includes > > Directories of the A project. > > > > Expected it is equal to <root>/B. > > But in fact it is empty. > > Is ${B_SOURCE_DIR} defined in the CMakeLists for project A? > It is defined if B folder is processed before A folder. But then A_SOURCE_DIR is not defined in the B project (circular dependency) > > > The other side of this problem is you have to write ADD_SUBDIRECTORY > > commands in specific order. IMHO it is inconvenient. > > CMakeLists are essentially a scripting language, so of course order > matters. What would you propose instead? > But... why does TARGET_LINK_LIBRARIES work correctly? You can pass not loaded-yet project name to TARGET_LINK_LIBRARIES. > > tyler >
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
