[Insight-users] Re: Re:Question on CMakeLists.txt

Ying Du duying at hotmail.com
Tue Aug 3 13:28:22 EDT 2004


Hi Yixun,

Thanks a lot for the help. 

My problem was that there are multiple ".cxx" files in the source directory, so I set a source directory in my CMakeLists.txt. I made a mistake when I included this source directory into the sentence "ADD_EXECUTABLE( ... )" before. I modified the CMakeLists.txt into the following, and it works fine now.

PROJECT( myProject )

INCLUDE_REGULAR_EXPRESSION(".*")

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)

INCLUDE_DIRECTORIES(
${myProject_SOURCE_DIR}
${myProject_BINARY_DIR}
)

SET(myProject_SRCS
  Registrator.cxx
  Optimizer.cxx
  Util.cxx
)

ADD_EXECUTABLE(MarquardtRegistration myProject_SRCS)

TARGET_LINK_LIBRARIES(myProject ITKNumerics ITKBasicFilters ITKIO)

Thanks again.

Ying

  ----- Original Message ----- 
  From: Yixun Liu 
  To: insight-users at itk.org ; duying at hotmail.com 
  Sent: Tuesday, August 03, 2004 7:04 AM
  Subject: Re:Question on CMakeLists.txt


  Hi,

  I am not familiar with cmake too, but I use a simple method which works fine.

  1.set up a new directory and create a cmake file and a main.cxx(can be empty)

  2.write the cmake as below:

  # This project is intended to be built outside the Insight source tree
  PROJECT(myProject)

  # 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)

  ADD_EXECUTABLE(myProject main.cxx )

  TARGET_LINK_LIBRARIES(myProject ITKCommon)

  3.run CmakeSetup and set the source dir to the dir including the cmake and the .cxx

  4.the binary dir can be same as the source, but I commend you set up another dir.

  Hope this helps!

  Yixun Liu





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20040803/b83cfa36/attachment.htm


More information about the Insight-users mailing list