Merge pull request #71 from advanpix/master
[platform/upstream/lapack.git] / LAPACKE / CMakeLists.txt
1 message(STATUS "LAPACKE enable")
2 enable_language(C)
3
4 set(LAPACK_INSTALL_EXPORT_NAME lapacke-targets)
5
6 # Create a header file lapacke_mangling.h for the routines called in my C programs
7 include(FortranCInterface)
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 ()
18
19 if (WIN32 AND NOT UNIX)
20  add_definitions(-DHAVE_LAPACK_CONFIG_H -DLAPACK_COMPLEX_STRUCTURE)
21  message (STATUS "Windows BUILD")
22 endif ()
23
24 get_directory_property( DirDefs COMPILE_DEFINITIONS )
25
26 include_directories( include ${LAPACK_BINARY_DIR}/include )
27 add_subdirectory(include)
28 add_subdirectory(src)
29 add_subdirectory(utils)
30
31 macro(append_subdir_files variable dirname)
32 get_directory_property(holder DIRECTORY ${dirname} DEFINITION ${variable})
33 foreach(depfile ${holder})
34   list(APPEND ${variable} "${dirname}/${depfile}")
35 endforeach()
36 endmacro()
37
38 append_subdir_files(LAPACKE_INCLUDE "include")
39 append_subdir_files(SRC_OBJ "src")
40 append_subdir_files(SRCX_OBJ "src")
41 append_subdir_files(MATGEN_OBJ "src")
42 append_subdir_files(UTILS_OBJ "utils")
43
44 if (USE_XBLAS)
45    add_library(lapacke ${SRC_OBJ} ${SRCX_OBJ} ${UTILS_OBJ})
46    target_link_libraries(lapacke ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${XBLAS_LIBRARY})
47 else ()
48   if (LAPACKE_WITH_TMG)
49    add_library(lapacke ${SRC_OBJ} ${MATGEN_OBJ} ${UTILS_OBJ})
50    target_link_libraries(lapacke tmglib ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
51   else ()
52    add_library(lapacke ${SRC_OBJ} ${UTILS_OBJ})
53    target_link_libraries(lapacke ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
54   endif()
55 endif()
56
57 lapack_install_library(lapacke)
58 install( FILES ${LAPACKE_INCLUDE} ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h DESTINATION include )
59
60 if(BUILD_TESTING)
61    add_subdirectory(example)
62 endif()
63
64
65 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapacke.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapacke.pc @ONLY)
66  install(FILES
67   ${CMAKE_CURRENT_BINARY_DIR}/lapacke.pc
68   DESTINATION ${PKG_CONFIG_DIR}
69    )
70
71 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/lapacke-config-version.cmake.in
72   ${LAPACK_BINARY_DIR}/lapacke-config-version.cmake @ONLY)
73 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/lapacke-config-build.cmake.in
74   ${LAPACK_BINARY_DIR}/lapacke-config.cmake @ONLY)
75
76 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/lapacke-config-install.cmake.in
77   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/lapacke-config.cmake @ONLY)
78 install(FILES
79   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/lapacke-config.cmake
80   ${LAPACK_BINARY_DIR}/lapacke-config-version.cmake
81   DESTINATION ${LIBRARY_DIR}/cmake/lapacke-${LAPACK_VERSION}
82   )
83
84 install(EXPORT lapacke-targets
85   DESTINATION ${LIBRARY_DIR}/cmake/lapacke-${LAPACK_VERSION})