From 045e9316adacfe364298d9480526c6d70ac45459 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 2 May 2016 14:38:12 -0400 Subject: [PATCH] update CMakeLists.txt to build with C++11 (#682) --- CMakeLists.txt | 16 ++++++++-------- examples/run_cmake.sh.in | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a21008a16..62a660384 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) + project(libtorrent) set (SOVERSION "8") set (VERSION "1.1.0") @@ -156,14 +157,13 @@ set(includes include ed25519/src) option(shared "build libtorrent as a shared library" ON) option(static_runtime "build libtorrent with static runtime" OFF) -option(tcmalloc "link against google performance tools tcmalloc" OFF) option(pool-allocators "Uses a pool allocator for disk and piece buffers" ON) option(encryption "link against openssl and enable encryption" ON) option(dht "enable support for Mainline DHT" ON) option(unicode "enable unicode support" ON) option(deprecated-functions "enable deprecated functions for backwards compatibility" ON) option(exceptions "build with exception support" ON) -option(logging "build with logging" OFF) +option(logging "build with logging" ON) option(build_tests "build tests" OFF) set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo) @@ -316,21 +316,21 @@ if (MSVC) #$(SolutionDir)msvc,release:/OPT:ICF=5 #$(SolutionDir)msvc,release:/OPT:REF elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_definitions(-Wno-c++11-extensions) add_definitions(-fcolor-diagnostics) endif() add_definitions(-D_FILE_OFFSET_BITS=64) add_definitions(-DBOOST_EXCEPTION_DISABLE) add_definitions(-DBOOST_ASIO_ENABLE_CANCELIO) - -if (tcmalloc) - target_link_libraries(torrent-rasterbar tcmalloc) -endif() +add_definitions(-DBOOST_ASIO_HAS_STD_CHRONO) set_target_properties(torrent-rasterbar PROPERTIES SOVERSION ${SOVERSION}) +# libtorrent requires at least C++11 +set_property(TARGET torrent-rasterbar PROPERTY CXX_STANDARD 11) +set_property(TARGET torrent-rasterbar PROPERTY CXX_STANDARD_REQUIRED ON) + get_property (COMPILETIME_OPTIONS_LIST DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY} PROPERTY COMPILE_DEFINITIONS diff --git a/examples/run_cmake.sh.in b/examples/run_cmake.sh.in index 53269e721..111d79344 100755 --- a/examples/run_cmake.sh.in +++ b/examples/run_cmake.sh.in @@ -2,7 +2,6 @@ cd ${libtorrent_BINARY_DIR}/examples cmake \ - -D libtorrent_includes_asio_source=${asio_source} \ -G "${CMAKE_GENERATOR}" \ $@ \ ${libtorrent_SOURCE_DIR}/examples