RoboidControl-cpp/CMakeLists.txt
2024-03-15 09:27:23 +01:00

66 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(VectorAlgebra) # Create project "simple_example"
set(CMAKE_CXX_STANDARD 11) # Enable c++11 standard
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_compile_definitions(GTEST)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/heads/main.zip
)
# 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(.)
add_library(VectorAlgebra STATIC
"FloatSingle.cpp"
"Angle.cpp"
"Vector2.cpp"
"Vector3.cpp"
"Quaternion.cpp"
"Polar.cpp"
"Spherical.cpp"
"Matrix.cpp"
)
enable_testing()
add_executable(
VectorAlgebraTest
"test/Angle_test.cc"
"test/FloatSingle_test.cc"
"test/Vector2_test.cc"
"test/Vector3_test.cc"
"test/Quaternion_test.cc"
"test/Matrix_test.cc"
"test/Polar_test.cc"
"test/Spherical_test.cc"
)
target_link_libraries(
VectorAlgebraTest
gtest_main
VectorAlgebra
)
if(MSVC)
target_compile_options(VectorAlgebraTest PRIVATE /W4 /WX)
else()
target_compile_options(VectorAlgebraTest PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
include(GoogleTest)
gtest_discover_tests(VectorAlgebraTest)
endif()