-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add the start of some cmake infrastructure. * Add cmake based tests build. * Fix compile errors in the tests. * Add readme for the cmake. * Remove extra "-c" option.
- Loading branch information
Showing
10 changed files
with
543 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# CMake Infrastructure | ||
|
||
Currently the CMake infrastructure is a work in progress. Some features work, many features do not. The official build infrastructure still uses the manually managed GNU Makefiles at this time. Users are recommended to use the manually managed GNU Makefiles for "stable" development. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Find SPIFFS | ||
|
||
if(DEFINED ENV{SPIFFSPATH}) | ||
set(SPIFFSPATH $ENV{SPIFFSPATH}) | ||
else() | ||
find_path( | ||
SPIFFSPATH | ||
src/ | ||
HINTS | ||
/opt/spiffs | ||
/opt/spiffs/default | ||
) | ||
endif() | ||
|
||
# SPIFFS | ||
if(${TARGET_SPIFFS}) | ||
add_library(spiffs | ||
${SPIFFSPATH}/src/spiffs_cache.c | ||
${SPIFFSPATH}/src/spiffs_check.c | ||
${SPIFFSPATH}/src/spiffs_gc.c | ||
${SPIFFSPATH}/src/spiffs_hydrogen.c | ||
${SPIFFSPATH}/src/spiffs_nucleus.c | ||
${OPENMRNPATH}/src/freertos_drivers/spiffs/SPIFFS.cxx | ||
) | ||
target_include_directories(spiffs | ||
PUBLIC | ||
${SPIFFSPATH}/src | ||
${OPENMRNPATH}/src/frertos_drivers/spiffs | ||
) | ||
target_compile_options(spiffs | ||
PUBLIC | ||
-DNO_TEST | ||
) | ||
endif() # TARGET_SPIFFS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# This is a target file designed to run on a host system. | ||
|
||
# Treat the tests (*.cxxtest extension) as C++ language files. | ||
set_source_files_properties(${TESTS} PROPERTIES LANGUAGE CXX) | ||
|
||
if(${COVERAGE}) | ||
# Setup gcov target. | ||
add_custom_target(TARGET_GCOV ALL | ||
DEPENDS gcovr/coverage.html | ||
) | ||
endif() | ||
|
||
# Build an executable for each test file. | ||
foreach(testsourcefile ${TESTS}) | ||
get_filename_component(testname ${testsourcefile} NAME_WE) | ||
add_executable(${testname} ${testsourcefile}) | ||
target_include_directories(${testname} | ||
PUBLIC | ||
$ENV{OPENMRNPATH}/src | ||
$ENV{OPENMRNPATH}/include | ||
$ENV{SXMLCPATH}/src | ||
${ROOT_DIR} | ||
) | ||
target_link_libraries(${testname} | ||
GTest::gtest_main | ||
GTest::gmock_main | ||
|
||
-fPIC | ||
-lgcov | ||
-Wl,--start-group | ||
openmrn | ||
${LINK_LIBS} | ||
-Wl,--end-group | ||
-lavahi-client | ||
-lavahi-common | ||
) | ||
add_custom_command(TARGET ${testname} | ||
POST_BUILD | ||
COMMAND ./${testname} | ||
# Forces the coverage report to be regenerated if tests are run. | ||
COMMAND rm -rf gcovr | ||
) | ||
if(${COVERAGE}) | ||
add_dependencies(TARGET_GCOV ${testname}) | ||
endif() | ||
endforeach(testsourcefile ${TESTS}) | ||
|
||
if(${COVERAGE}) | ||
# Generate the HTML coverage report | ||
add_custom_command(OUTPUT gcovr/coverage.html | ||
COMMAND mkdir -p gcovr | ||
COMMAND gcovr --html-details gcovr/coverage.html --exclude=_deps.* -r ${GCOV_SOURCE_DIR} . | ||
VERBATIM | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# This is a target file designed to run on a host system. | ||
|
||
# Default coverage option to off. | ||
option(COVERAGE "COVERAGE" OFF) | ||
|
||
# Enable the required language standards. | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_C_STANDARD 99) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
set(CMAKE_C_EXTENSIONS OFF) | ||
|
||
if(NOT DEFINED GTEST_TAG) | ||
set(GTEST_TAG v1.15.2) | ||
endif() | ||
message(STATUS "Using GoogleTest tag: ${GTEST_TAG}") | ||
|
||
# Get a copy of GoogleTest. | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/refs/tags/${GTEST_TAG}.zip | ||
) | ||
|
||
# On Windows: Prevent overriding the parent project's compiler/linker settings. | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
|
||
# This magic is required in order to properly add the "-x" option for the | ||
# *.cxxtest file extension. | ||
set(CMAKE_CXX_COMPILE_OBJECT | ||
"<CMAKE_CXX_COMPILER> -MD -MF [email protected] <DEFINES> <INCLUDES> <FLAGS> -o \ | ||
<OBJECT> -c -x c++ <SOURCE>" | ||
) | ||
|
||
# Compile flags. | ||
add_compile_options( | ||
-fPIC -g -O0 -Wall -Werror -DGTEST -D_GNU_SOURCE | ||
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS | ||
-Wno-attributes | ||
) | ||
if(${COVERAGE}) | ||
# Compile flags for coverage. | ||
add_compile_options(--coverage) | ||
endif() | ||
|
||
# GTest and GMock includes. | ||
include_directories(${gtest_SOURCE_DIR}/include ${gmock_SOURCE_DIR}/include) | ||
|
||
# Add OpenMRN sources | ||
add_subdirectory(${OPENMRNPATH}/src openmrn) | ||
|
Oops, something went wrong.