nanogui
nanogui copied to clipboard
propagate libcxx flags to CMake consumers
With clang, I think it would be nice to propagate the usage flags for libcxx. It enables a consuming project to do this:
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(nanogui-package-test)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(nanogui CONFIG REQUIRED)
add_executable(example2 example2.cpp) # copied from nanogui
target_link_libraries(example2 PUBLIC nanogui)
Since nanogui will put these flags in automatically, it ends up being a usage requirement and currently the consumer needs to manually add back the libcxx flags from nanogui's CMakeLists.txt somehow.
An alternative would be to just set a variable in the package config file to at least make the flags that were used available to consumers if forcing it on the target seems like a bad idea for some reason.
Will likely create merge conflict with #104 so will rebase one or the other, both together were needed for me to use nanogui externally, I can't compile with gcc 11 on fedora for reasons that don't seem related to this project at all (something about missing attributes in X11 headers...). AKA I've tested this locally, but additional testing would be a good idea (especially on mac).