-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
103 lines (78 loc) · 3.59 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
cmake_minimum_required(VERSION 3.13)
project(Z2-phi4 CXX)
# full path of g++ otherwise it does not work
#set(CMAKE_CXX_COMPILER /usr/bin/g++)
#set(CMAKE_CXX_FLAGS "-fopenmp -pedantic -g -O0 -pg -no-pie -lm -lgmp -lfftw3 ")
#-g # then compile , then open gdb, write the commands : file $namefile; run $options ; bt
# valgrind --leak-check=yes --track-origins=yes ./program #compile with -g to have line number
# no need to install Eigen with cmake and use find package
#SET( EIGEN3_INCLUDE_DIR /home/marco/library/eigen )
#IF( NOT EIGEN3_INCLUDE_DIR )
# MESSAGE( FATAL_ERROR "Please point the environment variable EIGEN3_INCLUDE_DIR to the include directory of your Eigen3 installation.")
#ENDIF()
#INCLUDE_DIRECTORIES ( "${EIGEN3_INCLUDE_DIR}" )
#using the globally installed version of Eigen: sudo apt-get libeigen3-dev
# Eigen
#IF(NOT DEFINED EIGEN3_INCLUDE_DIR)
# find_package(Eigen3 REQUIRED)
#ENDIF()
#INCLUDE_DIRECTORIES ( "${EIGEN3_INCLUDE_DIR}" )
IF(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${CXXFLAGS} -DDEBUG -g -lm ")
set(Kokkos_ENABLE_DEBUG ON)
set(Kokkos_ENABLE_DEBUG_BOUNDS_CHECK ON)
MESSAGE("DEBUG mode ON")
MESSAGE("Kokkos_ENABLE_DEBUG = ${Kokkos_ENABLE_DEBUG}")
MESSAGE("Kokkos_ENABLE_DEBUG_BOUNDS_CHECK = ${Kokkos_ENABLE_DEBUG_BOUNDS_CHECK}")
ENDIF()
IF(FFTW)
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${CXXFLAGS} -DFFTW ")
MESSAGE( "flags: " ${CMAKE_CXX_FLAGS})
elseif(CUFFT)
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${CXXFLAGS} -DcuFFT ")
MESSAGE( "flags: " ${CMAKE_CXX_FLAGS})
MESSAGE(FATAL_ERROR "You can't CUFFT" )
ENDIF()
MESSAGE("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
MESSAGE("CXXFLAGS ${CXXFLAGS}")
add_subdirectory("${PROJECT_SOURCE_DIR}/external/kokkos" "external/kokkos")
include_directories(${Kokkos_INCLUDE_DIRS_RET})
#target_link_libraries(myTarget kokkos)
#add_subdirectory(${PROJECT_SOURCE_DIR}/external/HighFive)
add_subdirectory(include include)
######################### git version ################
######################################################
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Get the latest commit hash
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
## this in not the end, you need to target_compile_definitions for the executable to build
## see the macro add_target_with_lib
######################################################
######################################################
macro(add_target_with_lib TARGETNAME)
# Make the executable
add_executable(${TARGETNAME} ${ARGN})
# target_link_libraries(${TARGETNAME} PUBLIC lattice)
target_link_libraries(${TARGETNAME} PUBLIC Kokkos::kokkos)
target_link_libraries(${TARGETNAME} PUBLIC utils)
target_link_libraries(${TARGETNAME} PUBLIC updates)
target_link_libraries(${TARGETNAME} PUBLIC geometry)
#target_link_libraries(${TARGETNAME} PUBLIC random)
target_link_libraries(${TARGETNAME} PUBLIC write_viewer)
target_link_libraries(${TARGETNAME} PUBLIC measurements)
target_link_libraries(${TARGETNAME} PUBLIC DFT)
# target_link_libraries(${TARGETNAME} PUBLIC HighFive)
# target_include_directories(${TARGETNAME} PUBLIC "${CMAKE_SOURCE_DIR}/include")
# target_include_directories(${TARGETNAME} PUBLIC "${CMAKE_BINARY_DIR}/include")
target_compile_definitions(${TARGETNAME} PRIVATE
"-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
endmacro()
add_subdirectory(main)