forked from Q-solvers/EDLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
127 lines (103 loc) · 3.99 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
cmake_minimum_required(VERSION 3.8.2)
project(EDLib LANGUAGES C CXX Fortran
VERSION 2.0)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(CXXStandard)
use_cxx11()
find_package(ALPSCore COMPONENTS params hdf5 gf REQUIRED)
find_package(ARPACK REQUIRED)
find_package(BLAS)
find_package(LAPACK)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${ALPSCore_INCLUDES})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message("setting build type to default, i.e. optimized build")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_DISABLE_ASSERTS -DNDEBUG -g")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(extlibs
${Boost_LIBRARIES}
${HDF5_LIBRARIES}
${ALPSCore_LIBRARIES}
${ARPACK_LIB}
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
)
if(USE_MPI)
if(!ALPS_HAVE_MPI)
MESSAGE(FATAL_ERROR "Enable MPI support in ALPSCore.")
endif(!ALPS_HAVE_MPI)
find_package(MPI REQUIRED)
if(MPI_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MPI")
endif(MPI_FOUND)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAG}")
set(parlibs ${PARPACK_LIB}
${MPI_CXX_LIBRARIES}
${MPI_Fortran_LIBRARIES})
message(INFO " Using parallel libraries: ${parlibs}")
endif(USE_MPI)
# Commented due to the bug in CMake (fixed in 3.13)
#add_subdirectory(lib)
add_subdirectory(include/edlib)
add_subdirectory(include/ext)
include(GNUInstallDirs)
add_library(${PROJECT_NAME} INTERFACE)
add_library(common-lib lib/dummy.f90)
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
install(TARGETS ${PROJECT_NAME} common-lib
EXPORT ${PROJECT_NAME}_targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(EXPORT ${PROJECT_NAME}_targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
file (GLOB_RECURSE TARGET_INSTALL_LIB_HEADERS "${PROJECT_SOURCE_DIR}/include/edlib/*.h")
file (GLOB_RECURSE TARGET_INSTALL_EXT_HEADERS "${PROJECT_SOURCE_DIR}/include/ext/*.h")
install(FILES include/edlib.h
DESTINATION include)
install(FILES ${TARGET_INSTALL_LIB_HEADERS}
DESTINATION include/edlib)
install(FILES ${TARGET_INSTALL_EXT_HEADERS}
DESTINATION include/ext)
option(Testing "Enable testing" OFF)
if(Testing)
include(EnableGtests)
#UseGtest()
#include_directories(${Hubbard_SOURCE_DIR}/test)
add_subdirectory(test)
include_directories(${GTEST_INCLUDE_DIR})
enable_testing()
add_test(SzSymmetryTest test/SzSymmetryTest)
add_test(NSymmetryTest test/NSymmetryTest)
add_test(HubbardModelTest test/HubbardModelTest)
add_test(LanczosTest test/LanczosTest)
add_test(StaticObservablesTest test/StaticObservablesTest)
endif (Testing)
option(Examples "Enable examples" ON)
if(Examples)
add_subdirectory(examples)
set(SOURCE_FILES main.cpp)
add_executable(Hubbard ${SOURCE_FILES})
target_link_libraries(Hubbard common-lib ${PROJECT_NAME} ${extlibs} ${parlibs})
endif(Examples)