Skip to content

Commit

Permalink
New module hunter_generate_qt_info and tests
Browse files Browse the repository at this point in the history
hunter_generate_qt_info is a wrapper which will call:
* hunter_generate_qt_5_5_info
* hunter_generate_qt_5_6_info
  • Loading branch information
ruslo committed Oct 14, 2015
1 parent 8aacabc commit a128a74
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ env:
- PROJECT_DIR=tests/issue/109/unit TOOLCHAIN=default
- PROJECT_DIR=tests/hunter_create_args_file TOOLCHAIN=default
- PROJECT_DIR=tests/hunter_create_dependency_entry TOOLCHAIN=default
- PROJECT_DIR=tests/hunter_generate_qt_info TOOLCHAIN=default
- PROJECT_DIR=tests/hunter_get_dependency_list TOOLCHAIN=default
- PROJECT_DIR=tests/hunter_pack_directory TOOLCHAIN=default
- PROJECT_DIR=tests/hunter_process_dependency_node TOOLCHAIN=default
Expand Down
59 changes: 59 additions & 0 deletions cmake/modules/hunter_generate_qt_info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (c) 2015, Ruslan Baratov
# All rights reserved.

include(hunter_generate_qt_5_5_info)
include(hunter_generate_qt_5_6_info)
include(hunter_test_string_not_empty)
include(hunter_user_error)

# See cmake/projects/Qt/generate.sh

function(
hunter_generate_qt_info
component_name
skip_components_varname
component_depends_on_varname
nobuild_varname
qt_version
is_android
is_win32
)
hunter_test_string_not_empty("${component_name}")
hunter_test_string_not_empty("${skip_components_varname}")
hunter_test_string_not_empty("${component_depends_on_varname}")
hunter_test_string_not_empty("${nobuild_varname}")
hunter_test_string_not_empty("${qt_version}")

if(qt_version MATCHES "^5\\.5\\.")
hunter_generate_qt_5_5_info(
"${component_name}"
toskip
depends_on
"${is_android}"
"${is_win32}"
)
elseif(qt_version MATCHES "^5\\.6\\.")
hunter_generate_qt_5_6_info(
"${component_name}"
toskip
depends_on
"${is_android}"
"${is_win32}"
)
else()
hunter_user_error("Unexpected Qt version")
endif()

set(
nobuild
"qtwebkit"
"qtwebengine"
"qtwebview"
"qtwinextras"
"qtx11extras"
)

set("${skip_components_varname}" "${toskip}" PARENT_SCOPE)
set("${component_depends_on_varname}" "${depends_on}" PARENT_SCOPE)
set("${nobuild_varname}" "${nobuild}" PARENT_SCOPE)
endfunction()
129 changes: 129 additions & 0 deletions tests/hunter_generate_qt_info/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Copyright (c) 2015, Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.0)

include("../../examples/common.cmake")
project(TestModuleHunterGenerateQtInfo)

include(hunter_generate_qt_info)

set(
all_components
qt3d
qtactiveqt
qtandroidextras
qtbase
qtcanvas3d
qtconnectivity
qtdeclarative
qtdoc
qtenginio
qtgraphicaleffects
qtimageformats
qtlocation
qtmacextras
qtmultimedia
qtquick1
qtquickcontrols
qtscript
qtsensors
qtserialport
qtsvg
qttools
qttranslations
qtwayland
qtwebchannel
qtwebengine
qtwebkit
qtwebkit-examples
qtwebsockets
qtwinextras
qtx11extras
qtxmlpatterns
)

### Test qtbase
hunter_generate_qt_info("qtbase" toskip depends_on nobuild "5.5.0" "NO" "NO")

list(APPEND toskip qtbase)
list(SORT toskip)
string(COMPARE EQUAL "${toskip}" "${all_components}" is_good)
if(NOT is_good)
message(FATAL_ERROR "qtbase should skip all components: ${toskip}")
endif()

string(COMPARE EQUAL "${depends_on}" "" is_good)
if(NOT is_good)
message(FATAL_ERROR "qtbase should not depends on anything: ${depends_on}")
endif()

### Test android component
hunter_generate_qt_info("qtconnectivity" toskip depends_on nobuild "5.5.0" "YES" "NO")
list(FIND depends_on "qtandroidextras" found)
if(found EQUAL -1)
message(FATAL_ERROR "qtandroidextras component not found")
endif()

### Test no android component
hunter_generate_qt_info("qtconnectivity" toskip depends_on nobuild "5.5.0" "0" "NO")
list(FIND depends_on "qtandroidextras" found)
if(NOT found EQUAL -1)
message(FATAL_ERROR "qtandroidextras component found")
endif()

###
hunter_generate_qt_info("qtsvg" toskip depends_on nobuild "5.5.0" "NO" "NO")
string(COMPARE EQUAL "qtbase" "${depends_on}" is_good)
if(NOT is_good)
message(FATAL_ERROR "qtsvg depends only on qtbase: ${depends_on}")
endif()

### Test qtdeclarative
hunter_generate_qt_info("qtdeclarative" toskip depends_on nobuild "5.5.0" "NO" "NO")
string(COMPARE EQUAL "${depends_on}" "qtbase;qtsvg;qtxmlpatterns" is_good)
if(NOT is_good)
message(FATAL_ERROR "Not good")
endif()

### Test
hunter_generate_qt_info("qtenginio" toskip depends_on nobuild "5.5.0" "NO" "") # empty string should work fine too
string(COMPARE EQUAL "${depends_on}" "qtbase;qtdeclarative;qtsvg;qtxmlpatterns" is_good)
if(NOT is_good)
message(FATAL_ERROR "Not good")
endif()

### Test
hunter_generate_qt_info("qtwebchannel" toskip depends_on nobuild "5.5.0" "NO" "NO")
string(COMPARE EQUAL "${depends_on}" "qtbase;qtdeclarative;qtsvg;qtwebsockets;qtxmlpatterns" is_good)
if(NOT is_good)
message(FATAL_ERROR "Not good")
endif()

### Test
hunter_generate_qt_info("qtwebkit" toskip depends_on nobuild "5.5.0" "NO" "NO")
string(
COMPARE
EQUAL
"${depends_on}"
"qtbase;qtdeclarative;qtlocation;qtmultimedia;qtsensors;qtsvg;qtwebchannel;qtwebsockets;qtxmlpatterns"
is_good
)
if(NOT is_good)
message(FATAL_ERROR "Not good: ${depends_on}")
endif()

### Test
hunter_generate_qt_info("qtwebengine" toskip depends_on nobuild "5.5.0" "NO" "NO")
string(
COMPARE
EQUAL
"${depends_on}"
"qtbase;qtdeclarative;qtgraphicaleffects;qtlocation;qtmultimedia;qtquickcontrols;qtsensors;qtsvg;qtwebchannel;qtwebkit;qtwebsockets;qtxmlpatterns"
is_good
)
if(NOT is_good)
message(FATAL_ERROR "Not good: ${depends_on}")
endif()

message("PASSED")

0 comments on commit a128a74

Please sign in to comment.