Skip to content

Commit

Permalink
Install headers (#33)
Browse files Browse the repository at this point in the history
* Update README.md

* Change name
  • Loading branch information
RaulPPelaez authored Feb 25, 2024
1 parent 66b8b37 commit 921e15c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.10)
project(uammd)
# Install headers
file(GLOB_RECURSE headers src/*)

foreach(header ${headers})
get_filename_component(header_path ${header} PATH)
file(RELATIVE_PATH header_path_rel ${CMAKE_CURRENT_SOURCE_DIR}/src ${header_path})
install(FILES ${header} DESTINATION include/uammd/${header_path_rel})
endforeach()

# Install FindUAMMD.cmake
install(FILES cmake/FindUAMMD.cmake DESTINATION share/cmake/Modules)
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ mamba env create -f environment.yml

**UAMMD does not need to be compiled separatedly (it is header only)**.

The top-level CMakeLists.txt file will install all UAMMD headers to `$CMAKE_INSTALL_PREFIX/include/uammd`. Additionally, a cmake module file (`FindUAMMD.cmake` will be installed at `$CMAKE_INSTALL_PREFIX/share/cmake/Modules`). To install the headers, go to the root of this repo and run:

```shell
$ mkdir build && cd build
$ cmake -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX .. # If you wish to install the headers to the conda environment
$ make install
```

Now other CMake scripts can find the UAMMD headers with:

```cmake
find_package(UAMMD REQUIRED)
include_directories(${UAMMD_INCLUDE_DIR})
```

Some special flags might be needed to compile codes including with certain UAMMD headers, see [Compiling UAMMD](https://uammd.readthedocs.io/en/latest/Compiling-UAMMD.html).
Here you have a short example of how a typical UAMMD code looks like, encoding a simple Brownian dynamics simulation of non interacting particles.:

Expand Down
26 changes: 26 additions & 0 deletions cmake/FindUAMMD.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Looks for the uammd include folder in the system and sets the UAMMD_INCLUDE_DIRS variable.
# Usage:
# find_package(UAMMD REQUIRED)
# include_directories(${UAMMD_INCLUDE_DIRS})
# The include folder can be in the following locations:
# 1. In the system include folder: /usr/include/uammd
# 2. In the user's home folder: ~/uammd/include/uammd
# 3. In the conda environment: $ENV{CONDA_PREFIX}/include/uammd

# First, look for the include folder in the system.
find_path(UAMMD_INCLUDE_DIRS uammd.cuh HINTS /usr/include/uammd)

# If the include folder is not found, look for it in the user's home folder.
if(NOT UAMMD_INCLUDE_DIRS)
find_path(UAMMD_INCLUDE_DIRS uammd.cuh HINTS $ENV{HOME}/uammd/include/uammd)
endif()

# If the include folder is not found, look for it in the conda environment.
if(NOT UAMMD_INCLUDE_DIRS)
find_path(UAMMD_INCLUDE_DIRS uammd.cuh HINTS $ENV{CONDA_PREFIX}/include/uammd)
endif()

# Add also the folder UAMMD_INCLUDE_DIRS/third_party to the include directories.
if(UAMMD_INCLUDE_DIRS)
set(UAMMD_INCLUDE_DIRS ${UAMMD_INCLUDE_DIRS} ${UAMMD_INCLUDE_DIRS}/third_party)
endif()

0 comments on commit 921e15c

Please sign in to comment.