summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/NodeJS.cmake600
-rw-r--r--cmake/core-files.cmake60
-rw-r--r--cmake/core.cmake22
-rw-r--r--cmake/glfw.cmake7
-rw-r--r--cmake/mason.cmake212
-rw-r--r--cmake/mbgl.cmake29
-rw-r--r--cmake/node.cmake10
-rw-r--r--cmake/shaders.cmake32
-rw-r--r--cmake/test-files.cmake12
-rw-r--r--cmake/test.cmake1
10 files changed, 896 insertions, 89 deletions
diff --git a/cmake/NodeJS.cmake b/cmake/NodeJS.cmake
new file mode 100644
index 0000000000..8e0ec56982
--- /dev/null
+++ b/cmake/NodeJS.cmake
@@ -0,0 +1,600 @@
+# NOTE: We're using a patched version of the original https://github.com/cjntaylor/node-cmake
+
+# Our version is in https://github.com/mapbox/node-cmake/blob/mapbox-gl-native/NodeJS.cmake and
+# contains these patches:
+# - https://github.com/cjntaylor/node-cmake/pull/20
+# - https://github.com/cjntaylor/node-cmake/pull/22
+# - https://github.com/cjntaylor/node-cmake/pull/23
+
+# Defaults for standard Node.js builds
+set(NODEJS_DEFAULT_URL https://nodejs.org/download/release)
+set(NODEJS_DEFAULT_VERSION installed)
+set(NODEJS_VERSION_FALLBACK latest)
+set(NODEJS_DEFAULT_NAME node)
+set(NODEJS_DEFAULT_CHECKSUM SHASUMS256.txt)
+set(NODEJS_DEFAULT_CHECKTYPE SHA256)
+
+include(CMakeParseArguments)
+
+# Find a path by walking upward from a base directory until the path is
+# found. Sets the variable ${PATH} to False if the path can't
+# be determined
+function(find_path_parent NAME BASE PATH)
+ set(ROOT ${BASE})
+ set(${PATH} ${ROOT}/${NAME} PARENT_SCOPE)
+ set(DRIVE "^[A-Za-z]?:?/$")
+ while(NOT ROOT MATCHES ${DRIVE} AND NOT EXISTS ${ROOT}/${NAME})
+ get_filename_component(ROOT ${ROOT} DIRECTORY)
+ set(${PATH} ${ROOT}/${NAME} PARENT_SCOPE)
+ endwhile()
+ if(ROOT MATCHES ${DRIVE})
+ set(${PATH} False PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Shortcut for finding standard node module locations
+macro(find_nodejs_module NAME BASE PATH)
+ find_path_parent(node_modules/${NAME} ${BASE} ${PATH})
+endmacro()
+
+# Download with a bit of nice output (without spewing progress)
+function(download_file DESCRIPTION URL FILE)
+ message(STATUS "Downloading: ${URL}")
+ file(DOWNLOAD
+ ${URL}
+ ${FILE}.tmp
+ ${ARGN}
+ STATUS RESULT
+ )
+ list(GET RESULT 0 STATUS)
+ if(STATUS)
+ list(GET result 1 MESSAGE)
+ message(FATAL_ERROR "Unable to download ${DESCRIPTION} from ${URL}: ${MESSAGE}")
+ else()
+ file(RENAME ${FILE}.tmp ${FILE})
+ endif()
+endfunction()
+
+# Embedded win_delay_load_hook file so that this file can be copied
+# into projects directly (recommended practice)
+function(nodejs_generate_delayload_hook OUTPUT)
+ file(WRITE ${OUTPUT} "")
+ file(APPEND ${OUTPUT} "/*\n")
+ file(APPEND ${OUTPUT} " * When this file is linked to a DLL, it sets up a delay-load hook that\n")
+ file(APPEND ${OUTPUT} " * intervenes when the DLL is trying to load 'node.exe' or 'iojs.exe'\n")
+ file(APPEND ${OUTPUT} " * dynamically. Instead of trying to locate the .exe file it'll just return\n")
+ file(APPEND ${OUTPUT} " * a handle to the process image.\n")
+ file(APPEND ${OUTPUT} " *\n")
+ file(APPEND ${OUTPUT} " * This allows compiled addons to work when node.exe or iojs.exe is renamed.\n")
+ file(APPEND ${OUTPUT} " */\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} "#ifdef _MSC_VER\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} "#ifndef DELAYIMP_INSECURE_WRITABLE_HOOKS\n")
+ file(APPEND ${OUTPUT} "#define DELAYIMP_INSECURE_WRITABLE_HOOKS\n")
+ file(APPEND ${OUTPUT} "#endif\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} "#ifndef WIN32_LEAN_AND_MEAN\n")
+ file(APPEND ${OUTPUT} "#define WIN32_LEAN_AND_MEAN\n")
+ file(APPEND ${OUTPUT} "#endif\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} "#include <windows.h>\n")
+ file(APPEND ${OUTPUT} "#include <Shlwapi.h>\n")
+ file(APPEND ${OUTPUT} "#include <delayimp.h>\n")
+ file(APPEND ${OUTPUT} "#include <string.h>\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} "static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {\n")
+ file(APPEND ${OUTPUT} " if (event != dliNotePreLoadLibrary) return NULL;\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " if (_stricmp(info->szDll, \"iojs.exe\") != 0 &&\n")
+ file(APPEND ${OUTPUT} " _stricmp(info->szDll, \"node.exe\") != 0 &&\n")
+ file(APPEND ${OUTPUT} " _stricmp(info->szDll, \"node.dll\") != 0)\n")
+ file(APPEND ${OUTPUT} " return NULL;\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " // Get a handle to the current process executable.\n")
+ file(APPEND ${OUTPUT} " HMODULE processModule = GetModuleHandle(NULL);\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " // Get the path to the executable.\n")
+ file(APPEND ${OUTPUT} " TCHAR processPath[_MAX_PATH];\n")
+ file(APPEND ${OUTPUT} " GetModuleFileName(processModule, processPath, _MAX_PATH);\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " // Get the name of the current executable.\n")
+ file(APPEND ${OUTPUT} " LPSTR processName = PathFindFileName(processPath);\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " // If the current process is node or iojs, then just return the proccess \n")
+ file(APPEND ${OUTPUT} " // module.\n")
+ file(APPEND ${OUTPUT} " if (_stricmp(processName, \"node.exe\") == 0 ||\n")
+ file(APPEND ${OUTPUT} " _stricmp(processName, \"iojs.exe\") == 0) {\n")
+ file(APPEND ${OUTPUT} " return (FARPROC) processModule;\n")
+ file(APPEND ${OUTPUT} " }\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " // If it is another process, attempt to load 'node.dll' from the same \n")
+ file(APPEND ${OUTPUT} " // directory.\n")
+ file(APPEND ${OUTPUT} " PathRemoveFileSpec(processPath);\n")
+ file(APPEND ${OUTPUT} " PathAppend(processPath, \"node.dll\");\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " HMODULE nodeDllModule = GetModuleHandle(processPath);\n")
+ file(APPEND ${OUTPUT} " if(nodeDllModule != NULL) {\n")
+ file(APPEND ${OUTPUT} " // This application has a node.dll in the same directory as the executable,\n")
+ file(APPEND ${OUTPUT} " // use that.\n")
+ file(APPEND ${OUTPUT} " return (FARPROC) nodeDllModule;\n")
+ file(APPEND ${OUTPUT} " }\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} " // Fallback to the current executable, which must statically link to \n")
+ file(APPEND ${OUTPUT} " // node.lib\n")
+ file(APPEND ${OUTPUT} " return (FARPROC) processModule;\n")
+ file(APPEND ${OUTPUT} "}\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} "PfnDliHook __pfnDliNotifyHook2 = load_exe_hook;\n")
+ file(APPEND ${OUTPUT} "\n")
+ file(APPEND ${OUTPUT} "#endif\n")
+endfunction()
+
+# Sets up a project to build Node.js native modules
+# - Downloads required dependencies and unpacks them to the build directory.
+# Internet access is required the first invocation but not after (
+# provided the download is successful)
+# - Sets up several variables for building against the downloaded
+# dependencies
+# - Guarded to prevent multiple executions, so a single project hierarchy
+# will only call this once
+function(nodejs_init)
+ # Prevents this function from executing more than once
+ if(NODEJS_INIT)
+ return()
+ endif()
+
+ # Regex patterns used by the init function for component extraction
+ set(HEADERS_MATCH "^([A-Fa-f0-9]+)[ \t]+([^-]+)-(headers|v?[0-9.]+)-(headers|v?[0-9.]+)([.]tar[.]gz)$")
+ set(LIB32_MATCH "(^[0-9A-Fa-f]+)[\t ]+(win-x86)?(/)?([^/]*)(.lib)$")
+ set(LIB64_MATCH "(^[0-9A-Fa-f]+)[\t ]+(win-)?(x64/)(.*)(.lib)$")
+
+ # Parse function arguments
+ cmake_parse_arguments(nodejs_init
+ "" "URL;NAME;VERSION;CHECKSUM;CHECKTYPE" "" ${ARGN}
+ )
+
+ # Allow the download URL to be overridden by command line argument
+ # NODEJS_URL
+ if(NODEJS_URL)
+ set(URL ${NODEJS_URL})
+ else()
+ # Use the argument if specified, falling back to the default
+ set(URL ${NODEJS_DEFAULT_URL})
+ if(nodejs_init_URL)
+ set(URL ${nodejs_init_URL})
+ endif()
+ endif()
+
+ # Allow name to be overridden by command line argument NODEJS_NAME
+ if(NODEJS_NAME)
+ set(NAME ${NODEJS_NAME})
+ else()
+ # Use the argument if specified, falling back to the default
+ set(NAME ${NODEJS_DEFAULT_NAME})
+ if(nodejs_init_NAME)
+ set(NAME ${nodejs_init_NAME})
+ endif()
+ endif()
+
+ # Allow the checksum file to be overridden by command line argument
+ # NODEJS_CHECKSUM
+ if(NODEJS_CHECKSUM)
+ set(CHECKSUM ${NODEJS_CHECKSUM})
+ else()
+ # Use the argument if specified, falling back to the default
+ set(CHECKSUM ${NODEJS_DEFAULT_CHECKSUM})
+ if(nodejs_init_CHECKSUM)
+ set(CHECKSUM ${nodejs_init_CHECKSUM})
+ endif()
+ endif()
+
+ # Allow the checksum type to be overriden by the command line argument
+ # NODEJS_CHECKTYPE
+ if(NODEJS_CHECKTYPE)
+ set(CHECKTYPE ${NODEJS_CHECKTYPE})
+ else()
+ # Use the argument if specified, falling back to the default
+ set(CHECKTYPE ${NODEJS_DEFAULT_CHECKTYPE})
+ if(nodejs_init_CHECKTYPE)
+ set(CHECKTYPE ${nodejs_init_CHECKTYPE})
+ endif()
+ endif()
+
+ # Allow the version to be overridden by the command line argument
+ # NODEJS_VERSION
+ if(NODEJS_VERSION)
+ set(VERSION ${NODEJS_VERSION})
+ else()
+ # Use the argument if specified, falling back to the default
+ set(VERSION ${NODEJS_DEFAULT_VERSION})
+ if(nodejs_init_VERSION)
+ set(VERSION ${nodejs_init_VERSION})
+ endif()
+ endif()
+
+ # "installed" is a special version that tries to use the currently
+ # installed version (determined by running node)
+ set(NODEJS_INSTALLED False CACHE BOOL "Node.js install status" FORCE)
+ if(VERSION STREQUAL "installed")
+ if(NOT NAME STREQUAL ${NODEJS_DEFAULT_NAME})
+ message(FATAL_ERROR
+ "'Installed' version identifier can only be used with"
+ "the core Node.js library"
+ )
+ endif()
+ # Fall back to the "latest" version if node isn't installed
+ set(VERSION ${NODEJS_VERSION_FALLBACK})
+ find_program(NODEJS_BINARY NAMES nodejs node)
+ if(NODEJS_BINARY)
+ execute_process(
+ COMMAND ${NODEJS_BINARY} --version
+ RESULT_VARIABLE INSTALLED_VERSION_RESULT
+ OUTPUT_VARIABLE INSTALLED_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(INSTALLED_VERSION_RESULT STREQUAL "0")
+ set(NODEJS_INSTALLED True CACHE BOOL
+ "Node.js install status" FORCE
+ )
+ set(VERSION ${INSTALLED_VERSION})
+ endif()
+ endif()
+ endif()
+
+ # Create a temporary download directory
+ set(TEMP ${CMAKE_CURRENT_BINARY_DIR}/temp)
+ file(MAKE_DIRECTORY ${TEMP})
+
+ # Unless the target is special version "latest", the parameters
+ # necessary to construct the root path are known
+ if(NOT VERSION STREQUAL "latest")
+ set(ROOT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${VERSION})
+ # Extract checksums from the existing checksum file
+ set(CHECKSUM_TARGET ${ROOT}/CHECKSUM)
+ endif()
+
+ # If we're trying to determine the version or we haven't saved the
+ # checksum file for this version, download it from the specified server
+ if(VERSION STREQUAL "latest" OR
+ (DEFINED ROOT AND NOT EXISTS ${ROOT}/CHECKSUM))
+ if(DEFINED ROOT)
+ # Clear away the old checksum in case the new one is different
+ # and/or it fails to download
+ file(REMOVE ${ROOT}/CHECKSUM)
+ endif()
+ file(REMOVE ${TEMP}/CHECKSUM)
+ download_file(
+ "checksum file"
+ ${URL}/${VERSION}/${CHECKSUM}
+ ${TEMP}/CHECKSUM
+ INACTIVITY_TIMEOUT 10
+ )
+ # Extract checksums from the temporary file
+ set(CHECKSUM_TARGET ${TEMP}/CHECKSUM)
+ endif()
+
+ # Extract the version, name, header archive and archive checksum
+ # from the file. This first extract is what defines / specifies the
+ # actual version number and name.
+ file(STRINGS
+ ${CHECKSUM_TARGET} HEADERS_CHECKSUM
+ REGEX ${HEADERS_MATCH}
+ LIMIT_COUNT 1
+ )
+ if(NOT HEADERS_CHECKSUM)
+ file(REMOVE ${TEMP}/CHECKSUM)
+ if(DEFINED ROOT)
+ file(REMOVE ${ROOT}/CHECKSUM)
+ endif()
+ message(FATAL_ERROR "Unable to extract header archive checksum")
+ endif()
+ string(REGEX MATCH ${HEADERS_MATCH} HEADERS_CHECKSUM ${HEADERS_CHECKSUM})
+ set(HEADERS_CHECKSUM ${CMAKE_MATCH_1})
+ set(NAME ${CMAKE_MATCH_2})
+ if(CMAKE_MATCH_3 STREQUAL "headers")
+ set(VERSION ${CMAKE_MATCH_4})
+ else()
+ set(VERSION ${CMAKE_MATCH_3})
+ endif()
+ set(HEADERS_ARCHIVE
+ ${CMAKE_MATCH_2}-${CMAKE_MATCH_3}-${CMAKE_MATCH_4}${CMAKE_MATCH_5}
+ )
+ # Make sure that the root directory exists, and that the checksum
+ # file has been moved over from temp
+ if(DEFINED ROOT)
+ set(OLD_ROOT ${ROOT})
+ endif()
+ set(ROOT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${VERSION})
+ if(DEFINED OLD_ROOT AND NOT ROOT STREQUAL "${OLD_ROOT}")
+ file(REMOVE ${TEMP}/CHECKSUM)
+ file(REMOVE ${ROOT}/CHECKSUM)
+ message(FATAL_ERROR "Version/Name mismatch")
+ endif()
+ file(MAKE_DIRECTORY ${ROOT})
+ if(EXISTS ${TEMP}/CHECKSUM)
+ file(REMOVE ${ROOT}/CHECKSUM)
+ file(RENAME ${TEMP}/CHECKSUM ${ROOT}/CHECKSUM)
+ endif()
+
+ # Now that its fully resolved, report the name and version of Node.js being
+ # used
+ message(STATUS "NodeJS: Using ${NAME}, version ${VERSION}")
+
+ # Download the headers for the version being used
+ # Theoretically, these could be found by searching the installed
+ # system, but in practice, this can be error prone. They're provided
+ # on the download servers, so just use the ones there.
+ if(NOT EXISTS ${ROOT}/include)
+ file(REMOVE ${TEMP}/${HEADERS_ARCHIVE})
+ download_file(
+ "Node.js headers"
+ ${URL}/${VERSION}/${HEADERS_ARCHIVE}
+ ${TEMP}/${HEADERS_ARCHIVE}
+ INACTIVITY_TIMEOUT 10
+ EXPECTED_HASH ${CHECKTYPE}=${HEADERS_CHECKSUM}
+ )
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar xfz ${TEMP}/${HEADERS_ARCHIVE}
+ WORKING_DIRECTORY ${TEMP}
+ )
+
+ # This adapts the header extraction to support a number of different
+ # header archive contents in addition to the one used by the
+ # default Node.js library
+ unset(NODEJS_HEADERS_PATH CACHE)
+ find_path(NODEJS_HEADERS_PATH
+ NAMES src include
+ PATHS
+ ${TEMP}/${NAME}-${VERSION}-headers
+ ${TEMP}/${NAME}-${VERSION}
+ ${TEMP}/${NODEJS_DEFAULT_NAME}-${VERSION}-headers
+ ${TEMP}/${NODEJS_DEFAULT_NAME}-${VERSION}
+ ${TEMP}/${NODEJS_DEFAULT_NAME}
+ ${TEMP}
+ NO_DEFAULT_PATH
+ )
+ if(NOT NODEJS_HEADERS_PATH)
+ message(FATAL_ERROR "Unable to find extracted headers folder")
+ endif()
+
+ # Move the headers into a standard location with a standard layout
+ file(REMOVE ${TEMP}/${HEADERS_ARCHIVE})
+ file(REMOVE_RECURSE ${ROOT}/include)
+ if(EXISTS ${NODEJS_HEADERS_PATH}/include/node)
+ file(RENAME ${NODEJS_HEADERS_PATH}/include/node ${ROOT}/include)
+ elseif(EXISTS ${NODEJS_HEADERS_PATH}/src)
+ file(MAKE_DIRECTORY ${ROOT}/include)
+ if(NOT EXISTS ${NODEJS_HEADERS_PATH}/src)
+ file(REMOVE_RECURSE ${ROOT}/include)
+ message(FATAL_ERROR "Unable to find core headers")
+ endif()
+ file(COPY ${NODEJS_HEADERS_PATH}/src/
+ DESTINATION ${ROOT}/include
+ )
+ if(NOT EXISTS ${NODEJS_HEADERS_PATH}/deps/uv/include)
+ file(REMOVE_RECURSE ${ROOT}/include)
+ message(FATAL_ERROR "Unable to find libuv headers")
+ endif()
+ file(COPY ${NODEJS_HEADERS_PATH}/deps/uv/include/
+ DESTINATION ${ROOT}/include
+ )
+ if(NOT EXISTS ${NODEJS_HEADERS_PATH}/deps/v8/include)
+ file(REMOVE_RECURSE ${ROOT}/include)
+ message(FATAL_ERROR "Unable to find v8 headers")
+ endif()
+ file(COPY ${NODEJS_HEADERS_PATH}/deps/v8/include/
+ DESTINATION ${ROOT}/include
+ )
+ if(NOT EXISTS ${NODEJS_HEADERS_PATH}/deps/zlib)
+ file(REMOVE_RECURSE ${ROOT}/include)
+ message(FATAL_ERROR "Unable to find zlib headers")
+ endif()
+ file(COPY ${NODEJS_HEADERS_PATH}/deps/zlib/
+ DESTINATION ${ROOT}/include
+ )
+ endif()
+ file(REMOVE_RECURSE ${NODEJS_HEADERS_PATH})
+ unset(NODEJS_HEADERS_PATH CACHE)
+ endif()
+
+ # Only download the libraries on windows, since its the only place
+ # its necessary. Note, this requires rerunning CMake if moving
+ # a module from one platform to another (should happen automatically
+ # with most generators)
+ if(WIN32)
+ # Download the win32 library for linking
+ file(STRINGS
+ ${ROOT}/CHECKSUM LIB32_CHECKSUM
+ LIMIT_COUNT 1
+ REGEX ${LIB32_MATCH}
+ )
+ if(NOT LIB32_CHECKSUM)
+ message(FATAL_ERROR "Unable to extract x86 library checksum")
+ endif()
+ string(REGEX MATCH ${LIB32_MATCH} LIB32_CHECKSUM ${LIB32_CHECKSUM})
+ set(LIB32_CHECKSUM ${CMAKE_MATCH_1})
+ set(LIB32_PATH win-x86)
+ set(LIB32_NAME ${CMAKE_MATCH_4}${CMAKE_MATCH_5})
+ set(LIB32_TARGET ${CMAKE_MATCH_2}${CMAKE_MATCH_3}${LIB32_NAME})
+ if(NOT EXISTS ${ROOT}/${LIB32_PATH})
+ file(REMOVE_RECURSE ${TEMP}/${LIB32_PATH})
+ download_file(
+ "Node.js windows library (32-bit)"
+ ${URL}/${VERSION}/${LIB32_TARGET}
+ ${TEMP}/${LIB32_PATH}/${LIB32_NAME}
+ INACTIVITY_TIMEOUT 10
+ EXPECTED_HASH ${CHECKTYPE}=${LIB32_CHECKSUM}
+ )
+ file(REMOVE_RECURSE ${ROOT}/${LIB32_PATH})
+ file(MAKE_DIRECTORY ${ROOT}/${LIB32_PATH})
+ file(RENAME
+ ${TEMP}/${LIB32_PATH}/${LIB32_NAME}
+ ${ROOT}/${LIB32_PATH}/${LIB32_NAME}
+ )
+ file(REMOVE_RECURSE ${TEMP}/${LIB32_PATH})
+ endif()
+
+ # Download the win64 library for linking
+ file(STRINGS
+ ${ROOT}/CHECKSUM LIB64_CHECKSUM
+ LIMIT_COUNT 1
+ REGEX ${LIB64_MATCH}
+ )
+ if(NOT LIB64_CHECKSUM)
+ message(FATAL_ERROR "Unable to extract x64 library checksum")
+ endif()
+ string(REGEX MATCH ${LIB64_MATCH} LIB64_CHECKSUM ${LIB64_CHECKSUM})
+ set(LIB64_CHECKSUM ${CMAKE_MATCH_1})
+ set(LIB64_PATH win-x64)
+ set(LIB64_NAME ${CMAKE_MATCH_4}${CMAKE_MATCH_5})
+ set(LIB64_TARGET ${CMAKE_MATCH_2}${CMAKE_MATCH_3}${LIB64_NAME})
+ if(NOT EXISTS ${ROOT}/${LIB64_PATH})
+ file(REMOVE_RECURSE ${TEMP}/${LIB64_PATH})
+ download_file(
+ "Node.js windows library (64-bit)"
+ ${URL}/${VERSION}/${LIB64_TARGET}
+ ${TEMP}/${LIB64_PATH}/${LIB64_NAME}
+ INACTIVITY_TIMEOUT 10
+ EXPECTED_HASH ${CHECKTYPE}=${LIB64_CHECKSUM}
+ )
+ file(REMOVE_RECURSE ${ROOT}/${LIB64_PATH})
+ file(MAKE_DIRECTORY ${ROOT}/${LIB64_PATH})
+ file(RENAME
+ ${TEMP}/${LIB64_PATH}/${LIB64_NAME}
+ ${ROOT}/${LIB64_PATH}/${LIB64_NAME}
+ )
+ file(REMOVE_RECURSE ${TEMP}/${LIB64_PATH})
+ endif()
+ endif()
+
+ # The downloaded headers should always be set for inclusion
+ list(APPEND INCLUDE_DIRS ${ROOT}/include)
+
+ # Look for the NAN module, and add it to the includes
+ find_nodejs_module(
+ nan
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ NODEJS_NAN_DIR
+ )
+ if(NODEJS_NAN_DIR)
+ list(APPEND INCLUDE_DIRS ${NODEJS_NAN_DIR})
+ endif()
+
+ # Under windows, we need a bunch of libraries (due to the way
+ # dynamic linking works)
+ if(WIN32)
+ # Generate and use a delay load hook to allow the node binary
+ # name to be changed while still loading native modules
+ set(DELAY_LOAD_HOOK ${CMAKE_CURRENT_BINARY_DIR}/win_delay_load_hook.c)
+ nodejs_generate_delayload_hook(${DELAY_LOAD_HOOK})
+ set(SOURCES ${DELAY_LOAD_HOOK})
+
+ # Necessary flags to get delayload working correctly
+ list(APPEND LINK_FLAGS
+ "-IGNORE:4199"
+ "-DELAYLOAD:iojs.exe"
+ "-DELAYLOAD:node.exe"
+ "-DELAYLOAD:node.dll"
+ )
+
+ # Core system libraries used by node
+ list(APPEND LIBRARIES
+ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
+ odbc32.lib Shlwapi.lib DelayImp.lib
+ )
+
+ # Also link to the node stub itself (downloaded above)
+ if(CMAKE_CL_64)
+ list(APPEND LIBRARIES ${ROOT}/${LIB64_PATH}/${LIB64_NAME})
+ else()
+ list(APPEND LIBRARIES ${ROOT}/${LIB32_PATH}/${LIB32_NAME})
+ endif()
+ else()
+ # Non-windows platforms should use these flags
+ list(APPEND DEFINITIONS _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64)
+ endif()
+
+ # Special handling for OSX / clang to allow undefined symbols
+ # Define is required by node on OSX
+ if(APPLE)
+ list(APPEND LINK_FLAGS "-undefined dynamic_lookup")
+ list(APPEND DEFINITIONS _DARWIN_USE_64_BIT_INODE=1)
+ endif()
+
+ # Export all settings for use as arguments in the rest of the build
+ set(NODEJS_VERSION ${VERSION} PARENT_SCOPE)
+ set(NODEJS_SOURCES ${SOURCES} PARENT_SCOPE)
+ set(NODEJS_INCLUDE_DIRS ${INCLUDE_DIRS} PARENT_SCOPE)
+ set(NODEJS_LIBRARIES ${LIBRARIES} PARENT_SCOPE)
+ set(NODEJS_LINK_FLAGS ${LINK_FLAGS} PARENT_SCOPE)
+ set(NODEJS_DEFINITIONS ${DEFINITIONS} PARENT_SCOPE)
+
+ # Prevents this function from executing more than once
+ set(NODEJS_INIT TRUE PARENT_SCOPE)
+endfunction()
+
+# Helper function for defining a node module
+# After nodejs_init, all of the settings and dependencies necessary to do
+# this yourself are defined, but this helps make sure everything is configured
+# correctly. Feel free to use it as a model to do this by hand (or to
+# tweak this configuration if you need something custom).
+function(add_nodejs_module NAME)
+ # Make sure node is initialized (variables set) before defining the module
+ if(NOT NODEJS_INIT)
+ message(FATAL_ERROR
+ "Node.js has not been initialized. "
+ "Call nodejs_init before adding any modules"
+ )
+ endif()
+ # In order to match node-gyp, we need to build into type specific folders
+ # ncmake takes care of this, but be sure to set CMAKE_BUILD_TYPE yourself
+ # if invoking CMake directly
+ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
+ message(FATAL_ERROR
+ "Configuration type must be specified. "
+ "Set CMAKE_BUILD_TYPE or use a different generator"
+ )
+ endif()
+
+ # A node module is a shared library
+ add_library(${NAME} SHARED ${NODEJS_SOURCES} ${ARGN})
+ # Add compiler defines for the module
+ # Two helpful ones:
+ # MODULE_NAME must match the name of the build library, define that here
+ target_compile_definitions(${NAME}
+ PRIVATE MODULE_NAME=${NAME}
+ PUBLIC ${NODEJS_DEFINITIONS}
+ )
+ # This properly defines includes for the module
+ target_include_directories(${NAME} PUBLIC ${NODEJS_INCLUDE_DIRS})
+
+ # Add link flags to the module
+ target_link_libraries(${NAME} ${NODEJS_LIBRARIES})
+
+ # Set required properties for the module to build properly
+ # Correct naming, symbol visiblity and C++ standard
+ set_target_properties(${NAME} PROPERTIES
+ OUTPUT_NAME ${NAME}
+ PREFIX ""
+ SUFFIX ".node"
+ MACOSX_RPATH ON
+ C_VISIBILITY_PRESET hidden
+ CXX_VISIBILITY_PRESET hidden
+ POSITION_INDEPENDENT_CODE TRUE
+ CMAKE_CXX_STANDARD_REQUIRED TRUE
+ CXX_STANDARD 11
+ LINK_FLAGS "${NODEJS_LINK_FLAGS}"
+ )
+
+ # Make sure we're buiilding in a build specific output directory
+ # Only necessary on single-target generators (Make, Ninja)
+ # Multi-target generators do this automatically
+ # This (luckily) mirrors node-gyp conventions
+ if(NOT CMAKE_CONFIGURATION_TYPES)
+ set_property(TARGET ${NAME} PROPERTY
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BUILD_TYPE}
+ )
+ endif()
+endfunction()
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index 4f2375e462..2c2b04f9ed 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -70,11 +70,13 @@ set(MBGL_CORE_FILES
src/mbgl/gl/framebuffer.hpp
src/mbgl/gl/gl.cpp
src/mbgl/gl/index_buffer.hpp
+ src/mbgl/gl/normalization.hpp
src/mbgl/gl/object.cpp
src/mbgl/gl/object.hpp
src/mbgl/gl/primitives.hpp
src/mbgl/gl/program.hpp
src/mbgl/gl/renderbuffer.hpp
+ src/mbgl/gl/segment.cpp
src/mbgl/gl/segment.hpp
src/mbgl/gl/state.hpp
src/mbgl/gl/stencil_mode.cpp
@@ -102,11 +104,13 @@ set(MBGL_CORE_FILES
# map
include/mbgl/map/backend.hpp
+ include/mbgl/map/backend_scope.hpp
include/mbgl/map/camera.hpp
include/mbgl/map/map.hpp
include/mbgl/map/mode.hpp
include/mbgl/map/view.hpp
src/mbgl/map/backend.cpp
+ src/mbgl/map/backend_scope.cpp
src/mbgl/map/change.hpp
src/mbgl/map/map.cpp
src/mbgl/map/transform.cpp
@@ -179,6 +183,34 @@ set(MBGL_CORE_FILES
src/mbgl/renderer/symbol_bucket.cpp
src/mbgl/renderer/symbol_bucket.hpp
+ # shaders
+ src/mbgl/shaders/circle.cpp
+ src/mbgl/shaders/circle.hpp
+ src/mbgl/shaders/collision_box.cpp
+ src/mbgl/shaders/collision_box.hpp
+ src/mbgl/shaders/debug.cpp
+ src/mbgl/shaders/debug.hpp
+ src/mbgl/shaders/fill.cpp
+ src/mbgl/shaders/fill.hpp
+ src/mbgl/shaders/fill_outline.cpp
+ src/mbgl/shaders/fill_outline.hpp
+ src/mbgl/shaders/fill_outline_pattern.cpp
+ src/mbgl/shaders/fill_outline_pattern.hpp
+ src/mbgl/shaders/fill_pattern.cpp
+ src/mbgl/shaders/fill_pattern.hpp
+ src/mbgl/shaders/line.cpp
+ src/mbgl/shaders/line.hpp
+ src/mbgl/shaders/line_pattern.cpp
+ src/mbgl/shaders/line_pattern.hpp
+ src/mbgl/shaders/line_sdf.cpp
+ src/mbgl/shaders/line_sdf.hpp
+ src/mbgl/shaders/raster.cpp
+ src/mbgl/shaders/raster.hpp
+ src/mbgl/shaders/symbol_icon.cpp
+ src/mbgl/shaders/symbol_icon.hpp
+ src/mbgl/shaders/symbol_sdf.cpp
+ src/mbgl/shaders/symbol_sdf.hpp
+
# sprite
include/mbgl/sprite/sprite_image.hpp
src/mbgl/sprite/sprite_atlas.cpp
@@ -205,14 +237,15 @@ set(MBGL_CORE_FILES
# style
include/mbgl/style/conversion.hpp
+ include/mbgl/style/data_driven_property_value.hpp
include/mbgl/style/filter.hpp
include/mbgl/style/filter_evaluator.hpp
- include/mbgl/style/function.hpp
include/mbgl/style/layer.hpp
include/mbgl/style/property_value.hpp
include/mbgl/style/source.hpp
include/mbgl/style/transition_options.hpp
include/mbgl/style/types.hpp
+ include/mbgl/style/undefined.hpp
src/mbgl/style/bucket_parameters.cpp
src/mbgl/style/bucket_parameters.hpp
src/mbgl/style/cascade_parameters.hpp
@@ -220,7 +253,7 @@ set(MBGL_CORE_FILES
src/mbgl/style/class_dictionary.hpp
src/mbgl/style/cross_faded_property_evaluator.cpp
src/mbgl/style/cross_faded_property_evaluator.hpp
- src/mbgl/style/function.cpp
+ src/mbgl/style/data_driven_property_evaluator.hpp
src/mbgl/style/group_by_layout.cpp
src/mbgl/style/group_by_layout.hpp
src/mbgl/style/layer.cpp
@@ -230,8 +263,10 @@ set(MBGL_CORE_FILES
src/mbgl/style/layout_property.hpp
src/mbgl/style/observer.hpp
src/mbgl/style/paint_property.hpp
+ src/mbgl/style/paint_property_binder.hpp
src/mbgl/style/parser.cpp
src/mbgl/style/parser.hpp
+ src/mbgl/style/possibly_evaluated_property_value.hpp
src/mbgl/style/property_evaluation_parameters.hpp
src/mbgl/style/property_evaluator.hpp
src/mbgl/style/property_parsing.cpp
@@ -252,6 +287,7 @@ set(MBGL_CORE_FILES
# style/conversion
include/mbgl/style/conversion/constant.hpp
+ include/mbgl/style/conversion/data_driven_property_value.hpp
include/mbgl/style/conversion/filter.hpp
include/mbgl/style/conversion/function.hpp
include/mbgl/style/conversion/geojson.hpp
@@ -262,8 +298,23 @@ set(MBGL_CORE_FILES
include/mbgl/style/conversion/property_value.hpp
include/mbgl/style/conversion/source.hpp
include/mbgl/style/conversion/tileset.hpp
+ include/mbgl/style/conversion/transition_options.hpp
src/mbgl/style/conversion/stringify.hpp
+ # style/function
+ include/mbgl/style/function/camera_function.hpp
+ include/mbgl/style/function/categorical_stops.hpp
+ include/mbgl/style/function/composite_categorical_stops.hpp
+ include/mbgl/style/function/composite_exponential_stops.hpp
+ include/mbgl/style/function/composite_function.hpp
+ include/mbgl/style/function/composite_interval_stops.hpp
+ include/mbgl/style/function/exponential_stops.hpp
+ include/mbgl/style/function/identity_stops.hpp
+ include/mbgl/style/function/interval_stops.hpp
+ include/mbgl/style/function/source_function.hpp
+ src/mbgl/style/function/categorical_stops.cpp
+ src/mbgl/style/function/identity_stops.cpp
+
# style/layers
include/mbgl/style/layers/background_layer.hpp
include/mbgl/style/layers/circle_layer.hpp
@@ -442,6 +493,7 @@ set(MBGL_CORE_FILES
src/mbgl/util/i18n.hpp
src/mbgl/util/ignore.hpp
src/mbgl/util/indexed_tuple.hpp
+ src/mbgl/util/interpolate.cpp
src/mbgl/util/interpolate.hpp
src/mbgl/util/intersection_tests.cpp
src/mbgl/util/intersection_tests.hpp
@@ -474,10 +526,12 @@ set(MBGL_CORE_FILES
src/mbgl/util/tile_cover.cpp
src/mbgl/util/tile_cover.hpp
src/mbgl/util/token.hpp
+ src/mbgl/util/type_list.hpp
src/mbgl/util/url.cpp
src/mbgl/util/url.hpp
src/mbgl/util/utf.hpp
- src/mbgl/util/version_info.cpp
+ src/mbgl/util/version.cpp
+ src/mbgl/util/version.hpp
src/mbgl/util/work_queue.cpp
src/mbgl/util/work_queue.hpp
src/mbgl/util/work_request.cpp
diff --git a/cmake/core.cmake b/cmake/core.cmake
index 8d8a942d9f..59de7708b6 100644
--- a/cmake/core.cmake
+++ b/cmake/core.cmake
@@ -1,28 +1,7 @@
-set(MBGL_VERSION_DEPS package.json)
-if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD)
- set(MBGL_VERSION_DEPS ${MBGL_VERSION_DEPS} .git/HEAD)
-endif()
-
-add_custom_command(
- OUTPUT ${MBGL_GENERATED}/include/mbgl/util/version.hpp
- DEPENDS ${MBGL_VERSION_DEPS}
- COMMAND ${NodeJS_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/build-version.js ${MBGL_GENERATED}
- VERBATIM
-)
-
-add_custom_target(mbgl-headers DEPENDS
- ${MBGL_GENERATED}/include/mbgl/util/version.hpp
- ${MBGL_SHADER_FILES}
-)
-
add_library(mbgl-core STATIC
${MBGL_CORE_FILES}
)
-add_dependencies(mbgl-core
- mbgl-headers
-)
-
target_compile_options(mbgl-core
PRIVATE -fPIC
PRIVATE -fvisibility-inlines-hidden
@@ -31,7 +10,6 @@ target_compile_options(mbgl-core
target_include_directories(mbgl-core
PUBLIC include
PUBLIC src # TODO: make private
- PRIVATE ${MBGL_GENERATED}/include
)
target_add_mason_package(mbgl-core PUBLIC geometry)
diff --git a/cmake/glfw.cmake b/cmake/glfw.cmake
index d63bdbc1cf..cdde92bbf2 100644
--- a/cmake/glfw.cmake
+++ b/cmake/glfw.cmake
@@ -25,13 +25,6 @@ target_link_libraries(mbgl-glfw
PRIVATE mbgl-core
)
-add_custom_command(
- TARGET mbgl-glfw POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_SOURCE_DIR}/common/ca-bundle.crt
- ${CMAKE_CURRENT_BINARY_DIR}/ca-bundle.crt
-)
-
target_add_mason_package(mbgl-glfw PRIVATE glfw)
mbgl_platform_glfw()
diff --git a/cmake/mason.cmake b/cmake/mason.cmake
new file mode 100644
index 0000000000..4e4e46b619
--- /dev/null
+++ b/cmake/mason.cmake
@@ -0,0 +1,212 @@
+# Mason CMake
+
+include(CMakeParseArguments)
+
+function(mason_detect_platform)
+ # Determine platform
+ if(NOT MASON_PLATFORM)
+ # we call uname -s manually here since
+ # CMAKE_HOST_SYSTEM_NAME will not be defined before the project() call
+ execute_process(
+ COMMAND uname -s
+ OUTPUT_VARIABLE UNAME
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if (UNAME STREQUAL "Darwin")
+ set(MASON_PLATFORM "osx" PARENT_SCOPE)
+ else()
+ set(MASON_PLATFORM "linux" PARENT_SCOPE)
+ endif()
+ endif()
+
+ # Determine platform version string
+ if(NOT MASON_PLATFORM_VERSION)
+ execute_process(
+ COMMAND uname -m
+ OUTPUT_VARIABLE MASON_PLATFORM_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(MASON_PLATFORM_VERSION "${MASON_PLATFORM_VERSION}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(mason_use _PACKAGE)
+ if(NOT _PACKAGE)
+ message(FATAL_ERROR "[Mason] No package name given")
+ endif()
+
+ cmake_parse_arguments("" "HEADER_ONLY" "VERSION" "" ${ARGN})
+
+ if(_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "[Mason] mason_use() called with unrecognized arguments: ${_UNPARSED_ARGUMENTS}")
+ endif()
+
+ if(NOT _VERSION)
+ message(FATAL_ERROR "[Mason] Specifying a version is required")
+ endif()
+
+ if(MASON_PACKAGE_${_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_${_PACKAGE}_VERSION STREQUAL ${_VERSION})
+ message(FATAL_ERROR "[Mason] Already using ${_PACKAGE} ${MASON_PACKAGE_${_PACKAGE}_VERSION}. Cannot select version ${_VERSION}.")
+ endif()
+ else()
+ if(_HEADER_ONLY)
+ set(_PLATFORM_ID "headers")
+ else()
+ set(_PLATFORM_ID "${MASON_PLATFORM}-${MASON_PLATFORM_VERSION}")
+ endif()
+
+ set(_SLUG "${_PLATFORM_ID}/${_PACKAGE}/${_VERSION}")
+ set(_INSTALL_PATH "${MASON_PACKAGE_DIR}/${_SLUG}")
+ file(RELATIVE_PATH _INSTALL_PATH_RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${_INSTALL_PATH}")
+
+ if(NOT EXISTS "${_INSTALL_PATH}")
+ set(_CACHE_PATH "${MASON_PACKAGE_DIR}/.binaries/${_SLUG}.tar.gz")
+ if (NOT EXISTS "${_CACHE_PATH}")
+ # Download the package
+ set(_URL "${MASON_REPOSITORY}/${_SLUG}.tar.gz")
+ message("[Mason] Downloading package ${_URL}...")
+
+ set(_FAILED)
+ set(_ERROR)
+ # Note: some CMake versions are compiled without SSL support
+ get_filename_component(_CACHE_DIR "${_CACHE_PATH}" DIRECTORY)
+ file(MAKE_DIRECTORY "${_CACHE_DIR}")
+ execute_process(
+ COMMAND curl --retry 3 -s -f -S -L "${_URL}" -o "${_CACHE_PATH}.tmp"
+ RESULT_VARIABLE _FAILED
+ ERROR_VARIABLE _ERROR)
+ if(_FAILED)
+ message(FATAL_ERROR "[Mason] Failed to download ${_URL}: ${_ERROR}")
+ else()
+ # We downloaded to a temporary file to prevent half-finished downloads
+ file(RENAME "${_CACHE_PATH}.tmp" "${_CACHE_PATH}")
+ endif()
+ endif()
+
+ # Unpack the package
+ message("[Mason] Unpacking package to ${_INSTALL_PATH_RELATIVE}...")
+ file(MAKE_DIRECTORY "${_INSTALL_PATH}")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar xzf "${_CACHE_PATH}"
+ WORKING_DIRECTORY "${_INSTALL_PATH}")
+ endif()
+
+ # Error out if there is no config file.
+ if(NOT EXISTS "${_INSTALL_PATH}/mason.ini")
+ message(FATAL_ERROR "[Mason] Could not find mason.ini for package ${_PACKAGE} ${_VERSION}")
+ endif()
+
+ set(MASON_PACKAGE_${_PACKAGE}_PREFIX "${_INSTALL_PATH}" CACHE STRING "${_PACKAGE} ${_INSTALL_PATH}" FORCE)
+ mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_PREFIX)
+
+ # Load the configuration from the ini file
+ file(STRINGS "${_INSTALL_PATH}/mason.ini" _CONFIG_FILE)
+ foreach(_LINE IN LISTS _CONFIG_FILE)
+ string(REGEX MATCH "^([a-z_]+) *= *" _KEY "${_LINE}")
+ if (_KEY)
+ string(LENGTH "${_KEY}" _KEY_LENGTH)
+ string(SUBSTRING "${_LINE}" ${_KEY_LENGTH} -1 _VALUE)
+ string(REGEX REPLACE ";.*$" "" _VALUE "${_VALUE}") # Trim trailing commas
+ string(REPLACE "{prefix}" "${_INSTALL_PATH}" _VALUE "${_VALUE}")
+ string(STRIP "${_VALUE}" _VALUE)
+ string(REPLACE "=" "" _KEY "${_KEY}")
+ string(STRIP "${_KEY}" _KEY)
+ string(TOUPPER "${_KEY}" _KEY)
+ if(_KEY STREQUAL "INCLUDE_DIRS" OR _KEY STREQUAL "STATIC_LIBS" )
+ separate_arguments(_VALUE)
+ endif()
+ set(MASON_PACKAGE_${_PACKAGE}_${_KEY} "${_VALUE}" CACHE STRING "${_PACKAGE} ${_KEY}" FORCE)
+ mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_${_KEY})
+ endif()
+ endforeach()
+
+ # Compare version in the package to catch errors early on
+ if(NOT _VERSION STREQUAL MASON_PACKAGE_${_PACKAGE}_VERSION)
+ message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has version '${MASON_PACKAGE_${_PACKAGE}_VERSION}', but required '${_VERSION}'")
+ endif()
+
+ if(NOT _PACKAGE STREQUAL MASON_PACKAGE_${_PACKAGE}_NAME)
+ message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has name '${MASON_PACKAGE_${_PACKAGE}_NAME}', but required '${_NAME}'")
+ endif()
+
+ if(NOT _HEADER_ONLY)
+ if(NOT MASON_PLATFORM STREQUAL MASON_PACKAGE_${_PACKAGE}_PLATFORM)
+ message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has platform '${MASON_PACKAGE_${_PACKAGE}_PLATFORM}', but required '${MASON_PLATFORM}'")
+ endif()
+
+ if(NOT MASON_PLATFORM_VERSION STREQUAL MASON_PACKAGE_${_PACKAGE}_PLATFORM_VERSION)
+ message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has platform version '${MASON_PACKAGE_${_PACKAGE}_PLATFORM_VERSION}', but required '${MASON_PLATFORM_VERSION}'")
+ endif()
+ endif()
+
+ # Concatenate the static libs and libraries
+ set(_LIBRARIES)
+ list(APPEND _LIBRARIES ${MASON_PACKAGE_${_PACKAGE}_STATIC_LIBS} ${MASON_PACKAGE_${_PACKAGE}_LDFLAGS})
+ set(MASON_PACKAGE_${_PACKAGE}_LIBRARIES "${_LIBRARIES}" CACHE STRING "${_PACKAGE} _LIBRARIES" FORCE)
+ mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_LIBRARIES)
+
+ if(NOT _HEADER_ONLY)
+ string(REGEX MATCHALL "(^| +)-L *([^ ]+)" MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS "${MASON_PACKAGE_${_PACKAGE}_LDFLAGS}")
+ string(REGEX REPLACE "(^| +)-L *" "\\1" MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS "${MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS}")
+ set(MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS "${MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS}" CACHE STRING "${_PACKAGE} ${MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS}" FORCE)
+ mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS)
+ endif()
+
+ # Store invocation ID to prevent different versions of the same package in one invocation
+ set(MASON_PACKAGE_${_PACKAGE}_INVOCATION "${MASON_INVOCATION}" CACHE INTERNAL "${_PACKAGE} invocation ID" FORCE)
+ endif()
+endfunction()
+
+macro(target_add_mason_package _TARGET _VISIBILITY _PACKAGE)
+ if (NOT MASON_PACKAGE_${_PACKAGE}_INVOCATION)
+ message(FATAL_ERROR "[Mason] Package ${_PACKAGE} has not been initialized yet")
+ endif()
+
+ target_include_directories(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_INCLUDE_DIRS}")
+ target_compile_definitions(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_DEFINITIONS}")
+ target_compile_options(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_OPTIONS}")
+ target_link_libraries(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_LIBRARIES}")
+endmacro()
+
+# Setup
+
+string(RANDOM LENGTH 16 MASON_INVOCATION)
+
+# Read environment variables if CMake is run in command mode
+if (CMAKE_ARGC)
+ set(MASON_PLATFORM "$ENV{MASON_PLATFORM}")
+ set(MASON_PLATFORM_VERSION "$ENV{MASON_PLATFORM_VERSION}")
+ set(MASON_PACKAGE_DIR "$ENV{MASON_PACKAGE_DIR}")
+ set(MASON_REPOSITORY "$ENV{MASON_REPOSITORY}")
+endif()
+
+# Directory where Mason packages are located; typically ends with mason_packages
+if (NOT MASON_PACKAGE_DIR)
+ set(MASON_PACKAGE_DIR "${CMAKE_SOURCE_DIR}/mason_packages")
+endif()
+
+# URL prefix of where packages are located.
+if (NOT MASON_REPOSITORY)
+ set(MASON_REPOSITORY "https://mason-binaries.s3.amazonaws.com")
+endif()
+
+mason_detect_platform()
+
+# Execute commands if CMake is run in command mode
+if (CMAKE_ARGC)
+ # Collect remaining arguments for passing to mason_use
+ set(_MASON_ARGS)
+ foreach(I RANGE 4 ${CMAKE_ARGC})
+ list(APPEND _MASON_ARGS "${CMAKE_ARGV${I}}")
+ endforeach()
+
+ # Install the package
+ mason_use(${_MASON_ARGS})
+
+ # Optionally print variables
+ if(DEFINED MASON_PACKAGE_${CMAKE_ARGV4}_${CMAKE_ARGV3})
+ # CMake can't write to stdout with message()
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${MASON_PACKAGE_${CMAKE_ARGV4}_${CMAKE_ARGV3}}")
+ endif()
+endif()
diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake
index 4002257bb4..8c9aa0fe8f 100644
--- a/cmake/mbgl.cmake
+++ b/cmake/mbgl.cmake
@@ -6,27 +6,12 @@ if (NOT MBGL_PLATFORM)
endif()
endif()
-if (NOT MASON_PLATFORM)
- set(MASON_PLATFORM "${MBGL_PLATFORM}")
+find_program(NodeJS_EXECUTABLE NAMES nodejs node)
+if (NOT NodeJS_EXECUTABLE)
+ message(FATAL_ERROR "Could not find Node.js")
endif()
-set(MBGL_GENERATED ${CMAKE_BINARY_DIR}/generated/${CMAKE_CFG_INTDIR})
-
-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/node_modules/node-cmake/FindNodeJS.cmake)
- message(FATAL_ERROR "Can't find node-cmake")
-endif()
-
-# Load Node.js
-set(NodeJS_CXX_STANDARD 14 CACHE INTERNAL "Use C++14" FORCE)
-set(NodeJS_DOWNLOAD ON CACHE INTERNAL "Download node.js sources" FORCE)
-set(NodeJS_USE_CLANG_STDLIB OFF CACHE BOOL "Don't use libc++ by default" FORCE)
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/node_modules/node-cmake)
-find_package(NodeJS)
-
-find_program(npm_EXECUTABLE
- NAMES npm
- PATHS ${NodeJS_ROOT_DIR})
-
+find_program(npm_EXECUTABLE NAMES npm)
if (NOT npm_EXECUTABLE)
message(FATAL_ERROR "Could not find npm")
endif()
@@ -56,7 +41,7 @@ endfunction()
# Run submodule update
message(STATUS "Updating submodules...")
execute_process(
- COMMAND git submodule update --init .mason mapbox-gl-js
+ COMMAND git submodule update --init mapbox-gl-js
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/mapbox-gl-js/node_modules")
@@ -70,14 +55,14 @@ endif()
# Add target for running submodule update during builds
add_custom_target(
update-submodules ALL
- COMMAND git submodule update --init .mason mapbox-gl-js
+ 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" mapbox-gl-js "${CMAKE_SOURCE_DIR}/node_modules/.mapbox-gl-native.stamp")
+_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"
diff --git a/cmake/node.cmake b/cmake/node.cmake
index ea28e86106..b9a4f68ecc 100644
--- a/cmake/node.cmake
+++ b/cmake/node.cmake
@@ -1,7 +1,15 @@
+# Load Node.js
+include(cmake/NodeJS.cmake)
+nodejs_init()
+
add_nodejs_module(mbgl-node
platform/node/src/node_mapbox_gl_native.cpp
)
+# NodeJS.cmake forces C++11.
+# https://github.com/cjntaylor/node-cmake/issues/18
+set_target_properties("mbgl-node" PROPERTIES CXX_STANDARD 14)
+
target_sources(mbgl-node
PRIVATE platform/node/src/node_logging.hpp
PRIVATE platform/node/src/node_logging.cpp
@@ -41,7 +49,7 @@ target_add_mason_package(mbgl-node PRIVATE geojson)
add_custom_command(
TARGET mbgl-node
POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mbgl-node> ${CMAKE_SOURCE_DIR}/lib/mapbox-gl-native.node
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mbgl-node> ${CMAKE_SOURCE_DIR}/lib/mapbox_gl_native.node
)
mbgl_platform_node()
diff --git a/cmake/shaders.cmake b/cmake/shaders.cmake
deleted file mode 100644
index a9ded80a6c..0000000000
--- a/cmake/shaders.cmake
+++ /dev/null
@@ -1,32 +0,0 @@
-function(add_shader VAR name)
- set(shader_build_cmd ${NodeJS_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/build-shaders.js)
- set(shader_file_prefix ${CMAKE_SOURCE_DIR}/mapbox-gl-js/shaders)
- set(shader_source_prefix ${MBGL_GENERATED}/include/mbgl/shader)
-
- add_custom_command(
- OUTPUT ${shader_source_prefix}/${name}.hpp
- COMMAND ${shader_build_cmd} ${name} ${shader_file_prefix} ${shader_source_prefix}
- DEPENDS npm-install
- DEPENDS ${CMAKE_SOURCE_DIR}/scripts/build-shaders.js
- DEPENDS ${shader_file_prefix}/${name}.vertex.glsl
- DEPENDS ${shader_file_prefix}/${name}.fragment.glsl
- DEPENDS ${shader_file_prefix}/_prelude.vertex.glsl
- DEPENDS ${shader_file_prefix}/_prelude.fragment.glsl
- VERBATIM
- )
- set(${VAR} ${${VAR}} ${shader_source_prefix}/${name}.hpp PARENT_SCOPE)
-endfunction()
-
-add_shader(MBGL_SHADER_FILES circle)
-add_shader(MBGL_SHADER_FILES collision_box)
-add_shader(MBGL_SHADER_FILES debug)
-add_shader(MBGL_SHADER_FILES fill)
-add_shader(MBGL_SHADER_FILES fill_outline)
-add_shader(MBGL_SHADER_FILES fill_outline_pattern)
-add_shader(MBGL_SHADER_FILES fill_pattern)
-add_shader(MBGL_SHADER_FILES line)
-add_shader(MBGL_SHADER_FILES line_pattern)
-add_shader(MBGL_SHADER_FILES line_sdf)
-add_shader(MBGL_SHADER_FILES raster)
-add_shader(MBGL_SHADER_FILES symbol_icon)
-add_shader(MBGL_SHADER_FILES symbol_sdf)
diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake
index 5d2b63d13f..59929bbb70 100644
--- a/cmake/test-files.cmake
+++ b/cmake/test-files.cmake
@@ -48,8 +48,11 @@ set(MBGL_TEST_FILES
test/src/mbgl/test/fake_file_source.hpp
test/src/mbgl/test/fixture_log_observer.cpp
test/src/mbgl/test/fixture_log_observer.hpp
+ test/src/mbgl/test/getrss.cpp
+ test/src/mbgl/test/getrss.hpp
test/src/mbgl/test/stub_file_source.cpp
test/src/mbgl/test/stub_file_source.hpp
+ test/src/mbgl/test/stub_geometry_tile_feature.hpp
test/src/mbgl/test/stub_layer_observer.hpp
test/src/mbgl/test/stub_style_observer.hpp
test/src/mbgl/test/stub_tile_observer.hpp
@@ -68,15 +71,22 @@ set(MBGL_TEST_FILES
test/storage/offline_download.test.cpp
test/storage/online_file_source.test.cpp
test/storage/resource.test.cpp
+ test/storage/sqlite.test.cpp
# style/conversion
test/style/conversion/function.test.cpp
test/style/conversion/geojson_options.test.cpp
+ test/style/conversion/layer.test.cpp
test/style/conversion/stringify.test.cpp
# style
test/style/filter.test.cpp
- test/style/functions.test.cpp
+
+ # style/function
+ test/style/function/camera_function.test.cpp
+ test/style/function/source_function.test.cpp
+
+ # style
test/style/group_by_layout.test.cpp
test/style/paint_property.test.cpp
test/style/source.test.cpp
diff --git a/cmake/test.cmake b/cmake/test.cmake
index fc7a22874c..2a83a633c0 100644
--- a/cmake/test.cmake
+++ b/cmake/test.cmake
@@ -14,7 +14,6 @@ target_include_directories(mbgl-test
PRIVATE test/include
PRIVATE test/src
PRIVATE platform/default
- PRIVATE ${MBGL_GENERATED}/include
)
target_link_libraries(mbgl-test