FindPython: Tests optimizations

* Use 'project(... LANGUAGES NONE)' when possible
* enhance error messages wording
This commit is contained in:
Marc Chevrier 2020-10-01 17:47:37 +02:00
parent 0519db374c
commit 5537ccd814
21 changed files with 82 additions and 82 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(TestArtifactsInteractive LANGUAGES C)
project(TestArtifactsInteractive LANGUAGES NONE)
set (components Interpreter Development)
if (CMake_TEST_FindPython_NumPy)

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1)
project(TestCustomFailureMessage.Check LANGUAGES C)
project(TestCustomFailureMessage.Check LANGUAGES NONE)
find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS})

View File

@ -1,16 +1,16 @@
cmake_minimum_required(VERSION 3.1)
project(TestExactVersion C)
project(TestExactVersion LANGUAGES NONE)
find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development)
if (NOT Python${Python_MAJOR_VERSION}_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}")
if(NOT Python${Python_MAJOR_VERSION}_FOUND)
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}")
endif()
if (NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Interpreter")
if(NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND)
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter")
endif()
if (NOT Python${Python_MAJOR_VERSION}_Development_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Development")
if(NOT Python${Python_MAJOR_VERSION}_Development_FOUND)
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development")
endif()
if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter)
@ -26,22 +26,22 @@ endif()
# reset artifacts and second search with exact version already founded
unset (Python${Python_MAJOR_VERSION}_EXECUTABLE)
unset (_Python${Python_MAJOR_VERSION}_EXECUTABLE CACHE)
unset(Python${Python_MAJOR_VERSION}_EXECUTABLE)
unset(_Python${Python_MAJOR_VERSION}_EXECUTABLE CACHE)
unset (_Python${Python_MAJOR_VERSION}_LIBRARY_RELEASE CACHE)
unset (_Python${Python_MAJOR_VERSION}_INCLUDE_DIR CACHE)
unset(_Python${Python_MAJOR_VERSION}_LIBRARY_RELEASE CACHE)
unset(_Python${Python_MAJOR_VERSION}_INCLUDE_DIR CACHE)
set (Python_REQUESTED_VERSION ${Python${Python_MAJOR_VERSION}_VERSION})
set(Python_REQUESTED_VERSION ${Python${Python_MAJOR_VERSION}_VERSION})
find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter Development)
if (NOT Python${Python_MAJOR_VERSION}_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}")
if(NOT Python${Python_MAJOR_VERSION}_FOUND)
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}")
endif()
if (NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Interpreter")
if(NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND)
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter")
endif()
if (NOT Python${Python_MAJOR_VERSION}_Development_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Development")
if(NOT Python${Python_MAJOR_VERSION}_Development_FOUND)
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development")
endif()
if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter)

View File

@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 3.1)
project(TestImplementation${Python_REQUESTED_IMPLEMENTATION} C)
project(TestImplementation${Python_REQUESTED_IMPLEMENTATION} LANGUAGES NONE)
set (Python${Python_REQUESTED_VERSION}_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION})
find_package(Python${Python_REQUESTED_VERSION} COMPONENTS Interpreter)
if (NOT Python${Python_REQUESTED_VERSION}_FOUND OR NOT Python${Python_REQUESTED_VERSION}_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python${Python_REQUESTED_VERSION}")
message (FATAL_ERROR "Failed to find Python${Python_REQUESTED_VERSION}")
endif()
if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython"
@ -24,7 +24,7 @@ set (Python_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION})
find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter)
if (NOT Python_FOUND OR NOT Python_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}")
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}")
endif()
if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython"

View File

@ -1,23 +1,23 @@
cmake_minimum_required(VERSION 3.1)
project(TestIronPython C)
project(TestIronPython LANGUAGES NONE)
set (Python_FIND_IMPLEMENTATIONS IronPython)
find_package(Python ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Compiler)
if (NOT Python_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}")
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}")
endif()
if (NOT Python_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python Interpreter")
message (FATAL_ERROR "Failed to find Python Interpreter")
endif()
if (NOT Python_INTERPRETER_ID STREQUAL "IronPython")
message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})")
endif()
if (NOT Python_Compiler_FOUND)
message (FATAL_ERROR "Fail to found Python Compiler")
message (FATAL_ERROR "Failed to find Python Compiler")
endif()
if (NOT Python_COMPILER_ID STREQUAL "IronPython")
message (FATAL_ERROR "Erroneous compiler ID (${Python_COMPILER_ID})")

View File

@ -1,23 +1,23 @@
cmake_minimum_required(VERSION 3.1)
project(TestIronPython2 C)
project(TestIronPython2 LANGUAGES NONE)
set (Python2_FIND_IMPLEMENTATIONS "IronPython")
find_package(Python2 COMPONENTS Interpreter Compiler)
if (NOT Python2_FOUND)
message (FATAL_ERROR "Fail to found Python 2")
message (FATAL_ERROR "Failed to find Python 2")
endif()
if (NOT Python2_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python 2 Interpreter")
message (FATAL_ERROR "Failed to find Python 2 Interpreter")
endif()
if (NOT Python2_INTERPRETER_ID STREQUAL "IronPython")
message (FATAL_ERROR "Erroneous interpreter ID (${Python2_INTERPRETER_ID})")
endif()
if (NOT Python2_Compiler_FOUND)
message (FATAL_ERROR "Fail to found Python 2 Compiler")
message (FATAL_ERROR "Failed to find Python 2 Compiler")
endif()
if (NOT Python2_COMPILER_ID STREQUAL "IronPython")
message (FATAL_ERROR "Erroneous compiler ID (${Python2_COMPILER_ID})")

View File

@ -1,29 +1,29 @@
cmake_minimum_required(VERSION 3.1)
project(TestPyPy C)
project(TestPyPy LANGUAGES NONE)
set (Python_FIND_IMPLEMENTATIONS PyPy)
find_package(Python ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development)
if (NOT Python_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION}")
message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION}")
endif()
if (NOT Python_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy Interpreter")
message (FATAL_ERROR "Failed to find Python PyPy Interpreter")
endif()
if (NOT Python_INTERPRETER_ID STREQUAL "PyPy")
message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})")
endif()
if (NOT Python_Development.Module_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION} Development.Module")
message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development.Module")
endif()
if (NOT Python_Development.Embed_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION} Development.Embed")
message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development.Embed")
endif()
if (NOT Python_Development_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION} Development")
message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development")
endif()
if(NOT TARGET Python::Interpreter)

View File

@ -1,29 +1,29 @@
cmake_minimum_required(VERSION 3.1)
project(TestPyPy2 C)
project(TestPyPy2 LANGUAGES NONE)
set (Python2_FIND_IMPLEMENTATIONS "PyPy")
find_package(Python2 COMPONENTS Interpreter Development)
if (NOT Python2_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 2")
message (FATAL_ERROR "Failed to find Python PyPy 2")
endif()
if (NOT Python2_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 2 Interpreter")
message (FATAL_ERROR "Failed to find Python PyPy 2 Interpreter")
endif()
if (NOT Python2_INTERPRETER_ID STREQUAL "PyPy")
message (FATAL_ERROR "Erroneous interpreter ID (${Python2_INTERPRETER_ID})")
endif()
if (NOT Python2_Development.Module_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 2 Development.Module")
message (FATAL_ERROR "Failed to find Python PyPy 2 Development.Module")
endif()
if (NOT Python2_Development.Embed_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 2 Development.Embed")
message (FATAL_ERROR "Failed to find Python PyPy 2 Development.Embed")
endif()
if (NOT Python2_Development_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 2 Development")
message (FATAL_ERROR "Failed to find Python PyPy 2 Development")
endif()
if(NOT TARGET Python2::Interpreter)

View File

@ -1,29 +1,29 @@
cmake_minimum_required(VERSION 3.1)
project(TestPyPy3 C)
project(TestPyPy3 LANGUAGES NONE)
set (Python3_FIND_IMPLEMENTATIONS "PyPy")
find_package(Python3 COMPONENTS Interpreter Development)
if (NOT Python3_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 3")
message (FATAL_ERROR "Failed to find Python PyPy 3")
endif()
if (NOT Python3_Interpreter_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 3 Interpreter")
message (FATAL_ERROR "Failed to find Python PyPy 3 Interpreter")
endif()
if (NOT Python3_INTERPRETER_ID STREQUAL "PyPy")
message (FATAL_ERROR "Erroneous interpreter ID (${Python3_INTERPRETER_ID})")
endif()
if (NOT Python3_Development.Module_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 3 Development.Module")
message (FATAL_ERROR "Failed to find Python PyPy 3 Development.Module")
endif()
if (NOT Python3_Development.Embed_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 3 Development.Embed")
message (FATAL_ERROR "Failed to find Python PyPy 3 Development.Embed")
endif()
if (NOT Python3_Development_FOUND)
message (FATAL_ERROR "Fail to found Python PyPy 3 Development")
message (FATAL_ERROR "Failed to find Python PyPy 3 Development")
endif()
if(NOT TARGET Python3::Interpreter)

View File

@ -1,18 +1,18 @@
cmake_minimum_required(VERSION 3.1)
project(TestPython C)
project(TestPython LANGUAGES C)
include(CTest)
find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
if (NOT Python_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}")
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}")
endif()
if (NOT Python_Development.Module_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module'")
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module'")
endif()
if (NOT Python_Development.Embed_FOUND)
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed'")
message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed'")
endif()
if(NOT TARGET Python::Interpreter)

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(TestPython2 C)
project(TestPython2 LANGUAGES C)
include(CTest)
@ -11,16 +11,16 @@ endif()
find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
if (NOT Python2_FOUND)
message (FATAL_ERROR "Fail to found Python 2")
message (FATAL_ERROR "Failed to find Python 2")
endif()
if (NOT Python2_Development_FOUND)
message (FATAL_ERROR "Fail to found Python 2 'Development' component")
message (FATAL_ERROR "Failed to find Python 2 'Development' component")
endif()
if (NOT Python2_Development.Module_FOUND)
message (FATAL_ERROR "Fail to found Python 2 'Development.Module' component")
message (FATAL_ERROR "Failed to find Python 2 'Development.Module' component")
endif()
if (NOT Python2_Development.Embed_FOUND)
message (FATAL_ERROR "Fail to found Python 2 'Development.Embed' component")
message (FATAL_ERROR "Failed to find Python 2 'Development.Embed' component")
endif()
if(NOT TARGET Python2::Interpreter)

View File

@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.1)
project(TestPython2Embedded C)
project(TestPython2Embedded LANGUAGES C)
include(CTest)
find_package(Python2 REQUIRED COMPONENTS Development.Embed)
if (NOT Python2_FOUND)
message (FATAL_ERROR "Fail to found Python 2")
message (FATAL_ERROR "Failed to find Python 2")
endif()
if (Python2_Development_FOUND)
message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found")

View File

@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.1)
project(TestPython2Module C)
project(TestPython2Module LANGUAGES C)
include(CTest)
find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module)
if (NOT Python2_FOUND)
message (FATAL_ERROR "Fail to found Python 2")
message (FATAL_ERROR "Failed to find Python 2")
endif()
if (Python2_Development_FOUND)
message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found")

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(TestPython3 C)
project(TestPython3 LANGUAGES C)
include(CTest)
@ -11,16 +11,16 @@ endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
if (NOT Python3_FOUND)
message (FATAL_ERROR "Fail to found Python 3")
message (FATAL_ERROR "Failed to find Python 3")
endif()
if (NOT Python3_Development_FOUND)
message (FATAL_ERROR "Fail to found Python 3 'Development' component")
message (FATAL_ERROR "Failed to find Python 3 'Development' component")
endif()
if (NOT Python3_Development.Module_FOUND)
message (FATAL_ERROR "Fail to found Python 3 'Development.Module' component")
message (FATAL_ERROR "Failed to find Python 3 'Development.Module' component")
endif()
if (NOT Python3_Development.Embed_FOUND)
message (FATAL_ERROR "Fail to found Python 3 'Development.Embed' component")
message (FATAL_ERROR "Failed to find Python 3 'Development.Embed' component")
endif()
if(NOT TARGET Python3::Interpreter)

View File

@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.1)
project(TestPython3Embedded C)
project(TestPython3Embedded LANGUAGES C)
include(CTest)
find_package(Python3 REQUIRED COMPONENTS Development.Embed)
if (NOT Python3_FOUND)
message (FATAL_ERROR "Fail to found Python 3")
message (FATAL_ERROR "Failed to find Python 3")
endif()
if (Python3_Development_FOUND)
message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found")

View File

@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.1)
project(TestPython3Module C)
project(TestPython3Module LANGUAGES C)
include(CTest)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
if (NOT Python3_FOUND)
message (FATAL_ERROR "Fail to found Python 3")
message (FATAL_ERROR "Failed to find Python 3")
endif()
if (Python3_Development_FOUND)
message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found")

View File

@ -1,16 +1,16 @@
cmake_minimum_required(VERSION 3.1)
project(TestRequiredArtifacts LANGUAGES C)
project(TestRequiredArtifacts LANGUAGES NONE)
include(CTest)
find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
if (NOT Python2_FOUND)
message (FATAL_ERROR "Fail to found Python 2")
message (FATAL_ERROR "Failed to find Python 2")
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
if (NOT Python3_FOUND)
message (FATAL_ERROR "Fail to found Python 3")
message (FATAL_ERROR "Failed to find Python 3")
endif()

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(TestRequiredArtifacts.Check LANGUAGES C)
project(TestRequiredArtifacts.Check LANGUAGES NONE)
set (components)
if (CHECK_INTERPRETER)
@ -29,13 +29,13 @@ endif()
if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter)
message (FATAL_ERROR "Fail to use input variable Python3_EXECUTABLE")
message (FATAL_ERROR "Failed to use input variable Python3_EXECUTABLE")
endif()
if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library)
message (FATAL_ERROR "Fail to use input variable Python3_LIBRARY")
message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY")
endif()
if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include)
message (FATAL_ERROR "Fail to use input variable Python3_INCLUDE_DIR")
message (FATAL_ERROR "Failed to use input variable Python3_INCLUDE_DIR")
endif()

View File

@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(TestSOABI C)
project(TestSOABI LANGUAGES C)
find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
if (NOT Python3_FOUND)
message (FATAL_ERROR "Fail to found Python 3")
message (FATAL_ERROR "Failed to find Python 3")
endif()
if(NOT DEFINED Python3_SOABI)

View File

@ -6,7 +6,7 @@ include(CTest)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
if (NOT Python3_FOUND)
message (FATAL_ERROR "Fail to found Python 3")
message (FATAL_ERROR "Failed to find Python 3")
endif()
set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/py3venv")

View File

@ -6,7 +6,7 @@ include(CTest)
find_program(CONDA_EXECUTABLE conda)
if (CONDA_EXECUTABLE EQUAL NOTFOUND)
message (FATAL_ERROR "Fail to found Conda")
message (FATAL_ERROR "Failed to find Conda")
endif()
set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/condaenv")