Skip to content

Commit

Permalink
Fix CMakeLists when BLAS isn't found
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlevy committed May 19, 2018
1 parent c6bd095 commit 918e4e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ project (MAXENT)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
find_package(ALPSCore 2.0 REQUIRED)

list(APPEND LINK_ALL ${ALPSCore_LIBRARIES})
#note: LAPACK also finds BLAS
find_package(LAPACK)
if(LAPACK_FOUND AND USE_LAPACK)
set(HAVE_BLAS 1)
set(HAVE_LAPACK 1)
message(STATUS "Using LAPACK and BLAS routines for SVD")
list(APPEND LINK_ALL ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
else()
set(HAVE_BLAS 0)
set(HAVE_LAPACK 0)
Expand All @@ -23,6 +25,7 @@ include_directories("${PROJECT_BINARY_DIR}/config")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
message(STATUS "Finding packages, please stand by...")
find_package(GSL REQUIRED)
list(APPEND LINK_ALL ${GSL_LIBRARIES})

# new ALPSCore provides Eigen
if (NOT ALPSCore_HAS_EIGEN_VERSION)
Expand Down Expand Up @@ -56,22 +59,21 @@ set(LIB_FILES
)

ADD_LIBRARY(libmaxent ${LIB_FILES})
target_link_libraries(libmaxent
${ALPSCore_LIBRARIES} ${GSL_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} )
target_link_libraries(libmaxent ${LINK_ALL})
#remove default "lib" prefix
set_target_properties(libmaxent PROPERTIES PREFIX "")
#executable
add_executable(maxent
./src/maxent.cpp
)
target_link_libraries(maxent libmaxent ${ALPSCore_LIBRARIES} ${GSL_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
target_link_libraries(maxent libmaxent ${LINK_ALL})

#testing setup
option(Testing "Enable testing" ON)

if (Testing)
add_library(gtest ./test/gtest-all.cc ./test/gtest_main.cc)
list(APPEND LINK_ALL libmaxent ${ALPSCore_LIBRARIES} ${GSL_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
list(APPEND LINK_ALL libmaxent)
enable_testing(test)
add_subdirectory(test)
endif (Testing)
Expand Down

0 comments on commit 918e4e5

Please sign in to comment.