Merge pull request #10 from GiuseppeCesarano/master

CMakeLists.txt rewrite
This commit is contained in:
Arthur Sonzogni 2020-02-11 14:51:03 +01:00 committed by GitHub
commit 5637fa3a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,10 @@ project(ftxui
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()
cmake_minimum_required(VERSION 3.0)
@ -56,6 +60,10 @@ add_library(component
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(component PUBLIC dom)
target_link_libraries(component PUBLIC Threads::Threads)
@ -71,6 +79,7 @@ foreach(lib screen dom component)
target_compile_options(${lib} PRIVATE -Wall -Werror -Wextra)
endforeach()
if(FTXUI_ENABLE_INSTALL)
include(GNUInstallDirs)
install(TARGETS screen dom component
EXPORT ftxui-export
@ -92,11 +101,15 @@ install(EXPORT ftxui-export
NAMESPACE 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:
# https://stackoverflow.com/questions/24295876/cmake-cannot-find-a-googletest-required-library
find_package(GTest)
if (GTEST_FOUND AND THREADS_FOUND)
if (FTXUI_BUILD_TESTS AND GTEST_FOUND AND THREADS_FOUND)
add_executable(dom_tests
tests/gauge_test.cpp
tests/hbox_test.cpp
@ -115,7 +128,8 @@ if (GTEST_FOUND AND THREADS_FOUND)
)
gtest_discover_tests(dom_tests)
add_test(dom_tests dom_tests)
endif()
if(FTXUI_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()