diff --git a/CMakeLists.txt b/CMakeLists.txt index 2527f70b..8b379960 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,21 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.18) project(aedis CXX) option(AEDIS_BUILD_EXAMPLES "Build aedis examples" ON) option(AEDIS_BUILD_TESTS "Build aedis tests" ON) -option(AEDIS_USE_CONAN "Include the conan build info file" ON) +option(AEDIS_USE_CONAN "Include the conan build info file" OFF) include(GNUInstallDirs) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines") + +#target_compile_features(aedis INTERFACE cxx_std_20) +#add_definitions(-D BOOST_ASIO_CONCURRENCY_HINT_1=BOOST_ASIO_CONCURRENCY_HINT_UNSAFE) +#add_definitions(-D BOOST_ASIO_NO_DEPRECATED) +#add_definitions(-D BOOST_ASIO_NO_TS_EXECUTORS) + if(AEDIS_USE_CONAN) include("${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(TARGETS) @@ -15,42 +23,40 @@ if(AEDIS_USE_CONAN) endif() find_package(Boost 1.74 REQUIRED COMPONENTS system) -find_package(fmt 7.0 REQUIRED) add_library(aedis INTERFACE) add_library(aedis::aedis ALIAS aedis) -target_link_libraries(aedis INTERFACE fmt::fmt Boost::system) -target_compile_features(aedis INTERFACE cxx_std_20) - target_include_directories(aedis INTERFACE $ - $ + $ ) if(AEDIS_BUILD_EXAMPLES) - add_executable(examples examples.cpp) - target_link_libraries(examples PRIVATE aedis::aedis) + add_executable(example examples/example.cpp) + target_link_libraries(example PRIVATE aedis::aedis) endif() if(AEDIS_BUILD_TESTS) enable_testing() - add_executable(tests tests.cpp) - target_link_libraries(tests PRIVATE aedis::aedis) - add_test(NAME aedis_tests COMMAND tests) + add_executable(general tests/general.cpp) + target_link_libraries(general PRIVATE aedis::aedis) + add_test(NAME aedis_test COMMAND general) endif() file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/aedis-config.cmake" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) install(TARGETS aedis EXPORT aedis-targets) -install(FILES aedis.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES include/aedis/aedis.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/aedis-config.cmake" DESTINATION share/cmake/aedis) install(EXPORT aedis-targets FILE aedis-targets.cmake NAMESPACE aedis:: DESTINATION share/cmake/aedis ) + export( EXPORT aedis-targets FILE "${CMAKE_CURRENT_BINARY_DIR}/aedis-targets.cmake" NAMESPACE aedis:: ) + diff --git a/Makefile b/Makefile index d1a9da7c..5bc4cd97 100644 --- a/Makefile +++ b/Makefile @@ -4,34 +4,38 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. -CXX = /opt/gcc-10.2.0/bin/g++-10.2.0 +#CXX = /opt/gcc-10.2.0/bin/g++-10.2.0 CPPFLAGS = CPPFLAGS += -g CPPFLAGS += -std=c++20 CPPFLAGS += -fcoroutines CPPFLAGS += -I/opt/boost_1_74_0/include +CPPFLAGS += -I./include CPPFLAGS += -D BOOST_ASIO_CONCURRENCY_HINT_1=BOOST_ASIO_CONCURRENCY_HINT_UNSAFE CPPFLAGS += -D BOOST_ASIO_NO_DEPRECATED CPPFLAGS += -D BOOST_ASIO_NO_TS_EXECUTORS LDFLAGS += -pthread -LDFLAGS += -lfmt -all: examples tests +all: example general Makefile.dep: - -$(CXX) -MM ./*.cpp > $@ + -$(CXX) -MM ./examples/*.cpp ./tests/*.cpp> $@ -include Makefile.dep -examples: examples.cpp +example: examples/example.cpp $(CXX) -o $@ $^ $(CPPFLAGS) $(LDFLAGS) -tests: % : tests.cpp +general: % : tests/general.cpp $(CXX) -o $@ $^ $(CPPFLAGS) $(LDFLAGS) +.PHONY: check +check: general + ./general + .PHONY: clean clean: - rm -f examples examples.o tests tests.o Makefile.dep + rm -f example example.o general general.o Makefile.dep diff --git a/cmake/aedis-config.cmake b/cmake/aedis-config.cmake index caa19829..9841491f 100644 --- a/cmake/aedis-config.cmake +++ b/cmake/aedis-config.cmake @@ -1,6 +1,5 @@ include(CMakeFindDependencyMacro) find_dependency(Boost 1.74 COMPONENTS system REQUIRED) -find_dependency(fmt 7.0 REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/aedis-targets.cmake") diff --git a/examples.cpp b/examples/example.cpp similarity index 98% rename from examples.cpp rename to examples/example.cpp index d06ae74a..046a4f61 100644 --- a/examples.cpp +++ b/examples/example.cpp @@ -6,8 +6,7 @@ */ #include - -#include "aedis.hpp" +#include namespace net = aedis::net; using tcp = net::ip::tcp; diff --git a/aedis.hpp b/include/aedis/aedis.hpp similarity index 99% rename from aedis.hpp rename to include/aedis/aedis.hpp index 17d1d6cc..88ea883b 100644 --- a/aedis.hpp +++ b/include/aedis/aedis.hpp @@ -29,9 +29,6 @@ #include -#include -#include - namespace aedis { @@ -543,7 +540,7 @@ void write(level filter, level ll, char const* fmt, Args const& ... args) if (ll > filter) return; - std::clog << fmt::format(fmt, args...) << std::endl; + //std::clog << std::format(fmt, args...) << std::endl; } } diff --git a/tests.cpp b/tests/general.cpp similarity index 99% rename from tests.cpp rename to tests/general.cpp index 7a5aff28..883fe04e 100644 --- a/tests.cpp +++ b/tests/general.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#include "aedis.hpp" +#include namespace net = aedis::net; using tcp = net::ip::tcp;