diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ac2ea7e0f..530461d1fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,10 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.4) project(mbgl LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) include(cmake/mbgl.cmake) include(cmake/mason.cmake) +include(cmake/xcode.cmake) option(WITH_CXX11ABI "Use cxx11abi mason packages" OFF) option(WITH_COVERAGE "Enable coverage reports" OFF) @@ -41,21 +42,24 @@ endif() set_source_files_properties(src/mbgl/util/version.cpp PROPERTIES COMPILE_DEFINITIONS MBGL_VERSION_REV="${MBGL_VERSION_REV}") -mason_use(geometry VERSION 0.9.0 HEADER_ONLY) +mason_use(geometry VERSION 0.9.2 HEADER_ONLY) mason_use(variant VERSION 1.1.4 HEADER_ONLY) mason_use(any VERSION 8fef1e9 HEADER_ONLY) mason_use(unique_resource VERSION cba309e HEADER_ONLY) mason_use(rapidjson VERSION 1.1.0 HEADER_ONLY) mason_use(boost VERSION 1.62.0 HEADER_ONLY) -mason_use(geojsonvt VERSION 6.2.0 HEADER_ONLY) -mason_use(supercluster VERSION 0.2.0-1 HEADER_ONLY) +mason_use(geojsonvt VERSION 6.2.1 HEADER_ONLY) +mason_use(supercluster VERSION 0.2.2 HEADER_ONLY) mason_use(kdbush VERSION 0.1.1-1 HEADER_ONLY) mason_use(earcut VERSION 0.12.3 HEADER_ONLY) -mason_use(protozero VERSION 1.4.2 HEADER_ONLY) +mason_use(protozero VERSION 1.5.2 HEADER_ONLY) mason_use(pixelmatch VERSION 0.10.0 HEADER_ONLY) -mason_use(geojson VERSION 0.4.0 HEADER_ONLY) -mason_use(polylabel VERSION 1.0.2 HEADER_ONLY) -mason_use(wagyu VERSION 0.4.1 HEADER_ONLY) +mason_use(geojson VERSION 0.4.2 HEADER_ONLY) +mason_use(polylabel VERSION 1.0.3 HEADER_ONLY) +mason_use(wagyu VERSION 0.4.3 HEADER_ONLY) +mason_use(shelf-pack VERSION 2.1.1 HEADER_ONLY) +mason_use(cheap-ruler VERSION 2.5.3 HEADER_ONLY) +mason_use(vector-tile VERSION 1.0.0-rc7 HEADER_ONLY) add_definitions(-DRAPIDJSON_HAS_STDSTRING=1) @@ -64,14 +68,16 @@ if(WITH_COVERAGE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") endif(WITH_COVERAGE) -set(CMAKE_CONFIGURATION_TYPES Debug Release) +set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebugInfo Sanitize) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -ftemplate-depth=1024 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Werror -Wno-variadic-macros -Wno-unknown-pragmas") -if(APPLE) +if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") # -Wno-error=unused-command-line-argument is required due to https://llvm.org/bugs/show_bug.cgi?id=7798 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument") endif() set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -DNDEBUG") +set(CMAKE_CXX_FLAGS_SANITIZE "-O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls") if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") @@ -81,6 +87,42 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") endif() +# Technique from https://crascit.com/2016/04/09/using-ccache-with-cmake/ +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + set(C_LAUNCHER "${CCACHE_PROGRAM}") + set(CXX_LAUNCHER "${CCACHE_PROGRAM}") + + if(CMAKE_GENERATOR STREQUAL "Xcode") + # Set Xcode project attributes to route compilation and linking through our scripts + # Xcode doesn't include the path to the compiler/linker by default, so we'll have to add it. + configure_file(scripts/launch-c-xcode.in launch-c @ONLY) + configure_file(scripts/launch-cxx-xcode.in launch-cxx @ONLY) + + set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx") + set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx") + else() + # Support Unix Makefiles and Ninja + configure_file(scripts/launch-c.in launch-c @ONLY) + configure_file(scripts/launch-cxx.in launch-cxx @ONLY) + + set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx") + endif() + + execute_process(COMMAND chmod a+rx "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx") + + if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + # ccache splits up the compile steps, so we end up with unused arguments in some steps. + # Clang also thinks that ccache isn't interactive, so we explicitly need to enable color. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics") + endif() +else() + message(STATUS "Can't find ccache — consider installing ccache to improve recompilation performance") +endif() + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/platform/${MBGL_PLATFORM}/config.cmake) message(ERROR "Can't find config.cmake file for platform ${MBGL_PLATFORM}") endif() |