Some checks failed
Build and Run C++ Unit Tests / build-and-test (push) Failing after 29s
65 lines
1.6 KiB
CMake
65 lines
1.6 KiB
CMake
cmake_minimum_required(VERSION 3.13) # CMake version check
|
|
if(ESP_PLATFORM)
|
|
idf_component_register(
|
|
SRC_DIRS "."
|
|
INCLUDE_DIRS "."
|
|
)
|
|
else()
|
|
project(LinearAlgebra)
|
|
|
|
set(CMAKE_CXX_STANDARD 17) # Enable c++11 standard
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
add_compile_definitions(GTEST)
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
googletest
|
|
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
|
URL https://github.com/google/googletest/archive/refs/heads/main.zip
|
|
)
|
|
|
|
# Enable coverage
|
|
option(CODE_COVERAGE "Enable coverage reporting" ON)
|
|
|
|
if(CODE_COVERAGE)
|
|
message(STATUS "Code coverage enabled")
|
|
add_compile_options(/PROFILE) # MSVC flag for coverage
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /Od") # Debug info
|
|
endif()
|
|
|
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
include_directories(.)
|
|
file(GLOB srcs
|
|
*.cpp
|
|
)
|
|
add_library(LinearAlgebra STATIC ${srcs}
|
|
)
|
|
|
|
enable_testing()
|
|
|
|
file(GLOB_RECURSE test_srcs test/*_test.cc)
|
|
add_executable(
|
|
LinearAlgebraTest
|
|
${test_srcs}
|
|
)
|
|
target_link_libraries(
|
|
LinearAlgebraTest
|
|
gtest_main
|
|
LinearAlgebra
|
|
)
|
|
|
|
if(MSVC)
|
|
target_compile_options(LinearAlgebraTest PRIVATE /W4 /WX)
|
|
# else()
|
|
# target_compile_options(LinearAlgebraTest PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
endif()
|
|
|
|
|
|
include(GoogleTest)
|
|
gtest_discover_tests(LinearAlgebraTest)
|
|
endif()
|
|
|