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

Allow PCH builds with 'BUILD_SHARED_LIBS=1' #2901

Open
wants to merge 7 commits into
base: master
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
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019 x86, os: windows-2019, flags: -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2019 x64, os: windows-2019, flags: -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2022 x86, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2022 x64, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2022 ClangCL MSBuild, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -T ClangCL } # ninja doesn't support specifying the toolset, so use the ClangCL toolset to test building with MSBuild as well
- { name: Windows VS2022 OpenGL ES, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -DSFML_OPENGL_ES=ON -GNinja }
- { name: Windows VS2022 Unity, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -DCMAKE_UNITY_BUILD=ON -GNinja }
- { name: Windows LLVM/Clang, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -DCMAKE_CXX_COMPILER=clang++ -GNinja }
- { name: Windows MinGW, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -DCMAKE_CXX_COMPILER=g++ -GNinja }
- { name: Linux GCC, os: ubuntu-22.04, flags: -DSFML_RUN_DISPLAY_TESTS=ON -GNinja }
- { name: Linux Clang, os: ubuntu-22.04, flags: -DCMAKE_CXX_COMPILER=clang++ -DSFML_RUN_DISPLAY_TESTS=ON -GNinja , gcovr_options: '--gcov-executable="llvm-cov-$CLANG_VERSION gcov"' }
- { name: Linux GCC DRM, os: ubuntu-22.04, flags: -DSFML_USE_DRM=ON -DSFML_RUN_DISPLAY_TESTS=OFF -GNinja }
- { name: Linux GCC OpenGL ES, os: ubuntu-22.04, flags: -DSFML_OPENGL_ES=ON -DSFML_RUN_DISPLAY_TESTS=OFF -GNinja }
- { name: Windows VS2019 x86, os: windows-2019, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2019 x64, os: windows-2019, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2022 x86, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2022 x64, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -GNinja }
- { name: Windows VS2022 ClangCL MSBuild, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -T ClangCL } # ninja doesn't support specifying the toolset, so use the ClangCL toolset to test building with MSBuild as well
- { name: Windows VS2022 OpenGL ES, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -DSFML_OPENGL_ES=ON -GNinja }
- { name: Windows VS2022 Unity, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -DCMAKE_UNITY_BUILD=ON -GNinja }
- { name: Windows LLVM/Clang, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -DCMAKE_CXX_COMPILER=clang++ -GNinja }
- { name: Windows MinGW, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_MESA3D=TRUE -DCMAKE_CXX_COMPILER=g++ -GNinja }
- { name: Linux GCC, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_RUN_DISPLAY_TESTS=ON -GNinja }
- { name: Linux Clang, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DCMAKE_CXX_COMPILER=clang++ -DSFML_RUN_DISPLAY_TESTS=ON -GNinja , gcovr_options: '--gcov-executable="llvm-cov-$CLANG_VERSION gcov"' }
- { name: Linux GCC DRM, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_DRM=ON -DSFML_RUN_DISPLAY_TESTS=OFF -GNinja }
- { name: Linux GCC OpenGL ES, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_OPENGL_ES=ON -DSFML_RUN_DISPLAY_TESTS=OFF -GNinja }
- { name: macOS x64, os: macos-12, flags: -GNinja }
- { name: macOS x64 Xcode, os: macos-12, flags: -GXcode }
- { name: macOS arm64, os: macos-14, flags: -GNinja }
Expand Down Expand Up @@ -338,10 +338,10 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows, os: windows-2022, flags: -GNinja }
- { name: Linux, os: ubuntu-22.04 }
- { name: Linux DRM, os: ubuntu-22.04, flags: -DSFML_USE_DRM=TRUE }
- { name: Linux OpenGL ES, os: ubuntu-22.04, flags: -DSFML_OPENGL_ES=ON }
- { name: Windows, os: windows-2022, flags: -DSFML_ENABLE_PCH=1 -GNinja }
- { name: Linux, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 }
- { name: Linux DRM, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_USE_DRM=TRUE }
- { name: Linux OpenGL ES, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_OPENGL_ES=ON }
- { name: macOS, os: macos-12 }
- { name: iOS, os: macos-12, flags: -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 }
- { name: Android, os: ubuntu-22.04, flags: -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DCMAKE_ANDROID_STL_TYPE=c++_shared }
Expand Down Expand Up @@ -386,9 +386,9 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Linux, os: ubuntu-22.04, flags: -DSFML_RUN_DISPLAY_TESTS=ON }
- { name: Linux DRM, os: ubuntu-22.04, flags: -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_USE_DRM=ON }
- { name: Linux GCC OpenGL ES, os: ubuntu-22.04, flags: -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_OPENGL_ES=ON }
- { name: Linux, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_RUN_DISPLAY_TESTS=ON }
- { name: Linux DRM, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_USE_DRM=ON }
- { name: Linux GCC OpenGL ES, os: ubuntu-22.04, flags: -DSFML_ENABLE_PCH=1 -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_OPENGL_ES=ON }

steps:
- name: Checkout Code
Expand Down
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")

if(SFML_ENABLE_PCH AND BUILD_SHARED_LIBS)
# required to make the PCH consistent between all targets
# must appear before subdirectories are addded to take effect
add_definitions(-DSFML_SYSTEM_EXPORTS)

if(MSVC)
add_definitions(-D_WINDLL)
endif()
endif()

# add the subdirectories
add_subdirectory(src/SFML)

Expand Down Expand Up @@ -247,10 +257,6 @@ endif()
# option to enable precompiled headers
sfml_set_option(SFML_ENABLE_PCH FALSE BOOL "TRUE to enable precompiled headers for SFML builds -- only supported on Windows/Linux and for static library builds")

if(SFML_ENABLE_PCH AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "Precompiled headers are currently not supported for shared library builds")
endif()

if(SFML_ENABLE_PCH AND SFML_OS_MACOS)
message(FATAL_ERROR "Precompiled headers are currently not supported in macOS builds")
endif()
Expand Down