From 9dd0968b2148a6f9cfdb193d9ae9a224ab28ddb7 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Mon, 4 Jul 2016 17:35:05 -0500 Subject: [PATCH 1/2] STYLE: Change source template files to .in extension The cblas_mangling_with_flags.h and lapacke_mangling_with_flags.h are template files that are not used directly. They need to be configured (i.e. copied) to lapacke_mangling.h and cblas_mangling.h header files that are used. These renamings make the intent of these files more clearly reported. The file LAPACKE/include/lapacke_mangling.h should not be stored in the repository because it should be generated (copied from above) at build time. --- CBLAS/Makefile | 2 +- ...h_flags.h => cblas_mangling_with_flags.h.in} | 0 LAPACKE/Makefile | 2 +- LAPACKE/include/lapacke_mangling_with_flags.h | 17 ----------------- ...gling.h => lapacke_mangling_with_flags.h.in} | 0 5 files changed, 2 insertions(+), 19 deletions(-) rename CBLAS/include/{cblas_mangling_with_flags.h => cblas_mangling_with_flags.h.in} (100%) delete mode 100644 LAPACKE/include/lapacke_mangling_with_flags.h rename LAPACKE/include/{lapacke_mangling.h => lapacke_mangling_with_flags.h.in} (100%) diff --git a/CBLAS/Makefile b/CBLAS/Makefile index d7ee0c5065..3da723c34d 100644 --- a/CBLAS/Makefile +++ b/CBLAS/Makefile @@ -1,7 +1,7 @@ include ../make.inc all: - cd include && cp cblas_mangling_with_flags.h cblas_mangling.h + cd include && cp cblas_mangling_with_flags.h.in cblas_mangling.h cd src && $(MAKE) all diff --git a/CBLAS/include/cblas_mangling_with_flags.h b/CBLAS/include/cblas_mangling_with_flags.h.in similarity index 100% rename from CBLAS/include/cblas_mangling_with_flags.h rename to CBLAS/include/cblas_mangling_with_flags.h.in diff --git a/LAPACKE/Makefile b/LAPACKE/Makefile index 31ddcd7a5d..2eedab2368 100644 --- a/LAPACKE/Makefile +++ b/LAPACKE/Makefile @@ -45,7 +45,7 @@ include ../make.inc all: lapacke lapacke: - cd include && cp lapacke_mangling_with_flags.h lapacke_mangling.h + cd include && cp lapacke_mangling_with_flags.h.in lapacke_mangling.h cd src && $(MAKE) cd utils && $(MAKE) diff --git a/LAPACKE/include/lapacke_mangling_with_flags.h b/LAPACKE/include/lapacke_mangling_with_flags.h deleted file mode 100644 index 6211fd144d..0000000000 --- a/LAPACKE/include/lapacke_mangling_with_flags.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef LAPACK_HEADER_INCLUDED -#define LAPACK_HEADER_INCLUDED - -#ifndef LAPACK_GLOBAL -#if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) -#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ -#elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) -#define LAPACK_GLOBAL(lcname,UCNAME) UCNAME -#elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) -#define LAPACK_GLOBAL(lcname,UCNAME) lcname -#else -#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ -#endif -#endif - -#endif - diff --git a/LAPACKE/include/lapacke_mangling.h b/LAPACKE/include/lapacke_mangling_with_flags.h.in similarity index 100% rename from LAPACKE/include/lapacke_mangling.h rename to LAPACKE/include/lapacke_mangling_with_flags.h.in From 2cf24483240fbe5d119b8f9b172d0d0b85d78819 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Mon, 4 Jul 2016 18:09:00 -0500 Subject: [PATCH 2/2] COMP: Improve introspection and header configuration Use CMake capabilities to test if the specified fortran and C compilers are compatible. Fail early if they are determined to be incompatible. Use CMake capabilities to generate platform specific header files, If CMake FortranCInterface_HEADER function fails to identify FortranCInterface_GLOBAL_FOUND or FortranCInterface_MODULE_FOUND, then fall back to the statically generated file that is used by Makefiles. --- CBLAS/CMakeLists.txt | 24 ++++++++++-------------- CBLAS/include/CMakeLists.txt | 2 +- LAPACKE/CMakeLists.txt | 29 +++++++++++++---------------- LAPACKE/include/CMakeLists.txt | 2 +- 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/CBLAS/CMakeLists.txt b/CBLAS/CMakeLists.txt index 95b3bf6e06..5dac73342d 100644 --- a/CBLAS/CMakeLists.txt +++ b/CBLAS/CMakeLists.txt @@ -5,22 +5,18 @@ set(LAPACK_INSTALL_EXPORT_NAME cblas-targets) # Create a header file cblas.h for the routines called in my C programs include(FortranCInterface) -FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/cblas_mangling.h +## Ensure that the fortran compiler and c compiler specified are compatible +FortranCInterface_VERIFY() +FortranCInterface_HEADER( ${LAPACK_BINARY_DIR}/include/cblas_mangling.h MACRO_NAMESPACE "F77_" SYMBOL_NAMESPACE "F77_" ) +if( NOT FortranCInterface_GLOBAL_FOUND OR NOT FortranCInterface_MODULE_FOUND) + message(WARNING "Reverting to pre-defined include/lapacke_mangling.h") + configure_file( include/lapacke_mangling_with_flags.h.in + ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h ) +endif () -# Old way to detect mangling -#include(FortranMangling) -#FORTRAN_MANGLING(CDEFS) -#set(CDEFS ${CDEFS} CACHE STRING "Fortran Mangling" FORCE) -#MESSAGE(STATUS "=========") - -# -------------------------------------------------- -# Compiler Flags -#ADD_DEFINITIONS( "-D${CDEFS}") - - -include_directories( include ) +include_directories( include ${LAPACK_BINARY_DIR}/include ) add_subdirectory(include) add_subdirectory(src) @@ -32,7 +28,7 @@ endforeach() endmacro() append_subdir_files(CBLAS_INCLUDE "include") -INSTALL( FILES ${CBLAS_INCLUDE} DESTINATION include ) +INSTALL( FILES ${CBLAS_INCLUDE} ${LAPACK_BINARY_DIR}/include/cblas_mangling.h DESTINATION include ) # -------------------------------------------------- if(BUILD_TESTING) diff --git a/CBLAS/include/CMakeLists.txt b/CBLAS/include/CMakeLists.txt index 06093f43f2..208733b272 100644 --- a/CBLAS/include/CMakeLists.txt +++ b/CBLAS/include/CMakeLists.txt @@ -1,3 +1,3 @@ -SET (CBLAS_INCLUDE cblas.h cblas_f77.h cblas_test.h cblas_mangling.h) +SET (CBLAS_INCLUDE cblas.h cblas_f77.h cblas_test.h ) file(COPY ${CBLAS_INCLUDE} DESTINATION ${LAPACK_BINARY_DIR}/include) diff --git a/LAPACKE/CMakeLists.txt b/LAPACKE/CMakeLists.txt index 4c61eaa04f..7208d53e55 100644 --- a/LAPACKE/CMakeLists.txt +++ b/LAPACKE/CMakeLists.txt @@ -3,21 +3,18 @@ enable_language(C) set(LAPACK_INSTALL_EXPORT_NAME lapacke-targets) -# Create a header file netlib.h for the routines called in my C programs +# Create a header file lapacke_mangling.h for the routines called in my C programs include(FortranCInterface) -FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/lapacke_mangling.h - MACRO_NAMESPACE "LAPACK_" - SYMBOL_NAMESPACE "LAPACK_" ) - -# Old way to detect mangling -#include(FortranMangling) -#FORTRAN_MANGLING(CDEFS) -#set(CDEFS ${CDEFS} CACHE STRING "Fortran Mangling" FORCE) -#MESSAGE(STATUS "=========") - -# -------------------------------------------------- -# Compiler Flags -#ADD_DEFINITIONS( "-D${CDEFS}") +## Ensure that the fortran compiler and c compiler specified are compatible +FortranCInterface_VERIFY() +FortranCInterface_HEADER( ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h + MACRO_NAMESPACE "LAPACK_" + SYMBOL_NAMESPACE "LAPACK_" ) +if( NOT FortranCInterface_GLOBAL_FOUND OR NOT FortranCInterface_MODULE_FOUND) + message(WARNING "Reverting to pre-defined include/lapacke_mangling.h") + configure_file( include/lapacke_mangling_with_flags.h.in + ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h ) +endif () if (WIN32 AND NOT UNIX) ADD_DEFINITIONS(-DHAVE_LAPACK_CONFIG_H -DLAPACK_COMPLEX_STRUCTURE) @@ -26,7 +23,7 @@ endif (WIN32 AND NOT UNIX) get_directory_property( DirDefs COMPILE_DEFINITIONS ) -include_directories( include ) +include_directories( include ${LAPACK_BINARY_DIR}/include ) add_subdirectory(include) add_subdirectory(src) add_subdirectory(utils) @@ -58,7 +55,7 @@ else (USE_XBLAS) endif(USE_XBLAS) lapack_install_library(lapacke) -INSTALL( FILES ${LAPACKE_INCLUDE} DESTINATION include ) +INSTALL( FILES ${LAPACKE_INCLUDE} ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h DESTINATION include ) if(BUILD_TESTING) add_subdirectory(example) diff --git a/LAPACKE/include/CMakeLists.txt b/LAPACKE/include/CMakeLists.txt index 80b269fb6d..fbcfbdd963 100644 --- a/LAPACKE/include/CMakeLists.txt +++ b/LAPACKE/include/CMakeLists.txt @@ -1,3 +1,3 @@ -SET (LAPACKE_INCLUDE lapacke.h lapacke_config.h lapacke_utils.h lapacke_mangling.h) +SET (LAPACKE_INCLUDE lapacke.h lapacke_config.h lapacke_utils.h ) file(COPY ${LAPACKE_INCLUDE} DESTINATION ${LAPACK_BINARY_DIR}/include)