[CMake] check_function_exists

Christer Solskogen christer.solskogen at gmail.com
Fri May 30 11:36:41 EDT 2014


Hi!

I have a CMakefile with the following code:

find_package(Readline)
if(READLINE_FOUND)
         set(CMAKE_REQUIRED_LIBRARIES "readline")
         check_function_exists(rl_filename_completion_function 
HAVE_RL_COMPLETION_FUNCTION)
         if(HAVE_RL_COMPLETION_FUNCTION)
                 set(HAVE_LIBREADLINE 1)
         else()
                 unset(READLINE_FOUND)
         endif(HAVE_RL_COMPLETION_FUNCTION)
         set(CMAKE_REQUIRED_LIBRARIES "")
endif(READLINE_FOUND)


If it finds libreadline.so it also finds the 
rl_filename_completion_function. But it it finds libreadline.a it does not.

-- Found READLINE: /usr/lib/x86_64-linux-gnu/libreadline.so
-- Looking for rl_filename_completion_function
-- Looking for rl_filename_completion_function - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hatari/temp

-- Found READLINE: /usr/lib/x86_64-linux-gnu/libreadline.a
-- Looking for rl_filename_completion_function
-- Looking for rl_filename_completion_function - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hatari/temp

Both .a and .so have that function:

hatari at friend:/usr/lib/x86_64-linux-gnu$ nm -D libreadline.so  | grep 
rl_filename_completion_function
000000000001abe0 T rl_filename_completion_function
hatari at friend:/usr/lib/x86_64-linux-gnu$ nm libreadline.a | grep 
rl_filename_completion_function
00000000000015e0 T rl_filename_completion_function
                  U rl_filename_completion_function


Any hints?




More information about the CMake mailing list