-
Notifications
You must be signed in to change notification settings - Fork 516
/
CMakeLists.txt
82 lines (72 loc) · 3.13 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
# md
set(MAKE_FF_AD FALSE)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)
find_package(xdrfile REQUIRED)
list(APPEND MD_INCLUDE_PATH "include")
list(APPEND MD_INCLUDE_PATH ${XDRFILE_INCLUDE_DIRS})
file(GLOB MD_SRC src/*.cc src/*.cpp)
set(MDNN_SOURCE_FILES mdnn.cc)
if(MAKE_FF_AD)
set(MDAD_SOURCE_FILES mdad.cc)
set(MDFF_SOURCE_FILES mdff.cc)
endif()
function(_add_md_variant variant_name prec_def)
set(libname "${LIB_DEEPMD_NATIVE}${variant_name}")
set(dp_mdnn_name "dp_mdnn${variant_name}")
set(dp_mdff_name "dp_mdff${variant_name}")
set(dp_mdad_name "dp_mdad${variant_name}")
add_library(${libname} SHARED ${MD_SRC})
target_link_libraries(${libname} PRIVATE ${LIB_DEEPMD})
target_include_directories(${libname} PUBLIC ${MD_INCLUDE_PATH})
set_target_properties(${libname} PROPERTIES COMPILE_DEFINITIONS ${prec_def}
INSTALL_RPATH "$ORIGIN")
add_executable(${dp_mdnn_name} ${MDNN_SOURCE_FILES})
if(MAKE_FF_AD)
add_executable(${dp_mdff_name} ${MDFF_SOURCE_FILES})
add_executable(${dp_mdad_name} ${MDAD_SOURCE_FILES})
endif()
# link: libdeepmd_native libdeepmd_cc libxdr
target_link_libraries(
${dp_mdnn_name} PRIVATE ${libname} ${LIB_DEEPMD_CC}${variant_name}
${XDRFILE_LIBRARIES})
target_include_directories(${dp_mdnn_name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/)
if(MAKE_FF_AD)
target_link_libraries(
${dp_mdad_name} PRIVATE ${libname} ${LIB_DEEPMD_CC}${variant_name}
${XDRFILE_LIBRARIES})
target_include_directories(${dp_mdad_name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/)
target_link_libraries(
${dp_mdff_name} PRIVATE ${libname} ${LIB_DEEPMD_CC}${variant_name}
${XDRFILE_LIBRARIES})
target_include_directories(${dp_mdff_name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/)
endif()
set_target_properties(
${dp_mdnn_name}
PROPERTIES COMPILE_DEFINITIONS ${prec_def}
LINK_FLAGS "-Wl,-rpath,'$ORIGIN'/../lib -Wl,-z,defs"
INSTALL_RPATH "$ORIGIN/../lib:${TensorFlow_LIBRARY_PATH}")
if(MAKE_FF_AD)
set_target_properties(
${dp_mdad_name}
PROPERTIES COMPILE_DEFINITIONS ${prec_def}
LINK_FLAGS "-Wl,-rpath,'$ORIGIN'/../lib -Wl,-z,defs"
INSTALL_RPATH "$ORIGIN/../lib:${TensorFlow_LIBRARY_PATH}")
set_target_properties(
${dp_mdff_name}
PROPERTIES COMPILE_DEFINITIONS ${prec_def}
LINK_FLAGS "-Wl,-rpath,'$ORIGIN'/../lib -Wl,-z,defs"
INSTALL_RPATH "$ORIGIN/../lib:${TensorFlow_LIBRARY_PATH}")
endif()
install(TARGETS ${LIB_DEEPMD_NATIVE} DESTINATION lib/)
install(TARGETS ${dp_mdnn_name} DESTINATION bin/)
if(MAKE_FF_AD)
install(TARGETS ${dp_mdad_name} DESTINATION bin/)
install(TARGETS ${dp_mdff_name} DESTINATION bin/)
endif()
endfunction()
_add_md_variant("${HIGH_PREC_VARIANT}" "${HIGH_PREC_DEF}")
# TODO: there is hard-code `DOUBLE` in the code
# _add_md_variant("${LOW_PREC_VARIANT}" "${LOW_PREC_DEF}")