Commit 2aa18ca3 authored by Csaba Keszegh's avatar Csaba Keszegh

fix: use CXX_STANDARD when extracting compiler flags for PCH with GNUCXX

When compiling with cmake using -DCMAKE_CXX_STANDARD=11 use `-std=gnu++11`
for PCH compiler flags, otherwise it triggers an error:

   opencv_core_Release.gch: not used because `__cplusplus' defined as ` 201103L' not ` 199711L' [-Winvalid-pch]

Use CXX_EXTENSIONS property to select `gnu++11` or `c++11`.
Trying to mimic cmake logic here: https://gitlab.kitware.com/cmake/cmake/blob/master/Source/cmLocalGenerator.cxx#L1527-1557
parent 9deaddcd
......@@ -56,6 +56,15 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
endforeach()
endif()
GET_TARGET_PROPERTY(_cxx_standard ${_PCH_current_target} CXX_STANDARD)
if (_cxx_standard)
GET_TARGET_PROPERTY(_cxx_extensions ${_PCH_current_target} CXX_EXTENSIONS)
if (_cxx_extensions)
LIST(APPEND ${_out_compile_flags} "${CMAKE_CXX${_cxx_standard}_EXTENSION_COMPILE_OPTION}")
else()
LIST(APPEND ${_out_compile_flags} "${CMAKE_CXX${_cxx_standard}_STANDARD_COMPILE_OPTION}")
endif()
endif()
ELSE()
## TODO ... ? or does it work out of the box
ENDIF()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment