[CMake] PKG_CHECK_MODULES cppunit

Philip Lowman philip at yhbt.com
Sat May 17 10:58:14 EDT 2008


On Sat, May 17, 2008 at 10:28 AM, Michael Bowerman <
michael.bowerman at gmail.com> wrote:

> List,
>
> I am trying to use cppunit for my automated tests.  I have the project
> compiling with autotools.  But, I am moving to cmake to build on windows
> (while the project is still small-ish).
>
> So, is the proper way to look for CppUnit to use pkg_check_modules?


Only if CppUnit is only meant to work only with the GCC compiler or you will
only ever use the GCC compiler.  If there is a chance you'll want to compile
your code with MSVC or some other compiler or you wish to contribute your
find modules back to CMake you should consider using the find_library() and
find_path() commands to locate the cppunit header files and library.

This is usually fairly simple to do and most people encapsulate this
activity in a Find* macro.  Looks like someone has already done some work to
make a FindCppUnit macro but it never got cleaned up and checked into CMake.

http://www.cmake.org/pipermail/cmake/2006-October/011446.html

Just set your CMAKE_MODULE_PATH and call FIND_PACKAGE(CppUnit) and then
react accordingly based on the cache variables it provides.  You should
probably also take advantage of CPPUNIT_FOUND in determining if it's
appropriate to build and link the test code.

Depending on how many test executables you have, you may want to make a
small macro wrapper that calls ADD_EXECUTABLE() then ADD_TEST() that way you
can keep your CMake code to a minimum.

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080517/7bc1d15f/attachment.htm>


More information about the CMake mailing list