env: ubuntu20.04 cmake3.15
I download xbindkeys from:https://www.nongnu.org/xbindkeys/ and try to use cmake to build it. I can build it successful with native configure(autoconf), but when i use cmake always get the unknown type name error; the cmakelist.txt:
cmake_minimum_required(VERSION 3.10)
project(xbindkeys LANGUAGES C VERSION 1.8.7)
#for x11
find_package(X11)
if(X11_FOUND)
message(STATUS "X11 found")
else()
message(STATUS "X11 NOT FOUND")
endif(X11_FOUND)
#find_package(Boost COMPONENTS log log_setup system thread REQUIRED)
aux_source_directory(. SRCS)
message(STATUS "all src:${SRCS}")
message(STATUS "X11 libries:${X11_LIBRARIES}")
file (GLOB H_Files "./*.h")
include_directories(./ ${X11_INCLUDE_DIR} /usr/include/X11/)
message(STATUS "cmake found x11 dir:${X11_INCLUDE_DIR}")
set(GCC_CXX_FLAGS "${GCC_CXX_FLAGS} -lX11")
add_executable(xbindkeys.app ${SRCS})
link_directories(${X11_LIBRARIES})
target_link_libraries(xbindkeys.app ${X11_LIBRARIES} -lX11)
after generate the makefile, and run make.get the message is below:
[ 16%] Building C object CMakeFiles/xbindkeys.app.dir/get_key.c.o
[ 33%] Building C object CMakeFiles/xbindkeys.app.dir/grab_key.c.o
In file included from /home/eton/workspace/xbindkeys/grab_key.c:18:
/home/eton/workspace/xbindkeys/grab_key.h:21:23: error: unknown type name 鈥楧isplay鈥?
21 | extern void grab_keys(Display* dpy);
| ^~~~~~~
/home/eton/workspace/xbindkeys/grab_key.h:22:29: error: unknown type name 鈥楧isplay鈥?
22 | extern void ungrab_all_keys(Display* dpy);
| ^~~~~~~
/home/eton/workspace/xbindkeys/grab_key.h:24:37: error: unknown type name 鈥楧isplay鈥?
24 | extern void get_offending_modifiers(Display* dpy);
| ^~~~~~~
/home/eton/workspace/xbindkeys/grab_key.c: In function 鈥榞rab_keys鈥?
/home/eton/workspace/xbindkeys/grab_key.c:223:16: warning: 鈥榅KeycodeToKeysym鈥?is deprecated [-Wdeprecated-declarations]
223 | XKeysymToString(XKeycodeToKeysym(dpy, keys[i].key.code, 0)));
| ^~~~~~~~~~~~~~~
In file included from /home/eton/workspace/xbindkeys/grab_key.c:20:
/usr/include/X11/Xlib.h:1687:15: note: declared here
1687 | extern KeySym XKeycodeToKeysym(
| ^~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xbindkeys.app.dir/build.make:76: CMakeFiles/xbindkeys.app.dir/grab_key.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/xbindkeys.app.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
anyone can help about this? because this question combine CMake in C-programming-language and X11 libs, not many infomation in the web. so i come here to ask.