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 MakeDeps example #115

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions examples/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@
### [tools.autotools](autotools)

- Build a [Autotools project](autotools/autotoolstoolchain/string_formatter/) using Conan and [fmt](https://fmt.dev/). [Docs](https://docs.conan.io/2/examples/tools/autotools/autotools_toolchain/build_project_autotools_toolchain.rst)


### [tools.makefiles](makefiles)

- Build a [Makefile project](makefile/makedeps/logger) using Conan and [make](https://www.gnu.org/software/make/). [Docs](https://docs.conan.io/2/examples/tools/makefile/makedeps/build_project_makefile.rst)
17 changes: 17 additions & 0 deletions examples/tools/makefile/makedeps/logger/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SRC_FOLDER = $(ROOT_DIR)/src
BUILD_FOLDER = $(ROOT_DIR)/build

include $(BUILD_FOLDER)/conandeps.mk

CXXFLAGS += $(CONAN_CXXFLAGS) -std=c++11
CPPFLAGS += $(addprefix -I, $(CONAN_INCLUDE_DIRS))
CPPFLAGS += $(addprefix -D, $(CONAN_DEFINES))
LDFLAGS += $(addprefix -L, $(CONAN_LIB_DIRS))
LDLIBS += $(addprefix -l, $(CONAN_LIBS))
LDLIBS += $(addprefix -l, $(CONAN_SYSTEM_LIBS))
EXELINKFLAGS += $(CONAN_EXELINKFLAGS)


all:
$(CXX) $(SRC_FOLDER)/main.cpp $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) $(EXELINKFLAGS) -o $(BUILD_FOLDER)/logger
5 changes: 5 additions & 0 deletions examples/tools/makefile/makedeps/logger/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[requires]
spdlog/1.12.0

[generators]
MakeDeps
32 changes: 32 additions & 0 deletions examples/tools/makefile/makedeps/logger/run_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

echo "- MakeDeps: The Makefile dependencies generator for Make -"

set -ex

# Remove cache
rm -rf build

# Then generate conanbuild.sh
conan install -r conancenter . -of build --build=missing
source build/conanbuild.sh

# Build the example
make

source build/deactivate_conanbuild.sh

# Make dynamic library available on PATH
source build/conanrun.sh

output=$(build/logger)

expected_str='To be a Cimmerian warrior, you must have both cunning and balance as well as speed and strength.'

if [[ $expected_str -eq $output ]]; then
echo "ERROR: The String Formatter output does not match with the expected value: '$(expected_str)'"
exit 1
fi

echo 'MakeDeps example has been executed with SUCCESS!'
exit 0
8 changes: 8 additions & 0 deletions examples/tools/makefile/makedeps/logger/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <cstdlib>
#include "spdlog/spdlog.h"


int main(void) {
spdlog::info("To be a Cimmerian warrior, you must have both cunning and balance as well as speed and strength.");
return EXIT_SUCCESS;
}