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})