mirror of
https://github.com/nasa/fprime.git
synced 2025-12-11 04:35:25 -06:00
Add UT_AUTO_HELPERS control word to new CMake API (#3648)
* Add hotfix * Review recommendation
This commit is contained in:
parent
eea6aca8fa
commit
32582d7e9a
@ -7,26 +7,27 @@
|
|||||||
# Note: using PROJECT_NAME as EXECUTABLE_NAME
|
# Note: using PROJECT_NAME as EXECUTABLE_NAME
|
||||||
####
|
####
|
||||||
|
|
||||||
set(MOD_DEPS
|
register_fprime_library(
|
||||||
Utils/Types
|
SOURCES
|
||||||
Fw/Buffer
|
"${CMAKE_CURRENT_LIST_DIR}/ComQueue.cpp"
|
||||||
Fw/Types
|
AUTOCODER_INPUTS
|
||||||
)
|
"${CMAKE_CURRENT_LIST_DIR}/ComQueue.fpp"
|
||||||
set(SOURCE_FILES
|
DEPENDS
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/ComQueue.fpp"
|
Fw_Types
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/ComQueue.cpp"
|
Utils_Types
|
||||||
)
|
Fw_Buffer
|
||||||
register_fprime_module()
|
)
|
||||||
|
|
||||||
### UTs ###
|
### UTs ###
|
||||||
set(UT_SOURCE_FILES
|
register_fprime_ut(
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/ComQueue.fpp"
|
SOURCES
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ComQueueTestMain.cpp"
|
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ComQueueTestMain.cpp"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ComQueueTester.cpp"
|
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ComQueueTester.cpp"
|
||||||
)
|
AUTOCODER_INPUTS
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/ComQueue.fpp"
|
||||||
|
UT_AUTO_HELPERS
|
||||||
|
)
|
||||||
|
|
||||||
set(UT_AUTO_HELPERS ON)
|
|
||||||
register_fprime_ut()
|
|
||||||
set (UT_TARGET_NAME "${FPRIME_CURRENT_MODULE}_ut_exe")
|
set (UT_TARGET_NAME "${FPRIME_CURRENT_MODULE}_ut_exe")
|
||||||
if (TARGET "${UT_TARGET_NAME}")
|
if (TARGET "${UT_TARGET_NAME}")
|
||||||
target_compile_options("${UT_TARGET_NAME}" PRIVATE -Wno-conversion)
|
target_compile_options("${UT_TARGET_NAME}" PRIVATE -Wno-conversion)
|
||||||
|
|||||||
@ -534,7 +534,7 @@ endfunction(register_fprime_ut)
|
|||||||
#
|
#
|
||||||
####
|
####
|
||||||
function(fprime_add_unit_test_build_target)
|
function(fprime_add_unit_test_build_target)
|
||||||
fprime__internal_add_build_target("Unit Test" "INCLUDE_GTEST" ${ARGN})
|
fprime__internal_add_build_target("Unit Test" "INCLUDE_GTEST;UT_AUTO_HELPERS" ${ARGN})
|
||||||
clear_historical_variables()
|
clear_historical_variables()
|
||||||
set(INTERNAL_MODULE_NAME "${INTERNAL_MODULE_NAME}" PARENT_SCOPE)
|
set(INTERNAL_MODULE_NAME "${INTERNAL_MODULE_NAME}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@ -45,6 +45,7 @@ function(ai_ut_setup_autocode MODULE_NAME AC_INPUT_FILE)
|
|||||||
list(APPEND REMOVALS "${CMAKE_CURRENT_BINARY_DIR}/GTestBase.cpp" "${CMAKE_CURRENT_BINARY_DIR}/GTestBase.hpp")
|
list(APPEND REMOVALS "${CMAKE_CURRENT_BINARY_DIR}/GTestBase.cpp" "${CMAKE_CURRENT_BINARY_DIR}/GTestBase.hpp")
|
||||||
endif()
|
endif()
|
||||||
# Extra test helpers file
|
# Extra test helpers file
|
||||||
|
get_target_property(UT_AUTO_HELPERS "${MODULE_NAME}" FPRIME_UT_AUTO_HELPERS)
|
||||||
if (DEFINED UT_AUTO_HELPERS AND UT_AUTO_HELPERS)
|
if (DEFINED UT_AUTO_HELPERS AND UT_AUTO_HELPERS)
|
||||||
list(APPEND AUTOCODER_GENERATED "${CMAKE_CURRENT_BINARY_DIR}/TesterHelpers.cpp")
|
list(APPEND AUTOCODER_GENERATED "${CMAKE_CURRENT_BINARY_DIR}/TesterHelpers.cpp")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@ -42,6 +42,7 @@ function(ai_ut_impl_setup_autocode MODULE_NAME AC_INPUT_FILE)
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/GTestBase.hpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/GTestBase.hpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/GTestBase.cpp")
|
"${CMAKE_CURRENT_SOURCE_DIR}/GTestBase.cpp")
|
||||||
# Extra test helpers file
|
# Extra test helpers file
|
||||||
|
get_target_property(UT_AUTO_HELPERS "${MODULE_NAME}" FPRIME_UT_AUTO_HELPERS)
|
||||||
if (NOT DEFINED UT_AUTO_HELPERS OR NOT UT_AUTO_HELPERS)
|
if (NOT DEFINED UT_AUTO_HELPERS OR NOT UT_AUTO_HELPERS)
|
||||||
list(APPEND AUTOCODER_GENERATED "${CMAKE_CURRENT_SOURCE_DIR}/TesterHelpers.cpp")
|
list(APPEND AUTOCODER_GENERATED "${CMAKE_CURRENT_SOURCE_DIR}/TesterHelpers.cpp")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@ -49,6 +49,7 @@ function(fpp_ut_setup_autocode MODULE_NAME AC_INPUT_FILES)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
set(CLI_ARGS ${FPP_TO_CPP} "-u" "-d" "${CMAKE_CURRENT_BINARY_DIR}" ${IMPORTS} ${AC_INPUT_FILES} "-p" "${FPRIME_BUILD_LOCATIONS_COMMA_SEP},${CMAKE_BINARY_DIR}")
|
set(CLI_ARGS ${FPP_TO_CPP} "-u" "-d" "${CMAKE_CURRENT_BINARY_DIR}" ${IMPORTS} ${AC_INPUT_FILES} "-p" "${FPRIME_BUILD_LOCATIONS_COMMA_SEP},${CMAKE_BINARY_DIR}")
|
||||||
|
get_target_property(UT_AUTO_HELPERS "${MODULE_NAME}" FPRIME_UT_AUTO_HELPERS)
|
||||||
if (UT_AUTO_HELPERS)
|
if (UT_AUTO_HELPERS)
|
||||||
list(APPEND CLI_ARGS "-a")
|
list(APPEND CLI_ARGS "-a")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@ -199,6 +199,11 @@ function(fprime__internal_add_build_target_helper TARGET_NAME TYPE SOURCES AUTOC
|
|||||||
else()
|
else()
|
||||||
fprime_cmake_fatal_error("Cannot register compilation target of type ${TYPE}")
|
fprime_cmake_fatal_error("Cannot register compilation target of type ${TYPE}")
|
||||||
endif()
|
endif()
|
||||||
|
if (TYPE STREQUAL "Unit Test" AND INTERNAL_UT_AUTO_HELPERS)
|
||||||
|
set_target_properties("${TARGET_NAME}" PROPERTIES
|
||||||
|
FPRIME_UT_AUTO_HELPERS TRUE
|
||||||
|
)
|
||||||
|
endif()
|
||||||
# Use the appropriate link type for the target
|
# Use the appropriate link type for the target
|
||||||
get_target_property(CMAKE_LIBRARY_TYPE "${TARGET_NAME}" TYPE)
|
get_target_property(CMAKE_LIBRARY_TYPE "${TARGET_NAME}" TYPE)
|
||||||
if (CMAKE_LIBRARY_TYPE MATCHES "INTERFACE_LIBRARY")
|
if (CMAKE_LIBRARY_TYPE MATCHES "INTERFACE_LIBRARY")
|
||||||
|
|||||||
@ -80,6 +80,7 @@ function(ut_setup_unit_test_include_directories UT_EXE_NAME SOURCE_FILES)
|
|||||||
set(UT_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}")
|
set(UT_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
# When running with auto-helpers, we need to include the .hpp directories as things are imported without path
|
# When running with auto-helpers, we need to include the .hpp directories as things are imported without path
|
||||||
# e.g. "#include <Tester.hpp>" and there is no guarantee for the location of these files
|
# e.g. "#include <Tester.hpp>" and there is no guarantee for the location of these files
|
||||||
|
get_target_property(UT_AUTO_HELPERS "${UT_EXE_NAME}" FPRIME_UT_AUTO_HELPERS)
|
||||||
if (DEFINED UT_AUTO_HELPERS AND UT_AUTO_HELPERS)
|
if (DEFINED UT_AUTO_HELPERS AND UT_AUTO_HELPERS)
|
||||||
foreach(SOURCE_FILE IN LISTS SOURCE_FILES)
|
foreach(SOURCE_FILE IN LISTS SOURCE_FILES)
|
||||||
get_filename_component(SOURCE_EXT "${SOURCE_FILE}" LAST_EXT)
|
get_filename_component(SOURCE_EXT "${SOURCE_FILE}" LAST_EXT)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user