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 #================================
99 if (Fortran_COMPILER_NAME STREQUAL "ifort")
100 set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f )
101 elseif(Fortran_COMPILER_NAME STREQUAL "mpif90")
102 set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f )
104 set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng_32.F )
105 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
108 set(UNRES_MDM_SRC3 energy_p_new_barrier.F energy_p_new-sep_barrier.F gradient_p.F )
122 energy_p_new_barrier.F
123 energy_p_new-sep_barrier.F
168 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
169 set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F")
170 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
173 #================================================
174 # Set comipiler flags for different sourcefiles
175 #================================================
176 if (Fortran_COMPILER_NAME STREQUAL "ifort")
177 set(FFLAGS0 "-ip -w" )
178 set(FFLAGS1 "-w -g -d2 -CA -CB" )
179 set(FFLAGS2 "-w -g -00 ")
180 set(FFLAGS3 "-w -ipo " )
181 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
182 set(FFLAGS0 "-std=legacy -I. " )
183 set(FFLAGS1 "-std=legacy -g -I. " )
184 set(FFLAGS2 "-std=legacy -I. ")
185 set(FFLAGS3 "-std=legacy -I. " )
186 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
189 # Add MPI compiler flags
191 set(FFLAGS0 "${FFLAGS0} -I${MPIF_INCLUDE_DIRECTORIES}")
192 set(FFLAGS1 "${FFLAGS1} -I${MPIF_INCLUDE_DIRECTORIES}")
193 set(FFLAGS2 "${FFLAGS2} -I${MPIF_INCLUDE_DIRECTORIES}")
194 set(FFLAGS3 "${FFLAGS3} -I${MPIF_INCLUDE_DIRECTORIES}")
195 endif(UNRES_WITH_MPI)
197 set_property(SOURCE ${UNRES_MDM_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
198 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
199 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
200 set_property(SOURCE ${UNRES_MDM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
202 #=========================================
203 # Settings for GAB force field
204 #=========================================
205 if(UNRES_MD_FF STREQUAL "GAB" )
206 # set preprocesor flags
207 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
209 #=========================================
210 # Settings for E0LL2Y force field
211 #=========================================
212 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
213 # set preprocesor flags
214 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0" )
215 endif(UNRES_MD_FF STREQUAL "GAB")
218 #=========================================
219 # System specific flags
220 #=========================================
221 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
222 set(CPPFLAGS "${CPPFLAGS} -DLINUX")
223 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
226 #=========================================
227 # Compiler specific flags
228 #=========================================
230 if (Fortran_COMPILER_NAME STREQUAL "ifort")
231 # Add ifort preprocessor flags
232 set(CPPFLAGS "${CPPFLAGS} -DPGI")
233 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
234 # Add new gfortran flags
235 set(CPPFLAGS "${CPPFLAGS} -DG77")
236 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
237 # Add old gfortran flags
238 set(CPPFLAGS "${CPPFLAGS} -DG77")
239 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
242 #=========================================
243 # Add MPI preprocessor flags
244 #=========================================
246 set(CPPFLAGS "${CPPFLAGS} -DMP -DMPI")
247 endif(UNRES_WITH_MPI)
250 # add 64-bit specific preprocessor flags
251 if (architektura STREQUAL "64")
252 set(CPPFLAGS "${CPPFLAGS} -DAMD64")
253 endif (architektura STREQUAL "64")
257 # Apply preprocesor flags to *.F files
258 set_property(SOURCE ${UNRES_MDM_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )
260 # Apply preprocesor flags to proc_proc.c
261 set_property(SOURCE proc_proc.c PROPERTY COMPILE_DEFINITIONS "SGI" )
264 #========================================
265 # Setting binary name
266 #========================================
269 set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_MPICH_${UNRES_MD_FF}.exe")
272 set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_single_${UNRES_MD_FF}.exe")
273 endif(UNRES_WITH_MPI)
275 #=========================================
276 # cinfo.f workaround for cmake
277 #=========================================
278 # get the current date
281 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
283 "C CMake generated file
285 include 'COMMON.IOUNITS'
286 write(iout,*)'++++ Compile info ++++'
287 write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
290 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
291 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
292 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
293 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
294 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
295 CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" )
296 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
299 " write(iout,*)'++++ End of compile info ++++'
305 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
307 #=========================================
308 # Set full unres MD-M sources
309 #=========================================
310 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c )
312 #=========================================
314 #=========================================
315 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
316 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
318 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
319 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
321 #=========================================
323 #=========================================
324 # link MPI library (libmpich.a)
326 target_link_libraries( UNRES_BIN-MD-M ${MPIF_LIBRARIES} )
327 endif(UNRES_WITH_MPI)
329 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
330 target_link_libraries( UNRES_BIN-MD-M xdrf )
332 #=========================================
334 #=========================================
336 #-- Copy all the data files from the test directory into the source directory
337 #SET(UNRES_TEST_FILES
341 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
342 # SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
343 # MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
344 # ADD_CUSTOM_COMMAND (
345 # TARGET ${UNRES_BIN}
347 # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
349 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
351 #=========================================
352 # Generate data test files
353 #=========================================
355 #if(NOT UNRES_WITH_MPI)
357 # add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
359 #endif(NOT UNRES_WITH_MPI)