Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CMake version less than 3.12 #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,28 @@ target_compile_features(matplotlib_cpp INTERFACE
cxx_std_11
)
# TODO: Use `Development.Embed` component when requiring cmake >= 3.18
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
target_link_libraries(matplotlib_cpp INTERFACE
Python3::Python
Python3::Module
)
find_package(Python3 COMPONENTS NumPy)
if(Python3_NumPy_FOUND)
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
find_package(PythonLibs 3 REQUIRED)
include_directories(
${PYTHON_INCLUDE_DIRS}
)
target_link_libraries(matplotlib_cpp INTERFACE
Python3::NumPy
${PYTHON_LIBRARIES}
)
else()
target_compile_definitions(matplotlib_cpp INTERFACE WITHOUT_NUMPY)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
target_link_libraries(matplotlib_cpp INTERFACE
Python3::Python
Python3::Module
)
find_package(Python3 COMPONENTS NumPy)
if(Python3_NumPy_FOUND)
target_link_libraries(matplotlib_cpp INTERFACE
Python3::NumPy
)
else()
target_compile_definitions(matplotlib_cpp INTERFACE WITHOUT_NUMPY)
endif()
endif()
install(
TARGETS matplotlib_cpp
Expand Down