Add GLSLANG_TESTS option

1 variable instead of ENABLE_CTEST and BUILD_TESTING.

OFF by default. See README.md for explanation.
This commit is contained in:
Juan Ramos 2023-11-30 12:33:36 -07:00 committed by arcady-lunarg
parent e854c8de10
commit 3b99124593
5 changed files with 22 additions and 23 deletions

View File

@ -28,7 +28,7 @@ jobs:
key: ubuntu-22-${{ matrix.cmake_build_type }}-${{ matrix.compiler.cc }}-${{matrix.compiler.cxx}}
- run: ./update_glslang_sources.py
- name: Configure
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} -DBUILD_WERROR=ON
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} -DBUILD_WERROR=ON -D GLSLANG_TESTS=ON
env:
CC: ${{matrix.compiler.cc}}
CXX: ${{matrix.compiler.cxx}}
@ -64,7 +64,7 @@ jobs:
key: ubuntu-22-${{ matrix.cmake_build_type }}-${{ matrix.compiler.cc }}-${{matrix.compiler.cxx}}-${{matrix.flags}}
- run: ./update_glslang_sources.py
- name: Configure
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} -D GLSLANG_TESTS=ON
env:
CC: ${{matrix.compiler.cc}}
CXX: ${{matrix.compiler.cxx}}
@ -101,7 +101,7 @@ jobs:
key: linux_backcompat
- run: ./update_glslang_sources.py
- name: Configure
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D GLSLANG_TESTS=ON
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
@ -126,7 +126,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: lukka/get-cmake@8be6cca406b575906541e8e3b885d46f416bba39 # v3.27.7
- run: ./update_glslang_sources.py
- run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -G Ninja -DBUILD_WERROR=ON
- run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -G Ninja -DBUILD_WERROR=ON -D GLSLANG_TESTS=ON
env:
CC: ${{matrix.compiler.cc}}
CXX: ${{matrix.compiler.cxx}}
@ -155,7 +155,7 @@ jobs:
- run: python update_glslang_sources.py
- name: Build
run: |
cmake -S. -Bbuild -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="$PWD/build/install" -DBUILD_WERROR=ON
cmake -S. -Bbuild -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="$PWD/build/install" -DBUILD_WERROR=ON -D GLSLANG_TESTS=ON
cmake --build build --config ${{matrix.cmake_build_type}} --target install
- name: Test
run: ctest -C ${{matrix.cmake_build_type}} --output-on-failure --test-dir build
@ -230,7 +230,7 @@ jobs:
- name: Update Glslang Sources
run: ./update_glslang_sources.py
- name: Configure
run: emcmake cmake -GNinja -Bbuild/web -DCMAKE_BUILD_TYPE=Release -DENABLE_GLSLANG_JS=ON -DBUILD_TESTING=OFF -DENABLE_OPT=OFF
run: emcmake cmake -GNinja -Bbuild/web -DCMAKE_BUILD_TYPE=Release -DENABLE_GLSLANG_JS=ON -DENABLE_OPT=OFF
env:
CMAKE_GENERATOR: Ninja
CMAKE_C_COMPILER_LAUNCHER: ccache

View File

@ -70,11 +70,11 @@ endif()
# Furthermore testing is equally problematic.
if (IOS OR ANDROID)
set(ENABLE_GLSLANG_BINARIES OFF)
set(ENABLE_CTEST OFF)
set(BUILD_TESTING OFF)
set(GLSLANG_TESTS OFF)
endif()
option(GLSLANG_TESTS "Enable glslang testing")
option(SKIP_GLSLANG_INSTALL "Skip installation")
if(NOT ${SKIP_GLSLANG_INSTALL})
@ -107,11 +107,6 @@ if(MINGW OR (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU"))
endif()
option(ENABLE_PCH "Enables Precompiled header" ON)
option(ENABLE_CTEST "Enables testing" ON)
if(ENABLE_CTEST)
include(CTest)
endif()
if(ENABLE_HLSL)
add_compile_definitions(ENABLE_HLSL)
@ -306,11 +301,11 @@ if(ENABLE_GLSLANG_BINARIES)
add_subdirectory(StandAlone)
endif()
add_subdirectory(SPIRV)
if(ENABLE_CTEST)
add_subdirectory(gtests)
endif()
if(ENABLE_CTEST AND BUILD_TESTING)
if(GLSLANG_TESTS)
enable_testing()
add_subdirectory(gtests)
# glslang-testsuite runs a bash script on Windows.
# Make sure to use '-o igncr' flag to ignore carriage returns (\r).
set(IGNORE_CR_FLAG "")

View File

@ -34,7 +34,7 @@
# Suppress all warnings from external projects.
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w)
if(BUILD_TESTING)
if(GLSLANG_TESTS)
if(TARGET gmock)
message(STATUS "Google Mock already configured - use it")
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)

View File

@ -171,6 +171,10 @@ cmake --build . --config Release --target install
If using MSVC, after running CMake to configure, use the
Configuration Manager to check the `INSTALL` project.
If you want to enable testing via CMake set `GLSLANG_TESTS=ON` when configuring the build.
`GLSLANG_TESTS` is off by default to streamline the packaging / Vulkan SDK process.
### Building (GN)
glslang can also be built with the [GN build system](https://gn.googlesource.com/gn/).
@ -228,7 +232,7 @@ Use the steps in [Build Steps](#build-steps), with the following notes/exception
Bash-like environments:
+ [Instructions located here](https://emscripten.org/docs/getting_started/downloads.html#sdk-download-and-install)
* Wrap cmake call: `emcmake cmake`
* Set `-DBUILD_TESTING=OFF -DENABLE_OPT=OFF`.
* Set `-DENABLE_OPT=OFF`.
* Set `-DENABLE_HLSL=OFF` if HLSL is not needed.
* For a standalone JS/WASM library, turn on `-DENABLE_GLSLANG_JS=ON`.
* To get a fully minimized build, make sure to use `brotli` to compress the .js
@ -238,7 +242,7 @@ Example:
```sh
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GLSLANG_JS=ON \
-DENABLE_HLSL=OFF -DBUILD_TESTING=OFF -DENABLE_OPT=OFF ..
-DENABLE_HLSL=OFF -DENABLE_OPT=OFF ..
```
## Building glslang - Using vcpkg

View File

@ -1,4 +1,4 @@
# Copyright (C) 2020 The Khronos Group Inc.
# Copyright (C) 2020-2023 The Khronos Group Inc.
#
# All rights reserved.
#
@ -31,7 +31,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
if(BUILD_TESTING)
if(GLSLANG_TESTS)
if(TARGET gmock)
message(STATUS "Google Mock found - building tests")