RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.37k stars 389 forks source link

Fix CMake compile flags definition. #398

Open jdumas opened 2 years ago

jdumas commented 2 years ago

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.

jdumas commented 1 year ago

@svenwoop can we get any feedback on this PR please?