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

Unable to install the library using provided CMakeLists.txt #2

Closed
alphahmed opened this issue Sep 11, 2020 · 3 comments
Closed

Unable to install the library using provided CMakeLists.txt #2

alphahmed opened this issue Sep 11, 2020 · 3 comments

Comments

@alphahmed
Copy link

Library installation instructions would be greatly appreciated!

Upon trying to install the library using cmake... The following results:

-- The CXX compiler identification is GNU 8.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.7")
-- Found BZip2: /usr/lib64/libbz2.so (found version "1.0.6")
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- 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
CMake Error at CMakeLists.txt:17 (add_library):
  add_library INTERFACE library requires no source arguments.


CMake Error at CMakeLists.txt:19 (target_sources):
  Cannot specify sources for target "kseq++" which is not built by this
  project.


CMake Error at CMakeLists.txt:21 (target_include_directories):
  Cannot specify include directories for target "kseq++" which is not built
  by this project.


CMake Error at CMakeLists.txt:28 (target_link_libraries):
  Cannot specify link libraries for target "kseq++" which is not built by
  this project.


-- Configuring incomplete, errors occurred!

@cartoonist
Copy link
Owner

add_library call at line 17 of CMakeLists.txt does not specify any source arguments:

add_library(kseq++ INTERFACE)

So, I cannot understand why it complains about it. Other three errors (lines 19, 21, and 28) are because of failing to define target kseq++ at line 17.

Which version of CMake are you using? What happens if you comment out line 19 since this line is the only line providing source arguments?

@cartoonist
Copy link
Owner

cartoonist commented Sep 14, 2020

Regarding installation guide, I am going to include some guides and examples. Meanwhile, the usual way should work with CMake 3.13+:

$ mkdir build
$ cd build
$ cmake /path/to/kseq++
$ make
$ sudo make install

Since it is a header-only library, there is nothing to build except generating the config.h for version management and pkg-config file kseq++.pc. And, make install only copies required files to the usual destinations.

If you are using CMake in your project, you can alternatively include the library in your source tree as a git submodule. Then, calling add_subdirectory(/path/to/kseq++) in your CMakeLists.txt will define kseq++::kseq++ target which can be used to link kseq++ library to your executable or library. For example:

add_subdirectory(ext/kseq++)
add_executable(your_target main.cpp)
target_include_directories(your_target PUBLIC kseq++::kseq++)
target_link_libraries(your_target PUBLIC kseq++::kseq++)

@alphahmed
Copy link
Author

Thank you!
It all worked out fine, using cmake 3.18.0-rc1

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

No branches or pull requests

2 participants