This is my first time trying to do this, so this might be a bit of a newbie question. I'm running ubuntu/linux, and I have a C++ library called wmrde that I'm trying to make "installable" using CMake. So I have a CMakeLists.txt file set up so that if you run the cmake command from the command line, followed by "make install" it installs all of the library files to /usr/local/lib/wmrde/, installs the header files to /usr/local/include/wmrde/, and installs a wmrdeConfig.cmake file in /usr/local/lib/cmake/wmrde/. That much is all working correctly.
Now I have a separate project and want to be able to link against this wmrde library. So I put FIND_PACKAGE(wmrde) in the CMakeLists.txt file for this other project. But when I try to build it, I get an error:
Could not find a package configuration file provided by "wmrde" with any of the following names:
wmrdeConfig.cmake
wmrde-config.cmake
I checked, and the files /usr/local/lib/cmake/wmrde/wmrdeConfig.cmake and /usr/local/lib/cmake/wmrde/wmrdeConfigVersion.cmake both exist, so I'm not sure why this FIND_PACKAGE statement can't find it.
So my question is, am I missing a step in the installation? I'd prefer it if I could find a solution that only involves modifying this wmrde library, since I'll be sharing this library and want other people to be able to easily include it in their own projects.
This is the entirety of the CMakeLists.txt file for my library-- it's pretty simple:
# Setup
cmake_minimum_required(VERSION 2.8.11)
project(wmrde)
set(WMRDE_VERSION 1.0.0)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 11)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/wmrde")
# Building the library
add_library(wmrde SHARED
wmrde.cpp
)
# Installation stuff
FILE(GLOB headerFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
INSTALL(FILES ${headerFiles} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/wmrde")
INSTALL(TARGETS wmrde LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/wmrde")
SET(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/lib/cmake/wmrde")
CONFIGURE_FILE("wmrdeConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/wmrdeConfig.cmake")
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wmrdeConfig.cmake DESTINATION ${INSTALL_CMAKE_DIR})
CONFIGURE_FILE(wmrdeConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/wmrdeConfigVersion.cmake")
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wmrdeConfigVersion.cmake DESTINATION ${INSTALL_CMAKE_DIR})