This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
73 lines (64 loc) · 2.55 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
cmake_minimum_required(VERSION 3.6)
project(SpinW)
set(DO_TESTS "TRUE")
set(MAKE_IDIVIDUAL_TESTS "FALSE")
set(CMAKE_CXX_STANDARD 11)
#Make highly optimised
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
# I've had problems with gcc < 5.3 and OpenMP does not work correctly.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 4.8
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "GCC version must be at least 4.8, but might not work with MATLAB.")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
message(WARNING "GCC version must be at least 5.3 to be fully compatible!")
endif()
else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with GCC.")
endif()
# Armadillo is the base package so it is required
find_package(Armadillo REQUIRED)
include_directories(${ARMADILLO_INCLUDE_DIRS})
# If we want threading then we must link with OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
# We use Intel MKL as a numeric library but fall back to LAPACK and BLAS if this fails.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(MKL)
#if (MKL_FOUND)
include_directories(${MKL_INCLUDE_DIR})
# set(LAPACK_INCLUDE_DIRS '')
#else()
# # This should find the BLAS libraries as well.
# find_package(LAPACK REQUIRED)
# include_directories(${LAPACK_INCLUDE_DIRS})
#endif()
# Make the shared library
add_library(
SpinW SHARED
src/spinw.cpp include/spinw.h
src/Hspinw.cpp include/Hspinw.h # The main files and C interface
include/sw_structs.h # Helpful structures
src/sw_additions.cpp include/sw_additions.h
src/spinw_external.cpp # Helpful functions
include/symmetryDat.h # Symmetry files
swsym/src/swsym.cpp swsym/include/swsym.h
swsym/src/position.cpp swsym/include/position.h
swsym/src/bond.cpp swsym/include/bond.h
swsym/src/symOperator.cpp swsym/include/symOperator.h
src/atom.cpp include/atom.h
src/templateFuncs.tpp include/templateFuncs.h # Template functions
swsym/src/oporder.cpp swsym/include/oporder.h)
# Link with the required libraries.
target_link_libraries(SpinW
${ARMADILLO_LIBRARIES}
${MKL_LIBRARIES} pthread dl)
# We can add tests here...
if(DO_TESTS)
add_subdirectory(tests)
endif()