diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 87a53c368..eea161bdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,9 @@ include_directories(src contrib/epee/include external "${CMAKE_BINARY_DIR}/versi if(APPLE) include_directories(SYSTEM /usr/include/malloc) + if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) + endif() endif() if(MSVC OR MINGW) @@ -270,14 +273,19 @@ endif() add_definitions("-DBLOCKCHAIN_DB=${BLOCKCHAIN_DB}") -find_package(Libunwind) # Can't install hook in static build on OSX, because OSX linker does not support --wrap # On ARM, having libunwind package (with .so's only) installed breaks static link. -if(LIBUNWIND_FOUND AND NOT (STATIC AND (APPLE OR ARM))) - set(DEFAULT_STACK_TRACE ON) -else() +if(APPLE OR (ARM AND STATIC)) set(DEFAULT_STACK_TRACE OFF) set(LIBUNWIND_LIBRARIES "") +else() + find_package(Libunwind) + if(LIBUNWIND_FOUND) + set(DEFAULT_STACK_TRACE ON) + else() + set(DEFAULT_STACK_TRACE OFF) + set(LIBUNWIND_LIBRARIES "") + endif() endif() option(STACK_TRACE "Install a hook that dumps stack on exception" ${DEFAULT_STACK_TRACE}) @@ -375,6 +383,13 @@ else() set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert") endif() + try_compile(STATIC_ASSERT_CPP_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-static-assert.cpp" COMPILE_DEFINITIONS "-std=c++11") + if(STATIC_ASSERT_CPP_RES) + set(STATIC_ASSERT_CPP_FLAG "") + else() + set(STATIC_ASSERT_CPP_FLAG "-Dstatic_assert=_Static_assert") + endif() + option(COVERAGE "Enable profiling for test coverage report" 0) if(COVERAGE) @@ -410,7 +425,7 @@ else() endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS} ${PIC_FLAG}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS} ${PIC_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_CPP_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS} ${PIC_FLAG}") # With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that # is fixed in the code (Issue #847), force compiler to be conservative. @@ -494,6 +509,13 @@ else() endif(ARM) + if(ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON") + #From Android 5: "only position independent executables (PIE) are supported" + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie") + endif() + if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0") endif() @@ -580,7 +602,7 @@ endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(MINGW) set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi) -elseif(APPLE OR FREEBSD OR OPENBSD) +elseif(APPLE OR FREEBSD OR OPENBSD OR ANDROID) set(EXTRA_LIBRARIES "") elseif(DRAGONFLY) find_library(COMPAT compat) |