Skip to content

Commit 8c4be3a

Browse files
committed
Updated find_package(Python); added CMake option AMP1394_PYTHON_VERSION_REQUIRED
1 parent 574ea4b commit 8c4be3a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/CMakeLists.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ if (Amp1394_BUILD_SWIG)
6565
find_package(SWIG REQUIRED)
6666
include(${SWIG_USE_FILE})
6767

68-
find_package(PythonLibs)
69-
include_directories(${PYTHON_INCLUDE_PATH})
70-
71-
find_package(PythonInterp)
72-
if (PYTHON_EXECUTABLE)
73-
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())"
74-
ERROR_QUIET
75-
OUTPUT_VARIABLE Amp1394_NUMPY_INCLUDE_DIR
76-
OUTPUT_STRIP_TRAILING_WHITESPACE)
77-
include_directories(${Amp1394_NUMPY_INCLUDE_DIR} "${Amp1394_BINARY_DIR}/Amp1394")
78-
endif()
68+
# Find Python and NumPy
69+
set (AMP1394_PYTHON_VERSION_REQUIRED "" CACHE STRING "Required Python version (if not empty)")
70+
if (AMP1394_PYTHON_VERSION_REQUIRED)
71+
message (STATUS "Looking for Python ${AMP1394_PYTHON_VERSION_REQUIRED}")
72+
find_package (Python ${AMP1394_PYTHON_VERSION_REQUIRED} EXACT REQUIRED COMPONENTS Development NumPy)
73+
else ()
74+
find_package (Python REQUIRED COMPONENTS Interpreter Development NumPy)
75+
endif ()
76+
77+
include_directories(${Python_INCLUDE_DIRS} ${Python_NumPy_INCLUDE_DIRS})
78+
include_directories("${Amp1394_BINARY_DIR}/Amp1394")
7979

8080
set_source_files_properties(Amp1394.i PROPERTIES CPLUSPLUS ON)
8181
swig_add_module(Amp1394Python python Amp1394.i ${HEADERS} ${SOURCE_FILES})
82-
swig_link_libraries(Amp1394Python ${PYTHON_LIBRARIES} ${Amp1394_EXTRA_LIBRARIES})
82+
swig_link_libraries(Amp1394Python ${Python_LIBRARIES} ${Amp1394_EXTRA_LIBRARIES})
8383

8484
if (WIN32)
8585
set_target_properties (_Amp1394Python PROPERTIES SUFFIX .pyd)

0 commit comments

Comments
 (0)