cinfo.f generation and macro for unres MD
[unres.git] / source / unres / src_MIN / CMakeLists.txt
1 #
2 # CMake project file for UNRES with Minimazation 
3
4
5 enable_language (Fortran)
6
7 #================================
8 # Set source file lists
9 #================================
10 set(UNRES_MIN_SRC0 
11         arcos.f
12         cartder.F 
13         cartprint.f 
14         chainbuild.F 
15         checkder_p.F 
16         convert.f 
17         econstr_local.F
18         geomout_min.F
19         initialize_p.F 
20         intcartderiv.F
21         intcor.f 
22         intlocal.f 
23         int_to_cart.f 
24         matmult.f 
25         minimize_p.F
26         misc.f 
27         MP.F 
28         parmread.F 
29         pinorm.f 
30         printmat.f 
31         randgens.f 
32         readrtns_min.F
33         rescode.f 
34         rmdd.f 
35         sumsld.f 
36         timing.F
37         unres_min.F
38
39 )
40
41 set(UNRES_MIN_SRC1 
42         cored.f
43 )
44
45 set(UNRES_MIN_SRC2 
46         readpdb.F
47 )
48
49 set(UNRES_MIN_SRC3 
50         energy_p_new_barrier.F
51         gradient_p.F
52 )
53
54 set(UNRES_MIN_PP_SRC
55         bank.F 
56         cartder.F 
57         chainbuild.F 
58         checkder_p.F 
59         compare_s1.F
60         cored.f
61         csa.f 
62         dihed_cons.F
63         diff12.f 
64         econstr_local.F
65         energy_p_new.F
66         energy_p_new_barrier.F 
67         energy_split-sep.F 
68         entmcm.F 
69         gen_rand_conf.F
70         geomout.F 
71         gradient_p.F 
72         intcor.f
73         initialize_p.F 
74         intcartderiv.F 
75         lagrangian_lesyng.F 
76         matmult.f
77         mc.F 
78         mcm.F 
79         MD_A-MTS.F
80         minimize_p.F 
81         minim_jlee.F
82         minim_mcmf.F 
83         MP.F 
84         MREMD.F
85         newconf.f 
86         parmread.F 
87         permut.F
88         prng_32.F 
89         q_measure1.F 
90         q_measure3.F 
91         q_measure.F
92         ran.f
93         rattle.F 
94         readpdb.F 
95         readrtns_min.F
96         regularize.F
97         rmdd.f 
98         rmsd.F 
99         sc_move.F
100         shift.F 
101         stochfric.F
102         sumsld.f 
103         test.F 
104         thread.F 
105         timing.F
106         together.F
107         unres.F 
108
109
110
111 #================================================
112 # Set comipiler flags for different sourcefiles  
113 #================================================
114 if (Fortran_COMPILER_NAME STREQUAL "ifort")
115   find_package (Threads)
116   set(FFLAGS0 "-g -ip -w" ) 
117   set(FFLAGS1 "-w -g -d2 -CA -CB" ) 
118   set(FFLAGS2 "-w -g -00 ")
119   set(FFLAGS3 "-g -w -ipo " )
120 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
121   set(FFLAGS0 "-O" ) 
122   set(FFLAGS1 "-g -C" ) 
123   set(FFLAGS2 "-g -O0 ")
124   set(FFLAGS3 "-O3" )
125 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
126
127
128 set_property(SOURCE ${UNRES_MIN_SRC0} PROPERTY COMPILE_FLAGS ${FFLAGS0} )
129 set_property(SOURCE ${UNRES_MIN_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
130 set_property(SOURCE ${UNRES_MIN_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
131 set_property(SOURCE ${UNRES_MIM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
132
133 # set preprocesor flags   
134 set(CPPFLAGS "PROCOR -DLINUX -DISNAN -DSPLITELE -DLANG0" )
135
136 if (Fortran_COMPILER_NAME STREQUAL "ifort")
137   # Add ifort preprocessor flags
138   set(CPPFLAGS "${CPPFLAGS} -DPGI") 
139 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
140   # Add gfortran flags
141   set(CPPFLAGS "${CPPFLAGS} -DG77") 
142 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
143   # Add gfortran flags
144   set(CPPFLAGS "${CPPFLAGS} -DG77") 
145 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
146
147
148 # add 64-bit specific preprocessor flags
149 if (architektura STREQUAL "64")
150   set(CPPFLAGS "${CPPFLAGS} -DAMD64")
151 endif (architektura STREQUAL "64")
152
153 # Apply preprocesor flags to *.F files
154 set_property(SOURCE ${UNRES_MIN_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )  
155
156
157
158 #========================================
159 #  Setting binary name
160 #========================================
161 set(UNRES_BIN "unres_min_${Fortran_COMPILER_NAME}.exe")
162
163 #========================================
164 #  cinfo.f workaround for Cmake
165 #========================================
166 # get the current date  
167 TODAY(DATE)
168 # generate cinfo.f
169 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f
170 "C CMake generated file
171        subroutine cinfo
172        include 'COMMON.IOUNITS'
173        write(iout,*)'++++ Compile info ++++'
174        write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
175        write(iout,*)'Compiled ${DATE}'
176        write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}'
177        write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}'
178        write(iout,*)'OS release: ${CMAKE_SYSTEM}'
179        write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}'
180        write(iout,*)'Version MINI energy and minimization only'
181        write(iout,*)'++++ End of compile info ++++'  
182        return  
183        end     
184 ")
185 # add include path
186 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
187
188 #=========================================
189 # Set full unres MIN sources
190 #=========================================
191 set(UNRES_MIN_SRCS ${UNRES_MIN_SRC0} ${UNRES_MIN_SRC1} ${UNRES_MIN_SRC2} ${UNRES_MIN_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f )
192
193 #=========================================
194 # Build the binary
195 #=========================================
196 add_executable(UNRES_BIN-MIN ${UNRES_MIN_SRCS} )
197 set_target_properties(UNRES_BIN-MIN PROPERTIES OUTPUT_NAME ${UNRES_BIN})
198
199 if (Fortran_COMPILER_NAME STREQUAL "ifort")
200   target_link_libraries (UNRES_BIN-MIN ${CMAKE_THREAD_LIBS_INIT})
201 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
202
203 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
204
205 #=========================================
206 # TESTS 
207 #=========================================
208
209 #-- Copy all the data files from the test directory into the source directory
210 #SET(UNRES_TEST_FILES
211 #       ala10.inp
212 #    )
213
214 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
215 #      SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
216 #      MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
217 #      ADD_CUSTOM_COMMAND (
218 #          TARGET     ${UNRES_BIN}
219 #          POST_BUILD
220 #          COMMAND    ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
221 #      )
222 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
223
224 #=========================================
225 # Generate data test files
226 #=========================================
227
228 #if(NOT UNRES_WITH_MPI)
229
230 #  add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
231
232 #endif(NOT UNRES_WITH_MPI)
233