Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes how CMake handles the OpenMM version #15

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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