Derecho-Project / derecho

The main code repository for the Derecho project.
BSD 3-Clause "New" or "Revised" License
186 stars 47 forks source link

Small improvements to CMakeLists #255

Closed etremel closed 1 year ago

etremel commented 1 year ago

It turns out nothing in the Derecho code uses mutils-tasks any more, so we don't need to be requiring it in CMakeLists or supplying a prerequisite script to install it. Also, now that mutils and mutils-containers have newer CMake package files that provide export targets (see mpmilano/mutils#4 and mpmilano/mutils-containers#2), we can use the simple find_package() and depend on mutils::mutils instead of ${mutils_LIBRARIES}.

While double-checking how to use the CMake incantations for package configurations, I learned that the ConfigPackageLocation variable should depend on ${CMAKE_INSTALL_LIBDIR} instead of explicitly writing lib/ as the prefix, and that it doesn't matter if the ${CURRENT_BINARY_DIR} location of the derechoConfig files has the same directory structure as their installed location in lib/cmake/derecho. I also learned that the derechoConfig.cmake template can use ${CMAKE_CURRENT_LIST_DIR} to get the location of derechoTargets.cmake, since those two files will always get installed to the same directory.

Finally, I discovered that CMake targets-style dependencies are not automatically "forwarded" to other projects that use Derecho, which means find_package(derecho) can succeed but then produce an error like "target links to mutils::mutils but it could not be found." To fix this, each CMake target listed in target_link_libraries(derecho) must be listed again in derechoConfig.cmake with a call to find_dependency, e.g. find_dependency(mutils).