From 851e235b5792a9f98d0d150bebb0ebf1e945d12e Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 11 Jan 2023 16:15:54 +0900 Subject: [PATCH 1/4] GH-26394: [Python] Don't use target_include_directories() for imported target It requires CMake 3.11 or later. --- cpp/cmake_modules/FindPythonLibsNew.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cpp/cmake_modules/FindPythonLibsNew.cmake b/cpp/cmake_modules/FindPythonLibsNew.cmake index 5cb5c958b98..b13cb35c9c4 100644 --- a/cpp/cmake_modules/FindPythonLibsNew.cmake +++ b/cpp/cmake_modules/FindPythonLibsNew.cmake @@ -218,7 +218,12 @@ find_package_message(PYTHON "${PYTHON_EXECUTABLE}${PYTHON_VERSION}") add_library(Python3::Module SHARED IMPORTED) -target_include_directories(Python3::Module INTERFACE ${PYTHON_INCLUDE_DIRS}) +if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(Python3::Module PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + ${PYTHON_INCLUDE_DIRS}) +else() + target_include_directories(Python3::Module INTERFACE ${PYTHON_INCLUDE_DIRS}) +endif() set_target_properties(Python3::Module PROPERTIES IMPORTED_LOCATION "${PYTHON_LIBRARIES}" IMPORTED_IMPLIB "${PYTHON_LIBRARIES}") From 04ffaef105d6451d158ee206e3917c1032eb0b9d Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Thu, 12 Jan 2023 05:58:10 +0900 Subject: [PATCH 2/4] Use INTERFACE_INCLUDE_DIRECTORIES --- cpp/cmake_modules/FindNumPy.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpp/cmake_modules/FindNumPy.cmake b/cpp/cmake_modules/FindNumPy.cmake index 46dc31f674b..70108bf56ea 100644 --- a/cpp/cmake_modules/FindNumPy.cmake +++ b/cpp/cmake_modules/FindNumPy.cmake @@ -96,5 +96,11 @@ find_package_message(NUMPY set(NUMPY_FOUND TRUE) add_library(Python3::NumPy INTERFACE IMPORTED) -target_include_directories(Python3::NumPy INTERFACE ${NUMPY_INCLUDE_DIRS}) +if(CMAKE_VERSION VERSION_LESS 3.11) + target_include_directories(Python3::NumPy PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + ${NUMPY_INCLUDE_DIRS}) + set_target_properties(Python3::Module PROPERTIES INTERFACE_INCLUDE_DIRECTORIES +else() + target_include_directories(Python3::NumPy INTERFACE ${NUMPY_INCLUDE_DIRS}) +endif() target_link_libraries(Python3::NumPy INTERFACE Python3::Module) From a90978932352a8c55aa7debd760b2176bf1fa2ad Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Thu, 12 Jan 2023 15:11:50 +0900 Subject: [PATCH 3/4] Remove garbage --- cpp/cmake_modules/FindNumPy.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/cmake_modules/FindNumPy.cmake b/cpp/cmake_modules/FindNumPy.cmake index 70108bf56ea..2ea1a7428d2 100644 --- a/cpp/cmake_modules/FindNumPy.cmake +++ b/cpp/cmake_modules/FindNumPy.cmake @@ -97,9 +97,8 @@ set(NUMPY_FOUND TRUE) add_library(Python3::NumPy INTERFACE IMPORTED) if(CMAKE_VERSION VERSION_LESS 3.11) - target_include_directories(Python3::NumPy PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + set_target_properties(Python3::NumPy PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${NUMPY_INCLUDE_DIRS}) - set_target_properties(Python3::Module PROPERTIES INTERFACE_INCLUDE_DIRECTORIES else() target_include_directories(Python3::NumPy INTERFACE ${NUMPY_INCLUDE_DIRS}) endif() From 2175f99e3eadae50031bb95834862a7dc6edc24a Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Thu, 12 Jan 2023 20:28:46 +0900 Subject: [PATCH 4/4] Can't use target_link_libraries() --- cpp/cmake_modules/FindNumPy.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpp/cmake_modules/FindNumPy.cmake b/cpp/cmake_modules/FindNumPy.cmake index 2ea1a7428d2..cdca68a5f24 100644 --- a/cpp/cmake_modules/FindNumPy.cmake +++ b/cpp/cmake_modules/FindNumPy.cmake @@ -97,9 +97,10 @@ set(NUMPY_FOUND TRUE) add_library(Python3::NumPy INTERFACE IMPORTED) if(CMAKE_VERSION VERSION_LESS 3.11) - set_target_properties(Python3::NumPy PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - ${NUMPY_INCLUDE_DIRS}) + set_target_properties(Python3::NumPy PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${NUMPY_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES Python3::Module) else() target_include_directories(Python3::NumPy INTERFACE ${NUMPY_INCLUDE_DIRS}) + target_link_libraries(Python3::NumPy INTERFACE Python3::Module) endif() -target_link_libraries(Python3::NumPy INTERFACE Python3::Module)