diff --git a/.gitignore b/.gitignore index 63cddfe..424e082 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ test-base64 .wsjcpp/* *.o *.exe +build/ +base64-test-11 +base64-test-17 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c76b25b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.12) +project("cpp-base64" LANGUAGES CXX VERSION 2.0.8 + DESCRIPTION "Base64 encoding and decoding with C++" + HOMEPAGE_URL "https://github.com/CodeFinder2/cpp-base64") +include(GNUInstallDirs) + +add_library(${PROJECT_NAME} src/base64.cpp) +target_include_directories(${PROJECT_NAME} SYSTEM + PUBLIC $ + $) + +install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME} DESTINATION include) +install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}Config.cmake) diff --git a/Makefile b/Makefile index 126e2ca..174815d 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ WARNINGS= \ -fdiagnostics-show-option test: base64-test-11 base64-test-17 - base64-test-11 - base64-test-17 + -./base64-test-11 + -./base64-test-17 base64-test-11: base64-11.o test-11.o g++ base64-11.o test-11.o -o $@ @@ -36,14 +36,14 @@ base64-test-11: base64-11.o test-11.o base64-test-17: base64-17.o test-17.o g++ base64-17.o test-17.o -o $@ -base64-11.o: base64.cpp base64.h - g++ -std=c++11 $(WARNINGS) -c base64.cpp -o base64-11.o +base64-11.o: src/base64.cpp include/cpp-base64/base64.h + g++ -std=c++11 $(WARNINGS) -c src/base64.cpp -o base64-11.o -I include -base64-17.o: base64.cpp base64.h - g++ -std=c++17 $(WARNINGS) -c base64.cpp -o base64-17.o +base64-17.o: src/base64.cpp include/cpp-base64/base64.h + g++ -std=c++17 $(WARNINGS) -c src/base64.cpp -o base64-17.o -I include -test-11.o: test.cpp - g++ -std=c++11 $(WARNINGS) -c test.cpp -o test-11.o +test-11.o: test/test.cpp + g++ -std=c++11 $(WARNINGS) -c test/test.cpp -o test-11.o -I include -test-17.o: test.cpp - g++ -std=c++17 $(WARNINGS) -c test.cpp -o test-17.o +test-17.o: test/test.cpp + g++ -std=c++17 $(WARNINGS) -c test/test.cpp -o test-17.o -I include diff --git a/compile-and-run-test b/compile-and-run-test index 1ab5985..9955487 100755 --- a/compile-and-run-test +++ b/compile-and-run-test @@ -1,2 +1,2 @@ -g++ test.cpp base64.cpp -o test-base64 +g++ test/test.cpp src/base64.cpp -o test-base64 -I include ./test-base64 diff --git a/base64.h b/include/cpp-base64/base64.h similarity index 100% rename from base64.h rename to include/cpp-base64/base64.h diff --git a/base64.cpp b/src/base64.cpp similarity index 99% rename from base64.cpp rename to src/base64.cpp index 7666ef8..8e58efe 100644 --- a/base64.cpp +++ b/src/base64.cpp @@ -31,7 +31,7 @@ */ -#include "base64.h" +#include "cpp-base64/base64.h" #include #include diff --git a/measure-time.cpp b/test/measure-time.cpp similarity index 99% rename from measure-time.cpp rename to test/measure-time.cpp index 91d4df9..46bb73b 100644 --- a/measure-time.cpp +++ b/test/measure-time.cpp @@ -1,4 +1,4 @@ -#include "base64.h" +#include "../include/cpp-base64/base64.h" #include #include diff --git a/test-google.cpp b/test/test-google.cpp similarity index 98% rename from test-google.cpp rename to test/test-google.cpp index bc5090e..261257a 100644 --- a/test-google.cpp +++ b/test/test-google.cpp @@ -1,4 +1,4 @@ -#include "base64.h" +#include "../include/cpp-base64/base64.h" #include #include diff --git a/test.cpp b/test/test.cpp similarity index 99% rename from test.cpp rename to test/test.cpp index 0b641cd..d5885b6 100644 --- a/test.cpp +++ b/test/test.cpp @@ -1,4 +1,4 @@ -#include "base64.h" +#include #include int main() {