[CMake] Linker and archiver options

Isaiah Norton isaiah.norton at gmail.com
Tue Aug 14 22:16:37 EDT 2018


>
> This seems like something that would be best-suited for a toolchain file
>

Is a toolchain file not equivalent to the corresponding list of '-D'
initializers? (aside from convenience)

On Tue, Aug 14, 2018 at 1:34 PM Michael Ellery <mellery451 at gmail.com> wrote:

> This seems like something that would be best-suited for a toolchain file:
>
> https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
>
> Have you given that a try? Also, I wonder if STATIC_LIBRARY_FLAGS is a
> custom setting, because I don’t think that one is a standard cmake variable.
>
> -Mike
>
> > On Aug 14, 2018, at 9:30 AM, Irina Chernushina via CMake <
> cmake at cmake.org> wrote:
> >
> > Hi,
> >
> > What is the correct way of setting archiver (and flags) and linker
> > (and flags) outside the CMakeLists.txt?
> >
> > 1) I am trying to use the following pattern:
> >
> > cmake -DCMAKE_AR="<path-to-ar>" -DCMAKE_CXX_LINK_EXECUTABLE="<linker
> > path> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o
> > <TARGET> <LINK_LIBRARIES>" -DSTATIC_LIBRARY_FLAGS="<flags>"
> > -DCMAKE_SHARED_LINKER_FLAGS="<flags>"
> > -DCMAKE_EXE_LINKER_FLAGS="<flags>"
> >
> > Is that in general correct options to pass that information?
> > Judging by documentation, they are.
> >
> > 2) However, I am getting the following warning:
> > CMake Warning:
> >  Manually-specified variables were not used by the project:
> >
> >    STATIC_LIBRARY_FLAGS
> > (Also, in CMakeCache.txt this variable is UNINITIALIZED)
> >
> > If I am trying to use CMAKE_STATIC_LINKER_FLAGS, I get in the cache:
> >
> > //Path to a program.
> > CMAKE_AR:FILEPATH=/usr/bin/ar
> > ...
> > //Flags used by the linker during the creation of static libraries.
> > CMAKE_STATIC_LINKER_FLAGS:STRING=rcsD
> >
> > But the link command looks like:
> >
> > /usr/bin/ar qc libXXX.a rcsD file1.o .. filen.o
> > /usr/bin/ranlib libz.a
> >
> > and I get the error:
> > /usr/bin/ar: rcsD: No such file or directory
> >
> > Because the order of ar arguments is wrong, flags should come before
> "qc".
> >
> > Thank you in advance
> > Irina
> >
> >
> > Irina Chernushina | Software Developer | ichern at google.com |
> >
> >
> > Google Germany GmbH
> >
> > Erika-Mann-Straße 33
> >
> > 80636 München
> >
> >
> > Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
> >
> > Registergericht und -nummer: Hamburg, HRB 86891
> >
> > Sitz der Gesellschaft: Hamburg
> >
> >
> > Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise
> > erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes
> > weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich
> > bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.
> >
> >
> >
> > This e-mail is confidential. If you received this communication by
> > mistake, please don't forward it to anyone else, please erase all
> > copies and attachments, and please let me know that it has gone to the
> > wrong person.
> > --
> >
> > Powered by www.kitware.com
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
> >
> > CMake Support: http://cmake.org/cmake/help/support.html
> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
> > CMake Training Courses: http://cmake.org/cmake/help/training.html
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > https://cmake.org/mailman/listinfo/cmake
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180814/45e0d3f5/attachment-0001.html>


More information about the CMake mailing list