2024-03-07 05:06:02 +00:00
|
|
|
cmake_minimum_required(VERSION 3.20)
|
|
|
|
|
|
|
|
# Use the fancy version substitution
|
2024-03-07 05:46:41 +00:00
|
|
|
project(cmake-cpputest-template
|
2024-03-07 05:06:02 +00:00
|
|
|
VERSION 1.0
|
|
|
|
DESCRIPTION "template for cmake + cpputest"
|
|
|
|
LANGUAGES C CXX
|
|
|
|
)
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
set(TARGET_GROUP production CACHE STRING "Group to build")
|
|
|
|
|
2024-03-07 06:01:43 +00:00
|
|
|
if(MSVC OR MSYS OR MINGW)
|
|
|
|
message("### SETUP FOR WINDOWS ###")
|
|
|
|
add_definitions(-DWINDOWS)
|
|
|
|
else()
|
|
|
|
message("### SETUP FOR UNIX ###")
|
|
|
|
add_definitions(-DUNIX)
|
|
|
|
endif()
|
|
|
|
|
2024-03-07 05:06:02 +00:00
|
|
|
# For being able to used LSP
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2024-03-13 05:42:01 +00:00
|
|
|
# Request C 17 standard features
|
|
|
|
set(CMAKE_C_STANDARD 17)
|
2024-03-07 05:06:02 +00:00
|
|
|
set(CMAKE_C_STANDARD_REQUIRED True)
|
|
|
|
set(CMAKE_C_FLAGS "-Wall -Werror -Wpedantic")
|
|
|
|
|
|
|
|
# SETUP THE CXX flags for .cpp
|
2024-03-13 05:42:01 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2024-03-07 05:06:02 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wpedantic")
|
|
|
|
|
|
|
|
|
2024-03-13 05:39:13 +00:00
|
|
|
|
2024-03-07 05:46:41 +00:00
|
|
|
# #######################################
|
|
|
|
# TESTING STUFF
|
|
|
|
# #######################################
|
|
|
|
|
|
|
|
# find_library()
|
2024-03-13 05:39:13 +00:00
|
|
|
set(CPPUTEST_INC_DIR "./cpputest/include")
|
|
|
|
set(CPPUTEST_LIB "./cpputest/build/src/CppUTest/libCppUTest.a")
|
|
|
|
|
|
|
|
# include_directories(
|
|
|
|
# ${CPPUTEST_DIR}
|
|
|
|
# ${CPPUTEST_DIR}/CppUTest
|
|
|
|
# ${CPPUTEST_DIR}/CppUTestExt
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
# add_library(CppUTest OBJECT
|
|
|
|
# ${CPPUTEST_LIB}
|
|
|
|
# )
|
2024-03-07 05:46:41 +00:00
|
|
|
|
|
|
|
if (UNIT_TESTING)
|
2024-03-13 05:39:13 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2024-03-15 20:47:21 +00:00
|
|
|
include_directories(
|
|
|
|
${CPPUTEST_INCLUDE_DIRS}
|
|
|
|
/usr/include/c++/11/
|
|
|
|
)
|
2024-03-13 05:39:13 +00:00
|
|
|
link_directories(${CPPUTEST_LIBRARIES})
|
|
|
|
|
2024-03-07 06:09:26 +00:00
|
|
|
message(STATUS "CPPUTEST_DIR: ${CPPUTEST_DIR}")
|
2024-03-07 05:46:41 +00:00
|
|
|
add_subdirectory(tests)
|
2024-03-13 05:39:13 +00:00
|
|
|
|
2024-03-07 05:46:41 +00:00
|
|
|
endif()
|
2024-03-07 05:06:02 +00:00
|
|
|
|
|
|
|
# #######################################
|
|
|
|
# PROJECT SPECIFIC
|
|
|
|
# #######################################
|
|
|
|
|
2024-03-07 05:46:41 +00:00
|
|
|
add_subdirectory(src)
|