From e81e9c5450467f6cc2f6f4105245b8dfeabd41f2 Mon Sep 17 00:00:00 2001 From: Jean-Francois Panisset Date: Tue, 27 Feb 2024 23:16:54 -0800 Subject: [PATCH] Retain backwards compatibility Signed-off-by: Jean-Francois Panisset --- CMakeLists.txt | 7 ++++++- src/py/CMakeLists.txt | 6 +++++- src/tests/CMakeLists.txt | 6 +++++- src/tools/CMakeLists.txt | 6 +++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b98c8d8..1338c2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,12 @@ set(OpenGL_GL_PREFERENCE GLVND) find_package(Threads REQUIRED) find_package(GLUT REQUIRED) find_package(OpenGL REQUIRED) -find_package(Python COMPONENTS Interpreter Development) +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12") + find_package(Python COMPONENTS Interpreter Development) +else() + find_package(PythonInterp REQUIRED) + find_package(PythonLibs REQUIRED) +endif() find_package(ZLIB) if (ZLIB_FOUND) add_definitions(-DPARTIO_USE_ZLIB) diff --git a/src/py/CMakeLists.txt b/src/py/CMakeLists.txt index 4d7c45b..56ac174 100644 --- a/src/py/CMakeLists.txt +++ b/src/py/CMakeLists.txt @@ -52,7 +52,11 @@ target_include_directories( ) target_link_libraries(partio_mod PRIVATE ${PYTHON_LIBRARIES} partio) -set(PYTHON_DEST "${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages" ) +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12") + set(PYTHON_DEST "${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages" ) +else() + set(PYTHON_DEST "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages" ) +endif() install(TARGETS partio_mod DESTINATION ${PYTHON_DEST}) install(FILES partio.i DESTINATION ${CMAKE_INSTALL_DATADIR}/swig) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index ce44c27..855d09f 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -50,7 +50,11 @@ else() endforeach(item) foreach(item testpartjson testpartio) - add_test(NAME ${item} COMMAND ${Python_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${item}.py) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12") + add_test(NAME ${item} COMMAND ${Python_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${item}.py) + else() + add_test(NAME ${item} COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${item}.py) + endif() install(PROGRAMS ${item}.py DESTINATION ${CMAKE_INSTALL_PARTIO_TESTDIR} RENAME ${item}) endforeach(item) endif() diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 6ca7e82..372bbaa 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -67,5 +67,9 @@ install(PROGRAMS partedit.py DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME partedit install(PROGRAMS partjson.py DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME partjson) install(PROGRAMS partinspect.py DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME partinspect) -set(PYTHON_DEST "${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages" ) +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12") + set(PYTHON_DEST "${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages" ) +else() + set(PYTHON_DEST "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages" ) +endif() install(FILES partedit.py partjson.py partinspect.py DESTINATION ${PYTHON_DEST})