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 )
101 set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng_32.F )
102 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
105 set(UNRES_MDM_SRC3 energy_p_new_barrier.F energy_p_new-sep_barrier.F gradient_p.F )
119 energy_p_new_barrier.F
120 energy_p_new-sep_barrier.F
165 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
166 set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F")
167 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
170 #================================================
171 # Set comipiler flags for different sourcefiles
172 #================================================
173 if (Fortran_COMPILER_NAME STREQUAL "ifort")
174 set(FFLAGS0 "-ip -w" )
175 set(FFLAGS1 "-w -g -d2 -CA -CB" )
176 set(FFLAGS2 "-w -g -00 ")
177 #set(FFLAGS3 "-c -w -O3 -ipo -ipo_obj -opt_report" )
178 set(FFLAGS3 "-w -ipo " )
179 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
181 set(FFLAGS1 "-g -I. " )
183 #set(FFLAGS3 "-c -w -O3 -ipo -ipo_obj -opt_report" )
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 stupid workaround for cmake
277 #=========================================
278 set_property(SOURCE compinfo.c PROPERTY CMAKE_C_FLAGS "-c" )
279 add_executable(compinfo-mdm compinfo.c)
280 set_target_properties(compinfo-mdm PROPERTIES OUTPUT_NAME compinfo)
282 set(UNRES_CINFO_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
283 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f
284 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cinfo.f ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f
285 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/COMMON.IOUNITS ${CMAKE_CURRENT_BINARY_DIR}/COMMON.IOUNITS
286 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/compinfo | true
287 DEPENDS compinfo-mdm )
288 set_property(SOURCE ${UNRES_CINFO_DIR}/cinfo.f PROPERTY COMPILE_FLAGS ${FFLAGS0} )
290 #=========================================
291 # Set full unres MD-M sources
292 #=========================================
293 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${UNRES_CINFO_DIR}/cinfo.f proc_proc.c )
295 #=========================================
297 #=========================================
298 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
299 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
301 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
302 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
304 #=========================================
306 #=========================================
307 # link MPI library (libmpich.a)
309 target_link_libraries( UNRES_BIN-MD-M ${MPIF_LIBRARIES} )
310 endif(UNRES_WITH_MPI)
312 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
313 target_link_libraries( UNRES_BIN-MD-M xdrf )
315 #=========================================
317 #=========================================
319 #-- Copy all the data files from the test directory into the source directory
320 #SET(UNRES_TEST_FILES
324 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
325 # SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
326 # MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
327 # ADD_CUSTOM_COMMAND (
328 # TARGET ${UNRES_BIN}
330 # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
332 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
334 #=========================================
335 # Generate data test files
336 #=========================================
338 #if(NOT UNRES_WITH_MPI)
340 # add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
342 #endif(NOT UNRES_WITH_MPI)