ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
6.92k stars 417 forks source link

Set include directories as system header files? #414

Closed vebjornjr closed 2 years ago

vebjornjr commented 2 years ago

Thank you for this nice library.

Would it be possible to set the include directories as system header files?

Here is a resource how libraries may structure their CMakeLists.txt to prevent projects linking to the library getting compiler warnings on includes. In short, the key is to make project include library headers as system includes.

After quickly looking through this project, I think it would be as simple as add SYSTEM before PUBLIC in function(ftxui_set_options library) in ftxui_set_options.cmake.

ArthurSonzogni commented 2 years ago

Thanks! Happy to accept PR toward this direction.

So, we need to turn: https://github.com/ArthurSonzogni/FTXUI/blob/master/cmake/ftxui_set_options.cmake#L18-L24

into:

set(LIBRARY_INCLUDE_DIR
    $<INSTALL_INTERFACE:include>
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_include_directories(${library}
  PUBLIC INTERFACE
    ${LIBRARY_INCLUDE_DIR}
  PRIVATE
    ${LIBRARY_INCLUDE_DIR}
    src
)

?

vebjornjr commented 2 years ago

Not quite, but I opened a PR (#415) now, @ArthurSonzogni.

ArthurSonzogni commented 2 years ago

Thanks!