diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-07-28 13:01:43 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-08-05 11:42:22 +0200 |
commit | 95b6d48b710a38b7969b72b6d2a89f3930fdbc0f (patch) | |
tree | 6e9b3ebd71c0c9b12ba4f2cd28fadf17daa182ae /cmake | |
parent | 6ccdd7d4817ea550db0578fa63da5d0f9335297b (diff) | |
download | qtlocation-mapboxgl-95b6d48b710a38b7969b72b6d2a89f3930fdbc0f.tar.gz |
[build] use cmake script bundled with Mason
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/mason.cmake | 117 | ||||
-rw-r--r-- | cmake/mbgl.cmake | 18 | ||||
-rw-r--r-- | cmake/node.cmake | 2 |
3 files changed, 9 insertions, 128 deletions
diff --git a/cmake/mason.cmake b/cmake/mason.cmake deleted file mode 100644 index 7954b53522..0000000000 --- a/cmake/mason.cmake +++ /dev/null @@ -1,117 +0,0 @@ -set(_mason_command ${CMAKE_SOURCE_DIR}/.mason/mason) -string(RANDOM LENGTH 16 _mason_invocation) - -if(EXISTS "${_mason_command}") -else() - execute_process( - COMMAND git submodule update --init .mason - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -endif() - -function(_mason_valid_args package version) - if(NOT package OR NOT version) - message(FATAL_ERROR "No package name or version given") - endif() -endfunction() - -function(_mason_install package version) - set(_mason_failed) - execute_process( - COMMAND ${_mason_command} install ${package} ${version} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _mason_failed) - if(_mason_failed) - message(FATAL_ERROR "[Mason] Could not install Mason package") - endif() -endfunction() - -function(_mason_get_flags package version) - set(_mason_flags) - set(_mason_failed) - execute_process( - COMMAND ${_mason_command} cflags ${package} ${version} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE _mason_flags - RESULT_VARIABLE _mason_failed - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(_mason_failed) - message(FATAL_ERROR "[Mason] Could not get flags for package ${package} ${version}") - endif() - - # Extract -I and -isystem to {package}_INCLUDE_DIRS - string(REGEX MATCHALL "(^| +)-(I|isystem) *([^ ]+)" _mason_include_dirs "${_mason_flags}") - string(REGEX REPLACE "(^| +)-(I|isystem) *" "" _mason_include_dirs "${_mason_include_dirs}") - string(STRIP "${_mason_include_dirs}" _mason_include_dirs) - list(REMOVE_DUPLICATES _mason_include_dirs) - set(_mason_include_dirs "${_mason_include_dirs}" PARENT_SCOPE) - - # Extract -D definitions to {package}_DEFINITIONS - string(REGEX MATCHALL "(^| +)-D *([^ ]+)" _mason_definitions "${_mason_flags}") - string(REGEX REPLACE "(^| +)-D *" "\\1" _mason_definitions "${_mason_definitions}") - string(STRIP "${_mason_definitions}" _mason_definitions) - set(_mason_definitions "${_mason_definitions}" PARENT_SCOPE) - - # Store all other flags in {package}_OPTIONS - string(REGEX REPLACE "(^| +)-(D|I|isystem) *([^ ]+)" "" _mason_options "${_mason_flags}") - string(STRIP "${_mason_options}" _mason_options) - set(_mason_options "${_mason_options}" PARENT_SCOPE) -endfunction() - -function(_mason_get_libs package version) - set(_mason_failed) - set(_mason_static_libs) - execute_process( - COMMAND ${_mason_command} static_libs ${package} ${version} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE _mason_static_libs - RESULT_VARIABLE _mason_failed - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(_mason_failed) - message(FATAL_ERROR "[Mason] Could not get static libraries for package ${package} ${version}") - endif() - - set(_mason_failed) - set(_mason_ldflags) - execute_process( - COMMAND ${_mason_command} ldflags ${package} ${version} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE _mason_ldflags - RESULT_VARIABLE _mason_failed - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(_mason_failed) - message(FATAL_ERROR "[Mason] Could not get linker flags for package ${package} ${version}") - endif() - - set(_mason_libraries) - list(APPEND _mason_libraries ${_mason_static_libs} ${_mason_ldflags}) - set(_mason_libraries ${_mason_libraries} PARENT_SCOPE) -endfunction() - -macro(mason_use package version) - _mason_valid_args("${package}" "${version}") - - if(MASON_${package}_INVOCATION STREQUAL ${_mason_invocation}) - # Check that the previous invocation of mason_use didn't select another version of this package - if(NOT MASON_${package}_VERSION STREQUAL ${version}) - message(FATAL_ERROR "[Mason] Already using ${package} ${MASON_${package}_VERSION}. Cannot select version ${version}.") - endif() - else() - _mason_install("${package}" "${version}") - _mason_get_flags("${package}" "${version}") - _mason_get_libs("${package}" "${version}") - set(MASON_${package}_INCLUDE_DIRS "${_mason_include_dirs}" CACHE STRING "${package} include directories" FORCE) - set(MASON_${package}_DEFINITIONS "${_mason_definitions}" CACHE STRING "${package} definitions" FORCE) - set(MASON_${package}_OPTIONS "${_mason_options}" CACHE STRING "${package} compiler options" FORCE) - set(MASON_${package}_LIBRARIES "${_mason_libraries}" CACHE STRING "${package} libraries" FORCE) - set(MASON_${package}_VERSION "${version}" CACHE INTERNAL "${package} version" FORCE) - set(MASON_${package}_INVOCATION "${_mason_invocation}" CACHE INTERNAL "${package} invocation ID" FORCE) - endif() -endmacro() - -macro(target_add_mason_package target visibility package) - mason_use("${package}" "${MASON_${package}_VERSION}") - target_include_directories(${target} ${visibility} "${MASON_${package}_INCLUDE_DIRS}") - target_compile_definitions(${target} ${visibility} "${MASON_${package}_DEFINITIONS}") - target_compile_options(${target} ${visibility} "${MASON_${package}_OPTIONS}") - target_link_libraries(${target} ${visibility} "${MASON_${package}_LIBRARIES}") -endmacro() diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake index 317057a406..752f05619c 100644 --- a/cmake/mbgl.cmake +++ b/cmake/mbgl.cmake @@ -1,4 +1,4 @@ -if (NOT DEFINED MBGL_PLATFORM) +if (NOT MBGL_PLATFORM) if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") set(MBGL_PLATFORM "macos") else() @@ -6,16 +6,8 @@ if (NOT DEFINED MBGL_PLATFORM) endif() endif() -if (NOT DEFINED ENV{MASON_PLATFORM}) - if(MBGL_PLATFORM STREQUAL "qt") - set(ENV{MASON_PLATFORM} ${BUILD_PLATFORM}) - else() - set(ENV{MASON_PLATFORM} ${MBGL_PLATFORM}) - endif() -endif() - -if ("$ENV{MASON_PLATFORM}" STREQUAL "macos") - set(ENV{MASON_PLATFORM} "osx") +if (NOT MASON_PLATFORM) + set(MASON_PLATFORM "${MBGL_PLATFORM}") endif() set(MBGL_GENERATED ${CMAKE_BINARY_DIR}/generated/${CMAKE_CFG_INTDIR}) @@ -54,3 +46,7 @@ endfunction() file(WRITE "${CMAKE_BINARY_DIR}/config.xcconfig" "// Do not edit -- generated by CMake\n") set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10) + +# CMake 3.1 does not have this yet. +set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") +set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") diff --git a/cmake/node.cmake b/cmake/node.cmake index 9c8c6b074b..081b158d41 100644 --- a/cmake/node.cmake +++ b/cmake/node.cmake @@ -43,6 +43,8 @@ target_link_libraries(mbgl-node PRIVATE mbgl-core ) +target_add_mason_package(mbgl-node PRIVATE geojson) + add_custom_command( TARGET mbgl-node POST_BUILD |