forked from ITensor/ITensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
117 lines (106 loc) · 4.17 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
cmake_minimum_required (VERSION 2.8)
project (ITensor)
# Disable build in source (not to overlap with existing Makefile)
if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
message(FATAL_ERROR "In source builds are disabled. Please use a separate build directory.")
endif()
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
# Select default build type : Release = -03 -DNDEBUG
if(NOT CMAKE_BUILD_TYPE:String AND NOT CMAKE_CONFIGURATION_TYPES)
SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
else()
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# rpath fix on a mac
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
else()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
option (CXX11 OFF)
if (CXX11)
# enable C++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
if (NOT (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.6 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
message( STATUS "Adding -stdlib=libc++ flag")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else()
message(FATAL_ERROR "Platform undefined")
endif()
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()
endif (CXX11)
# LAPACK
# Check if LAPACK vendor is not defined and try to set it.
if (NOT DEFINED BLA_VENDOR)
if (${APPLE})
message(STATUS "Setting lapack platform : Apple")
set(BLA_VENDOR Apple)
else()
set(BLA_VENDOR All)
endif()
endif()
# define platform flag inside of include/lapack_wrap.h
message(STATUS "Searching for LAPACK vendor : ${BLA_VENDOR}")
if (${BLA_VENDOR} MATCHES "Intel" OR "mkl")
message(STATUS "Setting lapack platform : Intel")
add_definitions(-DPLATFORM_mkl)
find_package(MKL REQUIRED)
list(APPEND CMAKE_LINKER_FLAGS ${MKL_LINKER_FLAGS})
include_directories(${MKL_INCLUDE_DIRS})
link_libraries(${MKL_LIBRARIES})
else()
if(${BLA_VENDOR} MATCHES ACML)
message(STATUS "Setting lapack platform : ACML")
add_definitions(-PLATFORM_mkl)
elseif(${BLA_VENDOR} MATCHES Apple)
message(STATUS "Setting lapack platform : Apple")
add_definitions(-DPLATFORM_macos)
else()
message(STATUS "Setting lapack platform : Generic")
add_definitions(-DPLATFORM_lapack)
endif()
find_package(LAPACK REQUIRED)
list(APPEND CMAKE_LINKER_FLAGS ${LAPACK_LINKER_FLAGS})
link_libraries(${LAPACK_LIBRARIES})
endif()
# build itensor parts
add_subdirectory(utilities)
add_subdirectory(matrix)
add_subdirectory(itensor)
# Enable testing
option(Testing "Enable testing" ON)
if (Testing)
enable_testing()
add_subdirectory(unittest)
endif (Testing)
# Build example
option(Tutorial "Build tutorial" ON)
if (Tutorial)
message(STATUS "Building tutorial")
add_subdirectory(tutorial)
endif (Tutorial)
# Build sample
option(Sample "Build samples" ON)
if (Sample)
message(STATUS "Building samples")
add_subdirectory(sample)
endif (Sample)
# Install pkg-config file
#configure_file(ITensor.pc.in ITensor.pc @ONLY)
#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ITensor.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)