初学CppUnit,有关cmake

早就听闻CppUnit是个好东西,奈何一直没有仔细研读,现在开始一步步来学习。

网上找了个例子,想先跑跑看看效果,卡在了cmake这一步。

原来cmake v2.8里还没有FindCppUnit这个模块,所幸已经有网友写出了一个可用的版本,先拿来借鉴一下.

 
     
#
#
Find the CppUnit includes and library
#
#
This module defines
#
CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc.
#
CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit.
#
CPPUNIT_FOUND, If false, do not try to use CppUnit.

# also defined, but not for general use are
#
CPPUNIT_LIBRARY, where to find the CppUnit library.
#
CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug mode.

FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit
/ TestCase.h
/ usr / local / include
/ usr / include
)

# With Win32, important to have both
IF(WIN32)
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
${CPPUNIT_INCLUDE_DIR}
/ .. / lib
/ usr / local / lib
/ usr / lib)
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd
${CPPUNIT_INCLUDE_DIR}
/ .. / lib
/ usr / local / lib
/ usr / lib)
ELSE(WIN32)
# On unix system, debug and release have the same name
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
${CPPUNIT_INCLUDE_DIR}
/ .. / lib
/ usr / local / lib
/ usr / lib)
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit
${CPPUNIT_INCLUDE_DIR}
/ .. / lib
/ usr / local / lib
/ usr / lib)
ENDIF(WIN32)

IF(CPPUNIT_INCLUDE_DIR)
IF(CPPUNIT_LIBRARY)
SET(CPPUNIT_FOUND
" YES " )
SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS})
SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY}
${CMAKE_DL_LIBS})
ENDIF(CPPUNIT_LIBRARY)
ENDIF(CPPUNIT_INCLUDE_DIR)

在自己的CMakeLists.txt中加上

 
     
set(MY_MODULE_PATH " /home/XXX/usr/share/cmake/Modules " )
# 这个是你放FindCppUnit.cmae的路径

LIST(APPEND CMAKE_MODULE_PATH ${MY_MODULE_PATH})

这样就可以使用find_package(CppUnit)了。

posted on 2011-06-08 16:44  闲人草堂 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/jtf-china/archive/2011/06/08/2075448.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值