diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b0389212e..5fd729f1bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,7 @@ option(BUILD_STATIC_LIBS "Build static libraries" OFF) option(BUILD_STATIC_CURL "Build curl executable with static libcurl" OFF) option(ENABLE_ARES "Enable c-ares support" OFF) option(CURL_DISABLE_INSTALL "Disable installation targets" OFF) +option(CURL_BUILD_EVERYTHING "Build optional build targets (examples, tests) by default" OFF) if(WIN32) option(ENABLE_UNICODE "Use the Unicode version of the Windows API functions" OFF) @@ -545,10 +546,7 @@ if(PERL_EXECUTABLE) COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/scripts/firefox-db2pem.sh" "lib/ca-bundle.crt" DEPENDS "${PROJECT_SOURCE_DIR}/scripts/firefox-db2pem.sh" ) - if(CURL_LINT) - set(_lint_all ALL) - endif() - add_custom_target(curl-lint "${_lint_all}" + add_custom_target(curl-lint COMMENT "Running lint checks" VERBATIM USES_TERMINAL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/scripts/checksrc-all.pl" @@ -557,6 +555,9 @@ if(PERL_EXECUTABLE) "${PROJECT_SOURCE_DIR}/scripts/checksrc-all.pl" "${PROJECT_SOURCE_DIR}/scripts/checksrc.pl" "${PROJECT_SOURCE_DIR}/scripts/spacecheck.pl" ) + if(CURL_LINT) + set_target_properties(curl-lint PROPERTIES EXCLUDE_FROM_ALL FALSE) + endif() endif() option(BUILD_LIBCURL_DOCS "Build libcurl man pages" ON) diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index 63c9f3103e..d61014f9e5 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -225,6 +225,9 @@ target_link_libraries(my_target PRIVATE CURL::libcurl) - `BUILD_STATIC_CURL`: Build curl executable with static libcurl. Default: `OFF` (turns to `ON`, when building static libcurl only) - `BUILD_STATIC_LIBS`: Build static libraries. Default: `OFF` (turns to `ON` if `BUILD_SHARED_LIBS` is `OFF`) - `BUILD_TESTING`: Build tests. Default: `ON` +- `CURL_BUILD_EVERYTHING`: Build optional build targets (examples, tests) by default. Default: `OFF` + Set `QUICK` to build examples quickly with the `curl-examples-build` target (for build tests). + Set `NOEXAMPLES` to not build examples. - `CURL_CLANG_TIDY`: Run the build through `clang-tidy`. Default: `OFF` If enabled, it implies `CMAKE_UNITY_BUILD=OFF` and `CURL_DISABLE_TYPECHECK=ON`. - `CURL_CLANG_TIDYFLAGS`: Custom options to pass to `clang-tidy`. Default: (empty) diff --git a/docs/examples/CMakeLists.txt b/docs/examples/CMakeLists.txt index 31f2808981..acf3c80955 100644 --- a/docs/examples/CMakeLists.txt +++ b/docs/examples/CMakeLists.txt @@ -21,7 +21,6 @@ # SPDX-License-Identifier: curl # ########################################################################### - add_custom_target(curl-examples) # Get check_PROGRAMS, COMPLICATED_MAY_BUILD, COMPLICATED_EXAMPLES variables @@ -90,3 +89,9 @@ endforeach() if(_with_deps) message(STATUS "Enabled examples with dependencies:${_with_deps}") endif() + +if(CURL_BUILD_EVERYTHING STREQUAL "QUICK") + set_target_properties(curl-examples-build PROPERTIES EXCLUDE_FROM_ALL FALSE) +elseif(CURL_BUILD_EVERYTHING AND NOT CURL_BUILD_EVERYTHING STREQUAL "NOEXAMPLES") + set_target_properties(curl-examples PROPERTIES EXCLUDE_FROM_ALL FALSE) +endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index da8e02677c..9644c187ff 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -33,6 +33,9 @@ add_custom_target(testdeps) if(BUILD_CURL_EXE) add_dependencies(testdeps "curlinfo") endif() +if(CURL_BUILD_EVERYTHING) + set_target_properties(testdeps PROPERTIES EXCLUDE_FROM_ALL FALSE) +endif() if(CURL_CLANG_TIDY) add_custom_target(tests-clang-tidy)