mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 01:24:08 +00:00
Add option 'MSVC_STATIC' (#6358)
* Add option 'MSVC_STATIC' * Update CMakeLists.txt * Update CMakeLists.txt * Upload msvc-static-build.yml
This commit is contained in:
parent
00cf5ed4c7
commit
b0d0c36b11
20
.github/workflows/msvc-static-build.yml
vendored
Normal file
20
.github/workflows/msvc-static-build.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
name: MSVC Static Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-2019
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DZ3_BUILD_LIBZ3_SHARED=OFF -DZ3_BUILD_LIBZ3_MSVC_STATIC=ON
|
||||
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel
|
||||
|
|
@ -304,6 +304,7 @@ endif()
|
|||
# Option to control what type of library we build
|
||||
################################################################################
|
||||
option(Z3_BUILD_LIBZ3_SHARED "Build libz3 as a shared library if true, otherwise build a static library" ON)
|
||||
option(Z3_BUILD_LIBZ3_MSVC_STATIC "Build libz3 as a statically-linked runtime library" OFF)
|
||||
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -115,6 +115,27 @@ if (Z3_BUILD_LIBZ3_SHARED)
|
|||
else()
|
||||
set(lib_type "STATIC")
|
||||
endif()
|
||||
# Enable static msvc runtime.
|
||||
if (MSVC AND Z3_BUILD_LIBZ3_MSVC_STATIC)
|
||||
set(CompilerFlags
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
)
|
||||
foreach(CompilerFlag ${CompilerFlags})
|
||||
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
||||
string(REPLACE "/MDd" "/MTd" ${CompilerFlag} "${${CompilerFlag}}")
|
||||
set(${CompilerFlag} "${${CompilerFlag}}" CACHE STRING "msvc compiler flags" FORCE)
|
||||
message("MSVC flags: ${CompilerFlag}:${${CompilerFlag}}")
|
||||
endforeach()
|
||||
endif(MSVC)
|
||||
add_library(libz3 ${lib_type} ${object_files})
|
||||
target_include_directories(libz3 INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api>
|
||||
|
|
Loading…
Reference in a new issue