Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cpputest/4.0 #4366

Merged
merged 51 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9fcbbe0
Copy in files from szip as a starting point
claremacrae Jan 26, 2021
084c76d
Update versions for cpputest
claremacrae Jan 26, 2021
a77a96a
Copy in values for CppUTest
claremacrae Jan 26, 2021
ce4a8c8
Fix error:
claremacrae Jan 26, 2021
64bc267
Remove references to patches
claremacrae Jan 26, 2021
ebb7a0b
Remove reference to CMAKE_POSITION_INDEPENDENT_CODE
claremacrae Jan 26, 2021
c59cec4
Copy in test code from https://github.com/cpputest/conan-cpputest/blo…
claremacrae Jan 26, 2021
43bb36e
Fix building of cpputest test package
claremacrae Jan 26, 2021
5669bba
Remove remnant references to szip
claremacrae Jan 26, 2021
cddb69e
Fix inconsistent quoting of version numbers
claremacrae Jan 26, 2021
d98daa6
Second attempt at fixing quoting of version numbers
claremacrae Jan 26, 2021
657c9be
Fix PC-FILES (KB-H020) by deleting lib/pkgconfig directory
claremacrae Jan 26, 2021
86907bb
Fix CMAKE-MODULES-CONFIG-FILES (KB-H016) by deleting lib/CppUTest/cmake
claremacrae Jan 26, 2021
9558c6d
Add options
claremacrae Jan 26, 2021
1af011c
Turn tests off, by default
claremacrae Jan 26, 2021
f4327a5
Update recipes/cpputest/all/conanfile.py
claremacrae Jan 27, 2021
a43fa98
Remove coverage and tests options - and force them to always be off.
claremacrae Jan 27, 2021
e8ee75a
Code review feedback: Fix use of find_package()
claremacrae Jan 27, 2021
8f855a6
Correct homepage URL to use https
claremacrae Jan 27, 2021
380caae
Remove unnecessary quotes in add_subdirectory() call
claremacrae Jan 27, 2021
3750ed8
Whitespace change: Fix inconsistent indentation
claremacrae Jan 27, 2021
d47ab82
Make default fPIC value consistent with majority of other recipes
claremacrae Jan 27, 2021
1f56212
Code review feedback: Set pkg_config name
claremacrae Jan 28, 2021
505c09b
Code review feedback: Remove unnecessary setting of self.cpp_info.fil…
claremacrae Jan 28, 2021
b8899f8
Attempt to fix Windows linker errors
claremacrae Jan 30, 2021
b83b8da
Further attempt to fix Windows linker errors
claremacrae Jan 30, 2021
767a0f5
Code review feedback: conditionally remove C++ settings
claremacrae Jan 30, 2021
33fd6c9
Further attempt to fix Windows linker errors
claremacrae Jan 30, 2021
73ad770
Fix typo in configure()
claremacrae Jan 30, 2021
5a3afcc
Remove ".lib" from library names, in further attempt to fix
claremacrae Jan 30, 2021
669e1e0
Remove verbose option - it doesn't affect the output library
claremacrae Jan 31, 2021
b4e90e8
Make tests pass if extensions are disabled
claremacrae Jan 31, 2021
11b570c
Invert if condition, to reduce nesting of code
claremacrae Jan 31, 2021
e65a2ef
Further attempt at fixing missing symbols on Windows
claremacrae Jan 31, 2021
5369177
Another attempt at fixing missing symbols on Windows
claremacrae Jan 31, 2021
6b43b85
Revert back to the way of specifying winmm in b83b8da0f8daed0f898b6d4…
claremacrae Jan 31, 2021
3a0a038
Fix windows linker errors
claremacrae Feb 3, 2021
3750335
Delete fPIC option if shared
claremacrae Feb 3, 2021
4c8c23e
Shared libraries are not supported, so remove that option
claremacrae Feb 3, 2021
e1de550
Completely remove shared option, as shared builds not supported
claremacrae Feb 3, 2021
7966248
Code-review feedback: Remove commented-out lines
claremacrae Feb 3, 2021
33014fd
Code-review feedback: Add pthread dependency on some platforms
claremacrae Feb 3, 2021
98104da
Add target CppUTest::CppUTestExt
claremacrae Feb 4, 2021
6a90c31
Make CppUTest::CppUTestExt depend on CppUTest::CppUTest
claremacrae Feb 4, 2021
5b91652
Port remaining package_info() code to components
claremacrae Feb 4, 2021
67cbd74
Rename option extensions to with_extensions
claremacrae Feb 4, 2021
95d10ac
Rename option longlong to with_longlong
claremacrae Feb 4, 2021
a53aff0
Rename option detect_mem_leaks to detect_memory_leaks
claremacrae Feb 4, 2021
ba70c31
Remove all options except fPIC and with_extensions
claremacrae Feb 4, 2021
a20a050
Remove empty method configure()
claremacrae Feb 5, 2021
9108346
Code review suggestion: "with_extensions" now uses [True, False]
claremacrae Feb 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/cpputest/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
5 changes: 5 additions & 0 deletions recipes/cpputest/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sources:
"4.0":
url: "https://github.com/cpputest/cpputest/releases/download/v4.0/cpputest-4.0.tar.gz"
sha256: 21c692105db15299b5529af81a11a7ad80397f92c122bd7bf1e4a4b0e85654f7

89 changes: 89 additions & 0 deletions recipes/cpputest/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import os

from conans import ConanFile, CMake, tools

class CppUTestConan(ConanFile):
name = "cpputest"
description = \
"CppUTest is a C /C++ based unit xUnit test framework for unit testing and for test-driving your code." \
"It is written in C++ but is used in C and C++ projects and frequently" \
"used in embedded systems but it works for any C/C++ project."
license = "BSD-3-Clause"
topics = ("conan", "testing", "unit-testing")
homepage = "https://cpputest.github.io"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"with_extensions": [True, False],
}
default_options = {
"fPIC": True,
"with_extensions": True,
}

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename(self.name + "-" + self.version, self._source_subfolder)

def build(self):
cmake = self._configure_cmake()
cmake.build()

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["STD_C"] = "ON"
self._cmake.definitions["STD_CPP"] = "ON"
self._cmake.definitions["C++11"] = "ON"
self._cmake.definitions["MEMORY_LEAK_DETECTION"] = "ON"
self._cmake.definitions["EXTENSIONS"] = self.options.with_extensions
self._cmake.definitions["LONGLONG"] = "ON"
self._cmake.definitions["COVERAGE"] = "OFF"
self._cmake.definitions["TESTS"] = "OFF"
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "lib", "CppUTest", "cmake"))

def package_info(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to explicitly set the pkg_config names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure that I understand that, but I have improved code in this area in e8ee75a.

If that's not what you mean, please can I have a bit more info?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need file name ... the default is names

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def package_info(self):
Self.cpp_info.names["pkg_config"] = "whatever the .pc file is that's removed"

Via mobile ⚠️

self.cpp_info.names["cmake_find_package"] = "CppUTest"
self.cpp_info.names["cmake_find_package_multi"] = "CppUTest"
self.cpp_info.names["pkg_config"] = "cpputest"

self.cpp_info.components["CppUTest"].names["cmake_find_package"] = "CppUTest"
self.cpp_info.components["CppUTest"].names["cmake_find_package_multi"] = "CppUTest"
self.cpp_info.components["CppUTest"].libs = ["CppUTest"]

if self.options.with_extensions:
self.cpp_info.components["CppUTestExt"].names["cmake_find_package"] = "CppUTestExt"
self.cpp_info.components["CppUTestExt"].names["cmake_find_package_multi"] = "CppUTestExt"
self.cpp_info.components["CppUTestExt"].libs = ["CppUTestExt"]
self.cpp_info.components["CppUTestExt"].requires = ["CppUTest"]

if self.settings.os == "Windows":
self.cpp_info.components["CppUTest"].system_libs.extend(["winmm"])
elif self.settings.os in ("Linux", "FreeBSD"):
self.cpp_info.components["CppUTest"].system_libs = ["pthread"]
16 changes: 16 additions & 0 deletions recipes/cpputest/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(CppUTest REQUIRED CONFIG)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package CppUTest::CppUTest)

if(WITH_EXTENSIONS)
add_executable(test_package_with_extensions test_package_with_extensions.cpp)
# Note: CppUTest::CppUTestExt adds dependency on CppUTest::CppUTest
target_link_libraries(test_package_with_extensions CppUTest::CppUTestExt)
endif()
22 changes: 22 additions & 0 deletions recipes/cpputest/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.definitions["WITH_EXTENSIONS"] = self.options["cpputest"].with_extensions
cmake.configure()
cmake.build()

def test(self):
if tools.cross_building(self.settings):
return

self.run(os.path.join("bin", "test_package"), run_environment=True)

if self.options["cpputest"].with_extensions:
self.run(os.path.join("bin", "test_package_with_extensions"), run_environment=True)
18 changes: 18 additions & 0 deletions recipes/cpputest/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <CppUTest/TestHarness.h>
#include <CppUTest/TestRegistry.h>
#include <CppUTest/CommandLineTestRunner.h>

TEST_GROUP(FirstTestGroup)
{
};

TEST(FirstTestGroup, FirstTest)
{
CHECK_TRUE(true);
}

int main(int argc, const char** argv)
{
CommandLineTestRunner runner(argc, argv, TestRegistry::getCurrentRegistry());
return runner.runAllTestsMain();
}
19 changes: 19 additions & 0 deletions recipes/cpputest/all/test_package/test_package_with_extensions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <CppUTest/TestHarness.h>
#include <CppUTest/TestRegistry.h>
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTestExt/GTestSupport.h> // Only found if extensions enabled

TEST_GROUP(FirstTestGroup)
{
};

TEST(FirstTestGroup, FirstTest)
{
CHECK_TRUE(true);
}

int main(int argc, const char** argv)
{
CommandLineTestRunner runner(argc, argv, TestRegistry::getCurrentRegistry());
return runner.runAllTestsMain();
}
3 changes: 3 additions & 0 deletions recipes/cpputest/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"4.0":
folder: all