Add support for CMake find_package() #106
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had a need for this and noticed that it's also a current issue (#99).
The end result is you can import UnitTest++ in your CMakeLists.txt via:
More can be done with this including adding proper version checking support but i'm not sure how to go about that with a minimum CMake version of 2.8.1 since I don't have much experience with it. There's an easier method with more recent versions of CMake using CMakePackageConfigHelpers module and setting the version in the project() call.
A more recent version of CMake would also allow setting the install include directory as part of the imported target meaning you can drop include_directories(${UTPP_INCLUDE_DIRS}) calls when linking the target.
Worth noting that the config file doesn't deal with changing '++' to 'pp' but it looks like the CMakeLists.txt has sort of broken that functionality since it was originally put in and i'm not sure if I should approach that issue here.