mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 03:10:01 +08:00
CMakeLists.txt rewrite
This commit is contained in:
parent
104d06f04e
commit
db888b3e09
@ -4,6 +4,10 @@ project(ftxui
|
|||||||
VERSION 0.1
|
VERSION 0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
@ -56,6 +60,10 @@ add_library(component
|
|||||||
src/ftxui/component/toggle.cpp
|
src/ftxui/component/toggle.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_library(ftxui::screen ALIAS screen)
|
||||||
|
add_library(ftxui::dom ALIAS dom)
|
||||||
|
add_library(ftxui::component ALIAS component)
|
||||||
|
|
||||||
target_link_libraries(dom PUBLIC screen)
|
target_link_libraries(dom PUBLIC screen)
|
||||||
target_link_libraries(component PUBLIC dom)
|
target_link_libraries(component PUBLIC dom)
|
||||||
target_link_libraries(component PUBLIC Threads::Threads)
|
target_link_libraries(component PUBLIC Threads::Threads)
|
||||||
@ -71,6 +79,7 @@ foreach(lib screen dom component)
|
|||||||
target_compile_options(${lib} PRIVATE -Wall -Werror -Wextra)
|
target_compile_options(${lib} PRIVATE -Wall -Werror -Wextra)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if(FTXUI_ENABLE_INSTALL)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS screen dom component
|
install(TARGETS screen dom component
|
||||||
EXPORT ftxui-export
|
EXPORT ftxui-export
|
||||||
@ -92,11 +101,15 @@ install(EXPORT ftxui-export
|
|||||||
NAMESPACE ftxui::
|
NAMESPACE ftxui::
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
export(TARGETS screen dom component NAMESPACE ftxui::
|
||||||
|
FILE ${PROJECT_BINARY_DIR}/ftxui-targets.cmake)
|
||||||
|
|
||||||
# Note: For gtest, please follow:
|
# Note: For gtest, please follow:
|
||||||
# https://stackoverflow.com/questions/24295876/cmake-cannot-find-a-googletest-required-library
|
# https://stackoverflow.com/questions/24295876/cmake-cannot-find-a-googletest-required-library
|
||||||
find_package(GTest)
|
find_package(GTest)
|
||||||
if (GTEST_FOUND AND THREADS_FOUND)
|
if (FTXUI_BUILD_TESTS AND GTEST_FOUND AND THREADS_FOUND)
|
||||||
add_executable(dom_tests
|
add_executable(dom_tests
|
||||||
tests/gauge_test.cpp
|
tests/gauge_test.cpp
|
||||||
tests/hbox_test.cpp
|
tests/hbox_test.cpp
|
||||||
@ -115,7 +128,8 @@ if (GTEST_FOUND AND THREADS_FOUND)
|
|||||||
)
|
)
|
||||||
gtest_discover_tests(dom_tests)
|
gtest_discover_tests(dom_tests)
|
||||||
add_test(dom_tests dom_tests)
|
add_test(dom_tests dom_tests)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(FTXUI_BUILD_EXAMPLES)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user