<span style="font-family:arial,sans-serif;font-size:12.666666984558105px">Hello, </span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px">I am trying to create a modular development environment. My goal is to have different source modules in separate source control projects. Sometimes there will be dependencies between these modules. I also will be scooping in 3rd party projects and placing some kind of wrapper build around it to make it conform to whatever standards I come up with to pull off this build environment. The main goal is to get and build a module (and there by all its dependencies) with minimal requirements for a build environment, and a minimal number of commands (On a fresh OS Install, git project; mkdir bld; cd bld; cmake ../project; make )</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">I researched build tools, decided on cmake over scons and autotools basically because it seemed popular, was on my base OS images, and it was easy to use.</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">As I was researching how to pull off my goals, I came across the ExternalProject_Add. Unfortunately I am stuck with RHEL 6 right now, and cmake 2.6 is all it supports, and this function appears to be added in 2.8</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">I investigated upgrading, which I didn't really want to do. I wanted to do development on almost any machine, and the one place I found an experimental repo with cmake 2.8 built for RHEL 6 seemed risky. Also I build on machines without internet access, and didn't want to end up in RPM hell trying to get it on, and end up with an expensive to replicate build environment.</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">So I tried to work around the issue in 2.6 using a combination of find_package and add_subdirectory. One requirements I made up is that if multiple paths in dependency tree share some parent, that parent is only retrieved from source control and built once. Yes I am ignoring custom flags differing in dependent modules, but I don't anticipate that requirement.</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">I tried add_subdirectory of an external directory, and I set the binary directory too. cmake completes without complaint, but then when I run make, I get a "No rule to make target 'dependency.so', needed by 'currentproject'. Stop. Google revealed that other people had this problem too. But any advice given to them I have tried and still no luck.</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">I have one more idea involving an unholy combination of prebuild custom command launching git, cmake, make. Make install would generate a module-config.cmake and then I would call find_package on that. It seems a bit crazy to do that when this is all fixed in 2.8</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">I am looking for some advice on how to accomplish my goals. Here is an example of 3 modules that would be in my source control, and how I would expect the directory layout to be.</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">+boost</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +include</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +lib</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> boost-config.cmake</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px">+core</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +src</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> some.cpp</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> CMakeLists.txt (depends on boost)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">+app</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +src</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> app.cpp</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> CMakeLists.txt (depends on boost and core)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px">Now I would get app from source control and build and expect this layout</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">+work</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +app (same as above)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +bld</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +core (same as above)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +core_bld</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> Makefile (and other cmake generated stuff)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +boost (same as above)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> +boost_bld</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> Makefile (and other cmake generated stuff)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> Makefile (and other cmake generated stuff)</span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"> </span><br style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span style="font-family:arial,sans-serif;font-size:12.666666984558105px">But currently when I add_subdirectory of core from the app's CMakeLists.txt I start running into trouble. I briefly tried moving the dependency source modules (core, boost) underneath the current module (app). This didn't work for me, but in theory I think it should as now add_subdirectory would actually be adding a subdirectory, so I may just need to put some more effort on it. This went against my desire to keep the module directories clean, the same as they are in source control, but I could live with this if it works, I would just make an external subfolder in each module and tell my source control to ignore it.</span><br>
<div><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">Does anyone have any advice for me?</span></div>
<div><span style="font-family:arial,sans-serif;font-size:12.666666984558105px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.666666984558105px">--Derrick</span></div>