Skip to content

CMake build, fix build with CPP_COMPILING, bug fixes#25

Open
matlo607 wants to merge 3 commits intodougbradbury:masterfrom
matlo607:features-cmake-bugfix-cppbuild
Open

CMake build, fix build with CPP_COMPILING, bug fixes#25
matlo607 wants to merge 3 commits intodougbradbury:masterfrom
matlo607:features-cmake-bugfix-cppbuild

Conversation

@matlo607
Copy link
Contributor

I propose an alternative way to build CSlim using CMake and Conan. It creates a small dependency (CONAN_PKG::CppUTest in tests/CMakeLists.txt) on Conan that could be easily fixable by creating a package finder for CppUTest.

To build it with conan, create a file conanfile.txt at the root of the project with the following content.

[requires]
CppUTest/3.8@matthieu/testing

[generators]
cmake

[options]

Create a conanfile.py in another directory and put the following content inside (NB: this file should be published in a separated git repository and uploaded to Conan Center to distribute it directly via Conan).

from os import path
from conans import ConanFile, CMake, tools


class CppUTest(ConanFile):
    name = "CppUTest"
    version = "3.8"
    description = """C /C++ based unit xUnit test framework for unit testing and for test-driving your code"""
    license = "BSD 3-clause \"New\" or \"Revised\" License, https://github.com/cpputest/cpputest/blob/master/COPYING"
    url = "https://cpputest.github.io"
    settings = "os", "compiler", "arch", "build_type"
    source_dir = "{name}-{version}".format(name=name, version=version)
    options = {
        "shared": [True, False],
        "include_pdbs": [True, False],
        "fPIC": [True, False],
        "tests": [True, False],
        "extensions": [True, False]
    }
    default_options = (
        "shared=False",
        "include_pdbs=False",
        "fPIC=False",
        "tests=False",
        "extensions=True"
    )
    scm = {
        "type": "git",
        "subfolder": source_dir,
        "url": "https://github.com/cpputest/cpputest.git",
        "revision": "tags/v{version}".format(version=version)
    }

    def source(self):
        pass

    def build(self):
        cmake = CMake(self)
        #cmake.verbose = True
        cmake.definitions["TESTS"] = self.options.tests
        cmake.configure(source_dir=path.join(self.source_folder, self.source_dir))
        cmake.build()
        if self.options.tests:
            cmake.test()
        cmake.install()

    def package(self):
        pass

    def package_info(self):
        self.cpp_info.libs = ["CppUTest"]
        if self.options.extensions:
            self.cpp_info.libs.append("CppUTestExt")
        if self.settings.compiler == "Visual Studio":
            self.cpp_info.libs.append("winmm.lib")

And run:

mkdir -p conan-recipes/conan-CppUTest
cd conan-recipes/conan-CppUTest
vim conanfile.py
# put the above content in conanfile.py
conan create . matthieu/testing
cd ${CSlim_root}
mkdir build-dir && cd build-dir
conan install ..
cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/root ..
make
make test
make install

@matlo607 matlo607 force-pushed the features-cmake-bugfix-cppbuild branch from a4a558e to 30df5c7 Compare July 24, 2018 12:42
@dougbradbury
Copy link
Owner

Thanks for the PR. It's always good to know that something is being used! It's nice to see a C language source package distribution system. How prolific is Conan?

While I appreciate the reformating, it makes this PR a chore to review. Any chance you would be willing to split the PR into a couple pieces? Reformating, CMAKE, and fixes?

@matlo607
Copy link
Contributor Author

Conan is young but a dynamic community is building around it. Some big companies are beginning to adopt it.
Yes I can split it but the commits are already atomic. Isn't the view by commit ok for reviewing ?

@matlo607
Copy link
Contributor Author

@dougbradbury , I split the commits. Please could you review the PRs ?

@dougbradbury
Copy link
Owner

dougbradbury commented Jan 24, 2019

@matlo607 Is there anything still relevant in this PR?

@matlo607 matlo607 force-pushed the features-cmake-bugfix-cppbuild branch from c86a46c to dbfc0d3 Compare January 24, 2019 20:09
@matlo607 matlo607 force-pushed the features-cmake-bugfix-cppbuild branch from c69b30c to 276d7f5 Compare January 24, 2019 20:24
@matlo607
Copy link
Contributor Author

@dougbradbury, I rebased the branch on master.
There are 2 fixes concerning clang-format. The other was merged, and then reverted.
Should I create another PR for clang-format ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants