Skip to content

Commit aadc998

Browse files
committed
ENH: Define environment variables for Python and Qt versions in CMake
Ensure that the CMake codegen and test environments have the environmental variables set as described in the Readme.md file.
1 parent e388ac3 commit aadc998

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ message(STATUS "QT_VERSION_MAJOR = ${QT_VERSION_MAJOR}")
3434

3535
find_package(Python3 COMPONENTS Development)
3636

37+
# Set the environment as defined in Readme.md
38+
# Set environment variables for Python
39+
if(Python3_FOUND)
40+
set(PYTHON_VERSION "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
41+
set(PYTHON_PATH "${Python3_PREFIX}")
42+
set(PYTHON_LIB "${Python3_PREFIX}/libs")
43+
set(PYTHON_DIR "${Python3_PREFIX}")
44+
set(ENV{PYTHON_VERSION} "${PYTHON_VERSION}")
45+
set(ENV{PYTHON_PATH} "${PYTHON_PATH}")
46+
set(ENV{PYTHON_LIB} "${PYTHON_LIB}")
47+
set(ENV{PYTHON_DIR} "${PYTHON_DIR}")
48+
endif()
49+
50+
# Set QTDIR environment variable to Qt installation root
51+
if(FORCE_BUILD_QT5)
52+
if(DEFINED Qt5_DIR)
53+
set(ENV{QTDIR} "${Qt5_DIR}")
54+
endif()
55+
else()
56+
if(DEFINED Qt6_DIR)
57+
set(ENV{QTDIR} "${Qt6_DIR}")
58+
endif()
59+
endif()
60+
61+
3762
set(PYTHONQT_SUFFIX Qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}-Python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
3863
include_directories(src)
3964
add_subdirectory(generator)

0 commit comments

Comments
 (0)