[CMake] find_library does not find libcurl for ios simulator

Jochen Issing iss at nesono.com
Tue May 5 06:31:16 EDT 2015


Hi,

I am running 3.2.2 and also get the error with 3.1.0 on a mac.
I have the particular curl library in a custom path.
The following snippet fetches the library correctly for mac and iOS, but not for iOS-simulator.
I also tried to change find_library to find_path using the real (platform dependent) library name.

TARGET_OS is our custom string for switching between different target platforms.

message(STATUS "Searching for CURL library in ${SEARCH_BASE}/lib")
unset(CURL_LIBRARY CACHE)
if(TARGET_OS MATCHES "macosx.*" OR TARGET_OS MATCHES "ios.*")
        message(STATUS "Mac/iOS method find_library")
        find_library(CURL_LIBRARY
                NAMES curl
                PATHS ${SEARCH_BASE}
                PATH_SUFFIXES lib
                NO_DEFAULT_PATH)
else(TARGET_OS MATCHES "macosx.*" OR TARGET_OS MATCHES "ios.*")
        message(STATUS "Non-Mac method find_library")
        find_library(CURL_LIBRARY
                NAMES curl
                PATHS ${SEARCH_BASE}
                PATH_SUFFIXES lib
                NO_CMAKE_FIND_ROOT_PATH)
endif(TARGET_OS MATCHES "macosx.*" OR TARGET_OS MATCHES "ios.*")
message(STATUS "Curl Library: ${CURL_LIBRARY}")

if(CURL_LIBRARY)
        message(STATUS "Curl library found")
        list(APPEND CURL_LIBRARIES ${CURL_LIBRARY} z)
else(CURL_LIBRARY)
        message(STATUS "Curl library not found")
endif(CURL_LIBRARY)

When running cmake in the console, I get the following (for iOS Simulator only):

-- Searching for CURL library in /Users/blaschnas/src/project/build/ios-x86-clang-libcxx/libs/curl/lib
-- Mac/iOS method find_library
-- Curl Library: CURL_LIBRARY-NOTFOUND
-- Curl library not found

When I look into the directory of the library, I can see libcurl.a lying exactly there.
Does find_library test for architecture, like deeply inspect the library or is it basically composing the correct prefix and suffix and then behaves like find_path?

Thanks for your help.

/jochen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150505/c9fc688e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150505/c9fc688e/attachment-0001.sig>


More information about the CMake mailing list