5d8442ff63834cd873419b20110bce317069089c
[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         refsys.f
37         rescode.f 
38         refsys.f
39         rmdd.f 
40         sc_move.F
41         sumsld.f 
42         timing.F
43         unres_min.F
44
45 )
46 # sources used with FFLAGS1
47 set(UNRES_MIN_SRC1 
48         cored.f
49 )
50
51 # sources used with FFLAGS2
52 set(UNRES_MIN_SRC2 
53         readpdb.F
54 )
55
56 # sources used with FFLAGS3
57 set(UNRES_MIN_SRC3 
58         energy_p_new_barrier.F
59         gradient_p.F
60 )
61
62 # sources used with preprocesor flags (should also be listed above with FFLAGSX)
63 set(UNRES_MIN_PP_SRC
64         bank.F 
65         cartder.F 
66         chainbuild.F 
67         checkder_p.F 
68         compare_s1.F
69         cored.f
70         csa.f 
71         dihed_cons.F
72         diff12.f 
73         econstr_local.F
74         energy_p_new.F
75         energy_p_new_barrier.F 
76         energy_split-sep.F 
77         entmcm.F 
78         gen_rand_conf.F
79         geomout.F 
80         gradient_p.F 
81         intcor.f
82         initialize_p.F 
83         intcartderiv.F 
84         lagrangian_lesyng.F 
85         matmult.f
86         mc.F 
87         mcm.F 
88         MD_A-MTS.F
89         minimize_p.F 
90         minim_jlee.F
91         minim_mcmf.F 
92         MP.F 
93         MREMD.F
94         newconf.f 
95         parmread.F 
96         permut.F
97         prng_32.F 
98         q_measure1.F 
99         q_measure3.F 
100         q_measure.F
101         ran.f
102         rattle.F 
103         readpdb.F 
104         readrtns_min.F
105         regularize.F
106         rmdd.f 
107         rmsd.F 
108         sc_move.F
109         shift.F 
110         stochfric.F
111         sumsld.f 
112         test.F 
113         thread.F 
114         timing.F
115         together.F
116         unres.F 
117
118
119
120 #================================================
121 # Set comipiler flags for different sourcefiles  
122 #================================================
123 if (Fortran_COMPILER_NAME STREQUAL "ifort")
124   find_package (Threads)
125   set(FFLAGS0 "-g -ip -w" ) 
126   set(FFLAGS1 "-w -g -d2 -CA -CB" ) 
127   set(FFLAGS2 "-w -g -00 ")
128   set(FFLAGS3 "-g -w -ipo " )
129 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
130   set(FFLAGS0 "-std=legacy -O " ) 
131   set(FFLAGS1 "-std=legacy -g -C" ) 
132   set(FFLAGS2 "-std=legacy -g -O0 ")
133   set(FFLAGS3 "-std=legacy -O3" )
134 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
135
136
137 set_property(SOURCE ${UNRES_MIN_SRC0} PROPERTY COMPILE_FLAGS ${FFLAGS0} )
138 set_property(SOURCE ${UNRES_MIN_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
139 set_property(SOURCE ${UNRES_MIN_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
140 set_property(SOURCE ${UNRES_MIM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
141
142 # set preprocesor flags   
143 set(CPPFLAGS "PROCOR -DLINUX -DISNAN -DSPLITELE -DLANG0" )
144
145 if (Fortran_COMPILER_NAME STREQUAL "ifort")
146   # Add ifort preprocessor flags
147   set(CPPFLAGS "${CPPFLAGS} -DPGI") 
148 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
149   # Add gfortran flags
150   set(CPPFLAGS "${CPPFLAGS} -DG77") 
151 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
152   # Add gfortran flags
153   set(CPPFLAGS "${CPPFLAGS} -DG77") 
154 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
155
156
157 # add 64-bit specific preprocessor flags
158 if (architektura STREQUAL "64")
159   set(CPPFLAGS "${CPPFLAGS} -DAMD64")
160 endif (architektura STREQUAL "64")
161
162 # Apply preprocesor flags to *.F files
163 set_property(SOURCE ${UNRES_MIN_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )  
164
165
166
167 #========================================
168 #  Setting binary name
169 #========================================
170 set(UNRES_BIN "unres_min_${Fortran_COMPILER_NAME}.exe")
171
172 #========================================
173 #  cinfo.f workaround for Cmake
174 #========================================
175 # get the current date  
176 TODAY(DATE)
177 # generate cinfo.f
178
179 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
180 FILE(WRITE ${CINFO}
181 "C CMake generated file
182        subroutine cinfo
183        include 'COMMON.IOUNITS'
184        write(iout,*)'++++ Compile info ++++'
185        write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
186 ")
187
188 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
189 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
190 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
191 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
192 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
193 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
194
195 FILE(APPEND ${CINFO} 
196 "       write(iout,*)'Version MINI energy and minimalization only'
197        write(iout,*)'++++ End of compile info ++++'  
198        return 
199        end ")
200
201 # add include path
202 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
203
204 #=========================================
205 # Set full unres MIN sources
206 #=========================================
207 set(UNRES_MIN_SRCS ${UNRES_MIN_SRC0} ${UNRES_MIN_SRC1} ${UNRES_MIN_SRC2} ${UNRES_MIN_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f )
208
209 #=========================================
210 # Build the binary
211 #=========================================
212 add_executable(UNRES_MIN_BIN ${UNRES_MIN_SRCS} )
213 set_target_properties(UNRES_MIN_BIN PROPERTIES OUTPUT_NAME ${UNRES_BIN})
214
215 if (Fortran_COMPILER_NAME STREQUAL "ifort")
216   target_link_libraries (UNRES_MIN_BIN ${CMAKE_THREAD_LIBS_INIT})
217 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
218 set_property(TARGET UNRES_MIN_BIN PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
219
220
221 #=========================================
222 # Install Path
223 #=========================================
224 install(TARGETS UNRES_MIN_BIN DESTINATION ${CMAKE_INSTALL_PREFIX})
225