aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-08-05 23:09:38 +0300
committerGitHub <noreply@github.com>2020-08-05 23:09:38 +0300
commit461cb7d5345d6811547d121078dcb26af9310a35 (patch)
tree4ee753ea4cf30287cca8a61f5f329e1d6d442cb3 /test cases
parent7db49db67d4aa7582cf46feb7157235e66aa95b1 (diff)
parentf16149cc4985fc1b35bf7b9435de9b9f52431175 (diff)
downloadmeson-461cb7d5345d6811547d121078dcb26af9310a35.zip
meson-461cb7d5345d6811547d121078dcb26af9310a35.tar.gz
meson-461cb7d5345d6811547d121078dcb26af9310a35.tar.bz2
Merge pull request #7527 from mensinda/cnFixExe
cmake: resolve IMPORTED executables in custom commands (fixes #7509)
Diffstat (limited to 'test cases')
-rw-r--r--test cases/cmake/11 cmake_module_path/cmake/FindSomethingLikePython.cmake17
-rw-r--r--test cases/cmake/11 cmake_module_path/meson.build10
-rw-r--r--test cases/cmake/11 cmake_module_path/subprojects/cmMod/CMakeLists.txt15
-rw-r--r--test cases/cmake/11 cmake_module_path/subprojects/cmMod/gen.py9
-rw-r--r--test cases/cmake/11 cmake_module_path/test.json5
5 files changed, 39 insertions, 17 deletions
diff --git a/test cases/cmake/11 cmake_module_path/cmake/FindSomethingLikePython.cmake b/test cases/cmake/11 cmake_module_path/cmake/FindSomethingLikePython.cmake
index 4a189bf..0c663f4 100644
--- a/test cases/cmake/11 cmake_module_path/cmake/FindSomethingLikePython.cmake
+++ b/test cases/cmake/11 cmake_module_path/cmake/FindSomethingLikePython.cmake
@@ -1,24 +1,9 @@
cmake_policy(VERSION 3.7)
-if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
- find_package(Python COMPONENTS Interpreter)
-else()
- find_package(PythonInterp)
-endif()
-
+find_package(Python COMPONENTS Interpreter)
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/11 cmake_module_path/meson.build b/test cases/cmake/11 cmake_module_path/meson.build
index 2259268..75467e3 100644
--- a/test cases/cmake/11 cmake_module_path/meson.build
+++ b/test cases/cmake/11 cmake_module_path/meson.build
@@ -1,7 +1,7 @@
# 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')
+ meson_version: '>= 0.55.0')
if not find_program('cmake', required: false).found()
error('MESON_SKIP_TEST cmake binary not available.')
@@ -15,3 +15,11 @@ endif
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')
+
+# Test a custom target with Python::Interpreter in COMMAND
+cm = import('cmake')
+op = cm.subproject_options()
+op.add_cmake_defines({'CMAKE_MODULE_PATH': meson.source_root() / 'cmake'})
+sp = cm.subproject('cmMod', options: op)
+main = sp.target('main')
+test('main', main)
diff --git a/test cases/cmake/11 cmake_module_path/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/11 cmake_module_path/subprojects/cmMod/CMakeLists.txt
new file mode 100644
index 0000000..88ba9bc
--- /dev/null
+++ b/test cases/cmake/11 cmake_module_path/subprojects/cmMod/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(cmMod)
+
+message(STATUS "CMAKE_MODULE_PATH: '${CMAKE_MODULE_PATH}'")
+
+find_package(SomethingLikePython REQUIRED)
+
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/main.c"
+ COMMAND Python::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/gen.py"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+)
+
+add_executable(main "${CMAKE_CURRENT_BINARY_DIR}/main.c")
diff --git a/test cases/cmake/11 cmake_module_path/subprojects/cmMod/gen.py b/test cases/cmake/11 cmake_module_path/subprojects/cmMod/gen.py
new file mode 100644
index 0000000..5c71646
--- /dev/null
+++ b/test cases/cmake/11 cmake_module_path/subprojects/cmMod/gen.py
@@ -0,0 +1,9 @@
+with open('main.c', 'w') as fp:
+ print('''
+#include <stdio.h>
+
+int main(void) {
+ printf(\"Hello World\");
+ return 0;
+}
+''', file=fp)
diff --git a/test cases/cmake/11 cmake_module_path/test.json b/test cases/cmake/11 cmake_module_path/test.json
new file mode 100644
index 0000000..79a2b60
--- /dev/null
+++ b/test cases/cmake/11 cmake_module_path/test.json
@@ -0,0 +1,5 @@
+{
+ "tools": {
+ "cmake": ">=3.12"
+ }
+}