diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b138b0c0..4c4ecba83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,9 +73,14 @@ include(FeatureSummary) # Optional build settings for libopenshot option(USE_SYSTEM_JSONCPP "Use system installed JsonCpp, if found" ON) option(DISABLE_BUNDLED_JSONCPP "Don't fall back to bundled JsonCpp" OFF) -option(DISABLE_TESTS "Don't build unit tests" OFF) option(ENABLE_IWYU "Enable 'Include What You Use' scanner (CMake 3.3+)" OFF) -option(ENABLE_COVERAGE "Enable coverage reporting" OFF) +option(ENABLE_TESTS "Build unit tests (requires UnitTest++)" ON) +option(ENABLE_DOCS "Build API documentation (requires Doxygen)" ON) + +# Legacy commandline override +if (DISABLE_TESTS) + set(ENABLE_TESTS OFF CACHE BOOL "Build unit tests (requires UnitTest++)" FORCE) +endif() ########## Configure Version.h header ############## configure_file(include/OpenShotVersion.h.in include/OpenShotVersion.h @ONLY) @@ -124,27 +129,32 @@ add_subdirectory(src) ################### DOCUMENTATION ################### # Find Doxygen (used for documentation) -include(cmake/Modules/UseDoxygen.cmake) - -# Doxygen was found -if (TARGET doc) - message(STATUS "Doxygen found, documentation target enabled") - message("\nTo compile documentation in doc/html, run: 'make doc'") - - # Install docs, if the user builds them with `make doc` - install(CODE "MESSAGE(\"Checking for documentation files to install...\")") - install(CODE "MESSAGE(\"(Compile with 'make doc' command, requires Doxygen)\")") - - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html/ - DESTINATION ${CMAKE_INSTALL_DOCDIR}/API - MESSAGE_NEVER # Don't spew about file copies - OPTIONAL ) # No error if the docs aren't found +set(DOCS_ENABLED FALSE) # Only set true if Doxygen is found and configured +if (ENABLE_DOCS) + include(cmake/Modules/UseDoxygen.cmake) + + # Doxygen was found + if (TARGET doc) + message(STATUS "Doxygen found, documentation target enabled") + set(DOCS_ENABLED TRUE) + + # Install docs, if the user builds them with `make doc` + install(CODE "MESSAGE(\"Checking for documentation files to install...\")") + install(CODE "MESSAGE(\"(Compile with 'make doc' command, requires Doxygen)\")") + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html/ + DESTINATION ${CMAKE_INSTALL_DOCDIR}/API + MESSAGE_NEVER # Don't spew about file copies + OPTIONAL ) # No error if the docs aren't found + endif() endif() +add_feature_info("Documentation" DOCS_ENABLED "Build API documentation with 'make doc'") ############# PROCESS tests/ DIRECTORY ############## -if(NOT DISABLE_TESTS) +if(ENABLE_TESTS) add_subdirectory(tests) endif() +add_feature_info("Unit tests" ENABLE_TESTS "Compile unit tests for library functions") ############## COVERAGE REPORTING ################# if (ENABLE_COVERAGE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4b2284f63..b7c042564 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -125,7 +125,6 @@ target_link_libraries(openshot-test openshot ${UNITTEST++_LIBRARY}) ##### RUNNING TESTS (make os_test / make test) ##### # Hook up the 'make os_test' target to the 'openshot-test' executable ADD_CUSTOM_TARGET(os_test COMMAND openshot-test) -list(APPEND OS_TEST_CMDS "'make os_test'") # Also hook up 'make test', if possible # This requires CMake 3.11+, where the CMP0037 policy @@ -137,8 +136,8 @@ endif() if (CMAKE_VERSION VERSION_GREATER 3.11) message(STATUS "Cmake 3.11+ detected, enabling 'test' target") add_custom_target(test COMMAND openshot-test) - list(APPEND OS_TEST_CMDS " or " "'make test'") + set(TEST_TARGET_NAME "test") +else() + set(TEST_TARGET_NAME "os_test") endif() - -string(CONCAT t ${OS_TEST_CMDS}) -message("\nTo run unit tests, use: ${t}") +add_feature_info("Testrunner" ENABLE_TESTS "Run unit tests with 'make ${TEST_TARGET_NAME}'")