简体   繁体   中英

How to set target library dynamically in cmake?

I use the boost_thread library. However, the name of this library in Linux is "boost_thread" but in Mac OSX is "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 . 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})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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