forked from cp2k/dbcsr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
67 lines (58 loc) · 2.31 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
set(DBCSR_PROGRAM_SRCS_FTN dbcsr_example_1.F dbcsr_example_2.F
dbcsr_example_3.F dbcsr_tensor_example_1.F)
set(DBCSR_PROGRAM_SRCS_CPP dbcsr_example_3.cpp dbcsr_tensor_example_2.cpp)
# Compile Fortran examples
foreach (dbcsr_program_src ${DBCSR_PROGRAM_SRCS_FTN})
get_filename_component(dbcsr_program_name ${dbcsr_program_src} NAME_WE)
if (USE_HIP)
hip_add_executable(${dbcsr_program_name} ${dbcsr_program_src})
else ()
add_executable(${dbcsr_program_name} ${dbcsr_program_src})
endif ()
target_link_libraries(${dbcsr_program_name} dbcsr)
# with the Intel compiler CMake 3.12 seems to forget that the source is
# actually Fortran and needs to be told explicitly:
set_target_properties(${dbcsr_program_name} PROPERTIES LINKER_LANGUAGE
Fortran)
endforeach ()
# Compile C++ examples
if (WITH_C_API)
foreach (dbcsr_program_src ${DBCSR_PROGRAM_SRCS_CPP})
get_filename_component(dbcsr_program_name ${dbcsr_program_src} NAME_WE)
set(dbcsr_program_name ${dbcsr_program_name}_cpp)
if (USE_HIP)
hip_add_executable(${dbcsr_program_name} ${dbcsr_program_src})
else ()
add_executable(${dbcsr_program_name} ${dbcsr_program_src})
endif ()
target_link_libraries(${dbcsr_program_name} dbcsr_c MPI::MPI_CXX)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Cray")
# for recent Cray compiler versions CMake doesn't know
target_compile_options(${dbcsr_program_name} PRIVATE "-hstd=c++14")
else ()
target_compile_features(${dbcsr_program_name} PRIVATE cxx_std_14)
endif ()
endforeach ()
endif ()
# =================================== DOCUMENTATION GENERATION Copy example
# source files into the build directory so that their documentation can be
# generated by FORD
set(DBCSR_PROGRAM_SRCS ${DBCSR_PROGRAM_SRCS_FTN} ${DBCSR_PROGRAM_SRCS_CPP})
# Make a list of the copy commands
set(example_copy_commands)
foreach (example ${DBCSR_PROGRAM_SRCS})
list(
APPEND
example_copy_commands
COMMAND
${CMAKE_COMMAND}
-E
copy
${CMAKE_SOURCE_DIR}/examples/${example}
${CMAKE_BINARY_DIR}/examples)
endforeach ()
add_custom_target(
doc_copy_examples
COMMENT "Copy examples for documentation generation"
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/examples ${example_copy_commands}
VERBATIM)