How can I pass arguments to ranlib using cmake?

三世轮回 提交于 2019-12-10 23:37:38

问题


How can I pass an argument to ranlib when compiling a static library with CMake?

I tried:

set_target_properties(myLibrary STATIC_LIBRARY_FLAGS "--plugin /usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so")

and this worked for ar but not for the subsequent ranlib command.


回答1:


Have you tried this?

SET(CMAKE_C_ARCHIVE_FINISH   "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")

On the Mac, this is how I pass the "-no_warning_for_no_symbols" flag to ranlib.

Note: The SET commands don't modify the ranlib command used as part of an installation by running "make install." CMake's installer code does not generate installation scripts that allow for options to be added to ranlib.




回答2:


Adding

set_property(
    TARGET myLibrary
    APPEND
    PROPERTY STATIC_LIBRARY_FLAGS "-no_warning_for_no_symbols"
)

worked for me.



来源:https://stackoverflow.com/questions/32319369/how-can-i-pass-arguments-to-ranlib-using-cmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!