Poprawka w Cmakelist
[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 # 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         eigen.f 
39         elecont.f 
40         energy_split-sep.F 
41         entmcm.F
42         fitsq.f 
43         gauss.f 
44         gen_rand_conf.F
45         geomout.F 
46         gnmr1.f
47         indexx.f 
48         initialize_p.F 
49         intcartderiv.F
50         intcor.f 
51         intlocal.f 
52         int_to_cart.f 
53         kinetic_lesyng.f 
54         lagrangian_lesyng.F
55         local_move.f 
56         map.f 
57         matmult.f 
58         mc.F 
59         mcm.F 
60         MD_A-MTS.F 
61         minimize_p.F
62         minim_jlee.F 
63         minim_mcmf.F 
64         misc.f 
65         moments.f
66         MP.F 
67         MREMD.F 
68         muca_md.f 
69         newconf.f
70         parmread.F 
71         permut.F
72         pinorm.f 
73         printmat.f 
74         q_measure.F 
75         ran.f
76         randgens.f 
77         rattle.F 
78         readpdb.F
79         readrtns_CSA.F 
80         refsys.f 
81         regularize.F
82         rescode.f 
83         rmdd.f 
84         rmsd.F 
85         sc_move.F 
86         shift.F
87         sort.f 
88         stochfric.F 
89         sumsld.f 
90         surfatom.f 
91         test.F 
92         thread.F 
93         timing.F
94         together.F
95         unres.F
96 )
97
98 if (Fortran_COMPILER_NAME STREQUAL "ifort")
99   set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f ) 
100 elseif(Fortran_COMPILER_NAME STREQUAL "mpif90")
101   set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f )
102 else()
103   set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng_32.F )
104 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
105
106
107 set(UNRES_MDM_SRC3 energy_p_new_barrier.F energy_p_new-sep_barrier.F gradient_p.F )
108
109 set(UNRES_MDM_PP_SRC
110         bank.F 
111         cartder.F 
112         chainbuild.F 
113         checkder_p.F 
114         compare_s1.F
115         cored.f
116         csa.f 
117         dihed_cons.F
118         diff12.f 
119         econstr_local.F 
120         energy_p_new.F
121         energy_p_new_barrier.F 
122         energy_p_new-sep_barrier.F 
123         energy_split-sep.F 
124         entmcm.F 
125         gen_rand_conf.F
126         geomout.F 
127         gradient_p.F 
128         intcor.f
129         initialize_p.F 
130         intcartderiv.F 
131         lagrangian_lesyng.F 
132         matmult.f
133         mc.F 
134         mcm.F 
135         MD_A-MTS.F
136         minimize_p.F 
137         minim_jlee.F
138         minim_mcmf.F 
139         MP.F 
140         MREMD.F
141         newconf.f 
142         parmread.F 
143         permut.F
144         q_measure1.F 
145         q_measure3.F 
146         q_measure.F
147         ran.f
148         rattle.F 
149         readpdb.F 
150         readrtns_CSA.F 
151         regularize.F
152         rmdd.f 
153         rmsd.F 
154         sc_move.F
155         shift.F 
156         stochfric.F
157         sumsld.f 
158         test.F 
159         thread.F 
160         timing.F
161         together.F
162         unres.F
163         proc_proc.c
164
165
166
167 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
168   set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F") 
169 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
170
171
172 #================================================
173 # Set comipiler flags for different sourcefiles  
174 #================================================
175 if (Fortran_COMPILER_NAME STREQUAL "ifort")
176   set(FFLAGS0 "-ip -w" ) 
177   set(FFLAGS1 "-w -g -d2 -CA -CB" ) 
178   set(FFLAGS2 "-w -g -00 ")
179   #set(FFLAGS3 "-c -w -O3 -ipo -ipo_obj -opt_report" )
180   set(FFLAGS3 "-w -ipo " )
181 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
182   set(FFLAGS0 "-I. " ) 
183   set(FFLAGS1 "-g -I. " ) 
184   set(FFLAGS2 "-I. ")
185   #set(FFLAGS3 "-c -w -O3 -ipo -ipo_obj -opt_report" )
186   set(FFLAGS3 "-I. " )
187 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
188
189
190 # Add MPI compiler flags
191 if(UNRES_WITH_MPI)
192   set(FFLAGS0 "${FFLAGS0} -I${MPIF_INCLUDE_DIRECTORIES}")
193   set(FFLAGS1 "${FFLAGS1} -I${MPIF_INCLUDE_DIRECTORIES}")
194   set(FFLAGS2 "${FFLAGS2} -I${MPIF_INCLUDE_DIRECTORIES}")
195   set(FFLAGS3 "${FFLAGS3} -I${MPIF_INCLUDE_DIRECTORIES}")
196 endif(UNRES_WITH_MPI)
197
198 set_property(SOURCE ${UNRES_MDM_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
199 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
200 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
201 set_property(SOURCE ${UNRES_MDM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
202
203 #=========================================
204 # Settings for GAB force field 
205 #=========================================
206 if(UNRES_MD_FF STREQUAL "GAB" )
207   # set preprocesor flags   
208   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
209
210 #=========================================
211 #  Settings for E0LL2Y force field
212 #=========================================
213 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
214   # set preprocesor flags   
215   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0" )
216 endif(UNRES_MD_FF STREQUAL "GAB")
217
218
219 #=========================================
220 # System specific flags
221 #=========================================
222 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
223   set(CPPFLAGS "${CPPFLAGS} -DLINUX") 
224 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
225
226
227 #=========================================
228 # Compiler specific flags
229 #=========================================
230
231 if (Fortran_COMPILER_NAME STREQUAL "ifort")
232   # Add ifort preprocessor flags
233   set(CPPFLAGS "${CPPFLAGS} -DPGI") 
234 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
235   # Add new gfortran flags
236   set(CPPFLAGS "${CPPFLAGS} -DG77") 
237 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
238   # Add old gfortran flags
239   set(CPPFLAGS "${CPPFLAGS} -DG77") 
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 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f
283 "C CMake generated file
284        subroutine cinfo
285        include 'COMMON.IOUNITS'
286        write(iout,*)'++++ Compile info ++++'
287        write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
288        write(iout,*)'Compiled ${DATE}'
289        write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}'
290        write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}'
291        write(iout,*)'OS release: ${CMAKE_SYSTEM}'
292        write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}'
293        write(iout,*)'MD Force field: ${UNRES_MD_FF}'
294        write(iout,*)'++++ End of compile info ++++'  
295        return  
296        end     
297 ")
298 # add include path
299 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
300
301 #=========================================
302 # Set full unres MD-M sources
303 #=========================================
304 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c )
305
306 #=========================================
307 # Build the binary
308 #=========================================
309 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
310 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
311
312 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
313 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
314
315 #=========================================
316 # Link libraries
317 #=========================================
318 # link MPI library (libmpich.a)  
319 if(UNRES_WITH_MPI)
320   target_link_libraries( UNRES_BIN-MD-M ${MPIF_LIBRARIES} )
321 endif(UNRES_WITH_MPI)
322 # link libxdrf.a 
323 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
324 target_link_libraries( UNRES_BIN-MD-M xdrf )
325
326 #=========================================
327 # TESTS 
328 #=========================================
329
330 #-- Copy all the data files from the test directory into the source directory
331 #SET(UNRES_TEST_FILES
332 #       ala10.inp
333 #    )
334
335 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
336 #      SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
337 #      MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
338 #      ADD_CUSTOM_COMMAND (
339 #          TARGET     ${UNRES_BIN}
340 #          POST_BUILD
341 #          COMMAND    ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
342 #      )
343 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
344
345 #=========================================
346 # Generate data test files
347 #=========================================
348
349 #if(NOT UNRES_WITH_MPI)
350
351 #  add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
352
353 #endif(NOT UNRES_WITH_MPI)
354