Having two variables is an advantage over autoconf:
HAVE_FOO is true if the function is found at all
FOO_LIB is a library where foo is found.
HAVE_FOO may be true, but FOO_LIB is empty, if the function foo is in libc
I can add ${FOO_LIB} to targets where I need foo; with autotools the
library containing foo
is added to all targets.
Here is how I use it:
CMAKE_SEARCH_LIBS (HAVE_DLADDR LIB_DLADDR dladdr dl)
if (NOT HAVE_DLADDR)
message (FATAL_ERROR "Cannot find library providing dladdr()")
endif()
CMAKE_SEARCH_LIBS (HAVE_PTHREAD_JOIN LIB_PTHREAD pthread_join pthread)
if (NOT HAVE_PTHREAD_JOIN)
message (FATAL_ERROR "Cannot find library providing pthread_join()")
endif()
MY_LINK_LIBRARIES (aaa
${LIB_DLADDR}
${LIB_PTHREAD}
dwarf
lzma
)
2013/9/9 Stewart, Robert <[email protected]>:
> Игорь Пашев wrote:
>>
>> Hi, all. I'm using this macro to get AC_SEARCH_LIBS (from GNU
>> autoconf) functionality with CMake.
>>
>> First of all, this macro searhes the function on libc, then,
>> if not found, in the given libraries. It sets two variables:
>> 1) boolean if function found
>> 2) string - in which library (may be empty).
>>
>> I'd like this macro to be in standard cmake set.
>
> Regardless of anything else in your proposal, why the two result
> variables? It seems to me that setting the string when found,
> and clearing it when not, serves both purposes. When the string
> is empty, the function wasn't found.
>
>> MACRO (CMAKE_SEARCH_LIBS v_func v_lib func)
>
> (I don't know what the "v_" prefix means, but I presume that those
> arguments are the outputs, so perhaps "v_" means "supply the name
> of a variable to set.") With my variation, the interface would
> work like the following:
>
> CMAKE_SEARCH_LIBS(library my_function)
> IF(library)
> # found my_function's library
> ENDIF()
>
>
> _____
> Rob Stewart
> Software Engineer
> Dev Tools & Components
> Susquehanna International Group, LLP
>
> ________________________________
>
> IMPORTANT: The information contained in this email and/or its attachments is
> confidential. If you are not the intended recipient, please notify the sender
> immediately by reply and immediately delete this message and all its
> attachments. Any review, use, reproduction, disclosure or dissemination of
> this message or any attachment by an unintended recipient is strictly
> prohibited. Neither this message nor any attachment is intended as or should
> be construed as an offer, solicitation or recommendation to buy or sell any
> security or other financial instrument. Neither the sender, his or her
> employer nor any of their respective affiliates makes any warranties as to
> the completeness or accuracy of any of the information contained herein or
> that this message or any of its attachments is free of viruses.
--
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://www.cmake.org/mailman/listinfo/cmake