When building embree as a subproject (via add_subdirectory()) and as a static library on Windows, I do get a bunch of errors of the sort:
error LNK2019: unresolved external symbol __imp_rtcNewDevice referenced in function XXX
This is because the compile flag EMBREE_STATIC_LIB is only defined for embree files (such as rtcore.cpp), but is NOT propagated transitively to downstream targets. The reason is that Embree's CMake uses the deprecated construct add_definitions(), which adds flags to a folder property. The modern CMake way to do this is to work with target properties instead, attaching compile flags to targets and properly express which ones should be transitively propagated (PUBLIC or INTERFACE properties).
This PR remedies this shortcoming by attaching all compilation flags to a new INTERFACE target embree_config, which will properly propagate the information to downstream targets.
When building embree as a subproject (via
add_subdirectory()
) and as a static library on Windows, I do get a bunch of errors of the sort:This is because the compile flag
EMBREE_STATIC_LIB
is only defined for embree files (such asrtcore.cpp
), but is NOT propagated transitively to downstream targets. The reason is that Embree's CMake uses the deprecated constructadd_definitions()
, which adds flags to a folder property. The modern CMake way to do this is to work with target properties instead, attaching compile flags to targets and properly express which ones should be transitively propagated (PUBLIC
orINTERFACE
properties).This PR remedies this shortcoming by attaching all compilation flags to a new
INTERFACE
targetembree_config
, which will properly propagate the information to downstream targets.