2023-01-15 03:37:42 +08:00
|
|
|
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable" )
|
2022-03-31 08:17:43 +08:00
|
|
|
|
2021-06-26 21:14:27 +08:00
|
|
|
function(ftxui_set_options library)
|
2023-01-15 03:37:42 +08:00
|
|
|
set_target_properties(${library} PROPERTIES VERSION ${PROJECT_VERSION})
|
|
|
|
if (NOT ${library} MATCHES "ftxui-*")
|
|
|
|
set_target_properties(${library} PROPERTIES OUTPUT_NAME "ftxui-${library}")
|
|
|
|
endif()
|
2021-07-06 08:10:35 +08:00
|
|
|
|
2023-06-04 20:35:08 +08:00
|
|
|
if (FTXUI_CLANG_TIDY)
|
|
|
|
if (NOT CLANG_TIDY_EXE)
|
|
|
|
message(FATAL_ERROR "clang-tidy requested but executable not found")
|
|
|
|
endif()
|
|
|
|
|
2022-03-31 08:17:43 +08:00
|
|
|
set_target_properties(${library}
|
|
|
|
PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-warnings-as-errors=*"
|
|
|
|
)
|
2022-06-12 00:39:07 +08:00
|
|
|
|
|
|
|
# By using "PUBLIC" as opposed to "SYSTEM INTERFACE", the compiler warning
|
|
|
|
# are enforced on the headers. This is behind "FTXUI_CLANG_TIDY", so that it
|
|
|
|
# applies only when developing FTXUI and on the CI. User's of the library
|
|
|
|
# get only the SYSTEM INTERFACE instead.
|
|
|
|
target_include_directories(${library}
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
target_include_directories(${library} SYSTEM
|
|
|
|
INTERFACE
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
)
|
2022-03-31 08:17:43 +08:00
|
|
|
endif()
|
2021-07-06 08:10:35 +08:00
|
|
|
|
2022-06-12 00:39:07 +08:00
|
|
|
target_include_directories(${library} SYSTEM
|
|
|
|
INTERFACE
|
2021-06-26 21:14:27 +08:00
|
|
|
$<INSTALL_INTERFACE:include>
|
2022-06-12 00:39:07 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(${library}
|
2021-06-26 21:14:27 +08:00
|
|
|
PRIVATE
|
2022-06-12 00:39:07 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
2021-06-26 21:14:27 +08:00
|
|
|
)
|
|
|
|
|
2023-05-26 01:34:34 +08:00
|
|
|
target_compile_features(${library} PUBLIC cxx_std_17)
|
2021-06-26 21:14:27 +08:00
|
|
|
|
|
|
|
# Force Microsoft Visual Studio to decode sources files in UTF-8. This applies
|
|
|
|
# to the library and the library users.
|
2024-01-08 14:05:41 +08:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
2021-06-26 21:14:27 +08:00
|
|
|
target_compile_options(${library} PUBLIC "/utf-8")
|
|
|
|
endif()
|
|
|
|
|
2024-08-08 19:26:55 +08:00
|
|
|
if(UNIX)
|
|
|
|
target_compile_options(${library} PRIVATE "-fPIC")
|
|
|
|
endif()
|
|
|
|
|
2021-06-26 21:14:27 +08:00
|
|
|
# Add as many warning as possible:
|
|
|
|
if (WIN32)
|
|
|
|
if (MSVC)
|
2023-05-23 20:38:49 +08:00
|
|
|
if(FTXUI_DEV_WARNINGS)
|
|
|
|
target_compile_options(${library} PRIVATE "/W3")
|
|
|
|
target_compile_options(${library} PRIVATE "/WX")
|
|
|
|
endif()
|
2021-06-26 21:14:27 +08:00
|
|
|
target_compile_options(${library} PRIVATE "/wd4244")
|
|
|
|
target_compile_options(${library} PRIVATE "/wd4267")
|
|
|
|
target_compile_options(${library} PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
|
|
|
|
endif()
|
|
|
|
# Force Win32 to UNICODE
|
|
|
|
target_compile_definitions(${library} PRIVATE UNICODE _UNICODE)
|
|
|
|
else()
|
2023-05-23 20:38:49 +08:00
|
|
|
if(FTXUI_DEV_WARNINGS)
|
|
|
|
target_compile_options(${library} PRIVATE "-Wall")
|
|
|
|
target_compile_options(${library} PRIVATE "-Werror")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wextra")
|
|
|
|
|
|
|
|
target_compile_options(${library} PRIVATE "-Wcast-align")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wdeprecated")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wmissing-declarations")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wnon-virtual-dtor")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wnull-dereference")
|
|
|
|
target_compile_options(${library} PRIVATE "-Woverloaded-virtual")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wpedantic")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wshadow")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wunused")
|
2023-08-19 17:20:04 +08:00
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
target_compile_options(${library} PRIVATE "-Wuseless-cast")
|
|
|
|
endif()
|
2023-05-23 20:38:49 +08:00
|
|
|
endif()
|
2023-03-31 23:13:48 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2023-05-23 20:38:49 +08:00
|
|
|
if(FTXUI_DEV_WARNINGS)
|
|
|
|
target_compile_options(${library} PRIVATE "-Wdocumentation")
|
|
|
|
endif()
|
2021-06-26 21:14:27 +08:00
|
|
|
endif()
|
2021-07-04 23:38:31 +08:00
|
|
|
|
2023-03-31 23:13:48 +08:00
|
|
|
|
2021-07-04 23:38:31 +08:00
|
|
|
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
|
|
|
target_compile_definitions(${library}
|
|
|
|
PRIVATE "FTXUI_MICROSOFT_TERMINAL_FALLBACK")
|
|
|
|
endif()
|
2021-06-26 21:14:27 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if (EMSCRIPTEN)
|
|
|
|
string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
|
2021-07-26 01:31:45 +08:00
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s ASYNCIFY")
|
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s PROXY_TO_PTHREAD")
|
2021-06-26 21:14:27 +08:00
|
|
|
endif()
|