-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
86 lines (72 loc) · 2.08 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
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_USER_MAKE_RULES_OVERRIDE "cmake/platform.cmake")
project(VMD-h5mdplugin C)
find_package(HDF5 REQUIRED COMPONENTS "C" "HL")
find_program(VMD_EXECUTABLE NAMES vmd PATH_SUFFIXES bin DOC "VMD command")
if(VMD_EXECUTABLE)
file(STRINGS "${VMD_EXECUTABLE}" VMDDIR REGEX "^[^#].*defaultvmddir=.*$")
string(REGEX REPLACE "(^.*=\"?|\"$)" "" VMDDIR "${VMDDIR}")
set(VMD_PLUGIN_INCLUDE_DIR "${VMDDIR}/plugins/include" CACHE STRING "Path to VMD plugin headers")
set(VMD_PLUGIN_PATH "${VMDDIR}/plugins/LINUXAMD64" CACHE STRING "Path to VMD plugin headers")
message(STATUS "VMD executable: ${VMD_EXECUTABLE}")
message(STATUS "VMD plugin path: ${VMD_PLUGIN_PATH}")
message(STATUS "VMD plugin include dir: ${VMD_PLUGIN_INCLUDE_DIR}")
else()
message(FATAL_ERROR "VMD not found, please specify with -DVMD_EXECUTABLE")
endif()
include_directories("${HDF5_INCLUDE_DIR}")
include_directories("${VMD_PLUGIN_INCLUDE_DIR}")
#
# add H5MD library
#
add_library(h5md # SHARED
libh5md.c
)
#
# add H5MD plugin
#
add_library(h5mdplugin SHARED
h5mdplugin.c
)
target_link_libraries(h5md
${HDF5_C_LIBRARIES}
${HDF5_HL_LIBRARIES}
# math library
m
)
SET (CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN'" )
# unset "lib" prefix
set_target_properties(h5mdplugin PROPERTIES PREFIX "")
target_link_libraries(h5mdplugin
h5md
${HDF5_C_LIBRARIES}
${HDF5_HL_LIBRARIES}
)
install(TARGETS h5md h5mdplugin
DESTINATION "${VMD_PLUGIN_PATH}/molfile"
)
#
# add test
#
enable_testing()
add_executable(h5mdtest
h5mdtest.c
h5mdplugin.c
)
target_link_libraries(h5mdtest
h5md
${HDF5_LIBRARIES}
# math library
m
)
add_test(h5md/particles/full_vmd_structure
h5mdtest h5md "${CMAKE_SOURCE_DIR}/samples/full_vmd_structure.h5"
)
add_test(h5md/particles/half_vmd_structure
h5mdtest h5md "${CMAKE_SOURCE_DIR}/samples/half_vmd_structure.h5"
)
add_test(h5md/particles/no_vmd_structure
h5mdtest h5md "${CMAKE_SOURCE_DIR}/samples/no_vmd_structure.h5"
)