2 # CMake project file for UNRES
4 cmake_minimum_required(VERSION 2.8)
6 project(UNRESPACK Fortran C)
11 set(UNRES_VERSION ${UNRES_MAJOR}.${UNRES_MINOR}.${UNRES_PATCH})
13 #======================================
15 #======================================
20 EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE ${RESULT})
21 string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})
23 EXECUTE_PROCESS(COMMAND "date" OUTPUT_VARIABLE ${RESULT})
24 string(REGEX REPLACE "(...) (...) (.+) (..:..:..) (.+) (....).*" "\\1 \\2 \\3 \\4 \\5 \\6" ${RESULT} ${${RESULT}})
26 MESSAGE(SEND_ERROR "date not implemented")
31 # foramt variables used in cinfo.f
32 MACRO (CINFO_FORMAT FN VN VD)
35 # write(iout,*)'INSTALL_DIR = /users/software/mpich-1.2.7p1_int...'
36 string(LENGTH "${VN}" VNLEN)
37 string(LENGTH "${VD}" VDLEN)
38 set(STR "${VN} ${VD}")
39 string(LENGTH "${STR}" SUMA)
40 math(EXPR STRLEN 50-${VNLEN})
41 # message("lancuch=${STRLEN}")
45 string(SUBSTRING "${STR}" 0 50 STR_OUT)
46 # message(" write(iout,*)'${VAR} = ${STR_OUT}'")
47 file(APPEND ${FN} " write(iout,*)'${STR_OUT}'\n")
48 math(EXPR STRLEN ${SUMA}-50)
49 string(SUBSTRING "${STR}" 50 ${STRLEN} STR)
50 string(LENGTH "${STR}" STRLEN)
51 while(STRLEN GREATER 48)
52 # message("Przycinam lancuch")
53 string(SUBSTRING "${STR}" 0 48 STR_OUT)
54 file(APPEND ${FN} " write(iout,*)' ${STR_OUT}'\n")
55 math(EXPR STRLEN ${STRLEN}-49)
56 string(SUBSTRING "${STR}" 49 ${STRLEN} STR)
57 string(LENGTH "${STR}" STRLEN)
58 endwhile(STRLEN GREATER 48)
59 file(APPEND ${FN} " write(iout,*)' ${STR}'\n")
60 # MESSAGE("DLUGOSC = ${VNLEN}; DLUGOSCD = ${VDLEN}; SUMA=${SUMA}; ${VAR} = ${${VAR}} " )
63 file(APPEND ${FN} " write(iout,*)'${STR}'\n")
64 endif(SUMA GREATER 50)
65 ENDMACRO (CINFO_FORMAT)
67 # Some MPI wrappers pass double include paths
68 # This macro fixes broken by semicolon occurence in path
69 MACRO (FIX_DBL_INCLUDE RESULT)
70 string(REPLACE ";" " -I" ${RESULT} "${${RESULT}}")
71 ENDMACRO (FIX_DBL_INCLUDE)
73 #======================================
75 #======================================A
81 #======================================
82 # Fortran compilers stuff
83 #======================================
84 # Get the compiler name
85 get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
87 # Altough cmake enables you to set some compiler definitions it seems by default they are ignored.
88 # This is a workaround to pass compiler definitions (preprocesor flags) to fortran compilers like ifort
89 SET(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> ${CMAKE_START_TEMP_FILE} <FLAGS> <DEFINES> -c <SOURCE> -o <OBJECT> ${CMAKE_END_TEMP_FILE}")
92 # make sure that the default is a RELEASE
93 if (NOT CMAKE_BUILD_TYPE)
94 set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo." FORCE)
95 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "None" "Debug" "Release" "RelWithDebInfo")
96 endif (NOT CMAKE_BUILD_TYPE)
99 if (CMAKE_BUILD_TYPE STREQUAL "Release")
100 # Set makefile verbosity off for Release builds
101 set( CMAKE_VERBOSE_MAKEFILE 0 )
103 # Set makefile verbosity on for other builds
104 set( CMAKE_VERBOSE_MAKEFILE 1 )
105 endif (CMAKE_BUILD_TYPE STREQUAL "Release")
107 # Default Install Path
109 set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/bin" CACHE PATH "Binary install directory " FORCE)
111 #=======================================
112 # Set the varous build variables
113 #=======================================
117 set(UNRES_MD_FF "GAB" CACHE STRING "Choose the force field, options are: GAB E0LL2Y" )
118 set_property(CACHE UNRES_MD_FF PROPERTY STRINGS "GAB" "E0LL2Y")
121 # Use of MPI library (default ON)
122 option(UNRES_WITH_MPI "Choose whether or not to use MPI library" ON )
124 option(UNRES_NEWGRAD "Choose whether or not to use NEWGRAD" OFF )
127 #=================================
129 #=================================
131 # Note for the future - use find package to get MPI
132 find_package(MPI QUIET)
134 if (MPI_Fortran_FOUND)
136 FIX_DBL_INCLUDE(MPI_Fortran_INCLUDE_PATH)
137 message(MPI_Fortran_INCLUDE_PATH)
138 message(${MPI_Fortran_INCLUDE_PATH})
139 message(MPI_Fortran_LIBRARIES)
140 message(${MPI_Fortran_LIBRARIES})
141 option(UNRES_SRUN "Use srun instead of mpiexec ?" OFF )
142 option(UNRES_MPIRUN "Use mpirun instead of mpiexec ?" OFF )
144 message("MPI not found - disabling MPI compile flags ")
145 set ( UNRES_WITH_MPI "OFF")
146 endif(MPI_Fortran_FOUND)
148 #======================================
149 # Detect system architecture
150 #=======================================
152 if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
153 set(architektura "32")
154 else (CMAKE_SIZEOF_VOID_P EQUAL 4)
155 set(architektura "64")
156 endif( CMAKE_SIZEOF_VOID_P EQUAL 4 )
158 message("Detected ${architektura}-bit architecture")
160 #=======================================
161 # Find other libraries
162 #=======================================
164 #=======================================
166 #=======================================
170 # the most independent ones should go first
172 add_subdirectory(source/xdrf)
173 add_subdirectory(source/unres)
174 add_subdirectory(source/wham)
175 add_subdirectory(source/cluster)