@@ -27,19 +27,34 @@ function(ftxui_set_options library)
2727 PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE} ;-warnings-as-errors=*"
2828 )
2929
30- # By using "PUBLIC" as opposed to "SYSTEM INTERFACE", the compiler warning
31- # are enforced on the headers. This is behind "FTXUI_CLANG_TIDY", so that it
32- # applies only when developing FTXUI and on the CI. User's of the library
33- # get only the SYSTEM INTERFACE instead.
30+ # By using "PUBLIC" as opposed to "INTERFACE", the compiler warnings are
31+ # enforced on the headers. This is behind "FTXUI_CLANG_TIDY", so that it
32+ # applies only when developing FTXUI and on the CI. Users of the library
33+ # get only the plain INTERFACE instead.
3434 target_include_directories (${library}
3535 PUBLIC
3636 $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } /include >
3737 )
3838 else ()
39- target_include_directories (${library} SYSTEM
40- INTERFACE
41- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } /include >
42- )
39+ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME )
40+ # Building FTXUI as a standalone project. Do NOT mark as SYSTEM: if
41+ # a sibling FTXUI target (e.g. dom depending on screen) inherits this
42+ # path via INTERFACE_SYSTEM_INCLUDE_DIRECTORIES, CMake demotes the
43+ # private -I to -isystem. That path is then searched *after* any -I
44+ # added by a package manager (e.g. MacPorts' -I/opt/local/include),
45+ # letting a stale installed FTXUI shadow the sources being built.
46+ target_include_directories (${library}
47+ INTERFACE
48+ $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } /include >
49+ )
50+ else ()
51+ # Consumed via add_subdirectory / FetchContent: keep SYSTEM so that
52+ # consumers do not receive warnings from FTXUI headers.
53+ target_include_directories (${library} SYSTEM
54+ INTERFACE
55+ $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } /include >
56+ )
57+ endif ()
4358 endif ()
4459
4560 target_include_directories (${library} SYSTEM
0 commit comments