Skip to content

Commit 185eaee

Browse files
authored
Merge pull request #2 from hjmjohnson/ImproveCMakeBuilding
Improve c make building
2 parents 40a3b2f + 2cf2448 commit 185eaee

File tree

9 files changed

+27
-51
lines changed

9 files changed

+27
-51
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/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include ../make.inc
22

33
all:
4-
cd include && cp cblas_mangling_with_flags.h cblas_mangling.h
4+
cd include && cp cblas_mangling_with_flags.h.in cblas_mangling.h
55
cd src && $(MAKE) all
66

77

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: 13 additions & 16 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)
@@ -58,7 +55,7 @@ else (USE_XBLAS)
5855
endif(USE_XBLAS)
5956

6057
lapack_install_library(lapacke)
61-
INSTALL( FILES ${LAPACKE_INCLUDE} DESTINATION include )
58+
INSTALL( FILES ${LAPACKE_INCLUDE} ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h DESTINATION include )
6259

6360
if(BUILD_TESTING)
6461
add_subdirectory(example)

LAPACKE/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ include ../make.inc
4545
all: lapacke
4646

4747
lapacke:
48-
cd include && cp lapacke_mangling_with_flags.h lapacke_mangling.h
48+
cd include && cp lapacke_mangling_with_flags.h.in lapacke_mangling.h
4949
cd src && $(MAKE)
5050
cd utils && $(MAKE)
5151

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)

LAPACKE/include/lapacke_mangling_with_flags.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)