rm exe
[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 1)
10 set(UNRES_PATCH 0)
11 set(UNRES_VERSION ${UNRES_MAJOR}.${UNRES_MINOR}.${UNRES_PATCH})
12  
13 #======================================
14 # CTest stuff
15 #======================================
16
17 include(CTest)
18 enable_testing()
19  
20 # Set makefile verbose on
21 set( CMAKE_VERBOSE_MAKEFILE 1 )
22
23 #======================================
24 # Fortran compilers stuff
25 #======================================
26 # Get the compiler name
27 get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
28
29 # Altough cmake enables you to set some compiler definitions it seems by default they are ignored.                 
30 # This is a workaround to pass compiler definitions (preprocesor flags) to fortran compilers like ifort
31 SET(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER>  ${CMAKE_START_TEMP_FILE} <FLAGS> <DEFINES> -c <SOURCE> -o <OBJECT> ${CMAKE_END_TEMP_FILE}")
32 #set(CPPFLAGS "-DPROCOR -DLINUX -DPGI -DUNRES -DISNAN -DMP -DMPI -DSPLITELE -DLANGO -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
33 #add_definitions( ${CPPFLAGS} ) 
34
35    
36 # make sure that the default is a RELEASE
37 if (NOT CMAKE_BUILD_TYPE)
38   set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release." FORCE)
39   set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "None" "Debug" "Release" )
40 endif (NOT CMAKE_BUILD_TYPE)
41    
42 #=======================================  
43 # Set the varous build variables 
44 #=======================================
45
46 # Set force field
47 if (NOT UNRES_FF)
48   set(UNRES_MD_FF "GAB" CACHE STRING "Choose the force field, options are: GAB E0LL2Y" )
49   set_property(CACHE UNRES_MD_FF PROPERTY STRINGS "GAB" "E0LL2Y")
50 endif (NOT UNRES_FF)
51
52 # Set CSA version force field
53 if (NOT UNRES_CSA_FF)
54   set(UNRES_CSA_FF "4P" CACHE STRING "Choose the CSA version force field, options are: CASP3 ALPHA BETA ALPHABETA CASP5 3P 4P" )
55   set_property(CACHE UNRES_CSA_FF PROPERTY STRINGS "CASP3" "ALPHA" "BETA" "ALPHABETA" "CASP5" "3P" "4P" ) 
56 endif (NOT UNRES_CSA_FF)
57
58 # Use of MPI library (default ON)
59 option(UNRES_WITH_MPI "Choose whether or not to use MPI library" ON )
60
61
62 # Piasek cluster devel stuff
63 option(UNRES_NA_MMCE "Kompilujemy na mmmce?" OFF )
64
65
66 #=================================
67 # MPI stuff
68 #=================================
69
70 # Note for the future - use finde package to get MPI 
71 find_package(MPI)
72
73 #if(MPI_LIBRARY)
74
75 #MPI_INCLUDE_PATH
76
77
78 if(MPIF_LOCAL_DIR)
79   find_library(MPIF_LIBRARY NAMES libmpich.a  NO_DEFAULT_PATH  PATHS  ${MPIF_LOCAL_DIR}/lib)
80   find_path( MPIF_INCLUDE_DIRECTORIES  NAMES mpif.h  NO_DEFAULT_PATH  PATHS  ${MPIF_LOCAL_DIR}/include  )
81 else(MPIF_LOCAL_DIR)
82   find_library(MPIF_LIBRARY NAMES mpi mpich PATHS 
83         ${MPI_LIBRARY}
84         ${MPI_EXTRA_LIBRARY}
85         /users/local/mpi64/mpich-1.2.7p1/lib 
86         /usr/lib
87         /usr/local/lib
88         /usr/local/mpi/lib
89   )
90   find_path( MPIF_INCLUDE_DIRECTORIES NAMES  mpif.h PATHS
91         ${MPI_INCLUDE_PATH}
92         /users/local/mpi64/mpich-1.2.7p1/include
93         /usr/include
94         /usr/local/include   
95         /usr/include/mpi
96         /usr/local/mpi/include
97   )
98 endif(MPIF_LOCAL_DIR)
99
100 set( MPIF_LIBRARIES  ${MPIF_LIBRARY})
101
102 if ( MPIF_INCLUDE_DIRECTORIES )
103   set( MPIF_FOUND TRUE )
104   message("MPI found")
105 else ( MPIF_INCLUDE_DIRECTORIES )
106   set( MPIF_FOUND FALSE )
107   message("MPI not found - disabling MPI compile flags ")
108   set ( UNRES_WITH_MPI "OFF")
109 endif ( MPIF_INCLUDE_DIRECTORIES )
110
111 if (MPIF_FOUND)
112   message("MPIF_LIBRARIES=${MPIF_LIBRARY}")
113   message("MPIF_INCLUDE_DIRECTORIES=${MPIF_INCLUDE_DIRECTORIES}" )
114 endif(MPIF_FOUND) 
115
116
117
118 #======================================
119 # Detect system architecture
120 #=======================================
121
122 if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
123   set(architektura "32")
124 else (CMAKE_SIZEOF_VOID_P EQUAL 4)
125   set(architektura "64")
126 endif( CMAKE_SIZEOF_VOID_P EQUAL 4 )
127
128 message("Detected ${architektura}-bit architecture")    
129
130 #=======================================
131 # Find other libraries
132 #=======================================
133
134 # used by unres/src_MIN
135 find_package (Threads)
136
137
138
139 #=======================================
140 #  Create diractories for build targets
141 #=======================================
142 #execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/unres/MD )
143
144 #=======================================
145 # Add source files
146 #=======================================     
147
148
149 add_subdirectory(source/lib/xdrf)
150
151
152 if(UNRES_NA_MMCE)
153
154   if(UNRES_WITH_MPI)
155     # Brak MPI dla gfortrana, wiec tylko na ifort sie skompiluje
156     if (Fortran_COMPILER_NAME STREQUAL "ifort")
157       add_subdirectory(source/unres/src_MD)
158       add_subdirectory(source/unres/src_MD-M)
159       add_subdirectory(source/unres/src_CSA)
160       add_subdirectory(source/cluster/wham/src)
161       add_subdirectory(source/cluster/wham/src-M)
162     endif (Fortran_COMPILER_NAME STREQUAL "ifort")
163   else()
164     add_subdirectory(source/unres/src_MD)
165     # src_MD-M doesn't work yet witout MPI
166     # add_subdirectory(source/unres/src_MD-M)
167   endif()
168   add_subdirectory(source/unres/src_MIN)
169   add_subdirectory(source/cluster/unres/src)
170   add_subdirectory(source/xdrfpdb/src)
171   add_subdirectory(source/xdrfpdb/src-M)
172   add_subdirectory(source/ga)
173 else()
174
175   add_subdirectory(source/unres/src_MD)
176   if(UNRES_WITH_MPI)
177     add_subdirectory(source/unres/src_MD-M)
178     add_subdirectory(source/unres/src_CSA)
179     add_subdirectory(source/wham/src)
180     add_subdirectory(source/wham/src-M)
181     add_subdirectory(source/cluster/wham/src)
182     add_subdirectory(source/cluster/wham/src-M)
183   endif(UNRES_WITH_MPI)
184   add_subdirectory(source/unres/src_MIN)
185   add_subdirectory(source/cluster/unres/src)
186   add_subdirectory(source/xdrfpdb/src)
187   add_subdirectory(source/xdrfpdb/src-M)
188   add_subdirectory(source/ga)
189
190 endif(UNRES_NA_MMCE)
191