summaryrefslogtreecommitdiff
path: root/cmake/mbgl.cmake
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2018-01-03 18:27:25 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2018-01-08 22:58:20 +0200
commitf391271532895c8a36cf20b6ccd20c49ee50176b (patch)
treedcebdbe0f613ec3fce40b14b74e8f48b0b4967b6 /cmake/mbgl.cmake
parent035418336e84d1afbeed989cd3a112e06d0b4590 (diff)
downloadqtlocation-mapboxgl-f391271532895c8a36cf20b6ccd20c49ee50176b.tar.gz
[windows][build] Make nodejs/npm optional
Diffstat (limited to 'cmake/mbgl.cmake')
-rw-r--r--cmake/mbgl.cmake118
1 files changed, 60 insertions, 58 deletions
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)