[CMake] Cmake for fftw library
aishwarya selvaraj
aishwaryaselvaraj1708 at gmail.com
Fri Apr 7 06:48:16 EDT 2017
Hi all ,
I was writing CMakelist.txt to compile my cpp code(prose ) which makes use
of two external libraries :libsndfile and fftw .
The script I have written is below :
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(PROSE)
########################################################################################################################################################################################################################################################
include(ExternalProject)
MESSAGE(STATUS "Trying to install fftw...")
ExternalProject_Add(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_library
CONFIGURE_COMMAND ""
#--Build step-----------------
BUILD_COMMAND ""
#--Install step---------------
UPDATE_COMMAND "" # Skip annoying updates for every build
INSTALL_COMMAND ""
)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/fftw_library/src/fftw/api)
########################################################################################################################################################################################################################################################
include(ExternalProject)
MESSAGE(STATUS "Trying to install libsndfile...")
ExternalProject_Add(project_libsndfile
GIT_REPOSITORY https://github.com/erikd/libsndfile.git
PREFIX lib/libsndfile
CONFIGURE_COMMAND <SOURCE_DIR>/configure
BUILD_COMMAND make
BUILD_IN_SOURCE 1
INSTALL_COMMAND echo Skipping install step for libsndfile
)
ExternalProject_Add_Step(project_libsndfile autogen
COMMAND <SOURCE_DIR>/autogen.sh
DEPENDEES update
DEPENDERS configure
)
ExternalProject_Get_Property(project_libsndfile BINARY_DIR)
SET(libsndfile_lib_dir "${BINARY_DIR}/src/.libs")
SET(libsndfile_inc_dir "${BINARY_DIR}/src")
ADD_LIBRARY(libsndfile STATIC IMPORTED)
SET_PROPERTY(TARGET libsndfile PROPERTY IMPORTED_LOCATION
${libsndfile_lib_dir}/libsndfile.a)
SET(LIBSNDFILE_INCLUDE_PATH
"${install_dir}/src/project_libsndfile-build/src/")
INCLUDE_DIRECTORIES(include ${libsndfile_inc_dir})
########################################################################################################################################################################################################################################################
ADD_EXECUTABLE(prose ${PROJECT_SOURCE_DIR}/src/prose.cpp)
TARGET_LINK_LIBRARIES(prose ${fftw} libsndfile )
########################################################################################################################################################################################################################################################
When cmake .. is done building is done without any problem
But when make is one , I get the following error:
*Linking CXX executable proseCMakeFiles/prose.dir/src/prose.cpp.o: In
function `prose(std::vector<double, std::allocator<double> >, int,
double)':prose.cpp:(.text+0x1c86): undefined reference to
`fftw_plan_r2r_1d'prose.cpp:(.text+0x1c9c): undefined reference to
`fftw_execute'prose.cpp:(.text+0x311d): undefined reference to
`fftw_plan_r2r_1d'prose.cpp:(.text+0x3133): undefined reference to
`fftw_execute'collect2: error: ld returned 1 exit statusmake[2]: ***
[prose] Error 1make[1]: *** [CMakeFiles/prose.dir/all] Error 2make: ***
[all] Error 2*
Where Am I going wrong ?
Can anyone please help me out ?
P.S
*`fftw_plan_r2r_1d',*
* `fftw_execute' are functions from fftw library I have used to find dct .*
--
Regards,
Aishwarya Selvaraj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170407/14abe6fe/attachment.html>
More information about the CMake
mailing list