-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
246 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,107 @@ | ||
# CMake script for finding HOOMD and setting up all needed compile options to create and link a plugin library | ||
# FindHOOMD | ||
# --------- | ||
# | ||
# CMake script for finding HOOMD and setting up all needed compile options | ||
# to create and link a plugin library | ||
# | ||
# Variables taken as input to this module: | ||
# HOOMD_ROOT : location to look for HOOMD, if it is not in the python path | ||
# HOOMD_ROOT -- Location to look for HOOMD, if it is not in the python path | ||
# | ||
# Variables defined by this module: | ||
# FOUND_HOOMD : set to true if HOOMD is found | ||
# HOOMD_LIBRARIES : a list of all libraries needed to link to to access hoomd (uncached) | ||
# HOOMD_INCLUDE_DIR : a list of all include directories that need to be set to include HOOMD | ||
# HOOMD_LIB : a cached var locating the hoomd library to link to | ||
# HOOMD_INCLUDE_DIR -- Include directories that need to be set to include HOOMD | ||
# HOOMD_LIB -- Cached var locating the hoomd library to link to | ||
# HOOMD_LIBRARIES -- Libraries needed to link to to access hoomd (uncached) | ||
# HOOMD_FOUND | ||
# | ||
# various ENABLE_ flags translated from hoomd_config.h so this plugin build can match the ABI of the installed hoomd | ||
# Various ENABLE_ flags are translated from hoomd_config.h | ||
# so this plugin build can match the ABI of the installed hoomd | ||
# | ||
# as a convenience (for the intended purpose of this find script), all include directories and definitions needed | ||
# to compile with all the various libs (boost, python, winsoc, etc...) are set within this script | ||
|
||
set(HOOMD_ROOT "" CACHE FILEPATH "Directory containing a hoomd installation (i.e. _hoomd.so)") | ||
# As a convenience (for the intended purpose of this find script), | ||
# all include directories and definitions needed to compile with all the various libs | ||
# (boost, python, winsoc, etc...) are set within this script | ||
|
||
# Let HOOMD_ROOT take precedence, but if unset, try letting Python find a hoomd package in its default paths. | ||
if(HOOMD_ROOT) | ||
set(hoomd_installation_guess ${HOOMD_ROOT}) | ||
else(HOOMD_ROOT) | ||
find_package(PythonInterp) | ||
|
||
set(find_hoomd_script " | ||
function(find_hoomd_with_python) | ||
find_package(Python QUIET COMPONENTS Interpreter) | ||
set(FIND_HOOMD_SCRIPT " | ||
from __future__ import print_function; | ||
import sys, os; sys.stdout = open(os.devnull, 'w') | ||
import hoomd | ||
print(os.path.dirname(hoomd.__file__), file=sys.stderr, end='')") | ||
|
||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "${find_hoomd_script}" | ||
ERROR_VARIABLE hoomd_installation_guess) | ||
message(STATUS "Python output: " ${hoomd_installation_guess}) | ||
endif(HOOMD_ROOT) | ||
import os | ||
try: | ||
import hoomd | ||
print(os.path.dirname(hoomd.__file__), end='') | ||
except: | ||
print('', end='')" | ||
) | ||
execute_process( | ||
COMMAND ${Python_EXECUTABLE} -c "${FIND_HOOMD_SCRIPT}" | ||
OUTPUT_VARIABLE HOOMD_ROOT | ||
) | ||
set(HOOMD_DIR ${HOOMD_ROOT} PARENT_SCOPE) | ||
endfunction() | ||
|
||
message(STATUS "Looking for a HOOMD installation at " ${hoomd_installation_guess}) | ||
find_path(FOUND_HOOMD_ROOT | ||
NAMES _hoomd.so __init__.py | ||
HINTS ${hoomd_installation_guess} | ||
) | ||
|
||
if(FOUND_HOOMD_ROOT) | ||
set(HOOMD_ROOT ${FOUND_HOOMD_ROOT} CACHE FILEPATH "Directory containing a hoomd installation (i.e. _hoomd.so)" FORCE) | ||
message(STATUS "Found hoomd installation at " ${HOOMD_ROOT}) | ||
else(FOUND_HOOMD_ROOT) | ||
message(FATAL_ERROR "Could not find hoomd installation, either set HOOMD_ROOT or set PYTHON_EXECUTABLE to a python which can find hoomd") | ||
endif(FOUND_HOOMD_ROOT) | ||
if(HOOMD_ROOT) | ||
set(HOOMD_DIR ${HOOMD_ROOT}) | ||
elseif(DEFINED ENV{HOOMD_ROOT}) | ||
set(HOOMD_DIR $ENV{HOOMD_ROOT}) | ||
else() | ||
find_hoomd_with_python() | ||
endif() | ||
|
||
# search for the hoomd include directory | ||
find_path(HOOMD_INCLUDE_DIR | ||
NAMES HOOMDVersion.h | ||
HINTS ${HOOMD_ROOT}/include | ||
) | ||
|
||
if (HOOMD_INCLUDE_DIR) | ||
message(STATUS "Found HOOMD include directory: ${HOOMD_INCLUDE_DIR}") | ||
mark_as_advanced(HOOMD_INCLUDE_DIR) | ||
endif (HOOMD_INCLUDE_DIR) | ||
|
||
set(HOOMD_FOUND FALSE) | ||
if (HOOMD_INCLUDE_DIR AND HOOMD_ROOT) | ||
set(HOOMD_FOUND TRUE) | ||
mark_as_advanced(HOOMD_ROOT) | ||
endif (HOOMD_INCLUDE_DIR AND HOOMD_ROOT) | ||
|
||
if (NOT HOOMD_FOUND) | ||
message(SEND_ERROR "HOOMD Not found. Please specify the location of your hoomd installation in HOOMD_ROOT") | ||
endif (NOT HOOMD_FOUND) | ||
|
||
############################################################# | ||
## Now that we've found hoomd, lets do some setup | ||
if (HOOMD_FOUND) | ||
|
||
include_directories(${HOOMD_INCLUDE_DIR}) | ||
|
||
# run all of HOOMD's generic lib setup scripts | ||
set(CMAKE_MODULE_PATH ${HOOMD_ROOT} | ||
${HOOMD_ROOT}/CMake/hoomd | ||
${HOOMD_ROOT}/CMake/thrust | ||
${CMAKE_MODULE_PATH} | ||
) | ||
|
||
# grab previously-set hoomd configuration | ||
include (hoomd_cache) | ||
|
||
# Handle user build options | ||
include (CMake_build_options) | ||
include (CMake_preprocessor_flags) | ||
# setup the install directories | ||
include (CMake_install_options) | ||
|
||
# Find the python executable and libraries | ||
include (HOOMDPythonSetup) | ||
# Find CUDA and set it up | ||
include (HOOMDCUDASetup) | ||
# Set default CFlags | ||
include (HOOMDCFlagsSetup) | ||
# include some os specific options | ||
include (HOOMDOSSpecificSetup) | ||
# setup common libraries used by all targets in this project | ||
include (HOOMDCommonLibsSetup) | ||
# setup macros | ||
include (HOOMDMacros) | ||
# setup MPI support | ||
include (HOOMDMPISetup) | ||
|
||
set(HOOMD_LIB ${HOOMD_ROOT}/_hoomd${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_MD_LIB ${HOOMD_ROOT}/md/_md${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_DEM_LIB ${HOOMD_ROOT}/dem/_dem${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_HPMC_LIB ${HOOMD_ROOT}/hpmc/_hpmc${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_CGCMM_LIB ${HOOMD_ROOT}/cgcmm/_cgcmm${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_METAL_LIB ${HOOMD_ROOT}/metal/_metal${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_DEPRECATED_LIB ${HOOMD_ROOT}/deprecated/_deprecated${PYTHON_MODULE_EXTENSION}) | ||
|
||
set(HOOMD_LIBRARIES ${HOOMD_LIB} ${HOOMD_COMMON_LIBS}) | ||
set(HOOMD_LIBRARIES ${HOOMD_LIB} ${HOOMD_COMMON_LIBS}) | ||
|
||
endif (HOOMD_FOUND) | ||
NAMES HOOMDVersion.h | ||
HINTS ${HOOMD_DIR}/include | ||
) | ||
if(HOOMD_INCLUDE_DIR) | ||
file(READ "${HOOMD_INCLUDE_DIR}/HOOMDVersion.h" HOOMD_VERSION_HEADER) | ||
string(REGEX | ||
MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" HOOMD_VERSION ${HOOMD_VERSION_HEADER} | ||
) | ||
endif() | ||
mark_as_advanced(HOOMD_FOUND HOOMD_DIR HOOMD_INCLUDE_DIR HOOMD_VERSION) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(HOOMD | ||
REQUIRED_VARS HOOMD_DIR HOOMD_INCLUDE_DIR HOOMD_VERSION | ||
) | ||
|
||
if(HOOMD_FOUND) | ||
include_directories(${HOOMD_INCLUDE_DIR}) | ||
# Run all of HOOMD's generic lib setup scripts | ||
set(CMAKE_MODULE_PATH | ||
${HOOMD_DIR} | ||
${HOOMD_DIR}/CMake/hoomd | ||
${HOOMD_DIR}/CMake/thrust | ||
${CMAKE_MODULE_PATH} | ||
) | ||
# Grab previously-set hoomd configuration | ||
include(hoomd_cache) | ||
# Handle user build options | ||
include(CMake_build_options) | ||
include(CMake_preprocessor_flags) | ||
# setup the install directories | ||
include(CMake_install_options) | ||
# Find the python executable and libraries | ||
include(HOOMDPythonSetup) | ||
# Find CUDA and set it up | ||
include(HOOMDCUDASetup) | ||
# Set default CFlags | ||
include(HOOMDCFlagsSetup) | ||
# Include some os specific options | ||
include(HOOMDOSSpecificSetup) | ||
# Setup common libraries used by all targets in this project | ||
include(HOOMDCommonLibsSetup) | ||
# Setup macros | ||
include(HOOMDMacros) | ||
# Setup MPI support | ||
include(HOOMDMPISetup) | ||
|
||
set(HOOMD_LIB ${HOOMD_DIR}/_hoomd${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_MD_LIB ${HOOMD_DIR}/md/_md${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_DEM_LIB ${HOOMD_DIR}/dem/_dem${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_HPMC_LIB ${HOOMD_DIR}/hpmc/_hpmc${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_CGCMM_LIB ${HOOMD_DIR}/cgcmm/_cgcmm${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_METAL_LIB ${HOOMD_DIR}/metal/_metal${PYTHON_MODULE_EXTENSION}) | ||
set(HOOMD_DEPRECATED_LIB ${HOOMD_DIR}/deprecated/_deprecated${PYTHON_MODULE_EXTENSION}) | ||
|
||
set(HOOMD_LIBRARIES ${HOOMD_LIB} ${HOOMD_COMMON_LIBS}) | ||
set(HOOMD_LIBRARIES ${HOOMD_LIB} ${HOOMD_COMMON_LIBS}) | ||
endif(HOOMD_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Try finding HOOMD first from the current environment | ||
set(HOOMD_GPU_PLATFORM "CUDA" CACHE STRING "GPU backend: CUDA or HIP.") | ||
find_package(HOOMD QUIET) | ||
|
||
if(HOOMD_FOUND) | ||
if( | ||
${HOOMD_VERSION} VERSION_GREATER_EQUAL "3.5.0" OR ( | ||
${HOOMD_VERSION} VERSION_LESS "3" AND | ||
${HOOMD_VERSION} VERSION_GREATER_EQUAL "2.6.0" | ||
) | ||
) | ||
message(STATUS "Found HOOMD: ${HOOMD_DIR} (version ${HOOMD_VERSION})") | ||
else() | ||
message(FATAL_ERROR | ||
"Supported HOOMD versions are v2.6.0 to v2.9.7 or >= v3.5.0 " | ||
"(version ${HOOMD_VERSION})" | ||
) | ||
endif() | ||
endif() | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_MODULE_PATH}) | ||
|
||
if(NOT HOOMD_FOUND) | ||
find_package(HOOMD 2.6.0 REQUIRED) | ||
endif() | ||
|
||
# Plugins must be built as shared libraries | ||
if(ENABLE_STATIC) | ||
message(SEND_ERROR "Plugins cannot be built against a statically compiled hoomd") | ||
endif() | ||
|
||
if(${HOOMD_VERSION} VERSION_LESS "3.5.0") | ||
add_compile_definitions(EXPORT_HALFSTEPHOOK) | ||
if(${HOOMD_VERSION} VERSION_LESS "3") | ||
add_compile_definitions(HOOMD2) | ||
endif() | ||
endif() | ||
|
||
if(ENABLE_HIP AND (HIP_PLATFORM STREQUAL "nvcc")) | ||
add_compile_definitions(ENABLE_CUDA) | ||
endif() | ||
|
||
if(NOT HOOMD_INSTALL_PREFIX) | ||
set(HOOMD_INSTALL_PREFIX ${HOOMD_DIR}) | ||
else() | ||
set(HOOMD_INSTALL_PREFIX "${HOOMD_INSTALL_PREFIX}/${PYTHON_SITE_INSTALL_DIR}") | ||
endif() | ||
|
||
if(NOT HOOMD_LIBRARIES) | ||
set(HOOMD_LIBRARIES HOOMD::_hoomd HOOMD::_md) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.