Skip to content

Commit

Permalink
Merge pull request #19 from donrolih/fmt_library
Browse files Browse the repository at this point in the history
Use CPM to manage dependencies
  • Loading branch information
rokzitko authored Sep 26, 2024
2 parents 1765cdb + 398f64e commit a7d31c2
Show file tree
Hide file tree
Showing 1,051 changed files with 76 additions and 360,178 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build

on:
push:
branches: [ master ]
branches: [ master, fmt_library]
pull_request:
branches: [ master ]
workflow_call:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
clang-15
g++-12
hdf5-tools
intel-mkl
libmkl-dev
libclang-15-dev
libc++-15-dev
libc++abi-15-dev
Expand All @@ -98,7 +98,7 @@ jobs:
- name: Install homebrew dependencies (clang)
if: ${{ (matrix.os == 'macos-12') && contains(matrix.cxx, 'clang') }}
run: |
brew install ccache llvm boost boost-mpi hdf5 open-mpi openblas gsl gmp
brew install ccache llvm gcc boost boost-mpi hdf5 open-mpi openblas gsl gmp
- name: add clang cxxflags
if: ${{ contains(matrix.cxx, 'clang') }}
Expand Down
24 changes: 24 additions & 0 deletions CMake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.40.2)
set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
34 changes: 31 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
# ##############################################################################

cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
Expand Down Expand Up @@ -172,6 +172,35 @@ install(TARGETS gsl EXPORT nrgljubljana-targets)
find_package(GMP REQUIRED)
install(TARGETS gmp EXPORT nrgljubljana-targets)

# CPM for downloading dependencies
include(CMake/CPM.cmake)

# Google Test
CPMAddPackage("gh:google/googletest#v1.15.2")

# Eigen, tries finding in system first
CPMFindPackage(
NAME Eigen3
GITLAB_REPOSITORY libeigen/eigen
GIT_TAG 3.4.0
OPTIONS
"BUILD_TESTING OFF" # Disable tests for Eigen
)

# High five library
CPMAddPackage(
GITHUB_REPOSITORY BlueBrain/HighFive
GIT_TAG v2.10.0
OPTIONS
"HIGHFIVE_BUILD_DOCS OFF" # Disable HighFive documentation
)

# fmt
CPMAddPackage("gh:fmtlib/fmt#11.0.2")

# range-v3
CPMAddPackage("gh:ericniebler/range-v3#0.12.0")

# MPFR
#find_package(MPFR REQUIRED)
#install(TARGETS mpfr EXPORT nrgljubljana-targets)
Expand All @@ -198,8 +227,7 @@ message(STATUS "BLAS_LIBRARIES=${BLAS_LIBRARIES}")
message(STATUS "BLAS_LINKER_FLAGS=${BLAS_LINKER_FLAGS}")
message(STATUS "LAPACK_LIBRARIES=${LAPACK_LIBRARIES}")
message(STATUS "LAPACK_LINKER_FLAGS=${LAPACK_LINKER_FLAGS}")
target_compile_options(blas_lapack INTERFACE ${LAPACK_LINKER_FLAGS} ${BLAS_LINKER_FLAGS})
target_link_libraries(blas_lapack INTERFACE ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
target_link_libraries(blas_lapack INTERFACE LAPACK::LAPACK)
install(TARGETS blas_lapack EXPORT nrgljubljana-targets)

# Check for availability of cblas interface
Expand Down
2 changes: 1 addition & 1 deletion c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ target_compile_definitions(nrgljubljana_c PUBLIC
)

# Link dependencies
target_link_libraries(nrgljubljana_c PUBLIC openmp boost blas_lapack gmp dl mpi hdf5
target_link_libraries(nrgljubljana_c PUBLIC openmp boost blas_lapack gmp dl mpi HighFive fmt::fmt-header-only range-v3 Eigen3::Eigen
$<$<BOOL:${ASAN}>:asan>
$<$<BOOL:${UBSAN}>:ubsan>
)
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion c++/algo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <memory>
#include <list>
#include <functional> // std::function
#define FMT_HEADER_ONLY
#include <fmt/format.h>
#include "traits.hpp"
#include "params.hpp"
Expand Down
1 change: 0 additions & 1 deletion c++/basicio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <iterator> // ostream_iterator
#include <stdexcept>

#define FMT_HEADER_ONLY
#include <fmt/format.h>

#include <boost/lexical_cast.hpp>
Expand Down
5 changes: 2 additions & 3 deletions c++/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "h5.hpp"
#include "io.hpp"

#define FMT_HEADER_ONLY
#include <fmt/format.h>
#include <fmt/color.h>

Expand Down Expand Up @@ -149,10 +148,10 @@ auto do_diag(const Step &step, const Operators<S> &operators, const Coef<S> &coe
break;
}
catch (NotEnough &e) {
fmt::color_print(P.pretty_out, fmt::emphasis::bold | fg(fmt::color::yellow), "Insufficient number of states computed.\n");
fmt::print(fmt::emphasis::bold | fg(fmt::color::yellow), "Insufficient number of states computed.\n");
if (!(step.nrg() && P.restart)) break;
diagratio = std::min(diagratio * P.restartfactor, 1.0);
fmt::color_print(P.pretty_out, fmt::emphasis::bold | fg(fmt::color::yellow), "\nRestarting this iteration step. diagratio={}\n\n", diagratio);
fmt::print(fmt::emphasis::bold | fg(fmt::color::yellow), "\nRestarting this iteration step. diagratio={}\n\n", diagratio);
}
}
return diag;
Expand Down
1 change: 0 additions & 1 deletion c++/diag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "debug.hpp" // nrglogdp
#include "numerics.hpp" // is_matrix_upper

#define FMT_HEADER_ONLY
#include <fmt/format.h>

#define LAPACK_COMPLEX_STRUCTURE
Expand Down
1 change: 0 additions & 1 deletion c++/dmnrg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "stats.hpp"
#include "numerics.hpp"

#define FMT_HEADER_ONLY
#include <fmt/format.h>

namespace NRG {
Expand Down
1 change: 0 additions & 1 deletion c++/eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "h5.hpp"
#include "numerics.hpp"

#define FMT_HEADER_ONLY
#include <fmt/format.h>

namespace NRG {
Expand Down
50 changes: 0 additions & 50 deletions c++/include/Eigen/AccelerateSupport

This file was deleted.

41 changes: 0 additions & 41 deletions c++/include/Eigen/Cholesky

This file was deleted.

48 changes: 0 additions & 48 deletions c++/include/Eigen/CholmodSupport

This file was deleted.

Loading

0 comments on commit a7d31c2

Please sign in to comment.