2024-04-10 17:47:04 +00:00
|
|
|
cmake_minimum_required(VERSION 3.20)
|
|
|
|
|
|
|
|
# Use the fancy version substitution
|
|
|
|
project(cmake-cpputest-template
|
|
|
|
VERSION 1.0
|
|
|
|
DESCRIPTION "template for cmake + cpputest"
|
|
|
|
LANGUAGES C CXX
|
|
|
|
)
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
set(TARGET_GROUP production CACHE STRING "Group to build")
|
|
|
|
|
|
|
|
if(MSVC OR MSYS OR MINGW)
|
|
|
|
message("### SETUP FOR WINDOWS ###")
|
|
|
|
add_definitions(-DWINDOWS)
|
|
|
|
else()
|
|
|
|
message("### SETUP FOR UNIX ###")
|
|
|
|
add_definitions(-DUNIX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# For being able to used LSP
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
# Request C 17 standard features
|
2024-04-10 18:16:09 +00:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2024-04-10 17:47:04 +00:00
|
|
|
set(CMAKE_C_STANDARD_REQUIRED True)
|
|
|
|
set(CMAKE_C_FLAGS "-Wall -Werror -Wpedantic")
|
|
|
|
|
|
|
|
# SETUP THE CXX flags for .cpp
|
2024-04-10 18:16:09 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
2024-04-10 17:47:04 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wpedantic")
|
|
|
|
|
2024-04-10 18:21:21 +00:00
|
|
|
#Define the device type
|
|
|
|
add_definitions(-D__AVR_ATtiny13A__)
|
2024-04-10 17:47:04 +00:00
|
|
|
|
|
|
|
# #######################################
|
|
|
|
# TESTING STUFF
|
|
|
|
# #######################################
|
|
|
|
|
|
|
|
|
|
|
|
if (UNIT_TESTING)
|
|
|
|
|
|
|
|
if(DEFINED ENV{CPPUTEST_HOME})
|
|
|
|
message(STATUS "Using CppUTest home: $ENV{CPPUTEST_HOME}")
|
|
|
|
set(CPPUTEST_INCLUDE_DIRS $ENV{CPPUTEST_HOME}/include)
|
|
|
|
set(CPPUTEST_LIBRARIES $ENV{CPPUTEST_HOME}/lib)
|
|
|
|
set(CPPUTEST_LDFLAGS CppUTest CppUTestExt)
|
|
|
|
else()
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_search_module(CPPUTEST REQUIRED cpputest>=3.8)
|
|
|
|
message(STATUS "Found CppUTest version ${CPPUTEST_VERSION}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${CPPUTEST_INCLUDE_DIRS}
|
|
|
|
/usr/include/c++/11/
|
|
|
|
)
|
|
|
|
link_directories(${CPPUTEST_LIBRARIES})
|
|
|
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# #######################################
|
|
|
|
# PROJECT SPECIFIC
|
|
|
|
# #######################################
|
|
|
|
|
|
|
|
add_subdirectory(src)
|