conan-io / examples2

Conan 2.x examples
MIT License
89 stars 49 forks source link

Add autotools example with fmtlib as dependency #84

Closed uilianries closed 1 year ago

uilianries commented 1 year ago

This very simple example using autotools is a part of the issue https://github.com/conan-io/docs/issues/3064

The fmt is already available on Conan Center for Conan v2

I didn't add support to Windows (.batch file) because we use Autotools on Linux/Max 90% of time. And it would increase complexity, as we would need to install msys2, or at least, be clear about some bash configured in the system.

To build locally:

$ conan install . && source conanbuild.sh &&./autogen.sh && ./configure && make && ./stringformatter

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=10
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=10
os=Linux

======== Computing dependency graph ========
Graph root
    conanfile.txt: /home/conan/project/conanfile.txt
Requirements
    fmt/9.1.0#e747928f85b03f48aaf227ff897d9634 - Cache

======== Computing necessary packages ========
Requirements
    fmt/9.1.0#e747928f85b03f48aaf227ff897d9634:329b3f931fcf4df166f2305ec2726eb4b27190d5#f67f5020fd59c785258a962d875ae21e - Cache

======== Installing packages ========
fmt/9.1.0: Already installed! (1 of 1)
WARN: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN:     'cpp_info.names' used in: fmt/9.1.0

======== Finalizing install (deploy, generators) ========
conanfile.txt: Writing generators to /home/conan/project
conanfile.txt: Generator 'AutotoolsToolchain' calling 'generate()'
conanfile.txt: Generator 'PkgConfigDeps' calling 'generate()'
conanfile.txt: Generating aggregated env files
conanfile.txt: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
Install finished succesfully
+ aclocal
+ automake --add-missing
configure.ac:2: installing './install-sh'
configure.ac:2: installing './missing'
Makefile.am: installing './depcomp'
+ autoconf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for fmt... yes
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/g++ accepts -g... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of /usr/bin/g++... gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
/usr/bin/g++ -DPACKAGE_NAME=\"stringformatter\" -DPACKAGE_TARNAME=\"stringformatter\" -DPACKAGE_VERSION=\"0.1.0\" -DPACKAGE_STRING=\"stringformatter\ 0.1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I.  -I/home/conan/.conan2/p/fmtd463ab80d6cb3/p/include -DNDEBUG -DNDEBUG  -std=gnu++14 -m64 -O3 -std=gnu++14 -m64 -O3 -MT src/stringformatter-main.o -MD -MP -MF src/.deps/stringformatter-main.Tpo -c -o src/stringformatter-main.o `test -f 'src/main.cpp' || echo './'`src/main.cpp
mv -f src/.deps/stringformatter-main.Tpo src/.deps/stringformatter-main.Po
/usr/bin/g++  -std=gnu++14 -m64 -O3 -std=gnu++14 -m64 -O3  -m64 -m64 -o stringformatter src/stringformatter-main.o -L/home/conan/.conan2/p/fmtd463ab80d6cb3/p/lib -lfmt -lm 
Conan - The C++ Package Manager!
uilianries commented 1 year ago

@memsharded I beat Windows! The support on Windows is working now.

To include nmake + msvc I would suggest another PR, because it would require another extra configuration with nmake.

czoido commented 1 year ago

Please, do not forget to update the Conan recipe tools examples README

uilianries commented 1 year ago

@czoido Done.

uilianries commented 1 year ago

I just removed Windows support for now, let's do it in a separated PR, so we can explore NMake + msvc scenario.