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 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,32 +79,37 @@ foreach(lib screen dom component)
target_compile_options(${lib} PRIVATE -Wall -Werror -Wextra) target_compile_options(${lib} PRIVATE -Wall -Werror -Wextra)
endforeach() endforeach()
include(GNUInstallDirs) if(FTXUI_ENABLE_INSTALL)
install(TARGETS screen dom component include(GNUInstallDirs)
EXPORT ftxui-export install(TARGETS screen dom component
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/ EXPORT ftxui-export
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/
) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/
)
install(DIRECTORY include/ftxui DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY include/ftxui DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( write_basic_package_version_file(
ftxui-config.cmake ftxui-config.cmake
VERSION ${PACKAGE_VERSION} VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
install(EXPORT ftxui-export install(EXPORT ftxui-export
FILE ftxui-config.cmake FILE ftxui-config.cmake
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()
add_subdirectory(examples) if(FTXUI_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()