Updated FindGSL.cmake to version written by me.
authorChristoph Junghans <junghans@votca.org>
Wed, 16 Jan 2013 21:25:52 +0000 (14:25 -0700)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 12 Feb 2013 19:57:15 +0000 (20:57 +0100)
relates to #815

Change-Id: I323f113b4016ef232124fcdcc985d0526bc8a880

CMakeLists.txt
cmake/FindGSL.cmake [new file with mode: 0644]
cmake/Findgsl.cmake [deleted file]

index 0a96f0287d20abdc301ca07bda0a513a60f30ac0..907f79d773266327bfe6093ba778d437b79677d4 100644 (file)
@@ -528,7 +528,7 @@ ENDIF()
 
 option(GMX_GSL "Add support for gsl" OFF)
 if (GMX_GSL)
-  find_package(gsl)
+  find_package(GSL)
   set(PKG_GSL "")
   if(GSL_FOUND)
     include_directories(${GSL_INCLUDE_DIR})
diff --git a/cmake/FindGSL.cmake b/cmake/FindGSL.cmake
new file mode 100644 (file)
index 0000000..d805aa6
--- /dev/null
@@ -0,0 +1,72 @@
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2009-2011, by the VOTCA Development Team (http://www.votca.org)
+# Copyright (c) 2012,2013 by the GROMACS development team, led by
+# David van der Spoel, Berk Hess, Erik Lindahl, and including many
+# others, as listed in the AUTHORS file in the top-level source
+# directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+#
+# - Find gsl
+# Find the native GSL headers and libraries.
+#
+#  GSL_INCLUDE_DIRS - where to find gsl/gsl_linalg.h, etc.
+#  GSL_LIBRARIES    - List of libraries when using gsl.
+#  GSL_FOUND        - True if gsl found.
+#
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_GSL gsl)
+find_path(GSL_INCLUDE_DIR gsl/gsl_linalg.h HINTS ${PC_GSL_INCLUDE_DIRS})
+find_library(GSL_LIBRARY NAMES gsl HINTS ${PC_GSL_LIBRARY_DIRS} )
+find_library(GSLCBLAS_LIBRARY NAMES gslcblas cblas HINTS ${PC_GSL_LIBRARY_DIRS} )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set GSL_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(GSL DEFAULT_MSG GSL_LIBRARY GSL_INCLUDE_DIR GSLCBLAS_LIBRARY)
+
+set(GSL_LIBRARIES "${GSL_LIBRARY};${GSLCBLAS_LIBRARY}")
+set(GSL_INCLUDE_DIRS ${GSL_INCLUDE_DIR} )
+
+if (GSL_FOUND)
+  include(CheckLibraryExists)
+  check_library_exists("${GSLCBLAS_LIBRARY};${MATH_LIBRARIES}" cblas_dsyrk "" FOUND_DSYRK)
+  if(NOT FOUND_DSYRK)
+    message(FATAL_ERROR "Could not find cblas_dsyrk in ${GSLCBLAS_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you are using a static lib (.a) make sure you have specified all dependencies of libcblas in GSLCBLAS_LIBRARY by hand (e.g. -DGSLCBLAS_LIBRARY='/path/to/libcblas.so;/path/to/libm.so')! If your gsl was build against an different version of cblas, specify it in GSLCBLAS_LIBRARY")
+  endif(NOT FOUND_DSYRK)
+  #adding MATH_LIBRARIES here to allow static libs, this does not harm us as we are anyway using it
+  check_library_exists("${GSL_LIBRARIES};${MATH_LIBRARIES}" gsl_linalg_QR_decomp "" FOUND_QR_DECOMP)
+  if(NOT FOUND_QR_DECOMP)
+    message(FATAL_ERROR "Could not find gsl_linalg_QR_decompx in ${GSL_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong.  If you are using a static lib (.a) make sure you have specified all dependencies of libgsl in GSL_LIBRARY by hand (e.g. -DGSL_LIBRARY='/path/to/libgsl.so;/path/to/libm.so') !")
+  endif(NOT FOUND_QR_DECOMP)
+endif (GSL_FOUND)
+
+mark_as_advanced(GSL_INCLUDE_DIR GSL_LIBRARY)
diff --git a/cmake/Findgsl.cmake b/cmake/Findgsl.cmake
deleted file mode 100644 (file)
index 210fd92..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-#
-# This file is part of the GROMACS molecular simulation package.
-#
-# Copyright (c) 2012,2013, by the GROMACS development team, led by
-# David van der Spoel, Berk Hess, Erik Lindahl, and including many
-# others, as listed in the AUTHORS file in the top-level source
-# directory and at http://www.gromacs.org.
-#
-# GROMACS is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1
-# of the License, or (at your option) any later version.
-#
-# GROMACS is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with GROMACS; if not, see
-# http://www.gnu.org/licenses, or write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
-#
-# If you want to redistribute modifications to GROMACS, please
-# consider that scientific software is very special. Version
-# control is crucial - bugs must be traceable. We will be happy to
-# consider code for inclusion in the official distribution, but
-# derived work must not be called official GROMACS. Details are found
-# in the README & COPYING files - if they are missing, get the
-# official version at http://www.gromacs.org.
-#
-# To help us fund GROMACS development, we humbly ask that you cite
-# the research papers on the package. Check out http://www.gromacs.org.
-#
-# Try to find gnu scientific library GSL
-# See 
-# http://www.gnu.org/software/gsl/  and 
-# http://gnuwin32.sourceforge.net/packages/gsl.htm
-#
-# Once run this will define: 
-# 
-# GSL_FOUND       = system has GSL lib
-#
-# GSL_LIBRARIES   = full path to the libraries
-#    on Unix/Linux with additional linker flags from "gsl-config --libs"
-# 
-# CMAKE_GSL_CXX_FLAGS  = Unix compiler flags for GSL, essentially "`gsl-config --cxxflags`"
-#
-# GSL_INCLUDE_DIR      = where to find headers 
-#
-# GSL_LINK_DIRECTORIES = link directories, useful for rpath on Unix
-# GSL_EXE_LINKER_FLAGS = rpath on Unix
-#
-# Felix Woelk 07/2004
-# Jan Woetzel
-#
-# www.mip.informatik.uni-kiel.de
-# --------------------------------
-
-IF(WIN32)
-  # JW tested with gsl-1.8, Windows XP, MSVS 7.1, MSVS 8.0
-  SET(GSL_POSSIBLE_ROOT_DIRS
-    ${GSL_ROOT_DIR}
-    $ENV{GSL_ROOT_DIR}
-    ${GSL_DIR}
-    ${GSL_HOME}    
-    $ENV{GSL_DIR}
-    $ENV{GSL_HOME}
-    $ENV{EXTERN_LIBS_DIR}/gsl
-    $ENV{EXTRA}
-    )
-  FIND_PATH(GSL_INCLUDE_DIR
-    NAMES gsl/gsl_cdf.h gsl/gsl_randist.h
-    PATHS ${GSL_POSSIBLE_ROOT_DIRS}
-    PATH_SUFFIXES include
-    DOC "GSL header include dir"
-    )
-  
-  FIND_LIBRARY(GSL_GSL_LIBRARY
-    NAMES gsl libgsl
-    PATHS  ${GSL_POSSIBLE_ROOT_DIRS}
-    PATH_SUFFIXES lib
-    DOC "GSL library dir" )  
-  
-  FIND_LIBRARY(GSL_GSLCBLAS_LIBRARY
-    NAMES gslcblas libgslcblas
-    PATHS  ${GSL_POSSIBLE_ROOT_DIRS}
-    PATH_SUFFIXES lib
-    DOC "GSL cblas library dir" )
-  
-  SET(GSL_LIBRARIES ${GSL_GSL_LIBRARY})
-
-  #MESSAGE("DBG\n"
-    #  "GSL_GSL_LIBRARY=${GSL_GSL_LIBRARY}\n"
-    #  "GSL_GSLCBLAS_LIBRARY=${GSL_GSLCBLAS_LIBRARY}\n"
-    #  "GSL_LIBRARIES=${GSL_LIBRARIES}")
-
-
-ELSE(WIN32)
-  
-  IF(UNIX) 
-    SET(GSL_CONFIG_PREFER_PATH 
-      "$ENV{GSL_DIR}/bin"
-      "$ENV{GSL_DIR}"
-      "$ENV{GSL_HOME}/bin" 
-      "$ENV{GSL_HOME}" 
-      CACHE STRING "preferred path to GSL (gsl-config)")
-    FIND_PROGRAM(GSL_CONFIG gsl-config
-      ${GSL_CONFIG_PREFER_PATH}
-      /usr/bin/
-      )
-    # MESSAGE("DBG GSL_CONFIG ${GSL_CONFIG}")
-    
-    IF (GSL_CONFIG) 
-      
-      MESSAGE(STATUS "GSL using gsl-config ${GSL_CONFIG}")
-      # set CXXFLAGS to be fed into CXX_FLAGS by the user:
-      EXEC_PROGRAM(${GSL_CONFIG}
-        ARGS --cflags
-        OUTPUT_VARIABLE  GSL_CXX_FLAGS )
-      #SET(GSL_CXX_FLAGS "`${GSL_CONFIG} --cflags`")
-      
-      # set INCLUDE_DIRS to prefix+include
-      EXEC_PROGRAM(${GSL_CONFIG}
-        ARGS --prefix
-        OUTPUT_VARIABLE GSL_PREFIX)
-      SET(GSL_INCLUDE_DIR ${GSL_PREFIX}/include CACHE STRING INTERNAL)
-
-      # set link libraries and link flags
-      
-      #SET(GSL_LIBRARIES "`${GSL_CONFIG} --libs`")
-      
-      # extract link dirs for rpath  
-      EXEC_PROGRAM(${GSL_CONFIG}
-        ARGS --libs
-        OUTPUT_VARIABLE  GSL_CONFIG_LIBS )
-      SET(GSL_LIBRARIES "${GSL_CONFIG_LIBS}")
-
-      # split off the link dirs (for rpath)
-      # use regular expression to match wildcard equivalent "-L*<endchar>"
-      # with <endchar> is a space or a semicolon
-      STRING(REGEX MATCHALL "[-][L]([^ ;])+" 
-        GSL_LINK_DIRECTORIES_WITH_PREFIX 
-        "${GSL_CONFIG_LIBS}" )
-      #      MESSAGE("DBG  GSL_LINK_DIRECTORIES_WITH_PREFIX=${GSL_LINK_DIRECTORIES_WITH_PREFIX}")
-
-      # remove prefix -L because we need the pure directory for LINK_DIRECTORIES
-      
-      IF (GSL_LINK_DIRECTORIES_WITH_PREFIX)
-        STRING(REGEX REPLACE "[-][L]" "" GSL_LINK_DIRECTORIES ${GSL_LINK_DIRECTORIES_WITH_PREFIX} )
-      ENDIF (GSL_LINK_DIRECTORIES_WITH_PREFIX)
-      SET(GSL_EXE_LINKER_FLAGS "-Wl,-rpath,${GSL_LINK_DIRECTORIES}" CACHE STRING INTERNAL)
-      #      MESSAGE("DBG  GSL_LINK_DIRECTORIES=${GSL_LINK_DIRECTORIES}")
-      #      MESSAGE("DBG  GSL_EXE_LINKER_FLAGS=${GSL_EXE_LINKER_FLAGS}")
-
-      #      ADD_DEFINITIONS("-DHAVE_GSL")
-      #      SET(GSL_DEFINITIONS "-DHAVE_GSL")
-      MARK_AS_ADVANCED(
-        GSL_CXX_FLAGS
-        GSL_INCLUDE_DIR
-        GSL_LIBRARIES
-        GSL_LINK_DIRECTORIES
-        GSL_DEFINITIONS
-        )
-      MESSAGE(STATUS "Using GSL from ${GSL_PREFIX}")
-      
-    ELSE(GSL_CONFIG)
-      
-      INCLUDE(UsePkgConfig) #needed for PKGCONFIG(...)
-
-      MESSAGE(STATUS "GSL using pkgconfig")
-      #      PKGCONFIG(gsl includedir libdir linkflags cflags)
-      PKGCONFIG(gsl GSL_INCLUDE_DIR GSL_LINK_DIRECTORIES GSL_LIBRARIES GSL_CXX_FLAGS)
-      IF(GSL_INCLUDE_DIR)
-        MARK_AS_ADVANCED(
-          GSL_CXX_FLAGS
-          GSL_INCLUDE_DIR
-          GSL_LIBRARIES
-          GSL_LINK_DIRECTORIES
-          )
-      ENDIF(GSL_INCLUDE_DIR)
-    ENDIF(GSL_CONFIG)
-
-  ENDIF(UNIX)
-ENDIF(WIN32)
-
-
-IF(GSL_LIBRARIES)
-  IF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)
-
-    SET(GSL_FOUND 1)
-    
-  ENDIF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)
-ENDIF(GSL_LIBRARIES)
-
-
-# ==========================================
-IF(NOT GSL_FOUND)
-  # make FIND_PACKAGE friendly
-  IF(NOT GSL_FIND_QUIETLY)
-    IF(GSL_FIND_REQUIRED)
-      MESSAGE(FATAL_ERROR "GSL required, please specify it's location.")
-    ELSE(GSL_FIND_REQUIRED)
-      MESSAGE(STATUS       "GSL was not found.")
-    ENDIF(GSL_FIND_REQUIRED)
-  ENDIF(NOT GSL_FIND_QUIETLY)
-ENDIF(NOT GSL_FOUND)