[CMake] Tips to create a UseXYZ.cmake

Michael Wild themiwi at gmail.com
Thu Jan 28 15:01:01 EST 2010


On 28. Jan, 2010, at 19:01 , Anton Deguet wrote:

> Hello,
> 
> Besides digging in the existing UseVTK, UseITK, UseOpenIGTLing, ... is there a short description of the philosophy and basic commands to  use?   Any pointer is welcome.  This would be for a project with multiple external dependencies, i.e. libxml, openCV, Python, numpy, ...
> 
> Thanks,
> 
> Anton

I usually do it like this:

XYZConfig.cmake:
- import targets
- deal with version requirements and COMPONENTS
- define variables, such as XYZ_INCLUDE_DIR, XYZ_LIBRARIES, XYZ_COMPILE_FLAGS and XYZ_USE_FILE
- anything else to make it work like a FindXYZ.cmake module, just the bare minimum

XYZUse.cmake (or UseXYZ.cmake):
- perhaps call include_directories (personally I don't like this)
- call add_definitions if required
- define useful macros/functions (such as qt4_wrap_ui)
- anything else that makes working with XYZ comfortable


If you don't plan on calling include_directories and add_definitions (and similar) in your USE-file and the macros/functions are few and short, it might be reasonable to put them in the CONFIG-file directly.


HTH

Michael


More information about the CMake mailing list