Skip to content

Instantly share code, notes, and snippets.

@parsa
Last active March 28, 2019 18:40
Show Gist options
  • Select an option

  • Save parsa/dbddcc623cd8b9c2d684cb178678c03c to your computer and use it in GitHub Desktop.

Select an option

Save parsa/dbddcc623cd8b9c2d684cb178678c03c to your computer and use it in GitHub Desktop.

Based on: https://stackoverflow.com/a/6646518/60996

References:

If Boost is always needed

find_package(Boost REQUIRED)
add_executable(progname file1.cxx file2.cxx) 
target_include_directories(progname PRIVATE ${Boost_INCLUDE_DIRS}) 
target_link_libraries(progname PRIVATE ${Boost_LIBRARIES})

If Boost is optional

find_package(Boost)
if(Boost_FOUND)
    add_executable(progname file1.cxx file2.cxx) 
    target_include_directories(progname PRIVATE ${Boost_INCLUDE_DIRS}) 
    target_link_libraries(progname PRIVATE ${Boost_LIBRARIES})
endif()

If you need specific libraries from Boost:

find_package(Boost COMPONENTS stuff)

e.g.

find_package(Boost COMPONENTS filesystem regex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment