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