From 962e6ed972fb7e8f4a65db213f85e6e5fc97b858 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 13 Aug 2023 17:50:13 -0600 Subject: [PATCH] Default to building static libraries See https://github.com/SFML/SFML/issues/2389 for full rationale --- .github/workflows/ci.yml | 6 +++--- CMakeLists.txt | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47945da6..f6611dca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: config: { name: OpenGL ES, flags: -DSFML_USE_MESA3D=TRUE -DBUILD_SHARED_LIBS=TRUE -DSFML_OPENGL_ES=ON } type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE } - platform: { name: Windows MinGW, os: windows-2022 } - config: { name: Static Standard Libraries, flags: -GNinja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_STATIC_STD_LIBS=TRUE } + config: { name: Static Standard Libraries, flags: -GNinja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DSFML_USE_STATIC_STD_LIBS=TRUE } - platform: { name: macOS, os: macos-12 } config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE } - platform: { name: Android, os: ubuntu-22.04 } @@ -72,7 +72,7 @@ jobs: - platform: { name: Android, os: ubuntu-22.04 } config: { name: x86_64, flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/android-ndk-r23b/build/cmake/android.toolchain.cmake -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r23b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 -DANDROID_PLATFORM=26 } - platform: { name: Linux GCC, os: ubuntu-22.04 } - config: { name: Static DRM, flags: -GNinja -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_DRM=TRUE -DSFML_RUN_DISPLAY_TESTS=FALSE } + config: { name: Static DRM, flags: -GNinja -DSFML_USE_DRM=TRUE -DSFML_RUN_DISPLAY_TESTS=FALSE } - platform: { name: Linux GCC, os: ubuntu-22.04 } config: { name: Shared DRM, flags: -GNinja -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_DRM=TRUE -DSFML_RUN_DISPLAY_TESTS=FALSE } - platform: { name: macOS , os: macos-12 } @@ -272,7 +272,7 @@ jobs: - name: Configure shell: bash - run: cmake --preset dev -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_UNITY_BUILD=ON ${{matrix.platform.flags}} + run: cmake --preset dev -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_UNITY_BUILD=ON ${{matrix.platform.flags}} - name: Analyze Code shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 9902cb4d..52e9425e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,10 +34,8 @@ include(cmake/Config.cmake) # https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html include(GNUInstallDirs) -# add an option for choosing the build type (shared or static) -if(NOT SFML_OS_ANDROID) - sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries") -else() +# disable static libraries on Android +if(SFML_OS_ANDROID) set(BUILD_SHARED_LIBS TRUE) endif()