change compiler flags (#9083)

* [cling][windows] change compiler flags

 - Set the `-std:c++14` / `-std:c++17` flag depending on the version of Visual Studio (only if building outside ROOT)
 - Split the one line exports in three lines to fix a potential issue with Ninja on Windows (missing a white space between each `/EXPORT:` specifier)

* Add a forgotten `endif()`
This commit is contained in:
Bertrand Bellenot 2021-10-07 16:43:41 +02:00 committed by jenkins
parent 027b698255
commit 6a7fc6bdc8
2 changed files with 13 additions and 8 deletions

View File

@ -292,10 +292,16 @@ endif ()
# The package needs to be compiler without RTTI information
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
if(NOT (MSVC_VERSION LESS 1910))
# Add the /std:c++14 flag for Visual Studio 2017 (and up)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -GR-")
if(NOT DEFINED ROOT_BINARY_DIR)
# Add the /std:c++XX flag for Visual Studio if not building as part of ROOT
if(MSVC_VERSION GREATER_EQUAL 1920)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING")
elseif(MSVC_VERSION GREATER_EQUAL 1910)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++14")
endif()
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")

View File

@ -39,8 +39,7 @@ set_target_properties(cling-demo
if(MSVC)
set_target_properties(cling-demo PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
set_property(TARGET cling-demo APPEND_STRING PROPERTY LINK_FLAGS
"/EXPORT:?setValueNoAlloc@internal@runtime@cling@@YAXPEAX00D_K@Z
/EXPORT:?setValueNoAlloc@internal@runtime@cling@@YAXPEAX00DM@Z
/EXPORT:cling_runtime_internal_throwIfInvalidPointer")
set_property(TARGET cling-demo APPEND_STRING PROPERTY LINK_FLAGS " /EXPORT:?setValueNoAlloc@internal@runtime@cling@@YAXPEAX00D_K@Z")
set_property(TARGET cling-demo APPEND_STRING PROPERTY LINK_FLAGS " /EXPORT:?setValueNoAlloc@internal@runtime@cling@@YAXPEAX00DM@Z")
set_property(TARGET cling-demo APPEND_STRING PROPERTY LINK_FLAGS " /EXPORT:cling_runtime_internal_throwIfInvalidPointer")
endif()