[CMake] Better way than: SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> my_flags ... ?

Marc Herbert marc.herbert at gmail.com
Sun Jul 14 01:09:51 EDT 2019


> Additional issue with this CMAKE_C_ARCHIVE_CREATE hack: it's ignored and
> reverts back to the default in link.txt when building a "pure assembly"
> library without any .c file. Adding an empty.c file works around the problem
>

Much better than adding an empty .c file: CMAKE_ASM_ARCHIVE_CREATE (resp.
CMAKE_CXX_ARCHIVE_CREATE).

Eventually I used:

foreach(lang ASM C CXX)
  SET(CMAKE_${lang}_CREATE_STATIC_LIBRARY

For the more general issue 2. below I filed
https://gitlab.kitware.com/cmake/cmake/issues/19474



> Is this expected? Reproduced with CMake 3.13 and 3.14.0.
>
>
> Le lun. 25 févr. 2019 à 11:41, Marc Herbert <marc.herbert at gmail.com> a
> écrit :
>
>> Hi,
>>
>> 1.  I found the hack below in the list's archive. However it seems...
>> hackish. Among others it can't _append_ a flag, it can only replace all
>> flags. Any newer and better way to append some extra flags?
>>
>> 2. Bonus question: how would you query "ar" and append some extra flags
>> *only* when ar/ranlib are new enough to support them?
>>
>> Thanks in advance,
>>
>> Marc
>>
>> SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -qcD <TARGET> <LINK_FLAGS>
>> <OBJECTS>")
>> SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190713/62cb46dd/attachment.html>


More information about the CMake mailing list