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. CMakeLists.txt: INCLUDE (CheckFunctionExists) INCLUDE (CheckLibraryExists) MACRO (CMAKE_SEARCH_LIBS v_func v_lib func) CHECK_FUNCTION_EXISTS (${func} ${v_func}) IF (NOT ${v_func}) FOREACH (lib ${ARGN}) CHECK_LIBRARY_EXISTS (${lib} ${func} "" "HAVE_${func}_IN_${lib}") IF ("HAVE_${func}_IN_${lib}") SET (${v_func} TRUE) SET (${v_lib} "${lib}" CACHE INTERNAL "Library providing ${func}") BREAK() ENDIF ("HAVE_${func}_IN_${lib}") ENDFOREACH (lib) ENDIF (NOT ${v_func}) ENDMACRO (CMAKE_SEARCH_LIBS) CMAKE_SEARCH_LIBS (HAVE_FORKPTY FORKPTY_LIB forkpty aaa util bbb) CMAKE_SEARCH_LIBS (HAVE_SENDFILE SENDFILE_LIB sendfile sendfile) # cmake . -- The C compiler identification is GNU 4.7.3 -- The CXX compiler identification is GNU 4.7.3 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Looking for forkpty -- Looking for forkpty - not found -- Looking for forkpty in aaa -- Looking for forkpty in aaa - not found -- Looking for forkpty in util -- Looking for forkpty in util - found -- Looking for sendfile -- Looking for sendfile - found -- Configuring done -- Generating done -- Build files have been written to: /home/pashev/tmp -- 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