I have OpenBLAS checked out as a Git submodule in thirdparty/OpenBLAS
. With
add_subdirectory("${PROJECT_SOURCE_DIR}/thirdparty/OpenBLAS")
in CMakeLists.txt
it successfully configures and builds. But
target_link_libraries(encoder_sample fused_transformer OpenBLAS::OpenBLAS OpenMP::OpenMP_CXX ${CMAKE_THREAD_LIBS_INIT})
fails to find the target:
Target "encoder_sample" links to target "OpenBLAS::OpenBLAS" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
If it matters, I am using Visual Studio 2019 with WSL. I expect that I am missing something trivial, just can't figure out what...
Because you are configuring and building OpenBLAS as part of your CMake project, the IMPORTED
target OpenBLAS::OpenBLAS
is not available. The imported target is defined by the OpenBLASConfig.cmake
configuration file, typically used in conjunction with find_package(OpenBLAS ...)
command, after you have installed OpenBLAS on your machine. In your case, you can use the OpenBLAS CMake target directly, as defined their CMake files.
Assuming your OpenBLAS repository is similar to this GitHub repo, the CMake target is defined here:
set(OpenBLAS_LIBNAME openblas${SUFFIX64_UNDERSCORE}) ... add_library(${OpenBLAS_LIBNAME} ${LA_SOURCES} ${LAPACKE_SOURCES} ${RELA_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE})
So the target name you want to use will be openblas
or openblas_64
, depending on your target architecture. So for a 64-bit build, you can try this:
target_link_libraries(encoder_sample fused_transformer openblas_64 OpenMP::OpenMP_CXX ${CMAKE_THREAD_LIBS_INIT})