2021-06-26 06:08:21 +08:00
|
|
|
cmake_minimum_required(VERSION 3.11)
|
2020-08-09 20:53:56 +08:00
|
|
|
|
2020-11-22 20:23:01 +08:00
|
|
|
find_package(Git QUIET)
|
2021-06-17 18:54:26 +08:00
|
|
|
if (Git_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
2020-11-22 20:23:01 +08:00
|
|
|
message("git found")
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE git_version
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(git_version 0)
|
|
|
|
endif()
|
2020-08-09 20:53:56 +08:00
|
|
|
|
2019-01-07 01:53:02 +08:00
|
|
|
project(ftxui
|
|
|
|
LANGUAGES CXX
|
2021-05-27 22:04:46 +08:00
|
|
|
VERSION 0.6.${git_version}
|
2019-01-07 01:53:02 +08:00
|
|
|
)
|
2019-01-03 07:35:59 +08:00
|
|
|
|
2021-06-18 05:07:26 +08:00
|
|
|
option(FTXUI_BUILD_DOCS "Set to ON to build tests" ON)
|
2020-02-11 21:04:23 +08:00
|
|
|
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" ON)
|
2020-04-17 05:20:04 +08:00
|
|
|
option(FTXUI_BUILD_TESTS "Set to ON to build tests" OFF)
|
2021-06-18 05:07:26 +08:00
|
|
|
option(FTXUI_BUILD_TESTS_FUZZER "Set to ON to enable fuzzing" OFF)
|
|
|
|
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
|
2018-09-18 14:48:40 +08:00
|
|
|
|
2019-02-02 08:59:48 +08:00
|
|
|
find_package(Threads)
|
|
|
|
|
2021-05-16 17:59:20 +08:00
|
|
|
add_library(screen STATIC
|
2019-02-02 08:59:48 +08:00
|
|
|
src/ftxui/screen/box.cpp
|
2020-09-02 17:32:22 +08:00
|
|
|
src/ftxui/screen/color.cpp
|
2020-09-06 19:43:24 +08:00
|
|
|
src/ftxui/screen/color_info.cpp
|
2019-02-02 08:59:48 +08:00
|
|
|
src/ftxui/screen/screen.cpp
|
|
|
|
src/ftxui/screen/string.cpp
|
|
|
|
src/ftxui/screen/terminal.cpp
|
2019-06-25 05:39:37 +08:00
|
|
|
src/ftxui/screen/wcwidth.cpp
|
2020-03-25 06:26:55 +08:00
|
|
|
include/ftxui/screen/box.hpp
|
|
|
|
include/ftxui/screen/color.hpp
|
2020-09-06 19:43:24 +08:00
|
|
|
include/ftxui/screen/color_info.hpp
|
2020-03-25 06:26:55 +08:00
|
|
|
include/ftxui/screen/screen.hpp
|
|
|
|
include/ftxui/screen/string.hpp
|
2019-02-02 08:59:48 +08:00
|
|
|
)
|
|
|
|
|
2021-05-16 17:59:20 +08:00
|
|
|
add_library(dom STATIC
|
2020-03-25 06:26:55 +08:00
|
|
|
include/ftxui/dom/elements.hpp
|
|
|
|
include/ftxui/dom/node.hpp
|
|
|
|
include/ftxui/dom/requirement.hpp
|
|
|
|
include/ftxui/dom/take_any_args.hpp
|
2019-02-02 08:59:48 +08:00
|
|
|
src/ftxui/dom/blink.cpp
|
|
|
|
src/ftxui/dom/bold.cpp
|
|
|
|
src/ftxui/dom/border.cpp
|
2020-08-26 23:58:18 +08:00
|
|
|
src/ftxui/dom/clear_under.cpp
|
2019-02-02 08:59:48 +08:00
|
|
|
src/ftxui/dom/color.cpp
|
|
|
|
src/ftxui/dom/composite_decorator.cpp
|
|
|
|
src/ftxui/dom/dbox.cpp
|
|
|
|
src/ftxui/dom/dim.cpp
|
|
|
|
src/ftxui/dom/flex.cpp
|
|
|
|
src/ftxui/dom/frame.cpp
|
|
|
|
src/ftxui/dom/gauge.cpp
|
|
|
|
src/ftxui/dom/graph.cpp
|
|
|
|
src/ftxui/dom/hbox.cpp
|
|
|
|
src/ftxui/dom/hflow.cpp
|
|
|
|
src/ftxui/dom/inverted.cpp
|
|
|
|
src/ftxui/dom/node.cpp
|
|
|
|
src/ftxui/dom/node_decorator.cpp
|
|
|
|
src/ftxui/dom/paragraph.cpp
|
2021-04-19 04:33:41 +08:00
|
|
|
src/ftxui/dom/reflect.cpp
|
2019-02-02 08:59:48 +08:00
|
|
|
src/ftxui/dom/separator.cpp
|
|
|
|
src/ftxui/dom/size.cpp
|
|
|
|
src/ftxui/dom/spinner.cpp
|
|
|
|
src/ftxui/dom/text.cpp
|
|
|
|
src/ftxui/dom/underlined.cpp
|
|
|
|
src/ftxui/dom/util.cpp
|
|
|
|
src/ftxui/dom/vbox.cpp
|
|
|
|
)
|
|
|
|
|
2021-05-16 17:59:20 +08:00
|
|
|
add_library(component STATIC
|
2020-08-26 22:26:09 +08:00
|
|
|
include/ftxui/component/button.hpp
|
2021-05-02 00:13:56 +08:00
|
|
|
include/ftxui/component/captured_mouse.hpp
|
2020-08-26 22:26:09 +08:00
|
|
|
include/ftxui/component/checkbox.hpp
|
|
|
|
include/ftxui/component/component.hpp
|
2021-05-10 02:32:27 +08:00
|
|
|
include/ftxui/component/component_base.hpp
|
2020-08-26 22:26:09 +08:00
|
|
|
include/ftxui/component/container.hpp
|
|
|
|
include/ftxui/component/event.hpp
|
|
|
|
include/ftxui/component/input.hpp
|
|
|
|
include/ftxui/component/menu.hpp
|
2021-04-25 21:22:38 +08:00
|
|
|
include/ftxui/component/mouse.hpp
|
2020-08-26 22:26:09 +08:00
|
|
|
include/ftxui/component/radiobox.hpp
|
|
|
|
include/ftxui/component/receiver.hpp
|
|
|
|
include/ftxui/component/screen_interactive.hpp
|
|
|
|
include/ftxui/component/toggle.hpp
|
|
|
|
src/ftxui/component/button.cpp
|
2021-05-23 18:53:20 +08:00
|
|
|
src/ftxui/component/catch_event.cpp
|
2019-02-02 08:59:48 +08:00
|
|
|
src/ftxui/component/checkbox.cpp
|
|
|
|
src/ftxui/component/component.cpp
|
|
|
|
src/ftxui/component/container.cpp
|
|
|
|
src/ftxui/component/event.cpp
|
|
|
|
src/ftxui/component/input.cpp
|
|
|
|
src/ftxui/component/menu.cpp
|
|
|
|
src/ftxui/component/radiobox.cpp
|
2020-03-27 06:15:52 +08:00
|
|
|
src/ftxui/component/radiobox.cpp
|
2021-05-13 17:44:47 +08:00
|
|
|
src/ftxui/component/renderer.cpp
|
2021-05-27 21:22:53 +08:00
|
|
|
src/ftxui/component/resizable_split.cpp
|
2019-02-02 08:59:48 +08:00
|
|
|
src/ftxui/component/screen_interactive.cpp
|
2021-04-29 06:18:58 +08:00
|
|
|
src/ftxui/component/slider.cpp
|
2020-10-25 07:57:56 +08:00
|
|
|
src/ftxui/component/terminal_input_parser.cpp
|
|
|
|
src/ftxui/component/terminal_input_parser.hpp
|
2021-04-29 06:18:58 +08:00
|
|
|
src/ftxui/component/toggle.cpp
|
2019-02-02 08:59:48 +08:00
|
|
|
)
|
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
add_library(ftxui::screen ALIAS screen)
|
|
|
|
add_library(ftxui::dom ALIAS dom)
|
|
|
|
add_library(ftxui::component ALIAS component)
|
|
|
|
|
2019-02-02 08:59:48 +08:00
|
|
|
target_link_libraries(dom PUBLIC screen)
|
2020-02-16 03:41:44 +08:00
|
|
|
target_link_libraries(component PUBLIC dom Threads::Threads)
|
2021-05-02 02:40:35 +08:00
|
|
|
find_program(iwyu_path NAMES include-what-you-use iwyu)
|
|
|
|
if(iwyu_path)
|
|
|
|
set_property(TARGET ${lib}
|
|
|
|
PROPERTY ${iwyu_path} -Xiwyu
|
|
|
|
--mapping_file ${CMAKE_CURRENT_SOURCE_DIR}/iwyu.impl
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2019-02-02 08:59:48 +08:00
|
|
|
|
|
|
|
foreach(lib screen dom component)
|
|
|
|
target_include_directories(${lib}
|
|
|
|
PUBLIC
|
2020-03-21 23:13:14 +08:00
|
|
|
$<INSTALL_INTERFACE:include>
|
2019-02-02 08:59:48 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
2020-03-23 05:32:44 +08:00
|
|
|
PRIVATE
|
|
|
|
src
|
2019-02-02 08:59:48 +08:00
|
|
|
)
|
2020-03-21 23:13:14 +08:00
|
|
|
|
|
|
|
# C++17 is used. We requires fold expression at least.
|
2020-03-23 04:01:44 +08:00
|
|
|
set_property(TARGET ${lib} PROPERTY CXX_STANDARD 17)
|
2020-03-21 23:13:14 +08:00
|
|
|
|
|
|
|
# Force Microsoft Visual Studio to decode sources files in UTF-8. This applies
|
|
|
|
# to the library and the library users.
|
|
|
|
if (MSVC)
|
2020-03-24 05:48:27 +08:00
|
|
|
target_compile_options(${lib} PUBLIC "/utf-8")
|
2020-03-21 23:13:14 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Add as many warning as possible:
|
2020-07-17 02:58:58 +08:00
|
|
|
if (WIN32)
|
|
|
|
if (MSVC)
|
2021-03-22 17:31:35 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "/W3")
|
2020-07-17 02:58:58 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "/WX")
|
|
|
|
target_compile_options(${lib} PRIVATE "/wd4244")
|
|
|
|
target_compile_options(${lib} PRIVATE "/wd4267")
|
2020-09-02 17:32:22 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
|
2020-07-17 02:58:58 +08:00
|
|
|
endif()
|
|
|
|
# Force Win32 to UNICODE
|
|
|
|
target_compile_definitions(${lib} PRIVATE UNICODE _UNICODE)
|
2020-03-21 23:13:14 +08:00
|
|
|
else()
|
|
|
|
target_compile_options(${lib} PRIVATE "-Wall")
|
|
|
|
target_compile_options(${lib} PRIVATE "-Wextra")
|
|
|
|
target_compile_options(${lib} PRIVATE "-pedantic")
|
|
|
|
target_compile_options(${lib} PRIVATE "-Werror")
|
2021-02-11 07:45:42 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "-Wmissing-declarations")
|
2021-05-16 15:57:55 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "-Wdeprecated")
|
2021-05-17 04:42:22 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "-Wshadow")
|
2020-03-21 23:13:14 +08:00
|
|
|
endif()
|
2020-03-25 08:38:50 +08:00
|
|
|
|
2019-02-02 08:59:48 +08:00
|
|
|
endforeach()
|
|
|
|
|
2021-03-22 05:54:39 +08:00
|
|
|
if (EMSCRIPTEN)
|
|
|
|
#string(APPEND CMAKE_CXX_FLAGS " -s ASSERTIONS=1")
|
|
|
|
string(APPEND CMAKE_CXX_FLAGS " -s ASYNCIFY")
|
|
|
|
string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
|
|
|
|
string(APPEND CMAKE_CXX_FLAGS " -s PROXY_TO_PTHREAD")
|
|
|
|
endif()
|
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
if(FTXUI_ENABLE_INSTALL)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
install(TARGETS screen dom component
|
|
|
|
EXPORT ftxui-export
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/
|
|
|
|
)
|
2019-02-02 08:59:48 +08:00
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
install(DIRECTORY include/ftxui DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2019-02-02 08:59:48 +08:00
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
include(CMakePackageConfigHelpers)
|
2020-10-17 04:07:30 +08:00
|
|
|
configure_package_config_file(ftxui-config.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/ftxui-config.cmake
|
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/cmake
|
|
|
|
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
|
|
|
|
)
|
2020-02-11 21:04:23 +08:00
|
|
|
write_basic_package_version_file(
|
2020-10-17 04:07:30 +08:00
|
|
|
ftxui-config-version.cmake
|
2020-02-11 21:04:23 +08:00
|
|
|
VERSION ${PACKAGE_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion
|
|
|
|
)
|
2019-02-02 08:59:48 +08:00
|
|
|
|
2020-10-17 04:07:30 +08:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ftxui-config.cmake
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
|
|
|
)
|
2020-02-11 21:04:23 +08:00
|
|
|
install(EXPORT ftxui-export
|
2020-10-17 04:07:30 +08:00
|
|
|
FILE ftxui-config-version.cmake
|
|
|
|
NAMESPACE ftxui::
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
2020-02-11 21:04:23 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
export(TARGETS screen dom component NAMESPACE ftxui::
|
|
|
|
FILE ${PROJECT_BINARY_DIR}/ftxui-targets.cmake)
|
2019-02-02 08:59:48 +08:00
|
|
|
|
2020-04-17 05:20:04 +08:00
|
|
|
|
2020-09-02 17:32:22 +08:00
|
|
|
if (FTXUI_BUILD_TESTS AND ${CMAKE_VERSION} VERSION_GREATER "3.11.4")
|
2021-06-18 05:07:26 +08:00
|
|
|
enable_testing()
|
2020-04-17 05:36:37 +08:00
|
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
|
|
|
2020-04-17 05:20:04 +08:00
|
|
|
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
|
|
|
|
include(FetchContent)
|
|
|
|
|
2020-04-17 05:36:37 +08:00
|
|
|
FetchContent_Declare( googletest
|
|
|
|
GIT_REPOSITORY "https://github.com/google/googletest"
|
2021-04-25 23:28:16 +08:00
|
|
|
GIT_TAG 23ef29555ef4789f555f1ba8c51b4c52975f0907
|
2020-04-17 05:20:04 +08:00
|
|
|
)
|
2021-06-26 06:08:21 +08:00
|
|
|
FetchContent_MakeAvailable(googletest)
|
2020-04-17 05:20:04 +08:00
|
|
|
|
2020-03-27 05:55:59 +08:00
|
|
|
add_executable(tests
|
2021-06-22 04:49:42 +08:00
|
|
|
src/ftxui/component/component_test.cpp
|
2020-03-27 06:33:55 +08:00
|
|
|
src/ftxui/component/container_test.cpp
|
2021-03-29 00:14:43 +08:00
|
|
|
src/ftxui/component/input_test.cpp
|
2020-07-24 02:41:25 +08:00
|
|
|
src/ftxui/component/radiobox_test.cpp
|
2020-03-27 07:22:04 +08:00
|
|
|
src/ftxui/component/receiver_test.cpp
|
2021-06-26 06:42:08 +08:00
|
|
|
src/ftxui/component/screen_interactive_test.cpp
|
2021-03-29 00:14:43 +08:00
|
|
|
src/ftxui/component/terminal_input_parser_test.cpp
|
2020-07-24 02:41:25 +08:00
|
|
|
src/ftxui/component/toggle_test.cpp
|
2020-03-27 05:55:59 +08:00
|
|
|
src/ftxui/dom/gauge_test.cpp
|
|
|
|
src/ftxui/dom/hbox_test.cpp
|
|
|
|
src/ftxui/dom/text_test.cpp
|
|
|
|
src/ftxui/dom/vbox_test.cpp
|
2019-02-02 08:59:48 +08:00
|
|
|
)
|
|
|
|
|
2020-03-27 05:55:59 +08:00
|
|
|
target_link_libraries(tests
|
2020-03-27 06:12:42 +08:00
|
|
|
PRIVATE component
|
2020-04-17 05:36:37 +08:00
|
|
|
PRIVATE gtest
|
|
|
|
PRIVATE gmock
|
|
|
|
PRIVATE gtest_main
|
2019-02-02 08:59:48 +08:00
|
|
|
)
|
2020-10-25 07:57:56 +08:00
|
|
|
target_include_directories(tests
|
|
|
|
PRIVATE src
|
|
|
|
)
|
2021-06-22 04:49:42 +08:00
|
|
|
target_compile_options(tests PRIVATE -fsanitize=address)
|
|
|
|
target_link_libraries(tests PRIVATE -fsanitize=address)
|
2020-03-27 05:55:59 +08:00
|
|
|
set_property(TARGET tests PROPERTY CXX_STANDARD 17)
|
2021-06-18 05:07:26 +08:00
|
|
|
|
2021-06-26 06:08:21 +08:00
|
|
|
if (NOT MSVC)
|
|
|
|
FetchContent_Declare(googlebenchmark
|
|
|
|
GIT_REPOSITORY "https://github.com/google/benchmark"
|
|
|
|
GIT_TAG 62937f91b5c763a8e119d0c20c67b87bde8eff1c
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(googlebenchmark)
|
|
|
|
|
|
|
|
add_executable(ftxui_benchmark
|
|
|
|
src/ftxui/dom/benchmark_test.cpp
|
|
|
|
)
|
|
|
|
target_link_libraries(ftxui_benchmark
|
|
|
|
PRIVATE dom
|
|
|
|
PRIVATE benchmark::benchmark
|
|
|
|
PRIVATE benchmark::benchmark_main
|
|
|
|
)
|
|
|
|
target_include_directories(ftxui_benchmark
|
|
|
|
PRIVATE src
|
|
|
|
)
|
|
|
|
set_property(TARGET ftxui_benchmark PROPERTY CXX_STANDARD 17)
|
|
|
|
endif()
|
|
|
|
|
2021-06-18 05:07:26 +08:00
|
|
|
if (FTXUI_BUILD_TESTS_FUZZER)
|
|
|
|
set(CMAKE_C_COMPILER clang)
|
|
|
|
set(CMAKE_CXX_COMPILER clang++)
|
|
|
|
add_executable(terminal_input_parser_test_fuzz
|
|
|
|
src/ftxui/component/terminal_input_parser_test_fuzz.cpp
|
|
|
|
)
|
|
|
|
target_include_directories(terminal_input_parser_test_fuzz
|
|
|
|
PRIVATE src
|
|
|
|
)
|
|
|
|
target_link_libraries(terminal_input_parser_test_fuzz
|
|
|
|
PRIVATE component
|
|
|
|
)
|
|
|
|
target_compile_options(terminal_input_parser_test_fuzz
|
|
|
|
PRIVATE -fsanitize=fuzzer,address
|
|
|
|
)
|
|
|
|
target_link_libraries(terminal_input_parser_test_fuzz
|
|
|
|
PRIVATE -fsanitize=fuzzer,address
|
|
|
|
)
|
|
|
|
endif()
|
2019-02-02 08:59:48 +08:00
|
|
|
endif()
|
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
if(FTXUI_BUILD_EXAMPLES)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
2020-05-25 07:34:13 +08:00
|
|
|
|
|
|
|
if(FTXUI_BUILD_DOCS)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
endif()
|