mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Separator ftxui::{screen,dom,component} into separate build unit.
This commit is contained in:
parent
5887114793
commit
7efe8a6385
@ -1,4 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(ftxui
|
||||
LANGUAGES CXX
|
||||
VERSION 0.1
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
function(example name)
|
||||
add_executable(${name} ${name}.cpp)
|
||||
target_link_libraries(${name} PUBLIC ftxui)
|
||||
endfunction(example)
|
||||
|
||||
add_subdirectory(component)
|
||||
add_subdirectory(dom)
|
||||
example(print_key_press)
|
||||
|
||||
add_executable(print_key_press print_key_press.cpp)
|
||||
target_link_libraries(print_key_press PUBLIC component)
|
||||
|
@ -1,3 +1,9 @@
|
||||
find_package(ftxui)
|
||||
function(example name)
|
||||
add_executable(${name} ${name}.cpp)
|
||||
target_link_libraries(${name} PUBLIC component)
|
||||
endfunction(example)
|
||||
|
||||
example(input)
|
||||
example(menu)
|
||||
example(menu2)
|
||||
|
@ -1,3 +1,8 @@
|
||||
function(example name)
|
||||
add_executable(${name} ${name}.cpp)
|
||||
target_link_libraries(${name} PUBLIC dom)
|
||||
endfunction(example)
|
||||
|
||||
example(blink)
|
||||
example(bold)
|
||||
example(color)
|
||||
|
@ -1,15 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
add_library(ftxui
|
||||
src/ftxui/component/component.cpp
|
||||
src/ftxui/component/component_direction.cpp
|
||||
src/ftxui/component/component_horizontal.cpp
|
||||
src/ftxui/component/component_vertical.cpp
|
||||
src/ftxui/component/event.cpp
|
||||
src/ftxui/component/input.cpp
|
||||
src/ftxui/component/menu.cpp
|
||||
src/ftxui/component/screen_interactive.cpp
|
||||
src/ftxui/component/toggle.cpp
|
||||
####################
|
||||
# ftxui::screen
|
||||
####################
|
||||
add_library(screen
|
||||
src/ftxui/screen/screen.cpp
|
||||
src/ftxui/terminal.cpp
|
||||
src/ftxui/util/string.cpp
|
||||
)
|
||||
|
||||
target_include_directories(screen
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
PRIVATE src
|
||||
)
|
||||
|
||||
target_compile_features(screen PUBLIC cxx_std_17)
|
||||
target_compile_options(screen PRIVATE -Wall)
|
||||
|
||||
####################
|
||||
# ftxui::dom
|
||||
####################
|
||||
add_library(dom
|
||||
src/ftxui/dom/blink.cpp
|
||||
src/ftxui/dom/bold.cpp
|
||||
src/ftxui/dom/color.cpp
|
||||
@ -28,45 +41,95 @@ add_library(ftxui
|
||||
src/ftxui/dom/underlined.cpp
|
||||
src/ftxui/dom/util.cpp
|
||||
src/ftxui/dom/vbox.cpp
|
||||
src/ftxui/screen/screen.cpp
|
||||
src/ftxui/terminal.cpp
|
||||
src/ftxui/util/string.cpp
|
||||
)
|
||||
|
||||
target_include_directories(ftxui
|
||||
PUBLIC include
|
||||
target_include_directories(dom
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
PRIVATE src
|
||||
)
|
||||
|
||||
target_compile_features(ftxui PUBLIC cxx_std_17)
|
||||
target_compile_options(ftxui PRIVATE -Wall)
|
||||
target_link_libraries(dom
|
||||
PUBLIC screen
|
||||
)
|
||||
|
||||
target_compile_features(dom PUBLIC cxx_std_17)
|
||||
target_compile_options(dom PRIVATE -Wall)
|
||||
|
||||
####################
|
||||
# ftxui::component
|
||||
####################
|
||||
add_library(component
|
||||
src/ftxui/component/component.cpp
|
||||
src/ftxui/component/component_direction.cpp
|
||||
src/ftxui/component/component_horizontal.cpp
|
||||
src/ftxui/component/component_vertical.cpp
|
||||
src/ftxui/component/event.cpp
|
||||
src/ftxui/component/input.cpp
|
||||
src/ftxui/component/menu.cpp
|
||||
src/ftxui/component/screen_interactive.cpp
|
||||
src/ftxui/component/toggle.cpp
|
||||
)
|
||||
|
||||
target_include_directories(component
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
PRIVATE src
|
||||
)
|
||||
|
||||
target_link_libraries(component
|
||||
PUBLIC dom
|
||||
)
|
||||
|
||||
target_compile_features(component PUBLIC cxx_std_17)
|
||||
target_compile_options(component PRIVATE -Wall)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS screen dom component
|
||||
EXPORT ftxui-export
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/
|
||||
)
|
||||
|
||||
install(DIRECTORY include/ftxui DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
ftxui-config.cmake
|
||||
VERSION ${PACKAGE_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
install(EXPORT ftxui-export
|
||||
FILE ftxui-targets.cmake
|
||||
NAMESPACE ftxui::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
||||
)
|
||||
|
||||
# Note: For gtest, please follow:
|
||||
# https://stackoverflow.com/questions/24295876/cmake-cannot-find-a-googletest-required-library
|
||||
find_package(GTest)
|
||||
find_package(Threads)
|
||||
if (GTEST_FOUND AND THREADS_FOUND)
|
||||
function(add_new_test test_name test_files)
|
||||
add_executable(${ARGV})
|
||||
target_link_libraries(${test_name}
|
||||
PRIVATE
|
||||
ftxui
|
||||
Threads::Threads
|
||||
${GTEST_BOTH_LIBRARIES}
|
||||
)
|
||||
target_include_directories(ftxui
|
||||
PRIVATE
|
||||
${GTest_INCLUDE_DIRS}
|
||||
ftxui
|
||||
)
|
||||
gtest_discover_tests(${test_name})
|
||||
add_test(${test_name} ${test_name})
|
||||
endfunction(add_new_test)
|
||||
|
||||
add_new_test(dom_tests
|
||||
add_executable(dom_tests
|
||||
src/ftxui/dom/gauge_test.cpp
|
||||
src/ftxui/dom/hbox_test.cpp
|
||||
src/ftxui/dom/text_test.cpp
|
||||
src/ftxui/dom/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}
|
||||
)
|
||||
gtest_discover_tests(dom_tests)
|
||||
add_test(dom_tests dom_tests)
|
||||
|
||||
endif()
|
||||
|
@ -43,6 +43,7 @@ Decorator bgcolor(Color);
|
||||
Element hcenter(Element);
|
||||
Element vcenter(Element);
|
||||
Element center(Element);
|
||||
Element align_right(Element);
|
||||
|
||||
// --- Util ---
|
||||
Element nothing(Element element);
|
||||
|
@ -15,4 +15,8 @@ std::unique_ptr<Node> center(Element child) {
|
||||
return hcenter(vcenter(std::move(child)));
|
||||
}
|
||||
|
||||
std::unique_ptr<Node> align_right(Element child) {
|
||||
return hbox(filler(), std::move(child));
|
||||
}
|
||||
|
||||
} // namespace ftxui::dom
|
||||
|
Loading…
Reference in New Issue
Block a user