[CMake] An interface targets/usage requirements example with automatic shared library handling! Take a look!

Walter Gray chrysalisx at gmail.com
Wed Jul 23 00:36:53 EDT 2014


Hey all,
You may have seen my earlier posts, "find_package" and INTERFACE targets 
in 3.0" and "Target usage requirements for shared libraries".  I've also 
seen Michael Darling's post "Package found - passing _INCLUDE_DIRS to 
include_directories() and _LIBRARIES to target_link_libraries()", so I'm 
assuming there's a fair bit of interest in this topic.

After wrestling with it for about a week, I've got a solution that I 
think works very well, and demonstrates how to properly make use of 
INTERFACE and IMPORTED targets with the new Usage Requirements 
Paradigm.  I've made a couple of helper functions for generating 
interface targets from the information exported by Find modules, as well 
as a couple of example find modules demonstrating their use with pure 
header, static, and shared libraries, and even one which uses a master 
INTERFACE target to control link library ordering. I've put the files up 
on github for you guys to take a look at.  I would really appreciate any 
feedback you may have on how I could make it any clearer or further 
reduce code duplication between the find modules.

https://github.com/wal-rus/cmake-modules


More information about the CMake mailing list