简体   繁体   English

如何在cmake中动态设置目标库?

[英]How to set target library dynamically in cmake?

I use the boost_thread library. 我使用boost_thread库。 However, the name of this library in Linux is "boost_thread" but in Mac OSX is "boost_thread-mt". 但是,该库在Linux中的名称为“ boost_thread”,而在Mac OSX中为“ boost_thread-mt”。 Now I have to change this name repeatedly and manually in different platform. 现在,我必须在不同平台上反复手动更改此名称。 I want to know how to solve this problem. 我想知道如何解决这个问题。

The correct library name should already be provided through FindBoost . 正确的库名称应该已经通过FindBoost提供了。 Just use it like this: 像这样使用它:

find_package(Boost COMPONENTS thread)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(foo foo.cpp)
target_link_libraries(foo ${Boost_LIBRARIES})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM