Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ src/exp
src/user/CylindricalDisk.cc
src/user/EllipsoidForce.cc
src/user/SLSphere.cc

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

# Needed for cmake configs
!*Config.cmake.in
170 changes: 128 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,72 @@ 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++
# 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})

# # Compiler flags. Not all tested thoroughly...
# if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# # using Clang
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
# elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# # using GCC
# add_compile_options(${WARN_OPTIONS})
# 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)
# add_compile_options(-D_REENTRANT)

# 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_DSMC "Enable DSMC module" 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

Expand All @@ -67,9 +93,11 @@ find_package(Boost COMPONENTS serialization)
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 @@ -168,6 +196,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 Down Expand Up @@ -211,35 +240,56 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)

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

find_package(yaml-cpp REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my standard build, this line addition is a problem. Perhaps it needs to be inside some if statement?

CMake Error at CMakeLists.txt:248 (find_package):
  By not providing "Findyaml-cpp.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "yaml-cpp",
  but CMake did not find one.

  Could not find a package configuration file provided by "yaml-cpp" with any
  of the following names:

    yaml-cppConfig.cmake
    yaml-cpp-config.cmake

  Add the installation prefix of "yaml-cpp" to CMAKE_PREFIX_PATH or set
  "yaml-cpp_DIR" to a directory containing one of the above files.  If
  "yaml-cpp" provides a separate development package or SDK, be sure it has
  been installed.

Copy link
Contributor Author

@georgiastuart georgiastuart Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I think it should only use find_package for yaml-cpp if USE_SUBMODULES=OFF, so I'll fix that. Merging in the latest updates and fixing up any oddities.


# Report to the user
message("Configuring build for ${GIT_BRANCH}/${GIT_COMMIT} at ${COMPILE_TIME}")

add_subdirectory(extern/yaml-cpp)
add_subdirectory(extern/pybind11)
if (USE_SUBMODULES)
add_subdirectory(extern/yaml-cpp)
add_subdirectory(extern/pybind11)
else()

endif()

# Set options for the HighFive git submodule in extern
set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "Do not build the examples")
set(HIGHFIVE_BUILD_DOCS OFF CACHE BOOL "Do not build the documentation")
set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "Do not use Boost in HighFIve")
set(H5_USE_EIGEN TRUE CACHE BOOL "Eigen3 support in HighFive")

add_subdirectory(extern/HighFive)
if (USE_SUBMODULES)
add_subdirectory(extern/HighFive)
else ()
find_package(HighFive REQUIRED)
endif()

# Configure the remaining native subdirectories
add_subdirectory(exputil)
add_subdirectory(coefs)
if (BUILD_COMMON_LIBRARIES)
add_subdirectory(exputil)
add_subdirectory(coefs)
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 (BUILD_USER)
add_subdirectory(extern/user-modules)
endif()

# Build the tests; set ENABLE_TEST=OFF to disable
if(ENABLE_TESTS)
Expand All @@ -248,12 +298,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 @@ -339,5 +389,41 @@ set(CMAKE_CXX_FLAGS_UBSAN
# 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)
configure_file(${CMAKE_SOURCE_DIR}/config_cmake.h_in ${CMAKE_BINARY_DIR}/config/config_exp.h)
include_directories(${PROJECT_BINARY_DIR})

# # Install the headers for development environments
if (INSTALL_HEADERS)
# TODO: Replace this globbing with a list of actually public headers
add_library(expcommon INTERFACE)
file(GLOB expcommon_PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.[hH]")
set_target_properties (expcommon PROPERTIES EXPORT_NAME EXPcommon)
set_target_properties (expcommon PROPERTIES PUBLIC_HEADER "${expcommon_PUBLIC_HEADERS}")
message(STATUS "HEADERS=${expcommon_PUBLIC_HEADERS}")

install (TARGETS expcommon
EXPORT EXPcommonTargets
PUBLIC_HEADER DESTINATION include/expcommon)

if (INSTALL_CMAKE_FIND)
# Set up cmake configs
set(CMAKEPACKAGE_INSTALL_DIR share/EXPcommon/cmake)
install (EXPORT EXPcommonTargets
FILE EXPcommonTargets.cmake
NAMESPACE EXP::
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})

include(CMakePackageConfigHelpers)
configure_package_config_file(include/EXPcommonConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/EXPcommonConfig.cmake
INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
PATH_VARS CMAKEPACKAGE_INSTALL_DIR CMAKE_INSTALL_PREFIX
)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EXPcommonVersion.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY SameMinorVersion )
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/EXPcommonConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/EXPcommonVersion.cmake
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} )
endif()
endif()
106 changes: 73 additions & 33 deletions coefs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
set(bin_PROGRAMS nativetoh5 h5compare viewcoefs h5power makecoefs testread)
set(common_LINKLIB ${OpenMP_CXX_LIBRARIES} ${MPI_CXX_LIBRARIES}
${YAML_CPP_LIBRARIES} $<$<NOT:$<BOOL:${EXPutil_LIBRARIES}>>:exputil>
${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}
$<BOOL:${HighFive_FOUND}>:HighFive>)

set(common_LINKLIB OpenMP::OpenMP_CXX MPI::MPI_CXX yaml-cpp exputil
${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES})
set(common_INCLUDE $<INSTALL_INTERFACE:include>
${DEP_INC} ${HDF5_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR} ${FFTW_INCLUDE_DIRS})

set(common_INCLUDE_DIRS_PRIVATE
${CMAKE_BINARY_DIR}/config
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/extern/>
${CMAKE_CURRENT_SOURCE_DIR})

if(PNG_FOUND)
list(APPEND common_LINKLIB PNG::PNG)
list(APPEND common_LINKLIB ${PNG_LIBRARIES})
endif()

set(common_INCLUDE $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/>
${CMAKE_BINARY_DIR} ${DEP_INC} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/.. ${HighFive_SOURCE_DIR}/include
${HDF5_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${FFTW_INCLUDE_DIRS})


if(ENABLE_CUDA)
list(APPEND common_INCLUDE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDAToolkit_INCLUDE_DIRS})
list(APPEND common_LINKLIB CUDA::cudart CUDA::nvToolsExt)
Expand All @@ -24,36 +26,74 @@ if(SLURM_FOUND)
list(APPEND common_LINKLIB ${SLURM_LIBRARY})
endif()

if(ENABLE_XDR AND TIRPC_FOUND)
list(APPEND common_INCLUDE ${TIRPC_INCLUDE_DIRS})
list(APPEND common_LINKLIB ${TIRPC_LIBRARIES})
endif()
# Appears to be an overlinker here...
# if(ENABLE_XDR AND TIRPC_FOUND)
# list(APPEND common_INCLUDE ${TIRPC_INCLUDE_DIRS})
# list(APPEND common_LINKLIB ${TIRPC_LIBRARIES})
# endif()

# Make the expcoef shared library
#
set(expcoef_SOURCES BasisFactory.cc BiorthBasis.cc FieldBasis.cc
CoefContainer.cc CoefStruct.cc FieldGenerator.cc expMSSA.cc
Coefficients.cc KMeans.cc Centering.cc ParticleIterator.cc
Koopman.cc)
add_library(expcoef ${expcoef_SOURCES})
set_target_properties(expcoef PROPERTIES OUTPUT_NAME expcoef)

# TODO: Replace this globbing with a list of actually public headers
file(GLOB expcoef_PUBLIC_HEADERS "*.[hH]")
set_target_properties (expcoef PROPERTIES OUTPUT_NAME expcoef)
set_target_properties (expcoef PROPERTIES EXPORT_NAME EXPcoefs)
set_target_properties (expcoef PROPERTIES PUBLIC_HEADER "${expcoef_PUBLIC_HEADERS}")

target_include_directories(expcoef PUBLIC ${common_INCLUDE})
target_include_directories(expcoef PRIVATE ${common_INCLUDE_DIRS_PRIVATE})
target_link_libraries(expcoef PUBLIC ${common_LINKLIB})

install(TARGETS expcoef DESTINATION lib)

# Configure and build the test routines
#
add_executable(nativetoh5 coefstoh5.cc)
add_executable(h5compare h5compare.cc)
add_executable(viewcoefs viewcoefs.cc)
add_executable(h5power h5power.cc)
add_executable(makecoefs makecoefs.cc)
add_executable(testread testread.cc)

foreach(program ${bin_PROGRAMS})
target_link_libraries(${program} expcoef exputil ${common_LINKLIB})
target_include_directories(${program} PUBLIC ${common_INCLUDE})
target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS})
install(TARGETS ${program} DESTINATION bin)
endforeach()
if (ENABLE_TESTS)
set(bin_PROGRAMS nativetoh5 h5compare viewcoefs h5power makecoefs testread)

add_executable(nativetoh5 coefstoh5.cc)
add_executable(h5compare h5compare.cc)
add_executable(viewcoefs viewcoefs.cc)
add_executable(h5power h5power.cc)
add_executable(makecoefs makecoefs.cc)
add_executable(testread testread.cc)

foreach(program ${bin_PROGRAMS})
target_link_libraries(${program} expcoef exputil ${common_LINKLIB})
target_include_directories(${program} PUBLIC ${common_INCLUDE})
target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS})
endforeach()
endif()

install (TARGETS expcoef
EXPORT EXPcoefsTargets
LIBRARY DESTINATION lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION include/expcoefs)

if (INSTALL_CMAKE_FIND)
# Set up cmake configs
set(CMAKEPACKAGE_INSTALL_DIR share/EXPcoefs/cmake)
install (EXPORT EXPcoefsTargets
FILE EXPcoefsTargets.cmake
NAMESPACE EXP::
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})

include(CMakePackageConfigHelpers)
configure_package_config_file(EXPcoefsConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/EXPcoefsConfig.cmake
INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
PATH_VARS CMAKEPACKAGE_INSTALL_DIR CMAKE_INSTALL_PREFIX
)

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EXPcoefsVersion.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY SameMinorVersion )

install (FILES ${CMAKE_CURRENT_BINARY_DIR}/EXPcoefsConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/EXPcoefsVersion.cmake
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} )
endif()
Loading