Skip to content

Commit

Permalink
Merge pull request #45 from AlpineMapsOrg/cmake_rework
Browse files Browse the repository at this point in the history
Cmake rework
  • Loading branch information
adam-ce authored Nov 13, 2023
2 parents 753b4fa + 6d98af5 commit 0ddc6c9
Show file tree
Hide file tree
Showing 37 changed files with 128 additions and 77 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ jobs:
release: false

- name: Install Qt
uses: jurplel/install-qt-action@v2
uses: jurplel/install-qt-action@v3
with:
version: '6.5.3'
version: '6.6.0'
host: ${{ matrix.host }}
target: 'desktop'
arch: ${{ matrix.arch }}
dir: '${{github.workspace}}/qt'
install-deps: 'true'
install-deps: 'true'
modules: 'qtcharts qtpositioning'

- name: Configure
env:
Expand All @@ -61,5 +62,5 @@ jobs:

- name: Test
run: |
'${{github.workspace}}'/build/sherpa/unittests_sherpa
'${{github.workspace}}'/build/unittests/unittests_nucleus
'${{github.workspace}}'/build/unittests_gl/unittests_gl_engine
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/CMakeLists.txt.user
/extern/*
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "sherpa"]
path = sherpa
url = [email protected]:AlpineMapsOrg/sherpa.git
39 changes: 20 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.24)
project(alpine-renderer LANGUAGES CXX)

option(ALP_UNITTESTS "include unit test targets in the buildsystem" ON)
option(ALP_ENABLE_ADDRESS_SANITIZER "compiles atb with address sanitizer enabled (only debug, works only on g++ and clang)" OFF)
option(ALP_ENABLE_THREAD_SANITIZER "compiles atb with thread sanitizer enabled (only debug, works only on g++ and clang)" OFF)
option(ALP_ENABLE_ASSERTS "enable asserts (do not define NDEBUG)" ON)
option(ALP_ENABLE_TRACK_OBJECT_LIFECYCLE "enables debug cmd printout of constructors & deconstructors if implemented" OFF)
option(ALP_USE_NOISY_CMAKE_DOWNLOAD "we download quite a lot when running cmake the first time. if this option is off, it may look like cmake stalled." ON)

set(ALP_EXTERN_DIR "extern" CACHE STRING "name of the directory to store external libraries, fonts etc..")

if(ALP_ENABLE_TRACK_OBJECT_LIFECYCLE)
add_definitions(-DALP_ENABLE_TRACK_OBJECT_LIFECYCLE)
Expand Down Expand Up @@ -33,6 +36,12 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

if (ALP_USE_NOISY_CMAKE_DOWNLOAD)
set(FETCHCONTENT_QUIET FALSE)
else()
set(FETCHCONTENT_QUIET TRUE)
endif()

if (ALP_ENABLE_ADDRESS_SANITIZER)
message(NOTICE "building with address sanitizer enabled")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
Expand All @@ -58,42 +67,34 @@ if (ALP_UNITTESTS)
find_package(Qt6 REQUIRED COMPONENTS Test)
endif()


include(FetchContent)
FetchContent_Declare(
alpine_height_data
URL https://gataki.cg.tuwien.ac.at/tiles/alpine_png2/height_data.atb
DOWNLOAD_NO_EXTRACT true
URL_HASH MD5=f5458b48ade5d6aaf980fcfc5b6be29a
FetchContent_Declare(alpine_height_data
DOWNLOAD_NO_EXTRACT true
URL https://gataki.cg.tuwien.ac.at/tiles/alpine_png2/height_data.atb
URL_HASH MD5=f5458b48ade5d6aaf980fcfc5b6be29a
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/alpine_height_data
)
FetchContent_Declare(
alpineapp_fonts
FetchContent_Declare(alpineapp_fonts
DOWNLOAD_EXTRACT_TIMESTAMP true
URL https://github.com/adobe-fonts/source-sans/archive/refs/heads/release.zip
URL_HASH MD5=681612d5ad33731c512ce056d2ca2297
URL https://github.com/adobe-fonts/source-sans/archive/refs/heads/release.zip
URL_HASH MD5=681612d5ad33731c512ce056d2ca2297
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/alpineapp_fonts
)
FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git)
FetchContent_Declare(zppbits GIT_REPOSITORY https://github.com/eyalz800/zpp_bits.git GIT_TAG main)

FetchContent_MakeAvailable(alpine_height_data alpineapp_fonts fmt zppbits)
FetchContent_MakeAvailable(alpine_height_data alpineapp_fonts)

if (ANDROID)
FetchContent_Declare(
android_openssl
DOWNLOAD_EXTRACT_TIMESTAMP true
URL https://github.com/AlpineMapsOrg/android_openssl/archive/refs/heads/issams_fixes.zip
# URL_HASH MD5=88dd38c0fc94a195ae3f29412cfdcf2b
)
FetchContent_MakeAvailable(android_openssl)
include(${android_openssl_SOURCE_DIR}/android_openssl.cmake)
endif()

add_library(zppbits INTERFACE)
target_include_directories(zppbits INTERFACE ${zppbits_SOURCE_DIR})


########################################### projects #################################################
add_subdirectory(sherpa) # pulls in Catch2 and glm
add_subdirectory(nucleus)
add_subdirectory(gl_engine)
add_subdirectory(plain_renderer)
Expand Down
2 changes: 1 addition & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.24)
project(alpine-renderer-app LANGUAGES CXX)

qt_add_executable(alpineapp
Expand Down
2 changes: 1 addition & 1 deletion gl_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.24)
project(alpine-renderer-gl_engine LANGUAGES CXX)

# If true the shaders will be loaded from the given ALP_SHADER_NETWORK_URL and can be reloaded
Expand Down
2 changes: 1 addition & 1 deletion gl_engine/TileSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <QOpenGLTexture>
#include <QOpenGLVertexArrayObject>

#include "sherpa/tile.h"
#include "radix/tile.h"

// we want to be flexible and have the ability to draw several tiles at once.
// GpuTileSets can have an arbitrary number of slots, each slot is an index in the corresponding
Expand Down
50 changes: 45 additions & 5 deletions nucleus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.24)
project(alpine-renderer-nucleus LANGUAGES CXX)

option(ALP_AUTOUPDATE_RADIX "Keeps whack up-to-date with origin/main, but prevents local edits. Change to OFF if you want to edit radix" TRUE)

include(FetchContent)

if(ALP_AUTOUPDATE_RADIX)
FetchContent_Declare(radix
GIT_REPOSITORY https://github.com/AlpineMapsOrg/radix.git
GIT_TAG origin/main
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/radix
SOURCE_SUBDIR src
)
FetchContent_MakeAvailable(radix)
else()
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/radix)
FetchContent_Declare(radix
GIT_REPOSITORY [email protected]:AlpineMapsOrg/radix.git
GIT_TAG main
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/radix
)
FetchContent_MakeAvailable(radix)
else()
add_subdirectory(${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/radix ${CMAKE_BINARY_DIR}/_deps/radix-build)
endif()
endif()

message("###################ALP_EXTERN_DIR = ${ALP_EXTERN_DIR}")
set(EXPECTED_BUILD_TESTS OFF CACHE BOOL "Enable tl::expected tests")
FetchContent_Declare(tl_expected
URL https://github.com/TartanLlama/expected/archive/refs/tags/v1.1.0.zip
URL_HASH MD5=cbc9465bb0e9328c821fc3cf89ec7711
DOWNLOAD_EXTRACT_TIMESTAMP true
URL https://github.com/TartanLlama/expected/archive/refs/tags/v1.1.0.zip
URL_HASH MD5=cbc9465bb0e9328c821fc3cf89ec7711
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/tl_expected
)
FetchContent_MakeAvailable(tl_expected)
FetchContent_Declare(fmt
DOWNLOAD_EXTRACT_TIMESTAMP true
URL https://github.com/fmtlib/fmt/releases/download/10.1.0/fmt-10.1.0.zip
URL_HASH MD5=56eaffa1e2a2afe29e9cb2348a446e63
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/fmt
)
FetchContent_Declare(zppbits
DOWNLOAD_EXTRACT_TIMESTAMP true
URL https://github.com/eyalz800/zpp_bits/archive/refs/heads/main.zip
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${ALP_EXTERN_DIR}/zppbits
)
FetchContent_MakeAvailable(tl_expected fmt zppbits)

add_library(zppbits INTERFACE)
target_include_directories(zppbits INTERFACE ${zppbits_SOURCE_DIR})

qt_add_library(nucleus STATIC
AbstractRenderWindow.h AbstractRenderWindow.cpp
Expand Down Expand Up @@ -59,7 +99,7 @@ qt_add_library(nucleus STATIC
)

target_include_directories(nucleus PRIVATE . PUBLIC ${CMAKE_SOURCE_DIR})
target_link_libraries(nucleus PUBLIC sherpa Qt::Core Qt::Gui Qt::Network Qt::Svg fmt::fmt zppbits expected)
target_link_libraries(nucleus PUBLIC radix Qt::Core Qt::Gui Qt::Network Qt::Svg fmt::fmt zppbits expected)


if (EMSCRIPTEN)
Expand Down
5 changes: 1 addition & 4 deletions nucleus/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "nucleus/tile_scheduler/SlotLimiter.h"
#include "nucleus/tile_scheduler/TileLoadService.h"
#include "nucleus/tile_scheduler/utils.h"
#include "sherpa/TileHeights.h"
#include "radix/TileHeights.h"

using namespace nucleus::tile_scheduler;

Expand Down Expand Up @@ -128,9 +128,6 @@ Controller::Controller(AbstractRenderWindow* render_window)
connect(m_tile_scheduler.get(), &Scheduler::gpu_quads_updated, m_render_window, &AbstractRenderWindow::update_gpu_quads);
connect(m_tile_scheduler.get(), &Scheduler::gpu_quads_updated, m_render_window, &AbstractRenderWindow::update_requested);

/// @todo: finish tile/cache_querier: find rgb to float, probably move to sherpa; finsih test tile generator for a specified height; finish tests + impl
/// @todo: use cache_querier for target location altitude, and use for look at
/// @todo: make fly to animation, modelled on rotation.
m_camera_controller->update();
}

Expand Down
2 changes: 1 addition & 1 deletion nucleus/Tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <glm/glm.hpp>

#include "Raster.h"
#include "sherpa/tile.h"
#include "radix/tile.h"

namespace nucleus {
struct Tile {
Expand Down
2 changes: 1 addition & 1 deletion nucleus/camera/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <QDebug>
#include <glm/gtx/transform.hpp>

#include "sherpa/geometry.h"
#include "radix/geometry.h"

// camera space in opengl / webgl:
// origin:
Expand Down
11 changes: 5 additions & 6 deletions nucleus/camera/Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
#include <vector>

#include <glm/glm.hpp>
#include <sherpa/geometry.h>
#include <radix/geometry.h>

namespace nucleus::camera {

namespace nucleus::camera {

struct Frustum {
std::array<geometry::Plane<double>, 6> clipping_planes; // the order of clipping panes is front, back, top, down, left, and right
std::array<glm::dvec3, 8> corners; // the order of corners is ccw, starting from top left, front plane -> back plane
struct Frustum {
std::array<geometry::Plane<double>, 6> clipping_planes; // the order of clipping panes is front, back, top, down, left, and right
std::array<glm::dvec3, 8> corners; // the order of corners is ccw, starting from top left, front plane -> back plane
};

class Definition {
Expand Down
2 changes: 1 addition & 1 deletion nucleus/srs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <glm/glm.hpp>

#include "sherpa/tile.h"
#include "radix/tile.h"

namespace nucleus::srs {
// the srs used for the alpine renderer is EPSG: 3857 (also called web mercator, spherical mercator).
Expand Down
2 changes: 1 addition & 1 deletion nucleus/tile_scheduler/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <tl/expected.hpp>
#include <zpp_bits.h>

#include "sherpa/tile.h"
#include "radix/tile.h"
#include "tile_types.h"
#include "utils.h"

Expand Down
6 changes: 3 additions & 3 deletions nucleus/tile_scheduler/DrawListGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include "DrawListGenerator.h"

#include "sherpa/iterator.h"
#include "sherpa/quad_tree.h"
#include "radix/iterator.h"
#include "radix/quad_tree.h"

using nucleus::tile_scheduler::DrawListGenerator;

Expand Down Expand Up @@ -74,6 +74,6 @@ DrawListGenerator::TileSet DrawListGenerator::generate_for(const nucleus::camera
return tile_scheduler::utils::camera_frustum_contains_tile(camera_frustum, m_aabb_decorator->aabb(tile));
};

std::copy_if(all_leaves.begin(), all_leaves.end(), sherpa::unordered_inserter(visible_leaves), is_visible);
std::copy_if(all_leaves.begin(), all_leaves.end(), radix::unordered_inserter(visible_leaves), is_visible);
return visible_leaves;
}
2 changes: 1 addition & 1 deletion nucleus/tile_scheduler/QuadAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <QObject>

#include "sherpa/tile.h"
#include "radix/tile.h"
#include "tile_types.h"

namespace nucleus::tile_scheduler {
Expand Down
2 changes: 1 addition & 1 deletion nucleus/tile_scheduler/RateLimiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <QObject>

#include <sherpa/tile.h>
#include <radix/tile.h>

class QTimer;

Expand Down
2 changes: 1 addition & 1 deletion nucleus/tile_scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "nucleus/tile_scheduler/utils.h"
#include "nucleus/utils/tile_conversion.h"
#include "sherpa/quad_tree.h"
#include "radix/quad_tree.h"

using namespace nucleus::tile_scheduler;

Expand Down
2 changes: 1 addition & 1 deletion nucleus/tile_scheduler/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <QObject>

#include "nucleus/camera/Definition.h"
#include "sherpa/tile.h"
#include "radix/tile.h"

#include "Cache.h"
#include "tile_types.h"
Expand Down
2 changes: 1 addition & 1 deletion nucleus/tile_scheduler/SlotLimiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <QObject>

#include <sherpa/tile.h>
#include <radix/tile.h>

#include "tile_types.h"

Expand Down
4 changes: 2 additions & 2 deletions nucleus/tile_scheduler/cache_quieries.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "nucleus/srs.h"
#include "nucleus/tile_scheduler/Cache.h"
#include "sherpa/height_encoding.h"
#include "radix/height_encoding.h"

#include <QImage>

Expand Down Expand Up @@ -49,7 +49,7 @@ inline float query_altitude(MemoryCache* cache, const glm::dvec2& lat_long)
const auto x = int(uv.x * height_tile.width());
const auto y = int(uv.y * height_tile.height());
const auto rgb = QColor(height_tile.pixel(x, y));
return sherpa::height_encoding::to_float({rgb.red(), rgb.green(), rgb.blue()});
return radix::height_encoding::to_float({rgb.red(), rgb.green(), rgb.blue()});
}
}

Expand Down
2 changes: 1 addition & 1 deletion nucleus/tile_scheduler/tile_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include "nucleus/tile_scheduler/utils.h"
#include "sherpa/tile.h"
#include "radix/tile.h"

#include <QByteArray>

Expand Down
4 changes: 2 additions & 2 deletions nucleus/tile_scheduler/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include "constants.h"
#include "nucleus/camera/Definition.h"
#include "nucleus/srs.h"
#include "sherpa/TileHeights.h"
#include "sherpa/geometry.h"
#include "radix/TileHeights.h"
#include "radix/geometry.h"

namespace nucleus::tile_scheduler {

Expand Down
2 changes: 1 addition & 1 deletion plain_renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.24)
project(alpine-renderer-plain_renderer LANGUAGES CXX)

qt_add_executable(plain_renderer
Expand Down
1 change: 0 additions & 1 deletion sherpa
Submodule sherpa deleted from eaf6c6
Loading

0 comments on commit 0ddc6c9

Please sign in to comment.