Skip to content

Commit bc3cb4d

Browse files
committed
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.
1 parent 9dd0968 commit bc3cb4d

File tree

4 files changed

+24
-31
lines changed

4 files changed

+24
-31
lines changed

CBLAS/CMakeLists.txt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,18 @@ set(LAPACK_INSTALL_EXPORT_NAME cblas-targets)
55

66
# Create a header file cblas.h for the routines called in my C programs
77
include(FortranCInterface)
8-
FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/cblas_mangling.h
8+
## Ensure that the fortran compiler and c compiler specified are compatible
9+
FortranCInterface_VERIFY()
10+
FortranCInterface_HEADER( ${LAPACK_BINARY_DIR}/include/cblas_mangling.h
911
MACRO_NAMESPACE "F77_"
1012
SYMBOL_NAMESPACE "F77_" )
13+
if( NOT FortranCInterface_GLOBAL_FOUND OR NOT FortranCInterface_MODULE_FOUND)
14+
message(WARNING "Reverting to pre-defined include/lapacke_mangling.h")
15+
configure_file( include/lapacke_mangling_with_flags.h.in
16+
${LAPACK_BINARY_DIR}/include/lapacke_mangling.h )
17+
endif ()
1118

12-
# Old way to detect mangling
13-
#include(FortranMangling)
14-
#FORTRAN_MANGLING(CDEFS)
15-
#set(CDEFS ${CDEFS} CACHE STRING "Fortran Mangling" FORCE)
16-
#MESSAGE(STATUS "=========")
17-
18-
# --------------------------------------------------
19-
# Compiler Flags
20-
#ADD_DEFINITIONS( "-D${CDEFS}")
21-
22-
23-
include_directories( include )
19+
include_directories( include ${LAPACK_BINARY_DIR}/include )
2420
add_subdirectory(include)
2521
add_subdirectory(src)
2622

@@ -32,7 +28,7 @@ endforeach()
3228
endmacro()
3329

3430
append_subdir_files(CBLAS_INCLUDE "include")
35-
INSTALL( FILES ${CBLAS_INCLUDE} DESTINATION include )
31+
INSTALL( FILES ${CBLAS_INCLUDE} ${LAPACK_BINARY_DIR}/include/cblas_mangling.h DESTINATION include )
3632

3733
# --------------------------------------------------
3834
if(BUILD_TESTING)

CBLAS/include/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SET (CBLAS_INCLUDE cblas.h cblas_f77.h cblas_test.h cblas_mangling.h)
1+
SET (CBLAS_INCLUDE cblas.h cblas_f77.h cblas_test.h )
22

33
file(COPY ${CBLAS_INCLUDE} DESTINATION ${LAPACK_BINARY_DIR}/include)

LAPACKE/CMakeLists.txt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@ enable_language(C)
33

44
set(LAPACK_INSTALL_EXPORT_NAME lapacke-targets)
55

6-
# Create a header file netlib.h for the routines called in my C programs
6+
# Create a header file lapacke_mangling.h for the routines called in my C programs
77
include(FortranCInterface)
8-
FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/lapacke_mangling.h
9-
MACRO_NAMESPACE "LAPACK_"
10-
SYMBOL_NAMESPACE "LAPACK_" )
11-
12-
# Old way to detect mangling
13-
#include(FortranMangling)
14-
#FORTRAN_MANGLING(CDEFS)
15-
#set(CDEFS ${CDEFS} CACHE STRING "Fortran Mangling" FORCE)
16-
#MESSAGE(STATUS "=========")
17-
18-
# --------------------------------------------------
19-
# Compiler Flags
20-
#ADD_DEFINITIONS( "-D${CDEFS}")
8+
## Ensure that the fortran compiler and c compiler specified are compatible
9+
FortranCInterface_VERIFY()
10+
FortranCInterface_HEADER( ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h
11+
MACRO_NAMESPACE "LAPACK_"
12+
SYMBOL_NAMESPACE "LAPACK_" )
13+
if( NOT FortranCInterface_GLOBAL_FOUND OR NOT FortranCInterface_MODULE_FOUND)
14+
message(WARNING "Reverting to pre-defined include/lapacke_mangling.h")
15+
configure_file( include/lapacke_mangling_with_flags.h.in
16+
${LAPACK_BINARY_DIR}/include/lapacke_mangling.h )
17+
endif ()
2118

2219
if (WIN32 AND NOT UNIX)
2320
ADD_DEFINITIONS(-DHAVE_LAPACK_CONFIG_H -DLAPACK_COMPLEX_STRUCTURE)
@@ -26,7 +23,7 @@ endif (WIN32 AND NOT UNIX)
2623

2724
get_directory_property( DirDefs COMPILE_DEFINITIONS )
2825

29-
include_directories( include )
26+
include_directories( include ${LAPACK_BINARY_DIR}/include )
3027
add_subdirectory(include)
3128
add_subdirectory(src)
3229
add_subdirectory(utils)

LAPACKE/include/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SET (LAPACKE_INCLUDE lapacke.h lapacke_config.h lapacke_utils.h lapacke_mangling.h)
1+
SET (LAPACKE_INCLUDE lapacke.h lapacke_config.h lapacke_utils.h )
22

33
file(COPY ${LAPACKE_INCLUDE} DESTINATION ${LAPACK_BINARY_DIR}/include)

0 commit comments

Comments
 (0)