Skip to content

Commit c913b21

Browse files
authored
Merge pull request #182 from agoose77/feature-add-optional-target
Feature: support xtensor as an existing parent build target
2 parents 910b6f1 + 9a020dd commit c913b21

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,19 @@ message(STATUS "xtensor-blas v${${PROJECT_NAME}_VERSION}")
4444
# Dependencies
4545
# ============
4646

47-
find_package(xtensor 0.23 REQUIRED)
48-
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
47+
set(xtensor_REQUIRED_VERSION 0.23.0)
48+
if(TARGET xtensor)
49+
set(xtensor_VERSION ${XTENSOR_VERSION_MAJOR}.${XTENSOR_VERSION_MINOR}.${XTENSOR_VERSION_PATCH})
50+
# Note: This is not SEMVER compatible comparison
51+
if( NOT ${xtensor_VERSION} VERSION_GREATER_EQUAL ${xtensor_REQUIRED_VERSION})
52+
message(ERROR "Mismatch xtensor versions. Found '${xtensor_VERSION}' but requires: '${xtensor_REQUIRED_VERSION}'")
53+
else()
54+
message(STATUS "Found xtensor v${xtensor_VERSION}")
55+
endif()
56+
else()
57+
find_package(xtensor ${xtensor_REQUIRED_VERSION} REQUIRED)
58+
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
59+
endif()
4960

5061
# Build
5162
# =====

0 commit comments

Comments
 (0)