0

I am trying to make a self contained library whose dependencies are self contained.All installs are installed to <repo_dir>/libs//build. To find dependencies in cmake build system I use find_package. Because all installs are in a custom location I point I use HINTS to help out like so -

# CMake 3.16.3
# ../lib/Catch2/build is where Catch2Config.cmake is located
find_package(Catch2 REQUIRED HINTS "../lib/Catch2/build" NO_MODULE)
include_directories(tests)
add_executable(tests tests.cpp)
target_link_libraries(tests PRIVATE project_warnings project_options Catch2::Catch2)

I recognize that Catch2 likely doesn't need this as it is header only, however I am trying to learn what cmake is doing. The CMakeLists.txt above prints out

include could not find load file:                                                                                                   
    <repo_dir>/lib/Catch2/build/Catch2Targets.cmake                                                   │
Call Stack (most recent call first):                                                                                                  
  tests/CMakeLists.txt:1 (find_package)

It looks like a target file is needed as well. I cannot find one in the Catch2 repo. I am also trying the same process for folly, however it does not work for me either. Using the following in module mode for Boost worked. Why does it work?

set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/lib/boost_1_75_0/")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/lib/boost_1_75_0/libs")
find_package(Boost 1.60.0 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${Boost_LIBRARIES})

Could someone help to uncover my problems and how I should go about using

  1. Header only libraries
  2. Static lib binaries
  3. Self-Compiled Libraries

Whose resources are in unusual places?

  • Typically `Catch2Targets.cmake` package install files are _generated_ when installing the library from cmake. Generated [from here](https://github.com/catchorg/Catch2/blob/devel/CMakeLists.txt#L104), isn't that hard to find. – KamilCuk Dec 30 '20 at 22:47
  • @KamilCuk how do I tell CMake where it is? I would like to not move the Catch2Targets.cmake file, however it looks like the find_package is only looking in the HINT directory –  Dec 31 '20 at 00:29
  • Install the library, inspect the installed files, then hint to the installed location of that file. – KamilCuk Dec 31 '20 at 00:30

0 Answers0