Skip to content

Commit

Permalink
Add proper pkg-config detection of bml library
Browse files Browse the repository at this point in the history
The bml library is installed with a pkg-config file. This patch searches
for this file and uses the settings in it to configure bml library
locations.
  • Loading branch information
nicolasbock committed Mar 13, 2017
1 parent 8d60072 commit 3d61514
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 43 deletions.
74 changes: 74 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,80 @@ if(CMAKE_Fortran_FLAGS STRGREATER "")
message(STATUS "Using user supplied Fortran compiler flags ${CMAKE_Fortran_FLAGS}")
endif()

pkg_check_modules(BML bml REQUIRED)
list(APPEND LINK_LIBRARIES ${BML_LDFLAGS})

set(BLAS_VENDOR ""
CACHE STRING "If set, the preferred BLAS/LAPACK vendor. Possible choices: {Intel,MKL,ACML}")

if(BLAS_VENDOR STREQUAL "Intel" OR BLAS_VENDOR STREQUAL "MKL")
message(STATUS "Attempting to use Intel's BLAS/LAPACK (MKL)")
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
if(BML_OPENMP)
set(BLAS_LIBRARIES "-L${MKLROOT}/lib/intel64"
-lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -lpthread -lm)
else()
set(BLAS_LIBRARIES "-L${MKLROOT}/lib/intel64"
-lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm)
endif()
else()
if(BML_OPENMP)
set(BLAS_LIBRARIES -Wl,--no-as-needed "-L${MKLROOT}/lib/intel64"
-lmkl_lapack95_lp64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm)
else()
set(BLAS_LIBRARIES -Wl,--no-as-needed "-L${MKLROOT}/lib/intel64"
-lmkl_lapack95_lp64 -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lmkl_sequential -lmkl_core -lpthread -lm)
endif()
endif()
set(BLAS_FOUND TRUE)
set(LAPACK_FOUND TRUE)
elseif(BLAS_VENDOR STREQUAL "ACML")
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
if(BML_OPENMP)
set(BLAS_LIBRARIES "-L$ENV{ACML_DIR}/ifort64_mp/lib" -lacml_mp)
else()
set(BLAS_LIBRARIES "-L$ENV{ACML_DIR}/ifort64/lib" -lacml)
endif()
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU"
OR CMAKE_Fortran_COMPILER_ID STREQUAL "PathScale")
if(BML_OPENMP)
set(BLAS_LIBRARIES "-L$ENV{ACML_DIR}/gfortran64_mp/lib" -lacml_mp)
else()
set(BLAS_LIBRARIES "-L$ENV{ACML_DIR}/gfortran64/lib" -lacml)
endif()
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
if(OPENMP)
set(BLAS_LIBRARIES "-L$ENV{ACML_DIR}/pgi64_mp/lib" -lacml_mp)
else()
set(BLAS_LIBRARIES "-L$ENV{ACML_DIR}/pgi64/lib" -lacml)
endif()
endif()
set(BLAS_FOUND TRUE)
set(LAPACK_FOUND TRUE)
elseif(BLAS_VENDOR STREQUAL "GNU")
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(BLAS_LIBRARIES -llapack -lblas)
endif()
set(BLAS_FOUND TRUE)
set(LAPACK_FOUND TRUE)
endif()

if(NOT (BLAS_LIBRARIES OR BLAS_FOUND))
include(FindBLAS)
if(NOT BLAS_FOUND)
message(FATAL_ERROR "Can not find suitable BLAS library")
endif()
endif()

if(NOT (LAPACK_LIBRARIES OR LAPACK_FOUND))
include(FindLAPACK)
if(NOT LAPACK_FOUND)
message(FATAL_ERROR "Can not find suitable LAPACK library")
endif()
endif()

list(APPEND LINK_LIBRARIES ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})

set(PROGRESS_OPENMP TRUE CACHE BOOL "Whether to compile with OpenMP support")
if(PROGRESS_OPENMP)
include(FindOpenMP)
Expand Down
2 changes: 0 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ include_directories(${CMAKE_SOURCE_DIR}/tests/src)
include_directories(${CMAKE_SOURCE_DIR}/build/src)
include_directories(${BML_INCLUDEDIR})

list(APPEND LINK_LIBRARIES "-L${BML_LIBDIR} -l${BML_LIBRARIES}")

function(progress_example myexample path_to_example)
add_executable(${myexample} ${path_to_example})
target_link_libraries(${myexample} progress ${LINK_LIBRARIES})
Expand Down
79 changes: 39 additions & 40 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,43 @@ install(TARGETS progress
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(FILES
charges_mod.mod
densitymatrix_mod.mod
dos_mod.mod
extras_mod.mod
genz_mod.mod
graph_mod.mod
graph_sp2parser_mod.mod
homolumo_mod.mod
initmatrices_mod.mod
kernelparser_mod.mod
nonortho_mod.mod
normalize_mod.mod
openfiles_mod.mod
parallel_mod.mod
partition_mod.mod
progress_mod.mod
ptable_mod.mod
pulaycomponent_mod.mod
pulaymixer_mod.mod
response_mod.mod
sp2_fermi_mod.mod
sp2_mod.mod
sp2parser_mod.mod
subgraphloop_mod.mod
system_mod.mod
timer_mod.mod
xlbo_mod.mod
# LATTE modes
coulomb_latte_mod.mod
latteparser_latte_mod.mod
ham_latte_mod.mod
hsderivative_latte_mod.mod
huckel_latte_mod.mod
md_latte_mod.mod
neighborlist_latte_mod.mod
nonorthocoulombforces_latte_mod.mod
slaterkosterforce_latte_mod.mod
physmathconst_latte_mod.mod
ppot_latte_mod.mod
tbparams_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/charges_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/densitymatrix_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/dos_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/extras_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/genz_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/graph_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/graph_sp2parser_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/homolumo_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/initmatrices_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/kernelparser_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/nonortho_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/normalize_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/openfiles_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/parallel_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/partition_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/progress_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/ptable_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/pulaycomponent_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/pulaymixer_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/response_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/sp2_fermi_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/sp2_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/sp2parser_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/subgraphloop_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/system_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/timer_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/xlbo_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/coulomb_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/latteparser_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/ham_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/hsderivative_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/huckel_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/md_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/neighborlist_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/nonorthocoulombforces_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/slaterkosterforce_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/physmathconst_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/ppot_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/tbparams_latte_mod.mod
DESTINATION include)
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ add_executable(main
src/main.F90
src/test_subgraphloop.F90)

list(APPEND LINK_LIBRARIES "-L${BML_LIBDIR} -l${BML_LIBRARIES}")
target_link_libraries(main progress ${LINK_LIBRARIES})

set_target_properties(main
Expand Down

0 comments on commit 3d61514

Please sign in to comment.