2 # CMake project file for UNRES with MD for single chains
5 enable_language (Fortran)
7 #================================
8 # Set source file lists
9 #================================
95 set(UNRES_MDM_SRC3 energy_p_new_barrier.F energy_p_new-sep_barrier.F gradient_p.F )
109 energy_p_new_barrier.F
110 energy_p_new-sep_barrier.F
157 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
158 set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F")
159 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
162 #================================================
163 # Set comipiler flags for different sourcefiles
164 #================================================
165 if (Fortran_COMPILER_NAME STREQUAL "ifort")
166 set(FFLAGS0 "-ip -w" )
167 set(FFLAGS1 "-w -g -d2 -CA -CB" )
168 set(FFLAGS2 "-w -g -00 ")
169 set(FFLAGS3 "-w -ipo " )
170 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
171 set(FFLAGS0 "-std=legacy -I. " )
172 set(FFLAGS1 "-std=legacy -g -I. " )
173 set(FFLAGS2 "-std=legacy -I. ")
174 set(FFLAGS3 "-std=legacy -I. " )
175 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
178 # Add MPI compiler flags
180 set(FFLAGS0 "${FFLAGS0} -I${MPI_Fortran_INCLUDE_PATH}")
181 set(FFLAGS1 "${FFLAGS1} -I${MPI_Fortran_INCLUDE_PATH}")
182 set(FFLAGS2 "${FFLAGS2} -I${MPI_Fortran_INCLUDE_PATH}")
183 set(FFLAGS3 "${FFLAGS3} -I${MPI_Fortran_INCLUDE_PATH}")
184 endif(UNRES_WITH_MPI)
186 set_property(SOURCE ${UNRES_MDM_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
187 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
188 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
189 set_property(SOURCE ${UNRES_MDM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
191 #=========================================
192 # Settings for GAB force field
193 #=========================================
194 if(UNRES_MD_FF STREQUAL "GAB" )
195 # set preprocesor flags
196 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC -DSCCORPDB -DTIMING -DTIMING_ENE" )
198 #=========================================
199 # Settings for E0LL2Y force field
200 #=========================================
201 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
202 # set preprocesor flags
203 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DSCCORPDB" )
204 endif(UNRES_MD_FF STREQUAL "GAB")
207 #=========================================
208 # System specific flags
209 #=========================================
210 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
211 set(CPPFLAGS "${CPPFLAGS} -DLINUX")
212 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
215 #=========================================
216 # Compiler specific flags
217 #=========================================
219 if (Fortran_COMPILER_NAME STREQUAL "ifort")
220 # Add ifort preprocessor flags
221 set(CPPFLAGS "${CPPFLAGS} -DPGI")
222 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
223 # Add new gfortran flags
224 set(CPPFLAGS "${CPPFLAGS} -DG77")
225 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
226 # Add old gfortran flags
227 set(CPPFLAGS "${CPPFLAGS} -DG77")
228 else (Fortran_COMPILER_NAME STREQUAL "ifort")
229 # Default preprocessor flags
230 set(CPPFLAGS "${CPPFLAGS} -DPGI")
231 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
234 #=========================================
235 # Add MPI preprocessor flags
236 #=========================================
238 set(CPPFLAGS "${CPPFLAGS} -DMP -DMPI")
239 endif(UNRES_WITH_MPI)
242 #=========================================
243 # add 64-bit specific preprocessor flags
244 #=========================================
245 if (architektura STREQUAL "64")
246 set(CPPFLAGS "${CPPFLAGS} -DAMD64")
247 endif (architektura STREQUAL "64")
251 # Apply preprocesor flags to *.F files
252 set_property(SOURCE ${UNRES_MDM_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )
254 # Apply preprocesor flags to proc_proc.c
255 set_property(SOURCE proc_proc.c PROPERTY COMPILE_DEFINITIONS "SGI" )
258 #========================================
259 # Setting binary name
260 #========================================
263 set(UNRES_BIN "unresMD-M_${Fortran_COMPILER_NAME}_MPICH_${UNRES_MD_FF}.exe")
266 set(UNRES_BIN "unresMD-M_${Fortran_COMPILER_NAME}_single_${UNRES_MD_FF}.exe")
267 endif(UNRES_WITH_MPI)
269 #=========================================
270 # cinfo.f workaround for cmake
271 #=========================================
272 # get the current date
275 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
277 "C CMake generated file
279 include 'COMMON.IOUNITS'
280 write(iout,*)'++++ Compile info ++++'
281 write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
284 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
285 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
286 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
287 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
288 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
289 CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" )
290 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
293 " write(iout,*)'++++ End of compile info ++++'
299 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
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 )
306 #=========================================
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 set_property(TARGET UNRES_BIN-MD-M PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
312 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
314 #=========================================
316 #=========================================
317 # link MPI library (libmpich.a)
319 target_link_libraries( UNRES_BIN-MD-M ${MPI_Fortran_LIBRARIES} )
320 endif(UNRES_WITH_MPI)
322 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
323 target_link_libraries( UNRES_BIN-MD-M xdrf )
325 #=========================================
327 #=========================================
328 install(TARGETS UNRES_BIN-MD-M DESTINATION ${CMAKE_INSTALL_PREFIX}/unres/MD)
330 #=========================================
332 #=========================================
334 #-- Copy all the data files from the test directory into the source directory
335 #SET(UNRES_TEST_FILES
339 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
340 # SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
341 # MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
342 # ADD_CUSTOM_COMMAND (
343 # TARGET ${UNRES_BIN}
345 # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
347 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
349 #=========================================
350 # Generate data test files
351 #=========================================
353 #if(NOT UNRES_WITH_MPI)
355 # add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
357 #endif(NOT UNRES_WITH_MPI)