diff options
author | Mathias Preiner <mathias.preiner@gmail.com> | 2018-08-24 15:11:03 -0700 |
---|---|---|
committer | Mathias Preiner <mathias.preiner@gmail.com> | 2018-09-22 16:30:59 -0700 |
commit | cdac01abe2bff167a82f749c8bf7a2d2bcd69498 (patch) | |
tree | 2c5dc25760e2227a48f51c669ace2029c1ef16a3 /cmake | |
parent | f0260ef80ee8020e6f5ee7cace54be0a568236f0 (diff) |
cmake: Compile Java tests and add to ctest if Java bindings are enabled.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindHamcrest.cmake | 13 | ||||
-rw-r--r-- | cmake/FindJUnit.cmake | 26 |
2 files changed, 39 insertions, 0 deletions
diff --git a/cmake/FindHamcrest.cmake b/cmake/FindHamcrest.cmake new file mode 100644 index 000000000..96fde96ba --- /dev/null +++ b/cmake/FindHamcrest.cmake @@ -0,0 +1,13 @@ +# Find Hamcrest +# Hamcrest_FOUND - system has Hamcrest lib +# Hamcrest_JAR - the Hamcrest jar file + +find_package(Java REQUIRED) +include(UseJava) + +find_jar(Hamcrest_JAR hamcrest-core) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Hamcrest DEFAULT_MSG Hamcrest_JAR) + +mark_as_advanced(Hamcrest_JAR) diff --git a/cmake/FindJUnit.cmake b/cmake/FindJUnit.cmake new file mode 100644 index 000000000..1fd4ebb2d --- /dev/null +++ b/cmake/FindJUnit.cmake @@ -0,0 +1,26 @@ +# Find JUnit +# JUnit_FOUND - system has JUnit lib +# JUnit_JAR - JUnit jar file +# JUnit_JAR_DEPS - JUnit jar dependencies + +find_package(Java REQUIRED) +include(UseJava) +find_package(Hamcrest REQUIRED) + +find_jar(JUnit_JAR NAMES junit junit4) + +if(JUnit_JAR) + set(JUnit_JAR_DEPS ${Hamcrest_JAR}) + # Determine version of JUnit + execute_process( + COMMAND ${Java_JAVA_EXECUTABLE} -cp ${JUnit_JAR} junit.runner.Version + OUTPUT_VARIABLE JUnit_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(JUnit + REQUIRED_VARS JUnit_JAR JUnit_JAR_DEPS + VERSION_VAR JUnit_VERSION) + +mark_as_advanced(JUnit_JAR JUnit_JAR_DEPS) |