[CMake] To include external libraries using Cmake

aishwarya selvaraj aishwaryaselvaraj1708 at gmail.com
Wed Jan 4 12:29:57 EST 2017


Hi ,
I'm using Cmake to create binary files as it can give a way to build my
application that will successfully compile on different platforms .
I use :
Linux -14.04
Cmake - 2.8.12

My .cpp code is called TSM_CODE_V3.cpp.It <http://tsm_code_v3.cpp.it/> depends
on two external library files .1) armadillo 2) sndfile .
I scripted a CmakeLists.txt as follows :

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
PROJECT(TSM2)

FIND_LIBRARY(ARMADILLO armadillo)
MESSAGE(STATUS "Armadillo Library location: " ${ARMADILLO})

IF (NOT ARMADILLO_FOUND)
include(ExternalProject)
MESSAGE(STATUS "Armadillo not found in the system ,Trying to install
armadillo...")
ExternalProject_Add(armadillo
  URL https://github.com/lsolanka/armadillo/archive/master.zip
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/armadillo-latest)
ENDIF()

FIND_LIBRARY(SNDFILE sndfile)
MESSAGE(STATUS "Sndfile Library location: " ${SNDFILE})

IF (NOT SNDFILE_FOUND)
include(ExternalProject)
MESSAGE(STATUS "Armadillo not found in the system ,Trying to install
libsndfile...")
ExternalProject_Add(sndfile
  URL https://github.com/erikd/libsndfile/archive/master.zip
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/sndfile-latest)
ENDIF()

ADD_EXECUTABLE(tsm ${PROJECT_SOURCE_DIR}/src/TSM_CODE_V3.cpp)
TARGET_LINK_LIBRARIES(tsm ${ARMADILLO} ${SNDFILE})


I made use of ExternalProject_add to download the external libraries from
the specified link address ,but when I try to compile the CmakeLists.txt ,
it throws an error of saying library not found .Basically , the external
library is not downloaded from the specified link .


I'm not  sure where am I going wrong here .
Can anyone help me out ?

Hoping to hear from you..

-- 
Regards,
Aishwarya Selvaraj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170104/ec4622aa/attachment.html>


More information about the CMake mailing list