diff --git a/openmp/libompd/CMakeLists.txt b/openmp/libompd/CMakeLists.txt --- a/openmp/libompd/CMakeLists.txt +++ b/openmp/libompd/CMakeLists.txt @@ -8,10 +8,73 @@ #//===----------------------------------------------------------------------===// # +find_package (Python3 COMPONENTS Interpreter Development) + if(LIBOMP_OMPD_SUPPORT) - set(OMPD_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/) - add_subdirectory(src) - if(NOT DISABLE_OMPD_GDB_PLUGIN) - add_subdirectory(gdb-plugin) + set(OMPD_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/) + add_subdirectory(src) + if(NOT DISABLE_OMPD_GDB_PLUGIN) + file(READ "/etc/os-release" OS_RELEASE) + set(DIST "") + string(REGEX MATCH "Debian|debian|Ubuntu|ubuntu" DIST ${OS_RELEASE}) + # UBUNTU and Debian package manager have its own patch in "pip" to avoid user + # installed packages messing up with default paths. + # https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1419695 + # Therfore, we have to use "--system" (specific to ubuntu and debian) when we + # use system installed pip.(Not required if user installed pip on other paths.) + # However, this has been taken care in pip for 20+ versions. + # https://github.com/pypa/pip/commit/5f1468274987348b569aa586eeca4363494d0357 + if(DIST) + execute_process(COMMAND "${Python3_EXECUTABLE}" + "-mpip" + "--version" + OUTPUT_VARIABLE PIP_VERSION_INFO + RESULT_VARIABLE HAD_ERROR) + if (NOT ${HAD_ERROR} EQUAL 0) + message(WARNING "PIP command failed, gdb-plugin disabled.") + return() + endif () + + string(REGEX REPLACE " " ";" PIP_VERSION_INFO "${PIP_VERSION_INFO}") + list(GET PIP_VERSION_INFO 1 PIP_VERSION) + set(PYSYSFLAG "") + + if(PIP_VERSION VERSION_LESS "20.0.0") + execute_process(COMMAND "${Python3_EXECUTABLE}" + "-mpip" + "install" + "--help" + OUTPUT_VARIABLE PIP_INSTALL_HELP + RESULT_VARIABLE HAD_ERROR ) + string(REGEX MATCH "--system" SYSTEM_FLAG ${PIP_INSTALL_HELP}) + if (SYSTEM_FLAG) + set(PYSYSFLAG "--system") + endif() + endif() + + #Python code used by gdb-plugin depends on "wheel" and "setuptool" + #packages. Skip the gdb-plugin if those are not available. + execute_process(COMMAND "${Python3_EXECUTABLE}" "-mpip" "show" "wheel" + OUTPUT_VARIABLE PIP3_SHOW_INFO + RESULT_VARIABLE PIP3_ERROR) + if (NOT ${PIP3_ERROR} EQUAL 0) + message(WARNING "PIP command failed, gdb-plugin disabled.") + return() + endif() + string(FIND ${PIP3_SHOW_INFO} "not found" WHEEL_FOUND) + if(NOT WHEEL_FOUND EQUAL -1) + message(WARNING "Required wheel, not found. gdb-plugin disabled.") + return() + endif() + execute_process(COMMAND "${Python3_EXECUTABLE}" "-mpip" "show" "setuptools" + OUTPUT_VARIABLE PIP3_SHOW_INFO + RESULT_VARIABLE PIP3_ERROR) + string(FIND ${PIP3_SHOW_INFO} "not found" SETUP_FOUND) + if(NOT SETUP_FOUND EQUAL -1) + message(WARNING "Required setuptools, not found. gdb-plugin disabled.") + return() + endif() endif() + add_subdirectory(gdb-plugin) + endif() endif() diff --git a/openmp/libompd/gdb-plugin/CMakeLists.txt b/openmp/libompd/gdb-plugin/CMakeLists.txt --- a/openmp/libompd/gdb-plugin/CMakeLists.txt +++ b/openmp/libompd/gdb-plugin/CMakeLists.txt @@ -15,45 +15,7 @@ find_package (Python3 COMPONENTS Interpreter Development) -file(READ "/etc/os-release" OS_RELEASE) -set(DIST "") -string(REGEX MATCH "Debian|Ubuntu" DIST ${OS_RELEASE}) -# UBUNTU and Debian package manager have its own patch in "pip" to avoid user -# installed packages messing up with default paths. -# https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1419695 -# Therfore, we have to use "--system" (specific to ubuntu and debian) when we -# use system installed pip.(Not required if user installed pip on other paths.) -# However, this has been taken care in pip for 20+ versions. -# https://github.com/pypa/pip/commit/5f1468274987348b569aa586eeca4363494d0357 - -if(DIST) - execute_process(COMMAND "${Python3_EXECUTABLE}" - "-mpip" - "--version" - OUTPUT_VARIABLE PIP_VERSION_INFO - RESULT_VARIABLE HAD_ERROR) - if (NOT ${HAD_ERROR} EQUAL 0) - message(WARNING "PIP command failed, gdb-plugin disabled.") - return() - endif () - string(REGEX REPLACE " " ";" PIP_VERSION_INFO "${PIP_VERSION_INFO}") - list(GET PIP_VERSION_INFO 1 PIP_VERSION) - set(PYSYSFLAG "") - - if(PIP_VERSION VERSION_LESS "20.0.0") - execute_process(COMMAND "${Python3_EXECUTABLE}" - "-mpip" - "install" - "--help" - OUTPUT_VARIABLE PIP_INSTALL_HELP - RESULT_VARIABLE HAD_ERROR ) - string(REGEX MATCH "--system" SYSTEM_FLAG ${PIP_INSTALL_HELP}) - if (SYSTEM_FLAG) - set(PYSYSFLAG "--system") - endif() - endif() -endif() include_directories (${OMPD_INCLUDE_PATH}) include_directories (${LIBOMP_INCLUDE_DIR})