Use CMake MSVC_RUNTIME_LIBRARY to control MSVC flags

This commit is contained in:
Luke Street 2020-05-27 21:37:03 -04:00
parent 6c52de489f
commit dec27c05ed
3 changed files with 6 additions and 11 deletions

View File

@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
# Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
project(athena)
if (NOT MSVC)
set(CMAKE_CXX_STANDARD 20)

View File

@ -10,13 +10,6 @@ get_directory_property(ATDNA_DEFINES COMPILE_DEFINITIONS)
list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}")
# Force this binary to /MD flags (to make MSVC happy)
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "/MD /Zi /Ob0 /Od /RTC1")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /O2 /Ob2 /DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "/MD /Zi /O2 /Ob1 /DNDEBUG")
endif()
# Find dependencies
include(FindLLVM.cmake)
if(NOT LLVM_FOUND)
@ -147,7 +140,9 @@ set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS
target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS})
target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS})
if(MSVC)
target_compile_options(atdna PRIVATE /GR-)
# Allow linking against release-built LLVM libraries
target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0)
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
else()
target_compile_options(atdna PRIVATE -fno-rtti -Wno-error)
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)

View File

@ -1,7 +1,5 @@
if(NOT WIN32)
find_package(ZLIB)
endif()
if(WIN32 OR NOT ZLIB_FOUND)
if(NOT ZLIB_FOUND)
message(STATUS "Using Athena's built-in zlib")
add_library(z
adler32.c