CoryG
CoryG

Reputation: 2581

How to make a CMake package?

I'm attempting to make a CMake package for Crypto++ inclusion in CMake projects, this will end up in the noloader/cryptopp-cmake repo if it gets done.

The ultimate goal is to come up with a working cross-platform FindCryptoPP.cmake file which can be dropped in the Crypto++ source directory to do things like:

find_package(CryptoPP REQUIRED)
target_link_libraries(libbiocoin cryptopp-static)

Or:

find_package(CryptoPP REQUIRED)
target_link_libraries(libbiocoin cryptopp-shared)

In a finished application and have it "just work."

My current best solution within a CMake application is to build Crypto++ for the platform, stick the resulting archive or library in a lib directory, reference that within the CMakeLists.txt and pull it in that way, but of course that requires packaging a binary distribution of the compiled Crypto++ for every platform targeted by the application, which would be nasty to maintain and generally bad even if it weren't crypto code.

Upvotes: 3

Views: 501

Answers (1)

usr1234567
usr1234567

Reputation: 23294

It's better to provide a CMake configuration file. find_package will look for a configuration file if no FindFoo.cmake find script is provided. One advantage over a find script is that you won't end with different, maybe conflicting versions of the find script.

See https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html, especially the section Create Layout.

Upvotes: 1

Related Questions