From d6743bfba5a571aa74ee1329bd01ba850523a699 Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Tue, 10 Dec 2019 15:42:07 +0100 Subject: [PATCH 1/7] fix FindSphinx version --- cmake/Modules/FindSphinx.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindSphinx.cmake b/cmake/Modules/FindSphinx.cmake index d8ec47b2..9a385f97 100644 --- a/cmake/Modules/FindSphinx.cmake +++ b/cmake/Modules/FindSphinx.cmake @@ -1,5 +1,5 @@ # ****************************************************************************** -# Copyright 2017-2018 Intel Corporation +# Copyright 2017-2019 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ if (SPHINX_EXECUTABLE) RESULT_VARIABLE __sphinx_result OUTPUT_VARIABLE __sphinx_output ERROR_VARIABLE __sphinx_error OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) if (__sphinx_result MATCHES 0) - string(REGEX MATCH ".* ([0-9]+)\\.([0-9]+)\\.([0-9]+)" __sphinx_version_check "${__sphinx_error}") + string(REGEX MATCH ".* ([0-9]+)\\.([0-9]+)\\.([0-9]+)" __sphinx_version_check "${__sphinx_output}") set(SPHINX_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}) else() set(__sphinx_output "${__sphinx_error}") From 8404e55ec53d85c6bd52ce2f8a1dcdefd6205f81 Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Tue, 10 Dec 2019 15:42:46 +0100 Subject: [PATCH 2/7] fix python discovery conflict --- CMakeLists.txt | 27 ++++---------- cmake/Modules/FindNumPy.cmake | 55 ---------------------------- cmake/summary.cmake | 8 ++-- examples/cpp_iterator/CMakeLists.txt | 2 +- examples/plugins/CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 +-- test/CMakeLists.txt | 2 +- 7 files changed, 18 insertions(+), 84 deletions(-) delete mode 100644 cmake/Modules/FindNumPy.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b245572..abce24a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # limitations under the License. # ****************************************************************************** -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.13.3) # Set this flag before project definition to avoid using other compiler by gtest set(CMAKE_CXX_COMPILER "g++") @@ -164,30 +164,19 @@ find_package(CURL REQUIRED) include_directories(${CURL_INCLUDE_DIRS}) link_directories(${CURL_LIBRARY_DIRS}) -# set(Python_ADDITIONAL_VERSIONS 3.6 3.5 3.4) - -find_package(PythonInterp) -find_package(PythonLibs) +find_package(Python COMPONENTS Interpreter Development NumPy) if (PYTHON_PLUGIN) - if (NOT ${PYTHON_VERISON_MAJOR} EQUAL ${OpenCV_VERSION_MAJOR}) - message(WARNING "Python version " ${PYTHON_VERSION_MAJOR} " incompatible with OpenCV version " ${OpenCV_VERSION_MAJOR}) + if (NOT ${Python_VERISON_MAJOR} EQUAL ${OpenCV_VERSION_MAJOR}) + message(WARNING "Python version " ${Python_VERSION_MAJOR} " incompatible with OpenCV version " ${OpenCV_VERSION_MAJOR}) endif () endif (PYTHON_PLUGIN) -if (PYTHONLIBS_FOUND) - find_package(NumPy) - if(NUMPY_FOUND) - set(PYTHON_FOUND true) +if (Python_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPYTHON_FOUND") - include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS}) - link_directories(${PYTHON_LIBRARY_DIRS}) - include_directories(SYSTEM ${NUMPY_INCLUDE_DIRS}) - link_directories(${NUMPY_LIBRARY_DIRS}) - endif(NUMPY_FOUND) -else() - unset(PYTHON_LIBRARIES) -endif (PYTHONLIBS_FOUND) + include_directories(SYSTEM ${Python_INCLUDE_DIRS} ${Python_NumPy_INCLUDE_DIRS}) + link_directories(${Python_LIBRARY_DIRS}) +endif (Python_FOUND) if (ENABLE_AEON_SERVICE) # Check for C++ REST SDK from Microsoft diff --git a/cmake/Modules/FindNumPy.cmake b/cmake/Modules/FindNumPy.cmake deleted file mode 100644 index 47a30d54..00000000 --- a/cmake/Modules/FindNumPy.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# ****************************************************************************** -# Copyright 2017-2018 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ****************************************************************************** - -unset(NUMPY_VERSION) -unset(NUMPY_INCLUDE_DIRS) - -if(NOT PYTHON_EXECUTABLE) - if(NumPy_FIND_QUIETLY) - find_package(PythonInterp QUIET) - else() - find_package(PythonInterp) - endif() -endif() - -if(PYTHONINTERP_FOUND) - execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import numpy as n; print(n.__version__); print(n.get_include());" - RESULT_VARIABLE __numpy_result - OUTPUT_VARIABLE __numpy_output - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (__numpy_result MATCHES 0) - string(REGEX REPLACE ";" "\\\\;" __numpy_values ${__numpy_output}) - string(REGEX REPLACE "\r?\n" ";" __numpy_values ${__numpy_values}) - list(GET __numpy_values 0 NUMPY_VERSION) - list(GET __numpy_values 1 NUMPY_INCLUDE_DIRS) - string(REGEX MATCH "^([0-9])+\\.([0-9])+\\.([0-9])+" __numpy_version_check "${NUMPY_VERSION}") - if (NOT "${__numpy_version_check}" STREQUAL "") - set(NUMPY_VERSION_MAJOR ${CMAKE_MATCH_1}) - set(NUMPY_VERSION_MINOR ${CMAKE_MATCH_2}) - set(NUMPY_VERSION_PATCH ${CMAKE_MATCH_3}) - else() - set(NUMPY_VERSION "?unknown?") - message(WARNING "NumPy: problem extracting version!") - endif() - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(NumPy REQUIRED_VARS NUMPY_INCLUDE_DIRS NUMPY_VERSION - VERSION_VAR NUMPY_VERSION) - diff --git a/cmake/summary.cmake b/cmake/summary.cmake index f6efb614..5e5ccf49 100644 --- a/cmake/summary.cmake +++ b/cmake/summary.cmake @@ -69,7 +69,7 @@ function(print_configuration_summary) else() report_status(" AEON Service : No") endif() - report_status(" AEON Python Interface : " PYTHONLIBS_FOUND AND NUMPY_FOUND THEN "Yes" ELSE "No (Python not found, see details below)") + report_status(" AEON Python Interface : " Python_FOUND THEN "Yes" ELSE "No (Python not found, see details below)") report_status(" AEON Python Plugin : " PYTHON_PLUGIN THEN "Yes" ELSE "No") if (ENABLE_AEON_SERVICE) report_status("") @@ -91,9 +91,9 @@ function(print_configuration_summary) report_status(" OpenSSL : " OPENSSL_FOUND THEN "Yes (ver. ${OPENSSL_VERSION})" ELSE "Not Found") report_status("") report_status(" Python:") - report_status(" Interpreter : " PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver. ${PYTHON_VERSION_STRING})" ELSE "No") - report_status(" Libraries : " PYTHONLIBS_FOUND THEN "${PYTHON_LIBRARIES} (ver. ${PYTHONLIBS_VERSION_STRING})" ELSE "No") - report_status(" NumPy : " NUMPY_FOUND THEN "${NUMPY_INCLUDE_DIRS} (ver. ${NUMPY_VERSION})" ELSE "No") + report_status(" Interpreter : " Python_Interpreter_FOUND THEN "${Python_EXECUTABLE} (ver. ${Python_VERSION})" ELSE "No") + report_status(" Libraries : " Python_Development_FOUND THEN "${Python_LIBRARIES}" ELSE "No") + report_status(" NumPy : " Python_NumPy_FOUND THEN "${Python_NUMPY_INCLUDE_DIRS} (ver. ${Python_NumPy_VERSION})" ELSE "No") report_status("") report_status(" Documentation:") report_status(" Doxygen : " DOXYGEN_FOUND THEN "${DOXYGEN_EXECUTABLE} (ver. ${DOXYGEN_VERSION})" ELSE "No") diff --git a/examples/cpp_iterator/CMakeLists.txt b/examples/cpp_iterator/CMakeLists.txt index a054d83e..6ff3e02b 100644 --- a/examples/cpp_iterator/CMakeLists.txt +++ b/examples/cpp_iterator/CMakeLists.txt @@ -22,5 +22,5 @@ file(COPY ${TEST_DATA_DIR}/flowers.jpg DESTINATION .) file(COPY ${TEST_DATA_DIR}/img_2112_70.jpg DESTINATION .) add_executable(iterator ${SRC}) -target_link_libraries(iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${Python_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(iterator aeon) diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt index f6bdd3fb..043ecf25 100644 --- a/examples/plugins/CMakeLists.txt +++ b/examples/plugins/CMakeLists.txt @@ -6,5 +6,5 @@ file(COPY ${TEST_DATA_DIR}/flowers.jpg DESTINATION .) file(COPY ${TEST_DATA_DIR}/img_2112_70.jpg DESTINATION .) add_executable(plugin_iterator ${SRC}) -target_link_libraries(plugin_iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(plugin_iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${Python_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(plugin_iterator aeon) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c17d643..6e8501f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,9 +78,9 @@ endif() set(AEON_HEADER_FILES version.hpp) -if (PYTHON_FOUND) +if (Python_FOUND) list(APPEND SRC api.cpp) -endif(PYTHON_FOUND) +endif(Python_FOUND) if (PYTHON_PLUGIN) list(APPEND SRC python_plugin.cpp @@ -96,7 +96,7 @@ add_library(aeon SHARED ${SRC} ${AEON_HEADER_FILES}) install(TARGETS aeon DESTINATION lib) -set(AEON_LIBRARIES ${CURL_LIBRARIES} ${OpenCV_LIBRARIES} ${PYTHON_LIBRARIES}) +set(AEON_LIBRARIES ${CURL_LIBRARIES} ${OpenCV_LIBRARIES} ${Python_LIBRARIES}) if (ENABLE_OPENFABRICS_CONNECTOR) list(APPEND AEON_LIBRARIES ${OPENFABRICS_LIBRARIES}) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 15cf3d12..56b96a66 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -55,7 +55,7 @@ set (SRC ) set(TESTSUITE_LIBRARIES aeon gtest gmock - ${LCOVERAGE} ${OpenCV_LIBRARIES} ${PYTHON_LIBRARIES} + ${LCOVERAGE} ${OpenCV_LIBRARIES} ${Python_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if (ENABLE_AEON_SERVICE) From 019d29f58d71acedb62a9273163938fee99d04be Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Mon, 16 Dec 2019 14:37:15 +0100 Subject: [PATCH 3/7] bring back compatibility with old cmake --- CMakeLists.txt | 37 +++++++++++++++++++++-- cmake/Modules/FindNumPy.cmake | 55 +++++++++++++++++++++++++++++++++++ cmake/summary.cmake | 7 ++++- 3 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 cmake/Modules/FindNumPy.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index abce24a0..9dc1ac43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # limitations under the License. # ****************************************************************************** -cmake_minimum_required(VERSION 3.13.3) +cmake_minimum_required(VERSION 2.8.12) # Set this flag before project definition to avoid using other compiler by gtest set(CMAKE_CXX_COMPILER "g++") @@ -164,10 +164,41 @@ find_package(CURL REQUIRED) include_directories(${CURL_INCLUDE_DIRS}) link_directories(${CURL_LIBRARY_DIRS}) -find_package(Python COMPONENTS Interpreter Development NumPy) +if (${CMAKE_VERSION} VERSION_LESS "3.13.3") + find_package(PythonInterp) + set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND}) + set(Python_EXECUTABLE ${Python_EXECUTABLE}) + set(Python_VERSION ${PYTHON_VERSION_STRING}) + set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) + set(Python_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS} ${NUMPY_LIBRARY_DIRS}) + set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) + find_package(PythonLibs) + set(Python_Development_FOUND ${PYTHONLIBS_FOUND}) + if (PYTHONLIBS_FOUND) + if (${PYTHONLIBS_VERSION_STRING} VERSION_LESS "${PYTHON_VERSION_MAJOR}.0.0") + message(WARNING "Python library version found does not match python interpreter version. Specify PYTHON_LIBRARY and PYTHON_INCLUDE_DIR manually.") + endif() + set(Python_LIBRARIES ${PYTHON_LIBRARIES}) + find_package(NumPy) + if(NUMPY_FOUND) + set(Python_NumPy_FOUND TRUE) + set(Python_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + set(Python_NumPy_VERSION ${NUMPY_VERSION}) + set(Python_FOUND TRUE) + endif(NUMPY_FOUND) + else() + unset(PYTHON_LIBRARIES) + endif (PYTHONLIBS_FOUND) + set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) + set(Python_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS}) + set(Python_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) +else() + find_package(Python COMPONENTS Interpreter Development NumPy) +endif() if (PYTHON_PLUGIN) - if (NOT ${Python_VERISON_MAJOR} EQUAL ${OpenCV_VERSION_MAJOR}) + if (${Python_VERISON_MAJOR} LESS ${OpenCV_VERSION_MAJOR}) message(WARNING "Python version " ${Python_VERSION_MAJOR} " incompatible with OpenCV version " ${OpenCV_VERSION_MAJOR}) endif () endif (PYTHON_PLUGIN) diff --git a/cmake/Modules/FindNumPy.cmake b/cmake/Modules/FindNumPy.cmake new file mode 100644 index 00000000..47a30d54 --- /dev/null +++ b/cmake/Modules/FindNumPy.cmake @@ -0,0 +1,55 @@ +# ****************************************************************************** +# Copyright 2017-2018 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ****************************************************************************** + +unset(NUMPY_VERSION) +unset(NUMPY_INCLUDE_DIRS) + +if(NOT PYTHON_EXECUTABLE) + if(NumPy_FIND_QUIETLY) + find_package(PythonInterp QUIET) + else() + find_package(PythonInterp) + endif() +endif() + +if(PYTHONINTERP_FOUND) + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" + "import numpy as n; print(n.__version__); print(n.get_include());" + RESULT_VARIABLE __numpy_result + OUTPUT_VARIABLE __numpy_output + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (__numpy_result MATCHES 0) + string(REGEX REPLACE ";" "\\\\;" __numpy_values ${__numpy_output}) + string(REGEX REPLACE "\r?\n" ";" __numpy_values ${__numpy_values}) + list(GET __numpy_values 0 NUMPY_VERSION) + list(GET __numpy_values 1 NUMPY_INCLUDE_DIRS) + string(REGEX MATCH "^([0-9])+\\.([0-9])+\\.([0-9])+" __numpy_version_check "${NUMPY_VERSION}") + if (NOT "${__numpy_version_check}" STREQUAL "") + set(NUMPY_VERSION_MAJOR ${CMAKE_MATCH_1}) + set(NUMPY_VERSION_MINOR ${CMAKE_MATCH_2}) + set(NUMPY_VERSION_PATCH ${CMAKE_MATCH_3}) + else() + set(NUMPY_VERSION "?unknown?") + message(WARNING "NumPy: problem extracting version!") + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NumPy REQUIRED_VARS NUMPY_INCLUDE_DIRS NUMPY_VERSION + VERSION_VAR NUMPY_VERSION) + diff --git a/cmake/summary.cmake b/cmake/summary.cmake index 5e5ccf49..de42d4f0 100644 --- a/cmake/summary.cmake +++ b/cmake/summary.cmake @@ -91,8 +91,13 @@ function(print_configuration_summary) report_status(" OpenSSL : " OPENSSL_FOUND THEN "Yes (ver. ${OPENSSL_VERSION})" ELSE "Not Found") report_status("") report_status(" Python:") + if (PYTHONLIBS_VERSION_STRING) + set(APPEND_VER_IF_PRESENT " (ver. ${PYTHONLIBS_VERSION_STRING})") + else() + unset(APPEND_VER_IF_PRESENT) + endif() report_status(" Interpreter : " Python_Interpreter_FOUND THEN "${Python_EXECUTABLE} (ver. ${Python_VERSION})" ELSE "No") - report_status(" Libraries : " Python_Development_FOUND THEN "${Python_LIBRARIES}" ELSE "No") + report_status(" Libraries : " Python_Development_FOUND THEN "${Python_LIBRARIES}${APPEND_VER_IF_PRESENT}" ELSE "No") report_status(" NumPy : " Python_NumPy_FOUND THEN "${Python_NUMPY_INCLUDE_DIRS} (ver. ${Python_NumPy_VERSION})" ELSE "No") report_status("") report_status(" Documentation:") From fc758ef64ee84a628c43225c49ec021431368b5a Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Mon, 16 Dec 2019 19:05:20 +0100 Subject: [PATCH 4/7] fix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9dc1ac43..3d16ca52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,7 +175,7 @@ if (${CMAKE_VERSION} VERSION_LESS "3.13.3") find_package(PythonLibs) set(Python_Development_FOUND ${PYTHONLIBS_FOUND}) if (PYTHONLIBS_FOUND) - if (${PYTHONLIBS_VERSION_STRING} VERSION_LESS "${PYTHON_VERSION_MAJOR}.0.0") + if (${PYTHONLIBS_VERSION_STRING} VERSION_LESS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.0") message(WARNING "Python library version found does not match python interpreter version. Specify PYTHON_LIBRARY and PYTHON_INCLUDE_DIR manually.") endif() set(Python_LIBRARIES ${PYTHON_LIBRARIES}) From 08c941305a11191c495eac55f8e7eddf2bd756de Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Thu, 19 Dec 2019 14:20:06 +0100 Subject: [PATCH 5/7] review fixes typos --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d16ca52..8fbadb17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,7 +167,7 @@ link_directories(${CURL_LIBRARY_DIRS}) if (${CMAKE_VERSION} VERSION_LESS "3.13.3") find_package(PythonInterp) set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND}) - set(Python_EXECUTABLE ${Python_EXECUTABLE}) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) set(Python_VERSION ${PYTHON_VERSION_STRING}) set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) set(Python_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS} ${NUMPY_LIBRARY_DIRS}) @@ -198,7 +198,7 @@ else() endif() if (PYTHON_PLUGIN) - if (${Python_VERISON_MAJOR} LESS ${OpenCV_VERSION_MAJOR}) + if (${Python_VERSION_MAJOR} LESS ${OpenCV_VERSION_MAJOR}) message(WARNING "Python version " ${Python_VERSION_MAJOR} " incompatible with OpenCV version " ${OpenCV_VERSION_MAJOR}) endif () endif (PYTHON_PLUGIN) From ee4e3ad2c7d64b8fdee8f7d051e4b78fad916a03 Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Tue, 7 Jan 2020 15:59:05 +0100 Subject: [PATCH 6/7] cmake version 3.14.7 instead of 3.13.3 required for finding numpy --- CMakeLists.txt | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fbadb17..bdf6ecd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,16 +164,9 @@ find_package(CURL REQUIRED) include_directories(${CURL_INCLUDE_DIRS}) link_directories(${CURL_LIBRARY_DIRS}) -if (${CMAKE_VERSION} VERSION_LESS "3.13.3") +if (${CMAKE_VERSION} VERSION_LESS "3.14.7") find_package(PythonInterp) - set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND}) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(Python_VERSION ${PYTHON_VERSION_STRING}) - set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) - set(Python_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS} ${NUMPY_LIBRARY_DIRS}) - set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) find_package(PythonLibs) - set(Python_Development_FOUND ${PYTHONLIBS_FOUND}) if (PYTHONLIBS_FOUND) if (${PYTHONLIBS_VERSION_STRING} VERSION_LESS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.0") message(WARNING "Python library version found does not match python interpreter version. Specify PYTHON_LIBRARY and PYTHON_INCLUDE_DIR manually.") @@ -189,20 +182,18 @@ if (${CMAKE_VERSION} VERSION_LESS "3.13.3") else() unset(PYTHON_LIBRARIES) endif (PYTHONLIBS_FOUND) + set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND}) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + set(Python_VERSION ${PYTHON_VERSION_STRING}) set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) - set(Python_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS}) - set(Python_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + set(Python_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS} ${NUMPY_LIBRARY_DIRS}) set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) + set(Python_Development_FOUND ${PYTHONLIBS_FOUND}) + set(Python_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) else() find_package(Python COMPONENTS Interpreter Development NumPy) endif() -if (PYTHON_PLUGIN) - if (${Python_VERSION_MAJOR} LESS ${OpenCV_VERSION_MAJOR}) - message(WARNING "Python version " ${Python_VERSION_MAJOR} " incompatible with OpenCV version " ${OpenCV_VERSION_MAJOR}) - endif () -endif (PYTHON_PLUGIN) - if (Python_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPYTHON_FOUND") include_directories(SYSTEM ${Python_INCLUDE_DIRS} ${Python_NumPy_INCLUDE_DIRS}) From dd552be7c6583f89e2a36a73465306cbd72bdf3b Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Tue, 7 Jan 2020 16:32:16 +0100 Subject: [PATCH 7/7] transition to python3; drop python2 --- CMakeLists.txt | 40 ++++++++++++++-------------- cmake/Modules/FindNumPy.cmake | 4 +-- cmake/summary.cmake | 8 +++--- examples/cpp_iterator/CMakeLists.txt | 2 +- examples/plugins/CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 ++--- test/CMakeLists.txt | 2 +- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bdf6ecd6..be8cc49b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,40 +165,40 @@ include_directories(${CURL_INCLUDE_DIRS}) link_directories(${CURL_LIBRARY_DIRS}) if (${CMAKE_VERSION} VERSION_LESS "3.14.7") - find_package(PythonInterp) - find_package(PythonLibs) + find_package(PythonInterp 3.0) + find_package(PythonLibs 3.0) if (PYTHONLIBS_FOUND) if (${PYTHONLIBS_VERSION_STRING} VERSION_LESS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.0") message(WARNING "Python library version found does not match python interpreter version. Specify PYTHON_LIBRARY and PYTHON_INCLUDE_DIR manually.") endif() - set(Python_LIBRARIES ${PYTHON_LIBRARIES}) + set(Python3_LIBRARIES ${PYTHON_LIBRARIES}) find_package(NumPy) if(NUMPY_FOUND) - set(Python_NumPy_FOUND TRUE) - set(Python_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) - set(Python_NumPy_VERSION ${NUMPY_VERSION}) - set(Python_FOUND TRUE) + set(Python3_NumPy_FOUND TRUE) + set(Python3_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + set(Python3_NumPy_VERSION ${NUMPY_VERSION}) + set(Python3_FOUND TRUE) endif(NUMPY_FOUND) else() unset(PYTHON_LIBRARIES) endif (PYTHONLIBS_FOUND) - set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND}) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(Python_VERSION ${PYTHON_VERSION_STRING}) - set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) - set(Python_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS} ${NUMPY_LIBRARY_DIRS}) - set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) - set(Python_Development_FOUND ${PYTHONLIBS_FOUND}) - set(Python_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND}) + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) + set(Python3_VERSION ${PYTHON_VERSION_STRING}) + set(Python3_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) + set(Python3_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS} ${NUMPY_LIBRARY_DIRS}) + set(Python3_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) + set(Python3_Development_FOUND ${PYTHONLIBS_FOUND}) + set(Python3_NumPy_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) else() - find_package(Python COMPONENTS Interpreter Development NumPy) + find_package(Python3 COMPONENTS Interpreter Development NumPy) endif() -if (Python_FOUND) +if (Python3_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPYTHON_FOUND") - include_directories(SYSTEM ${Python_INCLUDE_DIRS} ${Python_NumPy_INCLUDE_DIRS}) - link_directories(${Python_LIBRARY_DIRS}) -endif (Python_FOUND) + include_directories(SYSTEM ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS}) + link_directories(${Python3_LIBRARY_DIRS}) +endif (Python3_FOUND) if (ENABLE_AEON_SERVICE) # Check for C++ REST SDK from Microsoft diff --git a/cmake/Modules/FindNumPy.cmake b/cmake/Modules/FindNumPy.cmake index 47a30d54..1f6c37a2 100644 --- a/cmake/Modules/FindNumPy.cmake +++ b/cmake/Modules/FindNumPy.cmake @@ -19,9 +19,9 @@ unset(NUMPY_INCLUDE_DIRS) if(NOT PYTHON_EXECUTABLE) if(NumPy_FIND_QUIETLY) - find_package(PythonInterp QUIET) + find_package(PythonInterp 3.0 QUIET) else() - find_package(PythonInterp) + find_package(PythonInterp 3.0) endif() endif() diff --git a/cmake/summary.cmake b/cmake/summary.cmake index de42d4f0..7d01531b 100644 --- a/cmake/summary.cmake +++ b/cmake/summary.cmake @@ -69,7 +69,7 @@ function(print_configuration_summary) else() report_status(" AEON Service : No") endif() - report_status(" AEON Python Interface : " Python_FOUND THEN "Yes" ELSE "No (Python not found, see details below)") + report_status(" AEON Python Interface : " Python3_FOUND THEN "Yes" ELSE "No (Python not found, see details below)") report_status(" AEON Python Plugin : " PYTHON_PLUGIN THEN "Yes" ELSE "No") if (ENABLE_AEON_SERVICE) report_status("") @@ -96,9 +96,9 @@ function(print_configuration_summary) else() unset(APPEND_VER_IF_PRESENT) endif() - report_status(" Interpreter : " Python_Interpreter_FOUND THEN "${Python_EXECUTABLE} (ver. ${Python_VERSION})" ELSE "No") - report_status(" Libraries : " Python_Development_FOUND THEN "${Python_LIBRARIES}${APPEND_VER_IF_PRESENT}" ELSE "No") - report_status(" NumPy : " Python_NumPy_FOUND THEN "${Python_NUMPY_INCLUDE_DIRS} (ver. ${Python_NumPy_VERSION})" ELSE "No") + report_status(" Interpreter : " Python3_Interpreter_FOUND THEN "${Python3_EXECUTABLE} (ver. ${Python3_VERSION})" ELSE "No") + report_status(" Libraries : " Python3_Development_FOUND THEN "${Python3_LIBRARIES}${APPEND_VER_IF_PRESENT}" ELSE "No") + report_status(" NumPy : " Python3_NumPy_FOUND THEN "${Python3_NUMPY_INCLUDE_DIRS} (ver. ${Python3_NumPy_VERSION})" ELSE "No") report_status("") report_status(" Documentation:") report_status(" Doxygen : " DOXYGEN_FOUND THEN "${DOXYGEN_EXECUTABLE} (ver. ${DOXYGEN_VERSION})" ELSE "No") diff --git a/examples/cpp_iterator/CMakeLists.txt b/examples/cpp_iterator/CMakeLists.txt index 6ff3e02b..cdfdb433 100644 --- a/examples/cpp_iterator/CMakeLists.txt +++ b/examples/cpp_iterator/CMakeLists.txt @@ -22,5 +22,5 @@ file(COPY ${TEST_DATA_DIR}/flowers.jpg DESTINATION .) file(COPY ${TEST_DATA_DIR}/img_2112_70.jpg DESTINATION .) add_executable(iterator ${SRC}) -target_link_libraries(iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${Python_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${Python3_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(iterator aeon) diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt index 043ecf25..41a962f9 100644 --- a/examples/plugins/CMakeLists.txt +++ b/examples/plugins/CMakeLists.txt @@ -6,5 +6,5 @@ file(COPY ${TEST_DATA_DIR}/flowers.jpg DESTINATION .) file(COPY ${TEST_DATA_DIR}/img_2112_70.jpg DESTINATION .) add_executable(plugin_iterator ${SRC}) -target_link_libraries(plugin_iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${Python_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(plugin_iterator aeon pthread ${CURL_LIBRARIES} opencv_imgproc opencv_highgui opencv_core ${Python3_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(plugin_iterator aeon) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e8501f3..fd891f8f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,9 +78,9 @@ endif() set(AEON_HEADER_FILES version.hpp) -if (Python_FOUND) +if (Python3_FOUND) list(APPEND SRC api.cpp) -endif(Python_FOUND) +endif(Python3_FOUND) if (PYTHON_PLUGIN) list(APPEND SRC python_plugin.cpp @@ -96,7 +96,7 @@ add_library(aeon SHARED ${SRC} ${AEON_HEADER_FILES}) install(TARGETS aeon DESTINATION lib) -set(AEON_LIBRARIES ${CURL_LIBRARIES} ${OpenCV_LIBRARIES} ${Python_LIBRARIES}) +set(AEON_LIBRARIES ${CURL_LIBRARIES} ${OpenCV_LIBRARIES} ${Python3_LIBRARIES}) if (ENABLE_OPENFABRICS_CONNECTOR) list(APPEND AEON_LIBRARIES ${OPENFABRICS_LIBRARIES}) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 56b96a66..12bede84 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -55,7 +55,7 @@ set (SRC ) set(TESTSUITE_LIBRARIES aeon gtest gmock - ${LCOVERAGE} ${OpenCV_LIBRARIES} ${Python_LIBRARIES} + ${LCOVERAGE} ${OpenCV_LIBRARIES} ${Python3_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if (ENABLE_AEON_SERVICE)