Skip to content

Commit

Permalink
CMAKE - Allow to define QT_BASE_DIR dynamically via environment-variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-Grey committed Nov 11, 2020
1 parent 6781ef7 commit 325b573
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,39 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# Qt5 default install path with msvc2017 64bit component
# The Qt5_DIR should point to Qt5Config.cmake -> C:/Qt/5.xx/msvc2017_64/lib/cmake/Qt5
# The CMAKE_PREFIX_PATH should point to the install directory -> C:/Qt/5.xx/msvc2017_64
FIRSTSUBDIR(SUBDIRQT "C:/Qt")
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${SUBDIRQT}/msvc2019_64")
#
# Alternatively, use Qt5_BASE_DIR environment variable to point to Qt version to be used
# In MSVC19 add into CMakeSettings.json
#
# "environments": [
# {
# "Qt5_BASE_DIR": "D:\\Qt\\5.15.1\\msvc2019_64"
# }
# ]

if (NOT DEFINED ENV{Qt5_BASE_DIR})
FIRSTSUBDIR(SUBDIRQT "C:/Qt")
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${SUBDIRQT}/msvc2019_64")
else()
message(STATUS "QT5_BASE_DIR: $ENV{QT5_BASE_DIR}")
message(STATUS "Add QT5_BASE_DIR: $ENV{QT5_BASE_DIR} to CMAKE_PREFIX_PATH")
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{Qt5_BASE_DIR})
endif()

if (NOT DEFINED ENV{Qt5_DIR})
message(STATUS "Set Qt5 module path: ${SUBDIRQT}")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${SUBDIRQT}/msvc2019_64/lib/cmake/Qt5")
if (NOT DEFINED ENV{Qt5_BASE_DIR})
SET (qt_module_path "${SUBDIRQT}/msvc2019_64/lib/cmake/Qt5")
else ()
SET (qt_module_path "$ENV{Qt5_BASE_DIR}/lib/cmake/Qt5")
endif()
else()
SET (qt_module_path $ENV{Qt5_DIR})
endif()
message(STATUS "Add ${qt_module_path} to CMAKE_MODULE_PATH")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${qt_module_path})

#message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
#message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")

# Search for DirectX9
if (ENABLE_DX)
Expand Down

0 comments on commit 325b573

Please sign in to comment.