Skip to content

Instantly share code, notes, and snippets.

@pestilence669
Last active June 18, 2016 00:36
Show Gist options
  • Save pestilence669/65f0d31c67554d39b416a5deebf3ced5 to your computer and use it in GitHub Desktop.
Save pestilence669/65f0d31c67554d39b416a5deebf3ced5 to your computer and use it in GitHub Desktop.
Basic CMake C++11 w/ Boost configuration
# vim: set ts=4 sw=4 noet fileencoding=utf-8:
#
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Release ..
#
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.60.0 COMPONENTS program_options)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(main main.cpp)
target_link_libraries(main ${Boost_LIBRARIES})
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment