Skip to content

Commit

Permalink
build: set gtest_force_shared_crt to true
Browse files Browse the repository at this point in the history
  • Loading branch information
es3n1n committed Oct 9, 2024
1 parent 2cd73fb commit 3ee419e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,20 @@ jobs:
sudo apt-get install -yq --no-install-recommends gcc-13 g++-13 libstdc++-13-dev
- name: Prepare build
if: contains(matrix.os, 'ubuntu')
run: |
if [ "${{ matrix.compiler }}" = "gcc" ]; then
cmake -B build -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCOMMON_BUILD_TESTS=ON -DCMKR_SKIP_GENERATION=ON
elif [ "${{ matrix.compiler }}" = "clang" ]; then
cmake -B build -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCOMMON_BUILD_TESTS=ON -DCMKR_SKIP_GENERATION=ON
else
cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCOMMON_BUILD_TESTS=ON -DCMKR_SKIP_GENERATION=ON
exit 1
fi
- name: Prepare build (Windows)
if: contains(matrix.os, 'windows')
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCOMMON_BUILD_TESTS=ON -DCMKR_SKIP_GENERATION=ON

- name: Build
run: cmake --build build --config ${{ env.BUILD_TYPE }} --parallel

Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ target_include_directories(common INTERFACE
add_library(common-project INTERFACE)

add_library(es3n1n::common::project ALIAS common-project)
target_compile_features(common-project INTERFACE
cxx_std_23
)

if(MSVC) # msvc
target_compile_options(common-project INTERFACE
"/MP"
Expand All @@ -92,12 +96,8 @@ if(UNIX)
# Enforcing libc++ on clang
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$") OR
(CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$")) # clang
target_compile_options(common-project INTERFACE
-stdlib=libc++
)
target_link_libraries(common-project INTERFACE
-stdlib=libc++
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" CACHE STRING "" FORCE)
endif()
endif()

Expand Down
9 changes: 3 additions & 6 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ condition = "common-build-benchmarks"
[target.common-project]
alias = "es3n1n::common::project"
type = "interface"
compile-features = ["cxx_std_23"]
msvc.compile-options = ["/MP"]
cmake-after = """
if(UNIX)
# Enforcing libc++ on clang
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$") OR
(CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$")) # clang
target_compile_options(common-project INTERFACE
-stdlib=libc++
)
target_link_libraries(common-project INTERFACE
-stdlib=libc++
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" CACHE STRING "" FORCE)
endif()
endif()
"""
Expand Down

0 comments on commit 3ee419e

Please sign in to comment.