From a171418d2133226fe77a3afdb9639a1d1d66d047 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Wed, 17 Nov 2021 20:31:19 +0100 Subject: [PATCH 1/2] Update CMake Signed-off-by: Bensuperpc --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c80dba0..df3ae3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,22 +19,22 @@ include(cmake/variables.cmake) option(CRC32_USE_LOOKUP_TABLE_BYTE "Enable 1 byte crc32 function" ON) if(CRC32_USE_LOOKUP_TABLE_BYTE) - add_compile_definitions(CRC32_USE_LOOKUP_TABLE_BYTE) + add_definitions(-DCRC32_USE_LOOKUP_TABLE_BYTE) endif() option(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4 "Enable 4 byte crc32 function" ON) if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4) - add_compile_definitions(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4) + add_definitions(-DCRC32_USE_LOOKUP_TABLE_SLICING_BY_4) endif() option(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8 "Enable 8 byte crc32 function" ON) if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) - add_compile_definitions(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) + add_definitions(-DCRC32_USE_LOOKUP_TABLE_SLICING_BY_8) endif() option(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16 "Enable 16 byte crc32 function" ON) if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16) - add_compile_definitions(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16) + add_definitions(-DCRC32_USE_LOOKUP_TABLE_SLICING_BY_16) endif() # ---- Declare library ---- From 6efa1a06c6d5058dc08b1b7947bb9751fa731cd6 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Wed, 17 Nov 2021 22:29:17 +0100 Subject: [PATCH 2/2] Update CMake options Signed-off-by: Bensuperpc --- CMakeLists.txt | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df3ae3c..dbb2372 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,27 +15,12 @@ docs_early_return() include(cmake/project-is-top-level.cmake) include(cmake/variables.cmake) -# ---- Library variable ---- +# ---- Library options ---- option(CRC32_USE_LOOKUP_TABLE_BYTE "Enable 1 byte crc32 function" ON) -if(CRC32_USE_LOOKUP_TABLE_BYTE) - add_definitions(-DCRC32_USE_LOOKUP_TABLE_BYTE) -endif() - option(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4 "Enable 4 byte crc32 function" ON) -if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4) - add_definitions(-DCRC32_USE_LOOKUP_TABLE_SLICING_BY_4) -endif() - option(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8 "Enable 8 byte crc32 function" ON) -if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) - add_definitions(-DCRC32_USE_LOOKUP_TABLE_SLICING_BY_8) -endif() - option(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16 "Enable 16 byte crc32 function" ON) -if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16) - add_definitions(-DCRC32_USE_LOOKUP_TABLE_SLICING_BY_16) -endif() # ---- Declare library ---- @@ -55,10 +40,38 @@ generate_export_header( CUSTOM_CONTENT_FROM_VARIABLE pragma_suppress_c4251 ) +# ---- Library variables ---- + if(NOT BUILD_SHARED_LIBS) target_compile_definitions(crc32_crc32 PUBLIC CRC32_STATIC_DEFINE) endif() +if(CRC32_USE_LOOKUP_TABLE_BYTE) + target_compile_definitions(crc32_crc32 PUBLIC CRC32_USE_LOOKUP_TABLE_BYTE) +else() + message(STATUS "CRC32_USE_LOOKUP_TABLE_BYTE is disable") +endif() + +if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4) + target_compile_definitions(crc32_crc32 PUBLIC CRC32_USE_LOOKUP_TABLE_SLICING_BY_4) +else() + message(STATUS "DCRC32_USE_LOOKUP_TABLE_SLICING_BY_4 is disable") +endif() + +if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) + target_compile_definitions(crc32_crc32 PUBLIC CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) +else() + message(STATUS "DCRC32_USE_LOOKUP_TABLE_SLICING_BY_8 is disable") +endif() + +if(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16) +target_compile_definitions(crc32_crc32 PUBLIC CRC32_USE_LOOKUP_TABLE_SLICING_BY_16) +else() + message(STATUS "DCRC32_USE_LOOKUP_TABLE_SLICING_BY_16 is disable") +endif() + +# ---- Library properties ---- + set_target_properties( crc32_crc32 PROPERTIES CXX_VISIBILITY_PRESET hidden