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.
pull/5685/head
Michael Hirsch, Ph.D 5 years ago committed by Jussi Pakkanen
parent a348174313
commit b7a5d6b384
  1. 24
      test cases/cmake/10 cmake_module_path/cmake/FindSomethingLikePython.cmake
  2. 17
      test cases/cmake/10 cmake_module_path/meson.build

@ -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()

@ -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')
Loading…
Cancel
Save