Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2dbfaa1
Initial WIP for building with vcpkg
timoore Nov 13, 2024
0f73ad5
Add build types to CMake presets
timoore Nov 18, 2024
e1d36c1
Deal with cesium-native change of ImageCesium to ImageAsset
timoore Nov 19, 2024
fe749c8
Build using vcpkg manifest mode and dependencies
timoore Nov 19, 2024
9204174
Changes for a seamless vcpkg build on Windows
timoore Nov 21, 2024
63ddfb0
Arrange presets for a good Visual Studio experience
timoore Nov 21, 2024
f9c8e8e
Remove ktx vcpkg overlay
timoore Nov 24, 2024
4a17c8d
Various vcpkg improvements
Dec 5, 2024
6a1c62e
Start of vcpkg notes
Dec 5, 2024
9a1592c
Changes for compiling with C++ 20
timoore Dec 5, 2024
f343414
Merge remote-tracking branch 'origin/vcpkg-build' into vcpkg-build
Dec 5, 2024
493ef02
Merge branch 'master' into vcpkg-build
Dec 6, 2024
d8febde
Remove use of FetchContent
Dec 6, 2024
93634e2
Cleanup of generated header files usage and associated CMake commands
Dec 7, 2024
89dad3b
Remove use of VSG macros in CMake files
Dec 8, 2024
1710eaf
Add a custom target for run-clang-tidy
Dec 8, 2024
9f52fc9
Use qualifiers on auto keyword
Dec 8, 2024
ce253f5
Fixes from clang-tidy
Dec 9, 2024
bed053d
Add support for building with a local cesium-native source directory
timoore Dec 16, 2024
8aab861
Fix calculation of home viewpoint and MapManipulator setting
timoore Dec 16, 2024
a4e7834
Compute bounding sphere from glTF and handle instances correctly
timoore Dec 16, 2024
75b6c55
Merge branch 'instance-viewer-fixes' into vcpkg-build
timoore Dec 16, 2024
f104a3c
Move to VSG 1.1.8 from vcpkg
timoore Dec 17, 2024
2b9a019
Add each vertex of instance bounding box to accumulated bound
timoore Dec 22, 2024
fc0847d
Remove CesiumTextureSource and related functions
timoore Dec 22, 2024
6a3b513
Change command line argument processing to be more useful
timoore Dec 23, 2024
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
17 changes: 17 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
Checks: >
google-*,
performance-*,
portability-*,
readability-*,
modernize-*,
misc-include-cleaner,
-google-build-using-namespace,
-readability-identifier-length,
-readability-math-missing-parentheses,
-readability-uppercase-literal-suffix,
-google-readability-namespace-comments,
-readability-named-parameter,
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-modernize-use-trailing-return-type
114 changes: 28 additions & 86 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.22)

include(FetchContent)

project(vsgCs
VERSION 0.2.0
VERSION 0.9.0
DESCRIPTION "VSG library for rendering 3D Tiles and Cesium ion assets"
LANGUAGES CXX C
)
Expand All @@ -15,8 +13,8 @@ SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${vsgCs_SOURCE_DIR}/CMakeModules")

include("vsgCsMacros")

# set the use of C++17 globally as all examples require it
set(CMAKE_CXX_STANDARD 17)
# set the use of C++20 as Cesium Native requires it
set(CMAKE_CXX_STANDARD 20)

if (MSVC)
# template madness
Expand All @@ -28,113 +26,56 @@ endif()
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)

option(RUN_CLANG_TIDY "run the clang-tidy checker" OFF)
set(VSGCS_CESIUM_NATIVE_DIRECTORY "" CACHE PATH "directory for Cesium Native source if not installed")

# Find Vulkan and the VSG
if (VULKAN_SDK)
set(ENV{VULKAN_SDK} ${VULKAN_SDK})
endif()

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
SET(USE_FETCHCONTENT_DEFAULT ON)
else()
SET(USE_FETCHCONTENT_DEFAULT OFF)
endif()

option(VSGCS_USE_FETCHCONTENT "Use FetchContent to build dependencies" ${USE_FETCHCONTENT_DEFAULT})

set(VSG_MIN_VERSION 1.1.0)

if(VSGCS_USE_FETCHCONTENT)
FetchContent_Declare(vsg
GIT_REPOSITORY https://github.com/vsg-dev/VulkanSceneGraph.git
GIT_TAG master
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${VSG_MIN_VERSION}
)

FetchContent_MakeAvailable(vsg)
else()
find_package(vsg ${VSG_MIN_VERSION})
endif()

# find_package(vsg) includes vsgMacros
if (vsg_SOURCE_DIR)
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${vsg_SOURCE_DIR}/cmake")
include("vsgMacros")
endif()
find_package(vsg ${VSG_MIN_VERSION} REQUIRED)

find_package(vsgXchange)

set(VSGIMGUI_MIN_VERSION 0.1.0)

if(VSGCS_USE_FETCHCONTENT)
FetchContent_Declare(vsgImGui
GIT_REPOSITORY https://github.com/vsg-dev/vsgImGui.git
GIT_TAG v0.1.0
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${VSGIMGUI_MIN_VERSION}
)
find_package(vsgImGui ${VSGIMGUI_MIN_VERSION} REQUIRED)

FetchContent_MakeAvailable(vsgImGui)
if(VSGCS_CESIUM_NATIVE_DIRECTORY)
add_subdirectory(${VSGCS_CESIUM_NATIVE_DIRECTORY} cesium-native)
else()
find_package(vsgImGui ${VSGIMGUI_MIN_VERSION})
endif()

if(VSGCS_USE_FETCHCONTENT)
# Wrangle Cesium's dependencies into shape i.e., install them!
option(CESIUM_SPDLOG_HEADER_ONLY "Whether to use the header-only version of spdlog." OFF)
option(GSL_INSTALL "Generate and install GSL target" ON)
# XXX Not ready for cesium-native as a package yet...
FetchContent_Declare(cesium-native
GIT_REPOSITORY https://github.com/timoore/cesium-native.git
GIT_TAG 791a85712cbbb22ef7cd8f13498997d45b108546 # cmake-fixes
GIT_PROGRESS TRUE
)

message("Fetching cesium-native. This could take a while...")
FetchContent_MakeAvailable(cesium-native)
else()
# XXX This may not go well.
find_package(cesium-native)
find_package(cesium-native REQUIRED)
endif()

find_package(PROJ REQUIRED)

if (RUN_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=google-*,performance-*,portability-*,readability-*,modernize-*,-google-build-using-namespace,-readability-identifier-length,-readability-uppercase-literal-suffix,-google-readability-namespace-comments,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-magic-numbers,-modernize-use-trailing-return-type)
find_package(imgui REQUIRED)
find_package(tinyxml2 REQUIRED)
find_package(spdlog REQUIRED)

if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

find_program(CLANG_TIDY_EXECUTABLE clang-tidy)
find_program(RUN_CLANG_TIDY_EXECUTABLE run-clang-tidy)

if(CLANG_TIDY_EXECUTABLE AND RUN_CLANG_TIDY_EXECUTABLE)
add_custom_target(run-clang-tidy
COMMAND ${RUN_CLANG_TIDY_EXECUTABLE}
-clang-tidy-binary ${CLANG_TIDY_EXECUTABLE}
-p ${CMAKE_BINARY_DIR}
)
endif()
endif()

vsgCs_setup_build_vars()
# This does include(GNUInstallDirs), which sets up all the correct install directories.
vsg_setup_dir_vars()

set(GENERATED_HEADERS_DIR "${PROJECT_BINARY_DIR}/include")
include(GNUInstallDirs)

set(VSGCS_DATA_DIR "${CMAKE_INSTALL_DATADIR}/vsgCs")
set(VSGCS_FULL_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/vsgCs")

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/vsgCs/Config.h.in"
"${GENERATED_HEADERS_DIR}/vsgCs/Config.h")

vsg_add_target_clobber()
vsg_add_target_docs(
FILES
${CMAKE_SOURCE_DIR}/include
)
vsg_add_target_uninstall()

vsg_add_option_maintainer(
PREFIX ${PROJECT_NAME}
RCLEVEL ${VSGCS_RELEASE_CANDIDATE}
)

# Make the headers visible to everything. This is not OSG / VSG style,
# but we prefer that include files live next to their source files.
include_directories(${vsgCs_SOURCE_DIR}/src ${GENERATED_HEADERS_DIR})

if(WIN32)
set(CMAKE_INSTALL_UCRT_LIBRARIES YES)

Expand All @@ -146,7 +87,8 @@ endif()
add_subdirectory(src)
add_subdirectory(data)

vsg_add_feature_summary()
include(FeatureSummary)
feature_summary(WHAT ALL)

option(BUILD_TRACY "build with tracy profiling and server" OFF)

Expand Down
4 changes: 4 additions & 0 deletions CMakeModules/Fedora41Toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Work around a bug in patchelf, which doesn't work with the ELF file arrangement in Fedora 41
set(VCPKG_LINKER_FLAGS "-Wl,-z,noseparate-code")

include("$ENV{VCPKG_ROOT}/scripts/toolchains/linux.cmake")
15 changes: 0 additions & 15 deletions CMakeModules/vsgCsMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,18 @@
# and will set them up differently

macro(vsgCs_setup_build_vars)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
set(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
set(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")

# Change the default build type to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

if(CMAKE_COMPILER_IS_GNUCXX)
set(VSGCS_WARNING_FLAGS -Wall -Wextra -Wpedantic CACHE STRING "Compile flags to use.")
set(CMAKE_COMPILE_WARNING_AS_ERROR YES CACHE BOOL "Treat warnings as errors")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(VSGCS_WARNING_FLAGS -Wall -Wextra -Wparenthese -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wshadow -Wunused CACHE STRING "Compile flags to use.")
set(CMAKE_COMPILE_WARNING_AS_ERROR YES CACHE BOOL "Treat warnings as errors")
else()
set(VSGCS_WARNING_FLAGS CACHE STRING "Compile flags to use.")
set(CMAKE_COMPILE_WARNING_AS_ERROR NO CACHE BOOL "Treat warnings as errors")
endif()

add_compile_options(${VSGCS_WARNING_FLAGS})

# set upper case <PROJECT>_VERSION_... variables
string(TOUPPER ${PROJECT_NAME} UPPER_PROJECT_NAME)
set(${UPPER_PROJECT_NAME}_VERSION ${PROJECT_VERSION})
set(${UPPER_PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(${UPPER_PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(${UPPER_PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH})
endmacro()
66 changes: 66 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"version": 3,
"configurePresets": [
{
"name": "vcpkg-debug",
"binaryDir": "${sourceDir}/build-debug",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "vcpkg",
"inherits": "vcpkg-debug",
"binaryDir": "${sourceDir}/build-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "Windows-Devel",
"inherits": "vcpkg-debug",
"generator": "Visual Studio 17 2022",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md",
"VCPKG_TRIPLET": "x64-windows-static-md"
}
},
{
"name": "Windows-Devel-Release",
"inherits": "Windows-Devel",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "Strict",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": "YES"
}
},
{
"name": "local-cesium-native",
"cacheVariables": {
"VCPKG_MANIFEST_NO_DEFAULT_FEATURES": true,
"VCPKG_MANIFEST_FEATURES": "cesium-native-local"
}
}
],
"buildPresets": [
{
"name": "Windows-Debug",
"displayName": "Windows Debug",
"configurePreset": "Windows-Devel",
"configuration": "Debug"
},
{
"name": "Windows-Release",
"displayName": "Windows Release",
"configurePreset": "Windows-Devel-Release",
"configuration": "Release"
}
]
}
12 changes: 2 additions & 10 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
# Build and Installation

## Prerequisites
vsgCs uses the `FetchContent` package of `cmake` to download most
dependencies. This is convenient for casual users, but might be too
inflexible if you want to use your own version of those
dependencies. You can force `FetchContent` to use the source code in a
certain location by setting the corresponding
`FETCHCONTENT_SOURCE_DIR_` variable e.g., to use your own version of
Cesium Native sources, set `FETCHCONTENT_SOURCE_DIR_CESIUM`.

These dependencies are not downloaded via `FetchContent` and should be
installed manually:

These dependencies and should be installed manually:

- `libcurl` This is best installed via a package manager.
- the [Vulkan SDK](https://vulkan.lunarg.com/sdk/home) from LunarG. Follow installation instructions
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ application (worldviewer) on Linux:
The `cmake` part may take a long time to download the Cesium Native library and its dependencies. If
you encounter a git error, see [the install instructions](INSTALL.md) for possible workarounds.

## vcpkg

Install `xorg-macros`, `xproto`, xcb-proto`, `libXdmcp-devel`, `libXau-devel`
---


Expand Down
21 changes: 21 additions & 0 deletions extern/vcpkg-overlays/asyncplusplus/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Amanieu/asyncplusplus
REF 4159da79e20ad6d0eb1f13baa0f10e989edd9fba
SHA512 a7b099ce24184aa56e843d4858228196f8220374585a375a9c0d944832bd68c8aabd6b2efde5aacbb9c73f9dd8e942e97262be04550205b3fbea44d8b972d78e
HEAD_REF master
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(CONFIG_PATH cmake PACKAGE_NAME async++)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
18 changes: 18 additions & 0 deletions extern/vcpkg-overlays/asyncplusplus/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "asyncplusplus",
"version": "1.1",
"port-version": 2,
"description": "Async++ is a lightweight concurrency framework for C++11",
"license": "MIT",
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
29 changes: 29 additions & 0 deletions extern/vcpkg-overlays/cesium-native/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
dependencies-only CESIUM_NATIVE_DEPS_ONLY
)

if(CESIUM_NATIVE_DEPS_ONLY)
message(STATUS "skipping installation of cesium-native")
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
return()
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO timoore/cesium-native
REF 6c1b1edd4ee388f6372dcfe1c33de6839696e5b4
SHA512 1dd74feefe20dc0363c42f5b1a03d271de5d37cc86078ecc1090fa1c3517284c04ee0ae9f6c622f2b6391a48bccbf59a9b0f342e4e21f33a78c1cb85845b8b98
HEAD_REF vcpkg-pkg
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DCESIUM_USE_EZVCPKG=OFF
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/cesium-native PACKAGE_NAME cesium-native)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

Loading