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
156 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
157 set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F")
158 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
161 #================================================
162 # Set comipiler flags for different sourcefiles
163 #================================================
164 if (Fortran_COMPILER_NAME STREQUAL "ifort")
165 set(FFLAGS0 "-ip -w" )
166 set(FFLAGS1 "-w -g -d2 -CA -CB" )
167 set(FFLAGS2 "-w -g -00 ")
168 set(FFLAGS3 "-w -ipo " )
169 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
170 set(FFLAGS0 "-std=legacy -I. " )
171 set(FFLAGS1 "-std=legacy -g -I. " )
172 set(FFLAGS2 "-std=legacy -I. ")
173 set(FFLAGS3 "-std=legacy -I. " )
174 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
177 # Add MPI compiler flags
179 set(FFLAGS0 "${FFLAGS0} -I${MPI_Fortran_INCLUDE_PATH}")
180 set(FFLAGS1 "${FFLAGS1} -I${MPI_Fortran_INCLUDE_PATH}")
181 set(FFLAGS2 "${FFLAGS2} -I${MPI_Fortran_INCLUDE_PATH}")
182 set(FFLAGS3 "${FFLAGS3} -I${MPI_Fortran_INCLUDE_PATH}")
183 endif(UNRES_WITH_MPI)
185 set_property(SOURCE ${UNRES_MDM_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
186 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
187 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
188 set_property(SOURCE ${UNRES_MDM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
190 #=========================================
191 # Settings for GAB force field
192 #=========================================
193 if(UNRES_MD_FF STREQUAL "GAB" )
194 # set preprocesor flags
195 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC -DSCCORPDB -DTIMING -DTIMING_ENE" )
197 #=========================================
198 # Settings for E0LL2Y force field
199 #=========================================
200 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
201 # set preprocesor flags
202 set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DSCCORPDB -DNEWCORR" )
203 endif(UNRES_MD_FF STREQUAL "GAB")
206 #=========================================
207 # System specific flags
208 #=========================================
209 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
210 set(CPPFLAGS "${CPPFLAGS} -DLINUX")
211 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
214 #=========================================
215 # Compiler specific flags
216 #=========================================
218 if (Fortran_COMPILER_NAME STREQUAL "ifort")
219 # Add ifort preprocessor flags
220 set(CPPFLAGS "${CPPFLAGS} -DPGI")
221 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
222 # Add new gfortran flags
223 set(CPPFLAGS "${CPPFLAGS} -DG77")
224 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
225 # Add old gfortran flags
226 set(CPPFLAGS "${CPPFLAGS} -DG77")
227 else (Fortran_COMPILER_NAME STREQUAL "ifort")
228 # Default preprocessor flags
229 set(CPPFLAGS "${CPPFLAGS} -DPGI")
230 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
233 #=========================================
234 # Add MPI preprocessor flags
235 #=========================================
237 set(CPPFLAGS "${CPPFLAGS} -DMP -DMPI")
238 endif(UNRES_WITH_MPI)
241 #=========================================
242 # add 64-bit specific preprocessor flags
243 #=========================================
244 if (architektura STREQUAL "64")
245 set(CPPFLAGS "${CPPFLAGS} -DAMD64")
246 endif (architektura STREQUAL "64")
250 # Apply preprocesor flags to *.F files
251 set_property(SOURCE ${UNRES_MDM_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )
253 # Apply preprocesor flags to proc_proc.c
254 set_property(SOURCE proc_proc.c PROPERTY COMPILE_DEFINITIONS "SGI" )
257 #========================================
258 # Setting binary name
259 #========================================
262 set(UNRES_BIN "unresMD-M_${Fortran_COMPILER_NAME}_MPICH_${UNRES_MD_FF}.exe")
265 set(UNRES_BIN "unresMD-M_${Fortran_COMPILER_NAME}_single_${UNRES_MD_FF}.exe")
266 endif(UNRES_WITH_MPI)
268 #=========================================
269 # cinfo.f workaround for cmake
270 #=========================================
271 # get the current date
274 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
276 "C CMake generated file
278 include 'COMMON.IOUNITS'
279 write(iout,*)'++++ Compile info ++++'
280 write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
283 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
284 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
285 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
286 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
287 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
288 CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" )
289 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
292 " write(iout,*)'++++ End of compile info ++++'
298 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
300 #=========================================
301 # Set full unres MD-M sources
302 #=========================================
303 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c )
305 #=========================================
307 #=========================================
308 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
309 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
310 set_property(TARGET UNRES_BIN-MD-M PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
311 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
313 #=========================================
315 #=========================================
316 # link MPI library (libmpich.a)
318 target_link_libraries( UNRES_BIN-MD-M ${MPI_Fortran_LIBRARIES} )
319 endif(UNRES_WITH_MPI)
321 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
322 target_link_libraries( UNRES_BIN-MD-M xdrf )
324 #=========================================
326 #=========================================
327 install(TARGETS UNRES_BIN-MD-M DESTINATION ${CMAKE_INSTALL_PREFIX})
329 #=========================================
331 #=========================================
333 #-- Copy all the data files from the test directory into the source directory
334 #SET(UNRES_TEST_FILES
338 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
339 # SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
340 # MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
341 # ADD_CUSTOM_COMMAND (
342 # TARGET ${UNRES_BIN}
344 # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
346 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
348 #=========================================
349 # Generate data test files
350 #=========================================
352 #if(NOT UNRES_WITH_MPI)
354 # add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
356 #endif(NOT UNRES_WITH_MPI)