我正在努力将 ARPACK 添加到我在 Mac-OSX 下构建我的 Qt 项目的 myCMakeLists(见下文)文件中。 请注意,我通过“Macport”安装了 Armadillo 库,Qt 会自动识别它,而无需将其添加到 CMakeList 文件中。但由于我使用的是 Armadillo 的稀疏分解功能,Qt 要求我将 ARPACK 库链接到项目。我安装了 ARPACK 库,但我没有找到如何添加到我的 CMakeList 文件中。请问我该如何添加?
最佳答案
我通过将这些行添加到我的 CMakeList 来解决这个问题:
SET(ARMADILLO_INCLUDE_DIR "/Users/Anass/Downloads/armadillo-
6.600.4/include/")
SET(ARMADILLO_LIBRARIES "/Users/Anass/Downloads/armadillo-
6.600.4/libarmadillo.6.60.4.dylib")
SET(ARPACK_LIBRARIES "/opt/local/lib/libarpack.dylib")
...
IF(LAPACK_FOUND)
SET(LINK_LIBRARIES
${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}
${ARMADILLO_LIBRARIES} ${ARPACK_LIBRARIES})
ELSE()
SET(LINK_LIBRARIES ${ARMADILLO_LIBRARIES} ${ARPACK_LIBRARIES})
ENDIF()
MESSAGE("")
MESSAGE("STEP 3 : GENERATE COMPILATION PROCESS")
MESSAGE("")
include_directories(
${ARMADILLO_INCLUDE_DIR}
)
if(CMAKE_COMPILER_IS_GNUCXX)
message("adding c++11 support")
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
endif(CMAKE_COMPILER_IS_GNUCXX)
########################################################
SET(EXECUTABLE_OUTPUT_PATH ./bin)
MESSAGE("Add test cmake")
SET(test_cmake_SRCS
${CMAKE_SOURCE_DIR}/src/test_cmake.cpp
)
add_executable(test_cmake ${test_cmake_SRCS})
target_link_libraries(test_cmake ${LINK_LIBRARIES})
关于c++ - 在 Cmakelist 中添加 Arpack/Armadillo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35829372/