diff options
author | Michal Klocek <michal.klocek@qt.io> | 2021-02-02 10:49:19 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2021-05-12 09:40:28 +0200 |
commit | a60304e7ea154438060a71959f72a4a1b95f5327 (patch) | |
tree | 8aca57af64fcfa579c63cd2a0caa5c6073544cd4 /cmake | |
parent | b8fb47478db06cac231a8a7222e7afbce7b3cf90 (diff) |
Add configure.cmake files
Only evaluate features in the super repo and do not
create config headers files during the configure step.
However, print the build summary.
The build config headers will be created during the
configure step of 'libs' external project.
Done-With: Jüri Valdmann <juri.valdmann@qt.io>
Done-With: Allan Sandfeld Jensen <allan.jensen@qt.io>
Task-number: QTBUG-91760
Task-number: COIN-711
Change-Id: I481525571e71ca4684de5827f641416035a8f22a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindGPerf.cmake | 20 | ||||
-rw-r--r-- | cmake/FindNodejs.cmake | 32 | ||||
-rw-r--r-- | cmake/FindSnappy.cmake | 35 | ||||
-rw-r--r-- | cmake/Functions.cmake | 41 |
4 files changed, 128 insertions, 0 deletions
diff --git a/cmake/FindGPerf.cmake b/cmake/FindGPerf.cmake new file mode 100644 index 000000000..85b55f1b8 --- /dev/null +++ b/cmake/FindGPerf.cmake @@ -0,0 +1,20 @@ +find_program(GPerf_EXECUTABLE NAMES gperf) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GPerf + FOUND_VAR + GPerf_FOUND + REQUIRED_VARS + GPerf_EXECUTABLE +) + +if(GPerf_FOUND AND NOT TARGET GPerf::GPerf) + add_executable(GPerf::GPerf IMPORTED) + set_target_properties(GPerf::GPerf PROPERTIES IMPORTED_LOCATION "${GPerf_EXECUTABLE}") +endif() + +include(FeatureSummary) +set_package_properties(GPerf PROPERTIES + URL "https://www.gnu.org/software/gperf/" + DESCRIPTION "Perfect hash function generator" +) diff --git a/cmake/FindNodejs.cmake b/cmake/FindNodejs.cmake new file mode 100644 index 000000000..0e5efe4a3 --- /dev/null +++ b/cmake/FindNodejs.cmake @@ -0,0 +1,32 @@ +find_program(Nodejs_EXECUTABLE NAMES node nodejs) + +if(Nodejs_EXECUTABLE) + execute_process( + COMMAND ${Nodejs_EXECUTABLE} --version + OUTPUT_VARIABLE Nodejs_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +string (REGEX MATCHALL "([1-9][0-9])\..*" Nodejs_VERSION "${Nodejs_VERSION}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Nodejs + FOUND_VAR + Nodejs_FOUND + VERSION_VAR + Nodejs_VERSION + REQUIRED_VARS + Nodejs_EXECUTABLE +) + +if(Nodejs_FOUND AND NOT TARGET Nodejs::Nodejs) + add_executable(Nodejs::Nodejs IMPORTED) + set_target_properties(Nodejs::Nodejs PROPERTIES IMPORTED_LOCATION "${Nodejs_EXECUTABLE}") +endif() + +include(FeatureSummary) +set_package_properties(Nodejs PROPERTIES + URL "https://nodejs.org/" + DESCRIPTION "JavaScript runtime environment that runs on the V8 engine" +) diff --git a/cmake/FindSnappy.cmake b/cmake/FindSnappy.cmake new file mode 100644 index 000000000..1470c55a9 --- /dev/null +++ b/cmake/FindSnappy.cmake @@ -0,0 +1,35 @@ + +if(TARGET Snappy::Snappy) + set(Snappy_FOUND TRUE) + return() +endif() +find_package(PkgConfig QUIET) + +if(PkgConfig_FOUND) + pkg_check_modules(Snappy snappy IMPORTED_TARGET) + + if (TARGET PkgConfig::Snappy) + add_library(Snappy::Snappy INTERFACE IMPORTED) + target_link_libraries(Snappy::Snappy INTERFACE PkgConfig::Snappy) + set(Snappy_FOUND TRUE) + endif() +endif() + +if(NOT TARGET Snappy::Snappy) + find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h) + find_library(SNAPPY_LIBRARY NAMES snappy) + + if(SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR) + add_library(Snappy::Snappy UNKNOWN IMPORTED) + set_target_properties(Snappy::Snappy PROPERTIES + IMPORTED_LOCATION ${SNAPPY_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${SNAPPY_INCLUDE_DIR} + ) + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Snappy REQUIRED_VARS + SNAPPY_LIBRARY + SNAPPY_INCLUDE_DIR + ) +endif() diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake new file mode 100644 index 000000000..b954654bf --- /dev/null +++ b/cmake/Functions.cmake @@ -0,0 +1,41 @@ +function(assertTargets errorResult supportResult) + if(NOT DEFINED ${supportResult}) + set(${supportResult} ON PARENT_SCOPE) + set(${supportResult} ON) + endif() + if(${${supportResult}}) + list(REMOVE_ITEM ARGN ${errorResult}) + list(REMOVE_ITEM ARGN ${supportResult}) + foreach(qtTarget IN ITEMS ${ARGN}) + if(NOT TARGET Qt::${qtTarget}) + set(${errorResult} "Missing required Qt::${qtTarget}." PARENT_SCOPE) + set(${supportResult} OFF PARENT_SCOPE) + return() + endif() + endforeach() + endif() +endfunction() + +# TODO: this should be idealy in qtbase +function(add_check_for_support errorResult supportResult) + if(NOT DEFINED ${supportResult}) + set(${supportResult} ON PARENT_SCOPE) + set(${supportResult} ON) + endif() + if (${${supportResult}}) + qt_parse_all_arguments(arg "add_check_for_support" + "" "MODULE" "MESSAGE;CONDITION" "${ARGN}") + if ("x${arg_CONDITION}" STREQUAL x) + set(arg_CONDITION ON) + endif() + qt_evaluate_config_expression(result ${arg_CONDITION}) + if(NOT ${result}) + set(${supportResult} OFF PARENT_SCOPE) + set(${errorResult} ${arg_MESSAGE} PARENT_SCOPE) + qt_configure_add_report_entry(TYPE WARNING + MESSAGE "${arg_MODULE} won't be built. ${arg_MESSAGE}" + CONDITION ON + ) + endif() + endif() +endfunction() |