Skip to content

Commit

Permalink
initial changes for spack
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrismarsh committed Nov 30, 2023
1 parent 1aa08d3 commit 07c0e22
Showing 1 changed file with 24 additions and 60 deletions.
84 changes: 24 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.16)
project (CHM-project CXX Fortran)
project (CHM-project C CXX Fortran)

# In CMake 3.12 and above the find_package(<PackageName>) command now searches prefixes specified by the <PackageName>_ROOT
# CMake variable and the <PackageName>_ROOT environment variable.
Expand Down Expand Up @@ -27,10 +27,10 @@ option(OMP_SAFE_EXCEPTION "Enables safe exception handling from within OMP regio
option(ENABLE_SAFE_CHECKS "Enable variable map checking. Runtime perf cost. Allows for ensuring a variable is indeed available to be lookedup." ON)
option(BUILD_TESTS "Build all tests." OFF ) # Makes boolean 'test' available.
option(STATIC_ANLAYSIS "Enable PVS static anlaysis" OFF)
option(USE_TCMALLOC "Use tcmalloc from gperftools " ON)
option(USE_JEMALLOC "Use jemalloc" OFF)
option(USE_TCMALLOC "Use tcmalloc from gperftools " OFF)
option(USE_JEMALLOC "Use jemalloc" ON)
option(BUILD_DOCS "Builds documentation" OFF)
option(BUILD_WITH_CONAN "Uses Conan for dependencies" ON)


message(STATUS "This is an MPI build? ${USE_MPI}")

Expand All @@ -56,13 +56,10 @@ endif()

LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}")

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/")
LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/CMake-without-conan/")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake-without-conan/")

if(NOT BUILD_WITH_CONAN)
LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/CMake-without-conan/")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake-without-conan/")
endif()

#########
# lovely CMake script to integrate git hashes
Expand Down Expand Up @@ -126,22 +123,10 @@ endmacro()
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_find_names.cmake)

# Need to check for MPI before building external libraries
find_package(MPI)
find_package(MPI REQUIRED COMPONENTS C CXX Fortran) # MPI_C is needed for the mpi that HDF can bring in
if(MPI_FOUND AND USE_MPI)
message(STATUS "Found MPI at ${MPI_CXX_INCLUDE_DIRS}")
add_definitions(-DUSE_MPI)

if(BUILD_WITH_CONAN)
# ensure boost MPI support was built
if(MPI_FOUND AND USE_MPI)
file(READ ${CMAKE_BINARY_DIR}/FindBoost.cmake txt)
string(FIND "${txt}" "boost_mpi" RETCODE)

if(${RETCODE} EQUAL -1) # -1 is not found retcode from find
message(FATAL_ERROR "MPI was asked for, however boost was not built with mpi. Please build boost (--build boost) locally with a working MPI. See wiki for more information.")
endif()
endif()
endif()
else()
message(WARNING "MPI not enabled. Building for single process.")
endif()
Expand Down Expand Up @@ -267,47 +252,26 @@ find_package(${METEOIO} REQUIRED)
find_package(${ARMADILLO} REQUIRED)
create_target(ARMADILLO) #needs to be upper-case

if(BUILD_WITH_CONAN)
find_package(${EIGEN3} REQUIRED)
else()
find_package(${EIGEN3} REQUIRED NO_MODULE)
endif()
find_package(${EIGEN3} REQUIRED NO_MODULE)

# The trilinos library may have been built against a custom location blas/openblas
# If so, conaninfo.txt has information on the custom blas location if given with the -o trilinos:blas_root=<root> option
# If conaninfo.txt has a custom blas location, extract it and pass it as a hint to find_package(blas) which will detect any blas.
# Then use the find_package link target in CHM to fully avoid any problems of linking against the wrong blas or not being able to find it.
#if(BUILD_WITH_CONAN)
# if(EXISTS "${CMAKE_BINARY_DIR}/conaninfo.txt")
# file(READ ${CMAKE_BINARY_DIR}/conaninfo.txt conaninfotxt)
# string(REGEX MATCH "trilinos:blas_root=([^ ]+)lib" blasloc "${conaninfotxt}") # because cmake regex is only greedy
# if(NOT "${blasloc}" STREQUAL "")
# string(REPLACE "\n" "" blasloc ${CMAKE_MATCH_1}) # strip out a new line we've picked up
# message(WARNING "Using the conaninfo.txt trilinos:blas_root=${blasloc}")
# set(BLAS_ROOT ${blasloc})
# endif()
# elseif()
# set(blasloc "")
# endif()
#endif()

# we build blas from conan so do not do this if we are using the full conan stack
if(MACOSX AND NOT BUILD_WITH_CONAN)

execute_process(
COMMAND brew --prefix openblas
RESULT_VARIABLE BREW_BLAS
OUTPUT_VARIABLE BREW_BLAS_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(BREW_BLAS EQUAL 0)
message(WARNING "Found homebrew OpenBLAS ${BREW_BLAS_PREFIX}" )
set(BLAS_ROOT ${BREW_BLAS_PREFIX})
set(BLA_VENDOR Generic)
endif()

endif()
#if(MACOSX AND NOT BUILD_WITH_CONAN)
#
# execute_process(
# COMMAND brew --prefix openblas
# RESULT_VARIABLE BREW_BLAS
# OUTPUT_VARIABLE BREW_BLAS_PREFIX
# OUTPUT_STRIP_TRAILING_WHITESPACE
# )
#
# if(BREW_BLAS EQUAL 0)
# message(WARNING "Found homebrew OpenBLAS ${BREW_BLAS_PREFIX}" )
# set(BLAS_ROOT ${BREW_BLAS_PREFIX})
# set(BLA_VENDOR Generic)
# endif()
#
#endif()


find_package(${SPARSEHASH})
Expand Down

0 comments on commit 07c0e22

Please sign in to comment.