Fixed up root cmake config
+ Added -Werror flag. + Added correct CppUTest pkg finding. + Added inclusion of new layout.
This commit is contained in:
parent
2587bb2aba
commit
79e8629823
1 changed files with 17 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
# Use the fancy version substitution
|
# Use the fancy version substitution
|
||||||
project(main
|
project(WCH_Template
|
||||||
VERSION 0.1.0
|
VERSION 0.1.0
|
||||||
DESCRIPTION "template for cmake + cpputest"
|
DESCRIPTION "template for cmake + cpputest"
|
||||||
LANGUAGES C CXX
|
LANGUAGES C CXX
|
||||||
|
|
@ -24,7 +24,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
# Request C standard features
|
# Request C standard features
|
||||||
set(CMAKE_C_STANDARD 23)
|
set(CMAKE_C_STANDARD 23)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED True)
|
set(CMAKE_C_STANDARD_REQUIRED True)
|
||||||
set(CMAKE_C_FLAGS "-Wall -Wpedantic")
|
set(CMAKE_C_FLAGS "-Wall -Werror -Wpedantic")
|
||||||
|
|
||||||
# SETUP THE CXX flags for .cpp
|
# SETUP THE CXX flags for .cpp
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
@ -39,27 +39,30 @@ set(CMAKE_CXX_FLAGS "-Wall -Werror -Wpedantic")
|
||||||
|
|
||||||
|
|
||||||
if (UNIT_TESTING)
|
if (UNIT_TESTING)
|
||||||
|
#Allows usage of preprossor stuff in your files.
|
||||||
|
add_compile_definitions(UNIT_TESTING=1)
|
||||||
if(DEFINED ENV{CPPUTEST_HOME})
|
if(DEFINED ENV{CPPUTEST_HOME})
|
||||||
message(STATUS "Using CppUTest home: $ENV{CPPUTEST_HOME}")
|
message(STATUS "Using CppUTest home: $ENV{CPPUTEST_HOME}")
|
||||||
set(CPPUTEST_INCLUDE_DIRS $ENV{CPPUTEST_HOME}/include)
|
set(CPPUTEST_INCLUDE_DIRS $ENV{CPPUTEST_HOME}/include)
|
||||||
set(CPPUTEST_LIBRARIES $ENV{CPPUTEST_HOME}/lib)
|
set(CPPUTEST_LIBRARY_DIRS $ENV{CPPUTEST_HOME}/lib)
|
||||||
set(CPPUTEST_LDFLAGS CppUTest CppUTestExt)
|
#set(CPPUTEST_LIBRARIES $ENV{CPPUTEST_HOME}/lib)
|
||||||
|
#set(CPPUTEST_LIBRARIES CppUTest CppUTestExt)
|
||||||
|
#set(CPPUTEST_LDFLAGS CppUTest CppUTestExt)
|
||||||
|
set(CPPUTEST_LIBRARIES CppUTest CppUTestExt)
|
||||||
else()
|
else()
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(CPPUTEST REQUIRED cpputest>=3.8)
|
pkg_search_module(CPPUTEST REQUIRED cpputest>=3.8)
|
||||||
message(STATUS "Found CppUTest version ${CPPUTEST_VERSION}")
|
message(STATUS "Found CppUTest version ${CPPUTEST_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Diagnostic Messages for Multi-Platform testing.
|
||||||
|
message(STATUS "CPPUTEST_LIBRARY_DIRS: ${CPPUTEST_LIBRARY_DIRS}")
|
||||||
|
message(STATUS "CPPUTEST_INCLUDE_DIRS: ${CPPUTEST_INCLUDE_DIRS}" )
|
||||||
|
message(STATUS "CPPUTEST_LIBRARIES: ${CPPUTEST_LIBRARIES}" )
|
||||||
|
|
||||||
|
include_directories(${CPPUTEST_INCLUDE_DIRS})
|
||||||
|
link_directories(${CPPUTEST_LIBRARY_DIRS})
|
||||||
|
|
||||||
include_directories(
|
|
||||||
${CPPUTEST_INCLUDE_DIRS}
|
|
||||||
#/usr/include/c++/11/
|
|
||||||
./inc
|
|
||||||
./mocks
|
|
||||||
)
|
|
||||||
link_directories(${CPPUTEST_LIBRARIES})
|
|
||||||
|
|
||||||
add_subdirectory(mocks)
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue