Fwd: How to build static libraries with cmake (and more)? (was: Re: Testing internal classes)

Brad King brad.king at kitware.com
Fri May 12 23:36:34 CEST 2006


Friedrich W. H. Kossebau wrote:
> Alex, William, any other cmake guru, please:
> (How) could we build static libraries?

add_library(mylib-static STATIC src1.cxx src2.cxx)

If you want it to have the same name as a shared library then set the 
OUTPUT_NAME:

set_target_properties(mylib-static PROPERTIES OUTPUT_NAME mylib)

This may have problems on windows though because the static mylib.lib 
will have the same name as the import library mylib.lib that goes with 
mylib.dll.

> (How) could we build separate libraries with some build flag (visibility
>  here) turned off?

Use set_target_properties to set the COMPILE_FLAGS property which allows 
per-target flags.

> (How) could/should we link to uninstalled libraries (very much appreciated)?

If they are in the same build tree as your programs then just name the 
library.  Otherwise you'll have to find the kde build tree containing 
the libraries you need.  This is not a CMake issue though.

> Are there any plans to "make test/check" trigger a test build like with
>  auto*? Does this all make sense?

What do you mean by "test build"?  CTest provides 
nightly/continuous/experimental builds submitting to a dashboard:

http://public.kitware.com/KDE/Testing/Dashboard/MostRecentResults-Nightly/Dashboard.html

If you want to build code as part of running a test you can use the 
"ctest --build-and-test" feature to create your test.  Most of CMake's 
internal tests are run this way:

http://www.cmake.org/cgi-bin/viewcvs.cgi/Source/CMakeLists.txt?root=CMake&view=markup

-Brad


More information about the Kde-buildsystem mailing list