Skip to content

Commit

Permalink
update(cmake): Use the static CRT on Windows by default
Browse files Browse the repository at this point in the history
Set CMAKE_MSVC_RUNTIME_LIBRARY to "MultiThreaded" unless it was set
externally or if we're building shared libs. This

- uses CMake's documented variable to control CRT linking.
- ensures that we use the static CRT by default.
- allows the CRT setting to be overridden.

Add a Windows shared CRT CI job.

Signed-off-by: Gerald Combs <gerald@wireshark.org>
  • Loading branch information
geraldcombs committed Feb 15, 2024
1 parent 3b8e4f1 commit ac13242
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
os: [windows-latest]
crt: [MultiThreaded, MultiThreadedDLL]
include:
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Libs ⤵️
Expand All @@ -171,7 +174,7 @@ jobs:
- name: Build and test 🏗️🧪
run: |
mkdir -p build
cd build && cmake -DUSE_BUNDLED_DEPS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCREATE_TEST_TARGETS=ON -DMINIMAL_BUILD=ON ..
cd build && cmake -DUSE_BUNDLED_DEPS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=${{ matrix.crt }} -DCREATE_TEST_TARGETS=ON -DMINIMAL_BUILD=ON ..
cmake --build . --config Release && make run-unit-tests || libsinsp\test\Release\unit-test-libsinsp.exe
build-shared-libs-macos-amd64:
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()

# Enable CMAKE_MSVC_RUNTIME_LIBRARY on Windows + CMake >= 3.15
# Enable CMAKE_MSVC_RUNTIME_LIBRARY on Windows + CMake >= 3.15 and link
# with the static (MultiThreaded) CRT unless instructed otherwise.
if(NOT (CMAKE_MSVC_RUNTIME_LIBRARY OR BUILD_SHARED_LIBS))
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
Expand Down

0 comments on commit ac13242

Please sign in to comment.