diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 79 |
1 files changed, 56 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 099737212..5655bfc83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,22 @@ cmake_minimum_required(VERSION 2.8.6) +set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + +if (NOT DEFINED ENV{DEVELOPER_LOCAL_TOOLS}) + message(STATUS "Could not find DEVELOPER_LOCAL_TOOLS in env") + set(BOOST_IGNORE_SYSTEM_PATHS_DEFAULT OFF) +elseif ("$ENV{DEVELOPER_LOCAL_TOOLS}" EQUAL 1) + message(STATUS "found: env DEVELOPER_LOCAL_TOOLS = 1") + set(BOOST_IGNORE_SYSTEM_PATHS_DEFAULT ON) + option(BOOST_IGNORE_SYSTEM_PATHS "Ignore boost system paths for local boost installation" ON) +else() + message(STATUS "found: env DEVELOPER_LOCAL_TOOLS = 0") + set(BOOST_IGNORE_SYSTEM_PATHS_DEFAULT OFF) +endif() +message(STATUS "BOOST_IGNORE_SYSTEM_PATHS defaults to ${BOOST_IGNORE_SYSTEM_PATHS_DEFAULT}") +option(BOOST_IGNORE_SYSTEM_PATHS "Ignore boost system paths for local boost ins tallation" $BOOST_IGNORE_SYSTEM_PATHS_DEFAULT) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_CONFIGURATION_TYPES "Debug;Release") enable_testing() @@ -51,25 +67,28 @@ endif() # elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*") # set(BSDI TRUE) -function(set_static_flags) - if (NOT APPLE AND NOT FREEBSD) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") - endif() -endfunction(set_static_flags) - include_directories(src contrib/epee/include external "${CMAKE_BINARY_DIR}/version") if(APPLE) include_directories(SYSTEM /usr/include/malloc) endif() -set(STATIC ${MSVC} CACHE BOOL "Link libraries statically") +if(MSVC OR MINGW) + set(DEFAULT_STATIC true) +else() + set(DEFAULT_STATIC false) +endif() +set(STATIC ${DEFAULT_STATIC} CACHE BOOL "Link libraries statically") if (UNIX AND NOT APPLE) # Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail find_package(Threads) endif() +# Find unbound - don't move this to the end, cmake is weird about this +find_package(Unbound REQUIRED) +include_directories(${UNBOUND_INCLUDE}) + if(MSVC) add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__") # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline") @@ -93,17 +112,11 @@ else() else() set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized") endif() - # Since gcc 4.9 the LTO format is non-standard (slim), so we need the gcc-specific ar and ranlib binaries - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0)) - set(CMAKE_AR "gcc-ar") - set(CMAKE_RANLIB "gcc-ranlib") - endif() if(MINGW) - set(WARNINGS "${WARNINGS} -Wno-error=unused-value") - set(MINGW_FLAG "-DWIN32_LEAN_AND_MEAN") + set(WARNINGS "${WARNINGS} -Wno-error=unused-value -Wno-error=unused-but-set-variable") + set(MINGW_FLAG "${MINGW_FLAG} -DWIN32_LEAN_AND_MEAN") + set(Boost_THREADAPI win32) include_directories(SYSTEM src/platform/mingw) - else() - set(MINGW_FLAG "") endif() set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes") set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers") @@ -123,14 +136,30 @@ else() else() set(DEBUG_FLAGS "-g3 -O0") endif() + set(RELEASE_FLAGS "-Ofast -DNDEBUG -Wno-unused-variable") - if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled + + if(NOT DEFINED USE_LTO_DEFAULT) + set(USE_LTO_DEFAULT true) + endif() + set(USE_LTO ${USE_LTO_DEFAULT} CACHE BOOL "Use Link-Time Optimization (Release mode only)") + + # There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled, so explicitly disable + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(USE_LTO false) + endif() + if(USE_LTO) set(RELEASE_FLAGS "${RELEASE_FLAGS} -flto") + if(STATIC) + set(RELEASE_FLAGS "${RELEASE_FLAGS} -ffat-lto-objects") + endif() + # Since gcc 4.9 the LTO format is non-standard (slim), so we need the gcc-specific ar and ranlib binaries + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0)) + set(CMAKE_AR "gcc-ar") + set(CMAKE_RANLIB "gcc-ranlib") + endif() endif() - #if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW) - # set(RELEASE_FLAGS "${RELEASE_FLAGS} -fno-fat-lto-objects") - #endif() + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}") @@ -140,6 +169,10 @@ else() endif() endif() +if (BOOST_IGNORE_SYSTEM_PATHS) + set(Boost_NO_SYSTEM_PATHS TRUE) +endif() + if(STATIC) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) @@ -150,11 +183,11 @@ if((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 54)) endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(MINGW) - set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock") + set(Boost_LIBRARIES "${Boost_LIBRARIES};pthread;mswsock;ws2_32") elseif(APPLE OR FREEBSD) set(Boost_LIBRARIES "${Boost_LIBRARIES}") elseif(NOT MSVC) - set(Boost_LIBRARIES "${Boost_LIBRARIES};rt;pthread") + #set(Boost_LIBRARIES "${Boost_LIBRARIES};rt;pthread") endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version") |