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 workaround for cmake
276 #=========================================
277 # get the current date
280 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f
281 "C CMake generated file
283 include 'COMMON.IOUNITS'
284 write(iout,*)'++++ Compile info ++++'
285 write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
286 write(iout,*)'Compiled ${DATE}'
287 write(iout,*)'Compiled by $ENV{USER}@$ENV{HOST}'
288 write(iout,*)'OS name: ${CMAKE_SYSTEM_NAME}'
289 write(iout,*)'OS release: ${CMAKE_SYSTEM}'
290 write(iout,*)'FC: ${CMAKE_Fortran_COMPILER}'
291 write(iout,*)'MD Force field: ${UNRES_MD_FF}'
292 write(iout,*)'++++ End of compile info ++++'
297 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
299 #=========================================
300 # Set full unres MD-M sources
301 #=========================================
302 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c )
304 #=========================================
306 #=========================================
307 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
308 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
310 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
311 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
313 #=========================================
315 #=========================================
316 # link MPI library (libmpich.a)
318 target_link_libraries( UNRES_BIN-MD-M ${MPIF_LIBRARIES} )
319 endif(UNRES_WITH_MPI)
321 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
322 target_link_libraries( UNRES_BIN-MD-M xdrf )
324 #=========================================
326 #=========================================
328 #-- Copy all the data files from the test directory into the source directory
329 #SET(UNRES_TEST_FILES
333 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
334 # SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
335 # MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
336 # ADD_CUSTOM_COMMAND (
337 # TARGET ${UNRES_BIN}
339 # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
341 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
343 #=========================================
344 # Generate data test files
345 #=========================================
347 #if(NOT UNRES_WITH_MPI)
349 # add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
351 #endif(NOT UNRES_WITH_MPI)