利用Cmake集成ITK、VTK和MFC

Cmake命令详解博客:

http://www.cnblogs.com/coderfenghc/archive/2012/06/25/2562778.html

1.工程名称

2.1最低版本要求

2.2设置MFC标记

3.将MFC中所有资源文件加入SRCS(ITK和VTK结合还需要两个文件itkImageToVTKImageFilter.h和
itkImageToVTKImageFilter.txx)

4.链接WIN32库

5.包含ITK库、VTK库

6.为构建树添加包含路径

7.生成可执行文件

8.动态链接库

 

典型的MFC、ITK、VTK结合的CMakeLists:

PROJECT(MySystem)         #项目名称

# minimum version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

 

ADD_DEFINITIONS(-D_AFXDLL)
SET(CMAKE_MFC-FLAG 6)      #MFC标记

SET(MySystem_SRCS
       MainFrm.cpp
MainFrm.h
MySystem.cpp
MySystem.h
MySystem.rc


MySystemDoc.cpp
MySystemDoc.h
MySystemView.cpp
MySystemView.h


res/MySystem.ico

res/MySystem.rc2

res/MySystemDoc.ico
Resource.h
stdafx.cpp
stdafx.h
targetver.h

itkImageToVTKImageFilter.h
itkImageToVTKImageFilter.txx)

IF(WIN32)
   LINK_LIBRARIES(wsock32)
ENDIF(WIN32)

#FIND ITK
FIND_PACKAGE(ITK)
IF (ITK_FOUND)
 INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
 MESSAGE(FATAL_ERROR "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)


# adding VTK library
FIND_PACKAGE (VTK)
IF (VTK_FOUND)
   INCLUDE(${USE_VTK_FILE})
ELSE(VTK_FOUND)
 MESSAGE(FATAL_ERROR "Cannot build  without ITK.  Please set VTK_DIR.")
ENDIF(VTK_FOUND)


INCLUDE_DIRECTORIES(${VTKITK_SOURCE_DIR})
ADD_EXECUTABLE(MySystem WIN32 ${MySystem_SRCS})
Target_Link_Libraries( ${PROJECT_NAME}
${VTK_LIBRARIES} ${ITK_LIBRARIES}
                     )

 

你可能感兴趣的:(利用Cmake集成ITK、VTK和MFC)