[CMake] cmake to download and compile fftw library

Jorge Perez josp.jorge at gmail.com
Fri May 19 07:57:22 EDT 2017


Hi, here you have a working example for your requirement. Attached also a
zip file to test.

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(PROSE)
################################################################

include(ExternalProject)

MESSAGE(STATUS "Trying to install fftw...")

ExternalProject_Add(project_fftw
  #GIT_REPOSITORY  https://github.com/FFTW/fftw3
  URL http://www.fftw.org/fftw-3.3.2.tar.gz
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fftw
  CONFIGURE_COMMAND
${CMAKE_CURRENT_BINARY_DIR}/fftw/src/project_fftw/configure
--prefix=${CMAKE_CURRENT_BINARY_DIR}/fftw/install
  INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/fftw/install
  )

add_library(fftw STATIC IMPORTED)
set(lib_fftw_name
${CMAKE_STATIC_LIBRARY_PREFIX}fftw3${CMAKE_STATIC_LIBRARY_SUFFIX})
set_target_properties(fftw PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_BINARY_DIR}/fftw/install/lib/${lib_fftw_name})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/fftw/install/include)

add_executable(prose src/read.cpp)
add_dependencies(prose project_fftw)

TARGET_LINK_LIBRARIES(prose fftw)

HTH

Jorge


2017-05-19 7:06 GMT+02:00 aishwarya selvaraj <
aishwaryaselvaraj1708 at gmail.com>:

> Hi all,
> I have written the below cmakelist.txt .
>
>
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
> PROJECT(PROSE)
> ################################################################
>
> include(ExternalProject)
> MESSAGE(STATUS "Trying to install fftw...")
>
> ExternalProject_Add(project_fftw
>   #GIT_REPOSITORY  https://github.com/FFTW/fftw3
>   URL "http://www.fftw.org/fftw-3.3.2.tar.gz"
>   PREFIX ${CMAKE_CURRENT_BINARY_DIR}/fftw
>   CONFIGURE_COMMAND ""
>     #--Build step-----------------
>   BUILD_COMMAND ""
>     #--Install step---------------
>   UPDATE_COMMAND "" # Skip annoying updates for every build
>   INSTALL_COMMAND ""
>  )
>
> ADD_LIBRARY(fftw INTERFACE)
>
>
> TARGET_INCLUDE_DIRECTORIES(fftw INTERFACE "${install_dir}/src/project_fftw/api/")
>
>
> ​ADD_EXECUTABLE(prose ${PROJECT_SOURCE_DIR}/src/read.cpp)
> TARGET_LINK_LIBRARIES(prose fftw  )
>>
>
> ​But when I run it in cygwin (windows) I get the following error:
> *Scanning dependencies of target prose*
> *[ 94%] Building CXX object CMakeFiles/prose.dir/src/read.cpp.o*
> */home/computing7/prose/src/read.cpp:17:19: fatal error: fftw3.h: No such
> file or                                         directory*
> *compilation terminated.*
> *make[2]: *** [CMakeFiles/prose.dir/build.make:63:
> CMakeFiles/prose.dir/src/read.
>  cpp.o] Error 1*
> *make[1]: *** [CMakeFiles/Makefile2:142: CMakeFiles/prose.dir/all] Error 2*
> *make: *** [Makefile:84: all] Error 2*
>> ​Could anyone please tell me on how to solve this problem .​
>
> --
> Regards,
> Aishwarya Selvaraj
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170519/0cd4ed13/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fftw_imported.zip
Type: application/zip
Size: 1274 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170519/0cd4ed13/attachment-0001.zip>


More information about the CMake mailing list