[Insight-developers] FFTW as an external project?

Brad King brad.king at kitware.com
Fri Dec 17 11:52:52 EST 2010


On 12/17/2010 11:39 AM, kent williams wrote:
> Not sure on how to do the install step CMake-wise.  would this be
> sufficient?
> 
> install(FILES ${CMAKE_BINARY_DIR}/FFTW/lib/libfftw3.a
> DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
> install(FILES ${CMAKE_BINARY_DIR}/FFTW/include/fftw3.h
> DESTINATION ${CMAKE_INSTALL_PREFIX}/include)

Something like this might work:

  install(DIRECTORY ${CMAKE_BINARY_DIR}/FFTW DESTINATION .)

but it will install stale files from that directory if any
exist.

A better approach might be to invoke the FFTW installation
during the ITK installation by using install(SCRIPT) or
install(CODE) to add code to the ITK installation that
includes cmake_install.cmake from the top of the FFTW
build tree.

> 2. I don't know how to make the Algorithms library depend on the FFTW
> external project.  If I do a sequential build, FFTW does get built before
> everything else, but if I do a parallel build, FFTW builds concurrent with
> the rest of ITK.  This could definitely fail.

add_dependencies(ITKAlgorithms FFTW)

You should also consider bringing libfftw3 in as an imported
target:

  add_external_project(FFTW ...)
  add_library(fftw3 STATIC IMPORTED)
  set_property(TARGET fftw3 PROPERTY
    IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/FFTW/lib/${CMAKE_STATIC_LIBRARY_PREFIX}fft23${CMAKE_STATIC_LIBRARY_SUFFIX}
    )

Then you can write just

  target_link_libraries(ITKAlgorithms fftw3)

With (the future) CMake 2.8.4 you will also be able to do

  add_dependencies(fftw3 FFTW)

so that anything that links to the library automatically depends
on the FFTW external project target.

-Brad


More information about the Insight-developers mailing list