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

Use CMake's builtin functionality for pre-compiled headers #2327

Merged
merged 1 commit into from
Jul 9, 2020

Conversation

ben-clayton
Copy link
Contributor

@ben-clayton ben-clayton commented Jul 7, 2020

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 / static lib, but fortunately CMake has added first-class support for precompiled headers in 3.16, which does work with the new static libraries.

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.

@ben-clayton
Copy link
Contributor Author

Based on #2326

@ben-clayton ben-clayton marked this pull request as ready for review July 7, 2020 15:09
`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.
@johnkslang
Copy link
Member

@jeffbolznv do you think this new way of doing PCH will work for you?

Anyone: What versions of CMake are used on dev boxes?

Thanks.

@jeffbolznv
Copy link
Contributor

I tried it with Visual Studio and didn't have any problems. It would be good if somebody tried it with ninja + MSVC, I had all sorts of problems trying to get ninja to work with PCH and eventually gave up.

@ben-clayton
Copy link
Contributor Author

It would be good if somebody tried it with ninja + MSVC, I had all sorts of problems trying to get ninja to work with PCH and eventually gave up.

Yes, I believe it does.

Using the Developer Command Prompt for VS 2019:

> cd c:\src\glslang
> mkdir build
> cd build
> cmake .. -GNinja
> ninja
> dir glslang\CMakeFiles\MachineIndependent.dir
 Directory of c:\src\glslang\build\glslang\CMakeFiles\MachineIndependent.dir

08/07/2020  05:00 PM    <DIR>          .
08/07/2020  05:00 PM    <DIR>          ..
06/07/2020  07:52 PM                26 cmake_pch.cxx
08/07/2020  05:00 PM           312,520 cmake_pch.cxx.obj
08/07/2020  05:00 PM        47,382,528 cmake_pch.cxx.pch
06/07/2020  07:52 PM               154 cmake_pch.hxx
06/07/2020  07:52 PM                26 cmake_pch.hxx.cxx
08/07/2020  04:59 PM    <DIR>          Debug
08/07/2020  05:00 PM    <DIR>          HLSL
08/07/2020  05:00 PM    <DIR>          MachineIndependent
08/07/2020  05:00 PM         5,435,392 MachineIndependent.pdb
08/07/2020  04:59 PM    <DIR>          MinSizeRel
08/07/2020  04:59 PM    <DIR>          Release
08/07/2020  04:59 PM    <DIR>          RelWithDebInfo

The builtin CMake integration in VS 2019 by default uses ninja, without issue.

@johnkslang johnkslang merged commit 5aaa0c2 into KhronosGroup:master Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants