diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-10-03 22:26:09 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-10-03 22:26:15 (GMT) |
commit | da0dadf644be7c87c6f3550bf9f72753dfcfa1b8 (patch) | |
tree | ae6fac57e0e0e1972d39228d50cee041d6c71d46 | |
parent | 63aa279343df34d34e0a0fd0c92a444e2528bb8a (diff) | |
parent | 127436192de589416e94cbb40190d906a7c57c0a (diff) | |
download | CMake-da0dadf644be7c87c6f3550bf9f72753dfcfa1b8.zip CMake-da0dadf644be7c87c6f3550bf9f72753dfcfa1b8.tar.gz CMake-da0dadf644be7c87c6f3550bf9f72753dfcfa1b8.tar.bz2 |
Merge topic 'FindSWIG-foreach-missing'
127436192d FindSWIG: Fix syntax error
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5313
-rw-r--r-- | Modules/FindSWIG.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/FindSWIG/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/FindSWIG/version-exact.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/FindSWIG/version.cmake | 6 |
4 files changed, 31 insertions, 1 deletions
diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index f732289..87a3894 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -56,8 +56,8 @@ optional Fortran support: #]=======================================================================] # compute list of possible names +unset (_SWIG_NAMES) if (SWIG_FIND_VERSION_RANGE) - set (_SWIG_NAMES) foreach (_SWIG_MAJOR IN ITEMS 4 3 2) if (_SWIG_MAJOR VERSION_GREATER_EQUAL SWIG_FIND_VERSION_MIN_MAJOR AND ((SWIG_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND _SWIG_MAJOR VERSION_LESS_EQUAL SWIG_FIND_VERSION_MAX) @@ -73,10 +73,15 @@ elseif(SWIG_FIND_VERSION) if (_SWIG_MAJOR VERSION_GREATER_EQUAL SWIG_FIND_VERSION_MAJOR) list (APPEND _SWIG_NAMES swig${_SWIG_MAJOR}.0) endif() + endforeach() endif() else() set (_SWIG_NAMES swig4.0 swig3.0 swig2.0) endif() +if (NOT _SWIG_NAMES) + # try to find any version + set (_SWIG_NAMES swig4.0 swig3.0 swig2.0) +endif() find_program(SWIG_EXECUTABLE NAMES ${_SWIG_NAMES} swig) diff --git a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake index 6becc3c..2bdf913 100644 --- a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake @@ -2,4 +2,6 @@ include(RunCMake) run_cmake(components) run_cmake(missing-components) +run_cmake(version) +run_cmake(version-exact) run_cmake(version-range) diff --git a/Tests/RunCMake/FindSWIG/version-exact.cmake b/Tests/RunCMake/FindSWIG/version-exact.cmake new file mode 100644 index 0000000..ec3651f --- /dev/null +++ b/Tests/RunCMake/FindSWIG/version-exact.cmake @@ -0,0 +1,17 @@ +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) + +set (version ${SWIG_VERSION}) + +find_package (SWIG ${SWIG_VERSION} EXACT) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG with version ${version} EXACT") +endif() diff --git a/Tests/RunCMake/FindSWIG/version.cmake b/Tests/RunCMake/FindSWIG/version.cmake new file mode 100644 index 0000000..a4f1c39 --- /dev/null +++ b/Tests/RunCMake/FindSWIG/version.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required (VERSION 3.18...3.19) + +find_package (SWIG 1.0) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG with version 1.0") +endif() |