Skip to content

Commit

Permalink
fix for mismatched runtime library when building static libs with MSVC (
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnwnd authored and guillaumekln committed Oct 21, 2019
1 parent c2dd9e8 commit 161d272
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
cmake_minimum_required(VERSION 3.1.0)

# Set policy for setting the MSVC runtime library for static MSVC builds
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

project(OpenNMTTokenizer)

option(WITH_ICU "Compile with ICU" OFF)
Expand All @@ -8,7 +14,13 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
if(NOT BUILD_SHARED_LIBS)
if(CMAKE_VERSION VERSION_LESS "3.15.0")
message(FATAL_ERROR "Use CMake 3.15 or later when setting BUILD_SHARED_LIBS to OFF")
endif()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()
Expand Down

0 comments on commit 161d272

Please sign in to comment.