added/modified CMake files for all subdirs in source/unres + junkfiles cleanup
[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 mpich mpi PATHS 
83         ${MPI_LIBRARY}
84         /users/local/mpi64/mpich-1.2.7p1/lib 
85         /usr/lib
86         /usr/local/lib
87         /usr/local/mpi/lib
88   )
89   find_path( MPIF_INCLUDE_DIRECTORIES NAMES  mpif.h PATHS
90         ${MPI_INCLUDE_PATH}
91         /users/local/mpi64/mpich-1.2.7p1/include
92         /usr/include
93         /usr/local/include   
94         /usr/include/mpi
95         /usr/local/mpi/include
96   )
97 endif(MPIF_LOCAL_DIR)
98
99 set( MPIF_LIBRARIES  ${MPIF_LIBRARY})
100
101 if ( MPIF_INCLUDE_DIRECTORIES )
102   set( MPIF_FOUND TRUE )
103   message("MPI found")
104 else ( MPIF_INCLUDE_DIRECTORIES )
105   set( MPIF_FOUND FALSE )
106   message("MPI not found - disabling MPI compile flags ")
107   set ( UNRES_WITH_MPI "OFF")
108 endif ( MPIF_INCLUDE_DIRECTORIES )
109
110 if (MPIF_FOUND)
111   message("MPIF_LIBRARIES=${MPIF_LIBRARY}")
112   message("MPIF_INCLUDE_DIRECTORIES=${MPIF_INCLUDE_DIRECTORIES}" )
113 endif(MPIF_FOUND) 
114
115
116
117 #======================================
118 # Detect system architecture
119 #
120
121 if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
122   set(architektura "32")
123 else (CMAKE_SIZEOF_VOID_P EQUAL 4)
124   set(architektura "64")
125 endif( CMAKE_SIZEOF_VOID_P EQUAL 4 )
126
127 message("Detected ${architektura}-bit architecture")    
128
129
130 #=======================================
131 #  Create diractories for build targets
132 #=======================================
133 #execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/unres/MD )
134
135 #=======================================
136 # Add source files
137 #=======================================     
138
139
140 if(UNRES_NA_MMCE EQUAL "ON")
141
142   if(UNRES_WITH_MPI EQUAL "ON")
143     # Brak MPI dla gfortrana, wiec tylko na ifort sie skompiluje
144     if (Fortran_COMPILER_NAME STREQUAL "ifort")
145       add_subdirectory(source/unres/src_MD)
146       add_subdirectory(source/unres/src_MD-M)
147       add_subdirectory(source/unres/src_CSA)
148     endif (Fortran_COMPILER_NAME STREQUAL "ifort")
149   else()
150     add_subdirectory(source/unres/src_MD)
151     # src_MD-M doesn't work yet witout MPI
152     # add_subdirectory(source/unres/src_MD-M)
153   endif()
154   add_subdirectory(source/unres/src_MIN)
155
156 else()
157
158   add_subdirectory(source/unres/src_MD)
159   add_subdirectory(source/unres/src_MD-M)
160   add_subdirectory(source/unres/src_MIN)
161   add_subdirectory(source/unres/src_CSA)
162
163 endif(UNRES_NA_MMCE EQUAL "ON")
164