Merge branch 'prerelease-3.2.1' into czarek
[unres.git] / CMakeLists.txt
index f933d69..5b824dd 100644 (file)
@@ -6,8 +6,8 @@ cmake_minimum_required(VERSION 2.8)
 project(UNRESPACK Fortran C)
 
 set(UNRES_MAJOR 3)
-set(UNRES_MINOR 1)
-set(UNRES_PATCH 0)
+set(UNRES_MINOR 2)
+set(UNRES_PATCH 1)
 set(UNRES_VERSION ${UNRES_MAJOR}.${UNRES_MINOR}.${UNRES_PATCH})
 
 #======================================
@@ -63,6 +63,13 @@ MACRO (CINFO_FORMAT FN VN VD)
        file(APPEND ${FN} "       write(iout,*)'${STR}'\n")
     endif(SUMA GREATER 50)
 ENDMACRO (CINFO_FORMAT)
+
+# Some MPI wrappers pass double include paths
+# This macro fixes broken by semicolon occurence in path
+MACRO (FIX_DBL_INCLUDE RESULT)
+  string(REPLACE ";" " -I" ${RESULT} "${${RESULT}}")
+ENDMACRO (FIX_DBL_INCLUDE)
+
 #======================================
 # CTest stuff
 #======================================A
@@ -70,8 +77,6 @@ ENDMACRO (CINFO_FORMAT)
 include(CTest)
 enable_testing()
  
-# Set makefile verbose on
-set( CMAKE_VERBOSE_MAKEFILE 1 )
 
 #======================================
 # Fortran compilers stuff
@@ -88,10 +93,23 @@ SET(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER>  ${CMAKE_START_TEMP_F
    
 # make sure that the default is a RELEASE
 if (NOT CMAKE_BUILD_TYPE)
-  set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release." FORCE)
-  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "None" "Debug" "Release" )
+  set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo." FORCE)
+  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "None" "Debug" "Release" "RelWithDebInfo")
 endif (NOT CMAKE_BUILD_TYPE)
-   
+
+
+if (CMAKE_BUILD_TYPE STREQUAL "Release")
+  # Set makefile verbosity off for Release builds
+  set( CMAKE_VERBOSE_MAKEFILE 0 )
+else()
+  # Set makefile verbosity on for other builds
+  set( CMAKE_VERBOSE_MAKEFILE 1 )
+endif (CMAKE_BUILD_TYPE STREQUAL "Release")
+
+# Default Install Path
+
+set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/bin" CACHE PATH "Binary install directory " FORCE)
+
 #=======================================  
 # Set the varous build variables 
 #=======================================
@@ -120,54 +138,16 @@ option(UNRES_NA_MMCE "Kompilujemy na mmmce?" OFF )
 # MPI stuff
 #=================================
 
-# Note for the future - use finde package to get MPI 
-find_package(MPI)
-
-#if(MPI_LIBRARY)
-
-#MPI_INCLUDE_PATH
-
-
-if(MPIF_LOCAL_DIR)
-  find_library(MPIF_LIBRARY NAMES libmpich.a  NO_DEFAULT_PATH  PATHS  ${MPIF_LOCAL_DIR}/lib)
-  find_path( MPIF_INCLUDE_DIRECTORIES  NAMES mpif.h  NO_DEFAULT_PATH  PATHS  ${MPIF_LOCAL_DIR}/include  )
-else(MPIF_LOCAL_DIR)
-  find_library(MPIF_LIBRARY NAMES mpi mpich PATHS 
-       ${MPI_LIBRARY}
-       ${MPI_LIBRARY}/../
-       ${MPI_EXTRA_LIBRARY}
-       /users/local/mpi64/mpich-1.2.7p1/lib 
-       /usr/lib
-        /usr/local/lib
-        /usr/local/mpi/lib
-  )
-  find_path( MPIF_INCLUDE_DIRECTORIES NAMES  mpif.h PATHS
-       ${MPI_INCLUDE_PATH}
-       /users/local/mpi64/mpich-1.2.7p1/include
-       /usr/include
-       /usr/local/include   
-       /usr/include/mpi
-       /usr/local/mpi/include
-  )
-endif(MPIF_LOCAL_DIR)
-
-set( MPIF_LIBRARIES  ${MPIF_LIBRARY})
-
-if ( MPIF_INCLUDE_DIRECTORIES )
-  set( MPIF_FOUND TRUE )
+# Note for the future - use find package to get MPI 
+find_package(MPI QUIET)
+
+if (MPI_Fortran_FOUND)
   message("MPI found")
-else ( MPIF_INCLUDE_DIRECTORIES )
-  set( MPIF_FOUND FALSE )
+  FIX_DBL_INCLUDE(MPI_Fortran_INCLUDE_PATH)
+else()
   message("MPI not found - disabling MPI compile flags ")
   set ( UNRES_WITH_MPI "OFF")
-endif ( MPIF_INCLUDE_DIRECTORIES )
-
-if (MPIF_FOUND)
-  message("MPIF_LIBRARIES=${MPIF_LIBRARY}")
-  message("MPIF_INCLUDE_DIRECTORIES=${MPIF_INCLUDE_DIRECTORIES}" )
-endif(MPIF_FOUND) 
-
-
+endif(MPI_Fortran_FOUND)       
 
 #======================================
 # Detect system architecture
@@ -188,13 +168,6 @@ message("Detected ${architektura}-bit architecture")
 # used by unres/src_MIN
 find_package (Threads)
 
-
-
-#=======================================
-#  Create diractories for build targets
-#=======================================
-#execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/unres/MD )
-
 #=======================================
 # Add source files
 #=======================================     
@@ -211,7 +184,6 @@ if(UNRES_NA_MMCE)
       add_subdirectory(source/unres/src_MD)
       add_subdirectory(source/unres/src_MD-M)
       add_subdirectory(source/unres/src_CSA)
-      add_subdirectory(source/unres/src_CSA_DiL)
       add_subdirectory(source/cluster/wham/src)
       add_subdirectory(source/cluster/wham/src-M)
     endif (Fortran_COMPILER_NAME STREQUAL "ifort")
@@ -231,7 +203,6 @@ else()
   if(UNRES_WITH_MPI)
     add_subdirectory(source/unres/src_MD-M)
     add_subdirectory(source/unres/src_CSA)
-    add_subdirectory(source/unres/src_CSA_DiL)
     add_subdirectory(source/wham/src)
     add_subdirectory(source/wham/src-M)
     add_subdirectory(source/cluster/wham/src)