[CMake] Static Library output problem

Michael Hertling mhertling at online.de
Sat Nov 12 16:49:06 EST 2011


On 11/11/2011 03:42 PM, Romain LEGUAY wrote:
> Ok thanks for your quick answers! It works perfectly now!
> 
> Why don't we have just one variables for the library?
> 
> With set_target_properties, we can define for each library the path.

Because

(1) ADD_LIBRARY() might lack the SHARED/STATIC keyword, and the user
can decide which type of library is built via the BUILD_SHARED_LIBS
variable, so an ADD_LIBRARY() command can be unalteredly used to
build a shared library as well as a static one, and

(2) on *nix, the outcome of ADD_LIBRARY(... SHARED ...) is a LIBRARY
target whereas on Windows, the DLL part is a RUNTIME target, and the
accompanying import library is an ARCHIVE target.

For these reasons, the same ADD_LIBRARY() command - i.e., the same
target - might generate different types of libraries, so there is
a need to specify the respective *_OUTPUT_DIRECTORY individually.

Regards,

Michael

> Le 11/11/2011 15:38, Andreas Pakulat a écrit :
>> On 11.11.11 15:18:05, Romain LEGUAY wrote:
>>> Hello everyone!
>>> First, I need to thank you all the CMake developers for their
>>> awesome work!!!
>>>
>>> I try to build a static and a shared libraries. I set the
>>> LIBRARY_OUTPUT_DIRECTORY for each library target like this:
>> See the documentation for the LIBRARY_OUTPUT_DIRECTORY, it only applies
>> to shared libraries on non-dll platforms (*nix usually). For a static
>> library you need to set ARCHIVE_OUTPUT_DIRECTORY.
>>
>> Andreas


More information about the CMake mailing list