0

我有一个使用 Makefile 编译没有错误的库。现在我想切换到 CMake,但它不起作用。

源代码和 Makefiles 在这里。从所有文件夹中,我保留了以下内容:can_socket, can_virtual, timers_xeno, timers_rtpreempt, timers_unix, unix.

这是我的 CMakeLists:

cmake_minimum_required(VERSION 2.4.6)
project(ikarus_arm_common C CXX)


#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)


find_package(Boost COMPONENTS filesystem system serialization REQUIRED)

set(CAN_MASTER_INCLUDE_DIR include)

include_directories( ${Boost_INCLUDE_DIRS}  
    ${CAN_MASTER_INCLUDE_DIR} 
    ${CAN_MASTER_INCLUDE_DIR}/boost
    ${CAN_MASTER_INCLUDE_DIR}/timers_rtpreempt
    ${CAN_MASTER_INCLUDE_DIR}/timers_unix
    ${CAN_MASTER_INCLUDE_DIR}/timers_xeno
    ${CAN_MASTER_INCLUDE_DIR}/unix
    /usr/xenomai/include

)

set(CAN_FESTIVAL_CPP drivers/unix/unix.c
    drivers/timers_xeno/timers_xeno.c
    drivers/can_socket/can_socket.c
)

add_library(canfestival ${CAN_FESTIVAL_CPP})

编辑:

当我尝试编译时,它返回以下错误:

> $ make 
> [  9%] Building C object
> CMakeFiles/canfestival.dir/drivers/unix/unix.o 
> In file included from
> /home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/include/can.h:28:0,
>     from /home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/include/canDispatch.h:23,
>     from /home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/drivers/unix/unix.c:36:
> /usr/include/boost/function.hpp:13:57: fatal error: functional: No
> such file or directory compilation terminated. make[2]: ***
> [CMakeFiles/canfestival.dir/drivers/unix/unix.o] Error 1 make[1]: ***
> [CMakeFiles/canfestival.dir/all] Error 2 make: *** [all] Error 2

我想问题之一是由于某些文件具有扩展名.c但需要提升。如果我修改文件unix.cpp and can_socket.cpp编译的扩展名,则timers_xeno返回错误:

luca@luca-vmware:~/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/build$ make
[  9%] Building CXX object CMakeFiles/canfestival.dir/drivers/unix/unix.o
[ 18%] Building CXX object CMakeFiles/canfestival.dir/drivers/timers_xeno/timers_xeno.o
/home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/drivers/timers_xeno/timers_xeno.cpp: In function ‘void CreateReceiveTask(CAN_PORT, pthread_t*, void (*)(void*))’:
/home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/drivers/timers_xeno/timers_xeno.cpp:250:75: error: cannot convert ‘pthread_t* {aka long unsigned int*}’ to ‘RT_TASK* {aka rt_task_placeholder*}’ for argument ‘1’ to ‘int rt_task_create(RT_TASK*, const char*, int, int, int)’
/home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/drivers/timers_xeno/timers_xeno.cpp:256:70: error: cannot convert ‘pthread_t* {aka long unsigned int*}’ to ‘RT_TASK* {aka rt_task_placeholder*}’ for argument ‘1’ to ‘int rt_task_start(RT_TASK*, void (*)(void*), void*)’
/home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/drivers/timers_xeno/timers_xeno.cpp: In function ‘void WaitReceiveTaskEnd(pthread_t*)’:
/home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/drivers/timers_xeno/timers_xeno.cpp:270:38: error: cannot convert ‘pthread_t* {aka long unsigned int*}’ to ‘RT_TASK* {aka rt_task_placeholder*}’ for argument ‘1’ to ‘int rt_task_join(RT_TASK*)’
/home/luca/ArmIkarus/ikarus_arm_stack/ikarus_arm_common/drivers/timers_xeno/timers_xeno.cpp:273:36: error: cannot convert ‘pthread_t* {aka long unsigned int*}’ to ‘RT_TASK* {aka rt_task_placeholder*}’ for argument ‘1’ to ‘int rt_task_delete(RT_TASK*)’
make[2]: *** [CMakeFiles/canfestival.dir/drivers/timers_xeno/timers_xeno.o] Error 1
make[1]: *** [CMakeFiles/canfestival.dir/all] Error 2
make: *** [all] Error 2

我该如何解决这个问题?

4

0 回答 0