cluster unres
[unres.git] / source / cluster / unres / src / CMakeLists.txt
1 #
2 # CMake project file for cluster analysis from UNRESMD  
3
4
5 enable_language (Fortran)
6
7 #================================
8 # Set source file lists
9 #================================
10 set(UNRES_CLUSTER_UNRES_SRC0 
11         arcos.f
12         cartprint.f
13         chainbuild.f
14         contact.f
15         convert.f
16         fitsq.f
17         geomout.F
18         hc.f
19         initialize.f
20         intcor.f
21         main_clust.F
22         matmult.f
23         misc.f
24         noyes.f
25         pinorm.f
26         readpdb.f
27         readrtns.F
28         rescode.f
29         srtclust.f
30         timing.F
31         track.F
32         wrtclust.f
33         cxread.F
34 )
35
36 set(UNRES_CLUSTER_PP_SRC
37         geomout.F
38         readrtns.F
39         timing.F
40         track.F
41
42
43
44 #================================================
45 # Set comipiler flags for different sourcefiles  
46 #================================================
47 if (Fortran_COMPILER_NAME STREQUAL "ifort")
48   set(FFLAGS0 "-ip -w -I." ) 
49 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
50   set(FFLAGS0 "-std=legacy -I. " ) 
51 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
52
53
54 set_property(SOURCE ${UNRES_CLUSTER_SRC0} PROPERTY COMPILE_FLAGS ${FFLAGS0} )
55
56
57 #=========================================
58 # System specific flags
59 #=========================================
60 set(CPPFLAGS "NEWUNRES")
61 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
62   set(CPPFLAGS "${CPPFLAGS} -DLINUX") 
63 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
64
65
66
67 #=========================================
68 # Apply preprocesor flags to *.F files
69 #=========================================
70 set_property(SOURCE ${UNRES_CLUSTER_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )  
71
72
73 #========================================
74 #  Setting binary name
75 #========================================
76 set(UNRES_CLUSTER_BIN "cluster_unres_${Fortran_COMPILER_NAME}.exe")
77
78 #=========================================
79 # Set full unres CLUSTER sources
80 #=========================================
81 set(UNRES_CLUSTER_SRCS ${UNRES_CLUSTER_UNRES_SRC0} )
82
83 #=========================================
84 # Build the binary
85 #=========================================
86 add_executable(UNRES_CLUSTER_BIN ${UNRES_CLUSTER_SRCS} )
87 set_target_properties(UNRES_CLUSTER_BIN PROPERTIES OUTPUT_NAME ${UNRES_CLUSTER_BIN})
88 set_property(TARGET UNRES_CLUSTER_BIN PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
89
90 #=========================================
91 # Link libraries
92 #=========================================
93 # link libxdrf.a 
94 target_link_libraries( UNRES_CLUSTER_BIN xdrf )
95
96
97 #=========================================
98 # Install Path
99 #=========================================
100 install(TARGETS UNRES_CLUSTER_BIN DESTINATION ${CMAKE_INSTALL_PREFIX}/cluster)
101
102
103 #=========================================
104 # TESTS 
105 #=========================================
106
107 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/scripts/cluster_int.sh
108 "#!/bin/sh
109 export INPUT=$1
110 export INTIN=1l2y_csa_GB000
111 export OUTPUT=1l2y_csa_GB000
112 #-----------------------------------------------------------------------------
113 CLUSTER_BIN=${CMAKE_BINARY_DIR}/bin/${UNRES_CLUSTER_BIN}
114 #-----------------------------------------------------------------------------
115 echo CTEST_FULL_OUTPUT
116 $CLUSTER_BIN 
117 ./cluster_check.sh $1 
118 ")
119
120 #
121 # File permissions workaround
122 #
123 FILE(   COPY ${CMAKE_CURRENT_BINARY_DIR}/scripts/cluster_int.sh 
124         DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
125         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
126 )
127
128 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/cluster_check.sh
129         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} 
130         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
131 )
132
133 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/1l2y_clust_int.inp
134         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
135
136 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/1l2y_csa_GB000.int
137         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
138
139 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/1L2Y.pdb
140         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
141
142
143 add_test(NAME CLUSTER_INT COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/cluster_int.sh 1l2y_clust_int )