Skip to content

Commit

Permalink
Merge pull request #177 from tamatebako/main
Browse files Browse the repository at this point in the history
Fixed MSVC issues with /MT(d) flag propagation
  • Loading branch information
mhx authored Nov 6, 2023
2 parents 6cfce3b + f506169 commit 7026793
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
# dwarfs. If not, see <https://www.gnu.org/licenses/>.
#

cmake_minimum_required(VERSION 3.25.0)

# Enable CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)

project(dwarfs)

include(ExternalProject)

cmake_minimum_required(VERSION 3.25.0)

include(CheckCXXSourceCompiles)

option(WITH_TESTS "build with tests" OFF)
Expand Down Expand Up @@ -95,6 +98,8 @@ endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/Zc:__cplusplus /utf-8 /wd4267 /wd4244 /wd5219)
# Apply /MT or /MTd (multithread, static version of the run-time library)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
Expand Down Expand Up @@ -244,7 +249,6 @@ endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
foreach(CompilerFlag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE)
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
string(REPLACE "/RTC1" "" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()

Expand Down

0 comments on commit 7026793

Please sign in to comment.