2 # CMake project file for UNRES with MD for single chains
5 enable_language (Fortran)
7 #================================
8 # build the xdrf library
9 #================================
10 #add_subdirectory(xdrf)
12 #================================
13 # Set source file lists
14 #================================
98 if (Fortran_COMPILER_NAME STREQUAL "ifort")
99 set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f )
100 elseif(Fortran_COMPILER_NAME STREQUAL "mpif90")
101 set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f )
103 set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng_32.F )
104 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
107 set(UNRES_MDM_SRC3 energy_p_new_barrier.F energy_p_new-sep_barrier.F gradient_p.F )
121 energy_p_new_barrier.F
122 energy_p_new-sep_barrier.F
167 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
168 set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F")
169 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
172 #================================================
173 # Set comipiler flags for different sourcefiles
174 #================================================
175 if (Fortran_COMPILER_NAME STREQUAL "ifort")
176 set(FFLAGS0 "-ip -w" )
177 set(FFLAGS1 "-w -g -d2 -CA -CB" )
178 set(FFLAGS2 "-w -g -00 ")
179 set(FFLAGS3 "-w -ipo " )
180 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
181 set(FFLAGS0 "-std=legacy -I. " )
182 set(FFLAGS1 "-std=legacy -g -I. " )
183 set(FFLAGS2 "-std=legacy -I. ")
184 set(FFLAGS3 "-std=legacy -I. " )
185 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
188 # Add MPI compiler flags
190 set(FFLAGS0 "${FFLAGS0} -I${MPIF_INCLUDE_DIRECTORIES}")
191 set(FFLAGS1 "${FFLAGS1} -I${MPIF_INCLUDE_DIRECTORIES}")
192 set(FFLAGS2 "${FFLAGS2} -I${MPIF_INCLUDE_DIRECTORIES}")
193 set(FFLAGS3 "${FFLAGS3} -I${MPIF_INCLUDE_DIRECTORIES}")
194 endif(UNRES_WITH_MPI)
196 set_property(SOURCE ${UNRES_MDM_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
197 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
198 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
199 set_property(SOURCE ${UNRES_MDM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
201 #=========================================
202 # Settings for GAB force field
203 #=========================================
204 if(UNRES_MD_FF STREQUAL "GAB" )
205 # set preprocesor flags
206 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
208 #=========================================
209 # Settings for E0LL2Y force field
210 #=========================================
211 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
212 # set preprocesor flags
213 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0" )
214 endif(UNRES_MD_FF STREQUAL "GAB")
217 #=========================================
218 # System specific flags
219 #=========================================
220 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
221 set(CPPFLAGS "${CPPFLAGS} -DLINUX")
222 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
225 #=========================================
226 # Compiler specific flags
227 #=========================================
229 if (Fortran_COMPILER_NAME STREQUAL "ifort")
230 # Add ifort preprocessor flags
231 set(CPPFLAGS "${CPPFLAGS} -DPGI")
232 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
233 # Add new gfortran flags
234 set(CPPFLAGS "${CPPFLAGS} -DG77")
235 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
236 # Add old gfortran flags
237 set(CPPFLAGS "${CPPFLAGS} -DG77")
238 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
241 #=========================================
242 # Add MPI preprocessor flags
243 #=========================================
245 set(CPPFLAGS "${CPPFLAGS} -DMP -DMPI")
246 endif(UNRES_WITH_MPI)
249 # add 64-bit specific preprocessor flags
250 if (architektura STREQUAL "64")
251 set(CPPFLAGS "${CPPFLAGS} -DAMD64")
252 endif (architektura STREQUAL "64")
256 # Apply preprocesor flags to *.F files
257 set_property(SOURCE ${UNRES_MDM_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )
259 # Apply preprocesor flags to proc_proc.c
260 set_property(SOURCE proc_proc.c PROPERTY COMPILE_DEFINITIONS "SGI" )
263 #========================================
264 # Setting binary name
265 #========================================
268 set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_MPICH_${UNRES_FF}.exe")
271 set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_single_${UNRES_FF}.exe")
272 endif(UNRES_WITH_MPI)
274 #=========================================
275 # cinfo.f workaround for cmake
276 #=========================================
277 # get the current date
280 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
282 "C CMake generated file
284 include 'COMMON.IOUNITS'
285 write(iout,*)'++++ Compile info ++++'
286 write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
289 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
290 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
291 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
292 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
293 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
294 CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" )
295 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
298 " write(iout,*)'++++ End of compile info ++++'
304 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
306 #=========================================
307 # Set full unres MD-M sources
308 #=========================================
309 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c )
311 #=========================================
313 #=========================================
314 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
315 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
317 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
318 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
320 #=========================================
322 #=========================================
323 # link MPI library (libmpich.a)
325 target_link_libraries( UNRES_BIN-MD-M ${MPIF_LIBRARIES} )
326 endif(UNRES_WITH_MPI)
328 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
329 target_link_libraries( UNRES_BIN-MD-M xdrf )
331 #=========================================
333 #=========================================
335 #-- Copy all the data files from the test directory into the source directory
336 #SET(UNRES_TEST_FILES
340 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
341 # SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
342 # MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
343 # ADD_CUSTOM_COMMAND (
344 # TARGET ${UNRES_BIN}
346 # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
348 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
350 #=========================================
351 # Generate data test files
352 #=========================================
354 #if(NOT UNRES_WITH_MPI)
356 # add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
358 #endif(NOT UNRES_WITH_MPI)