<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" face="Monaco">I have a project structure that looks like this:</font><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">project</font></div><div><font class="Apple-style-span" face="Monaco">|</font></div><div><font class="Apple-style-span" face="Monaco">| - lib</font></div><div><font class="Apple-style-span" face="Monaco">| ----bin</font></div><div><font class="Apple-style-span" face="Monaco">| ----util</font></div><div><font class="Apple-style-span" face="Monaco">| --------inc</font></div><div><font class="Apple-style-span" face="Monaco">| --------src</font></div><div><font class="Apple-style-span" face="Monaco">| - app</font></div><div><font class="Apple-style-span" face="Monaco">| ----bin</font></div><div><font class="Apple-style-span" face="Monaco">| ----inc</font></div><div><font class="Apple-style-span" face="Monaco">| ----src</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">In short, each library in the project lives under project/lib. &nbsp;Built libraries are stored in project/lib/bin. &nbsp;Each library subdirectory (i.e. util) has a CMakeLists.txt to build that particular library. &nbsp;In the lib folder is a CMakeLists.txt which does add_subdirectory() on all the subdirectories. &nbsp;So far, so good - works like a charm.</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">The executable lives under project/app. &nbsp;The built executable is stored in project/app/bin. &nbsp;There is a CMakeLists.txt in project/app to build the application executable.</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">Now for the problem. &nbsp;How do I add the libraries as dependencies?</font></div><div><br></div><div><font class="Apple-style-span" face="Monaco">I can't use add_dependencies() because the app/CMakeLists.txt doesn't know about the targets in the library directories. &nbsp;I suppose I could do:</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">add_subdirectory(../../lib ../../lib/bin)</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">so it would know about those targets, but that doesn't seem the right solution.</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">I can certainly use find_library() to add the built libraries to my executable, but then my executable is not dependent upon being them and linking will fail if make was not executed in lib first.</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">Now, I certainly plan to have a project/CMakeLists.txt file that does add_subdirectory() on lib and app. &nbsp;Thus, if someone builds from that top level, it should all work if I use find_library() at the application level. &nbsp;However, I'd like it also to work if someone cd's into the application directory and types "cmake . ; make".&nbsp;</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">Any thoughts?</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">Thanks,</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><font class="Apple-style-span" face="Monaco">Wade&nbsp;</font></div><div><font class="Apple-style-span" face="Monaco"><br></font></div><div><br></div></body></html>