[CMake] running CMake from different parts of the tree

Michael Jackson mike.jackson at bluequartz.net
Thu Mar 12 08:59:47 EDT 2009


Depending on your build system (Makefiles works best although some  
IDE's may work this way also) is that you only have CMake generate  
build files from ProductLib/Build. Then if you are just tweaking  
baselib then you 'cd' into Build/BaseLib and do a "make" from there.  
Only BaseLib will be built. When BaseLib is working the way you want  
it to work then you can "cd ../" and do "make" which will then build  
productLib (assuming _nothing_ else necessitates a rebuild of baselib).

This is what I'll do when working on subparts of my projects and works  
well.

Eclipse CDT: Use a custom make command to tell 'make' to use the  
makefiles from Build/BaseLib
VS IDE: Just set the baselib as the only project to compile
Xcode: Set Baselib as the active target.

HTH
_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Mar 11, 2009, at 7:15 PM, Tyler Roscoe wrote:

> Let's say I have two components baselib and productlib. baselib has a
> CMakeLists and knows how to build itself. productlib has a CMakeLists,
> has add_subdirectory() and add_dependencies() and target_link_libs()
> calls to baselib, and knows how to build baselib and then itself.
>
> As a developer, I'm making some changes in baselib. I cd into
> baselib/build, run cmake .., and run make every once in a while to  
> check
> my changes.
>
> Now I'm done so I want to make sure that productlib still works. So  
> I cd
> into productli/build and run cmake ... When I run make, I am surprised
> to see that baselib recompiles and relinks even though there have been
> no changes (other than running cmake from a different directory).
>
> Is this expected? What causes it? I see that the generated Makefile  
> gets
> rewritten with some different paths -- is that what triggers the
> rebuild, or is it something else?
>
> Do your developers accept this as a fact of life, or do they have
> workarounds, or do they simply not work in this way (preferring to do
> something like always run make from the same top-level build directory
> no matter where in the tree they are working)? Am I crazy for wanting
> the ability to work with each component both on its own and as part of
> the larger system?
>
> Is there a way to avoid this behavior through careful writing of
> CMakeLists? Through some other hacks?
>
> Thanks,
> tyler
>



More information about the CMake mailing list