forked from cp2k/dbcsr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (65 loc) · 2.84 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
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)
add_executable(${dbcsr_program_name} ${dbcsr_program_src})
target_link_libraries(${dbcsr_program_name} dbcsr)
if (OpenMP_FOUND)
target_link_libraries(${dbcsr_program_name} OpenMP::OpenMP_Fortran)
endif ()
# 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 ()
# override -Werror for certain translation units
if ((CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
AND (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10))
set_source_files_properties(dbcsr_tensor_example_1.F PROPERTIES COMPILE_FLAGS
-Wno-error)
endif ()
# 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)
add_executable(${dbcsr_program_name} ${dbcsr_program_src})
target_link_libraries(${dbcsr_program_name} dbcsr_c MPI::MPI_CXX)
set_target_properties(${dbcsr_program_name} PROPERTIES LINKER_LANGUAGE
Fortran)
if (OpenMP_FOUND)
target_compile_options(${dbcsr_program_name} PRIVATE ${OpenMP_CXX_FLAGS})
target_link_libraries(${dbcsr_program_name} OpenMP::OpenMP_Fortran)
endif ()
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)