adding in cmake UNRES_MD_FF = 4P for src_MD and src_MD-M
[unres.git] / source / unres / src_MD-M / CMakeLists.txt
1 #
2 # CMake project file for UNRES with MD for single chains
3
4
5 enable_language (Fortran)
6
7 #================================
8 # Set source file lists
9 #================================
10 set(UNRES_MDM_SRC0 
11         add.f 
12         arcos.f
13         banach.f
14         bank.F 
15         blas.f 
16         bond_move.f 
17         cartder.F 
18         cartprint.f 
19         chainbuild.F 
20         check_bond.f 
21         checkder_p.F 
22         check_sc_distr.f
23         compare_s1.F 
24         contact.f 
25         convert.f 
26         cored.f
27         csa.f 
28         dihed_cons.F
29         diff12.f
30         distfit.f 
31         djacob.f
32         econstr_local.F
33         eigen.f 
34         elecont.f 
35         energy_split-sep.F 
36         entmcm.F
37         fitsq.f 
38         gauss.f 
39         gen_rand_conf.F
40         geomout.F 
41         gnmr1.f
42         indexx.f 
43         initialize_p.F 
44         intcartderiv.F
45         intcor.f 
46         intlocal.f 
47         int_to_cart.f 
48         kinetic_lesyng.f 
49         lagrangian_lesyng.F
50         local_move.f 
51         map.f 
52         matmult.f 
53         mc.F 
54         mcm.F 
55         MD_A-MTS.F 
56         minimize_p.F
57         minim_jlee.F 
58         minim_mcmf.F 
59         misc.f 
60         moments.f
61         MP.F 
62         MREMD.F 
63         muca_md.f 
64         newconf.f
65         parmread.F 
66         permut.F
67         pinorm.f 
68         printmat.f 
69         prng_32.F
70         q_measure.F 
71         ran.f
72         randgens.f 
73         rattle.F 
74         readpdb.F
75         readrtns_CSA.F 
76         refsys.f 
77         regularize.F
78         rescode.f 
79         rmdd.f 
80         rmsd.F 
81         sc_move.F 
82         shift.F
83         sort.f 
84         stochfric.F 
85         sumsld.f 
86         surfatom.f 
87         test.F 
88         thread.F 
89         timing.F
90         together.F
91         unres.F
92         ssMD.F
93 )
94
95 set(UNRES_MDM_SRC3 energy_p_new_barrier.F energy_p_new-sep_barrier.F gradient_p.F )
96
97 set(UNRES_MDM_PP_SRC
98         bank.F 
99         cartder.F 
100         chainbuild.F 
101         checkder_p.F 
102         compare_s1.F
103         cored.f
104         csa.f 
105         dihed_cons.F
106         diff12.f 
107         econstr_local.F 
108         energy_p_new.F
109         energy_p_new_barrier.F 
110         energy_p_new-sep_barrier.F 
111         energy_split-sep.F 
112         entmcm.F 
113         gen_rand_conf.F
114         geomout.F 
115         gradient_p.F 
116         intcor.f
117         initialize_p.F 
118         intcartderiv.F 
119         lagrangian_lesyng.F 
120         matmult.f
121         mc.F 
122         mcm.F 
123         MD_A-MTS.F
124         minimize_p.F 
125         minim_jlee.F
126         minim_mcmf.F 
127         MP.F 
128         MREMD.F
129         newconf.f 
130         parmread.F 
131         permut.F
132         prng_32.F
133         q_measure1.F 
134         q_measure3.F 
135         q_measure.F
136         ran.f
137         rattle.F 
138         readpdb.F 
139         readrtns_CSA.F 
140         regularize.F
141         rmdd.f 
142         rmsd.F 
143         sc_move.F
144         shift.F 
145         stochfric.F
146         sumsld.f 
147         test.F 
148         thread.F 
149         timing.F
150         together.F
151         unres.F
152         proc_proc.c
153
154
155
156 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
157   set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F") 
158 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
159
160
161 #================================================
162 # Set comipiler flags for different sourcefiles  
163 #================================================
164 if (Fortran_COMPILER_NAME STREQUAL "ifort")
165   set(FFLAGS0 "-ip -w" ) 
166   set(FFLAGS1 "-w -g -d2 -CA -CB" ) 
167   set(FFLAGS2 "-w -g -00 ")
168   set(FFLAGS3 "-w -ipo " )
169 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
170   set(FFLAGS0 "-std=legacy -I. " ) 
171   set(FFLAGS1 "-std=legacy -g -I. " ) 
172   set(FFLAGS2 "-std=legacy -I. ")
173   set(FFLAGS3 "-std=legacy -I. " )
174 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
175
176
177 # Add MPI compiler flags
178 if(UNRES_WITH_MPI)
179   set(FFLAGS0 "${FFLAGS0} -I${MPI_Fortran_INCLUDE_PATH}")
180   set(FFLAGS1 "${FFLAGS1} -I${MPI_Fortran_INCLUDE_PATH}")
181   set(FFLAGS2 "${FFLAGS2} -I${MPI_Fortran_INCLUDE_PATH}")
182   set(FFLAGS3 "${FFLAGS3} -I${MPI_Fortran_INCLUDE_PATH}")
183 endif(UNRES_WITH_MPI)
184
185 set_property(SOURCE ${UNRES_MDM_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
186 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
187 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
188 set_property(SOURCE ${UNRES_MDM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
189
190 #=========================================
191 # Settings for GAB force field 
192 #=========================================
193 if(UNRES_MD_FF STREQUAL "GAB" )
194   # set preprocesor flags   
195   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
196
197 #=========================================
198 #  Settings for E0LL2Y force field
199 #=========================================
200 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
201   # set preprocesor flags   
202   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0" )
203 elseif(UNRES_MD_FF STREQUAL "4P")
204   set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC -DSCCORPDB" )
205 endif(UNRES_MD_FF STREQUAL "GAB")
206
207
208 #=========================================
209 # System specific flags
210 #=========================================
211 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
212   set(CPPFLAGS "${CPPFLAGS} -DLINUX") 
213 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
214
215
216 #=========================================
217 # Compiler specific flags
218 #=========================================
219
220 if (Fortran_COMPILER_NAME STREQUAL "ifort")
221   # Add ifort preprocessor flags
222   set(CPPFLAGS "${CPPFLAGS} -DPGI") 
223 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
224   # Add new gfortran flags
225   set(CPPFLAGS "${CPPFLAGS} -DG77") 
226 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
227   # Add old gfortran flags
228   set(CPPFLAGS "${CPPFLAGS} -DG77") 
229 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
230
231
232 #=========================================
233 # Add MPI preprocessor flags
234 #=========================================
235 if (UNRES_WITH_MPI)
236   set(CPPFLAGS "${CPPFLAGS} -DMP -DMPI") 
237 endif(UNRES_WITH_MPI)
238
239
240 #=========================================
241 # add 64-bit specific preprocessor flags
242 #=========================================
243 if (architektura STREQUAL "64")
244   set(CPPFLAGS "${CPPFLAGS} -DAMD64")
245 endif (architektura STREQUAL "64")
246
247
248
249 # Apply preprocesor flags to *.F files
250 set_property(SOURCE ${UNRES_MDM_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )  
251
252 # Apply preprocesor flags to proc_proc.c
253 set_property(SOURCE proc_proc.c PROPERTY COMPILE_DEFINITIONS "SGI" )  
254
255
256 #========================================
257 #  Setting binary name
258 #========================================
259 if(UNRES_WITH_MPI) 
260   # binary with mpi
261   set(UNRES_BIN "unresMD-mult_${Fortran_COMPILER_NAME}_MPI_${UNRES_MD_FF}.exe")
262 else(UNRES_WITH_MPI)
263   # binary without mpi
264   set(UNRES_BIN "unresMD-mult_${Fortran_COMPILER_NAME}_single_${UNRES_MD_FF}.exe")
265 endif(UNRES_WITH_MPI)  
266
267 #=========================================
268 # cinfo.f workaround for cmake
269 #=========================================
270 # get the current date  
271 TODAY(DATE)
272 # generate cinfo.f
273 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
274 FILE(WRITE ${CINFO}
275 "C CMake generated file
276        subroutine cinfo
277        include 'COMMON.IOUNITS'
278        write(iout,*)'++++ Compile info ++++'
279        write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
280 ")
281
282 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
283 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
284 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
285 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
286 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
287 CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" )
288 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
289
290 FILE(APPEND ${CINFO} 
291 "       write(iout,*)'++++ End of compile info ++++'  
292        return 
293        end ")
294
295
296 # add include path
297 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
298
299 #=========================================
300 # Set full unres MD-M sources
301 #=========================================
302 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c )
303
304 #=========================================
305 # Build the binary
306 #=========================================
307 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
308 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
309 set_property(TARGET UNRES_BIN-MD-M PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
310 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
311
312 #=========================================
313 # Link libraries
314 #=========================================
315 # link MPI library (libmpich.a)  
316 if(UNRES_WITH_MPI)
317   target_link_libraries( UNRES_BIN-MD-M ${MPI_Fortran_LIBRARIES} )
318 endif(UNRES_WITH_MPI)
319 # link libxdrf.a 
320 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
321 target_link_libraries( UNRES_BIN-MD-M xdrf )
322
323 #=========================================
324 # Install Path
325 #=========================================
326 install(TARGETS UNRES_BIN-MD-M DESTINATION ${CMAKE_INSTALL_PREFIX}/unres/MD)
327
328 #=========================================
329 # TESTS 
330 #=========================================
331
332 #-- Copy all the data files from the test directory into the source directory
333 #SET(UNRES_TEST_FILES
334 #       ala10.inp
335 #    )
336
337 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
338 #      SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
339 #      MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
340 #      ADD_CUSTOM_COMMAND (
341 #          TARGET     ${UNRES_BIN}
342 #          POST_BUILD
343 #          COMMAND    ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
344 #      )
345 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
346
347 #=========================================
348 # Generate data test files
349 #=========================================
350
351 #if(NOT UNRES_WITH_MPI)
352
353 #  add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
354
355 #endif(NOT UNRES_WITH_MPI)
356