Skip to content

Commit 302ff55

Browse files
authored
Merge pull request #231 from TheButlah/master
Enable `add_subdirectory()` for xtensor dependency
2 parents e3f841e + 6667b3e commit 302ff55

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

CMakeLists.txt

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,29 @@ message(STATUS "xtensor-python v${${PROJECT_NAME}_VERSION}")
3232
# Dependencies
3333
# ============
3434

35-
find_package(xtl REQUIRED)
36-
message(STATUS "Found xtl: ${xtl_INCLUDE_DIRS}/xtl")
37-
find_package(xtensor REQUIRED)
38-
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
39-
find_package(pybind11 REQUIRED)
40-
message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIRS}/pybind11")
35+
set(xtensor_REQUIRED_VERSION 0.21.2)
36+
if(TARGET xtensor)
37+
set(xtensor_VERSION ${XTENSOR_VERSION_MAJOR}.${XTENSOR_VERSION_MINOR}.${XTENSOR_VERSION_PATCH})
38+
# Note: This is not SEMVER compatible comparison
39+
if( NOT ${xtensor_VERSION} VERSION_GREATER_EQUAL ${xtensor_REQUIRED_VERSION})
40+
message(ERROR "Mismatch xtensor versions. Found '${xtensor_VERSION}' but requires: '${xtensor_REQUIRED_VERSION}'")
41+
else()
42+
message(STATUS "Found xtensor v${xtensor_VERSION}")
43+
endif()
44+
else()
45+
find_package(xtensor ${xtensor_REQUIRED_VERSION} REQUIRED)
46+
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
47+
endif()
48+
49+
# Currently no required version for pybind11
50+
if(TARGET pybind11)
51+
# pybind11 has a variable that indicates its version already, so use that
52+
message(STATUS "Found pybind11 v${pybind11_VERSION}")
53+
else()
54+
find_package(pybind11 REQUIRED)
55+
message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIRS}/pybind11")
56+
endif()
57+
4158
find_package(NumPy REQUIRED)
4259
message(STATUS "Found numpy: ${NUMPY_INCLUDE_DIRS}")
4360

0 commit comments

Comments
 (0)