[CMake] making two targets with similar names

Juan Sanchez Juan.Sanchez at amd.com
Fri Aug 10 15:11:02 EDT 2007


Hi Bill,

Thanks, it works when I do this in SET_TARGET_PROPERTIES.

Juan

Juan Sanchez wrote:
> Hi Bill,
> 
> What's the proper syntax? Setting the variable in CMakeLists.txt doesn't
> work.  Neither does setting it in my initial Cache file (loaded with
> cmake -C).
> 
> SET (CLEAN_DIRECT_OUTPUT 1 CACHE STRING "1")
> 
> Thanks,
> 
> Juan
> 
> Bill Hoffman wrote:
>> Juan Sanchez wrote:
>>> I am having the following issue.  I want to create both a libFOO.a and a
>>> libFOO.so.  Note that the libFOO.so is composed of more sources than the
>>> libFOO.a.
>>>
>>> I use OUTPUT_NAME in order so they have the same name.  I can make the
>>> FOOSTATIC, libFOO.a, target, just fine.  However, making the FOODYNAMIC,
>>> libFOO.so, target deletes libFOO.a, just before linking against it.
>>> This causes a build error.
>>>
>>> Is there anyway to prevent this from happening?
>>>
>>>
>>> ADD_LIBRARY (FOOSTATIC  STATIC ${UDB_SRCS})
>>> ADD_LIBRARY (FOODYNAMIC SHARED ${PERL_SRCS})
>>>
>>> target_link_libraries(FOODYNAMIC  FOOSTATIC)
>>>
>>> SET_TARGET_PROPERTIES(FOODYNAMIC PROPERTIES
>>>     LINK_FLAGS --whole-archive
>>>     OUTPUT_NAME   FOO
>>> )
>>>
>>> SET_TARGET_PROPERTIES(FOOSTATIC PROPERTIES
>>>     OUTPUT_NAME   FOO
>>> )
>>>   
>> See the documentation for OUTPUT_NAME:
>>
>> When a library is built CMake by default generates code to remove any 
>> existing library using all possible names. This is needed to support 
>> libraries that switch between STATIC and SHARED by a user option. 
>> However when using OUTPUT_NAME to build a static and shared library of 
>> the same name using different logical target names the two targets will 
>> remove each other's files. This can be prevented by setting the 
>> CLEAN_DIRECT_OUTPUT property to 1.
>>
>>
>> -Bill
>>
>>
>>
> 
> 


-- 
Juan Sanchez
Juan.Sanchez at amd.com
800-538-8450 Ext. 54395
512-602-4395




More information about the CMake mailing list