From 71b48253e871caa753aaadb63566d552759565da Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 30 Jun 2023 23:15:37 -0400 Subject: [PATCH] remove special case CMake code for versions before 3.16 --- cmake/CMakeLists.txt | 41 +++++++--------------------- cmake/Modules/CodingStandard.cmake | 18 ++++-------- cmake/Modules/Documentation.cmake | 24 ++++++---------- cmake/Modules/FindCythonize.cmake | 10 +------ cmake/Modules/Packages/KIM.cmake | 7 +---- cmake/Modules/Packages/MDI.cmake | 34 ++++------------------- cmake/Modules/Packages/ML-IAP.cmake | 21 +++----------- cmake/Modules/Packages/PYTHON.cmake | 34 ++++++----------------- cmake/Modules/Testing.cmake | 26 ++++-------------- examples/kim/plugin/CMakeLists.txt | 9 ++---- unittest/CMakeLists.txt | 6 +--- unittest/force-styles/CMakeLists.txt | 17 ++---------- unittest/python/CMakeLists.txt | 10 +------ unittest/tools/CMakeLists.txt | 10 ++----- 14 files changed, 57 insertions(+), 210 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 24b08ae667..3393a56682 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -22,13 +22,8 @@ endif() if(POLICY CMP0135) cmake_policy(SET CMP0135 OLD) endif() -######################################## -# Use CONFIGURE_DEPENDS as option for file(GLOB...) when available -if(CMAKE_VERSION VERSION_LESS 3.12) - unset(CONFIGURE_DEPENDS) -else() - set(CONFIGURE_DEPENDS CONFIGURE_DEPENDS) -endif() + +set(CONFIGURE_DEPENDS CONFIGURE_DEPENDS) ######################################## project(lammps CXX) @@ -466,12 +461,7 @@ option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) if(WITH_JPEG) find_package(JPEG REQUIRED) target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES}) - else() - target_link_libraries(lammps PRIVATE JPEG::JPEG) - endif() + target_link_libraries(lammps PRIVATE JPEG::JPEG) endif() find_package(PNG QUIET) @@ -819,20 +809,11 @@ install( # This is primarily for people that only want to use the Python wrapper. ############################################################################### if(BUILD_SHARED_LIBS) - if(CMAKE_VERSION VERSION_LESS 3.12) - # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - else() - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) + # backward compatibility + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() + find_package(Python COMPONENTS Interpreter) if(BUILD_IS_MULTI_CONFIG) set(MY_BUILD_DIR ${CMAKE_BINARY_DIR}/$) else() @@ -941,11 +922,9 @@ if(_index GREATER -1) endif() message(STATUS "<<< Linker flags: >>>") message(STATUS "Executable name: ${LAMMPS_BINARY}") -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - get_target_property(OPTIONS lammps LINK_OPTIONS) - if(OPTIONS) - message(STATUS "Linker options: ${OPTIONS}") - endif() +get_target_property(OPTIONS lammps LINK_OPTIONS) +if(OPTIONS) + message(STATUS "Linker options: ${OPTIONS}") endif() if(CMAKE_EXE_LINKER_FLAGS) message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}") diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 4efd373d22..94639c7771 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -1,19 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(Python3_VERSION ${PYTHON_VERSION_STRING}) - endif() -else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.5) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 COMPONENTS Interpreter QUIET) +# use default (or custom) Python executable, if version is sufficient +if(Python_VERSION VERSION_GREATER_EQUAL 3.6) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() +find_package(Python3 COMPONENTS Interpreter) if(Python3_EXECUTABLE) - if(Python3_VERSION VERSION_GREATER_EQUAL 3.5) + if(Python3_VERSION VERSION_GREATER_EQUAL 3.6) add_custom_target( check-whitespace ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/whitespace.py . diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index 0b01407cd9..df9bf2b449 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -5,25 +5,19 @@ option(BUILD_DOC "Build LAMMPS HTML documentation" OFF) if(BUILD_DOC) # Current Sphinx versions require at least Python 3.8 - if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.8 REQUIRED) - set(VIRTUALENV ${PYTHON_EXECUTABLE} -m venv) - else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.8) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 REQUIRED COMPONENTS Interpreter) - if(Python3_VERSION VERSION_LESS 3.8) - message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") - endif() - set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + # use default (or custom) Python executable, if version is sufficient + if(Python_VERSION VERSION_GREATER_EQUAL 3.8) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter) + if(Python3_VERSION VERSION_LESS 3.8) + message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") + endif() + set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + find_package(Doxygen 1.8.10 REQUIRED) - file(GLOB DOC_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_DOC_DIR}/src/[^.]*.rst) - add_custom_command( OUTPUT docenv COMMAND ${VIRTUALENV} docenv diff --git a/cmake/Modules/FindCythonize.cmake b/cmake/Modules/FindCythonize.cmake index 97f0304279..fe436aef28 100644 --- a/cmake/Modules/FindCythonize.cmake +++ b/cmake/Modules/FindCythonize.cmake @@ -7,15 +7,7 @@ # adapted from https://github.com/cmarshall108/cython-cmake-example/blob/master/cmake/FindCython.cmake #============================================================================= -if(CMAKE_VERSION VERSION_LESS 3.12) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp 3.6 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python 3.6 COMPONENTS Interpreter QUIET) -endif() +find_package(Python 3.6 COMPONENTS Interpreter QUIET) # Use the Cython executable that lives next to the Python executable # if it is a local installation. diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 995d2d9490..d724ec18fc 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -1,12 +1,7 @@ set(KIM-API_MIN_VERSION 2.1.3) find_package(CURL) if(CURL_FOUND) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(lammps PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(lammps PRIVATE CURL::libcurl) - endif() + target_link_libraries(lammps PRIVATE CURL::libcurl) target_compile_definitions(lammps PRIVATE -DLMP_KIM_CURL) set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.") mark_as_advanced(LMP_DEBUG_CURL) diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake index dc3af94a0a..447b941d99 100644 --- a/cmake/Modules/Packages/MDI.cmake +++ b/cmake/Modules/Packages/MDI.cmake @@ -26,29 +26,9 @@ if(DOWNLOAD_MDI) # detect if we have python development support and thus can enable python plugins set(MDI_USE_PYTHON_PLUGINS OFF) - if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs QUIET) # Deprecated since version 3.12 - if(PYTHONLIBS_FOUND) - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - set(MDI_USE_PYTHON_PLUGINS ON) - endif() - else() - find_package(Python QUIET COMPONENTS Development) - if(Python_Development_FOUND) - set(MDI_USE_PYTHON_PLUGINS ON) - endif() + find_package(Python QUIET COMPONENTS Development) + if(Python_Development_FOUND) + set(MDI_USE_PYTHON_PLUGINS ON) endif() # python plugins are not supported and thus must be always off on Windows if(CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -102,13 +82,9 @@ if(DOWNLOAD_MDI) # if compiling with python plugins we need # to add python libraries as dependency. if(MDI_USE_PYTHON_PLUGINS) - if(CMAKE_VERSION VERSION_LESS 3.12) - list(APPEND MDI_DEP_LIBS ${PYTHON_LIBRARIES}) - else() - list(APPEND MDI_DEP_LIBS Python::Python) - endif() - + list(APPEND MDI_DEP_LIBS Python::Python) endif() + # need to add support for dlopen/dlsym, except when compiling for Windows. if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) list(APPEND MDI_DEP_LIBS "${CMAKE_DL_LIBS}") diff --git a/cmake/Modules/Packages/ML-IAP.cmake b/cmake/Modules/Packages/ML-IAP.cmake index f8439be538..2e9a02977d 100644 --- a/cmake/Modules/Packages/ML-IAP.cmake +++ b/cmake/Modules/Packages/ML-IAP.cmake @@ -2,12 +2,7 @@ set(MLIAP_ENABLE_PYTHON_DEFAULT OFF) if(PKG_PYTHON) find_package(Cythonize QUIET) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy QUIET) - else() - # assume we have NumPy - set(Python_NumPy_FOUND ON) - endif() + find_package(Python COMPONENTS NumPy QUIET) if(Cythonize_FOUND AND Python_NumPy_FOUND) set(MLIAP_ENABLE_PYTHON_DEFAULT ON) endif() @@ -17,20 +12,12 @@ option(MLIAP_ENABLE_PYTHON "Build ML-IAP package with Python support" ${MLIAP_EN if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy REQUIRED) - endif() + find_package(Python COMPONENTS NumPy REQUIRED) if(NOT PKG_PYTHON) message(FATAL_ERROR "Must enable PYTHON package for including Python support in ML-IAP") endif() - if(CMAKE_VERSION VERSION_LESS 3.12) - if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() - else() - if(Python_VERSION VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() + if(Python_VERSION VERSION_LESS 3.6) + message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") endif() set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake index 4a2925fe31..59260e39d5 100644 --- a/cmake/Modules/Packages/PYTHON.cmake +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -1,29 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() + +if(NOT Python_INTERPRETER) + # backward compatibility + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs REQUIRED) # Deprecated since version 3.12 - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARIES}) -else() - if(NOT Python_INTERPRETER) - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) - endif() - find_package(Python REQUIRED COMPONENTS Interpreter Development) - target_link_libraries(lammps PRIVATE Python::Python) + find_package(Python COMPONENTS Interpreter) endif() +find_package(Python REQUIRED COMPONENTS Interpreter Development) +target_link_libraries(lammps PRIVATE Python::Python) target_compile_definitions(lammps PRIVATE -DLMP_PYTHON) diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 5345211178..5bb8b512d3 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -19,7 +19,7 @@ if(ENABLE_TESTING) # we need to build and link a LOT of tester executables, so it is worth checking if # a faster linker is available. requires GNU or Clang compiler, newer CMake. # also only verified with Fedora Linux > 30 and Ubuntu 18.04 or 22.04+(Ubuntu 20.04 fails) - if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND ((CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04) OR (CMAKE_DISTRO_VERSION VERSION_GREATER_EQUAL 22.04))) @@ -66,16 +66,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) mark_as_advanced(ENABLE_COVERAGE) if(ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() - else() - target_compile_options(lammps PUBLIC --coverage) - target_link_options(lammps PUBLIC --coverage) - endif() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) endif() endif() @@ -118,16 +110,8 @@ validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) if(NOT ENABLE_SANITIZER STREQUAL "none") if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - endif() - else() - target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) else() message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") set(ENABLE_SANITIZER "none") diff --git a/examples/kim/plugin/CMakeLists.txt b/examples/kim/plugin/CMakeLists.txt index 367c0b5b78..999214f9b8 100644 --- a/examples/kim/plugin/CMakeLists.txt +++ b/examples/kim/plugin/CMakeLists.txt @@ -3,7 +3,7 @@ # distributed independent from the LAMMPS package. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(kimplugin VERSION 1.0 LANGUAGES CXX) @@ -30,12 +30,7 @@ target_link_libraries(kimplugin PRIVATE KIM-API::kim-api) # need libcurl find_package(CURL) if(CURL_FOUND) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(kimplugin PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(kimplugin PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(kimplugin PRIVATE CURL::libcurl) - endif() + target_link_libraries(kimplugin PRIVATE CURL::libcurl) target_compile_definitions(kimplugin PRIVATE -DLMP_KIM_CURL) set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.") mark_as_advanced(LMP_DEBUG_CURL) diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index cad6c3213c..ba80e654bb 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -35,11 +35,7 @@ endforeach() # must repeat handling coverage for older CMake if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") endif() ######################################## diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index 5742bb6436..21a1bd3eda 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -20,16 +20,7 @@ function(extract_tags out yaml_file) set(${out} "${TAGS}" PARENT_SCOPE) endfunction() -if(CMAKE_VERSION VERSION_LESS 3.12) - # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5) - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python COMPONENTS Interpreter) -endif() +find_package(Python COMPONENTS Interpreter) if(Python_EXECUTABLE) add_custom_target(check-tests ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/check_tests.py @@ -54,10 +45,8 @@ target_link_libraries(style_tests PUBLIC GTest::GMock Yaml::Yaml lammps) # propagate sanitizer options to test tools if(ENABLE_SANITIZER AND (NOT (ENABLE_SANITIZER STREQUAL "none"))) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() + target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) endif() # unit test for error stats class diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index fd18d7463d..ed56841733 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -12,20 +12,12 @@ if(NOT BUILD_SHARED_LIBS) return() endif() -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.6) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python COMPONENTS Interpreter Development) -endif() +find_package(Python 3.6 COMPONENTS Interpreter Development) if(PKG_PYTHON) add_executable(test_python_package test_python_package.cpp) target_link_libraries(test_python_package PRIVATE lammps GTest::GMock) target_compile_definitions(test_python_package PRIVATE -DTEST_INPUT_FOLDER=${TEST_INPUT_FOLDER}) - # this requires CMake 3.12. don't care to add backward compatibility for this. if(Python_Development_FOUND) target_compile_definitions(test_python_package PRIVATE -DTEST_HAVE_PYTHON_DEVELOPMENT=1) target_link_libraries(test_python_package PRIVATE Python::Python) diff --git a/unittest/tools/CMakeLists.txt b/unittest/tools/CMakeLists.txt index 15576c60c1..7a496722d2 100644 --- a/unittest/tools/CMakeLists.txt +++ b/unittest/tools/CMakeLists.txt @@ -1,14 +1,8 @@ # -*- CMake -*- file for tests of utily functions and classes in LAMMPS # we use python 3's subprocess module to run the tools and check the output -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python 3.5 COMPONENTS Interpreter) -endif() +find_package(Python 3.6 COMPONENTS Interpreter) + get_property(BUILD_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(BUILD_IS_MULTI_CONFIG) set(LAMMPS_SHELL_EXE_DIR ${CMAKE_BINARY_DIR}/$)