From d5fb69c2e6ff13608be62ef9a4d923fb0e976d2c Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 8 Oct 2019 17:17:35 +0200 Subject: [PATCH] QtCreatorCDBExt: CMake: handle presence of release version of Python lib Done-by: cristian.adam@qt.io Change-Id: I39f13e7534a8d0d0dd1d97e1c5cff35d6dc2464d Reviewed-by: Cristian Adam Reviewed-by: Alessandro Portale --- src/libs/qtcreatorcdbext/CMakeLists.txt | 30 +++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index ffdd094bf7e..e8ee8aa2ecf 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -1,4 +1,4 @@ -if (NOT WIN32 AND NOT MSVC) +if (NOT WIN32 OR NOT MSVC) return() endif() @@ -59,6 +59,23 @@ if (NOT ${PYTHONLIBS_FOUND}) return() endif() +set(PythonRegex "^(.*)/(.*)/(python[0-9]+)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(PythonRegex "^(.*)/(.*)/(python[0-9]+_d)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") +endif() + +foreach(lib IN LISTS PYTHON_LIBRARIES) + if (lib MATCHES ${PythonRegex}) + set(PythonDll "${CMAKE_MATCH_1}/${CMAKE_MATCH_3}${CMAKE_SHARED_LIBRARY_SUFFIX}") + break() + endif() +endforeach() + +if (NOT PythonDll) + message(WARNING "PythonDll not found. qtcreatorcdbext will be built without Python support.") + return() +endif() + extend_qtc_target(qtcreatorcdbext DEPENDS "${PYTHON_LIBRARIES}" INCLUDES "${PYTHON_INCLUDE_DIR}" @@ -71,17 +88,6 @@ extend_qtc_target(qtcreatorcdbext pyvalue.cpp pyvalue.h ) -set(PythonRegex "^(.*)/(.*)/(python[0-9]+)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(PythonRegex "^(.*)/(.*)/(python[0-9]+_d)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") -endif() - -foreach(lib IN LISTS PYTHON_LIBRARIES) - if (lib MATCHES ${PythonRegex}) - set(PythonDll "${CMAKE_MATCH_1}/${CMAKE_MATCH_3}${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() -endforeach() - install(FILES "${PythonDll}" DESTINATION lib/qtcreatorcdbext${ArchSuffix}/) add_custom_target(copy_python_dll ALL VERBATIM)