Skip to content

Support _incremental_ CMAKE_AR_FLAGS / CMAKE_RANLIB_FLAGS

There doesn't to be any way to "tune" the existing CMAKE_${lang}_CREATE_STATIC_LIBRARY commands that generate libfoo.a files. The only to add a new flag like for instance "-D" seems to be:

  • reverse engineer what flags and/or commands CMake uses by default
  • redefine the entire CMAKE_${lang}_CREATE_STATIC_LIBRARY command or the CMAKE_C_ARCHIVE_CREATE one or CMAKE_C_ARCHIVE_FINISH - not even clear which one is/are best.
  • Pray a future CMake version doesn't break it

Example: https://github.com/zephyrproject-rtos/zephyr/pull/17495/files

foreach(lang ASM C CXX)
  # GNU ar always updates the index: no need for CMAKE_RANLIB
  SET(CMAKE_${lang}_CREATE_STATIC_LIBRARY
      "<CMAKE_AR> qcD <TARGET> <LINK_FLAGS> <OBJECTS>")
endforeach()

https://stackoverflow.com/questions/5659225/how-do-i-set-the-options-for-cmake-ar/5663246

https://cmake.org/pipermail/cmake/2019-February/069087.html Etc.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information