This should allow downstream to automatically use the correct compile and linke flags for CMake > 3.9. For older versions we fall back to the old approach. Closes #1751