0

I am using the modern conan method for compiling. I am cross compiling an application and am trying to figure out how to convert my existing gcc command to conan / cmake solution.

Here is the gcc command: arm-linux-gnueabihf-gcc -Wall -static -o sctc sctc.cpp -lm -lstdc++

Pretty simple.
I have successfully built the application using conan/cmake. However it is not running, I think because I am unable to invoke add the options:

  • -static
  • -lm
  • -lstdc++

I think. Also, would like to know how to add -Wall. How are people debugging the command lines? Any docs or blogs about it?

Here is the conanfile.py

from conans import ConanFile, tools
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps

import os

class SctsConan(ConanFile):
    name = "sctc"
    version = "1.0.0"
    license = "<Put the package license here>"
    author = "<Put your name here> <And your email here>"
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": False, "fPIC": True}
    generators = "compiler_args"

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

    def requirements(self):
        self.requires("fff/1.1")
        self.requires("gtest/cci.20210126")

    def generate(self):
        tc = CMakeToolchain(self)
        tc.generate()
        deps = CMakeDeps(self)
        deps.generate()


    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def package_info(self):
        self.cpp_info.libs = ["sctc"]

Here is the profile

[settings]
os=Linux
compiler=gcc
compiler.version=9.4
compiler.libcxx=libstdc++11
build_type=Release
arch=armv6

[env]
CC=arm-linux-gnueabihf-gcc
CXX=arm-linux-gnueabihf-g++-9

Here is the CMakeFile.txt

cmake_minimum_required(VERSION 3.14)
project(sctc)

add_executable(sctc sctc.cpp )

Any pointers to documentation are welcome. I tried searching for answers but was not able to find anything that I thought relevant. I am new to conan and cmake but am enjoying working with both.

Cheers, Dave

Dave
  • 1
  • 1
  • When you are moving to CMake, all of those details are part of the CMakeLists.txt file, while Conan implements the higher level orchestration of the building and packaging. This might not be the best place for posting a full case, but if you want to add a link with your full project, including the source code, the CMakeLists, etc, then the https://github.com/conan-io/conan/issues could be better for this kind of support. – drodri Jun 08 '22 at 21:12
  • Thanks drodi! I will do so. The Above links helped me and based on them I was able to resolve my issues. It is hard to know what the best practices are as some parts of the build options are performed through conan and others in CMake. Anyways, really appreciate any help that I got. Cheers! – Dave Jun 10 '22 at 15:19

0 Answers0