Commit Graph

130 Commits

Author SHA1 Message Date
SpaceIm
de2581ed0c fix MinGW
pre compiled headers leads to "internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:192: MapViewOfFileEx: Attempt to access invalid address"
2022-04-07 21:18:27 +02:00
Nicolas Morales
ab87ffe7cf #2861: If compiling with macOS and GCC, default ENABLE_PCH to false since CMake will generate incompatible Xarch flags for the precompiled headers 2022-01-11 11:41:44 +01:00
Nicolas Morales
66ac0df61b #2861: Check for macOS systems before adding "--no-undefined" to linker flags as it is not compatible with the default linker. 2022-01-11 11:41:44 +01:00
scribam
f1cc215e55 Override CMAKE_INSTALL_PREFIX only if ENABLE_GLSLANG_INSTALL is ON 2022-01-09 22:30:11 +01:00
Nathaniel Cesario
c8ef4f8a9f cmake: Remove "conditions" from endif
See https://cmake.org/cmake/help/latest/command/endif.html and
https://cmake.org/cmake/help/latest/command/if.html.

If the else/endif condition does not match the if condition verbatim,
an error is produced on some versions of cmake. This change removes
these "legacy conditions."
2021-09-30 11:00:09 -06:00
Alastair Cota
48937f931a
Update CMakeLists.txt
Checked REGEX REPLACE for consistency failure
2021-08-08 17:00:26 +01:00
andrei.malashkin
0784c41300 correct ident 2021-07-30 09:12:45 +02:00
andrei.malashkin
fda1c58350 make AND to upper case 2021-07-14 09:33:02 +04:00
andrei.malashkin
22d19b963c add possibility to not override runtime of MSVC 2021-07-14 06:35:03 +04:00
okuoku
4c09598526 Set CMake policy CMP0054 to NEW to silence warning
CMAKE_SYSTEM_NAME variable might evaluate to existing variable such as
CYGWIN. This setting also matches with SPIRV-Tools.
2021-05-02 03:49:05 +09:00
Greg Fischer
7b51e234fe Fix CMakeLists.txt to keep compatibility with CMake 3.10.2 2021-04-22 16:30:17 -06:00
Evgeny Proydakov
a990b97d07 Returned using find_host_package for PythonInterp 3 instead of find_package.
I changed this logic here: 05798c17fb
It was originally fixed here: 967fa92d14
2021-02-26 14:32:38 +03:00
Evgeny Proydakov
5f7228e785 Fixed msvc 2019 nmake noexcept build.
By default cmake generates cxx_flags with /EHsc parameter.
I updated CMAKE_CXX_FLAGS string and removed /EHsc, also I added compile defenitions _HAS_EXCEPTIONS=0, it is mandatory for noexcept build with MSVC STL implementation.
Output files became smaller.

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

CXX 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
-- ENABLE_RTTI:       OFF
-- ENABLE_EXCEPTIONS: OFF

OUTPUT SIZE BEFORE:

Build folder size: 61,8 MB (64 808 580 bytes)

GLSLANG SIZE BEFORE:

glslang.lib 22,7 MB (23 887 150 bytes)

CXX FLAGS AFTER:

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

OUTPUT SIZE AFTER:

Build folder size: 58,4 MB (61 331 179 bytes)

GLSLANG SIZE AFTER:

glslang.lib 21,6 MB (22 655 252 bytes)
2021-02-24 11:08:57 +03:00
Evgeny Proydakov
6332f80b2d Code review. Thx greg-lunarg for comments. 2021-02-23 17:14:42 +03:00
Evgeny Proydakov
31d234c1da Fixed cmake generation warning for regeneration project build files.
[BEFORE]:

% cmake ..
CMake Warning (dev) at CMakeLists.txt:35 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    CMAKE_PROJECT_VERSION
    CMAKE_PROJECT_VERSION_MAJOR
    CMAKE_PROJECT_VERSION_MINOR
    CMAKE_PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

-- No build type selected, default to Debug
-- Found PythonInterp: /usr/local/bin/python3 (found version "3.9")
-- Found PythonInterp: /usr/local/bin/python3 (found suitable version "3.9", minimum required is "3")
-- optimizer enabled
-- Google Mock found - building tests
-- Configuring done

[AFTER]:

% cmake ..
-- No build type selected, default to Debug
-- Google Mock was not found - tests based on that will not build
-- Configuring done
-- Generating done
2021-02-19 02:18:17 +03:00
Evgeny Proydakov
05798c17fb Fixed issues 2496. Used option 4: parse_version.cmake to avoid python3 usage.
https://github.com/KhronosGroup/glslang/issues/2496
2021-02-09 12:14:52 +03:00
Denis Zalevskiy
78dbd7514a Fix option replacement when flags are empty
For the scenario when cmake is executed from MSVC with empty CXX flags.

Signed-off-by: Denis Zalevskiy <denis.zalevskiy@basemark.com>
2021-01-05 15:07:24 +02:00
nihui
967fa92d14
Try to find python interpreter from host first 2020-09-12 11:18:02 +08:00
Julius Ikkala
b357badc02 Obey ENABLE_PCH CMake option 2020-08-21 18:49:17 +03:00
Ben Clayton
2a44064885 Revert changes that migrate to thread_local.
iOS 8 does not support `thread_local`, which is still in use.
Another approach will have to be found.

This change is a revert of the following changes:

a3845240 - "Simplify PoolAlloc with use of thread_local."
abf92c80 - "Deprecate InitializeDll functions"
33585c87 - "Limit visibility of symbols for internal libraries"

Issue: #2346
2020-07-31 07:13:24 +01:00
Ben Clayton
33585c871d Limit visibility of symbols for internal libraries
Also remove `SPIRV/doc.cpp` from the `SPVRemapper` target as this
is part of `SPIRV`, causing ODR violations. Instead have
`SPVRemapper` link against `SPIRV`.

Fixes ODR violations.
2020-07-22 10:53:50 +01:00
Ben Clayton
6b20d83c41 CMake: Move project() to top of CMakeLists.txt
Also remove `NOTICE` from message() about PCHs - it seems to print this in the actual message, contrary to the documentation where it is used as a severity.
2020-07-13 19:14:02 +01:00
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