Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake error Cannot specify link libraries for target "xtensor-blas" which is not built #169

Open
pnarvor opened this issue Jun 26, 2020 · 13 comments · May be fixed by #193
Open

cmake error Cannot specify link libraries for target "xtensor-blas" which is not built #169

pnarvor opened this issue Jun 26, 2020 · 13 comments · May be fixed by #193

Comments

@pnarvor
Copy link

pnarvor commented Jun 26, 2020

I tried to compile a small test with xtensor-blas but I can't get cmake to configure properly. I installed xtensor-blas using cmake in a user directory pointed by CMAKE_PREFIX_PATH. The xtensor-blasConfig.cmake is found but i get the following error :

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Creating xtensor-blas target
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- A library with BLAS API found.
-- A library with BLAS API found.
-- Looking for cheev_
-- Looking for cheev_ - found
-- A library with LAPACK API found.
-- xtensor-blas target exists   # checks I added into xtensor-blas cmake 
CMake Error at /home/narvorpi/work/narval/soft/install/lib/cmake/xtensor-blas/xtensor-blasConfig.cmake:53 (target_link_libraries):
  Cannot specify link libraries for target "xtensor-blas" which is not built
  by this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/narvorpi/work/narval/code/narval_tbn/cxx/narval_tools/build/CMakeFiles/CMakeOutput.log".
See also "/home/narvorpi/work/narval/code/narval_tbn/cxx/narval_tools/build/CMakeFiles/CMakeError.log".

Seems like the target is created in xtensor-blasTargets.cmake, the xtensor-blasConfig.cmake sees the target but for a reason this line fails.

target_link_libraries(xtensor-blas INTERFACE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})

Any ideas ?

@tdegeus
Copy link
Member

tdegeus commented Jun 29, 2020

Can you include more details:

  • What does you CMakeLists.txt look like?
  • What command do you use to execute CMake?
  • What version CMake do you use?
  • What command did you use to install?
  • What does the line # checks I added into xtensor-blas cmake mean?

@pnarvor
Copy link
Author

pnarvor commented Jun 29, 2020

Hello, sorry for the lack of details.

Cmake version : 3.10 (from ubuntu 18.04 package manager).
My CMakeLists (I commented the rest of the CMakeLists.txt when I tried to debug, I still had the same issue):

cmake_minimum_required(VERSION 3.10)
project(cmake_test VERSION 0.1)

find_package(Eigen3  REQUIRED)
find_package(xtensor REQUIRED)
find_package(xtensor-blas REQUIRED)

cmake command : mkdir build && cd build && cmake ..

For xtensor-blas installation :

git clone https://github.com/xtensor-stack/xtensor-blas.git
cd xtensor-blas
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/home/narvorpi/work/narval/soft/install ..
make install

content of CMAKE_PREFIX_PATH : /home/narvorpi/work/narval/soft/install

# checks I added into xtensor-blas cmake : I added some lines to /home/narvorpi/work/narval/soft/install/lib/cmake/xtensor-blasConfig.cmake:45 to check if the target xtensor-blas was effectively created :

if(NOT TARGET xtensor-blas)
  include("${CMAKE_CURRENT_LIST_DIR}/xtensor-blasTargets.cmake")
  if(NOT TARGET xtensor-blas)
    message(STATUS "No xtensor-blas target")
  else()
    message(STATUS "xtensor-blas target exists") # this is displayed on configure
  endif()
  get_target_property(xtensor-blas_INCLUDE_DIRS xtensor-blas INTERFACE_INCLUDE_DIRECTORIES)
  find_dependency(BLAS REQUIRED)
  find_dependency(LAPACK REQUIRED)
  target_link_libraries(xtensor-blas INTERFACE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}) #this is le line which fails
  if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.8)
    target_compile_features(xtensor-blas INTERFACE cxx_std_14)
  endif()
endif()

@pnarvor
Copy link
Author

pnarvor commented Jun 29, 2020

I finally managed to make it work, but I had to edit the xtensor-blasConfig.cmake. However I am by no means a cmake wizard, so I really don't understand why this works but not the original code.
I xtensor-blasConfig.cmake, I replaced the following lines:

if(NOT TARGET xtensor-blas)
  include("${CMAKE_CURRENT_LIST_DIR}/xtensor-blasTargets.cmake")
  get_target_property(xtensor-blas_INCLUDE_DIRS xtensor-blas INTERFACE_INCLUDE_DIRECTORIES)
  find_dependency(BLAS REQUIRED)
  find_dependency(LAPACK REQUIRED)
  target_link_libraries(xtensor-blas INTERFACE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}) #this is le line which fails
  if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.8)
    target_compile_features(xtensor-blas INTERFACE cxx_std_14)
  endif()
endif()

by these ones:

if(NOT TARGET xtensor-blas)
  include("${CMAKE_CURRENT_LIST_DIR}/xtensor-blasTargets.cmake")
  get_target_property(xtensor-blas_INCLUDE_DIRS xtensor-blas INTERFACE_INCLUDE_DIRECTORIES)
  find_dependency(BLAS REQUIRED)
  find_dependency(LAPACK REQUIRED)
  # target_link_libraries(xtensor-blas INTERFACE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
  message(STATUS "${BLAS_LIBRARIES};${LAPACK_LIBRARIES}")
  set_target_properties(xtensor-blas PROPERTIES 
    INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES};${LAPACK_LIBRARIES}"
  )
  if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.8)
    # target_compile_features(xtensor-blas INTERFACE cxx_std_14)
    set_target_properties(xtensor-blas PROPERTIES
        INTERFACE_COMPILE_FEATURES cxx_std_14
    )
  endif()
endif()

If you can throw some light on this, I would really appreciate it.

@tdegeus
Copy link
Member

tdegeus commented Jun 29, 2020

I think it has to do with your CMake version not accepting a more modern CMake version. You did exactly the same as what there was before with simple a different 'syntax'. To increase robustness we could update the CMake config with your code, possibly with a switch based on the CMake version.

@tdegeus
Copy link
Member

tdegeus commented Jun 29, 2020

At the same time, it might be worth updating your CMake.

@pnarvor
Copy link
Author

pnarvor commented Jun 29, 2020

Ok. Thanks for your reply. I will look into it.

However, shouldn't the cmake_minimum_required(VERSION 3.1) in xtensor-blas contains a more recent version then ? (unless you update the xtensor-blasConfig of course).

@JohanMabille
Copy link
Member

Indeed we should keep the minimum required version consistent with the implementation. I think this requirement was left because of old versions of Ubuntu which should not be so much used now.

@pnarvor
Copy link
Author

pnarvor commented Jun 29, 2020

Ok. Thank you for your help !

@tdegeus
Copy link
Member

tdegeus commented Jun 29, 2020

@JohanMabille Do you know which CMake version supports what in terms of the target? I have seen this this problem before in several libraries, but I cannot find the right details in the CMake documentation.

@JohanMabille
Copy link
Member

JohanMabille commented Jun 29, 2020

Not really, I need to do some cmake archeology. We also need to check which version of cmake is installed on "recent" release of Ubuntu (or check if updating CMake on Ubuntu is still a nightmare).

@tdegeus
Copy link
Member

tdegeus commented Jun 29, 2020

I'm still so surprised that such old CMake's are shipped... But ok, we should deal with it.

@pnarvor
Copy link
Author

pnarvor commented Jun 29, 2020

Not really, I need to do some cmake archeology. We also need to check which version of cmake is installed on "recent" release of Ubuntu (or check if updating CMake on Ubuntu is still a nightmare).

fyi, I installed cmake from sources and it worked right away. (I installed on user side though. I did not try to update the system-installed cmake). Also, it solved the issue above.

@jonathonl
Copy link
Contributor

Both target_link_libraries() and target_compile_features() are supposed to be in the lists file (not the config file). I created a PR (#193) to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants