czytanie opcji
[unres.git] / CMakeLists.txt
1 #
2 # CMake project file for UNRES 
3 #
4 cmake_minimum_required(VERSION 2.8)
5    
6 project(UNRESPACK Fortran C)
7
8 set(UNRES_MAJOR 3)
9 set(UNRES_MINOR 5)
10 set(UNRES_PATCH 2)
11 set(UNRES_VERSION ${UNRES_MAJOR}.${UNRES_MINOR}.${UNRES_PATCH})
12
13 #======================================
14 # MACROS
15 #======================================
16
17 # Get system date
18 MACRO (TODAY RESULT)
19     IF (WIN32)
20         EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE ${RESULT})
21         string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})
22     ELSEIF(UNIX)
23         EXECUTE_PROCESS(COMMAND "date" "--rfc-2822" OUTPUT_VARIABLE ${RESULT})
24         string(REGEX REPLACE "\n" " " ${RESULT} ${${RESULT}})
25     ELSE (WIN32)
26         MESSAGE(SEND_ERROR "date not implemented")
27         SET(${RESULT} 000000)
28     ENDIF (WIN32)
29 ENDMACRO (TODAY)
30
31 # format variables used in cinfo.f 
32 MACRO (CINFO_FORMAT FN VN VD)
33 # 50 znakowi
34 # 73 w ca?ej linii
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}") 
42 # Fit in one line?
43 # No.
44     if(SUMA GREATER 50) 
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}} " )
61 # Yes
62     else(SUMA GREATER 50)
63         file(APPEND ${FN} "       write(iout,*)'${STR}'\n")
64     endif(SUMA GREATER 50)
65 ENDMACRO (CINFO_FORMAT)
66
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)
72
73 #======================================
74 # CTest stuff
75 #======================================A
76
77 include(CTest)
78 enable_testing()
79  
80
81 #======================================
82 # Fortran compilers stuff
83 #======================================
84 # Get the compiler name
85 get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
86
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}")
90 #set(CPPFLAGS "-DPROCOR -DLINUX -DPGI -DUNRES -DISNAN -DMP -DMPI -DSPLITELE -DLANGO -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
91 #add_definitions( ${CPPFLAGS} ) 
92
93    
94 # make sure that the default is a RELEASE
95 if (NOT CMAKE_BUILD_TYPE)
96   set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo." FORCE)
97   set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "None" "Debug" "Release" "RelWithDebInfo")
98 endif (NOT CMAKE_BUILD_TYPE)
99
100
101 if (CMAKE_BUILD_TYPE STREQUAL "Release")
102   # Set makefile verbosity off for Release builds
103   set( CMAKE_VERBOSE_MAKEFILE 0 )
104 else()
105   # Set makefile verbosity on for other builds
106   set( CMAKE_VERBOSE_MAKEFILE 1 )
107 endif (CMAKE_BUILD_TYPE STREQUAL "Release")
108
109 # Default Install Path
110
111 set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/bin" CACHE PATH "Binary install directory " FORCE)
112
113 #=======================================  
114 # Set the varous build variables 
115 #=======================================
116
117 # Set force field
118 if (NOT UNRES_FF)
119   set(UNRES_MD_FF "NEWCORR" CACHE STRING "Choose the force field, options are: GAB E0LL2Y NEWCORR" )
120   set_property(CACHE UNRES_MD_FF PROPERTY STRINGS "GAB" "E0LL2Y" "NEWCORR")
121 endif (NOT UNRES_FF)
122
123 # Set CSA version force field
124 if (NOT UNRES_CSA_FF)
125   set(UNRES_CSA_FF "E0LL2Y" CACHE STRING "Choose the CSA version force field, options are: CASP3 ALPHA BETA ALPHABETA CASP5 3P 4P" )
126   set_property(CACHE UNRES_CSA_FF PROPERTY STRINGS "CASP3" "ALPHA" "BETA" "ALPHABETA" "CASP5" "3P" "4P" ) 
127 endif (NOT UNRES_CSA_FF)
128
129 # Use of MPI library (default ON)
130 option(UNRES_WITH_MPI "Choose whether or not to use MPI library" ON )
131
132
133 # Piasek cluster devel stuff
134 #option(UNRES_NA_MMCE "Kompilujemy na mmmce?" OFF )
135
136 option(UNRES_DFA "Choose whether or not to use DFA" OFF )
137 option(UNRES_5D "Choose whether or not to use HCD-5D" ON )
138 option(UNRES_NO5D "Choose the old code" OFF )
139 option(UNRES_SUMSLD "Choose SUMSLD (ON) or LBFGS (OFF, default)" OFF )
140
141 #=================================
142 # MPI stuff
143 #=================================
144
145 # Note for the future - use find package to get MPI 
146 find_package(MPI QUIET)
147
148 if (MPI_Fortran_FOUND)
149   message("MPI found")
150   FIX_DBL_INCLUDE(MPI_Fortran_INCLUDE_PATH)
151 else()
152   message("MPI not found - disabling MPI compile flags ")
153   set ( UNRES_WITH_MPI "OFF")
154 endif(MPI_Fortran_FOUND)        
155
156 #======================================
157 # Detect system architecture
158 #=======================================
159
160 if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
161   set(architektura "32")
162 else (CMAKE_SIZEOF_VOID_P EQUAL 4)
163   set(architektura "64")
164 endif( CMAKE_SIZEOF_VOID_P EQUAL 4 )
165
166 message("Detected ${architektura}-bit architecture")    
167
168 #=======================================
169 # Find other libraries
170 #=======================================
171
172 # used by unres/src_MIN
173 find_package (Threads)
174
175 #=======================================
176 # Add source files
177 #=======================================     
178
179 add_subdirectory(source/lib/xdrf)
180
181 #add_subdirectory(source/unres/src_MD)
182
183 if(UNRES_WITH_MPI)
184  if(UNRES_NO5D)
185 #    add_subdirectory(source/unres/src_MD-M)
186 #    add_subdirectory(source/unres/src_MD_DFA)
187 #    add_subdirectory(source/unres/src_CSA)
188     add_subdirectory(source/unres/src_MD-M-SAXS-homology)
189 #    add_subdirectory(source/unres/src_CSA_DiL)
190 #    add_subdirectory(source/wham/src)
191 #    add_subdirectory(source/wham/src-M)
192     add_subdirectory(source/wham/src-M-SAXS-homology)
193 #    add_subdirectory(source/cluster/wham/src)
194 #    add_subdirectory(source/cluster/wham/src-M)
195     add_subdirectory(source/cluster/wham/src-M-SAXS-homology)
196 #
197  else(UNRES_NO5D)
198 # src-HCD-5D
199   add_subdirectory(source/cluster/wham/src-HCD-5D)
200   add_subdirectory(source/wham/src-HCD-5D)
201   add_subdirectory(source/unres/src-HCD-5D)
202  endif(UNRES_NO5D)
203 # if(NOT UNRES_DFA)
204    add_subdirectory(source/unres-dock)
205 # endif(NOT UNRES_DFA)
206 endif(UNRES_WITH_MPI)
207
208 #add_subdirectory(source/unres/src_MIN)
209 add_subdirectory(source/cluster/unres/src)
210 #add_subdirectory(source/xdrfpdb/src)
211 add_subdirectory(source/xdrfpdb/src-M)
212 #add_subdirectory(source/maxlik/src_CSA)
213
214