Hi there, If I’m not mistaken, when a library cannot be found, the value of the variable “ARMADILLO” will be set to “ARMADILLO-NOTFOUND”. So I think you need to adjust your test to:
IF (${ARMADILLO} STREQUAL “ARMADILLO-NOTFOUND”) # do what you want ENDIF () The following links in the doc may be helpful: https://cmake.org/cmake/help/v3.7/command/find_library.html https://cmake.org/cmake/help/v3.7/command/if.html Parag Chandra Technical Lead, Mobile Team Mobile: +1.919.824.1410 Ionic Security Inc. 1170 Peachtree St. NE STE 400, Atlanta, GA 30309 From: CMake <cmake-boun...@cmake.org> on behalf of aishwarya selvaraj <aishwaryaselvaraj1...@gmail.com> Date: Wednesday, January 4, 2017 at 12:29 PM To: cmake <cmake@cmake.org> Subject: [EXTERNAL]: [CMake] To include external libraries using Cmake 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
-- 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