Skip to content

Commit ad81e22

Browse files
committed
feat: enable MODMESH_USE_PYSIDE to on, by default
1 parent f55469c commit ad81e22

4 files changed

Lines changed: 62 additions & 48 deletions

File tree

.github/workflows/devbuild.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ jobs:
212212
VERBOSE=1 USE_CLANG_TIDY=OFF \
213213
BUILD_QT=OFF \
214214
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
215-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
215+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
216216
make buildext VERBOSE=1
217217
218218
- name: make pytest BUILD_QT=OFF
@@ -227,7 +227,7 @@ jobs:
227227
VERBOSE=1 USE_CLANG_TIDY=OFF \
228228
BUILD_QT=ON \
229229
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
230-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
230+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DMODMESH_USE_PYSIDE=ON"
231231
make buildext VERBOSE=1
232232
233233
# build with pytest helper binding for testing
@@ -238,7 +238,7 @@ jobs:
238238
VERBOSE=1 USE_CLANG_TIDY=OFF \
239239
BUILD_QT=ON \
240240
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
241-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
241+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
242242
make buildext VERBOSE=1
243243
244244
- name: make pytest BUILD_QT=ON USE_PYTEST_HELPER_BINDING=ON
@@ -257,7 +257,7 @@ jobs:
257257
VERBOSE=1 USE_CLANG_TIDY=OFF \
258258
BUILD_QT=ON \
259259
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
260-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
260+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
261261
262262
- name: make run_pilot_pytest
263263
run: |
@@ -273,7 +273,7 @@ jobs:
273273
VERBOSE=1 USE_CLANG_TIDY=OFF \
274274
BUILD_QT=OFF \
275275
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
276-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF -DUSE_PYTEST_HELPER_BINDING=ON"
276+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
277277
make buildext VERBOSE=1
278278
make pytest VERBOSE=1
279279
@@ -394,7 +394,7 @@ jobs:
394394
VERBOSE=1 USE_CLANG_TIDY=OFF \
395395
BUILD_QT=OFF \
396396
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
397-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
397+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
398398
make buildext VERBOSE=1
399399
400400
- name: make pytest BUILD_QT=OFF
@@ -416,7 +416,7 @@ jobs:
416416
VERBOSE=1 USE_CLANG_TIDY=OFF \
417417
BUILD_QT=ON \
418418
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
419-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
419+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DMODMESH_USE_PYSIDE=ON"
420420
make buildext VERBOSE=1
421421
422422
# build with pytest helper binding for testing
@@ -427,7 +427,7 @@ jobs:
427427
VERBOSE=1 USE_CLANG_TIDY=OFF \
428428
BUILD_QT=ON \
429429
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
430-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
430+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
431431
make buildext VERBOSE=1
432432
433433
- name: make pytest BUILD_QT=ON USE_PYTEST_HELPER_BINDING=ON
@@ -455,7 +455,7 @@ jobs:
455455
VERBOSE=1 USE_CLANG_TIDY=OFF \
456456
BUILD_QT=ON \
457457
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
458-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
458+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
459459
460460
- name: make run_pilot_pytest
461461
run: |
@@ -470,7 +470,7 @@ jobs:
470470
VERBOSE=1 USE_CLANG_TIDY=OFF \
471471
BUILD_QT=OFF \
472472
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
473-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF -DUSE_PYTEST_HELPER_BINDING=ON"
473+
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF -DUSE_PYTEST_HELPER_BINDING=ON -DMODMESH_USE_PYSIDE=ON"
474474
make buildext VERBOSE=1
475475
make pytest VERBOSE=1
476476
@@ -554,6 +554,7 @@ jobs:
554554
cmake `
555555
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} `
556556
-Dpybind11_DIR="$(pybind11-config --cmakedir)" `
557+
-DMODMESH_USE_PYSIDE=ON `
557558
-S${{ github.workspace }} `
558559
-B${{ github.workspace }}/build
559560
cmake --build ${{ github.workspace }}/build `
@@ -567,6 +568,7 @@ jobs:
567568
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} `
568569
-Dpybind11_DIR="$(pybind11-config --cmakedir)" `
569570
-DUSE_PYTEST_HELPER_BINDING=ON `
571+
-DMODMESH_USE_PYSIDE=ON `
570572
-S${{ github.workspace }} `
571573
-B${{ github.workspace }}/build
572574
cmake --build ${{ github.workspace }}/build `
@@ -626,7 +628,7 @@ jobs:
626628
Remove-Item -Path $pyside6_path\Qt*.dll
627629
628630
# Configure and build the pilot
629-
cmake -Dpybind11_DIR="$(pybind11-config --cmakedir)" -S . -B build
631+
cmake -Dpybind11_DIR="$(pybind11-config --cmakedir)" -DMODMESH_USE_PYSIDE=ON -S . -B build
630632
cmake --build build --config Release --target pilot
631633
632634
# Deploy the Qt environment for the pilot executable and copy necessary files

CMakeLists.txt

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ endif()
1616
option(BUILD_QT "build with QT" ON)
1717
message(STATUS "BUILD_QT: ${BUILD_QT}")
1818

19+
option(MODMESH_USE_PYSIDE "enable PySide6 support" ON)
20+
message(STATUS "MODMESH_USE_PYSIDE: ${MODMESH_USE_PYSIDE}")
21+
1922
option(BUILD_METAL "build with Metal" OFF)
2023
message(STATUS "BUILD_METAL: ${BUILD_METAL}")
2124
if(BUILD_METAL)
@@ -138,42 +141,45 @@ set(MODMESH_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/cpp" CACHE INTERNAL "")
138141

139142
include_directories(${MODMESH_INCLUDE_DIR})
140143

141-
execute_process(
142-
COMMAND python3 -c "import sys, os, PySide6; sys.stdout.write(os.path.dirname(PySide6.__file__))"
143-
OUTPUT_VARIABLE PYSIDE6_PYTHON_PACKAGE_PATH
144-
)
145-
message(STATUS "PYSIDE6_PYTHON_PACKAGE_PATH: ${PYSIDE6_PYTHON_PACKAGE_PATH}")
144+
if(MODMESH_USE_PYSIDE)
145+
add_compile_definitions(MODMESH_USE_PYSIDE)
146+
execute_process(
147+
COMMAND python3 -c "import sys, os, PySide6; sys.stdout.write(os.path.dirname(PySide6.__file__))"
148+
OUTPUT_VARIABLE PYSIDE6_PYTHON_PACKAGE_PATH
149+
)
150+
message(STATUS "PYSIDE6_PYTHON_PACKAGE_PATH: ${PYSIDE6_PYTHON_PACKAGE_PATH}")
146151

147-
execute_process(
148-
COMMAND python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))"
149-
OUTPUT_VARIABLE SHIBOKEN6_PYTHON_PACKAGE_PATH
150-
)
151-
message(STATUS "SHIBOKEN6_PYTHON_PACKAGE_PATH: ${SHIBOKEN6_PYTHON_PACKAGE_PATH}")
152-
execute_process(
153-
COMMAND python3 -c "import sys, os, shiboken6_generator; sys.stdout.write(os.path.dirname(shiboken6_generator.__file__))"
154-
OUTPUT_VARIABLE SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH
155-
)
156-
message(STATUS "SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH: ${SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH}")
152+
execute_process(
153+
COMMAND python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))"
154+
OUTPUT_VARIABLE SHIBOKEN6_PYTHON_PACKAGE_PATH
155+
)
156+
message(STATUS "SHIBOKEN6_PYTHON_PACKAGE_PATH: ${SHIBOKEN6_PYTHON_PACKAGE_PATH}")
157+
execute_process(
158+
COMMAND python3 -c "import sys, os, shiboken6_generator; sys.stdout.write(os.path.dirname(shiboken6_generator.__file__))"
159+
OUTPUT_VARIABLE SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH
160+
)
161+
message(STATUS "SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH: ${SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH}")
157162

158-
if(NOT "${PYSIDE6_PYTHON_PACKAGE_PATH}" STREQUAL "")
159-
include_directories("${PYSIDE6_PYTHON_PACKAGE_PATH}/include")
160-
link_directories("${PYSIDE6_PYTHON_PACKAGE_PATH}")
161-
endif()
162-
if(NOT "${SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH}" STREQUAL "")
163-
include_directories("${SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH}/include")
164-
endif()
165-
if(NOT "${SHIBOKEN6_PYTHON_PACKAGE_PATH}" STREQUAL "")
166-
link_directories("${SHIBOKEN6_PYTHON_PACKAGE_PATH}")
167-
endif()
163+
if(NOT "${PYSIDE6_PYTHON_PACKAGE_PATH}" STREQUAL "")
164+
include_directories("${PYSIDE6_PYTHON_PACKAGE_PATH}/include")
165+
link_directories("${PYSIDE6_PYTHON_PACKAGE_PATH}")
166+
endif()
167+
if(NOT "${SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH}" STREQUAL "")
168+
include_directories("${SHIBOKEN6_GENERATOR_PYTHON_PACKAGE_PATH}/include")
169+
endif()
170+
if(NOT "${SHIBOKEN6_PYTHON_PACKAGE_PATH}" STREQUAL "")
171+
link_directories("${SHIBOKEN6_PYTHON_PACKAGE_PATH}")
172+
endif()
168173

169-
# PySide6 and Shiboken6 library name are different in Windows and Unix-like OS
170-
# therefore needs sperate in different cases
171-
if(MSVC)
172-
file(GLOB PYSIDE6_LIBFILE LIST_DIRECTORIES false "${PYSIDE6_PYTHON_PACKAGE_PATH}/pyside6.*.lib")
173-
file(GLOB SHIBOKEN6_LIBFILE LIST_DIRECTORIES false "${SHIBOKEN6_PYTHON_PACKAGE_PATH}/shiboken6.*.lib")
174-
else()
175-
file(GLOB PYSIDE6_LIBFILE LIST_DIRECTORIES false "${PYSIDE6_PYTHON_PACKAGE_PATH}/libpyside6.*")
176-
file(GLOB SHIBOKEN6_LIBFILE LIST_DIRECTORIES false "${SHIBOKEN6_PYTHON_PACKAGE_PATH}/libshiboken6.*")
174+
# PySide6 and Shiboken6 library name are different in Windows and Unix-like OS
175+
# therefore needs sperate in different cases
176+
if(MSVC)
177+
file(GLOB PYSIDE6_LIBFILE LIST_DIRECTORIES false "${PYSIDE6_PYTHON_PACKAGE_PATH}/pyside6.*.lib")
178+
file(GLOB SHIBOKEN6_LIBFILE LIST_DIRECTORIES false "${SHIBOKEN6_PYTHON_PACKAGE_PATH}/shiboken6.*.lib")
179+
else()
180+
file(GLOB PYSIDE6_LIBFILE LIST_DIRECTORIES false "${PYSIDE6_PYTHON_PACKAGE_PATH}/libpyside6.*")
181+
file(GLOB SHIBOKEN6_LIBFILE LIST_DIRECTORIES false "${SHIBOKEN6_PYTHON_PACKAGE_PATH}/libshiboken6.*")
182+
endif()
177183
endif()
178184

179185
add_subdirectory(cpp/modmesh)

cpp/modmesh/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ if (BUILD_QT)
123123
Qt::Gui
124124
)
125125

126-
target_link_libraries(
127-
modmesh_primary PUBLIC
128-
${PYSIDE6_LIBFILE}
129-
)
126+
if(MODMESH_USE_PYSIDE)
127+
target_link_libraries(
128+
modmesh_primary PUBLIC
129+
${PYSIDE6_LIBFILE}
130+
)
131+
endif()
130132
else () # BUILD_QT
131133
add_library(
132134
modmesh_primary

cpp/modmesh/toggle/toggle.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ Toggle & Toggle::instance()
6464
}
6565

6666
SolidToggle::SolidToggle()
67+
#ifdef MODMESH_USE_PYSIDE
6768
: m_use_pyside(true)
69+
#else
70+
: m_use_pyside(false)
71+
#endif
6872
{
6973
}
7074

0 commit comments

Comments
 (0)