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

Prefix cmake options and compiler definitions with GLSLANG_ #2115

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 35 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ addons:
install:
# Make sure that clang-3.6 is selected on Linux.
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "clang" ]]; then
export CC=clang-3.6 CXX=clang++-3.6;
export CC=clang-3.6 CXX=clang++-3.6;
fi
# Download a recent Android NDK and use its android.toolchain.cmake file.
- if [[ "$BUILD_NDK" == "ON" ]]; then
export ANDROID_NDK=$HOME/android-ndk;
git init $ANDROID_NDK;
pushd $ANDROID_NDK;
git remote add dneto0 https://github.com/dneto0/android-ndk.git;
git fetch --depth=1 dneto0 r17b-strip;
git checkout FETCH_HEAD;
popd;
export TOOLCHAIN_PATH=$ANDROID_NDK/build/cmake/android.toolchain.cmake;
export ANDROID_NDK=$HOME/android-ndk;
git init $ANDROID_NDK;
pushd $ANDROID_NDK;
git remote add dneto0 https://github.com/dneto0/android-ndk.git;
git fetch --depth=1 dneto0 r17b-strip;
git checkout FETCH_HEAD;
popd;
export TOOLCHAIN_PATH=$ANDROID_NDK/build/cmake/android.toolchain.cmake;
fi

before_script:
Expand All @@ -71,42 +71,42 @@ script:
# We can use newer API levels if we want.
# For Linux and macOS, do debug/release building with testing.
- if [[ "$BUILD_NDK" == "ON" ]]; then
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH}
-DANDROID_NATIVE_API_LEVEL=android-14
-DCMAKE_BUILD_TYPE=Release
-DANDROID_ABI="armeabi-v7a with NEON"
-DBUILD_TESTING=OFF ..;
make -j4;
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH}
-DANDROID_NATIVE_API_LEVEL=android-14
-DCMAKE_BUILD_TYPE=Release
-DANDROID_ABI="armeabi-v7a with NEON"
-DGLSLANG_BUILD_TESTING=OFF ..;
make -j4;
else
cmake -DCMAKE_BUILD_TYPE=${GLSLANG_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=`pwd`/install ..;
make -j4 install;
ctest --output-on-failure &&
cd ../Test && ./runtests;
cmake -DCMAKE_BUILD_TYPE=${GLSLANG_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=`pwd`/install ..;
make -j4 install;
ctest --output-on-failure &&
cd ../Test && ./runtests;
fi

after_success:
# For debug build, the generated dll has a postfix "d" in its name.
- if [[ "${GLSLANG_BUILD_TYPE}" == "Debug" ]]; then
export SUFFIX="d";
export SUFFIX="d";
else
export SUFFIX="";
export SUFFIX="";
fi
# Create tarball for deployment
- if [[ ${CC} == clang* && "${BUILD_NDK}" != "ON" ]]; then
cd ../build/install;
export TARBALL=glslang-master-${TRAVIS_OS_NAME}-${GLSLANG_BUILD_TYPE}.zip;
zip ${TARBALL}
bin/glslangValidator
include/glslang/*
lib/libglslang${SUFFIX}.a
lib/libHLSL${SUFFIX}.a
lib/libOGLCompiler${SUFFIX}.a
lib/libOSDependent${SUFFIX}.a
lib/libSPIRV${SUFFIX}.a
lib/libSPVRemapper${SUFFIX}.a
lib/libSPIRV-Tools${SUFFIX}.a
lib/libSPIRV-Tools-opt${SUFFIX}.a;
cd ../build/install;
export TARBALL=glslang-master-${TRAVIS_OS_NAME}-${GLSLANG_BUILD_TYPE}.zip;
zip ${TARBALL}
bin/glslangValidator
include/glslang/*
lib/libglslang${SUFFIX}.a
lib/libHLSL${SUFFIX}.a
lib/libOGLCompiler${SUFFIX}.a
lib/libOSDependent${SUFFIX}.a
lib/libSPIRV${SUFFIX}.a
lib/libSPVRemapper${SUFFIX}.a
lib/libSPIRV-Tools${SUFFIX}.a
lib/libSPIRV-Tools-opt${SUFFIX}.a;
fi

before_deploy:
Expand Down
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)

GLSLANG_OS_FLAGS := -DGLSLANG_OSINCLUDE_UNIX
# AMD and NV extensions are turned on by default in upstream Glslang.
GLSLANG_DEFINES:= -DAMD_EXTENSIONS -DNV_EXTENSIONS -DENABLE_HLSL $(GLSLANG_OS_FLAGS)
GLSLANG_DEFINES:= -DAMD_EXTENSIONS -DNV_EXTENSIONS -DGLSLANG_ENABLE_HLSL $(GLSLANG_OS_FLAGS)

include $(CLEAR_VARS)
LOCAL_MODULE:=OSDependent
Expand Down
8 changes: 4 additions & 4 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ cc_library(
copts = COMMON_COPTS,
defines = [
"AMD_EXTENSIONS",
"ENABLE_HLSL=0",
"ENABLE_OPT=0",
"GLSLANG_ENABLE_HLSL=0",
"GLSLANG_ENABLE_OPT=0",
"NV_EXTENSIONS",
],
linkopts = select({
Expand All @@ -85,7 +85,7 @@ genrule(
"SPIRV/GLSL.ext.KHR.h",
"SPIRV/GLSL.ext.NV.h",
"SPIRV/GLSL.std.450.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/spirv.hpp",
],
outs = [
Expand All @@ -94,7 +94,7 @@ genrule(
"include/SPIRV/GLSL.ext.KHR.h",
"include/SPIRV/GLSL.ext.NV.h",
"include/SPIRV/GLSL.std.450.h",
"include/SPIRV/NonSemanticDebugPrintf.h",
"include/SPIRV/NonSemanticDebugPrintf.h",
"include/SPIRV/spirv.hpp",
],
cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
Expand Down
10 changes: 5 additions & 5 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spirv_tools_dir = glslang_spirv_tools_dir
config("glslang_public") {
include_dirs = [ "." ]

defines = [ "ENABLE_HLSL=1" ]
defines = [ "GLSLANG_ENABLE_HLSL=1" ]
}

source_set("glslang_sources") {
Expand All @@ -70,7 +70,7 @@ source_set("glslang_sources") {
"SPIRV/InReadableOrder.cpp",
"SPIRV/Logger.cpp",
"SPIRV/Logger.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/SPVRemapper.cpp",
"SPIRV/SPVRemapper.h",
"SPIRV/SpvBuilder.cpp",
Expand Down Expand Up @@ -164,7 +164,7 @@ source_set("glslang_sources") {
"hlsl/hlslTokens.h",
]

defines = [ "ENABLE_OPT=1" ]
defines = [ "GLSLANG_ENABLE_OPT=1" ]

if (is_win) {
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
Expand Down Expand Up @@ -224,7 +224,7 @@ executable("glslang_validator") {
if (!is_win) {
cflags = [ "-Woverflow" ]
}
defines = [ "ENABLE_OPT=1" ]
defines = [ "GLSLANG_ENABLE_OPT=1" ]
deps = [
":glslang_default_resource_limits_sources",
":glslang_sources",
Expand All @@ -238,7 +238,7 @@ executable("spirv-remap") {
sources = [
"StandAlone/spirv-remap.cpp",
]
defines = [ "ENABLE_OPT=1" ]
defines = [ "GLSLANG_ENABLE_OPT=1" ]
deps = [
":glslang_sources",
]
Expand Down
59 changes: 30 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ include(GNUInstallDirs)
# Needed for CMAKE_DEPENDENT_OPTION macro
include(CMakeDependentOption)

option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
option(BUILD_EXTERNAL "Build external dependencies in /External" ON)
option(GLSLANG_BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
option(GLSLANG_BUILD_EXTERNAL "Build external dependencies in /External" ON)

set(LIB_TYPE STATIC)

if(BUILD_SHARED_LIBS)
if(GLSLANG_BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
endif()

Expand Down Expand Up @@ -51,22 +51,23 @@ CMAKE_DEPENDENT_OPTION(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE
OFF "ENABLE_GLSLANG_JS AND EMSCRIPTEN"
OFF)

CMAKE_DEPENDENT_OPTION(ENABLE_HLSL
CMAKE_DEPENDENT_OPTION(GLSLANG_ENABLE_HLSL
"Enables HLSL input support"
ON "NOT ENABLE_GLSLANG_WEBMIN"
OFF)

option(ENABLE_RTTI "Enables RTTI" OFF)
option(ENABLE_OPT "Enables spirv-opt capability if present" ON)
option(ENABLE_PCH "Enables Precompiled header" ON)
option(ENABLE_CTEST "Enables testing" ON)
option(GLSLANG_ENABLE_RTTI "Enables RTTI" OFF)
option(GLSLANG_ENABLE_OPT "Enables spirv-opt capability if present" ON)
option(GLSLANG_ENABLE_PCH "Enables Precompiled header" ON)
option(GLSLANG_ENABLE_CTEST "Enables testing" ON)
option(GLSLANG_BUILD_TESTING "Builds tests" ON)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
endif()

option(USE_CCACHE "Use ccache" OFF)
if(USE_CCACHE)
option(GLSLANG_USE_CCACHE "Use ccache" OFF)
if(GLSLANG_USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
Expand All @@ -75,7 +76,7 @@ endif()

# Precompiled header macro. Parameters are source file list and filename for pch cpp file.
macro(glslang_pch SRCS PCHCPP)
if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio" AND ENABLE_PCH)
if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio" AND GLSLANG_ENABLE_PCH)
set(PCH_NAME "$(IntDir)\\pch.pch")
# make source files use/depend on PCH_NAME
set_source_files_properties(${${SRCS}} PROPERTIES COMPILE_FLAGS "/Yupch.h /FIpch.h /Fp${PCH_NAME} /Zm300" OBJECT_DEPENDS "${PCH_NAME}")
Expand All @@ -87,13 +88,13 @@ endmacro(glslang_pch)

project(glslang)

if(ENABLE_CTEST)
if(GLSLANG_ENABLE_CTEST)
include(CTest)
endif()

if(ENABLE_HLSL)
add_definitions(-DENABLE_HLSL)
endif(ENABLE_HLSL)
if(GLSLANG_ENABLE_HLSL)
add_definitions(-DGLSLANG_ENABLE_HLSL)
endif(GLSLANG_ENABLE_HLSL)

if(ENABLE_GLSLANG_WEBMIN)
add_definitions(-DGLSLANG_WEB)
Expand All @@ -118,7 +119,7 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
if(NOT ENABLE_RTTI)
if(NOT GLSLANG_ENABLE_RTTI)
add_compile_options(-fno-rtti)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")
Expand All @@ -128,11 +129,11 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
if(NOT ENABLE_RTTI)
if(NOT GLSLANG_ENABLE_RTTI)
add_compile_options(-fno-rtti)
endif()
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
if(NOT ENABLE_RTTI)
if(NOT GLSLANG_ENABLE_RTTI)
add_compile_options(/GR-) # Disable RTTI
endif()
endif()
Expand Down Expand Up @@ -168,25 +169,25 @@ endfunction(glslang_set_link_args)

# CMake needs to find the right version of python, right from the beginning,
# otherwise, it will find the wrong version and fail later
if(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External)
if(GLSLANG_BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External)
find_package(PythonInterp 3 REQUIRED)

# We depend on these for later projects, so they should come first.
add_subdirectory(External)
endif()

if(NOT TARGET SPIRV-Tools-opt)
set(ENABLE_OPT OFF)
set(GLSLANG_ENABLE_OPT OFF)
endif()

if(ENABLE_OPT)
if(GLSLANG_ENABLE_OPT)
message(STATUS "optimizer enabled")
add_definitions(-DENABLE_OPT=1)
add_definitions(-DGLSLANG_ENABLE_OPT=1)
else()
if(ENABLE_HLSL)
if(GLSLANG_ENABLE_HLSL)
message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
endif()
add_definitions(-DENABLE_OPT=0)
add_definitions(-DGLSLANG_ENABLE_OPT=0)
endif()

add_subdirectory(glslang)
Expand All @@ -195,14 +196,14 @@ if(ENABLE_GLSLANG_BINARIES)
add_subdirectory(StandAlone)
endif()
add_subdirectory(SPIRV)
if(ENABLE_HLSL)
if(GLSLANG_ENABLE_HLSL)
add_subdirectory(hlsl)
endif(ENABLE_HLSL)
if(ENABLE_CTEST)
endif(GLSLANG_ENABLE_HLSL)
if(GLSLANG_ENABLE_CTEST)
add_subdirectory(gtests)
endif()

if(BUILD_TESTING)
if(GLSLANG_BUILD_TESTING)
# glslang-testsuite runs a bash script on Windows.
# Make sure to use '-o igncr' flag to ignore carriage returns (\r).
set(IGNORE_CR_FLAG "")
Expand All @@ -223,4 +224,4 @@ if(BUILD_TESTING)
add_test(NAME glslang-testsuite
COMMAND bash ${IGNORE_CR_FLAG} runtests ${RESULTS_PATH} ${VALIDATOR_PATH} ${REMAP_PATH}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Test/)
endif(BUILD_TESTING)
endif(GLSLANG_BUILD_TESTING)
6 changes: 3 additions & 3 deletions External/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Suppress all warnings from external projects.
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w)

if(BUILD_TESTING)
if(GLSLANG_BUILD_TESTING)
if(TARGET gmock)
message(STATUS "Google Mock already configured - use it")
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
Expand All @@ -23,7 +23,7 @@ if(BUILD_TESTING)
mark_as_advanced(gmock_build_tests
BUILD_GMOCK
BUILD_GTEST
BUILD_SHARED_LIBS
GLSLANG_BUILD_SHARED_LIBS
gtest_build_samples
gtest_build_tests
gtest_disable_pthreads
Expand All @@ -35,7 +35,7 @@ if(BUILD_TESTING)
endif()
endif()

if(ENABLE_OPT AND NOT TARGET SPIRV-Tools-opt)
if(GLSLANG_ENABLE_OPT AND NOT TARGET SPIRV-Tools-opt)
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools)
set(SPIRV_SKIP_TESTS ON CACHE BOOL "Skip building SPIRV-Tools tests")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools spirv-tools)
Expand Down