From 9c8fbccb21c15c88632ee2f31f6c6fbf57723bb6 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 29 Aug 2023 11:04:45 +0200 Subject: [PATCH 1/7] Add MakeDeps example Signed-off-by: Uilian Ries --- examples/tools/makefile/makedeps/Makefile | 16 ++++++++++ .../tools/makefile/makedeps/conanfile.txt | 5 +++ .../tools/makefile/makedeps/run_example.bat | 24 ++++++++++++++ .../tools/makefile/makedeps/run_example.sh | 32 +++++++++++++++++++ examples/tools/makefile/makedeps/src/main.cpp | 21 ++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 examples/tools/makefile/makedeps/Makefile create mode 100644 examples/tools/makefile/makedeps/conanfile.txt create mode 100755 examples/tools/makefile/makedeps/run_example.bat create mode 100755 examples/tools/makefile/makedeps/run_example.sh create mode 100644 examples/tools/makefile/makedeps/src/main.cpp diff --git a/examples/tools/makefile/makedeps/Makefile b/examples/tools/makefile/makedeps/Makefile new file mode 100644 index 00000000..720bb7a2 --- /dev/null +++ b/examples/tools/makefile/makedeps/Makefile @@ -0,0 +1,16 @@ +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)) +EXELINKFLAGS += $(CONAN_EXELINKFLAGS) + + +all: + $(CXX) $(SRC_FOLDER)/main.cpp $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) $(EXELINKFLAGS) -o $(BUILD_FOLDER)/string_digest_hex diff --git a/examples/tools/makefile/makedeps/conanfile.txt b/examples/tools/makefile/makedeps/conanfile.txt new file mode 100644 index 00000000..f41971bf --- /dev/null +++ b/examples/tools/makefile/makedeps/conanfile.txt @@ -0,0 +1,5 @@ +[requires] +poco/1.12.4 + +[generators] +MakeDeps diff --git a/examples/tools/makefile/makedeps/run_example.bat b/examples/tools/makefile/makedeps/run_example.bat new file mode 100755 index 00000000..771ae5e7 --- /dev/null +++ b/examples/tools/makefile/makedeps/run_example.bat @@ -0,0 +1,24 @@ +@echo on + +echo "- MakeDeps: The Makefile dependencies generator for Make -" + +Rem Remove cache +@rd /S /Q build + +Rem Then generate conanbuild.sh +call conan install -r conancenter . -of build --build=missing +call build/conanbuild.bat + +Rem Build the example +make + +call build/deactivate_conanbuild.bat + +Rem Make dynamic library available on PATH +call build/conanrun.sh + +call build/string_digest_hex.exe + +echo 'MakeDeps example has been executed with SUCCESS!' + +exit 0 diff --git a/examples/tools/makefile/makedeps/run_example.sh b/examples/tools/makefile/makedeps/run_example.sh new file mode 100755 index 00000000..309cd943 --- /dev/null +++ b/examples/tools/makefile/makedeps/run_example.sh @@ -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/string_digest_hex) + +expected_str='[9d9bad5e773ca301b2a2977843ce6fb5] 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 diff --git a/examples/tools/makefile/makedeps/src/main.cpp b/examples/tools/makefile/makedeps/src/main.cpp new file mode 100644 index 00000000..8d280f83 --- /dev/null +++ b/examples/tools/makefile/makedeps/src/main.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +#include "Poco/MD5Engine.h" +#include "Poco/DigestStream.h" + +int main(void) { + Poco::MD5Engine md5; + Poco::DigestOutputStream dos(md5); + const std::string quote ("To be a Cimmerian warrior, you must have both cunning and balance as well as speed and strength."); + + dos << quote << std::endl; + dos.flush(); + + const Poco::DigestEngine::Digest& digest = md5.digest(); + + std::cout << "[" << Poco::DigestEngine::digestToHex(digest) << "] " << quote << std::endl; + + return EXIT_SUCCESS; +} From 37b89994fdec043cbaf165d85502833d7b5fd383 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 29 Aug 2023 12:56:54 +0200 Subject: [PATCH 2/7] remove windows support Signed-off-by: Uilian Ries --- .../tools/makefile/makedeps/run_example.bat | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100755 examples/tools/makefile/makedeps/run_example.bat diff --git a/examples/tools/makefile/makedeps/run_example.bat b/examples/tools/makefile/makedeps/run_example.bat deleted file mode 100755 index 771ae5e7..00000000 --- a/examples/tools/makefile/makedeps/run_example.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo on - -echo "- MakeDeps: The Makefile dependencies generator for Make -" - -Rem Remove cache -@rd /S /Q build - -Rem Then generate conanbuild.sh -call conan install -r conancenter . -of build --build=missing -call build/conanbuild.bat - -Rem Build the example -make - -call build/deactivate_conanbuild.bat - -Rem Make dynamic library available on PATH -call build/conanrun.sh - -call build/string_digest_hex.exe - -echo 'MakeDeps example has been executed with SUCCESS!' - -exit 0 From 48212398a3811ac57e2384cdcbb832d8590257b0 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 30 Aug 2023 13:41:31 +0200 Subject: [PATCH 3/7] Replace Poco by spdlog Signed-off-by: Uilian Ries --- examples/tools/makefile/makedeps/conanfile.txt | 2 +- examples/tools/makefile/makedeps/run_example.sh | 2 +- examples/tools/makefile/makedeps/src/main.cpp | 17 ++--------------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/examples/tools/makefile/makedeps/conanfile.txt b/examples/tools/makefile/makedeps/conanfile.txt index f41971bf..c0551c05 100644 --- a/examples/tools/makefile/makedeps/conanfile.txt +++ b/examples/tools/makefile/makedeps/conanfile.txt @@ -1,5 +1,5 @@ [requires] -poco/1.12.4 +spdlog/1.12.0 [generators] MakeDeps diff --git a/examples/tools/makefile/makedeps/run_example.sh b/examples/tools/makefile/makedeps/run_example.sh index 309cd943..7a126c13 100755 --- a/examples/tools/makefile/makedeps/run_example.sh +++ b/examples/tools/makefile/makedeps/run_example.sh @@ -21,7 +21,7 @@ source build/conanrun.sh output=$(build/string_digest_hex) -expected_str='[9d9bad5e773ca301b2a2977843ce6fb5] To be a Cimmerian warrior, you must have both cunning and balance as well as speed and strength.' +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)'" diff --git a/examples/tools/makefile/makedeps/src/main.cpp b/examples/tools/makefile/makedeps/src/main.cpp index 8d280f83..3f1e46df 100644 --- a/examples/tools/makefile/makedeps/src/main.cpp +++ b/examples/tools/makefile/makedeps/src/main.cpp @@ -1,21 +1,8 @@ #include -#include -#include +#include "spdlog/spdlog.h" -#include "Poco/MD5Engine.h" -#include "Poco/DigestStream.h" int main(void) { - Poco::MD5Engine md5; - Poco::DigestOutputStream dos(md5); - const std::string quote ("To be a Cimmerian warrior, you must have both cunning and balance as well as speed and strength."); - - dos << quote << std::endl; - dos.flush(); - - const Poco::DigestEngine::Digest& digest = md5.digest(); - - std::cout << "[" << Poco::DigestEngine::digestToHex(digest) << "] " << quote << std::endl; - + spdlog::info("To be a Cimmerian warrior, you must have both cunning and balance as well as speed and strength."); return EXIT_SUCCESS; } From 1a51a316723e87db91cce8eecfaeccd52a297459 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 30 Aug 2023 15:44:25 +0200 Subject: [PATCH 4/7] add system libs Signed-off-by: Uilian Ries --- examples/tools/makefile/makedeps/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/tools/makefile/makedeps/Makefile b/examples/tools/makefile/makedeps/Makefile index 720bb7a2..cad83c94 100644 --- a/examples/tools/makefile/makedeps/Makefile +++ b/examples/tools/makefile/makedeps/Makefile @@ -9,6 +9,7 @@ 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) From 95a3eacc17d497b513af26bc7298306f3b1d4b4a Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 7 Sep 2023 12:29:05 +0200 Subject: [PATCH 5/7] Add README entry Signed-off-by: Uilian Ries --- examples/tools/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/tools/README.md b/examples/tools/README.md index 8fee3df2..0da1541e 100644 --- a/examples/tools/README.md +++ b/examples/tools/README.md @@ -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/) using Conan and [make](https://www.gnu.org/software/make/). [Docs](https://docs.conan.io/2/examples/tools/makefiles/makedeps/build_project_makefile.rst) From 32af89771ab4a4139a7c95afb1f8882b7962c2f8 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 7 Sep 2023 12:36:43 +0200 Subject: [PATCH 6/7] change folder name Signed-off-by: Uilian Ries --- examples/tools/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tools/README.md b/examples/tools/README.md index 0da1541e..7bf2f67b 100644 --- a/examples/tools/README.md +++ b/examples/tools/README.md @@ -23,4 +23,4 @@ ### [tools.makefiles](makefiles) -- Build a [Makefile project](makefile/makedeps/) using Conan and [make](https://www.gnu.org/software/make/). [Docs](https://docs.conan.io/2/examples/tools/makefiles/makedeps/build_project_makefile.rst) +- Build a [Makefile project](makefile/makedeps/) using Conan and [make](https://www.gnu.org/software/make/). [Docs](https://docs.conan.io/2/examples/tools/makefile/makedeps/build_project_makefile.rst) From 70ffb93cada59b75976a304e6388ffe57fb20f05 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 7 Sep 2023 13:06:30 +0200 Subject: [PATCH 7/7] Rename example app to logger Signed-off-by: Uilian Ries --- examples/tools/README.md | 2 +- examples/tools/makefile/makedeps/{ => logger}/Makefile | 2 +- examples/tools/makefile/makedeps/{ => logger}/conanfile.txt | 0 examples/tools/makefile/makedeps/{ => logger}/run_example.sh | 2 +- examples/tools/makefile/makedeps/{ => logger}/src/main.cpp | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename examples/tools/makefile/makedeps/{ => logger}/Makefile (90%) rename examples/tools/makefile/makedeps/{ => logger}/conanfile.txt (100%) rename examples/tools/makefile/makedeps/{ => logger}/run_example.sh (95%) rename examples/tools/makefile/makedeps/{ => logger}/src/main.cpp (100%) diff --git a/examples/tools/README.md b/examples/tools/README.md index 7bf2f67b..6a6bd68e 100644 --- a/examples/tools/README.md +++ b/examples/tools/README.md @@ -23,4 +23,4 @@ ### [tools.makefiles](makefiles) -- Build a [Makefile project](makefile/makedeps/) using Conan and [make](https://www.gnu.org/software/make/). [Docs](https://docs.conan.io/2/examples/tools/makefile/makedeps/build_project_makefile.rst) +- 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) diff --git a/examples/tools/makefile/makedeps/Makefile b/examples/tools/makefile/makedeps/logger/Makefile similarity index 90% rename from examples/tools/makefile/makedeps/Makefile rename to examples/tools/makefile/makedeps/logger/Makefile index cad83c94..e0cb3bb5 100644 --- a/examples/tools/makefile/makedeps/Makefile +++ b/examples/tools/makefile/makedeps/logger/Makefile @@ -14,4 +14,4 @@ EXELINKFLAGS += $(CONAN_EXELINKFLAGS) all: - $(CXX) $(SRC_FOLDER)/main.cpp $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) $(EXELINKFLAGS) -o $(BUILD_FOLDER)/string_digest_hex + $(CXX) $(SRC_FOLDER)/main.cpp $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) $(EXELINKFLAGS) -o $(BUILD_FOLDER)/logger diff --git a/examples/tools/makefile/makedeps/conanfile.txt b/examples/tools/makefile/makedeps/logger/conanfile.txt similarity index 100% rename from examples/tools/makefile/makedeps/conanfile.txt rename to examples/tools/makefile/makedeps/logger/conanfile.txt diff --git a/examples/tools/makefile/makedeps/run_example.sh b/examples/tools/makefile/makedeps/logger/run_example.sh similarity index 95% rename from examples/tools/makefile/makedeps/run_example.sh rename to examples/tools/makefile/makedeps/logger/run_example.sh index 7a126c13..4585465e 100755 --- a/examples/tools/makefile/makedeps/run_example.sh +++ b/examples/tools/makefile/makedeps/logger/run_example.sh @@ -19,7 +19,7 @@ source build/deactivate_conanbuild.sh # Make dynamic library available on PATH source build/conanrun.sh -output=$(build/string_digest_hex) +output=$(build/logger) expected_str='To be a Cimmerian warrior, you must have both cunning and balance as well as speed and strength.' diff --git a/examples/tools/makefile/makedeps/src/main.cpp b/examples/tools/makefile/makedeps/logger/src/main.cpp similarity index 100% rename from examples/tools/makefile/makedeps/src/main.cpp rename to examples/tools/makefile/makedeps/logger/src/main.cpp