From 52099f5792a3bfc5b124377e28021868a4da4529 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 16 May 2019 10:54:21 +0200 Subject: [PATCH] cmake: include lockstep_scheduler test This makes sure we add the lockstep_scheduler_test even if the ENABLE_LOCKSTEP_SCHEDULER is not set to yes. This means the lockstep_scheduler is not used for SITL but the CMakeLists.txt file still used and the test added. --- platforms/posix/src/CMakeLists.txt | 5 +- .../src/lockstep_scheduler/CMakeLists.txt | 46 ++++--------------- 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/platforms/posix/src/CMakeLists.txt b/platforms/posix/src/CMakeLists.txt index a50e081bd4..c46e436e8e 100644 --- a/platforms/posix/src/CMakeLists.txt +++ b/platforms/posix/src/CMakeLists.txt @@ -31,9 +31,8 @@ # ############################################################################ -if (ENABLE_LOCKSTEP_SCHEDULER) - add_subdirectory(lockstep_scheduler) -endif() add_subdirectory(px4_daemon) add_subdirectory(px4_layer) + +add_subdirectory(lockstep_scheduler) diff --git a/platforms/posix/src/lockstep_scheduler/CMakeLists.txt b/platforms/posix/src/lockstep_scheduler/CMakeLists.txt index d892b23e75..0705c07278 100644 --- a/platforms/posix/src/lockstep_scheduler/CMakeLists.txt +++ b/platforms/posix/src/lockstep_scheduler/CMakeLists.txt @@ -1,41 +1,13 @@ cmake_minimum_required(VERSION 2.8.12) -if(NOT PROJECT_NAME STREQUAL "px4") +# We want to test the lockstep schedule even if it is not used otherwise. +add_library(lockstep_scheduler + src/lockstep_scheduler.cpp +) - project(lockstep_scheduler) +target_include_directories(lockstep_scheduler + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include +) - set (CMAKE_CXX_STANDARD 11) - - add_definitions(-DUNIT_TESTS) - - add_library(lockstep_scheduler - src/lockstep_scheduler.cpp - ) - - target_include_directories(lockstep_scheduler - PUBLIC - $ - $ - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) - - target_link_libraries(lockstep_scheduler - pthread - ) - - target_compile_options(lockstep_scheduler PRIVATE -Wall -Wextra -Werror -O2) - - add_subdirectory(test) - -else() - - add_library(lockstep_scheduler - src/lockstep_scheduler.cpp - ) - target_include_directories(lockstep_scheduler - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include - ) - -endif() +px4_add_gtest(SRC test/src/lockstep_scheduler_test.cpp LINKLIBS lockstep_scheduler)