aditional MPI search lib path added
[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_LIBRARY}/../
85         ${MPI_EXTRA_LIBRARY}
86         /users/local/mpi64/mpich-1.2.7p1/lib 
87         /usr/lib
88         /usr/local/lib
89         /usr/local/mpi/lib
90   )
91   find_path( MPIF_INCLUDE_DIRECTORIES NAMES  mpif.h PATHS
92         ${MPI_INCLUDE_PATH}
93         /users/local/mpi64/mpich-1.2.7p1/include
94         /usr/include
95         /usr/local/include   
96         /usr/include/mpi
97         /usr/local/mpi/include
98   )
99 endif(MPIF_LOCAL_DIR)
100
101 set( MPIF_LIBRARIES  ${MPIF_LIBRARY})
102
103 if ( MPIF_INCLUDE_DIRECTORIES )
104   set( MPIF_FOUND TRUE )
105   message("MPI found")
106 else ( MPIF_INCLUDE_DIRECTORIES )
107   set( MPIF_FOUND FALSE )
108   message("MPI not found - disabling MPI compile flags ")
109   set ( UNRES_WITH_MPI "OFF")
110 endif ( MPIF_INCLUDE_DIRECTORIES )
111
112 if (MPIF_FOUND)
113   message("MPIF_LIBRARIES=${MPIF_LIBRARY}")
114   message("MPIF_INCLUDE_DIRECTORIES=${MPIF_INCLUDE_DIRECTORIES}" )
115 endif(MPIF_FOUND) 
116
117
118
119 #======================================
120 # Detect system architecture
121 #=======================================
122
123 if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
124   set(architektura "32")
125 else (CMAKE_SIZEOF_VOID_P EQUAL 4)
126   set(architektura "64")
127 endif( CMAKE_SIZEOF_VOID_P EQUAL 4 )
128
129 message("Detected ${architektura}-bit architecture")    
130
131 #=======================================
132 # Find other libraries
133 #=======================================
134
135 # used by unres/src_MIN
136 find_package (Threads)
137
138
139
140 #=======================================
141 #  Create diractories for build targets
142 #=======================================
143 #execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/unres/MD )
144
145 #=======================================
146 # Add source files
147 #=======================================     
148
149
150 add_subdirectory(source/lib/xdrf)
151
152
153 if(UNRES_NA_MMCE)
154
155   if(UNRES_WITH_MPI)
156     # Brak MPI dla gfortrana, wiec tylko na ifort sie skompiluje
157     if (Fortran_COMPILER_NAME STREQUAL "ifort")
158       add_subdirectory(source/unres/src_MD)
159       add_subdirectory(source/unres/src_MD-M)
160       add_subdirectory(source/unres/src_CSA)
161       add_subdirectory(source/cluster/wham/src)
162       add_subdirectory(source/cluster/wham/src-M)
163     endif (Fortran_COMPILER_NAME STREQUAL "ifort")
164   else()
165     add_subdirectory(source/unres/src_MD)
166     # src_MD-M doesn't work yet witout MPI
167     # add_subdirectory(source/unres/src_MD-M)
168   endif()
169   add_subdirectory(source/unres/src_MIN)
170   add_subdirectory(source/cluster/unres/src)
171   add_subdirectory(source/xdrfpdb/src)
172   add_subdirectory(source/xdrfpdb/src-M)
173
174 else()
175
176   add_subdirectory(source/unres/src_MD)
177   if(UNRES_WITH_MPI)
178     add_subdirectory(source/unres/src_MD-M)
179     add_subdirectory(source/unres/src_CSA)
180     add_subdirectory(source/wham/src)
181     add_subdirectory(source/wham/src-M)
182     add_subdirectory(source/cluster/wham/src)
183     add_subdirectory(source/cluster/wham/src-M)
184   endif(UNRES_WITH_MPI)
185   add_subdirectory(source/unres/src_MIN)
186   add_subdirectory(source/cluster/unres/src)
187   add_subdirectory(source/xdrfpdb/src)
188   add_subdirectory(source/xdrfpdb/src-M)
189
190 endif(UNRES_NA_MMCE)
191