Skip to content

Commit

Permalink
CMake: use LIBS, refactor Lapack
Browse files Browse the repository at this point in the history
Now Lapack libraries are added to LIBS and that is used to link libdftatom.so
  • Loading branch information
certik committed Feb 26, 2014
1 parent 7132bb2 commit a235873
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Expand Up @@ -25,8 +25,14 @@ set(WITH_C_INTERFACE no
if (WITH_PYTHON)
set(WITH_C_INTERFACE yes)
endif ()

set(WITH_LAPACK no
CACHE BOOL "Build tests that depend on Lapack")
if(WITH_LAPACK)
find_package(Lapack REQUIRED)
set(LIBS ${LIBS} ${LAPACK_LIBRARIES})
endif()


if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
# gfortran
Expand Down Expand Up @@ -64,9 +70,13 @@ else ()
message("Fortran compiler flags: ${CMAKE_Fortran_FLAGS_RELEASE}")
endif ()
message("Installation prefix: ${CMAKE_INSTALL_PREFIX}")
message("LIBS: ${LIBS}")
if (WITH_PYTHON)
message("Python install path: ${PYTHON_INSTALL_PATH}")
endif ()
message("With C interface: ${WITH_C_INTERFACE}")
message("With Python: ${WITH_PYTHON}")
message("With Lapack: ${WITH_LAPACK}")
if (WITH_LAPACK)
message("LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}")
endif(WITH_LAPACK)
4 changes: 4 additions & 0 deletions cmake/FindLapack.cmake
@@ -0,0 +1,4 @@
set(LAPACK_LIBRARIES lapack blas)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Lapack DEFAULT_MSG LAPACK_LIBRARIES)
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -23,12 +23,16 @@ set(SRC
dftatom.f90
)

if(WITH_LAPACK)
set(SRC ${SRC} lapack.f90 interpolation.f90)
endif()

if(WITH_C_INTERFACE)
set(SRC ${SRC} c_dftatom.f90)
endif()

add_library(dftatom SHARED ${SRC})
target_link_libraries(dftatom)
target_link_libraries(dftatom ${LIBS})
install(TARGETS dftatom
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
Expand Down
12 changes: 3 additions & 9 deletions tests/double_min/CMakeLists.txt
Expand Up @@ -2,20 +2,14 @@ include_directories(${PROJECT_BINARY_DIR}/src)

project(double_min)

set(SRC
interpolation.f90 lapack.f90
)
add_library(double_min ${SRC})
add_dependencies(double_min dftatom)

add_executable(rmin_conv rmin_conv.f90)
target_link_libraries(rmin_conv dftatom double_min lapack blas)
target_link_libraries(rmin_conv dftatom)
add_test(rmin_conv ${PROJECT_BINARY_DIR}/rmin_conv)

add_executable(N_conv N_conv.f90)
target_link_libraries(N_conv dftatom double_min lapack blas)
target_link_libraries(N_conv dftatom)
add_test(N_conv ${PROJECT_BINARY_DIR}/N_conv)

add_executable(fd fd.f90)
target_link_libraries(fd dftatom double_min lapack blas)
target_link_libraries(fd dftatom)
add_test(fd ${PROJECT_BINARY_DIR}/fd)

0 comments on commit a235873

Please sign in to comment.