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

Changed to pull in glslang as an external dependency #1216

Merged
merged 6 commits into from
Jun 11, 2024
Merged
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
30 changes: 11 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7)

project(vsg
VERSION 1.1.4
VERSION 1.1.5
DESCRIPTION "VulkanSceneGraph library"
LANGUAGES CXX
)
Expand Down Expand Up @@ -43,26 +43,18 @@ set(VSG_MAX_INSTRUMENTATION_LEVEL 1 CACHE STRING "Set the instrumentation level
# Enable/disable shader compilation support that pulls in glslang
set(VSG_SUPPORTS_ShaderCompiler 1 CACHE STRING "Optional shader compiler support, 0 for off, 1 for enabled." )
if (VSG_SUPPORTS_ShaderCompiler)
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/build_vars.cmake)
set(GLSLANG_MIN_VERSION "14" CACHE STRING "glslang 14 is the earliest version that we think installs itself properly on all platforms. Other platforms may be able to use an earlier version")
find_package(glslang ${GLSLANG_MIN_VERSION} CONFIG)

if (Git_FOUND)

set(glslang_URL "https://github.com/vsg-dev/glslang.git" CACHE STRING "URL of the glslang git repository")
set(glslang_branch "VSG-1.0.x" CACHE STRING "branch/tag of the glslang git repository")

execute_process(COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch ${glslang_branch} ${glslang_URL}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src
RESULT_VARIABLE GIT_SUBMOD_RESULT)

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(WARNING "git clone of glslang failed. ShaderCompile support disabled.")
set(VSG_SUPPORTS_ShaderCompiler 0)
endif()
else()
message(WARNING "git clone of glslang failed. ShaderCompile support disabled.")
set(VSG_SUPPORTS_ShaderCompiler 0)
endif()
if (glslang_FOUND)
set(FIND_DEPENDENCY_glslang "find_package(glslang ${GLSLANG_MIN_VERSION} CONFIG REQUIRED)")
else()
message(WARNING "glslang not found. ShaderCompile support disabled.")
set(VSG_SUPPORTS_ShaderCompiler 0)
set(FIND_DEPENDENCY_glslang "")
endif()
else()
set(FIND_DEPENDENCY_glslang "")
endif()

set(VSG_SUPPORTS_Windowing 1 CACHE STRING "Optional native windowing support providing a default implementation of vsg::Window::create(), 0 for off, 1 for enabled." )
Expand Down
24 changes: 14 additions & 10 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,33 @@

### Installing dependencies

* Ubuntu:
`sudo apt-get install cmake-curses-gui g++ git libvulkan-dev`
VulkanSceneGraph build requires C++ 17, CMake and vulkan as a required dependency, and has an optional dependency of glslang 14.0 or later which is used for applications that required runtime shader compilation. Latest Linux releases, such as Ubuntu 24.04, have a modern enough version of glslang out of the box so the following instructions will work out of the box, but wiht older distributions the glslang version will predate 14 and is not supported by the VulkanSceneGraph, so if you require runtime shader compilation you will need to either use the version provided by a recent [VulkanSDK](https://vulkan.lunarg.com/) distribution or compile and install [glslang](https://github.com/KhronosGroup/glslang) from source.

* Gentoo:
* Ubuntu family:
`sudo apt-get install cmake-curses-gui g++ git libvulkan-dev glslang-dev glslang-tools`

* Fedora:
`dnf install git cmake ninja-build gcc-c++ libxcb-devel vulkan-loader-devel glslc glslang-devel`

* Gentoo:
`emerge dev-util/vulkan-tools`


### Build
Command line instructions for default build of static library (.a) in source:

git clone https://github.com/vsg-dev/VulkanSceneGraph.git
cd VulkanSceneGraph
cmake .
make -j 8
make install
cmake .c
cmake --build . -j 16 -t install

Command line instructions for building shared library (.so) out of source:

git clone https://github.com/vsg-dev/VulkanSceneGraph.git
mkdir vsg-shared-build
cd vsg-shared-build
cmake ../VulkanSceneGraph -DBUILD_SHARED_LIBS=ON
make -j 8
make install
cmake --build . -j 16 -t install

---

Expand Down Expand Up @@ -207,7 +211,7 @@ For example, a bare minimum CMakeLists.txt file adding the mentioned cmake targe

### Using VSG provided cmake macro to generate cmake support files

Projects that install a library must generate some cmake-related files so that the library can be found by ```find_package()```. To simplify the generation of these files, the cmake macro ```vsg_add_cmake_support_files()``` has been added.
Projects that install a library must generate some cmake-related files so that the library can be found by ```find_package()```. To simplify the generation of these files, the cmake macro ```vsg_add_cmake_support_files()``` has been added.

In addition to calling the macro, it requires a template for creating the xxxConfig.cmake file, as given in the following example:

Expand Down Expand Up @@ -323,7 +327,7 @@ So now we're ready to build VSG. With the SDK installed this is very similar to
git clone https://github.com/vsg-dev/VulkanSceneGraph.git
cd VulkanSceneGraph
cmake . -G "Xcode"

Once CMake has finished you can open the generated Xcode project and build the 'install' target. This will build VSG and install the headers and generated library onto your machine.

Again, as with other platforms it's useful to now set your CMAKE_PREFIX_PATH to point to the VSG library we have just installed. If you've installed to the default location you can add the following to your .bash_profile file.
Expand Down
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,14 @@ Community projects:
## Quick Guide to building the VSG

### Prerequisites:
* C++17 compliant compiler i.e. g++ 7.3 or later, Clang 6.0 or later, Visual Studio S2017 or later.
* [Vulkan](https://vulkan.lunarg.com/) 1.1 or later.
* [CMake](https://www.cmake.org) 3.7 or later.
* Required: C++17 compliant compiler i.e. g++ 7.3 or later, Clang 6.0 or later, Visual Studio S2017 or later.
* Required: [CMake](https://www.cmake.org) 3.7 or later.
* Required: [Vulkan](https://vulkan.lunarg.com/) 1.1 or later.
* Optional : [glslang](https://github.com/KhronosGroup/glslang) 14.0 or later. Only required if shader compilation at runtime is needed.

The above dependency versions are known to work so they've been set as the current minimum, it may be possible to build against older versions. If you find success with older versions let us know and we can update the version info.

Download VulkanSDK from [LunarG](https://vulkan.lunarg.com/sdk/home), unpack into local directory and set VULKAN_SDK environment variable to the include/lib directory within it. For Linux it would typically be along the lines of:

export VULKAN_SDK_VERSION=1.2.162.1
export VULKAN_SDK=${PWD}/VulkanSDK/${VULKAN_SDK_VERSION}/x86_64

mkdir VulkanSDK
wget https://sdk.lunarg.com/sdk/download/${VULKAN_SDK_VERSION}/linux/vulkansdk-linux-x86_64-${VULKAN_SDK_VERSION}.tar.gz -O VulkanSDK/vulkansdk-linux-x86_64-${VULKAN_SDK_VERSION}.tar.gz
tar zxf VulkanSDK/vulkansdk-linux-x86_64-${VULKAN_SDK_VERSION}.tar.gz -C VulkanSDK/

Once you've downloaded and unpacked the VulkanSDK you'll want to put VULKAN_SDK into your user environment variable setup so that CMake's find_package(Vulkan) can find the VulkanSDK's location.
While you can install Vulkan and glslang development libraries and headers from 3rd party repositoriesm these may be older, so for the latest versions you can also use the VulkanSDK provided by LunarG. Your can download VulkanSDK from [LunarG](https://vulkan.lunarg.com/sdk/home), unpack into a local directory and set VULKAN_SDK environment variable to the include/lib directory within it.

### Command line build instructions:

Expand All @@ -62,7 +54,6 @@ To build and install the static libvsg library (.a/.lib) in source:
git clone https://github.com/vsg-dev/VulkanSceneGraph.git
cd VulkanSceneGraph
cmake .
make -j 8
sudo make install
cmake --build . -j 16 -t install

Full details on how to build the VSG (Unix/Windows/Android/macOS) can be found in the [INSTALL.md](INSTALL.md) file.
13 changes: 4 additions & 9 deletions src/vsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,16 @@ set(SOURCES
utils/Profiler.cpp
)

if (${VSG_SUPPORTS_ShaderCompiler})

# include glslang source code directly into the VulkanScenegraph library build.
include(../glslang/build_vars.cmake)
endif()

# set up library dependencies
set(LIBRARIES PUBLIC
Vulkan::Vulkan
Threads::Threads
)

if (${VSG_SUPPORTS_ShaderCompiler})
list(APPEND LIBRARIES PRIVATE glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV)
endif()

# Check for std::atomic
if(NOT MSVC AND NOT ANDROID AND NOT APPLE)
include(CheckCXXSourceCompiles)
Expand Down Expand Up @@ -402,9 +400,6 @@ target_include_directories(vsg
PUBLIC
$<BUILD_INTERFACE:${VSG_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${VSG_BINARY_DIR}/include>
PRIVATE
$<BUILD_INTERFACE:${VSG_SOURCE_DIR}/src/glslang>
$<BUILD_INTERFACE:${GLSLANG_GENERATED_INCLUDEDIR}>
)

target_link_libraries(vsg ${LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion src/vsg/utils/ShaderCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/utils/ShaderCompiler.h>

#if VSG_SUPPORTS_ShaderCompiler
# include <SPIRV/GlslangToSpv.h>
# include <glslang/SPIRV/GlslangToSpv.h>
# include <glslang/Public/ResourceLimits.h>
# include <glslang/Public/ShaderLang.h>
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/vsg/vsgConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ include(CMakeFindDependencyMacro)

find_package(Vulkan @Vulkan_MIN_VERSION@ REQUIRED)
find_dependency(Threads)

@FIND_DEPENDENCY_glslang@
@FIND_DEPENDENCY_WINDOWING@

include("${CMAKE_CURRENT_LIST_DIR}/vsgTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vsgMacros.cmake")
Loading