From 29065889d0eeaa3e12109a5f509458b07efbf185 Mon Sep 17 00:00:00 2001 From: EndrII Date: Wed, 16 Nov 2022 20:53:29 +0300 Subject: [PATCH 1/6] added support of the cmake build system --- .gitignore | 28 ++++++++++++++++++++++++++++ CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..265c337 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.dll +*.dylib + +# cmake + +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + + +# git +*.orig diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d25d6a5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +if(DEFINED CRC_LIBRARY) + return() +else() + set(CRC_LIBRARY 1) + add_definitions(-DCRC_LIBRARY) +endif() + +project(CRC) + +if(TARGET ${PROJECT_NAME}) + message("The ${PROJECT_NAME} arledy included in main Project") + return() +endif() + +cmake_minimum_required(VERSION 3.1) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +option(BUILD_SHARED_LIBS "Enable or disable shared libraries" OFF) + +file(GLOB SOURCE_CPP + "crc/*.h" + "crc/*.cpp" + "crc/*.c" +) + +add_library(${PROJECT_NAME} ${SOURCE_CPP}) + + From d916c4e448ba2fde28bcd026e90d41faa750dd12 Mon Sep 17 00:00:00 2001 From: EndrII Date: Wed, 16 Nov 2022 20:55:45 +0300 Subject: [PATCH 2/6] fix typo errors --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d25d6a5..4a1ef76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,6 @@ if(DEFINED CRC_LIBRARY) return() else() set(CRC_LIBRARY 1) - add_definitions(-DCRC_LIBRARY) endif() project(CRC) @@ -20,7 +19,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) option(BUILD_SHARED_LIBS "Enable or disable shared libraries" OFF) file(GLOB SOURCE_CPP - "crc/*.h" + "crc/*.h" "crc/*.cpp" "crc/*.c" ) From 36d8994094bfa0b403bb0e6adc0c67ce390654a8 Mon Sep 17 00:00:00 2001 From: Andrei Yankovich Date: Wed, 16 Nov 2022 21:06:44 +0300 Subject: [PATCH 3/6] Update README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index feb263b..627dd9f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,23 @@ # crc crc16/crc32/crc64 + +## Build + +``` bash +git clone https://github.com/gityf/crc.git +mkdir build +cd build +cmake .. -DBUILD_SHARED_LIBS=1 +make +``` + +## Include + +### Cmake build system + +``` cmake +add_subdirectory(crc) + +target_link_libraries(${PROJECT_NAME} PUBLIC crc) + +``` From 1cba3b53e502979365d5dbc0e1439d9e3023b01c Mon Sep 17 00:00:00 2001 From: Andrei Yankovich Date: Wed, 16 Nov 2022 23:33:53 +0300 Subject: [PATCH 4/6] Update CMakeLists.txt --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a1ef76..a2f270e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ else() set(CRC_LIBRARY 1) endif() -project(CRC) +project(crc) if(TARGET ${PROJECT_NAME}) message("The ${PROJECT_NAME} arledy included in main Project") @@ -25,5 +25,4 @@ file(GLOB SOURCE_CPP ) add_library(${PROJECT_NAME} ${SOURCE_CPP}) - - +target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) From 43a1b9291522f0ec78f5d9e45305ac96bed55318 Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 21 Nov 2022 22:36:10 +0300 Subject: [PATCH 5/6] added support tests cases --- CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2f270e..fcc07f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) option(BUILD_SHARED_LIBS "Enable or disable shared libraries" OFF) +option(CRC_TESTS "Enable tests of the ${PROJECT_NAME} library" OFF) file(GLOB SOURCE_CPP "crc/*.h" @@ -26,3 +27,21 @@ file(GLOB SOURCE_CPP add_library(${PROJECT_NAME} ${SOURCE_CPP}) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) + + +if (CRC_TESTS) + + file(GLOB SOURCE_CPP_TEST + "unit-test/*.h" + "unit-test/*.cpp" + "unit-test/*.c" + + "unit-test/ut/*.h" + "unit-test/ut/*.cpp" + "unit-test/ut/*.c" + ) + + add_executable(${PROJECT_NAME}_test ${SOURCE_CPP_TEST}) + target_link_libraries(${PROJECT_NAME}_test PUBLIC ${PROJECT_NAME}) + +endif() From 4d871007ffee57cfb1afa8bf399b703a2ef698af Mon Sep 17 00:00:00 2001 From: Andrei Yankovich Date: Tue, 22 Nov 2022 10:50:51 +0300 Subject: [PATCH 6/6] Update README.md --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 627dd9f..33a2269 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,26 @@ git clone https://github.com/gityf/crc.git mkdir build cd build -cmake .. -DBUILD_SHARED_LIBS=1 +cmake .. -DBUILD_SHARED_LIBS=1 -DCRC_TESTS=1 make ``` +## Testing + +``` bash +./crc_test +[ RUN ] ==== Test CRC8Test.BasicTest +[ RUN ] ==== Test CRC16Test.BasicTest +[ RUN ] ==== Test CRC32Test.BasicTest +[ RUN ] ==== Test CRC64Test.BasicTest +[ RUN ] ==== Test CRC8PolyTest.BasicTest +[ RUN ] ==== Test CRC16PolyTest.BasicTest +[ RUN ] ==== Test CRC32PolyTest.BasicTest +[ PASS ] ==== PASSED 7 tests +[ NOPASS ] ==== ERROR 0 tests + +``` + ## Include ### Cmake build system