[CMake] Best practice for static libraries and include files

Alexander Neundorf a.neundorf-work at gmx.net
Fri Mar 8 16:33:01 EST 2013


On Friday 08 March 2013, Alessandro Saccoia wrote:
> > Even better, if each of your libraries declares a project, you can use
> > ${lib1_SOURCE_DIR}/src, and you won't have to change it if you later
> > move lib1 to a different place in the source tree.
> 
> I didn't know about this syntax, it's very handy indeed. I always try to
> make self contained projects, with 2 directories: include with the public
> interface to the library, and src that contains not just .cxx files but
> also the internal headers. So this is the best solution.
> 
> > (I've seen legitimate uses of defining variables for libraries' interface
> > properties, e.g. include directories, but all of this is about to become
> > properly supported :-), and anyway isn't something I would recommend
> > trying to emulate in a young project.)
> 
> Where can I find more about it?
> 
> OT: Since we're already here, do you know why CTest seems to be broken, as
> I need to create a new custom target that depends on the tests in order to
> run them, i.e. "make check" doesnt do anything and "ctest -N" always shows
> "Total Tests: 0"? 

I think you have to post some parts of your CMakeLists.txt.
Do you call enable_testing() ?

> Also, I want my tests to be verbose and both cout and
> cerr seem to be redirected to /dev/null so I can read nothing… 


Run ctest with -V -VV  to get more output.

Alex


More information about the CMake mailing list