Commit Graph

108 Commits

Author SHA1 Message Date
Ben Clayton
2270713d6a Fix CMake rules when nesting CMake projects
`${CMAKE_SOURCE_DIR}` points to the outer project root, not the current directory.

Fixes building of `glslang` when included into another CMake project.
2020-07-10 14:39:39 +01:00
Ben Clayton
fbe9a23baf Generate build information from CHANGES.md
This PR significantly reworks the way glslang is versioned.

Instead of committing changes to the `GLSLANG_MINOR_VERSION` define in
`glslang/Public/ShaderLang.h`, and using `make-revision` to generate
`GLSLANG_PATCH_LEVEL` in `glslang/Include/revision.h`, all version
information is now derived from the new `CHANGES.md` file.

`CHANGES.md` acts as the single source of truth for glslang version
information, along with a convenient place to put all release notes for
each notable change made.

`CHANGES.md` is parsed using the new `build_info.py` python script.
This script can read basic template files to produce new source files,
which it does to read the new `build_info.h.tmpl` to generate (at build
time) a glslang private header at
`<build-dir>/include/glslang/build_info.h`.
I've written generators for each of the CMake, Bazel, gn, and
`Android.mk` build scripts.

The new version code conforms to the Semantic Versioning 2.0 spec.

This new version is also used by the CMake rules to produce versioned
shared objects, including a major-versioned SONAME.

New APIs:
---------

* `glslang::GetVersion()` returns a `Version` struct with the version
  major, minor, patch and flavor.

Breaking API changes:
---------------------

* The public defines `GLSLANG_MINOR_VERSION` and `GLSLANG_PATCH_LEVEL`
  have been entirely removed.
* `glslang/Public/ShaderLang.h` and `glslang/Include/revision.h` have
  been deleted.
* Instead, `<build-dir>/include/glslang/build_info.h` is created in
  the build directory, and `<build-dir>/include` is a CMake `PUBLIC`
  (dependee-inherited) include directory for the glslang targets.
* `<build-dir>/include/glslang/build_info.h` contains the following
   new #defines:
   `GLSLANG_VERSION_MAJOR`, `GLSLANG_VERSION_MINOR`,
   `GLSLANG_VERSION_PATCH`, `GLSLANG_VERSION_FLAVOR`,
   `GLSLANG_VERSION_GREATER_THAN(major, minor, patch)`,
   `GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch)`,
   `GLSLANG_VERSION_LESS_THAN(major, minor, patch)`,
   `GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch)`
*  The CMake install output directory contains a copy of
   `build_info.h` at: `include/glslang/build_info.h`
*  Python3 is now always required to build glslang (likely always
   required for transitive dependency builds).
2020-07-09 12:34:02 +01:00
Ben Clayton
31cad22758 Use CMake's builtin functionality for PCHs
`glslang_pch()` did manual mangling of the compiler flags to enable pre-compiled headers.
I couldn't get this approach to work with the `MachineIndependent` subdirectory, but fortunately CMake has added first-class support for precompiled headers in 3.16, which does work with subdirectories.

Moved `glslang_pch()` to the other global function declarations.

`glslang_pch()` is a no-op when using CMake earlier than `3.16`.

CMake's PCH implementation does not need the `pch.cpp` files, so just remove them.
2020-07-07 16:44:19 +01:00
Ben Clayton
3604be156c Remove GLSLANG_BUILD_PIC flag
On closer inspection, it appears that nearly all the targets use the `POSITION_INDEPENDENT_CODE` target option anyway.
Simplify all this away by always being PIC.
2020-07-07 11:49:40 +01:00
John Kessenich
257e9a3f19
Merge pull request #2319 from ben-clayton/build-pic
Add GLSLANG_BUILD_PIC CMake flag
2020-07-03 22:37:25 -06:00
Ben Clayton
1125f1b269 Add GLSLANG_BUILD_PIC CMake flag
Enables `-fPIC` compiler flag even when building statically.
This is helpful for statically linking a `glslang` target into a shared library.

Simplifies the workarounds seen in google/shaderc#1093 to a `set(GLSLANG_BUILD_PIC 1)`.
2020-07-03 23:24:08 +01:00
Ben Clayton
4af48da4e3 Don't use add_link_options() on old CMake versions
Fixes: #2315
2020-07-03 15:41:03 +01:00
Ben Clayton
cb261e3c21 License headers: s/Google/The Khronos Group
This was a copy-paste screwup, where the first line of the copyright had the company name was updated, but the company name mid way though was not.
2020-07-03 12:21:01 +01:00
John Kessenich
4728509962
Merge pull request #2310 from ben-clayton/license-checker
Add license checking continuous and presubmit tests
2020-07-02 23:33:30 -06:00
Ben Clayton
cb4788c7a6 Fix GLSLANG_IS_SHARED_LIBRARY define
It was incorrectly always being set, causing linker warnings for MSVC builds.
Also simplify the preprocessor nesting in `glslang\Public\ShaderLang.h`
2020-07-02 16:10:20 +01:00
Ben Clayton
1d21270ebf Add missing copyright headers
Add copyright headers to build files and scripts.
Simplifies automated scanning for bad license headers.
2020-07-02 16:03:48 +01:00
Ben Clayton
d64e859987 glslang: Only export public interface for SOs
Default to `-fvisibility=hidden`, and annotate the public glslang interface with `GLSLANG_EXPORT` to change the visibility of these cherry-picked symbols to default.
This is also used by Windows builds for `__declspec(dllexport)`-ing the public DLL interface.

This allows us to classify API changes into those that are publicly backwards compatible, and those that are not.

Note that `libSPIRV` will likely need similar treatment.

Issues: #2283, #1484
2020-06-30 17:06:17 +01:00
John Kessenich
8f4251a708
Merge pull request #2297 from ben-clayton/fpic
CMake: Compile with -fPIC when building SOs
2020-06-30 07:55:53 -06:00
Ben Clayton
981e127698 CMake: Compile with -fPIC when building SOs
Without this embedding static libraries into shared libraries may result in link time errors.

Issue: #2283
2020-06-29 14:57:47 +01:00
Ben Clayton
1fee6072d0 CMake: Error on unresolved symbols
Issue: #1484
2020-06-29 14:57:12 +01:00
Evgeny Proydakov
b90adef928 Fixed msvc 2019 nmake compiler warnings with RTTI.
By default cmake generates cxx_flags with `/GR` parameter.
I updated CMAKE_CXX_FLAGS string and replaced `/GR` -> `/GR-`

How to reproduce:

Visual Studio 2019 x64 command port

mkdir build-msvc2019
cd build-msvc2019
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=install ..
nmake

COMPILATION BEFORE:

Scanning dependencies of target OSDependent
[  1%] Building CXX object glslang/OSDependent/Windows/CMakeFiles/OSDependent.dir/ossource.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'
ossource.cpp
[  3%] Linking CXX static library OSDependent.lib
[  3%] Built target OSDependent
Scanning dependencies of target OGLCompiler
[  4%] Building CXX object OGLCompilersDLL/CMakeFiles/OGLCompiler.dir/InitializeDll.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'
InitializeDll.cpp
[  6%] Linking CXX static library OGLCompiler.lib
[  6%] Built target OGLCompiler
Scanning dependencies of target glslang
[  7%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/glslang_tab.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'
glslang_tab.cpp
[  9%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/attribute.cpp.obj
cl : Command line warning D9025 : overriding '/GR' with '/GR-'

FLAGS BEFORE:

-- CMAKE_C_FLAGS:   /DWIN32 /D_WINDOWS /W3
-- CMAKE_CXX_FLAGS: /DWIN32 /D_WINDOWS /W3 /GR /EHsc
-- CMAKE_CXX_FLAGS_DEBUG:   /MDd /Zi /Ob0 /Od /RTC1
-- CMAKE_CXX_FLAGS_RELEASE: /MD /O2 /Ob2 /DNDEBUG

COMPILATION AFTER:

[  1%] Building CXX object glslang/OSDependent/Windows/CMakeFiles/OSDependent.dir/ossource.cpp.obj
ossource.cpp
[  3%] Linking CXX static library OSDependent.lib
[  3%] Built target OSDependent
[  4%] Building CXX object OGLCompilersDLL/CMakeFiles/OGLCompiler.dir/InitializeDll.cpp.obj
InitializeDll.cpp
[  6%] Linking CXX static library OGLCompiler.lib
[  6%] Built target OGLCompiler
[  7%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/glslang_tab.cpp.obj
glslang_tab.cpp
[  9%] Building CXX object glslang/CMakeFiles/glslang.dir/MachineIndependent/attribute.cpp.obj

FLAGS AFTER:

-- CMAKE_C_FLAGS:   /DWIN32 /D_WINDOWS /W3
-- CMAKE_CXX_FLAGS: /DWIN32 /D_WINDOWS /W3 /GR- /EHsc
-- CMAKE_CXX_FLAGS_DEBUG:   /MDd /Zi /Ob0 /Od /RTC1
-- CMAKE_CXX_FLAGS_RELEASE: /MD /O2 /Ob2 /DNDEBUG
2020-06-23 22:02:34 +03:00
nihui
a0cce739bc
Do not build glslang-testsuite when ENABLE_CTEST is disabled (#2240) 2020-05-21 05:33:17 -06:00
nihui
044113abe8
Add an option to make Exceptions enabled (#2239)
* Add an option to make Exceptions enabled

* /EHsc enable exceptions since vs2003
2020-05-20 23:55:24 -06:00
Malacath-92
fd593d5f08
Get rid of all warnings with MSVC and clang-cl (#2177) 2020-04-10 02:39:16 -06:00
Kai Ninomiya
16bb8881e6 Fix build on CMake 2.8, and fix Web build
And suppress some warnings that are too verbose in Web builds.
2020-03-23 12:34:55 -07:00
durswd
b848387262 Add an option to make RTTI enabled 2020-02-18 02:37:09 +09:00
Kai Ninomiya
5166bc1859 Split "is emscripten" config from "enable glslang.js"
This should enable glslang to be used as a dependency of other projects
that target WebAssembly, instead of assuming "EMSCRIPTEN" => "Want
glslang.js".
2020-02-06 14:06:20 -08:00
Jeff Bolz
141dbedeac Use NOT ... VERSION_LESS instead of VERSION_GREATER_EQUAL 2020-01-29 21:39:13 -06:00
John Kessenich
d5f2f7b93d
Merge pull request #1940 from tsuoranta/fix-gcc9
Fix for GCC 9 / Werror=deprecated-copy
2020-01-27 01:02:08 -07:00
Sergey Kosarevsky
3b8d94f422 Add option ENABLE_CTEST to skip testing 2019-10-25 11:57:11 +03:00
Timo Suoranta
5e634c8999 Enable generation of compile_commands.json (#1938) 2019-10-21 22:38:04 -06:00
Timo Suoranta
f0a85fc744 Fixes for gcc 9 / -Werror=deprecated-copy
Also enable -Werror-deprecated-copy for GCC version 9 and later.
2019-10-19 15:36:34 +03:00
John Kessenich
a959deb007
Merge pull request #1933 from dj2/runtest
Make runtests configurable.
2019-10-16 20:53:39 -06:00
Dan Sinclair
3290d38011 Use commandline options instead of ENV variables 2019-10-16 13:08:48 -04:00
John Kessenich
9e4f6d03f2
Merge pull request #1932 from zoddicus/anotherSemiColonFix
Fix config issues and revert previous fixes for semi-colon issues
2019-10-16 10:39:51 -06:00
dan sinclair
7d623e1c90
Indenting 2019-10-16 10:45:11 -04:00
dan sinclair
0f98465f0a
Update CMakeLists.txt 2019-10-15 19:11:39 -04:00
Dan Sinclair
3f072e158c Move TARGETDIR as well 2019-10-15 16:47:28 -04:00
Dan Sinclair
167201430d Make runtests configurable.
This CL allows setting the location of glslangValidator and spirv-remap
when calling the runtests script. A test target is added to CMake to
execute runtests and sets the location to the build folder for the two
applications.
2019-10-15 15:21:21 -04:00
Ryan Harrison
1aeceaea7d Fix config issues and revert previous fixes for semi-colon issues
This reverts commit 41261d95a4.
This reverts commit 7c9accb653.

Instead of trying to work around all of the potential semicolon issues
in glslang, making it conform to Chromium's style, mark the code
explicitly as non-chromium in the BUILD.gn, so chromium doesn't
attempt to enforce its style rules on glslang.

Fixes #1931
2019-10-15 14:45:02 -04:00
durswd
0539823243 Added an option to make pch enabled in Cmake 2019-10-16 02:28:40 +09:00
Fabian Wahlster
03be018a47 find Python and add External subdir only if BUILD_EXTERNAL option was set (on by default) and /External dir exists 2019-10-15 11:00:23 +02:00
Ryan Harrison
41261d95a4 Forgot that GCC doesn't recognize this flag 2019-10-11 13:18:07 -04:00
Ryan Harrison
7c9accb653 Remove unnecessary semi-colons and add warning about them
These are causing integration issues with Chromium down stream since
it is more strict about these.
2019-10-11 11:25:04 -04:00
Kai Ninomiya
230117a02c use custom es6 modularization instead of MODULARIZE=1 2019-09-18 00:04:09 -07:00
Kai Ninomiya
4391924ac5 Separate GLSLANG_WEB (min-size build) and Emscripten options
Allows building non-min-size builds with Emscripten.
Adds ENABLE_GLSLANG_WEB_DEVEL.
Moves the glslang.js files to OSDependent/Web.
Small cleanups and docs update.
2019-09-17 23:18:03 -07:00
John Kessenich
eaf4496312 Web: Complete the removal of vendor-specific #ifdef's, including CMake. 2019-08-20 23:21:56 -06:00
John Kessenich
23d27751e8 Web: Selectively remove a few key features, using #ifndef GLSLANG_WEB
Save about 100K.

N.B.: This is done by eliminating a function call, at a high level,
not by #ifdef'ing a bunch of code.

Also, removed no longer needed *_EXTENSION #ifdef in the code not
needed by GLSLANG_WEB.
2019-08-20 23:21:55 -06:00
Kai Ninomiya
a91561d583 enable build for node 2019-08-20 13:10:53 -07:00
Ryan Harrison
7eb3e6e07a Make non-emscripten flags platform agnostic. 2019-08-09 11:19:07 -04:00
Ryan Harrison
c1063cd5e2 Converted ENABLE_HLSL to a dependent option, so it can be always disabled in web builds 2019-08-09 10:56:51 -04:00
Ryan Harrison
c96e42dca8 Add WASM build target for Web version of glslang
This adds build rules to support generating a WASM binary to be used
on the web. The API exposed to web applications is definated in the
new glslang.js.cpp file.
2019-08-08 15:08:10 -04:00
Ryan Harrison
8126eb1962 Convert no RTTI rule to be compiler specific
MSVC uses a different flag for disabling RTTI, so is currently
including RTTI information and throwing warnings.
2019-07-30 11:25:19 -04:00
Ryan Harrison
bbf172b518 Explicitly remove RTTI in the top-level build config
Fixes #1831
2019-07-12 14:25:18 -04:00
John Kessenich
6fef1ca6f9 Latest known-good SPIRV-Tools: WARNING: Needs python 3.x.
You may need to install python 3.x and also
[windows users] may need to get it in your path in front of python 2.7.x.

If you don't need the external projects (i.e., SPIRV-Tools) and don't want
to upgrade to python 3, don't create the External subdirectory and CMake
won't require python 3.  (CMake has a bug that makes it find the wrong one
on a first pass if the top level does not require the version needed by
lower levels.)
2019-05-09 10:11:54 -06:00