2018-09-18 14:48:40 +08:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2019-01-07 01:53:02 +08:00
|
|
|
project(ftxui
|
|
|
|
LANGUAGES CXX
|
|
|
|
VERSION 0.1
|
|
|
|
)
|
2019-01-03 07:35:59 +08:00
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" ON)
|
|
|
|
option(FTXUI_BUILD_TESTS "Set to ON to build tests" ON)
|
|
|
|
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
|
|
|
|
|
2018-09-18 14:48:40 +08:00
|
|
|
enable_testing()
|
|
|
|
|
2019-02-02 08:59:48 +08:00
|
|
|
find_package(Threads)
|
|
|
|
|
|
|
|
add_library(screen
|
|
|
|
src/ftxui/screen/box.cpp
|
|
|
|
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
|
|
|
|
include/ftxui/screen/screen.hpp
|
|
|
|
include/ftxui/screen/string.hpp
|
2019-02-02 08:59:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_library(dom
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(component
|
|
|
|
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
|
|
|
|
src/ftxui/component/screen_interactive.cpp
|
|
|
|
src/ftxui/component/toggle.cpp
|
2020-03-25 06:26:55 +08:00
|
|
|
include/ftxui/component/checkbox.hpp
|
|
|
|
include/ftxui/component/component.hpp
|
|
|
|
include/ftxui/component/container.hpp
|
|
|
|
include/ftxui/component/event.hpp
|
|
|
|
include/ftxui/component/input.hpp
|
|
|
|
include/ftxui/component/menu.hpp
|
|
|
|
include/ftxui/component/radiobox.hpp
|
|
|
|
include/ftxui/component/screen_interactive.hpp
|
2020-03-25 07:07:41 +08:00
|
|
|
include/ftxui/component/receiver.hpp
|
2020-03-25 06:26:55 +08:00
|
|
|
include/ftxui/component/toggle.hpp
|
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)
|
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:
|
|
|
|
if (MSVC)
|
|
|
|
target_compile_options(${lib} PRIVATE "/W4")
|
|
|
|
target_compile_options(${lib} PRIVATE "/WX")
|
2020-03-25 09:06:14 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "/wd4244")
|
2020-03-25 15:52:57 +08:00
|
|
|
target_compile_options(${lib} PRIVATE "/wd4267")
|
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")
|
|
|
|
target_compile_options(${lib} PRIVATE "-Wno-sign-compare")
|
|
|
|
endif()
|
2020-03-25 08:38:50 +08:00
|
|
|
|
|
|
|
# Force Win32 to UNICODE
|
|
|
|
if(MSVC)
|
|
|
|
target_compile_definitions(${lib} PRIVATE UNICODE _UNICODE)
|
|
|
|
endif()
|
2019-02-02 08:59:48 +08:00
|
|
|
endforeach()
|
|
|
|
|
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)
|
|
|
|
write_basic_package_version_file(
|
|
|
|
ftxui-config.cmake
|
|
|
|
VERSION ${PACKAGE_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion
|
|
|
|
)
|
2019-02-02 08:59:48 +08:00
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
install(EXPORT ftxui-export
|
|
|
|
FILE ftxui-config.cmake
|
|
|
|
NAMESPACE ftxui::
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
export(TARGETS screen dom component NAMESPACE ftxui::
|
|
|
|
FILE ${PROJECT_BINARY_DIR}/ftxui-targets.cmake)
|
2019-02-02 08:59:48 +08:00
|
|
|
|
|
|
|
# Note: For gtest, please follow:
|
|
|
|
# https://stackoverflow.com/questions/24295876/cmake-cannot-find-a-googletest-required-library
|
|
|
|
find_package(GTest)
|
2020-02-11 21:04:23 +08:00
|
|
|
if (FTXUI_BUILD_TESTS AND GTEST_FOUND AND THREADS_FOUND)
|
2019-02-02 08:59:48 +08:00
|
|
|
add_executable(dom_tests
|
|
|
|
tests/gauge_test.cpp
|
|
|
|
tests/hbox_test.cpp
|
|
|
|
tests/text_test.cpp
|
|
|
|
tests/vbox_test.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(dom_tests
|
|
|
|
PRIVATE dom
|
|
|
|
PRIVATE Threads::Threads
|
|
|
|
PRIVATE ${GTEST_BOTH_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(dom_tests
|
|
|
|
PRIVATE ${GTest_INCLUDE_DIRS}
|
|
|
|
)
|
2020-03-25 08:15:46 +08:00
|
|
|
set_property(TARGET dom_tests PROPERTY CXX_STANDARD 17)
|
2019-02-02 08:59:48 +08:00
|
|
|
gtest_discover_tests(dom_tests)
|
|
|
|
add_test(dom_tests dom_tests)
|
|
|
|
endif()
|
|
|
|
|
2020-02-11 21:04:23 +08:00
|
|
|
if(FTXUI_BUILD_EXAMPLES)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|