[CMake] Multiple library configurations with the same output name

Eric Noulard eric.noulard at gmail.com
Thu Mar 3 07:11:56 EST 2011


2011/3/3 Alexey Livshits <livchits at web.de>:
> Hello CMakers,
> suppose I've got a library foo with tow configurations: foo_1 and
> foo_2. Both versions should have the same output name: foo. The
> problem is, the output directory for both ist the same, so the second
> will overwrite the first.

You can definition two different library target
and use OUTPUT_NAME property to adjust the name

add_library(foo1 ${foo_source})
set_target_properties(foo1 PROPERTIES
                                       OUTPUT_NAME foo)

add_library(foo2 ${foo_source})
set_target_properties(foo2 PROPERTIES
                                       OUTPUT_NAME foo)

You probably want to adjust COMPILE_FLAGS and/or LINK_FLAGS
for each target as well.

> What's the best way to organize it?

If you intend to build those librarie during the same build then
you'll have to define those targets in separate directories
(with shared source are shared).

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list