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()
精彩评论