From def47c94e1eb52c80eeb96deb8ccb58668da30f1 Mon Sep 17 00:00:00 2001 From: Charlles Abreu Date: Mon, 11 Dec 2023 17:14:24 -0500 Subject: [PATCH] Fixed how cmake handles the openmm version (#15) --- CMakeLists.txt | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 761fa27..ec627e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,17 +8,23 @@ PROJECT(OpenMMNonbondedSlicing VERSION 0.2.1) IF(DEFINED ENV{CONDA_PREFIX}) SET(OPENMM_DIR $ENV{CONDA_PREFIX} CACHE PATH "Where OpenMM is installed") + EXECUTE_PROCESS( + COMMAND conda list ^openmm\\b + OUTPUT_VARIABLE CONDA_OPENMM_VERSION + ) + IF (NOT CONDA_OPENMM_VERSION) + MESSAGE(FATAL_ERROR "OpenMM conda package not found. Please install OpenMM with conda.") + ENDIF(NOT CONDA_OPENMM_VERSION) + STRING(REGEX REPLACE "[^\\.]+([0-9]+\\.[0-9]+).*" "\\1" CONDA_OPENMM_VERSION "${CONDA_OPENMM_VERSION}") + SET(OPENMM_VERSION ${CONDA_OPENMM_VERSION} CACHE STRING "OpenMM version") +ELSE(DEFINED ENV{CONDA_PREFIX}) ENDIF(DEFINED ENV{CONDA_PREFIX}) -EXECUTE_PROCESS( - COMMAND conda list ^openmm\\b - OUTPUT_VARIABLE OPENMM_VERSION -) -IF (NOT OPENMM_VERSION) - MESSAGE(FATAL_ERROR "OpenMM conda package not found. Please install OpenMM with conda.") -ENDIF(NOT OPENMM_VERSION) -STRING(REGEX REPLACE ".* ([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" OPENMM_VERSION_MAJOR "${OPENMM_VERSION}") -STRING(REGEX REPLACE ".* [0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" OPENMM_VERSION_MINOR "${OPENMM_VERSION}") +MESSAGE(STATUS "OpenMM version: ${OPENMM_VERSION}") +STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" OPENMM_VERSION_MAJOR "${OPENMM_VERSION}") +STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" OPENMM_VERSION_MINOR "${OPENMM_VERSION}") +MESSAGE(STATUS "OpenMM major version: ${OPENMM_VERSION_MAJOR}") +MESSAGE(STATUS "OpenMM minor version: ${OPENMM_VERSION_MINOR}") ADD_COMPILE_DEFINITIONS(OPENMM_VERSION_MAJOR=${OPENMM_VERSION_MAJOR}) ADD_COMPILE_DEFINITIONS(OPENMM_VERSION_MINOR=${OPENMM_VERSION_MINOR})