Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Fixes to CMake for MSVC build #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,26 @@ endif()

add_library(json11 json11.cpp)
target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_options(json11
PRIVATE -fPIC -fno-rtti -fno-exceptions -Wall)
if (NOT MSVC)
target_compile_options(json11
PRIVATE -fPIC -fno-rtti -fno-exceptions -Wall)
endif()

# Set warning flags, which may vary per platform
include(CheckCXXCompilerFlag)
set(_possible_warnings_flags /W4 /WX -Wextra -Werror)
set(_possible_warnings_flags /W4 /WX)
#
# Add Wextra & Werror compiler flags only if not building with Microsoft compiler
#
# NOTE:
# check_cxx_compiler_flag() for these flags evaluates to positive result
# but during build, cl.exe fails with following error
# cl : Command line error D8021: invalid numeric argument '/Wextra'
#
if (NOT MSVC)
set(_possible_warnings_flags ${_possible_warnings_flags} -Wextra -Werror)
endif()

foreach(_warning_flag ${_possible_warnings_flags})
unset(_flag_supported)
CHECK_CXX_COMPILER_FLAG(${_warning_flag} _flag_supported)
Expand Down