cmake: add clion support

This commit is contained in:
Beat Küng 2022-07-19 15:28:16 +02:00 committed by Daniel Agar
parent f22dc80ecc
commit 84b0a889a4
2 changed files with 16 additions and 8 deletions

View File

@ -175,6 +175,12 @@ include(kconfig)
message(STATUS "PX4 config: ${PX4_CONFIG}") message(STATUS "PX4 config: ${PX4_CONFIG}")
message(STATUS "PX4 platform: ${PX4_PLATFORM}") message(STATUS "PX4 platform: ${PX4_PLATFORM}")
if($ENV{CLION_IDE})
# CLion automatically executes some compiler commands after configuring the
# project. This would fail on NuttX, as visibility.h tries to (indirectly)
# include nuttx/config.h, which at that point does not exist yet
add_definitions(-DPX4_DISABLE_GCC_POISON)
endif()
if(${PX4_PLATFORM} STREQUAL "posix") if(${PX4_PLATFORM} STREQUAL "posix")
if(ENABLE_LOCKSTEP_SCHEDULER) if(ENABLE_LOCKSTEP_SCHEDULER)

View File

@ -60,14 +60,19 @@
#endif #endif
#define system_exit exit
#define system_clock_gettime clock_gettime
#define system_clock_settime clock_settime
#define system_pthread_cond_timedwait pthread_cond_timedwait
#define system_usleep usleep
#define system_sleep sleep
#ifndef PX4_DISABLE_GCC_POISON
/* exit() is used on NuttX to exit a task. However on Posix, it will exit the /* exit() is used on NuttX to exit a task. However on Posix, it will exit the
* whole application, so we prevent its use there. There are cases where it * whole application, so we prevent its use there. There are cases where it
* still needs to be used, thus we remap system_exit to exit. * still needs to be used, thus we remap system_exit to exit.
*/ */
#define system_exit exit
#if !defined(__PX4_NUTTX) #if !defined(__PX4_NUTTX)
#include <stdlib.h> #include <stdlib.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -83,8 +88,6 @@
/* For SITL lockstep we fake the clock, sleeping, and timedwaits /* For SITL lockstep we fake the clock, sleeping, and timedwaits
* Therefore, we prefix these syscalls with system_. */ * Therefore, we prefix these syscalls with system_. */
#include <time.h> #include <time.h>
#define system_clock_gettime clock_gettime
#define system_clock_settime clock_settime
/* We can't poison clock_settime/clock_gettime because they are /* We can't poison clock_settime/clock_gettime because they are
* used in DriverFramework. */ * used in DriverFramework. */
@ -93,20 +96,17 @@
// We can't include this for NuttX otherwise we get conflicts for read/write // We can't include this for NuttX otherwise we get conflicts for read/write
// symbols in cannode. // symbols in cannode.
#endif // !defined(__PX4_NUTTX) #endif // !defined(__PX4_NUTTX)
#define system_pthread_cond_timedwait pthread_cond_timedwait
/* We can't poison pthread_cond_timedwait because it seems to be used in the /* We can't poison pthread_cond_timedwait because it seems to be used in the
* <string> include. */ * <string> include. */
/* We don't poison usleep and sleep because it is used in dependencies /* We don't poison usleep and sleep because it is used in dependencies
* like uavcan and DriverFramework. */ * like uavcan. */
#if !defined(__PX4_NUTTX) #if !defined(__PX4_NUTTX)
#include <unistd.h> #include <unistd.h>
// We can't include this for NuttX otherwise we get conflicts for read/write // We can't include this for NuttX otherwise we get conflicts for read/write
// symbols in cannode. // symbols in cannode.
#endif // !defined(__PX4_NUTTX) #endif // !defined(__PX4_NUTTX)
#define system_usleep usleep
#define system_sleep sleep
/* On NuttX we call clearenv() so we cannot use getenv() and others (see /* On NuttX we call clearenv() so we cannot use getenv() and others (see
@ -123,3 +123,5 @@
* need to get changed. */ * need to get changed. */
#pragma GCC poison getenv setenv putenv #pragma GCC poison getenv setenv putenv
#endif // defined(__PX4_NUTTX) #endif // defined(__PX4_NUTTX)
#endif // PX4_DISABLE_GCC_POISON