I am toying with a CMake project for Apknite and in the tutorial, there is a step about system introspection.
I tried to do a very simple test which I thought would work but unfortunately, it doesn't.
I have a simple module called add which exists in its own module and defines a function called add.
directory structure
├── bin
├── cmake_bin
├── CMakeLists.txt
├── src
│ ├── add
│ │ ├── add.c
│ │ ├── add.h
│ │ └── CMakeLists.txt
│ ├── CMakeLists.txt
│ ├── main.c
│ ├── main.h
│ └── version.h.in
src/CMakeLists.txt has the following lines
add_executable(main.out main.c)
add_subdirectory(add)
include(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
check_function_exists (add HAVE_ADD)
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/version.h.in"
"${EXECUTABLE_OUTPUT_PATH}/version.h"
)
where main.c includes add.h and makes use of the add function.
version.h.in contains
#cmakedefine HAVE_ADD
Can someone help me understand why when version.h is generated it reports looking for add - not found?
What I have tried so far is to move the check_function_exists in the src/add/CMakeLists.txt and to use check_symbol_exists(add add.h HAVE_ADD).
After a glance at the internetz, I saw that check_function_exists is for system header files but I don't quite get why or how it would distinguish between system files and my source files.
Any help is appreciated.