diff --git a/CPP/CMakeLists.txt b/CPP/CMakeLists.txt index bb1e9244..22f0cb74 100644 --- a/CPP/CMakeLists.txt +++ b/CPP/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(Clipper2 LANGUAGES C CXX) +project(Clipper2 VERSION 1.0.4 LANGUAGES C CXX) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_CXX_STANDARD 17) @@ -10,6 +10,9 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) option(CLIPPER2_UTILS "Build utilities" ON) option(CLIPPER2_EXAMPLES "Build examples" ON) option(CLIPPER2_TESTS "Build tests" ON) +option(BUILD_SHARED_LIBS "Build shared libs" OFF) + +include(GNUInstallDirs) set(CLIPPER2_INC Clipper2Lib/clipper.core.h @@ -25,21 +28,19 @@ set(CLIPPER2_SRC ) # 2d version of Clipper2 -add_library(Clipper2 STATIC ${CLIPPER2_INC} ${CLIPPER2_SRC}) +add_library(Clipper2 ${CLIPPER2_SRC}) target_include_directories(Clipper2 PUBLIC Clipper2Lib - SYSTEM INTERFACE Clipper2Lib ) # Clipper2 but with USINGZ defined -add_library(Clipper2Z STATIC ${CLIPPER2_INC} ${CLIPPER2_SRC}) +add_library(Clipper2Z ${CLIPPER2_SRC}) target_compile_definitions(Clipper2Z PUBLIC USINGZ) target_include_directories(Clipper2Z PUBLIC Clipper2Lib - SYSTEM INTERFACE Clipper2Lib ) if (WIN32) @@ -53,7 +54,11 @@ else() target_link_libraries(Clipper2Z PUBLIC -lm) endif() -set_target_properties(Clipper2 Clipper2Z PROPERTIES FOLDER Libraries) +set_target_properties(Clipper2 Clipper2Z PROPERTIES FOLDER Libraries + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + PUBLIC_HEADER "${CLIPPER2_INC}" +) if(CLIPPER2_UTILS OR CLIPPER2_TESTS OR CLIPPER2_EXAMPLES) set(CLIPPER2_UTILS_INC @@ -67,24 +72,25 @@ if(CLIPPER2_UTILS OR CLIPPER2_TESTS OR CLIPPER2_EXAMPLES) Utils/ClipFileSave.cpp ) - add_library(Clipper2utils STATIC ${CLIPPER2_UTILS_INC} ${CLIPPER2_UTILS_SRC}) + add_library(Clipper2utils STATIC ${CLIPPER2_UTILS_SRC}) target_link_libraries(Clipper2utils PUBLIC Clipper2) target_include_directories(Clipper2utils PUBLIC Utils - SYSTEM INTERFACE Utils ) - add_library(Clipper2Zutils STATIC ${CLIPPER2_UTILS_INC} ${CLIPPER2_UTILS_SRC}) + add_library(Clipper2Zutils STATIC ${CLIPPER2_UTILS_SRC}) target_link_libraries(Clipper2Zutils PUBLIC Clipper2Z) target_include_directories(Clipper2Zutils PUBLIC Utils - SYSTEM INTERFACE Utils ) set_target_properties(Clipper2utils Clipper2Zutils PROPERTIES FOLDER Libraries) - +if (NOT WIN32) + target_compile_options(Clipper2utils PRIVATE -Wno-unused-variable -Wno-unused-function) + target_compile_options(Clipper2Zutils PRIVATE -Wno-unused-variable -Wno-unused-function) +endif() endif() if(CLIPPER2_EXAMPLES) @@ -140,6 +146,11 @@ if(CLIPPER2_TESTS) add_executable(ClipperTestsZ ${ClipperTests_SRC}) target_link_libraries(ClipperTestsZ gtest gtest_main Clipper2Z Clipper2Zutils) +if (NOT WIN32) + target_compile_options(ClipperTests PRIVATE -Wno-unused-variable -Wno-unused-function) + target_compile_options(ClipperTestsZ PRIVATE -Wno-unused-variable -Wno-unused-function) +endif() + set_target_properties(ClipperTests ClipperTestsZ PROPERTIES FOLDER Tests) gtest_discover_tests(ClipperTests @@ -161,10 +172,6 @@ if(CLIPPER2_TESTS) file(COPY ../Tests/Polygons.txt DESTINATION ${CMAKE_BINARY_DIR} FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ ) endif() -install(TARGETS Clipper2 Clipper2Z) - -install( - DIRECTORY Clipper2Lib/ - DESTINATION include - FILES_MATCHING PATTERN "*.h" +install(TARGETS Clipper2 Clipper2Z + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/clipper2 ) diff --git a/CPP/Utils/ClipFileSave.cpp b/CPP/Utils/ClipFileSave.cpp index 07e35c94..f918960e 100644 --- a/CPP/Utils/ClipFileSave.cpp +++ b/CPP/Utils/ClipFileSave.cpp @@ -64,7 +64,7 @@ class BMH_Search { while (current < end) { - uint8_t i = shift[*current]; //compare last byte first + uint8_t i = shift[(unsigned)*current]; //compare last byte first if (!i) //last byte matches if i == 0 { char* j = current - needle_len_less1; @@ -88,12 +88,12 @@ class BMH_Search { while (current < end) { - uint8_t i = shift[case_table[*current]]; + uint8_t i = shift[case_table[(unsigned)*current]]; if (!i) { char* j = current - needle_len_less1; while (i < needle_len_less1 && - needle_ic_[i] == case_table[*(j + i)]) ++i; + needle_ic_[i] == case_table[(unsigned)*(j + (unsigned)i)]) ++i; if (i == needle_len_less1) { ++current; @@ -154,8 +154,8 @@ class BMH_Search needle_ic_ = new uint8_t[needle_len_ +1]; std::memcpy(needle_ic_, needle_, needle_len_); uint8_t* c = needle_ic_; - for (uint8_t i = 0; i < needle_len_; ++i) - *c = case_table[*c++]; + for (uint8_t i = 0; i < needle_len_; ++i, c++) + *c = case_table[*c]; std::fill(std::begin(shift), std::begin(shift) + 256, needle_len_); for (uint8_t j = 0; j < needle_len_less1; ++j)