Skip to content

Commit

Permalink
Add MdtQtPath CMake module
Browse files Browse the repository at this point in the history
  • Loading branch information
scandyna committed Dec 3, 2017
1 parent 2c04520 commit 536dfdb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(UNIX)
elseif(WIN32)
set(MDT_CMAKE_MODULES_INSTALL_DIR "cmake")
else()
message(FATAL "Could not determine install dir for MdtCMakeModules")
message(FATAL_ERROR "Could not determine install dir for MdtCMakeModules")
endif()

# Rules to install the modules
Expand All @@ -23,6 +23,7 @@ install(
"modules/MdtDeployUtils.cmake"
"modules/MdtInstallCopyTargetsDependenciesScript.cmake.in"
"modules/MdtInstallDirs.cmake"
"modules/MdtQtPath.cmake"
DESTINATION "${MDT_CMAKE_MODULES_INSTALL_DIR}/modules"
COMPONENT "${PROJECT_NAME}-cmake"
)
Expand Down
40 changes: 40 additions & 0 deletions cmake/modules/MdtQtPath.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#.rst:
# MdtQtPath
# --------------
#
# Get the prefix of the Qt library on which a Mdt installation depends.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# Inclusion of this module defines the following variables:
#
# ``QT_PREFIX_PATH``
#
# Path to the Qt library on which a Mdt installation depends.
#

# list(LENGTH CMAKE_PREFIX_PATH _cmake_prefix_path_length)
# if(${_cmake_prefix_path_length} LESS 1)
# message(FATAL_ERROR "")
# endif()

find_file(
_qt_prefix_path_file
NAMES "QtPrefixPath.txt"
PATHS ${CMAKE_PREFIX_PATH}
NO_DEFAULT_PATH
)

if(NOT EXISTS "${_qt_prefix_path_file}")
message(FATAL_ERROR "Could not locate QtPrefixPath.txt. Searched in: ${CMAKE_PREFIX_PATH}")
endif()

file(STRINGS "${_qt_prefix_path_file}" QT_PREFIX_PATH)

# Check that QT_PREFIX_PATH points to a Qt installation
if(NOT QT_PREFIX_PATH)
message(FATAL_ERROR "QT_PREFIX_PATH was not set, please check that CMAKE_PREFIX_PATH contains a path to a Mdt installation.")
endif()

message("QT_PREFIX_PATH: ${QT_PREFIX_PATH}")

0 comments on commit 536dfdb

Please sign in to comment.