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