diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-30 17:18:34 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-10-01 10:00:29 (GMT) |
commit | 1d300ee2a9f51e08d4006191e2d50fd5771af202 (patch) | |
tree | c475aca47b7269dd7fcd1c523866b1c5de301c37 /Tests | |
parent | 47b569a85852f716b05ede538e9940392407316c (diff) | |
download | CMake-1d300ee2a9f51e08d4006191e2d50fd5771af202.zip CMake-1d300ee2a9f51e08d4006191e2d50fd5771af202.tar.gz CMake-1d300ee2a9f51e08d4006191e2d50fd5771af202.tar.bz2 |
FindSWIG: Add version range support
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/FindSWIG/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FindSWIG/version-range.cmake | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake index 5f5f7f5..6becc3c 100644 --- a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(components) run_cmake(missing-components) +run_cmake(version-range) diff --git a/Tests/RunCMake/FindSWIG/version-range.cmake b/Tests/RunCMake/FindSWIG/version-range.cmake new file mode 100644 index 0000000..7ba1134 --- /dev/null +++ b/Tests/RunCMake/FindSWIG/version-range.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required (VERSION 3.18...3.19) + +find_package (SWIG) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG") +endif() + +# clean-up SWIG variables +unset (SWIG_EXECUTABLE CACHE) +unset (SWIG_DIR CACHE) + +## Specify a range including current SWIG version +string (REGEX MATCH "^([0-9]+)" upper_version "${SWIG_VERSION}") +math (EXPR upper_version "${upper_version} + 1") + +find_package (SWIG 1.0...${upper_version}.0) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG with version range 1.0...${upper_version}.0") +endif() + +# clean-up SWIG variables +unset (SWIG_EXECUTABLE CACHE) +unset (SWIG_DIR CACHE) + +## Specify a range excluding current SWIG version +set (range 1.0...<${SWIG_VERSION}) +find_package (SWIG ${range}) +if (SWIG_FOUND) + message (FATAL_ERROR "Unexpectedly find SWIG with version range ${range}") +endif() |