The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry.
Recently I've stumbled upon a problem while using OpenImageIO via vcpkg on windows, while using clang as my compiler. Vcpkg would build the packages using its default toolchain which means MSVC. This would lead to my user targets inheriting /EHsc flag from OpenEXR and Imath and failing to build with clang.
The problem turned out to be in these lines (and same corresponding lines in config/LibraryDefine.cmake for Imath:
As pointed out to me in https://github.com/microsoft/vcpkg/discussions/38466 using generator expression instead of if fixes the problem. In my local overlay port I simply replaced the if with set(_openexr_extra_flags "$<$<CXX_COMPILER_ID:MSVC>:/EHsc>") which would remove the flag completely for non-msvc compilers (+ the same change for Imath). I'm not sure this is entirely correct in this case and perhaps for other compilers corresponding exception handling flag should be publicly exported instead.
Could you advise on the need for this public compile flag and whether it is possible to fix it upstream?
Hello!
Recently I've stumbled upon a problem while using OpenImageIO via vcpkg on windows, while using clang as my compiler. Vcpkg would build the packages using its default toolchain which means MSVC. This would lead to my user targets inheriting
/EHsc
flag from OpenEXR and Imath and failing to build with clang.The problem turned out to be in these lines (and same corresponding lines in
config/LibraryDefine.cmake
for Imath:https://github.com/AcademySoftwareFoundation/openexr/blob/694606da25571c04bf0cace3e565fbc7ec6aa277/cmake/LibraryDefine.cmake#L12-L14
As pointed out to me in https://github.com/microsoft/vcpkg/discussions/38466 using generator expression instead of
if
fixes the problem. In my local overlay port I simply replaced theif
withset(_openexr_extra_flags "$<$<CXX_COMPILER_ID:MSVC>:/EHsc>")
which would remove the flag completely for non-msvc compilers (+ the same change for Imath). I'm not sure this is entirely correct in this case and perhaps for other compilers corresponding exception handling flag should be publicly exported instead.Could you advise on the need for this public compile flag and whether it is possible to fix it upstream?