diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-07-16 14:09:57 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-07-18 23:37:33 +0300 |
commit | b7a5d6b38428a988435ee420a55bf42304072752 (patch) | |
tree | e45836bbab727a11076b5b15991c9a8dfb68ef06 | |
parent | a3481743134048ed0c6130457a79ce36bed896f7 (diff) | |
download | meson-b7a5d6b38428a988435ee420a55bf42304072752.tar.gz |
add cross-platform test for cmake_module_path
This test tolerates CMake >= 3.7, and checks that
dependency(..., cmake_module_path=...) works on any OS with CMake.
-rw-r--r-- | test cases/cmake/10 cmake_module_path/cmake/FindSomethingLikePython.cmake | 24 | ||||
-rw-r--r-- | test cases/cmake/10 cmake_module_path/meson.build | 17 |
2 files changed, 41 insertions, 0 deletions
diff --git a/test cases/cmake/10 cmake_module_path/cmake/FindSomethingLikePython.cmake b/test cases/cmake/10 cmake_module_path/cmake/FindSomethingLikePython.cmake new file mode 100644 index 000000000..4a189bffc --- /dev/null +++ b/test cases/cmake/10 cmake_module_path/cmake/FindSomethingLikePython.cmake @@ -0,0 +1,24 @@ +cmake_policy(VERSION 3.7) + +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) + find_package(Python COMPONENTS Interpreter) +else() + find_package(PythonInterp) +endif() + +if(Python_FOUND OR PYTHONINTERP_FOUND) + set(SomethingLikePython_FOUND ON) + set(SomethingLikePython_EXECUTABLE ${Python_EXECUTABLE}) + + if(NOT DEFINED Python_VERSION) + set(Python_VERSION ${Python_VERSION_STRING}) + endif() + if(NOT TARGET Python::Interpreter) + add_executable(Python::Interpreter IMPORTED) + set_target_properties(Python::Interpreter PROPERTIES + IMPORTED_LOCATION ${Python_EXECUTABLE} + VERSION ${Python_VERSION}) + endif() +else() + set(SomethingLikePython_FOUND OFF) +endif() diff --git a/test cases/cmake/10 cmake_module_path/meson.build b/test cases/cmake/10 cmake_module_path/meson.build new file mode 100644 index 000000000..225926824 --- /dev/null +++ b/test cases/cmake/10 cmake_module_path/meson.build @@ -0,0 +1,17 @@ +# We use Python3 as it's the only thing guaranteed to be available on any platform Meson can run on (unlike Zlib in linuxlike/13 cmake dependency). + +project('user CMake find_package module using cmake_module_path', + meson_version: '>= 0.50.0') + +if not find_program('cmake', required: false).found() + error('MESON_SKIP_TEST cmake binary not available.') +endif + +# NOTE: can't request Python3 via dependency('Python3', method: 'cmake') +# Meson intercepts and wants "method: auto" + +# Try to find a dependency with a custom CMake module + +dependency('SomethingLikePython', required : true, method : 'cmake', cmake_module_path : 'cmake', modules: 'Python::Interpreter') + +dependency('SomethingLikePython', method : 'cmake', cmake_module_path : ['doesNotExist', 'cmake'], modules: 'Python::Interpreter') |