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