Skip to content

Commit

Permalink
Fixed how cmake handles the openmm version (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
craabreu authored Dec 11, 2023
1 parent 1545ce4 commit def47c9
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down

0 comments on commit def47c9

Please sign in to comment.