summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt9
-rw-r--r--cmake/mbgl.cmake118
-rw-r--r--platform/qt/config.cmake43
3 files changed, 88 insertions, 82 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf4eda5252..69bb5abe4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,14 +2,15 @@ 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)
option(WITH_OSMESA "Use OSMesa headless backend" OFF)
option(WITH_EGL "Use EGL backend" OFF)
+option(WITH_NODEJS "Download test dependencies like NPM and Node.js" ON)
+
+include(cmake/mbgl.cmake)
+include(cmake/mason.cmake)
+include(cmake/xcode.cmake)
if(WITH_CXX11ABI)
set(MASON_CXXABI_SUFFIX -cxx11abi)
diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake
index 0393ff366e..3d82899538 100644
--- a/cmake/mbgl.cmake
+++ b/cmake/mbgl.cmake
@@ -6,73 +6,69 @@ if (NOT MBGL_PLATFORM)
endif()
endif()
-find_program(NodeJS_EXECUTABLE NAMES nodejs node)
-if (NOT NodeJS_EXECUTABLE)
- message(FATAL_ERROR "Could not find Node.js")
-endif()
-
-find_program(npm_EXECUTABLE NAMES npm)
-if (NOT npm_EXECUTABLE)
- message(FATAL_ERROR "Could not find npm")
-endif()
+if(WITH_NODEJS)
+ find_program(NodeJS_EXECUTABLE NAMES nodejs node)
+ if (NOT NodeJS_EXECUTABLE)
+ message(FATAL_ERROR "Could not find Node.js")
+ endif()
-function(_npm_install DIRECTORY NAME ADDITIONAL_DEPS)
- SET(NPM_INSTALL_FAILED FALSE)
- if("${DIRECTORY}/package.json" IS_NEWER_THAN "${DIRECTORY}/node_modules/.${NAME}.stamp")
- message(STATUS "Running 'npm install' for ${NAME}...")
- execute_process(
- COMMAND ${NodeJS_EXECUTABLE} ${npm_EXECUTABLE} install --ignore-scripts
- WORKING_DIRECTORY "${DIRECTORY}"
- RESULT_VARIABLE NPM_INSTALL_FAILED)
- if(NOT NPM_INSTALL_FAILED)
- execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${DIRECTORY}/node_modules/.${NAME}.stamp")
- endif()
+ find_program(npm_EXECUTABLE NAMES npm)
+ if (NOT npm_EXECUTABLE)
+ message(FATAL_ERROR "Could not find npm")
endif()
- add_custom_command(
- OUTPUT "${DIRECTORY}/node_modules/.${NAME}.stamp"
- COMMAND ${NodeJS_EXECUTABLE} ${npm_EXECUTABLE} install --ignore-scripts
- COMMAND ${CMAKE_COMMAND} -E touch "${DIRECTORY}/node_modules/.${NAME}.stamp"
- WORKING_DIRECTORY "${DIRECTORY}"
- DEPENDS ${ADDITIONAL_DEPS} "${DIRECTORY}/package.json"
- COMMENT "Running 'npm install' for ${NAME}...")
-endfunction()
+ function(_npm_install DIRECTORY NAME ADDITIONAL_DEPS)
+ SET(NPM_INSTALL_FAILED FALSE)
+ if("${DIRECTORY}/package.json" IS_NEWER_THAN "${DIRECTORY}/node_modules/.${NAME}.stamp")
+ message(STATUS "Running 'npm install' for ${NAME}...")
+ execute_process(
+ COMMAND ${NodeJS_EXECUTABLE} ${npm_EXECUTABLE} install --ignore-scripts
+ WORKING_DIRECTORY "${DIRECTORY}"
+ RESULT_VARIABLE NPM_INSTALL_FAILED)
+ if(NOT NPM_INSTALL_FAILED)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${DIRECTORY}/node_modules/.${NAME}.stamp")
+ endif()
+ endif()
-# Run submodule update
-message(STATUS "Updating submodules...")
-execute_process(
- COMMAND git submodule update --init mapbox-gl-js
- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
+ add_custom_command(
+ OUTPUT "${DIRECTORY}/node_modules/.${NAME}.stamp"
+ COMMAND ${NodeJS_EXECUTABLE} ${npm_EXECUTABLE} install --ignore-scripts
+ COMMAND ${CMAKE_COMMAND} -E touch "${DIRECTORY}/node_modules/.${NAME}.stamp"
+ WORKING_DIRECTORY "${DIRECTORY}"
+ DEPENDS ${ADDITIONAL_DEPS} "${DIRECTORY}/package.json"
+ COMMENT "Running 'npm install' for ${NAME}...")
+ endfunction()
-if(MBGL_PLATFORM STREQUAL "ios")
+ # Run submodule update
+ message(STATUS "Updating submodules...")
execute_process(
- COMMAND git submodule update --init platform/ios/vendor/SMCalloutView platform/ios/uitest/KIF platform/ios/uitest/OHHTTPStubs
+ COMMAND git submodule update --init mapbox-gl-js
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
-endif()
-if(NOT EXISTS "${CMAKE_SOURCE_DIR}/mapbox-gl-js/node_modules")
- # Symlink mapbox-gl-js/node_modules so that the modules that are
- # about to be installed get cached between CI runs.
- execute_process(
- COMMAND ln -sF ../node_modules .
- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mapbox-gl-js")
-endif()
+ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/mapbox-gl-js/node_modules")
+ # Symlink mapbox-gl-js/node_modules so that the modules that are
+ # about to be installed get cached between CI runs.
+ execute_process(
+ COMMAND ln -sF ../node_modules .
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mapbox-gl-js")
+ endif()
-# Add target for running submodule update during builds
-add_custom_target(
- update-submodules ALL
- COMMAND git submodule update --init mapbox-gl-js
- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
- COMMENT "Updating submodules..."
-)
-
-# Run npm install for both directories, and add custom commands, and a target that depends on them.
-_npm_install("${CMAKE_SOURCE_DIR}" mapbox-gl-native update-submodules)
-_npm_install("${CMAKE_SOURCE_DIR}/mapbox-gl-js/test/integration" mapbox-gl-js "${CMAKE_SOURCE_DIR}/node_modules/.mapbox-gl-native.stamp")
-add_custom_target(
- npm-install ALL
- DEPENDS "${CMAKE_SOURCE_DIR}/node_modules/.mapbox-gl-js.stamp"
-)
+ # Add target for running submodule update during builds
+ add_custom_target(
+ update-submodules ALL
+ COMMAND git submodule update --init mapbox-gl-js
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ COMMENT "Updating submodules..."
+ )
+
+ # Run npm install for both directories, and add custom commands, and a target that depends on them.
+ _npm_install("${CMAKE_SOURCE_DIR}" mapbox-gl-native update-submodules)
+ _npm_install("${CMAKE_SOURCE_DIR}/mapbox-gl-js/test/integration" mapbox-gl-js "${CMAKE_SOURCE_DIR}/node_modules/.mapbox-gl-native.stamp")
+ add_custom_target(
+ npm-install ALL
+ DEPENDS "${CMAKE_SOURCE_DIR}/node_modules/.mapbox-gl-js.stamp"
+ )
+endif()
# Generate source groups so the files are properly sorted in IDEs like Xcode.
function(create_source_groups target)
@@ -112,6 +108,12 @@ function(_get_xcconfig_property target var)
endif()
endfunction()
+if(MBGL_PLATFORM STREQUAL "ios")
+ execute_process(
+ COMMAND git submodule update --init platform/ios/vendor/SMCalloutView platform/ios/uitest/KIF platform/ios/uitest/OHHTTPStubs
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
+endif()
+
function(write_xcconfig_target_properties)
foreach(target ${ARGN})
_get_xcconfig_property(${target} INCLUDE_DIRECTORIES)
diff --git a/platform/qt/config.cmake b/platform/qt/config.cmake
index d93c6fe197..76d0c2ad52 100644
--- a/platform/qt/config.cmake
+++ b/platform/qt/config.cmake
@@ -1,7 +1,5 @@
include(platform/qt/qt.cmake)
-mason_use(gtest VERSION 1.8.0${MASON_CXXABI_SUFFIX})
-
if(NOT WITH_QT_DECODERS)
mason_use(libjpeg-turbo VERSION 1.5.0)
mason_use(libpng VERSION 1.6.25)
@@ -63,28 +61,33 @@ macro(mbgl_filesource)
)
endmacro()
+# FIXME: For now tests are disabled on Windows until we
+# get the node.js dependencies working.
+if (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ mason_use(gtest VERSION 1.8.0${MASON_CXXABI_SUFFIX})
-macro(mbgl_platform_test)
- target_sources(mbgl-test
- PRIVATE platform/qt/test/main.cpp
- PRIVATE platform/qt/test/qmapboxgl.test.cpp
- PRIVATE platform/qt/test/qmapboxgl.test.cpp
- )
+ macro(mbgl_platform_test)
+ target_sources(mbgl-test
+ PRIVATE platform/qt/test/main.cpp
+ PRIVATE platform/qt/test/qmapboxgl.test.cpp
+ PRIVATE platform/qt/test/qmapboxgl.test.cpp
+ )
- target_include_directories(mbgl-test
- PRIVATE platform/qt
- )
+ target_include_directories(mbgl-test
+ PRIVATE platform/qt
+ )
- set_source_files_properties(
- platform/qt/test/main.cpp
- PROPERTIES COMPILE_FLAGS -DWORK_DIRECTORY="${CMAKE_SOURCE_DIR}"
- )
+ set_source_files_properties(
+ platform/qt/test/main.cpp
+ PROPERTIES COMPILE_FLAGS -DWORK_DIRECTORY="${CMAKE_SOURCE_DIR}"
+ )
- target_link_libraries(mbgl-test
- PRIVATE qmapboxgl
- PRIVATE mbgl-filesource
- )
-endmacro()
+ target_link_libraries(mbgl-test
+ PRIVATE qmapboxgl
+ PRIVATE mbgl-filesource
+ )
+ endmacro()
+endif()
target_add_mason_package(qmapboxgl PRIVATE geojson)
target_add_mason_package(qmapboxgl PRIVATE rapidjson)