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

Marc Herbert marc.herbert at gmail.com
Fri Apr 5 23:00:10 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.

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/20190405/76386f91/attachment-0001.html>


More information about the CMake mailing list