开发者

Conditional CMAKE link to rt-library

开发者 https://www.devze.com 2023-04-11 20:09 出处:网络
How to write CMakeLists.txt to conditionally link to the system-wide librt librar开发者_运维知识库y only when on Linux environment?cmake has several predefined variables useful for environment detecti

How to write CMakeLists.txt to conditionally link to the system-wide librt librar开发者_运维知识库y only when on Linux environment?


cmake has several predefined variables useful for environment detection (WIN32, UNIX, APPLE, CYGWIN). Here is the full list: http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_VariablesThatDescribetheSystem

So you can write something like

if(UNIX AND NOT APPLE)
    target_link_libraries(target_name rt)
endif()
0

精彩评论

暂无评论...
验证码 换一张
取 消