I have come up with a partial solution to this issue by putting the add_subdirectory into a macro that is called to do the add along with the add_depend.
It looks for a variable of ${CMAKE_PROJECT_NAME}_BUILT in order to determine if it should add_subdirectory or just add_depend. The issue now is that I recieve warnings of overiding commands and ignoring old commands for the shared dependency. Let me clarify my earlier post. My top level project contains 4 projects. /trunk/a (Only Executable) /trunk/b /trunk/c /trunk/d To Build, a requires b. b requires c. Both a and c require d. In a: project(a) set(BASEDIR /trunk) add_subdirectory(${BASEDIR}/b ${CMAKE_BINARY_DIR}/b) add_subdirectory(${BASEDIR}/d ${CMAKE_BINARY_DIR}/d) ... In b: project(a) set(BASEDIR /trunk) add_subdirectory(${BASEDIR}/c ${CMAKE_BINARY_DIR}/c) ... In c: project(a) set(BASEDIR /trunk) add_subdirectory(${BASEDIR}/d ${CMAKE_BINARY_DIR}/d) ... This method fails due to the same Bin dir being used for d in both c and a. To solve this, I created a macro that does the following along with adding set (${CMAKE_PROJECT_NAME}_BUILT 1) to all projects if(${_name}_BUILT) add_dependencies(${_target} ${_name}) else() add_subdirectory(${_src} ${_bin}) add_dependencies(${_target} ${_name}) endif() The issue that now appears is that project d has the following warnings when make is ran. CMakeFiles/Makefile2:76051: warning: overriding commands for target `trunk/d/CMakeFiles/d.dir/all' CMakeFiles/Makefile2:64065: warning: ignoring old commands for target `trunk/d/CMakeFiles/d.dir/all' CMakeFiles/Makefile2:76063: warning: overriding commands for target `trunk/d/CMakeFiles/d.dir/rule' CMakeFiles/Makefile2:64077: warning: ignoring old commands for target `trunk/d/CMakeFiles/d.dir/rule' CMakeFiles/Makefile2:76074: warning: overriding commands for target `trunk/d/CMakeFiles/d.dir/clean' CMakeFiles/Makefile2:64088: warning: ignoring old commands for target `trunk/d/CMakeFiles/d.dir/clean' What would cause this issue in the makefiles? ________________________________ From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of Schwartz, Philip Sent: Monday, January 25, 2010 4:33 PM To: cmake@cmake.org Subject: [CMake] Out of source dependencies. The current project that I am working on has multiple projects layered through subdirectories. The project was a conversion from traditional makefiles and when we do a cmake build from the root of the source tree all is done correctly. The issue comes to when we try and build a single component from a out of source build directory (we are requiring out of source builds). I have found a temp solution for example /trunk/a /trunk/b /trunk/c a requires b and b requires c to build correctly. As long as they dont share dependencies, if I use add_subdirectory(src ${CMAKE_BINARY_DIR}/<project>) for each it works to build the deps as needed. The issue is if both a and c require the another dep pulled in the same way. The error that comes up is through a policy error of CMP0013. Yes, I could disable the policy, but would prefer a more elegant solution for the issue. Any help would be appreciated. --Philip ________________________________ This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. ________________________________ This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.
_______________________________________________ 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