How can I pass arguments to ranlib using cmake?

2019-07-16 04:45发布

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.

2条回答
太酷不给撩
2楼-- · 2019-07-16 04:55

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.

查看更多
不美不萌又怎样
3楼-- · 2019-07-16 05:11

Adding

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

worked for me.

查看更多
登录 后发表回答