summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorSeth R Johnson <johnsonsr@ornl.gov>2020-02-21 03:05:55 (GMT)
committerSeth R Johnson <johnsonsr@ornl.gov>2020-02-26 15:12:30 (GMT)
commite131d9f974fd51d0cecb8f3e23d72f2aa8f12ec8 (patch)
tree8a390f2bd7f55f54284d1718abed14a69d1b4e71 /Tests/RunCMake
parent25ca8e5ce5019c0fb8648f7408b864add6b19d83 (diff)
downloadCMake-e131d9f974fd51d0cecb8f3e23d72f2aa8f12ec8.zip
CMake-e131d9f974fd51d0cecb8f3e23d72f2aa8f12ec8.tar.gz
CMake-e131d9f974fd51d0cecb8f3e23d72f2aa8f12ec8.tar.bz2
FindSWIG: Add COMPONENTS support for SWIG target languages
Newer versions of SWIG drop support for some target languages, and some forks of SWIG (such as for Fortran and MATLAB) aren't supported by the mainline version of SWIG. Swig versions as old as 1.3.6 (circa 2001) and possibly older use the same format for listing available wrappers "%-15s - Generate %s wrappers", so component detection should be quite reliable.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/FindSWIG/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FindSWIG/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/FindSWIG/components-stdout.txt6
-rw-r--r--Tests/RunCMake/FindSWIG/components.cmake9
-rw-r--r--Tests/RunCMake/FindSWIG/missing-components-result.txt1
-rw-r--r--Tests/RunCMake/FindSWIG/missing-components-stderr.txt1
-rw-r--r--Tests/RunCMake/FindSWIG/missing-components.cmake3
8 files changed, 28 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index e9f8bca..d751d24 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -188,6 +188,7 @@ add_RunCMake_test(FindBoost)
add_RunCMake_test(FindLua)
add_RunCMake_test(FindOpenGL)
if(CMake_TEST_UseSWIG)
+ add_RunCMake_test(FindSWIG)
add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython=${CMake_TEST_FindPython})
endif()
if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom")
diff --git a/Tests/RunCMake/FindSWIG/CMakeLists.txt b/Tests/RunCMake/FindSWIG/CMakeLists.txt
new file mode 100644
index 0000000..d1b0d2c
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.10)
+project(${RunCMake_TEST} C)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake
new file mode 100644
index 0000000..5f5f7f5
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(components)
+run_cmake(missing-components)
diff --git a/Tests/RunCMake/FindSWIG/components-stdout.txt b/Tests/RunCMake/FindSWIG/components-stdout.txt
new file mode 100644
index 0000000..3977b08
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/components-stdout.txt
@@ -0,0 +1,6 @@
+-- Found SWIG: [^ ]+ \(found version "[0-9.]+"\) found components: java python missing components: PERL
+-- SWIG_VERSION='[0-9.]+'
+-- SWIG_java_FOUND=TRUE
+-- SWIG_python_FOUND=TRUE
+-- SWIG_PERL_FOUND=
+-- Configuring done
diff --git a/Tests/RunCMake/FindSWIG/components.cmake b/Tests/RunCMake/FindSWIG/components.cmake
new file mode 100644
index 0000000..b79a81e
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/components.cmake
@@ -0,0 +1,9 @@
+# Note that 'perl' will not be found because it is not lowercase.
+find_package(SWIG REQUIRED
+ COMPONENTS java
+ OPTIONAL_COMPONENTS python PERL)
+
+message(STATUS "SWIG_VERSION='${SWIG_VERSION}'")
+foreach(_lang java python PERL)
+ message(STATUS "SWIG_${_lang}_FOUND=${SWIG_${_lang}_FOUND}")
+endforeach()
diff --git a/Tests/RunCMake/FindSWIG/missing-components-result.txt b/Tests/RunCMake/FindSWIG/missing-components-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/missing-components-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FindSWIG/missing-components-stderr.txt b/Tests/RunCMake/FindSWIG/missing-components-stderr.txt
new file mode 100644
index 0000000..c937532
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/missing-components-stderr.txt
@@ -0,0 +1 @@
+Could NOT find SWIG \(missing: invalid\)
diff --git a/Tests/RunCMake/FindSWIG/missing-components.cmake b/Tests/RunCMake/FindSWIG/missing-components.cmake
new file mode 100644
index 0000000..1d05ae4
--- /dev/null
+++ b/Tests/RunCMake/FindSWIG/missing-components.cmake
@@ -0,0 +1,3 @@
+find_package(SWIG REQUIRED
+ COMPONENTS invalid
+ OPTIONAL_COMPONENTS alsoinvalid)