Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Conan 2 #64

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '21.x'
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install Ninja
run: |
sudo apt update && sudo apt install ninja-build

- name: Install npm dependencies
run: npm -g install --force --include=dev
- name: Install Conan
run: |
pip install conan
conan profile detect
conan --version

- name: Install mapget (git+conan)
run: |
cd $(mktemp -d)
git clone "https://github.com/ndsev/mapget.git" -b use-conan
cd mapget
conan create . -s compiler.cppstd=20 -s build_type=Release -b missing \
-pr:b default -pr:h "$GITHUB_WORKSPACE/conan-profiles/emscripten.profile" \
-o with_httplib=False \
-o with_service=False \
-o with_wheel=False

- name: Build demo with Emscripten
run: |
Expand Down
42 changes: 8 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.24)
project(erdblick)

include(FetchContent)
project(erdblick CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Treat warnings as errors, with some exceptions for Cesium.
set (ERDBLICK_CXX_FLAGS
Expand All @@ -15,40 +15,14 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()

# External dependencies.
find_package(mapget CONFIG REQUIRED COMPONENTS model)
find_package(glm CONFIG REQUIRED)
find_package(yaml-cpp CONFIG REQUIRED)

message("Building for ${CMAKE_SYSTEM_NAME}.")

FetchContent_Declare(glm
GIT_REPOSITORY "https://github.com/g-truc/glm.git"
GIT_TAG "0.9.9.8"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(glm)

FetchContent_Declare(mapget
GIT_REPOSITORY "https://github.com/Klebert-Engineering/mapget"
GIT_TAG "main"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(mapget)

set(CESIUM_TESTS_ENABLED OFF)
set(CESIUM_GLM_STRICT_ENABLED OFF)
set(CESIUM_TRACING_ENABLED OFF)
set(DRACO_JS_GLUE OFF CACHE BOOL "Disable JS glue for Draco" FORCE)
FetchContent_Declare(
cesiumnative
GIT_REPOSITORY https://github.com/Klebert-Engineering/cesium-native.git
GIT_TAG "spdlog-upgrade"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(cesiumnative)

FetchContent_Declare(yaml-cpp
GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
GIT_TAG "yaml-cpp-0.7.0"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(yaml-cpp)

# Erdblick Core Library
# Cesium
include(cmake/cesium.cmake)

message("Building for ${CMAKE_SYSTEM_NAME}.")
add_subdirectory(libs/core)

if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
Expand Down
11 changes: 6 additions & 5 deletions build-ui.bash
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/usr/bin/env bash
set -eu

SOURCE_LOC=$1
if [ -z $SOURCE_LOC ]; then
SOURCE_LOC="$1"

if [ -z "$SOURCE_LOC" ]; then
echo "No source location supplied."
exit 1
fi

echo "Using source dir @ $SOURCE_LOC."
cd "$SOURCE_LOC" || exit 1
cd "$SOURCE_LOC"

echo "Collecting npm modules."
npm install

echo "Building Angular distribution files."
if [[ -z "$NG_DEVELOP" ]]; then
if [[ -z "${NG_DEVELOP:-}" ]]; then
npm run build -- -c production
else
npm run build
fi
exit 0
21 changes: 12 additions & 9 deletions ci/00_linux_setup.bash
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/usr/bin/env bash
set -eu

ci_dir="$(realpath ${BASH_SOURCE[0]} | xargs -I{} dirname {})"
echo "Setting up Emscripten in: $ci_dir"
cd "$ci_dir"
BUILD_DIR="./build"
PROFILE_DIR="./conan-profiles"

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR/deps"
mkdir -p "$BUILD_DIR/assets"

conan install . \
-pr:b "$PROFILE_DIR/build.profile" \
-pr:h "$PROFILE_DIR/emscripten.profile" \
-s build_type=Release -s compiler.cppstd=20 -b missing -b editable \
-of "$BUILD_DIR"
17 changes: 4 additions & 13 deletions ci/10_linux_build.bash
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
#!/usr/bin/env bash

set -e
source "./build/conanbuild.sh"

ci_dir="$(realpath ${BASH_SOURCE[0]} | xargs -I{} dirname {})"
source "$ci_dir/emsdk/emsdk_env.sh"
cd "$ci_dir/.."

export EMSCRIPTEN="$ci_dir/emsdk/upstream/emscripten"

rm -rf build && mkdir build
cd build
mkdir deps
mkdir assets
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..
cmake --build . -- -j
set -eu
cmake --preset conan-release
cmake --build --preset conan-release -- -j
12 changes: 2 additions & 10 deletions ci/20_linux_rebuild.bash
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#!/usr/bin/env bash

set -e

ci_dir="$(realpath ${BASH_SOURCE[0]} | xargs -I{} dirname {})"
source "$ci_dir/emsdk/emsdk_env.sh"

export EMSCRIPTEN="$ci_dir/emsdk/upstream/emscripten"

cd "$ci_dir/../build"
cmake --build . -- -j
set -eu
cmake --build --preset conan-release -- -j
48 changes: 48 additions & 0 deletions cmake/cesium.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
include(FetchContent)
include(ExternalProject)

# Use fetch content for cloning the repository durring
# configure phase. We do not call `FetchContent_MakeAvailable`,
# but instead use `ExternalProject_Add` to compile Cesium in
# isolation.
FetchContent_Declare(cesiumnative_src
GIT_REPOSITORY "https://github.com/Klebert-Engineering/cesium-native.git"
GIT_TAG "main"
GIT_SUBMODULES_RECURSE YES
GIT_PROGRESS YES)

FetchContent_GetProperties(cesiumnative_src)
if (NOT cesiumnative_src_POPULATED)
FetchContent_Populate(cesiumnative_src)
endif()

ExternalProject_Add(cesiumnative
SOURCE_DIR ${cesiumnative_src_SOURCE_DIR}
CMAKE_ARGS
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCESIUM_TESTS_ENABLED=OFF
-DCESIUM_GLM_STRICT_ENABLED=OFF
-DCESIUM_TRACING_ENABLED=OFF
-DDRACO_JS_GLUE=OFF
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
INSTALL_COMMAND ""
STEP_TARGETS build)

function (add_cesium_lib TARGET)
ExternalProject_Get_Property(cesiumnative
SOURCE_DIR BINARY_DIR)
message(STATUS "Adding Cesium library: ${TARGET} (${BINARY_DIR}/${TARGET}/${CMAKE_STATIC_LIBRARY_PREFIX}${TARGET}${CMAKE_STATIC_LIBRARY_SUFFIX})")

add_library(${TARGET} STATIC IMPORTED)
set_target_properties(${TARGET} PROPERTIES
IMPORTED_LOCATION "${BINARY_DIR}/${TARGET}/${CMAKE_STATIC_LIBRARY_PREFIX}${TARGET}${CMAKE_STATIC_LIBRARY_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/${TARGET}/include")
add_dependencies(${TARGET} cesiumnative-build)
endfunction()

add_cesium_lib(CesiumUtility)
add_cesium_lib(Cesium3DTilesWriter)
add_cesium_lib(CesiumGeospatial)
add_cesium_lib(CesiumGltf)
add_cesium_lib(CesiumGltfWriter)
7 changes: 7 additions & 0 deletions conan-profiles/build.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include(default)

[settings]
compiler.cppstd=20

[replace_requires]
nodejs/*: nodejs/18.15.0
12 changes: 12 additions & 0 deletions conan-profiles/emscripten.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=15
compiler.libcxx=libc++
compiler.cppstd=20

[tool_requires]
# See https://github.com/emscripten-core/emsdk/blob/3.1.47/emscripten-releases-tags.json
# for latest version with linux-arm64 support
emsdk/3.1.50
13 changes: 13 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[requires]
mapget/dev
glm/cci.20230113
yaml-cpp/0.8.0

[options]
mapget/*:with_service=False
mapget/*:with_httplib=False
mapget/*:with_wheel=False

[generators]
CMakeDeps
CMakeToolchain
7 changes: 4 additions & 3 deletions libs/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ target_link_libraries(erdblick-core
CesiumGeospatial
CesiumGltf
CesiumGltfWriter
glm
mapget-model
yaml-cpp)
CesiumUtility
glm::glm
mapget::model
yaml-cpp::yaml-cpp)
Loading