add support for CUnit versions less than 2.1-3
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
parent
6ab48746c5
commit
085985dce7
3 changed files with 23 additions and 1 deletions
|
@ -124,5 +124,10 @@ function(add_cunit_executable target)
|
|||
add_executable(${target} "${runner}.c" "${root}/src/runner.c" ${sources})
|
||||
target_link_libraries(${target} CUnit)
|
||||
target_include_directories(${target} PRIVATE "${root}/include")
|
||||
if("2.1.3" VERSION_LESS_EQUAL
|
||||
"${CUNIT_VERSION_MAJOR}.${CUNIT_VERSION_MINOR}.${CUNIT_VERSION_PATCH}")
|
||||
set_source_files_properties(
|
||||
"${root}/src/runner.c" PROPERTIES COMPILE_DEFINITIONS HAVE_ENABLE_JUNIT_XML)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
|
@ -195,7 +195,9 @@ cu_runner_run(
|
|||
}
|
||||
|
||||
if (runner.junit) {
|
||||
#if defined(HAVE_ENABLE_JUNIT_XML)
|
||||
CU_automated_enable_junit_xml(CU_TRUE);
|
||||
#endif
|
||||
} else {
|
||||
CU_list_tests_to_file();
|
||||
}
|
||||
|
|
|
@ -12,8 +12,23 @@
|
|||
find_path(CUNIT_INC CUnit/CUnit.h)
|
||||
find_library(CUNIT_LIB cunit)
|
||||
|
||||
if(CUNIT_INC AND EXISTS "${CUNIT_INC}/CUnit/CUnit.h")
|
||||
set(PATTERN "^#define CU_VERSION \"([0-9]+)\.([0-9]+)\-([0-9]+)\"$")
|
||||
file(STRINGS "${CUNIT_INC}/CUnit/CUnit.h" CUNIT_H REGEX "${PATTERN}")
|
||||
|
||||
string(REGEX REPLACE "${PATTERN}" "\\1" CUNIT_VERSION_MAJOR "${CUNIT_H}")
|
||||
string(REGEX REPLACE "${PATTERN}" "\\2" CUNIT_VERSION_MINOR "${CUNIT_H}")
|
||||
string(REGEX REPLACE "${PATTERN}" "\\3" CUNIT_VERSION_PATCH "${CUNIT_H}")
|
||||
|
||||
set(CUNIT_VERSION "${CUNIT_VERSION_MAJOR}.${CUNIT_VERSION_MINOR}-${CUNIT_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CUnit DEFAULT_MSG CUNIT_LIB CUNIT_INC)
|
||||
find_package_handle_standard_args(
|
||||
CUnit
|
||||
REQUIRED_VARS
|
||||
CUNIT_LIB CUNIT_INC
|
||||
VERSION_VAR CUNIT_VERSION)
|
||||
|
||||
if(CUNIT_FOUND AND NOT TARGET CUnit)
|
||||
add_library(CUnit INTERFACE IMPORTED)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue