CMake: [skip ci] add build option to let the user decide to link with shiboken/PySide at build time
This commit is contained in:
@@ -43,7 +43,7 @@ macro(SetupShibokenAndPyside)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# pyside2 changed it's cmake files, this is the dance we have
|
||||
# pyside2 changed its cmake files, this is the dance we have
|
||||
# to dance to be compatible with the old (<5.12) and the new versions (>=5.12)
|
||||
if(NOT SHIBOKEN_INCLUDE_DIR AND TARGET Shiboken2::libshiboken)
|
||||
get_property(SHIBOKEN_INCLUDE_DIR TARGET Shiboken2::libshiboken PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
@@ -137,10 +137,71 @@ macro(SetupShibokenAndPyside)
|
||||
endif(BUILD_QT5)
|
||||
|
||||
# If shiboken cannot be found the build option will be set to OFF
|
||||
if(NOT SHIBOKEN_INCLUDE_DIR)
|
||||
option(FREECAD_USE_SHIBOKEN "Links to the shiboken and PySide libraries at build time. If OFF their Python modules are imported at runtime" OFF)
|
||||
if(SHIBOKEN_INCLUDE_DIR)
|
||||
option(FREECAD_USE_SHIBOKEN "Links to the shiboken library at build time. If OFF its Python module is imported at runtime" ON)
|
||||
else()
|
||||
option(FREECAD_USE_SHIBOKEN "Links to the shiboken and PySide libraries at build time. If OFF their Python modules are imported at runtime" ON)
|
||||
endif(NOT SHIBOKEN_INCLUDE_DIR)
|
||||
option(FREECAD_USE_SHIBOKEN "Links to the shiboken library at build time. If OFF its Python module is imported at runtime" OFF)
|
||||
|
||||
# Now try to import the shiboken Python module and print a warning if it can't be loaded
|
||||
if(BUILD_QT5)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "import shiboken2"
|
||||
RESULT_VARIABLE FAILURE
|
||||
OUTPUT_VARIABLE PRINT_OUTPUT
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "import shiboken"
|
||||
RESULT_VARIABLE FAILURE
|
||||
OUTPUT_VARIABLE PRINT_OUTPUT
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FAILURE)
|
||||
message("=================================\n"
|
||||
"shiboken Python module not found.\n"
|
||||
"=================================\n")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If PySide cannot be found the build option will be set to OFF
|
||||
if(PYSIDE_INCLUDE_DIR)
|
||||
option(FREECAD_USE_PYSIDE "Links to the PySide libraries at build time." ON)
|
||||
else()
|
||||
option(FREECAD_USE_PYSIDE "Links to the PySide libraries at build time." OFF)
|
||||
endif()
|
||||
|
||||
# Independent of the build option PySide modules must be loaded at runtime. Print a warning if it fails.
|
||||
if(BUILD_QT5)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "import PySide2;import os;print(os.path.dirname(PySide2.__file__), end='')"
|
||||
RESULT_VARIABLE FAILURE
|
||||
OUTPUT_VARIABLE PRINT_OUTPUT
|
||||
)
|
||||
if(FAILURE)
|
||||
message("================================\n"
|
||||
"PySide2 Python module not found.\n"
|
||||
"================================\n")
|
||||
else()
|
||||
message(STATUS "===============================================\n"
|
||||
"PySide2 Python module found at ${PRINT_OUTPUT}.\n"
|
||||
"===============================================\n")
|
||||
endif()
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "import PySide;import os;print(os.path.dirname(PySide.__file__))"
|
||||
RESULT_VARIABLE FAILURE
|
||||
OUTPUT_VARIABLE PRINT_OUTPUT
|
||||
)
|
||||
if(FAILURE)
|
||||
message("===============================\n"
|
||||
"PySide Python module not found.\n"
|
||||
"===============================\n")
|
||||
else()
|
||||
message(STATUS "==============================================\n"
|
||||
"PySide Python module found at ${PRINT_OUTPUT}.\n"
|
||||
"==============================================\n")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endmacro(SetupShibokenAndPyside)
|
||||
|
||||
@@ -193,7 +193,7 @@ if(FREECAD_USE_SHIBOKEN)
|
||||
endif (SHIBOKEN_LIBRARY)
|
||||
endif(FREECAD_USE_SHIBOKEN)
|
||||
|
||||
if(PYSIDE_INCLUDE_DIR)
|
||||
if(FREECAD_USE_PYSIDE)
|
||||
include_directories(
|
||||
${PYSIDE_INCLUDE_DIR}
|
||||
${PYSIDE_INCLUDE_DIR}/QtCore
|
||||
@@ -218,7 +218,7 @@ if(PYSIDE_INCLUDE_DIR)
|
||||
else()
|
||||
add_definitions(-DHAVE_PYSIDE)
|
||||
endif()
|
||||
endif(PYSIDE_INCLUDE_DIR)
|
||||
endif(FREECAD_USE_PYSIDE)
|
||||
|
||||
generate_from_xml(DocumentPy)
|
||||
generate_from_xml(PythonWorkbenchPy)
|
||||
|
||||
Reference in New Issue
Block a user