Merge some of Sebastien Fabbro's patch for CMAKE
authorjulie <julielangou@users.noreply.github.com>
Wed, 15 Dec 2010 18:44:42 +0000 (18:44 +0000)
committerjulie <julielangou@users.noreply.github.com>
Wed, 15 Dec 2010 18:44:42 +0000 (18:44 +0000)
BLAS/CMakeLists.txt
BLAS/blas.pc.in [new file with mode: 0644]
CMakeLists.txt
lapack.pc.in [new file with mode: 0644]

index 05b8ff97a684552c30a91b44afc63bd1d0a3b251..45e68e9960c7ca9b597bf0ca8b0be0c762863eca 100644 (file)
@@ -1,2 +1,9 @@
 add_subdirectory(SRC)
-add_subdirectory(TESTING)
\ No newline at end of file
+if(BUILD_TESTING)
+add_subdirectory(TESTING)
+endif(BUILD_TESTING)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/blas.pc.in ${CMAKE_CURRENT_BINARY_DIR}/blas.pc)
+install(FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/blas.pc
+  DESTINATION ${PKG_CONFIG_DIR}
+  )
diff --git a/BLAS/blas.pc.in b/BLAS/blas.pc.in
new file mode 100644 (file)
index 0000000..845a25c
--- /dev/null
@@ -0,0 +1,9 @@
+prefix=@prefix@
+libdir=@libdir@
+
+Name: blas
+Description: Basic Linear Algebra Subprograms F77 reference implementations
+Version: @LAPACK_VERSION@
+URL: http://www.netlib.org/blas/
+Libs: -L${libdir} -lblas
+Libs.private: -lm
index 7a72dc5fec58c00771507a744fee83311076c028..c8fb0be759e567d1ef30002694bad2ed4cf407ba 100644 (file)
@@ -12,8 +12,8 @@ endif ()
 
 macro(lapack_install_library lib)
   install(TARGETS ${lib} EXPORT lapack-targets
-    ARCHIVE DESTINATION lib
-    LIBRARY DESTINATION lib
+    ARCHIVE DESTINATION lib${LIB_SUFFIX}
+    LIBRARY DESTINATION lib${LIB_SUFFIX}
     RUNTIME DESTINATION bin
     )
 endmacro()
@@ -42,26 +42,48 @@ message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as
 
 set(SECOND_SRC  ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f)
 set(DSECOND_SRC  ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f)
+set(prefix ${CMAKE_INSTALL_PREFIX})
+set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
+set(PKG_CONFIG_DIR ${libdir}/pkgconfig)
 
 # --------------------------------------------------
 # Subdirectories that need to be processed
 
 option(LOOK_FOR_OPTIMZED_BLAS "Whether or not to use an optimized BLAS library or the included netlib BLAS" OFF)
-if( LOOK_FOR_OPTIMZED_BLAS )
-  find_package( BLAS )
-endif(LOOK_FOR_OPTIMZED_BLAS)
+if (BLAS_LIBRAIRIES)
+     # User provided a BLAS Library
+     include(CheckFortranFunctionExists)
+     set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRAIRIES})
+     CHECK_FORTRAN_FUNCTION_EXISTS("dgemm" BLAS_FOUND)
+     unset( CMAKE_REQUIRED_LIBRARIES )
+     if (BLAS_FOUND)
+        message(STATUS "--> BLAS supplied by user is WORKING, will use ${BLAS_LIBRAIRIES}.")
+     else(BLAS_FOUND)
+        message(ERROR "--> BLAS supplied by user is not WORKING, CANNOT USE ${BLAS_LIBRAIRIES}.")
+        message(ERROR "-->     Will use REFERENCE BLAS (by default)")
+        message(ERROR "-->     Or Correct your BLAS_LIBRAIRIES entry ")
+        message(ERROR "-->     Or Consider checking LOOK_FOR_OPTIMZED_BLAS")
+     endif(BLAS_FOUND)
+else (BLAS_LIBRAIRIES)
+     # User did not provide a BLAS Library
+   if( LOOK_FOR_OPTIMZED_BLAS )
+       find_package( BLAS )
+   endif(LOOK_FOR_OPTIMZED_BLAS)
+endif (BLAS_LIBRAIRIES)
+
 if(NOT BLAS_FOUND)
-  add_subdirectory(BLAS)
-  set( BLAS_LIBRARIES blas )
+      add_subdirectory(BLAS)
+      set( BLAS_LIBRARIES blas )
 else()
   set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${BLAS_LINKER_FLAGS}" 
     CACHE STRING "Flags for Fortran compiler" FORCE
   )
 endif( NOT BLAS_FOUND )
-
-
+   
 add_subdirectory(SRC)
-add_subdirectory(TESTING)
+if(BUILD_TESTING)
+  add_subdirectory(TESTING)
+endif(BUILD_TESTING)
 
 # --------------------------------------------------
 # CPACK Packaging 
@@ -96,6 +118,7 @@ INCLUDE(CPack)
 # --------------------------------------------------
 # By default static library
 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
+OPTION(BUILD_STATIC_LIBS "Build static libraries" ON )
 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
 
 if( NOT BLAS_FOUND )
@@ -105,8 +128,12 @@ else( NOT BLAS_FOUND )
 endif( NOT BLAS_FOUND )
 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-version.cmake.in
   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
-configure_file(${LAPACK_SOURCE_DIR}/lapack-config.cmake.in
-  ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc)
+ install(FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
+  DESTINATION ${PKG_CONFIG_DIR}
+   )
 
 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
@@ -115,5 +142,6 @@ install(FILES
   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
   DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
   )
-install(EXPORT lapack-targets
-  DESTINATION lib/cmake/lapack-${LAPACK_VERSION})
+
+configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
+  ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
diff --git a/lapack.pc.in b/lapack.pc.in
new file mode 100644 (file)
index 0000000..d34c870
--- /dev/null
@@ -0,0 +1,9 @@
+prefix=@prefix@
+libdir=@libdir@
+
+Name: lapack
+Description: FORTRAN reference implementation of LAPACK Linear Algebra PACKage
+Version: @LAPACK_VERSION@
+URL: http://www.netlib.org/lapack/
+Libs: -L${libdir} -llapack
+Requires: blas