Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c19e33
Initial packaging
georgiastuart Feb 26, 2024
c0af40d
Add cmake packaging
georgiastuart Feb 27, 2024
05cf1d1
Packaging modifications
georgiastuart Feb 28, 2024
bd96e58
Update conda install
georgiastuart Mar 2, 2024
731a621
Add nbody pip package
georgiastuart Mar 6, 2024
191aa5d
Committing unfinished conda work
georgiastuart Sep 4, 2024
badc8b2
Merge branch 'main' into build-tools
georgiastuart Sep 5, 2024
af414f8
Update EXP-libraries for latest change
georgiastuart Sep 5, 2024
23654b4
Fix exp build following main merge
georgiastuart Sep 17, 2024
f10d3a8
Fix pyEXP pypi packaging
georgiastuart Sep 17, 2024
158a7ff
Fix pybind11 load when using submodules
georgiastuart Sep 17, 2024
780f36a
Silence find_package warnings when not needed
georgiastuart Sep 17, 2024
a3d6c9b
Move pybind11 subdir add to outer CMake file
georgiastuart Sep 17, 2024
c781aa5
Fix syntax error
georgiastuart Sep 17, 2024
caa66ac
Remove extra libgfortran find causing issues
georgiastuart Sep 17, 2024
8182865
Add include for yaml and highfive submodule versions
georgiastuart Sep 17, 2024
c0d294a
Add config dir for whole project
georgiastuart Sep 17, 2024
36f191c
Use build interface generator function for config include
georgiastuart Sep 17, 2024
60d7fb4
Adjust fortran and libtirpc strategy
georgiastuart Sep 18, 2024
0e3689e
Fix highfive locating
georgiastuart Sep 18, 2024
4f77d15
Update CMakeLists.txt
georgiastuart Sep 18, 2024
7e95b67
Fix highfive locating
georgiastuart Sep 18, 2024
479e1c1
Update tests for new pyEXP layout
georgiastuart Sep 23, 2024
ca4134a
Update to use internal highfive everywhere
georgiastuart Sep 24, 2024
c59e83f
Add spack package draft
georgiastuart Oct 6, 2024
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ src/exp
src/user/CylindricalDisk.cc
src/user/EllipsoidForce.cc
src/user/SLSphere.cc

# Python generated files
*.egg-info
_skbuild
build.log
__pycache__

# Needed for cmake configs
!*Config.cmake.in
196 changes: 115 additions & 81 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,77 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)

# Compiler flags. Not all tested thoroughly...
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using Clang
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# using GCC
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
# using intel
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qno-offload")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# using Visual Studio C++
endif()

# Required compiler features
add_compile_options(-D_REENTRANT)
# Search extern first
list(PREPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/extern )

# Build options
option(BUILD_COMMON_LIBRARIES "Build the exputil and expcoefs libraries" ON)
option(INSTALL_HEADERS "Install headers for exputil and expcoefs" OFF)
option(INSTALL_CMAKE_FIND "Installs the Cmake find_package helpers" OFF)
option(ENABLE_NBODY "Enable EXP n-body" ON)
option(ENABLE_PYEXP "Enable the Python bindings" ON)
option(ENABLE_PNG "Enable PNG graphics support" OFF)
option(ENABLE_CUDA "Enable CUDA" OFF)
option(ENABLE_SLURM "Enable SLURM checkpointing support" OFF)
option(ENABLE_XDR "Enable RPC/XDR support for Tipsy standard" OFF)
option(ENABLE_VTK "Configure VTK if available" OFF)
option(ENABLE_CUDA_SINGLE "Use real*4 instead of real*8 for CUDA" OFF)
option(ENABLE_DSMC "Enable DSMC module" OFF)
option(ENABLE_USER "Enable basic user modules" ON)
option(ENABLE_SLCHECK "Enable *careful* Sturm-Liouville solutions" ON)
option(ENABLE_TESTS "Enable build tests for EXP, pyEXP and helpers" ON)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(BUILD_DOCS "Build documentation" OFF)
option(BUILD_UTILS "Build the utility executables" ON)
option(USE_SUBMODULES "Pull submodules from the EXP git distribution." ON)
option(ENABLE_COMPILER_WARNINGS "Add extra warnings to compile time" OFF)

if(ENABLE_COMPILER_WARNINGS)
set(WARN_OPTIONS
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang,GNU,Intel>>:-Wall>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang,GNU>>:-Wextra>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:-Wpedantic>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang>>:-pedantic>
)
endif()

set(DEFAULT_COMPILER_OPTIONS
-D_REENTRANT
$<$<CXX_COMPILER_ID:Clang>:-stdlib=libc++>
$<$<CXX_COMPILER_ID:Intel>:-qno-offload>
)

add_compile_options(${DEFAULT_COMPILER_OPTIONS} ${WARN_OPTIONS})

# If USE_SUBMODULES is ON
# Check and enforce that we are a git repository. Necessary for
# submodules to work correctly.
if(USE_SUBMODULES)
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
message(STATUS "Checking that we are a git repository - good")
else()
message(STATUS "Checking that we are a git repository - NO")
message(SEND_ERROR "You need to 'git clone ${CMAKE_PROJECT_HOMEPAGE_URL}'. Please don't use the zip download.")
endif()

# Build options
option(ENABLE_NBODY "Enable EXP n-body" ON)
option(ENABLE_PYEXP "Enable the Python bindings" ON)
option(ENABLE_PNG "Enable PNG graphics support" FALSE)
option(ENABLE_CUDA "Enable CUDA" FALSE)
option(ENABLE_SLURM "Enable SLURM checkpointing support" FALSE)
option(ENABLE_XDR "Enable RPC/XDR support for Tipsy standard" FALSE)
option(ENABLE_VTK "Configure VTK if available" FALSE)
option(ENABLE_CUDA_SINGLE "Use real*4 instead of real*8 for CUDA" FALSE)
option(ENABLE_USER "Enable basic user modules" ON)
option(ENABLE_SLCHECK "Enable *careful* Sturm-Liouville solutions" TRUE)
option(ENABLE_TESTS "Enable build tests for EXP, pyEXP and helpers" ON)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(BUILD_DOCS "Build documentation" OFF)
endif()

# Set mpirun launcher for CTest

set(EXP_MPI_LAUNCH "mpirun" CACHE STRING "Command to run an MPI application (for unit tests only)")

# Find newest version if multiple versions are available

set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)

# Package support

find_package(MPI REQUIRED COMPONENTS C CXX)
find_package(OpenMP)
find_package(FFTW)
find_package(HDF5 COMPONENTS C CXX HL REQUIRED)
find_package(TIRPC) # Check for alternative Sun rpc support
find_package(Eigen3 REQUIRED)
find_package(PNG)

if(ENABLE_PNG)
find_package(PNG REQUIRED)
endif()

# Check for FE
include(FEENABLE)
Expand Down Expand Up @@ -160,6 +173,7 @@ endif()

# Only include RPC support if the installer wants XDR
if(ENABLE_XDR)
find_package(TIRPC) # Check for alternative Sun rpc support
if(TIRPC_FOUND OR HAVE_RPC_TYPES)
set(HAVE_XDR TRUE CACHE BOOL "We have an XDR implementation")
message(STATUS "We have an XDR implementation; Tipsy standard files will be supported.")
Expand All @@ -179,35 +193,37 @@ set(CUDA_EXP_DATTRIB "4" CACHE STRING
"Number of real particle attributes for Cuda particle structure")
add_compile_definitions(DATTRIB_CUDA=${CUDA_EXP_DATTRIB})

# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Git submodule updates
execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT
)
if(USE_SUBMODULES)
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT
)

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed ${GIT_SUBMOD_RESULT}, please checkout submodules")
else()
message(STATUS "Submodules updated successfully - good")
endif()

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed ${GIT_SUBMOD_RESULT}, please checkout submodules")
else()
message(STATUS "Submodules updated successfully - good")
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()

# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the build date
execute_process(
COMMAND date +%Y-%m-%d\ %H:%M:%S\ %Z
Expand All @@ -216,14 +232,21 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)

include_directories(${PROJECT_SOURCE_DIR}/extern/yaml-cpp/include)
include_directories(${PROJECT_SOURCE_DIR}/extern/pybind11/include)

# Report to the user
message("Configuring build for ${GIT_BRANCH}/${GIT_COMMIT} at ${COMPILE_TIME}")
if (USE_SUBMODULES)
message("Configuring build for ${GIT_BRANCH}/${GIT_COMMIT} at ${COMPILE_TIME}")
include_directories(${PROJECT_SOURCE_DIR}/extern/yaml-cpp/include)
add_subdirectory(extern/yaml-cpp)
else()
find_package(yaml-cpp REQUIRED)
endif()

add_subdirectory(extern/yaml-cpp)
add_subdirectory(extern/pybind11)
if (USE_SUBMODULES AND ENABLE_PYEXP)
message("Configuring pybind11 for ${GIT_BRANCH}/${GIT_COMMIT} at ${COMPILE_TIME}")
add_subdirectory(extern/pybind11)
include_directories(${PROJECT_SOURCE_DIR}/extern/pybind11/include)
elseif(ENABLE_PYEXP)
find_package(pybind11 CONFIG REQUIRED)
endif()

# Set options for the HighFive git submodule in extern
set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "Do not build the examples")
Expand All @@ -232,20 +255,33 @@ set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "Do not use Boost in HighFive")
set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "Turn off internal testing for HighFIve")
set(H5_USE_EIGEN TRUE CACHE BOOL "Eigen3 support in HighFive")

add_subdirectory(extern/HighFive EXCLUDE_FROM_ALL)
find_package(HighFive 3)

if (NOT HighFive_FOUND)
add_subdirectory(extern/HighFive EXCLUDE_FROM_ALL)
endif()

# Configure the remaining native subdirectories
add_subdirectory(exputil)
add_subdirectory(expui)
if (BUILD_COMMON_LIBRARIES)
add_subdirectory(exputil)
add_subdirectory(expui)
endif()

if (ENABLE_NBODY)
add_subdirectory(src)
endif()
add_subdirectory(utils)

if (BUILD_UTILS)
add_subdirectory(utils)
endif()

if (ENABLE_PYEXP)
add_subdirectory(pyEXP)
endif()

add_subdirectory(extern/user-modules)
if (ENABLE_USER)
add_subdirectory(extern/user-modules)
endif()

# Build the tests; set ENABLE_TEST=OFF to disable
if(ENABLE_TESTS)
Expand All @@ -254,12 +290,12 @@ if(ENABLE_TESTS)
endif()

# try to find pybind11 and build wrapper python module
find_package(Python3 COMPONENTS Interpreter Development)
message(STATUS "python3 include dirs: ${Python3_INCLUDE_DIRS}")
# find_package(Python3 COMPONENTS Interpreter Development)
# message(STATUS "python3 include dirs: ${Python3_INCLUDE_DIRS}")


# Force installation of the yaml-cpp libraries
install(TARGETS yaml-cpp DESTINATION lib)
# install(TARGETS yaml-cpp DESTINATION lib)

# Check for doxygen is the user wants web docs
if (BUILD_DOCS)
Expand Down Expand Up @@ -341,9 +377,7 @@ set(CMAKE_CXX_FLAGS_UBSAN
CACHE STRING "Flags used by the C++ compiler during UndefinedBehaviourSanitizer builds."
FORCE)

# Make the config_exp.h file in the build directory, add the build dir
# to the CMake include path. This allows for multiple configurations
# from the same source.
configure_file(${CMAKE_SOURCE_DIR}/config_cmake.h_in ${CMAKE_BINARY_DIR}/config_exp.h)
include_directories(${PROJECT_BINARY_DIR})

# Make the config_exp.h file in the build directory,
# to be added to the private include path by modules
configure_file(config_cmake.h_in ${CMAKE_BINARY_DIR}/config/config_exp.h)
configure_file(config_cmake.h_in ${CMAKE_BINARY_DIR}/config_exp.h)
92 changes: 48 additions & 44 deletions cmake/FindTIRPC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,60 @@
#

find_package(PkgConfig)
pkg_check_modules(PC_TIRPC QUIET TIRPC)
pkg_check_modules(TIRPC QUIET libtirpc)

find_path(
TIRPC_INCLUDE_DIR
NAMES
"rpc/types.h"
"tpc/xdr.h"
PATHS
ENV CPATH
ENV C_INCLUDE_PATH
ENV CPLUS_INCLUDE_PATH
ENV RPC_PATH
PATH_SUFFIXES
"include/tirpc"
DOC
"Path to the Sun RPC include directory"
)
if (NOT TIRPC_FOUND)
find_path(
TIRPC_INCLUDE_DIR
NAMES
"rpc/types.h"
"tpc/xdr.h"
PATHS
ENV CPATH
ENV C_INCLUDE_PATH
ENV CPLUS_INCLUDE_PATH
ENV RPC_PATH
PATH_SUFFIXES
"include/tirpc"
DOC
"Path to the Sun RPC include directory"
)

find_library(TIRPC_LIBRARY
NAMES tirpc
PATH_SUFFIXES
"lib"
"lib64"
"lib/x86_64-linux-gnu"
DOC
"Path to the Sun RPC library"
)
find_library(TIRPC_LIBRARY
NAMES tirpc
PATH_SUFFIXES
"lib"
"lib64"
"lib/x86_64-linux-gnu"
DOC
"Path to the Sun RPC library"
)

set(TIRPC_VERSION ${PC_TIRPC_VERSION})
set(TIRPC_VERSION ${PC_TIRPC_VERSION})

include(FindPackageHandleStandardArgs)
include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(TIRPC
FOUND_VAR
TIRPC_FOUND
REQUIRED_VARS
TIRPC_LIBRARY
TIRPC_INCLUDE_DIR
)
find_package_handle_standard_args(TIRPC
FOUND_VAR
TIRPC_FOUND
REQUIRED_VARS
TIRPC_LIBRARY
TIRPC_INCLUDE_DIR
)

if(TIRPC_FOUND)
set(TIRPC_LIBRARIES "${TIRPC_LIBRARY}")
set(TIRPC_INCLUDE_DIRS "${TIRPC_INCLUDE_DIR}")
set(TIRPC_DEFINITIONS "${PC_TIRPC_CFLAGS_OTHER}")
if(TIRPC_FOUND)
set(TIRPC_LIBRARIES "${TIRPC_LIBRARY}")
set(TIRPC_INCLUDE_DIRS "${TIRPC_INCLUDE_DIR}")
set(TIRPC_DEFINITIONS "${PC_TIRPC_CFLAGS_OTHER}")

add_library(TIRPC::TIRPC UNKNOWN IMPORTED)
set_target_properties(TIRPC::TIRPC
PROPERTIES
IMPORTED_LOCATION "${TIRPC_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_TIRPC_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${TIRPC_INCLUDE_DIR}")
add_library(TIRPC::TIRPC UNKNOWN IMPORTED)
set_target_properties(TIRPC::TIRPC
PROPERTIES
IMPORTED_LOCATION "${TIRPC_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_TIRPC_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${TIRPC_INCLUDE_DIR}")
endif()
else ()
message(STATUS "Found TIRPC: ${TIRPC_LINK_LIBRARIES}")
endif()

Loading
Loading