diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-06-03 18:05:04 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-08-05 11:42:22 +0200 |
commit | 692fe1f3ffc8f4364b39c14aa7d90cec2ff5c0a6 (patch) | |
tree | 1d08af7d56e986dba2b548ff9b9a7e1a77c713ed /cmake | |
parent | e3ee55b28d0b230d054c9718f79a1f6d685cd62b (diff) | |
download | qtlocation-mapboxgl-692fe1f3ffc8f4364b39c14aa7d90cec2ff5c0a6.tar.gz |
[build] switch to CMake
This is very much a work in progress.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/core-files.cmake | 465 | ||||
-rw-r--r-- | cmake/core.cmake | 52 | ||||
-rw-r--r-- | cmake/glfw.cmake | 27 | ||||
-rw-r--r-- | cmake/loop-darwin.cmake | 18 | ||||
-rw-r--r-- | cmake/loop-uv.cmake | 19 | ||||
-rw-r--r-- | cmake/mason.cmake | 117 | ||||
-rw-r--r-- | cmake/mbgl.cmake | 50 | ||||
-rw-r--r-- | cmake/node.cmake | 52 | ||||
-rw-r--r-- | cmake/npm.cmake | 20 | ||||
-rw-r--r-- | cmake/offline.cmake | 21 | ||||
-rw-r--r-- | cmake/render.cmake | 21 | ||||
-rw-r--r-- | cmake/shaders.cmake | 29 | ||||
-rw-r--r-- | cmake/test-files.cmake | 100 | ||||
-rw-r--r-- | cmake/test.cmake | 35 |
14 files changed, 1026 insertions, 0 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake new file mode 100644 index 0000000000..d817909e33 --- /dev/null +++ b/cmake/core-files.cmake @@ -0,0 +1,465 @@ +# Do not edit. Regenerate this with ./scripts/generate-core-files.sh + +set(MBGL_CORE_FILES + # algorithm + src/mbgl/algorithm/covered_by_children.hpp + src/mbgl/algorithm/generate_clip_ids.cpp + src/mbgl/algorithm/generate_clip_ids.hpp + src/mbgl/algorithm/generate_clip_ids_impl.hpp + src/mbgl/algorithm/update_renderables.hpp + + # annotation + include/mbgl/annotation/annotation.hpp + src/mbgl/annotation/annotation_manager.cpp + src/mbgl/annotation/annotation_manager.hpp + src/mbgl/annotation/annotation_source.cpp + src/mbgl/annotation/annotation_source.hpp + src/mbgl/annotation/annotation_tile.cpp + src/mbgl/annotation/annotation_tile.hpp + src/mbgl/annotation/fill_annotation_impl.cpp + src/mbgl/annotation/fill_annotation_impl.hpp + src/mbgl/annotation/line_annotation_impl.cpp + src/mbgl/annotation/line_annotation_impl.hpp + src/mbgl/annotation/shape_annotation_impl.cpp + src/mbgl/annotation/shape_annotation_impl.hpp + src/mbgl/annotation/style_sourced_annotation_impl.cpp + src/mbgl/annotation/style_sourced_annotation_impl.hpp + src/mbgl/annotation/symbol_annotation_impl.cpp + src/mbgl/annotation/symbol_annotation_impl.hpp + + # clipper + src/clipper/clipper.cpp + src/clipper/clipper.hpp + + # csscolorparser + src/csscolorparser/csscolorparser.cpp + src/csscolorparser/csscolorparser.hpp + + # geometry + src/mbgl/geometry/anchor.hpp + src/mbgl/geometry/binpack.hpp + src/mbgl/geometry/buffer.hpp + src/mbgl/geometry/circle_buffer.cpp + src/mbgl/geometry/circle_buffer.hpp + src/mbgl/geometry/collision_box_buffer.cpp + src/mbgl/geometry/collision_box_buffer.hpp + src/mbgl/geometry/debug_font_buffer.cpp + src/mbgl/geometry/debug_font_buffer.hpp + src/mbgl/geometry/debug_font_data.hpp + src/mbgl/geometry/elements_buffer.cpp + src/mbgl/geometry/elements_buffer.hpp + src/mbgl/geometry/feature_index.cpp + src/mbgl/geometry/feature_index.hpp + src/mbgl/geometry/fill_buffer.cpp + src/mbgl/geometry/fill_buffer.hpp + src/mbgl/geometry/glyph_atlas.cpp + src/mbgl/geometry/glyph_atlas.hpp + src/mbgl/geometry/icon_buffer.cpp + src/mbgl/geometry/icon_buffer.hpp + src/mbgl/geometry/line_atlas.cpp + src/mbgl/geometry/line_atlas.hpp + src/mbgl/geometry/line_buffer.cpp + src/mbgl/geometry/line_buffer.hpp + src/mbgl/geometry/static_vertex_buffer.cpp + src/mbgl/geometry/static_vertex_buffer.hpp + src/mbgl/geometry/text_buffer.cpp + src/mbgl/geometry/text_buffer.hpp + src/mbgl/geometry/vao.cpp + src/mbgl/geometry/vao.hpp + + # gl + include/mbgl/gl/gl.hpp + include/mbgl/gl/gl_helper.hpp + include/mbgl/gl/gl_values.hpp + src/mbgl/gl/debugging.cpp + src/mbgl/gl/debugging.hpp + src/mbgl/gl/gl.cpp + src/mbgl/gl/gl_config.cpp + src/mbgl/gl/gl_config.hpp + src/mbgl/gl/object_store.cpp + src/mbgl/gl/object_store.hpp + + # map + include/mbgl/map/camera.hpp + include/mbgl/map/map.hpp + include/mbgl/map/mode.hpp + include/mbgl/map/update.hpp + include/mbgl/map/view.hpp + src/mbgl/map/change.hpp + src/mbgl/map/map.cpp + src/mbgl/map/transform.cpp + src/mbgl/map/transform.hpp + src/mbgl/map/transform_state.cpp + src/mbgl/map/transform_state.hpp + src/mbgl/map/view.cpp + src/mbgl/map/zoom_history.hpp + + # math + include/mbgl/math/clamp.hpp + include/mbgl/math/minmax.hpp + include/mbgl/math/wrap.hpp + + # mbgl + include/mbgl/mbgl.hpp + + # parsedate + src/parsedate/parsedate.c + src/parsedate/parsedate.h + + # platform + include/mbgl/platform/event.hpp + include/mbgl/platform/log.hpp + include/mbgl/platform/platform.hpp + src/mbgl/platform/event.cpp + src/mbgl/platform/log.cpp + + # platform/darwin + include/mbgl/platform/darwin/reachability.h + + # platform/default + include/mbgl/platform/default/glfw_view.hpp + include/mbgl/platform/default/headless_display.hpp + include/mbgl/platform/default/headless_view.hpp + include/mbgl/platform/default/settings_json.hpp + + # renderer + src/mbgl/renderer/bucket.hpp + src/mbgl/renderer/circle_bucket.cpp + src/mbgl/renderer/circle_bucket.hpp + src/mbgl/renderer/debug_bucket.cpp + src/mbgl/renderer/debug_bucket.hpp + src/mbgl/renderer/fill_bucket.cpp + src/mbgl/renderer/fill_bucket.hpp + src/mbgl/renderer/frame_history.cpp + src/mbgl/renderer/frame_history.hpp + src/mbgl/renderer/line_bucket.cpp + src/mbgl/renderer/line_bucket.hpp + src/mbgl/renderer/paint_parameters.hpp + src/mbgl/renderer/painter.cpp + src/mbgl/renderer/painter.hpp + src/mbgl/renderer/painter_background.cpp + src/mbgl/renderer/painter_circle.cpp + src/mbgl/renderer/painter_clipping.cpp + src/mbgl/renderer/painter_debug.cpp + src/mbgl/renderer/painter_fill.cpp + src/mbgl/renderer/painter_line.cpp + src/mbgl/renderer/painter_raster.cpp + src/mbgl/renderer/painter_symbol.cpp + src/mbgl/renderer/raster_bucket.cpp + src/mbgl/renderer/raster_bucket.hpp + src/mbgl/renderer/render_item.hpp + src/mbgl/renderer/render_pass.hpp + src/mbgl/renderer/render_tile.cpp + src/mbgl/renderer/render_tile.hpp + src/mbgl/renderer/symbol_bucket.cpp + src/mbgl/renderer/symbol_bucket.hpp + + # shader + src/mbgl/shader/circle_shader.cpp + src/mbgl/shader/circle_shader.hpp + src/mbgl/shader/collision_box_shader.cpp + src/mbgl/shader/collision_box_shader.hpp + src/mbgl/shader/icon_shader.cpp + src/mbgl/shader/icon_shader.hpp + src/mbgl/shader/line_shader.cpp + src/mbgl/shader/line_shader.hpp + src/mbgl/shader/linepattern_shader.cpp + src/mbgl/shader/linepattern_shader.hpp + src/mbgl/shader/linesdf_shader.cpp + src/mbgl/shader/linesdf_shader.hpp + src/mbgl/shader/outline_shader.cpp + src/mbgl/shader/outline_shader.hpp + src/mbgl/shader/outlinepattern_shader.cpp + src/mbgl/shader/outlinepattern_shader.hpp + src/mbgl/shader/pattern_shader.cpp + src/mbgl/shader/pattern_shader.hpp + src/mbgl/shader/plain_shader.cpp + src/mbgl/shader/plain_shader.hpp + src/mbgl/shader/raster_shader.cpp + src/mbgl/shader/raster_shader.hpp + src/mbgl/shader/sdf_shader.cpp + src/mbgl/shader/sdf_shader.hpp + src/mbgl/shader/shader.cpp + src/mbgl/shader/shader.hpp + src/mbgl/shader/shaders.hpp + src/mbgl/shader/uniform.cpp + src/mbgl/shader/uniform.hpp + + # sprite + include/mbgl/sprite/sprite_image.hpp + src/mbgl/sprite/sprite_atlas.cpp + src/mbgl/sprite/sprite_atlas.hpp + src/mbgl/sprite/sprite_image.cpp + src/mbgl/sprite/sprite_parser.cpp + src/mbgl/sprite/sprite_parser.hpp + src/mbgl/sprite/sprite_store.cpp + src/mbgl/sprite/sprite_store.hpp + src/mbgl/sprite/sprite_store_observer.hpp + + # storage + include/mbgl/storage/default_file_source.hpp + include/mbgl/storage/file_source.hpp + include/mbgl/storage/network_status.hpp + include/mbgl/storage/offline.hpp + include/mbgl/storage/online_file_source.hpp + include/mbgl/storage/resource.hpp + include/mbgl/storage/response.hpp + src/mbgl/storage/asset_file_source.hpp + src/mbgl/storage/http_file_source.hpp + src/mbgl/storage/network_status.cpp + src/mbgl/storage/resource.cpp + src/mbgl/storage/response.cpp + + # style + include/mbgl/style/conversion.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 + src/mbgl/style/bucket_parameters.cpp + src/mbgl/style/bucket_parameters.hpp + src/mbgl/style/calculation_parameters.hpp + src/mbgl/style/cascade_parameters.hpp + src/mbgl/style/class_dictionary.cpp + src/mbgl/style/class_dictionary.hpp + src/mbgl/style/layer.cpp + src/mbgl/style/layer_impl.cpp + src/mbgl/style/layer_impl.hpp + src/mbgl/style/layout_property.hpp + src/mbgl/style/observer.hpp + src/mbgl/style/paint_property.hpp + src/mbgl/style/parser.cpp + src/mbgl/style/parser.hpp + src/mbgl/style/property_evaluator.cpp + src/mbgl/style/property_evaluator.hpp + src/mbgl/style/property_parsing.cpp + src/mbgl/style/property_parsing.hpp + src/mbgl/style/query_parameters.hpp + src/mbgl/style/rapidjson_conversion.hpp + src/mbgl/style/source.cpp + src/mbgl/style/source_impl.cpp + src/mbgl/style/source_impl.hpp + src/mbgl/style/source_observer.hpp + src/mbgl/style/style.cpp + src/mbgl/style/style.hpp + src/mbgl/style/tile_source_impl.cpp + src/mbgl/style/tile_source_impl.hpp + src/mbgl/style/types.cpp + src/mbgl/style/update_parameters.hpp + + # style/conversion + include/mbgl/style/conversion/constant.hpp + include/mbgl/style/conversion/filter.hpp + include/mbgl/style/conversion/function.hpp + include/mbgl/style/conversion/geojson.hpp + include/mbgl/style/conversion/layer.hpp + include/mbgl/style/conversion/make_property_setters.hpp + include/mbgl/style/conversion/property_setter.hpp + include/mbgl/style/conversion/property_value.hpp + include/mbgl/style/conversion/source.hpp + include/mbgl/style/conversion/tileset.hpp + + # style/layers + include/mbgl/style/layers/background_layer.hpp + include/mbgl/style/layers/circle_layer.hpp + include/mbgl/style/layers/custom_layer.hpp + include/mbgl/style/layers/fill_layer.hpp + include/mbgl/style/layers/line_layer.hpp + include/mbgl/style/layers/raster_layer.hpp + include/mbgl/style/layers/symbol_layer.hpp + src/mbgl/style/layers/background_layer.cpp + src/mbgl/style/layers/background_layer_impl.cpp + src/mbgl/style/layers/background_layer_impl.hpp + src/mbgl/style/layers/background_layer_properties.cpp + src/mbgl/style/layers/background_layer_properties.hpp + src/mbgl/style/layers/circle_layer.cpp + src/mbgl/style/layers/circle_layer_impl.cpp + src/mbgl/style/layers/circle_layer_impl.hpp + src/mbgl/style/layers/circle_layer_properties.cpp + src/mbgl/style/layers/circle_layer_properties.hpp + src/mbgl/style/layers/custom_layer.cpp + src/mbgl/style/layers/custom_layer_impl.cpp + src/mbgl/style/layers/custom_layer_impl.hpp + src/mbgl/style/layers/fill_layer.cpp + src/mbgl/style/layers/fill_layer_impl.cpp + src/mbgl/style/layers/fill_layer_impl.hpp + src/mbgl/style/layers/fill_layer_properties.cpp + src/mbgl/style/layers/fill_layer_properties.hpp + src/mbgl/style/layers/line_layer.cpp + src/mbgl/style/layers/line_layer_impl.cpp + src/mbgl/style/layers/line_layer_impl.hpp + src/mbgl/style/layers/line_layer_properties.cpp + src/mbgl/style/layers/line_layer_properties.hpp + src/mbgl/style/layers/raster_layer.cpp + src/mbgl/style/layers/raster_layer_impl.cpp + src/mbgl/style/layers/raster_layer_impl.hpp + src/mbgl/style/layers/raster_layer_properties.cpp + src/mbgl/style/layers/raster_layer_properties.hpp + src/mbgl/style/layers/symbol_layer.cpp + src/mbgl/style/layers/symbol_layer_impl.cpp + src/mbgl/style/layers/symbol_layer_impl.hpp + src/mbgl/style/layers/symbol_layer_properties.cpp + src/mbgl/style/layers/symbol_layer_properties.hpp + + # style/sources + include/mbgl/style/sources/geojson_source.hpp + include/mbgl/style/sources/raster_source.hpp + include/mbgl/style/sources/vector_source.hpp + src/mbgl/style/sources/geojson_source.cpp + src/mbgl/style/sources/geojson_source_impl.cpp + src/mbgl/style/sources/geojson_source_impl.hpp + src/mbgl/style/sources/raster_source.cpp + src/mbgl/style/sources/raster_source_impl.cpp + src/mbgl/style/sources/raster_source_impl.hpp + src/mbgl/style/sources/vector_source.cpp + src/mbgl/style/sources/vector_source_impl.cpp + src/mbgl/style/sources/vector_source_impl.hpp + + # text + src/mbgl/text/check_max_angle.cpp + src/mbgl/text/check_max_angle.hpp + src/mbgl/text/collision_feature.cpp + src/mbgl/text/collision_feature.hpp + src/mbgl/text/collision_tile.cpp + src/mbgl/text/collision_tile.hpp + src/mbgl/text/get_anchors.cpp + src/mbgl/text/get_anchors.hpp + src/mbgl/text/glyph.cpp + src/mbgl/text/glyph.hpp + src/mbgl/text/glyph_pbf.cpp + src/mbgl/text/glyph_pbf.hpp + src/mbgl/text/glyph_range.hpp + src/mbgl/text/glyph_set.cpp + src/mbgl/text/glyph_set.hpp + src/mbgl/text/glyph_store.cpp + src/mbgl/text/glyph_store.hpp + src/mbgl/text/glyph_store_observer.hpp + src/mbgl/text/placement_config.hpp + src/mbgl/text/quads.cpp + src/mbgl/text/quads.hpp + src/mbgl/text/shaping.cpp + src/mbgl/text/shaping.hpp + + # tile + src/mbgl/tile/geojson_tile.cpp + src/mbgl/tile/geojson_tile.hpp + src/mbgl/tile/geometry_tile.cpp + src/mbgl/tile/geometry_tile.hpp + src/mbgl/tile/geometry_tile_data.cpp + src/mbgl/tile/geometry_tile_data.hpp + src/mbgl/tile/raster_tile.cpp + src/mbgl/tile/raster_tile.hpp + src/mbgl/tile/tile.cpp + src/mbgl/tile/tile.hpp + src/mbgl/tile/tile_cache.cpp + src/mbgl/tile/tile_cache.hpp + src/mbgl/tile/tile_id.hpp + src/mbgl/tile/tile_id_io.cpp + src/mbgl/tile/tile_loader.hpp + src/mbgl/tile/tile_loader_impl.hpp + src/mbgl/tile/tile_observer.hpp + src/mbgl/tile/tile_worker.cpp + src/mbgl/tile/tile_worker.hpp + src/mbgl/tile/vector_tile.cpp + src/mbgl/tile/vector_tile.hpp + + # util + include/mbgl/util/async_request.hpp + include/mbgl/util/char_array_buffer.hpp + include/mbgl/util/chrono.hpp + include/mbgl/util/color.hpp + include/mbgl/util/compression.hpp + include/mbgl/util/constants.hpp + include/mbgl/util/convert.hpp + include/mbgl/util/default_styles.hpp + include/mbgl/util/enum.hpp + include/mbgl/util/exception.hpp + include/mbgl/util/feature.hpp + include/mbgl/util/font_stack.hpp + include/mbgl/util/geo.hpp + include/mbgl/util/geojson.hpp + include/mbgl/util/geometry.hpp + include/mbgl/util/image.hpp + include/mbgl/util/noncopyable.hpp + include/mbgl/util/optional.hpp + include/mbgl/util/projection.hpp + include/mbgl/util/range.hpp + include/mbgl/util/run_loop.hpp + include/mbgl/util/string.hpp + include/mbgl/util/tileset.hpp + include/mbgl/util/timer.hpp + include/mbgl/util/traits.hpp + include/mbgl/util/unitbezier.hpp + include/mbgl/util/util.hpp + include/mbgl/util/variant.hpp + include/mbgl/util/work_request.hpp + include/mbgl/util/work_task.hpp + src/mbgl/util/async_task.hpp + src/mbgl/util/chrono.cpp + src/mbgl/util/clip_id.cpp + src/mbgl/util/clip_id.hpp + src/mbgl/util/clip_lines.cpp + src/mbgl/util/clip_lines.hpp + src/mbgl/util/color.cpp + src/mbgl/util/compression.cpp + src/mbgl/util/constants.cpp + src/mbgl/util/convert.cpp + src/mbgl/util/default_styles.cpp + src/mbgl/util/dtoa.cpp + src/mbgl/util/dtoa.hpp + src/mbgl/util/exclusive.hpp + src/mbgl/util/font_stack.cpp + src/mbgl/util/geo.cpp + src/mbgl/util/grid_index.cpp + src/mbgl/util/grid_index.hpp + src/mbgl/util/http_header.cpp + src/mbgl/util/http_header.hpp + src/mbgl/util/interpolate.hpp + src/mbgl/util/intersection_tests.cpp + src/mbgl/util/intersection_tests.hpp + src/mbgl/util/io.cpp + src/mbgl/util/io.hpp + src/mbgl/util/mapbox.cpp + src/mbgl/util/mapbox.hpp + src/mbgl/util/mat2.cpp + src/mbgl/util/mat2.hpp + src/mbgl/util/mat3.cpp + src/mbgl/util/mat3.hpp + src/mbgl/util/mat4.cpp + src/mbgl/util/mat4.hpp + src/mbgl/util/math.cpp + src/mbgl/util/math.hpp + src/mbgl/util/merge_lines.cpp + src/mbgl/util/merge_lines.hpp + src/mbgl/util/premultiply.cpp + src/mbgl/util/premultiply.hpp + src/mbgl/util/ptr.hpp + src/mbgl/util/rapidjson.hpp + src/mbgl/util/raster.cpp + src/mbgl/util/raster.hpp + src/mbgl/util/rect.hpp + src/mbgl/util/std.hpp + src/mbgl/util/stopwatch.cpp + src/mbgl/util/stopwatch.hpp + src/mbgl/util/thread.hpp + src/mbgl/util/thread_context.cpp + src/mbgl/util/thread_context.hpp + src/mbgl/util/thread_local.hpp + src/mbgl/util/tile_coordinate.hpp + src/mbgl/util/tile_cover.cpp + src/mbgl/util/tile_cover.hpp + src/mbgl/util/token.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/work_queue.cpp + src/mbgl/util/work_queue.hpp + src/mbgl/util/work_request.cpp + src/mbgl/util/worker.cpp + src/mbgl/util/worker.hpp +) diff --git a/cmake/core.cmake b/cmake/core.cmake new file mode 100644 index 0000000000..266a5c92a2 --- /dev/null +++ b/cmake/core.cmake @@ -0,0 +1,52 @@ +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 ${CMAKE_SOURCE_DIR}/scripts/build-version.py ${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 +) + +target_include_directories(mbgl-core + PUBLIC include + PUBLIC src # TODO: make private + PRIVATE ${MBGL_GENERATED}/include +) + +target_add_mason_package(mbgl-core PUBLIC geometry) +target_add_mason_package(mbgl-core PUBLIC variant) +target_add_mason_package(mbgl-core PRIVATE unique_resource) +target_add_mason_package(mbgl-core PRIVATE rapidjson) +target_add_mason_package(mbgl-core PRIVATE boost) +target_add_mason_package(mbgl-core PRIVATE geojson) +target_add_mason_package(mbgl-core PRIVATE geojsonvt) +target_add_mason_package(mbgl-core PRIVATE supercluster) +target_add_mason_package(mbgl-core PRIVATE kdbush) +target_add_mason_package(mbgl-core PRIVATE earcut) +target_add_mason_package(mbgl-core PRIVATE protozero) + +mbgl_platform_core() + +create_source_groups(mbgl-core) +target_append_xcconfig(mbgl-core) diff --git a/cmake/glfw.cmake b/cmake/glfw.cmake new file mode 100644 index 0000000000..67eac0934d --- /dev/null +++ b/cmake/glfw.cmake @@ -0,0 +1,27 @@ +add_executable(mbgl-glfw + bin/glfw.cpp +) + +target_sources(mbgl-glfw + PRIVATE include/mbgl/platform/default/glfw_view.hpp + PRIVATE platform/default/glfw_view.cpp + PRIVATE include/mbgl/platform/default/settings_json.hpp + PRIVATE platform/default/settings_json.cpp +) + +target_compile_options(mbgl-glfw + PRIVATE -fvisibility-inlines-hidden +) + +target_include_directories(mbgl-glfw + PRIVATE include + PRIVATE src # TODO: eliminate +) + +target_link_libraries(mbgl-glfw + PRIVATE mbgl-core +) + +target_add_mason_package(mbgl-glfw PRIVATE glfw) + +mbgl_platform_glfw() diff --git a/cmake/loop-darwin.cmake b/cmake/loop-darwin.cmake new file mode 100644 index 0000000000..16bc62537c --- /dev/null +++ b/cmake/loop-darwin.cmake @@ -0,0 +1,18 @@ +add_library(mbgl-loop STATIC + platform/darwin/src/async_task.cpp + platform/darwin/src/run_loop.cpp + platform/darwin/src/timer.cpp +) + +target_compile_options(mbgl-loop + PRIVATE -fPIC + PRIVATE -fvisibility-inlines-hidden +) + +target_include_directories(mbgl-loop + PUBLIC include + PRIVATE src +) + +create_source_groups(mbgl-loop) +target_append_xcconfig(mbgl-loop) diff --git a/cmake/loop-uv.cmake b/cmake/loop-uv.cmake new file mode 100644 index 0000000000..d44f43580c --- /dev/null +++ b/cmake/loop-uv.cmake @@ -0,0 +1,19 @@ +add_library(mbgl-loop STATIC + platform/default/async_task.cpp + platform/default/run_loop.cpp + platform/default/timer.cpp +) + +target_compile_options(mbgl-loop + PRIVATE -fPIC + PRIVATE -fvisibility-inlines-hidden +) + +target_include_directories(mbgl-loop + PUBLIC include + PRIVATE src +) + +target_add_mason_package(mbgl-loop PUBLIC libuv) + +create_source_groups(mbgl-loop) diff --git a/cmake/mason.cmake b/cmake/mason.cmake new file mode 100644 index 0000000000..7954b53522 --- /dev/null +++ b/cmake/mason.cmake @@ -0,0 +1,117 @@ +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 new file mode 100644 index 0000000000..105c8822e9 --- /dev/null +++ b/cmake/mbgl.cmake @@ -0,0 +1,50 @@ +if (NOT DEFINED MBGL_PLATFORM) + if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(MBGL_PLATFORM "macos") + else() + set(MBGL_PLATFORM "linux") + endif() +endif() + +if(MBGL_PLATFORM STREQUAL "macos") + set(ENV{MASON_PLATFORM} "osx") +else() + set(ENV{MASON_PLATFORM} ${MBGL_PLATFORM}) +endif() + +set(MBGL_GENERATED ${CMAKE_BINARY_DIR}/generated/${CMAKE_CFG_INTDIR}) + +# Generate source groups so the files are properly sorted in IDEs like Xcode. +function(create_source_groups target) + get_target_property(sources ${target} SOURCES) + foreach(file ${sources}) + get_filename_component(file "${file}" ABSOLUTE) + string(REGEX REPLACE "^${CMAKE_SOURCE_DIR}/" "" group "${file}") + get_filename_component(group "${group}" DIRECTORY) + string(REPLACE "/" "\\" group "${group}") + source_group("${group}" FILES "${file}") + endforeach() +endfunction() + +function(_write_xcconfig_var target var) + get_property(result TARGET ${target} PROPERTY INTERFACE_${var} SET) + if (result) + get_property(result TARGET ${target} PROPERTY INTERFACE_${var}) + string(REPLACE ";" "\" \"" result "${result}") + string(REPLACE "-" "_" target "${target}") + file(APPEND "${CMAKE_BINARY_DIR}/config.xcconfig" "${target}_${var} = \"${result}\"\n") + endif() +endfunction() + +function(target_append_xcconfig target) + file(APPEND "${CMAKE_BINARY_DIR}/config.xcconfig" "\n// ${target}\n") + _write_xcconfig_var(${target} INCLUDE_DIRECTORIES) + _write_xcconfig_var(${target} COMPILE_DEFINITIONS) + _write_xcconfig_var(${target} COMPILE_OPTIONS) + _write_xcconfig_var(${target} LINK_LIBRARIES) +endfunction() + +# Start a new file when we're running CMake +file(WRITE "${CMAKE_BINARY_DIR}/config.xcconfig" "// Do not edit -- generated by CMake\n") + +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10) diff --git a/cmake/node.cmake b/cmake/node.cmake new file mode 100644 index 0000000000..9c8c6b074b --- /dev/null +++ b/cmake/node.cmake @@ -0,0 +1,52 @@ +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/node_modules/node-cmake/FindNodeJS.cmake) + message(FATAL_ERROR "Can't find node-cmake") +endif() + +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) + +add_nodejs_module(mbgl-node + platform/node/src/node_mapbox_gl_native.cpp +) + +target_sources(mbgl-node + PRIVATE platform/node/src/node_log.hpp + PRIVATE platform/node/src/node_log.cpp + PRIVATE platform/node/src/node_map.hpp + PRIVATE platform/node/src/node_map.cpp + PRIVATE platform/node/src/node_request.hpp + PRIVATE platform/node/src/node_request.cpp + PRIVATE platform/node/src/node_feature.hpp + PRIVATE platform/node/src/node_feature.cpp + PRIVATE platform/node/src/util/async_queue.hpp + + # We are compiling with the uv loop, but since this target already has the headers for libuv, + # we don't have to install it manually. + PRIVATE platform/default/async_task.cpp + PRIVATE platform/default/run_loop.cpp + PRIVATE platform/default/timer.cpp +) + +target_compile_options(mbgl-node + PRIVATE -fPIC + PRIVATE -fvisibility-inlines-hidden +) + +target_include_directories(mbgl-node + PRIVATE src # TODO: eliminate +) + +target_link_libraries(mbgl-node + PRIVATE mbgl-core +) + +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 +) + +mbgl_platform_node() diff --git a/cmake/npm.cmake b/cmake/npm.cmake new file mode 100644 index 0000000000..bb456666e2 --- /dev/null +++ b/cmake/npm.cmake @@ -0,0 +1,20 @@ +function(cache_executable_path name variable) + # Obtain paths to node and npm and cache it, so when e.g. Xcode reruns CMake, we still have the + # variables from the original invocation + if(NOT ${variable}) + set(_which_output) + execute_process( + COMMAND which ${name} + OUTPUT_VARIABLE _which_output + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_which_output STREQUAL "") + message(STATUS "Using cached ${name}: ${${variable}}") + else() + set(${variable} "${_which_output}" CACHE PATH "Path to ${name} executable") + message(STATUS "Using ${name}: ${${variable}}") + endif() + endif() +endfunction() + +cache_executable_path(node _node) +cache_executable_path(npm _npm) diff --git a/cmake/offline.cmake b/cmake/offline.cmake new file mode 100644 index 0000000000..c2959e7492 --- /dev/null +++ b/cmake/offline.cmake @@ -0,0 +1,21 @@ +add_executable(mbgl-offline + bin/offline.cpp +) + +target_compile_options(mbgl-offline + PRIVATE -fvisibility-inlines-hidden +) + +target_include_directories(mbgl-offline + PRIVATE include + PRIVATE src # TODO: eliminate +) + +target_link_libraries(mbgl-offline + PRIVATE mbgl-core +) + +target_add_mason_package(mbgl-offline PRIVATE boost) +target_add_mason_package(mbgl-offline PRIVATE boost_libprogram_options) + +mbgl_platform_offline() diff --git a/cmake/render.cmake b/cmake/render.cmake new file mode 100644 index 0000000000..3cf79cc0cc --- /dev/null +++ b/cmake/render.cmake @@ -0,0 +1,21 @@ +add_executable(mbgl-render + bin/render.cpp +) + +target_compile_options(mbgl-render + PRIVATE -fvisibility-inlines-hidden +) + +target_include_directories(mbgl-render + PRIVATE include + PRIVATE src # TODO: eliminate +) + +target_link_libraries(mbgl-render + PRIVATE mbgl-core +) + +target_add_mason_package(mbgl-render PRIVATE boost) +target_add_mason_package(mbgl-render PRIVATE boost_libprogram_options) + +mbgl_platform_render() diff --git a/cmake/shaders.cmake b/cmake/shaders.cmake new file mode 100644 index 0000000000..5a16fa682f --- /dev/null +++ b/cmake/shaders.cmake @@ -0,0 +1,29 @@ +function(add_shader VAR name) + set(shader_build_cmd ${CMAKE_SOURCE_DIR}/scripts/build-shaders.py) + set(shader_file_prefix ${CMAKE_SOURCE_DIR}/node_modules/mapbox-gl-shaders/src) + set(shader_source_prefix ${MBGL_GENERATED}/include/mbgl/shader) + + add_custom_command( + OUTPUT ${shader_source_prefix}/${name}.vertex.hpp ${shader_source_prefix}/${name}.fragment.hpp + COMMAND ${shader_build_cmd} ${shader_file_prefix}/${name}.vertex.glsl ${shader_source_prefix}/${name}.vertex.hpp + COMMAND ${shader_build_cmd} ${shader_file_prefix}/${name}.fragment.glsl ${shader_source_prefix}/${name}.fragment.hpp + DEPENDS ${shader_file_prefix}/${name}.vertex.glsl + DEPENDS ${shader_file_prefix}/${name}.fragment.glsl + VERBATIM + ) + set(${VAR} ${${VAR}} ${shader_source_prefix}/${name}.vertex.hpp ${shader_source_prefix}/${name}.fragment.hpp PARENT_SCOPE) +endfunction() + +add_shader(MBGL_SHADER_FILES circle) +add_shader(MBGL_SHADER_FILES collisionbox) +add_shader(MBGL_SHADER_FILES debug) +add_shader(MBGL_SHADER_FILES fill) +add_shader(MBGL_SHADER_FILES icon) +add_shader(MBGL_SHADER_FILES line) +add_shader(MBGL_SHADER_FILES linepattern) +add_shader(MBGL_SHADER_FILES linesdfpattern) +add_shader(MBGL_SHADER_FILES outline) +add_shader(MBGL_SHADER_FILES outlinepattern) +add_shader(MBGL_SHADER_FILES pattern) +add_shader(MBGL_SHADER_FILES raster) +add_shader(MBGL_SHADER_FILES sdf) diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake new file mode 100644 index 0000000000..d6c6215291 --- /dev/null +++ b/cmake/test-files.cmake @@ -0,0 +1,100 @@ +# Do not edit. Regenerate this with ./scripts/generate-test-files.sh + +set(MBGL_TEST_FILES + # algorithm + test/algorithm/covered_by_children.cpp + test/algorithm/generate_clip_ids.cpp + test/algorithm/mock.hpp + test/algorithm/update_renderables.cpp + + # api + test/api/annotations.cpp + test/api/api_misuse.cpp + test/api/custom_layer.cpp + test/api/render_missing.cpp + test/api/repeated_render.cpp + test/api/set_style.cpp + + # geometry + test/geometry/binpack.cpp + + # gl + test/gl/object.cpp + + # include/mbgl + test/include/mbgl/test.hpp + + # map + test/map/map.cpp + test/map/transform.cpp + + # math + test/math/clamp.cpp + test/math/minmax.cpp + + # sprite + test/sprite/sprite_atlas.cpp + test/sprite/sprite_image.cpp + test/sprite/sprite_parser.cpp + test/sprite/sprite_store.cpp + + # src + test/src/main.cpp + + # src/mbgl/test + test/src/mbgl/test/fixture_log_observer.cpp + test/src/mbgl/test/fixture_log_observer.hpp + test/src/mbgl/test/stub_file_source.cpp + test/src/mbgl/test/stub_file_source.hpp + test/src/mbgl/test/stub_style_observer.hpp + test/src/mbgl/test/test.cpp + test/src/mbgl/test/util.cpp + test/src/mbgl/test/util.hpp + + # storage + test/storage/asset_file_source.cpp + test/storage/default_file_source.cpp + test/storage/headers.cpp + test/storage/http_file_source.cpp + test/storage/offline.cpp + test/storage/offline_database.cpp + test/storage/offline_download.cpp + test/storage/online_file_source.cpp + test/storage/resource.cpp + + # style + test/style/filter.cpp + test/style/functions.cpp + test/style/glyph_store.cpp + test/style/source.cpp + test/style/style.cpp + test/style/style_layer.cpp + test/style/style_parser.cpp + test/style/tile_source.cpp + test/style/variant.cpp + + # text + test/text/quads.cpp + + # tile + test/tile/geometry_tile_data.cpp + test/tile/tile_id.cpp + + # util + test/util/async_task.cpp + test/util/geo.cpp + test/util/image.cpp + test/util/mapbox.cpp + test/util/memory.cpp + test/util/merge_lines.cpp + test/util/number_conversions.cpp + test/util/projection.cpp + test/util/run_loop.cpp + test/util/text_conversions.cpp + test/util/thread.cpp + test/util/thread_local.cpp + test/util/tile_cover.cpp + test/util/timer.cpp + test/util/token.cpp + test/util/work_queue.cpp +) diff --git a/cmake/test.cmake b/cmake/test.cmake new file mode 100644 index 0000000000..6cce8d248d --- /dev/null +++ b/cmake/test.cmake @@ -0,0 +1,35 @@ +add_executable(mbgl-test + ${MBGL_TEST_FILES} +) + +cache_executable_path(node _node) + +target_compile_options(mbgl-test + PRIVATE -fvisibility-inlines-hidden +) + +set_source_files_properties(test/src/mbgl/test/util.cpp PROPERTIES COMPILE_FLAGS -DNODE_EXECUTABLE="${_node}") + +target_include_directories(mbgl-test + PRIVATE include + PRIVATE src # TODO: eliminate + PRIVATE test/include + PRIVATE test/src + PRIVATE platform/default +) + +target_link_libraries(mbgl-test + PRIVATE mbgl-core +) + +target_add_mason_package(mbgl-test PRIVATE geometry) +target_add_mason_package(mbgl-test PRIVATE variant) +target_add_mason_package(mbgl-test PRIVATE unique_resource) +target_add_mason_package(mbgl-test PRIVATE rapidjson) +target_add_mason_package(mbgl-test PRIVATE gtest) +target_add_mason_package(mbgl-test PRIVATE pixelmatch) +target_add_mason_package(mbgl-test PRIVATE boost) +target_add_mason_package(mbgl-test PRIVATE geojson) +target_add_mason_package(mbgl-test PRIVATE geojsonvt) + +mbgl_platform_test() |