0

我正在做一个在 ITK中使用离散高斯图像过滤器的项目。我正在使用 CMake 来自动化构建过程,但似乎 CMake 在配置/生成步骤中遗漏了某些 ITK 库。我目前正在使用 ITK 库中的其他头文件,没有任何问题。该项目的 CMake 中没有配置错误消息。

我的项目的 CMakeLists.txt:

#PROJECT(REGISTRATION)
#
# List of source files
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# Top of file: the name of the program
PROJECT(MultiObjModelToUSReg)
INCLUDE_REGULAR_EXPRESSION("^.*$")

FIND_PACKAGE( ITK REQUIRED)
IF( ITK_FOUND )
    INCLUDE( ${USE_ITK_FILE} )
ENDIF( ITK_FOUND )


# Directories to search for #include (add more if needed) 
# (ITK is already included through the use of INCLUDE(${ITK_USE_FILE})
INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}
   src
)

# Name of the executable
#SET(MultiObjModelToUSReg MultiObjModelToUSReg_EXE) 

# All source files (only .cxx, not .h or .txx)
SET(MultiObjModelToUSReg_SRCS 
    src/Utilities.cpp 
    src/MultiObjModel.cpp
    src/USVolume.cpp
    src/Registration.cpp
    src/BoneProbabilityMap.cpp
    #src/MultiObjModelToUSRegistration.cpp
    #src/USRegistrationDialog.cpp   
    #src/MainPanel.cpp
    #src/ModelRegistration.cxx
)

#only .h files that use QT_ macros!
#SET(MultiObjModelToUSReg_HEADERS 
    #src/USRegistrationDialog.h 
    #src/MainPanel.h
    #src/ModelRegistration.h)

#SET(MultiObjModelToUSReg_FORMS 
    ##ui/USRegistrationDialog.ui 
    ##ui/MainPanel.ui
    #ui/ModelRegistration.ui)

#SET(MultiObjModelToUSReg_RESOURCES)


# These two lines will compile and link your executable
#ADD_EXECUTABLE(MultiObjModelToUSReg
    #${MultiObjModelToUSReg_EXE} 
    #${MultiObjModelToUSReg_SRCS}
    #${MultiObjModelToUSReg_HEADERS_MOC} 
        #${MultiObjModelToUSReg_FORMS_HEADERS} 
        #${MultiObjModelToUSReg_RESOURCES_RCC}
        #)



ADD_LIBRARY(MultiObjModelToUSReg STATIC ${MultiObjModelToUSReg_SRCS})
TARGET_LINK_LIBRARIES(MultiObjModelToUSReg ${ITK_LIBRARIES} )
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

ENABLE_TESTING()

INCLUDE(CTEST)
IF (BUILD_TESTING)
    ADD_SUBDIRECTORY (Test)
ENDIF (BUILD_TESTING)

CMake 的无错误输出:

Check for working C compiler using: Visual Studio 9 2008
Check for working C compiler using: Visual Studio 9 2008 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 9 2008
Check for working CXX compiler using: Visual Studio 9 2008 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Configuring done
Generating done

但是,当我在 Visual C++ 2008 中编译时:

1>------ Build started: Project: MultiObjModelToUSReg, Configuration: Debug Win32 ------
1>Compiling...
1>BoneProbabilityMap.cpp
1>..\src\BoneProbabilityMap.cpp(8) : fatal error C1083: Cannot open include file: 'itkDiscreteGaussianImageFilter.h': No such file or directory
1>Build log was saved at "file://c:\MultiObjModelToUSReg\bin\MultiObjModelToUSReg.dir\Debug\BuildLog.htm"
1>MultiObjModelToUSReg - 1 error(s), 0 warning(s)
2>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration 
========== Build: 0 succeeded, 1 failed, 12 up-to-date, 1 skipped ==========

虽然有一种解决方法可以将其手动配置到项目的配置中,但我需要与其他人协作,因此将构建过程自动化是理想的选择。

任何帮助将不胜感激!(我对 Stackoverflow 很陌生,如果我有不清楚的地方请告诉我)。

4

1 回答 1

1

您需要使用 ITK_BUILD_ALL_MODULES=ON 构建 ITK。

于 2013-05-15T11:57:48.680 回答